checkItemModule.vue 13 KB

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