checkItemModule.vue 14 KB

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