checkItemModule.vue 15 KB

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