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