checkItemModule.vue 15 KB

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