edit.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <div class="lz-edit">
  3. <nav-bar></nav-bar>
  4. <div class="page-container">
  5. <!-- 基本信息 -->
  6. <div class="card" v-if="taskInfo">
  7. <van-panel :title="taskInfo.title" :status="getDicts(taskInfo.status,'resumption_status')">
  8. <van-cell title="日期时间" :value="rangDate(taskInfo.planstarttime,taskInfo.planendtime)" />
  9. <van-collapse :border="false" v-model="activeNames">
  10. <van-collapse-item title="履职内容" :name="1">
  11. <van-cell title="检查内容:" :value="allCheckNum" />
  12. <van-cell title="NFC:" >
  13. <template #extra>
  14. <p class="flex-box">
  15. <span >已扫 {{taskInfo.areaScanY}}</span>
  16. <span >未扫 {{taskInfo.areaScanN}}</span>
  17. </p>
  18. </template>
  19. </van-cell>
  20. <van-cell title="检查区域:">
  21. <template #extra>
  22. <p class="flex-box">
  23. <span >已查 {{taskInfo.nfcScanY}}</span>
  24. <span >未查 {{taskInfo.nfcScanN}}</span>
  25. </p>
  26. </template>
  27. </van-cell>
  28. </van-collapse-item>
  29. </van-collapse>
  30. </van-panel>
  31. </div>
  32. <!-- 检查区域 -->
  33. <div class="card">
  34. <van-panel title="巡检区域" v-if="areaList">
  35. <div style="padding: 10px;">
  36. <van-row >
  37. <van-col span="12" v-for="(v,i) in areaList" :key="v.areaid">
  38. <div class="check-area" @click="clickArea(v,i)">
  39. {{v.areaname}}
  40. <!-- <van-icon v-if="v.status" name="success" color="primary"/>-->
  41. <!-- <van-icon v-else name="fail" color="red"/>-->
  42. </div>
  43. </van-col>
  44. </van-row>
  45. <van-cell title="检查内容:" :value="checkNum" />
  46. <van-cell>
  47. <template #title>
  48. <span>NFC:</span>
  49. </template>
  50. <template #extra>
  51. <span style="display: inline-block;color:#969799;">{{NFCNum}}</span>
  52. <img v-if="enable && NFCNum" :src="require('../../../assets/svg/NFC.svg')" class="nfc-icon" @click="clickNFC"/>
  53. </template>
  54. </van-cell>
  55. <van-cell v-show="nfcImage.length > 0" :border="false" >
  56. <img class="nfc-img" v-for="(v,i) in selectArea.nfclist" v-if="v.img" :src="imgUrl(v.img)" alt="" :key="v.img">
  57. </van-cell>
  58. </div>
  59. </van-panel>
  60. </div>
  61. <!-- 检查事项 -->
  62. <!-- <div class="card" v-if="selectArea" v-for="v in checkList" :key="v.itemid">-->
  63. <!-- <van-panel :title="v.itemname">-->
  64. <!-- <van-collapse v-model="activeNames" v-for="(item,index) in v.checkitemlist" :key="item.pointdataid">-->
  65. <!-- <van-collapse-item :title="item.pointname" :name="index" >-->
  66. <!-- <van-cell :border="false" title="是否异常">-->
  67. <!-- <template #right-icon>-->
  68. <!-- <van-switch-->
  69. <!-- v-model="item.resvalue"-->
  70. <!-- inactive-color="#4fc08d"-->
  71. <!-- active-color="orange"-->
  72. <!-- size="20" />-->
  73. <!-- </template>-->
  74. <!-- </van-cell>-->
  75. <!-- <van-cell-group v-show="item.resvalue">-->
  76. <!-- <van-field-->
  77. <!-- v-model="item.resremark"-->
  78. <!-- rows="1"-->
  79. <!-- autosize-->
  80. <!-- label="情况描述:"-->
  81. <!-- type="textarea"-->
  82. <!-- placeholder="请输入"/>-->
  83. <!-- <div class="upload-box" >-->
  84. <!-- <uploader v-model="item.imgData" multiple />-->
  85. <!-- </div>-->
  86. <!-- <select-cell title="整改期限" v-model="item.rectificationDeadline" :dict="'rectification_deadline'" is-link/>-->
  87. <!-- </van-cell-group>-->
  88. <!-- <date-cell v-if="item.businessType === 1" v-for="(val,ind) in item.protectionVo" :title="val.protectionName" v-model="val.statusUpdateTime" :key="val.id" date-type="datetime" />-->
  89. <!-- </van-collapse-item >-->
  90. <!-- </van-collapse >-->
  91. <!-- </van-panel>-->
  92. <!-- </div>-->
  93. <!-- 检查项目2 -->
  94. <fieldset class="fieldset" :disabled="!enable">
  95. <div class="card" v-if="selectArea">
  96. <van-collapse v-model="activeNames" v-for="v in checkList" :key="v.itemid">
  97. <van-collapse-item :title="v.itemname" :name="v.itemname" >
  98. <div v-for="(item,index) in v.checkitemlist" :key="item.pointdataid">
  99. <van-cell :title="item.pointname">
  100. <template #right-icon>
  101. <van-switch
  102. v-if="enable"
  103. v-model="item.resvalue"
  104. :active-value="1"
  105. :inactive-value="0"
  106. inactive-color="#4fc08d"
  107. active-color="orange"
  108. @change="switchChange(item)"
  109. size="20" />
  110. </template>
  111. </van-cell>
  112. <van-cell-group v-show="item.resvalue">
  113. <van-field
  114. v-model="item.resremark"
  115. rows="1"
  116. autosize
  117. label="情况描述:"
  118. type="textarea"
  119. placeholder="请输入"/>
  120. <div class="upload-box" >
  121. <uploader v-model="item.imgData"/>
  122. </div>
  123. <select-cell :disabled="!enable" title="整改期限" v-model="item.rectificationDeadline" :dict="'rectification_deadline'" />
  124. </van-cell-group>
  125. <date-cell
  126. :disabled="!enable"
  127. v-if="item.businessType === 1"
  128. v-for="(val,ind) in item.protectionVo"
  129. :title="val.protectionName"
  130. v-model="val.statusUpdateTime"
  131. :key="val.id"
  132. date-type="datetime" />
  133. </div>
  134. </van-collapse-item>
  135. </van-collapse>
  136. </div >
  137. <p v-if="enable" class="warning-msg">需要完成所有区域的履职内容才能提交内容</p>
  138. <div v-if="enable" class="flex-box">
  139. <van-button type="default" style="width: 28%;" plain @click="goBack">取消</van-button>
  140. <van-button type="info" style="width: 28%;" plain hairline @click="saveData">保存</van-button>
  141. <van-button type="info" style="width: 28%;" @click="submitData">提交</van-button>
  142. </div>
  143. </fieldset>
  144. </div>
  145. <!-- nfc弹窗 -->
  146. <nfc-popup v-if="enable" ref="NfcPopup" @change="changeNfcImg"></nfc-popup>
  147. </div>
  148. </template>
  149. <script>
  150. import NavBar from '@/components/NavBar';
  151. import SelectCell from '@/components/selectCell';
  152. import DateCell from '@/components/dateCell';
  153. import Uploader from '@/components/upload';
  154. import NfcPopup from '@/components/nfcPopup/more';
  155. import {taskDetails,saveTaskData} from "@/views/menu/LZRegister/api";
  156. import {formatDate} from "@/filters/filter";
  157. export default {
  158. components:{NavBar,SelectCell,DateCell,Uploader,NfcPopup},
  159. data(){
  160. return {
  161. activeNames: ['1'],
  162. //区域列表
  163. areaList:[],
  164. //基本信息
  165. taskInfo:[],
  166. //字典
  167. dicts: ['resumption_status'],
  168. //选中的区域
  169. selectArea:[],
  170. //区域下nfc列表
  171. NFCList:[],
  172. //区域下检查内容列表
  173. checkList:[],
  174. //检查内容具体项列表
  175. checkItemList:[],
  176. //nfc扫描数量
  177. NFCNum:0,
  178. //所有检查项数量
  179. allCheckNum:0,
  180. //区域下检查项数量
  181. checkNum:0,
  182. //nfc图片
  183. nfcImage:[],
  184. enable:false,
  185. }
  186. },
  187. mounted() {
  188. this.getData();
  189. },
  190. computed:{
  191. },
  192. // watch:{
  193. // NFCList(){
  194. // if(!this.NFCList) return;
  195. // let arr = this.NFCList.filter(item=>{
  196. // return item.status == 0;
  197. // })
  198. // this.NFCNum = arr.length;
  199. // },
  200. // },
  201. methods:{
  202. //初始化数据
  203. getData() {
  204. let data = {
  205. dateTime:new Date(),
  206. taskId:this.$route.query.id,
  207. }
  208. taskDetails(data).then(res=>{
  209. //res = json;
  210. console.log(res,'res')
  211. let {areaScanN,areaScanY,nfcScanN,nfcScanY} = res.data;
  212. this.taskInfo = {
  213. areaScanN,
  214. areaScanY,
  215. nfcScanN,
  216. nfcScanY,
  217. ...res.data.taskObj
  218. }
  219. this.taskInfo.nfcScaning = res.data.nfcScaning;
  220. this.enable = this.taskInfo.status === 1 || this.taskInfo.status === 2; //是否可编辑
  221. this.areaList = res.data.taskarealist;
  222. this.activeArea(this.areaList[0],0);
  223. this.getAllCheckItemNum();
  224. console.log(res)
  225. })
  226. },
  227. //保存数据
  228. saveData(){
  229. let pointdata = [];
  230. this.areaList.forEach(area=>{
  231. console.log(area,'area')
  232. area.checklist.forEach(item=>{
  233. item.checkitemlist.forEach(checkItem=>{
  234. checkItem.protections = checkItem.protectionVo;
  235. checkItem.resRemark = checkItem.resremark;
  236. checkItem.resStatus = checkItem.resstatus;
  237. checkItem.areaId = checkItem.areaid;
  238. checkItem.id = checkItem.pointdataid;
  239. checkItem.pointId = checkItem.pointid;
  240. checkItem.resValue = checkItem.resvalue;
  241. checkItem.resumptionId = this.$route.query.id;
  242. pointdata.push(checkItem);
  243. })
  244. })
  245. })
  246. let data = {
  247. dateTime:new Date(),
  248. isSubmit:0,
  249. resumptionId:this.$route.query.id,
  250. year: this.taskInfo.year,
  251. quarter: this.taskInfo.quarter,
  252. nfcData:this.nfcImage,
  253. pointdata,
  254. }
  255. saveTaskData(data).then(res=>{
  256. this.$toast('提交成功');
  257. this.$router.go(-1);
  258. })
  259. },
  260. //获取所有检查项数量
  261. getAllCheckItemNum(){
  262. let num = 0;
  263. this.areaList.forEach(v=>{
  264. v.checklist.forEach(item=>{
  265. num += item.checkitemlist.length;
  266. })
  267. });
  268. this.allCheckNum = num;
  269. console.log(num,'num1111')
  270. },
  271. //点击区域
  272. clickArea(area,index){
  273. this.activeArea(area,index);
  274. },
  275. //选中区域时数据变更
  276. activeArea(area,index){
  277. this.$nextTick(()=>{
  278. let doms = document.getElementsByClassName('check-area');
  279. console.log(doms,'doms')
  280. Array.prototype.forEach.call(doms,item=>{
  281. item.classList.remove('active');
  282. })
  283. doms[index].classList.add('active');
  284. })
  285. this.selectArea = area;
  286. this.checkList = area.checklist;
  287. //设置默认展开项
  288. this.activeNames = this.checkList.map(v=>v.itemname);
  289. //回显nfc图片
  290. area.nfclist.forEach( v =>{
  291. if(v.img){
  292. v.url = v.img;
  293. this.nfcImage.push(v)
  294. }
  295. });
  296. console.log(this.nfcImage,'nfcImage')
  297. //获取当前区域检查项数量
  298. this.getCheckItemNum();
  299. //获取当前区域nfc数量
  300. this.getNFCItemNum();
  301. },
  302. //获取当前区域检查项数量
  303. getCheckItemNum(){
  304. let num = 0;
  305. this.selectArea.checklist.forEach(v=>{
  306. num += v.checkitemlist.length;
  307. });
  308. this.checkNum = num;
  309. },
  310. //获取当前区域nfc数量
  311. getNFCItemNum(){
  312. let num = 0;
  313. this.selectArea.nfclist.forEach(v=>{
  314. if(v.status === 0 || !v.img){
  315. num++;
  316. }
  317. })
  318. this.NFCNum = num;
  319. },
  320. //提交数据
  321. submitData(){
  322. let pointdata = [];
  323. this.areaList.forEach(area=>{
  324. area.checklist.forEach(item=>{
  325. item.checkitemlist.forEach(checkItem=>{
  326. checkItem.protections = checkItem.protectionVo;
  327. checkItem.resRemark = checkItem.resremark;
  328. checkItem.resStatus = checkItem.resstatus;
  329. checkItem.areaId = checkItem.areaid;
  330. checkItem.id = checkItem.pointdataid;
  331. checkItem.pointId = checkItem.pointid;
  332. checkItem.resValue = checkItem.resvalue;
  333. checkItem.resumptionId = this.$route.query.id;
  334. pointdata.push(checkItem);
  335. })
  336. })
  337. })
  338. console.log(pointdata,'pointdata')
  339. let data = {
  340. dateTime:new Date(),
  341. isSubmit:1,
  342. resumptionId:this.$route.query.id,
  343. year: this.taskInfo.year,
  344. quarter: this.taskInfo.quarter,
  345. nfcData:[],
  346. pointdata,
  347. }
  348. saveTaskData(data).then(res=>{
  349. this.$toast('提交成功');
  350. this.$router.go(-1);
  351. })
  352. },
  353. //返回
  354. goBack(){
  355. this.$router.go(-1);
  356. this.clearData();
  357. },
  358. //点击NFC图标
  359. clickNFC(){
  360. if(!this.NFCNum) return;
  361. let arr = this.selectArea.nfclist.filter(item=>{
  362. return item.status == 0;
  363. })
  364. this.$refs.NfcPopup.show(arr);
  365. },
  366. //清空数据
  367. clearData(){
  368. this.areaList = [];
  369. this.taskInfo= [];
  370. this.selectArea = [];
  371. this.NFCList = [];
  372. this.checkList = [];
  373. this.checkItemList = [];
  374. this.NFCNum = 0;
  375. this.enable = false;
  376. },
  377. //切换开关时添加操作时间
  378. switchChange(item){
  379. console.log(item,'666')
  380. item.resTime = formatDate(new Date());
  381. },
  382. //添加图片时的回调
  383. changeNfcImg(imgItem){
  384. console.log(imgItem,'imgItem')
  385. this.selectArea.nfclist.forEach(v=>{
  386. if(v.nfccdoe === imgItem.nfcCode){
  387. v.img = imgItem.url;
  388. this.nfcImage.push(v);
  389. }
  390. })
  391. console.log( this.selectArea.nfclist,this.nfcImage,'nfcObj')
  392. },
  393. }
  394. }
  395. </script>
  396. <style lang="scss" scoped>
  397. .lz-edit{
  398. height: 100%;
  399. overflow: hidden;
  400. }
  401. .page-container{
  402. height: calc(100vh - 90px);
  403. overflow: auto;
  404. padding: 20px;
  405. }
  406. .flex-box{
  407. display: flex;
  408. justify-content: space-between;
  409. align-items: center;
  410. >span{
  411. margin: 0 20px;
  412. }
  413. }
  414. .card{
  415. margin-bottom: 20px;
  416. box-shadow: 0 10px 10px #eaeaea;
  417. }
  418. .check-area{
  419. background-color: #f1f1f1;
  420. margin: 10px;
  421. padding:20px;
  422. color:#aaa;
  423. border-radius: 6px;
  424. display: flex;
  425. justify-content: space-between;
  426. align-items: center;
  427. box-shadow: 0 2px 6px #ddd;
  428. }
  429. .nfc-icon{
  430. width: 50px;
  431. height: 50px;
  432. margin-left: 20px;
  433. }
  434. .custom-title {
  435. align-self: center;
  436. vertical-align: middle;
  437. }
  438. .upload-box{
  439. margin: 30px;
  440. }
  441. .warning-msg{
  442. color: orange;
  443. text-align: center;
  444. height: 80px;
  445. line-height: 80px;
  446. }
  447. .active{
  448. color: #fff;
  449. background-color: #1989fa;
  450. }
  451. .nfc-img{
  452. width: 160px;
  453. height: 160px;
  454. }
  455. </style>