checkItemModule.vue 13 KB

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