checkItemModule.vue 15 KB

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