smartSearch.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view>
  3. <!-- 头部 -->
  4. <cu-custom bgColor="bg-blue" :isBack="true">
  5. <block slot="backText">智能查阅</block>
  6. <block slot="content"></block>
  7. <block slot="right">
  8. <view class=" flex justify-center" >
  9. <button @click="search()" class="margin-top-ssm cu-btn round line-blue text-white">
  10. <image class="login-img" src="/static/index/search-white.png"></image>搜索
  11. </button>
  12. </view>
  13. </block>
  14. </cu-custom>
  15. <scroll-view scroll-y="true" style="margin-bottom: 300rpx;">
  16. <view v-for="(item,index) in treeData" :key="item.id" class="treeData_b">
  17. <view class="treeData_1" @click="treeTap(index+1,item)">
  18. <view style="font-weight: bold;font-size: 34rpx;" :class="item.selected?'indexColor':''">{{item.name}}</view>
  19. <view v-if="item.children.length>0">
  20. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="show == index + 1"></image>
  21. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="show != index + 1 || show == 0"></image>
  22. </view>
  23. </view>
  24. <view v-for="(second,seconds) in item.children" :key="second.id" v-if="show == index + 1">
  25. <view class="treeData_1s treeData_2" @click="secondTap(seconds + 1,second)">
  26. <view :class="second.selected?'indexColor':''">{{second.name}}</view>
  27. <view v-if="second.children.length>0">
  28. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showsecond == seconds + 1"></image>
  29. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showsecond != seconds + 1 || showsecond == 0"></image>
  30. </view>
  31. </view>
  32. <view v-if="showsecond == seconds + 1" :style="{'padding-bottom': second.children.length>0 ? '22rpx':''}">
  33. <view v-for="(three,threes) in second.children" :key="three.id" class="treeData_three">
  34. <view class="treeData_1s treeData_3" @click="threeTap(threes + 1,three)">
  35. <view :class="three.selected?'indexColor':''">{{three.name}}</view>
  36. <view v-if="three.children.length>0">
  37. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showthree == threes + 1"></image>
  38. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showthree != threes + 1 || showthree == 0"></image>
  39. </view>
  40. </view>
  41. <view v-if="showthree == threes + 1" v-for="(four,fours) in three.children" :key="four.id">
  42. <view class="treeData_1s treeData_3" @click="fourTap(fours + 1,four)">
  43. <view style="padding-left: 22rpx;" :class="four.selected?'indexColor':''"><text style="margin-right: 10rpx;">◈</text>{{four.name}}</view>
  44. <view v-if="four.children.length>0">
  45. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showfour == fours + 1"></image>
  46. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showfour != fours + 1 || showfour == 0"></image>
  47. </view>
  48. </view>
  49. <view v-if="showfour == fours + 1" v-for="(five,fives) in four.children" :key="five.id">
  50. <view class="treeData_1s treeData_3" @click="fiveTap(fives + 1,five)">
  51. <view style="padding-left: 44rpx;" :class="five.selected?'indexColor':''"><text style="margin-right: 10rpx;">➣</text>{{five.name}}</view>
  52. <view v-if="five.children.length>0">
  53. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showfive == fives + 1"></image>
  54. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showfive != fives + 1 || showfive == 0"></image>
  55. </view>
  56. </view>
  57. <view v-if="showfive == fives + 1" v-for="(six,sixs) in five.children" :key="six.id">
  58. <view class="treeData_1s treeData_3" @click="sixTap(sixs + 1,six)">
  59. <view style="padding-left: 66rpx;" :class="six.selected?'indexColor':''"><text style="margin-right: 10rpx;">•</text>{{six.name}}</view>
  60. <view v-if="six.children.length>0">
  61. <image src="/static/information/shang.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showsix == sixs + 1"></image>
  62. <image src="/static/information/xia.png" style="width: 40rpx;height: 40rpx;vertical-align: middle;" v-if="showsix != sixs + 1 || showsix == 0"></image>
  63. </view>
  64. </view>
  65. <view v-if="showsix == sixs + 1" v-for="(seven,sevens) in six.children" :key="seven.id">
  66. <view class="treeData_1s treeData_3" @click="sevenTap(sevens + 1,seven)">
  67. <view style="padding-left: 88rpx;" :class="seven.selected?'indexColor':''">{{seven.name}}</view>
  68. </view>
  69. </view>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. </view>
  76. </view>
  77. </scroll-view>
  78. <!-- 底部-->
  79. <view v-if="modalShow" class="shadow foot" style="background-color: #0A8CD5;color: #fff;position: fixed; z-index: 999; bottom: 0;width: 100%;padding-bottom: calc(var(--window-bottom) + 15px);">
  80. <view class="padding-sm solid-bottom-type" style="display: flex;align-items: center;position: absolute;left: 0;right: 0;top: -80rpx;height: 80rpx;opacity: 0.9;background-image: linear-gradient(#91C9E8, #0A8CD5);box-shadow: 0px -1px 2px #D0D0D0;">
  81. <image class="login-img" src="/static/index/label.png"></image>
  82. <view style="overflow-x: scroll;width: 680rpx;margin-left: 16rpx;">
  83. <view class="text-white" style="white-space : nowrap;font-weight: bold;">{{path}}</view>
  84. </view>
  85. </view>
  86. <view class="padding-sm flex justify-between" @click="navTo()" style="margin-top: 16rpx;">
  87. <view v-for="(item,index) in fileType" :key="index">
  88. <image v-if="item==1" class="menuImageTask margin-right-sm" src="/static/task/excel.png"></image>
  89. <image v-if="item==2" class="menuImageTask margin-right-sm" src="/static/task/word.png"></image>
  90. <image v-if="item==3" class="menuImageTask margin-right-sm" src="/static/task/pdf.png"></image>
  91. <image v-if="item==4" class="menuImageTask margin-right-sm" src="/static/task/image.png"></image>
  92. </view>
  93. <view class="margin-top-sm">
  94. <text class="text-white text-xl" >共{{fileData.length}}个文件</text>
  95. </view>
  96. <view class="margin-top-sm">
  97. <text class="cuIcon-right margin-left" style="font-size: 26px;"></text>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. <script>
  104. export default {
  105. data() {
  106. return {
  107. treeData: [],
  108. modalShow:false,
  109. show: 0, //一级状态
  110. showsecond: 0, //二级状态
  111. showthree: 0, //三级状态
  112. showfour: 0, //四级状态
  113. showfive: 0, //五级状态
  114. showsix: 0, //六级状态
  115. showseven: 0, //七级状态
  116. path:"",
  117. chooseData:[],
  118. fileData:[],
  119. fileType:[],
  120. }
  121. },
  122. onLoad(e) {
  123. var projectId = uni.getStorageSync("porject"+"_"+uni.getStorageSync("userInfo").id).id;
  124. if(e.value){//扫码进行的
  125. projectId = e.value.split(",")[1];
  126. this.findDataProgress(projectId,0);
  127. }else{
  128. this.findDataProgress(projectId,1);
  129. }
  130. },
  131. methods: {
  132. search(){
  133. uni.setStorageSync("pageType",4);//区分搜索页面跳转
  134. if(this.treeData!=''){
  135. uni.setStorageSync("fileId",this.treeData[0].id)
  136. uni.navigateTo({
  137. url:"/pages/search/search"
  138. })
  139. }else{
  140. this.$prompt.none("暂无数据,不可搜索")
  141. }
  142. },
  143. findDataProgress(projectId,type) {
  144. var that = this;
  145. that.http.request('/app/divideClient/findDataByProjectId', {
  146. projectIdOrFileID: projectId,
  147. type:type
  148. }).then((result) => {
  149. if (result.data!= null) {
  150. that.treeData = result.data.children;
  151. /* that.text(that.treeData); */
  152. }else{
  153. that.$prompt.none(result.msg);
  154. }
  155. })
  156. },
  157. filterNode(value, data) {
  158. if (!value) return true;
  159. return data.label.indexOf(value) !== -1;
  160. },
  161. handleNodeClick(obj) {
  162. var that=this;
  163. that.fileData=[];
  164. that.fileType=[];
  165. that.modalShow=false;
  166. that.http.request("/app/divideClient/findFile",{nodeId:obj.id}).then((res)=>{
  167. if(res.datas.length!=0){
  168. that.fileData=res.datas;
  169. that.fileData.forEach((item)=>{
  170. that.fileType.push(item.fileType);
  171. });
  172. that.fileType = that.unique(that.fileType);
  173. that.findNodePath(obj.id);
  174. }else{
  175. that.$prompt.none("该节点没有文件");
  176. that.modalShow=false;
  177. }
  178. })
  179. this.chooseData = obj;
  180. },
  181. findNodePath(id){
  182. var that=this;
  183. that.http.request("/app/divideClient/selectNodeTreeByFile",{id:id}).then((res)=>{
  184. that.path="";
  185. res.datas.forEach((item)=>{
  186. if(item.parentId!=0){
  187. that.path += " / "+item.name;
  188. }
  189. })
  190. that.modalShow=true;
  191. })
  192. },
  193. // 数组去重
  194. unique(arr){
  195.   let hash=[];
  196.   for (let i = 0; i < arr.length; i++) {
  197.     if(hash.indexOf(arr[i]) === -1){
  198.       hash.push(arr[i]);
  199.     }
  200.   }
  201. return hash;
  202. },
  203. navTo(){
  204. uni.navigateTo({
  205. url:"/pages/documentList/documentList?title="+this.path+"&id="+this.chooseData.id
  206. })
  207. },
  208. treeTap(e,r) {
  209. this.text(this.treeData)
  210. r.selected = true;
  211. if (this.show == e) {
  212. this.show = 0
  213. } else {
  214. this.show = e
  215. }
  216. this.handleNodeClick(r);
  217. },
  218. secondTap(e,r) {
  219. this.text(this.treeData)
  220. r.selected = true;
  221. if (this.showsecond == e) {
  222. this.showsecond = 0
  223. } else {
  224. this.showsecond = e
  225. }
  226. this.handleNodeClick(r);
  227. },
  228. threeTap(e,r) {
  229. this.text(this.treeData)
  230. r.selected = true;
  231. if (this.showthree == e) {
  232. this.showthree = 0
  233. } else {
  234. this.showthree = e
  235. }
  236. this.handleNodeClick(r);
  237. },
  238. fourTap(e,r) {
  239. this.text(this.treeData);
  240. this.$set(r,"selected",true);
  241. if (this.showfour == e) {
  242. this.showfour = 0
  243. } else {
  244. this.showfour = e
  245. }
  246. this.handleNodeClick(r);
  247. },
  248. fiveTap(e,r) {
  249. this.text(this.treeData);
  250. this.$set(r,"selected",true);
  251. if (this.showfive == e) {
  252. this.showfive = 0
  253. } else {
  254. this.showfive = e
  255. }
  256. this.handleNodeClick(r);
  257. },
  258. sixTap(e,r) {
  259. this.text(this.treeData)
  260. r.selected = true;
  261. if (this.showsix == e) {
  262. this.showsix = 0
  263. } else {
  264. this.showsix = e
  265. }
  266. this.handleNodeClick(r);
  267. },
  268. sevenTap(e,r) {
  269. this.text(this.treeData)
  270. r.selected = true;
  271. if (this.showseven == e) {
  272. this.showseven = 0
  273. } else {
  274. this.showseven = e
  275. }
  276. this.handleNodeClick(r);
  277. },
  278. text(data) {
  279. var that = this;
  280. data.forEach((item) => {
  281. item.selected = false;
  282. if (item.children.length > 0) {
  283. that.text(item.children);
  284. }
  285. })
  286. that.treeData = data;
  287. }
  288. }
  289. }
  290. </script>
  291. <style>
  292. .solid-bottom-type {
  293. border-bottom: 1upx solid white;
  294. }
  295. .solid-bottom-btn {
  296. border: 1upx solid white;
  297. }
  298. .treeData_b {
  299. margin: 12rpx 22rpx 0;
  300. background-color: #fff;
  301. border-radius: 10rpx;
  302. padding: 0 22rpx;
  303. }
  304. .treeData_1 {
  305. font-size: 30rpx;
  306. color: #101010;
  307. height: 88rpx;
  308. display: flex;
  309. justify-content: space-between;
  310. align-items: center;
  311. }
  312. .treeData_1s {
  313. font-size: 30rpx;
  314. color: #101010;
  315. display: flex;
  316. justify-content: space-between;
  317. align-items: center;
  318. padding: 22upx 0;
  319. min-height: 88rpx;
  320. }
  321. .treeData_2 {
  322. border-top: 1upx dashed #E3E1E1;
  323. }
  324. .treeData_3 {
  325. border-top: 1upx dashed #E3E1E1;
  326. }
  327. .treeData_three {
  328. background-color: #F7F7F7;
  329. padding: 0 22rpx;
  330. border-radius: 10rpx;
  331. margin-bottom: 22;
  332. }
  333. .treeData_three:first-child {
  334. border-radius: 10rpx 10rpx 0 0;
  335. }
  336. .treeData_three:last-child {
  337. border-radius: 0 0 10rpx 10rpx;
  338. }
  339. .indexColor {
  340. color: #0A8CD5;
  341. font-weight: bold;
  342. }
  343. .padding-sm{
  344. padding:20rpx 22rpx;
  345. }
  346. </style>