checkItemModule.vue 16 KB

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