checkItemModule.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. this.$nextTick(() => {
  175. this.securityCheckOptionSelAllList();
  176. })
  177. },
  178. methods: {
  179. theBlur(e) {
  180. this.searchValue = e.target.value
  181. },
  182. //输入框查询
  183. getSearchValue() {
  184. if (this.optionData.infoType == 0) {
  185. //检查
  186. this.securityAppCheckSetOptionList();
  187. } else if (this.optionData.infoType == 1) {
  188. //复查
  189. this.securityAppCheckSetOptionGetReviewList();
  190. } else if (this.optionData.infoType == 2) {
  191. //整改
  192. this.securityAppCheckDangerGetCheckDangerSubId();
  193. }
  194. },
  195. //选项卡title切换
  196. checkTitleButton(type) {
  197. if (this.pageType != type) {
  198. this.$set(this, 'pageType', type);
  199. }
  200. },
  201. //退出页面
  202. outButton() {
  203. this.$parent.checkItemModuleButton('out');
  204. },
  205. //清除输入框内容
  206. delSearchValue() {
  207. if (this.searchValue) {
  208. this.$set(this, 'searchValue', '');
  209. this.$set(this, 'dataList', []);
  210. this.getSearchValue();
  211. }
  212. },
  213. //级联等级点击
  214. cascadeButton(type) {
  215. if (type == 1) {
  216. this.$set(this, 'levelListTwo', null);
  217. this.$set(this, 'levelListThree', null);
  218. this.$set(this, 'checkList', this.levelListOne.children);
  219. } else if (type == 2) {
  220. this.$set(this, 'levelListThree', null);
  221. this.$set(this, 'checkList', this.levelListTwo.children);
  222. }
  223. },
  224. //级联检查项选中
  225. cascadeItemButton(item) {
  226. if (item.level == 1) {
  227. this.$set(this, 'levelListTwo', item);
  228. this.$set(this, 'checkList', item.children);
  229. } else if (item.level == 2) {
  230. this.$set(this, 'levelListThree', item);
  231. if (item.children[0]) {
  232. item.children.forEach(function(item) {
  233. if (item.hazardCheckPoint) {
  234. item.hazardCheckPointList = item.hazardCheckPoint.split('#')
  235. }
  236. })
  237. }
  238. this.$set(this, 'checkList', item.children);
  239. } else if (item.level == 3) {
  240. this.checkItemButton(item, item2);
  241. }
  242. },
  243. //选中检查项
  244. checkItemButton(item, item2) {
  245. this.$parent.checkItemModuleButton('submit', item, item2);
  246. },
  247. //高亮
  248. brightenKeyword(code,val, editKeyword) {
  249. const Reg = new RegExp(editKeyword);
  250. if (val) {
  251. const res = code+ val.replace(Reg, `<span style="color: #0183FA;">${editKeyword }</span>`);
  252. return res;
  253. }
  254. },
  255. //基础检查项检查
  256. async securityCheckOptionSelAllList() {
  257. let self = this;
  258. const {
  259. data
  260. } = await securityCheckOptionSelAllList({});
  261. if (data.code == 200) {
  262. let maxList = this.getCascaderData(JSON.parse(JSON.stringify(data.data)), 2)
  263. this.$nextTick(() => {
  264. if (this.optionData.infoType == 0) {
  265. this.securityAppCheckSetOptionList(maxList);
  266. } else if (this.optionData.infoType == 1) {
  267. this.securityAppCheckSetOptionGetReviewList(maxList);
  268. } else if (this.optionData.infoType == 2) {
  269. this.securityAppCheckDangerGetCheckDangerSubId(maxList);
  270. }
  271. })
  272. }
  273. },
  274. /********************** 检查相关查询 **********************/
  275. async securityAppCheckSetOptionList(maxList) {
  276. let self = this;
  277. const {
  278. data
  279. } = await securityAppCheckSetOptionList({
  280. manageId: this.optionData.manageId,
  281. checkStatus: this.optionData.checkType,
  282. searchValue: this.searchValue
  283. });
  284. if (data.code == 200) {
  285. //级联数据
  286. if (maxList) {
  287. let minList = JSON.parse(JSON.stringify(data.data))
  288. this.cascadeData(maxList, minList);
  289. }
  290. if (data.data[0]) {
  291. data.data.forEach(function(item) {
  292. if (item.hazardCheckPoint) {
  293. item.hazardCheckPointList = item.hazardCheckPoint.split('#')
  294. }
  295. })
  296. }
  297. //查询数据
  298. let map = new Map();
  299. for (let item of data.data) {
  300. let hazardCheckCode2 = item.hazardCheckCode2;
  301. if (!map.has(hazardCheckCode2)) {
  302. map.set(hazardCheckCode2, {
  303. hazardCheckCode2: hazardCheckCode2,
  304. hazardCheckName2: item.hazardCheckName2,
  305. hazardCheckCode1: item.hazardCheckCode1,
  306. hazardCheckName1: item.hazardCheckName1,
  307. data: [item]
  308. });
  309. } else {
  310. map.get(hazardCheckCode2).data.push(item);
  311. }
  312. }
  313. let finalResult = Array.from(map.values());
  314. this.$set(this, 'dataList', finalResult);
  315. }
  316. },
  317. /********************** 复查相关查询 **********************/
  318. async securityAppCheckSetOptionGetReviewList(maxList) {
  319. let self = this;
  320. const {
  321. data
  322. } = await securityAppCheckSetOptionGetReviewList({
  323. planId: this.optionData.planId,
  324. planSetId: this.optionData.planSetId,
  325. subId: this.optionData.subId,
  326. appReviewStatus: this.optionData.checkType,
  327. searchValue: this.searchValue
  328. });
  329. if (data.code == 200) {
  330. //级联数据
  331. if (maxList) {
  332. let minList = JSON.parse(JSON.stringify(data.data.records))
  333. this.cascadeData(maxList, minList);
  334. }
  335. //查询数据
  336. this.$set(this, 'dataList', JSON.parse(JSON.stringify(data.data.records)));
  337. }
  338. },
  339. /********************** 整改相关查询 **********************/
  340. async securityAppCheckDangerGetCheckDangerSubId(maxList) {
  341. let self = this;
  342. const {
  343. data
  344. } = await securityAppCheckDangerGetCheckDangerSubId({
  345. planId: this.optionData.planId,
  346. planSetId: this.optionData.planSetId,
  347. subId: this.optionData.subId,
  348. appReviewStatus: this.optionData.checkType,
  349. searchValue: this.searchValue
  350. });
  351. if (data.code == 200) {
  352. //级联数据
  353. if (maxList) {
  354. let minList = JSON.parse(JSON.stringify(data.data.records))
  355. this.cascadeData(maxList, minList);
  356. }
  357. //查询数据
  358. this.$set(this, 'dataList', JSON.parse(JSON.stringify(data.data.records)));
  359. }
  360. },
  361. /********************** 处理级联数据 **********************/
  362. cascadeData(maxList, minList) {
  363. for (let i = 0; i < maxList.length; i++) {
  364. for (let o = 0; o < maxList[i].children.length; o++) {
  365. for (let x = 0; x < minList.length; x++) {
  366. if (maxList[i].children[o].id == minList[x].hazardCheckPro2) {
  367. minList[x].level = 3;
  368. if (maxList[i].children[o].children) {
  369. maxList[i].children[o].children.push(minList[x])
  370. } else {
  371. maxList[i].children[o].children = [minList[x]]
  372. }
  373. }
  374. }
  375. }
  376. }
  377. let list = this.getCascaderData(JSON.parse(JSON.stringify(maxList)), 3)
  378. this.$nextTick(() => {
  379. this.$set(this, 'levelListOne', JSON.parse(JSON.stringify({
  380. level: 0,
  381. children: list
  382. })));
  383. this.$set(this, 'checkList', JSON.parse(JSON.stringify(list)));
  384. })
  385. },
  386. /********************** 检查项格式处理 **********************/
  387. getCascaderData(list, type) {
  388. let self = this
  389. for (let i = 0; i < list.length; i++) {
  390. if (list[i].level == type) {
  391. delete list[i].children
  392. } else if (list[i].children) {
  393. if (list[i].children[0]) {
  394. list[i].children = self.getCascaderData(list[i].children, type)
  395. } else {
  396. list.splice(i, 1)
  397. i--
  398. }
  399. } else {
  400. list.splice(i, 1)
  401. i--
  402. }
  403. }
  404. for (let i = 0; i < list.length; i++) {
  405. if (list[i].level == type) {
  406. delete list[i].children
  407. } else if (list[i].children) {
  408. if (list[i].children[0]) {
  409. list[i].children = self.getCascaderData(list[i].children, type)
  410. } else {
  411. list.splice(i, 1)
  412. i--
  413. }
  414. } else {
  415. list.splice(i, 1)
  416. i--
  417. }
  418. }
  419. for (let i = 0; i < list.length; i++) {
  420. if (list[i].level == type) {
  421. delete list[i].children
  422. } else if (list[i].children) {
  423. if (list[i].children[0]) {
  424. list[i].children = self.getCascaderData(list[i].children, type)
  425. } else {
  426. list.splice(i, 1)
  427. i--
  428. }
  429. } else {
  430. list.splice(i, 1)
  431. i--
  432. }
  433. }
  434. return list
  435. },
  436. }
  437. }
  438. </script>
  439. <style lang="stylus" scoped>
  440. .checkItemModule {
  441. position: fixed;
  442. top: 0;
  443. left: 0;
  444. height: 100%;
  445. width: 100%;
  446. flex: 1;
  447. overflow: hidden;
  448. display: flex;
  449. flex-direction: column;
  450. background-color: #fff;
  451. .checkItemModule-title-box {
  452. display: flex;
  453. height: 100rpx;
  454. background-color: #FFFFFF;
  455. border-bottom: 1rpx solid #dedede;
  456. .checkItemModule-title-p {
  457. width: 140rpx;
  458. height: 100rpx;
  459. >view:nth-child(1) {
  460. color: #333;
  461. text-align: center;
  462. font-size: 29rpx;
  463. line-height: 30rpx;
  464. margin: 35rpx 0 20rpx 0;
  465. }
  466. >view:nth-child(2) {
  467. width: 56rpx;
  468. height: 6rpx;
  469. border-radius: 14rpx;
  470. margin: 0 auto;
  471. }
  472. }
  473. .checkItemModule-title-check {
  474. >view:nth-child(1) {
  475. color: #0183FA;
  476. }
  477. >view:nth-child(2) {
  478. background: #0183FA;
  479. }
  480. }
  481. }
  482. .input-max-big-box {
  483. flex: 1;
  484. display: flex;
  485. flex-direction: column;
  486. overflow: hidden;
  487. .input-big-box {
  488. height: 104rpx;
  489. display: flex;
  490. background-color: #fff;
  491. border-bottom: 1rpx solid #E0E0E0;
  492. .input-box {
  493. width: 611rpx;
  494. height: 69rpx;
  495. border: 1px solid #E0E0E0;
  496. display: flex;
  497. border-radius: 35px 35px 35px 35px;
  498. margin: 17rpx 0 17rpx 21rpx;
  499. .left-icons {
  500. padding: 15rpx 18rpx 0 22rpx;
  501. }
  502. .right-icons {
  503. padding: 15rpx 15rpx 0 22rpx;
  504. }
  505. >input {
  506. flex: 1;
  507. height: 69rpx;
  508. line-height: 69rpx;
  509. }
  510. }
  511. .out-button {
  512. width: 100rpx;
  513. margin: 17rpx 0 17rpx 15rpx;
  514. text-align: center;
  515. line-height: 69rpx;
  516. color: #0183FA;
  517. font-size: 29rpx;
  518. }
  519. }
  520. .input-for-max-box {
  521. flex: 1;
  522. display: flex;
  523. flex-direction: column;
  524. overflow-y: scroll;
  525. background-color: #fff;
  526. .for-box {
  527. .for-box-n {
  528. margin: 0 21rpx;
  529. font-size: 32rpx;
  530. line-height: 40rpx;
  531. padding: 20rpx 0;
  532. background-color: #fff;
  533. border-bottom: 1rpx solid #E0E0E0;
  534. }
  535. }
  536. }
  537. }
  538. .check-max-big-box {
  539. flex: 1;
  540. display: flex;
  541. flex-direction: column;
  542. overflow: hidden;
  543. .check-big-box {
  544. height: 70rpx;
  545. display: flex;
  546. background-color: #fff;
  547. border-bottom: 1rpx solid #E0E0E0;
  548. >view {
  549. width: 200rpx;
  550. line-height: 70rpx;
  551. text-align: center;
  552. color: #333;
  553. font-size: 29rpx;
  554. }
  555. .checkView {
  556. color: #0183FA;
  557. }
  558. }
  559. .check-for-max-box {
  560. flex: 1;
  561. display: flex;
  562. flex-direction: column;
  563. overflow-y: scroll;
  564. background-color: #fff;
  565. >view {
  566. >view {
  567. font-size: 32rpx;
  568. line-height: 70rpx;
  569. margin: 0 21rpx;
  570. border-bottom: 1px solid #dedede;
  571. }
  572. }
  573. }
  574. }
  575. }
  576. </style>