checkItemModule.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <!--
  2. //参数说明
  3. propsData参数下
  4. infoType 为必要参数 0.检查 1.复查 2.整改
  5. checkType 为必要参数 infoType为0时 代表检查状态 为1时代表复查状态 为2时代表整改状态
  6. //检查时的必要参数
  7. manageId
  8. //复查时的必要参数
  9. planId
  10. planSetId
  11. subId
  12. //隐患时的必要参数
  13. planId
  14. planSetId
  15. subId
  16. //引用方法
  17. <checkItemModule :propsData="propsData" v-if="checkItemModuleType"></checkItemModule>
  18. import {
  19. checkItemModule
  20. } from '@/pages/checkItemModule.vue'
  21. components: {
  22. checkItemModule
  23. },
  24. checkItemModuleType:false,
  25. propsData:{
  26. infoType:0,
  27. manageId:'1839113478692855815',
  28. checkType:0,
  29. planId:'',
  30. planSetId:'',
  31. subId:'',
  32. searchValue:'',
  33. },
  34. checkItemModuleButton(type,item){
  35. if(type = 'open'){
  36. this.$set(this,'propsData',{
  37. infoType:0,
  38. manageId:'1839113478692855815',
  39. checkType:0,
  40. planId:'',
  41. planSetId:'',
  42. subId:'',
  43. searchValue:'',
  44. });
  45. this.$set(this,'checkItemModuleType',true);
  46. }else if(type = 'out'){
  47. this.$set(this,'checkItemModuleType',false);
  48. this.$set(this,'propsData',{});
  49. }else if(type = 'submit'){
  50. console.log('已选中-item', item)
  51. }
  52. },
  53. -->
  54. <template>
  55. <scroll-view scroll-y style="overflow-y: scroll;">
  56. <view class="checkItemModule">
  57. <!-- 标签选项卡 -->
  58. <view class="checkItemModule-title-box">
  59. <view class="checkItemModule-title-p" @click="checkTitleButton(1)"
  60. :class="pageType==1?'.checkItemModule-title-check':''">
  61. <view>关键字</view>
  62. <view></view>
  63. </view>
  64. <view class="checkItemModule-title-p" @click="checkTitleButton(2)"
  65. :class="pageType==2?'.checkItemModule-title-check':''">
  66. <view>按层级</view>
  67. <view></view>
  68. </view>
  69. </view>
  70. <!-- 输入搜索模块 -->
  71. <view class="input-max-big-box" v-if="pageType == 1">
  72. <view class="input-big-box">
  73. <view class="input-box">
  74. <view class="left-icons">
  75. <uni-icons color="#A2A2A2" type="search" size="20"></uni-icons>
  76. </view>
  77. <input type="text" v-model="searchValue" placeholder="搜索检查项" name="search" @confirm='getSearchValue'
  78. confirm-type='search' @input="theBlur" maxlength="50"
  79. placeholder-style="color: #666;font-size:24rpx;">
  80. <view v-if="searchValue" class="left-icons" @click="delSearchValue()">
  81. <uni-icons color="#0183FA" type="clear" size="20"></uni-icons>
  82. </view>
  83. </view>
  84. <view class="out-button" @click="outButton()">取消</view>
  85. </view>
  86. <view class="input-for-max-box">
  87. <view class="for-box" v-for="(item,index) in dataList" :key="index" v-if="optionData.infoType==0">
  88. <view class="for-box-n" v-html="brightenKeyword(item.hazardCheckCode1,item.hazardCheckName1,searchValue)">
  89. {{item.hazardCheckCode1}}{{item.hazardCheckName1}}
  90. </view>
  91. <view class="for-box-n" v-html="brightenKeyword(item.hazardCheckCode2,item.hazardCheckName2,searchValue)">
  92. {{item.hazardCheckCode2}}{{item.hazardCheckName2}}
  93. </view>
  94. <view v-for="(item2,index2) in item.data">
  95. <view class="for-box-n" v-html="brightenKeyword(item2.hazardCheckCode,item2.hazardCheckName,searchValue)">
  96. {{item2.hazardCheckCode}}{{item2.hazardCheckName}}
  97. </view>
  98. <view class="for-box-n" @click="checkItemButton(item2,item3)"
  99. v-for="(item3,index3) in item2.hazardCheckPointList" v-html="brightenKeyword('',item3,searchValue)">
  100. {{item3}}
  101. </view>
  102. </view>
  103. </view>
  104. <view class="for-box" @click="checkItemButton(item,'')" v-for="(item,index) in dataList" :key="index"
  105. v-if="optionData.infoType==1 || optionData.infoType==2">
  106. <view class="for-box-n">
  107. {{item.hazardCheckCode}}{{item.hazardCheckName}}
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. <!-- 级联选择模块 -->
  113. <view class="check-max-big-box" v-if="pageType == 2">
  114. <view class="check-big-box">
  115. <view v-if="levelListOne" @click="cascadeButton(1)">一级检查</view>
  116. <view v-if="levelListTwo" @click="cascadeButton(2)">二级检查</view>
  117. <view v-if="levelListThree" @click="cascadeButton(3)">三级检查</view>
  118. </view>
  119. <view class="check-for-max-box">
  120. <view v-if="!levelListThree" v-for="(item,index) in checkList" :key="index" @click="cascadeItemButton(item,item2)">
  121. <view>{{item.hazardCheckCode?item.hazardCheckCode:item.code}}
  122. {{item.hazardCheckName?item.hazardCheckName:item.name}}
  123. </view>
  124. </view>
  125. <view v-for="(item,index) in checkList" :key="index" v-if="levelListThree">
  126. <view>{{item.hazardCheckCode?item.hazardCheckCode:item.code}}
  127. {{item.hazardCheckName?item.hazardCheckName:item.name}}
  128. </view>
  129. <view v-for="(item2,index2) in item.hazardCheckPointList" @click="checkItemButton(item,item2)">
  130. {{item2}}
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </view>
  136. </scroll-view>
  137. </template>
  138. <script>
  139. import {
  140. securityCheckOptionSelAllList,
  141. securityAppCheckSetOptionList,
  142. securityAppCheckSetOptionGetReviewList,
  143. securityAppCheckDangerGetCheckDangerSubId,
  144. } from '@/pages_safetyCheck/api/index.js'
  145. export default {
  146. name: "checkItemModule",
  147. props: {
  148. propsData: {}
  149. },
  150. data() {
  151. return {
  152. //父级参数
  153. optionData: {},
  154. //选项卡状态
  155. pageType: 1,
  156. //输入框数据
  157. searchValue: "",
  158. //输入搜索返回列表
  159. dataList: [],
  160. //一级-级联数据
  161. levelListOne: null,
  162. //二级-级联数据
  163. levelListTwo: null,
  164. //三级-级联数据
  165. levelListThree: null,
  166. //级联列表
  167. checkList: [],
  168. }
  169. },
  170. onLoad() {
  171. },
  172. mounted() {
  173. this.$set(this, 'optionData', JSON.parse(JSON.stringify(this.propsData)));
  174. console.log('检查项列表',this.optionData)
  175. this.$nextTick(() => {
  176. this.securityCheckOptionSelAllList();
  177. })
  178. },
  179. methods: {
  180. theBlur(e) {
  181. this.searchValue = e.target.value
  182. },
  183. //输入框查询
  184. getSearchValue() {
  185. if (this.optionData.infoType == 0) {
  186. //检查
  187. this.securityAppCheckSetOptionList();
  188. } else if (this.optionData.infoType == 1) {
  189. //复查
  190. this.securityAppCheckSetOptionGetReviewList();
  191. } else if (this.optionData.infoType == 2) {
  192. //整改
  193. this.securityAppCheckDangerGetCheckDangerSubId();
  194. }
  195. },
  196. //选项卡title切换
  197. checkTitleButton(type) {
  198. if (this.pageType != type) {
  199. this.$set(this, 'pageType', type);
  200. }
  201. },
  202. //退出页面
  203. outButton() {
  204. this.$parent.checkItemModuleButton('out');
  205. },
  206. //清除输入框内容
  207. delSearchValue() {
  208. if (this.searchValue) {
  209. this.$set(this, 'searchValue', '');
  210. this.$set(this, 'dataList', []);
  211. this.getSearchValue();
  212. }
  213. },
  214. //级联等级点击
  215. cascadeButton(type) {
  216. if (type == 1) {
  217. this.$set(this, 'levelListTwo', null);
  218. this.$set(this, 'levelListThree', null);
  219. this.$set(this, 'checkList', this.levelListOne.children);
  220. } else if (type == 2) {
  221. this.$set(this, 'levelListThree', null);
  222. this.$set(this, 'checkList', this.levelListTwo.children);
  223. }
  224. },
  225. //级联检查项选中
  226. cascadeItemButton(item) {
  227. if (item.level == 1) {
  228. this.$set(this, 'levelListTwo', item);
  229. this.$set(this, 'checkList', item.children);
  230. } else if (item.level == 2) {
  231. this.$set(this, 'levelListThree', item);
  232. if (item.children[0]) {
  233. item.children.forEach(function(item) {
  234. if (item.hazardCheckPoint) {
  235. item.hazardCheckPointList = item.hazardCheckPoint.split('#')
  236. }
  237. })
  238. }
  239. this.$set(this, 'checkList', item.children);
  240. } else if (item.level == 3) {
  241. this.checkItemButton(item, item2);
  242. }
  243. },
  244. //选中检查项
  245. checkItemButton(item, item2) {
  246. this.$parent.checkItemModuleButton('submit', item, item2);
  247. },
  248. //高亮
  249. brightenKeyword(code,val, editKeyword) {
  250. const Reg = new RegExp(editKeyword);
  251. if (val) {
  252. const res = code+ val.replace(Reg, `<span style="color: #0183FA;">${editKeyword }</span>`);
  253. return res;
  254. }
  255. },
  256. //基础检查项检查
  257. async securityCheckOptionSelAllList() {
  258. let self = this;
  259. const {
  260. data
  261. } = await securityCheckOptionSelAllList({});
  262. if (data.code == 200) {
  263. let maxList = this.getCascaderData(JSON.parse(JSON.stringify(data.data)), 2)
  264. this.$nextTick(() => {
  265. if (this.optionData.infoType == 0) {
  266. this.securityAppCheckSetOptionList(maxList);
  267. } else if (this.optionData.infoType == 1) {
  268. this.securityAppCheckSetOptionGetReviewList(maxList);
  269. } else if (this.optionData.infoType == 2) {
  270. this.securityAppCheckDangerGetCheckDangerSubId(maxList);
  271. }
  272. })
  273. }
  274. },
  275. /********************** 检查相关查询 **********************/
  276. async securityAppCheckSetOptionList(maxList) {
  277. let self = this;
  278. const {
  279. data
  280. } = await securityAppCheckSetOptionList({
  281. manageId: this.optionData.manageId,
  282. checkStatus: this.optionData.checkType,
  283. searchValue: this.searchValue
  284. });
  285. if (data.code == 200) {
  286. //级联数据
  287. if (maxList) {
  288. let minList = JSON.parse(JSON.stringify(data.data))
  289. this.cascadeData(maxList, minList);
  290. }
  291. if(this.optionData.editStatus){
  292. data.data.unshift(this.optionData.editItem);
  293. }
  294. if (data.data[0]) {
  295. data.data.forEach(function(item) {
  296. if (item.hazardCheckPoint) {
  297. item.hazardCheckPointList = item.hazardCheckPoint.split('#')
  298. }
  299. })
  300. }
  301. //查询数据
  302. let map = new Map();
  303. for (let item of data.data) {
  304. let hazardCheckCode2 = item.hazardCheckCode2;
  305. if (!map.has(hazardCheckCode2)) {
  306. map.set(hazardCheckCode2, {
  307. hazardCheckCode2: hazardCheckCode2,
  308. hazardCheckName2: item.hazardCheckName2,
  309. hazardCheckCode1: item.hazardCheckCode1,
  310. hazardCheckName1: item.hazardCheckName1,
  311. data: [item]
  312. });
  313. } else {
  314. map.get(hazardCheckCode2).data.push(item);
  315. }
  316. }
  317. let finalResult = Array.from(map.values());
  318. this.$set(this, 'dataList', finalResult);
  319. }
  320. },
  321. /********************** 复查相关查询 **********************/
  322. async securityAppCheckSetOptionGetReviewList(maxList) {
  323. let self = this;
  324. const {
  325. data
  326. } = await securityAppCheckSetOptionGetReviewList({
  327. planId: this.optionData.planId,
  328. planSetId: this.optionData.planSetId,
  329. subId: this.optionData.subId,
  330. appReviewStatus: this.optionData.checkType,
  331. searchValue: this.searchValue
  332. });
  333. if (data.code == 200) {
  334. //级联数据
  335. if (maxList) {
  336. let minList = JSON.parse(JSON.stringify(data.data.records))
  337. this.cascadeData(maxList, minList);
  338. }
  339. //查询数据
  340. this.$set(this, 'dataList', JSON.parse(JSON.stringify(data.data.records)));
  341. }
  342. },
  343. /********************** 整改相关查询 **********************/
  344. async securityAppCheckDangerGetCheckDangerSubId(maxList) {
  345. let self = this;
  346. const {
  347. data
  348. } = await securityAppCheckDangerGetCheckDangerSubId({
  349. planId: this.optionData.planId,
  350. planSetId: this.optionData.planSetId,
  351. subId: this.optionData.subId,
  352. appReviewStatus: this.optionData.checkType,
  353. searchValue: this.searchValue
  354. });
  355. if (data.code == 200) {
  356. //级联数据
  357. if (maxList) {
  358. let minList = JSON.parse(JSON.stringify(data.data.records))
  359. this.cascadeData(maxList, minList);
  360. }
  361. //查询数据
  362. this.$set(this, 'dataList', JSON.parse(JSON.stringify(data.data.records)));
  363. }
  364. },
  365. /********************** 处理级联数据 **********************/
  366. cascadeData(maxList, minList) {
  367. for (let i = 0; i < maxList.length; i++) {
  368. for (let o = 0; o < maxList[i].children.length; o++) {
  369. for (let x = 0; x < minList.length; x++) {
  370. if (maxList[i].children[o].id == minList[x].hazardCheckPro2) {
  371. minList[x].level = 3;
  372. if (maxList[i].children[o].children) {
  373. maxList[i].children[o].children.push(minList[x])
  374. } else {
  375. maxList[i].children[o].children = [minList[x]]
  376. }
  377. }
  378. }
  379. }
  380. }
  381. let list = this.getCascaderData(JSON.parse(JSON.stringify(maxList)), 3)
  382. this.$nextTick(() => {
  383. this.$set(this, 'levelListOne', JSON.parse(JSON.stringify({
  384. level: 0,
  385. children: list
  386. })));
  387. this.$set(this, 'checkList', JSON.parse(JSON.stringify(list)));
  388. })
  389. },
  390. /********************** 检查项格式处理 **********************/
  391. getCascaderData(list, type) {
  392. let self = this
  393. for (let i = 0; i < list.length; i++) {
  394. if (list[i].level == type) {
  395. delete list[i].children
  396. } else if (list[i].children) {
  397. if (list[i].children[0]) {
  398. list[i].children = self.getCascaderData(list[i].children, type)
  399. } else {
  400. list.splice(i, 1)
  401. i--
  402. }
  403. } else {
  404. list.splice(i, 1)
  405. i--
  406. }
  407. }
  408. for (let i = 0; i < list.length; i++) {
  409. if (list[i].level == type) {
  410. delete list[i].children
  411. } else if (list[i].children) {
  412. if (list[i].children[0]) {
  413. list[i].children = self.getCascaderData(list[i].children, type)
  414. } else {
  415. list.splice(i, 1)
  416. i--
  417. }
  418. } else {
  419. list.splice(i, 1)
  420. i--
  421. }
  422. }
  423. for (let i = 0; i < list.length; i++) {
  424. if (list[i].level == type) {
  425. delete list[i].children
  426. } else if (list[i].children) {
  427. if (list[i].children[0]) {
  428. list[i].children = self.getCascaderData(list[i].children, type)
  429. } else {
  430. list.splice(i, 1)
  431. i--
  432. }
  433. } else {
  434. list.splice(i, 1)
  435. i--
  436. }
  437. }
  438. return list
  439. },
  440. }
  441. }
  442. </script>
  443. <style lang="stylus" scoped>
  444. .checkItemModule {
  445. position: fixed;
  446. top: 0;
  447. left: 0;
  448. height: 100%;
  449. width: 100%;
  450. flex: 1;
  451. overflow: hidden;
  452. display: flex;
  453. flex-direction: column;
  454. background-color: #fff;
  455. .checkItemModule-title-box {
  456. display: flex;
  457. height: 100rpx;
  458. background-color: #FFFFFF;
  459. border-bottom: 1rpx solid #dedede;
  460. .checkItemModule-title-p {
  461. width: 140rpx;
  462. height: 100rpx;
  463. >view:nth-child(1) {
  464. color: #333;
  465. text-align: center;
  466. font-size: 29rpx;
  467. line-height: 30rpx;
  468. margin: 35rpx 0 20rpx 0;
  469. }
  470. >view:nth-child(2) {
  471. width: 56rpx;
  472. height: 6rpx;
  473. border-radius: 14rpx;
  474. margin: 0 auto;
  475. }
  476. }
  477. .checkItemModule-title-check {
  478. >view:nth-child(1) {
  479. color: #0183FA;
  480. }
  481. >view:nth-child(2) {
  482. background: #0183FA;
  483. }
  484. }
  485. }
  486. .input-max-big-box {
  487. flex: 1;
  488. display: flex;
  489. flex-direction: column;
  490. overflow: hidden;
  491. .input-big-box {
  492. height: 104rpx;
  493. display: flex;
  494. background-color: #fff;
  495. border-bottom: 1rpx solid #E0E0E0;
  496. .input-box {
  497. width: 611rpx;
  498. height: 69rpx;
  499. border: 1px solid #E0E0E0;
  500. display: flex;
  501. border-radius: 35px 35px 35px 35px;
  502. margin: 17rpx 0 17rpx 21rpx;
  503. .left-icons {
  504. padding: 15rpx 18rpx 0 22rpx;
  505. }
  506. .right-icons {
  507. padding: 15rpx 15rpx 0 22rpx;
  508. }
  509. >input {
  510. flex: 1;
  511. height: 69rpx;
  512. line-height: 69rpx;
  513. }
  514. }
  515. .out-button {
  516. width: 100rpx;
  517. margin: 17rpx 0 17rpx 15rpx;
  518. text-align: center;
  519. line-height: 69rpx;
  520. color: #0183FA;
  521. font-size: 29rpx;
  522. }
  523. }
  524. .input-for-max-box {
  525. flex: 1;
  526. display: flex;
  527. flex-direction: column;
  528. overflow-y: scroll;
  529. background-color: #fff;
  530. .for-box {
  531. .for-box-n {
  532. margin: 0 21rpx;
  533. font-size: 32rpx;
  534. line-height: 40rpx;
  535. padding: 20rpx 0;
  536. background-color: #fff;
  537. border-bottom: 1rpx solid #E0E0E0;
  538. }
  539. }
  540. }
  541. }
  542. .check-max-big-box {
  543. flex: 1;
  544. display: flex;
  545. flex-direction: column;
  546. overflow: hidden;
  547. .check-big-box {
  548. height: 70rpx;
  549. display: flex;
  550. background-color: #fff;
  551. border-bottom: 1rpx solid #E0E0E0;
  552. >view {
  553. width: 200rpx;
  554. line-height: 70rpx;
  555. text-align: center;
  556. color: #333;
  557. font-size: 29rpx;
  558. }
  559. .checkView {
  560. color: #0183FA;
  561. }
  562. }
  563. .check-for-max-box {
  564. flex: 1;
  565. display: flex;
  566. flex-direction: column;
  567. overflow-y: scroll;
  568. background-color: #fff;
  569. >view {
  570. >view {
  571. font-size: 32rpx;
  572. line-height: 70rpx;
  573. margin: 0 21rpx;
  574. border-bottom: 1px solid #dedede;
  575. }
  576. }
  577. }
  578. }
  579. }
  580. </style>