edit.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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)">
  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="NFC:" >
  12. <template #extra>
  13. <p class="flex-box">
  14. <span >已扫 {{taskInfo.nfcScanY}}</span>
  15. <span >未扫 {{taskInfo.nfcScanN}}</span>
  16. </p>
  17. </template>
  18. </van-cell>
  19. <van-cell title="履职项:">
  20. <template #extra>
  21. <p class="flex-box">
  22. <span >已查 {{taskInfo.areaScanY}}</span>
  23. <span >未查 {{taskInfo.areaScanN}}</span>
  24. </p>
  25. </template>
  26. </van-cell>
  27. <van-cell title="履职内容:" :value="allCheckNum" />
  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. <div v-if="v.img" class="nfc-img" v-for="(v,i) in nfcImage" :key="v.img" @click="preViewNFC(i)">
  57. <img :src="imgUrl(v.img)" alt="" >
  58. <span>{{v.checkName}}</span>
  59. </div>
  60. <!-- <img class="nfc-img" v-for="(v,i) in selectArea.nfclist" v-if="v.img" :src="imgUrl(v.img)" alt="" :key="v.img">-->
  61. </van-cell>
  62. </div>
  63. </van-panel>
  64. </div>
  65. <!-- 检查事项 -->
  66. <!-- <div class="card" v-if="selectArea" v-for="v in checkList" :key="v.itemid">-->
  67. <!-- <van-panel :title="v.itemname">-->
  68. <!-- <van-collapse v-model="activeNames" v-for="(item,index) in v.checkitemlist" :key="item.pointdataid">-->
  69. <!-- <van-collapse-item :title="item.pointname" :name="index" >-->
  70. <!-- <van-cell :border="false" title="是否异常">-->
  71. <!-- <template #right-icon>-->
  72. <!-- <van-switch-->
  73. <!-- v-model="item.resvalue"-->
  74. <!-- inactive-color="#4fc08d"-->
  75. <!-- active-color="orange"-->
  76. <!-- size="20" />-->
  77. <!-- </template>-->
  78. <!-- </van-cell>-->
  79. <!-- <van-cell-group v-show="item.resvalue">-->
  80. <!-- <van-field-->
  81. <!-- v-model="item.resremark"-->
  82. <!-- rows="1"-->
  83. <!-- autosize-->
  84. <!-- label="情况描述:"-->
  85. <!-- type="textarea"-->
  86. <!-- placeholder="请输入"/>-->
  87. <!-- <div class="upload-box" >-->
  88. <!-- <uploader v-model="item.imgData" multiple />-->
  89. <!-- </div>-->
  90. <!-- <select-cell title="整改期限" v-model="item.rectificationDeadline" :dict="'rectification_deadline'" is-link/>-->
  91. <!-- </van-cell-group>-->
  92. <!-- <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" />-->
  93. <!-- </van-collapse-item >-->
  94. <!-- </van-collapse >-->
  95. <!-- </van-panel>-->
  96. <!-- </div>-->
  97. <!-- 检查项目2 -->
  98. <fieldset class="fieldset" :disabled="!enable">
  99. <div class="card" v-if="selectArea">
  100. <van-collapse v-model="activeNames" v-for="v in checkList" :key="v.itemid">
  101. <van-collapse-item :title="v.itemname" :name="v.itemname" >
  102. <div v-for="(item,index) in v.checkitemlist" :key="item.pointdataid">
  103. <van-cell :title="item.pointname">
  104. <template #right-icon>
  105. <van-switch
  106. v-if="enable"
  107. style="margin-left: 10px;"
  108. v-model="item.resvalue"
  109. :active-value="1"
  110. :inactive-value="0"
  111. inactive-color="#4fc08d"
  112. active-color="#ee0a24"
  113. @change="switchChange(item)"
  114. size="20" />
  115. <span v-else>
  116. <!-- <van-icon v-if="item.resvalue" name="success" color="#07c160" />-->
  117. <!-- <van-icon v-else name="fail" color="#ee0a24"/>-->
  118. <van-tag v-if="item.resvalue" type="warning">隐患</van-tag>
  119. <van-tag v-else type="success">正常</van-tag>
  120. </span>
  121. </template>
  122. </van-cell>
  123. <van-cell-group v-show="item.resvalue">
  124. <select-cell required :disabled="!enable" title="整改期限" v-model="item.rectificationDeadline" :data-list="dayList" />
  125. <van-field
  126. required
  127. v-model="item.resremark"
  128. rows="1"
  129. autosize
  130. label="情况描述:"
  131. type="textarea"
  132. placeholder="请输入"/>
  133. <div class="upload-box" >
  134. <uploader :maxCount="5" v-if="enable" v-model="item.imgData"/>
  135. <van-cell v-else>
  136. <div class="nfc-img van-hairline--surround" v-for="(v,i) in item.imgData" :key="v.imgPath" @click="clickWarnImage(item.imgData,i)">
  137. <img :src="imgUrl(v.imgPath)" alt="" >
  138. <span>{{v.checkName}}</span>
  139. </div>
  140. <!-- <img class="nfc-img" v-for="v in item.imgData" :src="imgUrl(v.imgPath)" alt="" :key="v.id">-->
  141. </van-cell>
  142. </div>
  143. </van-cell-group>
  144. <date-cell
  145. :disabled="!enable"
  146. v-if="item.businessType === 1"
  147. v-for="(val,ind) in item.protectionVo"
  148. :title="val.protectionName"
  149. v-model="val.statusUpdateTime"
  150. :key="val.id"
  151. date-type="datetime" />
  152. </div>
  153. </van-collapse-item>
  154. </van-collapse>
  155. </div >
  156. <p v-if="enable" class="warning-msg">需要完成所有区域的履职内容才能提交内容</p>
  157. <div v-if="enable" class="flex-box">
  158. <van-button type="default" style="width: 28%;" plain @click="goBack">取消</van-button>
  159. <van-button type="info" style="width: 28%;" plain hairline @click="saveData">保存</van-button>
  160. <van-button type="info" style="width: 28%;" @click="submitData">提交</van-button>
  161. </div>
  162. </fieldset>
  163. </div>
  164. <!-- <van-image-preview v-model="showPreView" :images="preViewImages.images" :startPosition="preViewImages.startPosition">-->
  165. <!-- <template v-slot:index>第{{ index }}页</template>-->
  166. <!-- </van-image-preview>-->
  167. <!-- nfc弹窗 -->
  168. <nfc-popup v-if="enable" ref="NfcPopup" @change="changeNfcImg"></nfc-popup>
  169. </div>
  170. </template>
  171. <script>
  172. import NavBar from '@/components/NavBar';
  173. import SelectCell from '@/components/selectCell';
  174. import DateCell from '@/components/dateCell';
  175. import Uploader from '@/components/upload/uploader';
  176. import NfcPopup from '@/components/nfcPopup/more';
  177. import {taskDetails,saveTaskData} from "@/views/menu/LZRegister/api";
  178. import {formatDate} from "@/filters/filter";
  179. import {getDict} from "@/api/toConsult";
  180. import {imgUrl} from "@/utils";
  181. import { ImagePreview } from 'vant';
  182. export default {
  183. components:{NavBar,SelectCell,DateCell,Uploader,NfcPopup},
  184. data(){
  185. return {
  186. activeNames: ['1'],
  187. //区域列表
  188. areaList:[],
  189. //基本信息
  190. taskInfo:[],
  191. //字典
  192. dicts: ['resumption_status'],
  193. //选中的区域
  194. selectArea:[],
  195. //区域下nfc列表
  196. NFCList:[],
  197. //区域下检查内容列表
  198. checkList:[],
  199. //检查内容具体项列表
  200. checkItemList:[],
  201. //nfc扫描数量
  202. NFCNum:0,
  203. //所有检查项数量
  204. allCheckNum:0,
  205. //区域下检查项数量
  206. checkNum:0,
  207. //nfc图片
  208. nfcImage:[],
  209. enable:false,
  210. stateList:[],
  211. dayList:[],
  212. preViewImages:{
  213. images:[],
  214. startPosition:0
  215. },
  216. showPreView:false,
  217. }
  218. },
  219. created() {
  220. getDict( 'resumption_status' ).then(res => {
  221. let { data } = res
  222. this.stateList = data;
  223. })
  224. getDict( 'rectification_deadline' ).then(res => {
  225. let { data } = res
  226. this.dayList = data;
  227. })
  228. },
  229. mounted() {
  230. this.getData();
  231. },
  232. methods:{
  233. clickWarnImage(arr,i){
  234. this.preViewImages.images = arr.map(v=>imgUrl(v.imgPath));
  235. this.preViewImages.startPosition = i;
  236. ImagePreview(this.preViewImages)
  237. },
  238. preViewNFC(i){
  239. this.preViewImages.images = this.nfcImage.map(v=>imgUrl(v.img));
  240. this.preViewImages.startPosition = i;
  241. ImagePreview(this.preViewImages)
  242. },
  243. getDicts(s){
  244. return this.stateList.find(v=> s == v.dictValue)?.dictLabel;
  245. },
  246. //初始化数据
  247. getData() {
  248. let data = {
  249. dateTime:new Date(),
  250. taskId:this.$route.query.id,
  251. }
  252. taskDetails(data).then(res=>{
  253. //res = json;
  254. console.log(res,'res')
  255. let {areaScanN,areaScanY,nfcScanN,nfcScanY} = res.data;
  256. this.taskInfo = {
  257. areaScanN,
  258. areaScanY,
  259. nfcScanN,
  260. nfcScanY,
  261. ...res.data.taskObj
  262. }
  263. this.taskInfo.nfcScaning = res.data.nfcScaning;
  264. this.enable = this.taskInfo.status === 1 || this.taskInfo.status === 2; //是否可编辑
  265. this.areaList = res.data.taskarealist;
  266. this.activeArea(this.areaList[0],0);
  267. this.getAllCheckItemNum();
  268. })
  269. },
  270. //保存数据
  271. saveData(){
  272. let pointdata = [];
  273. let checkNFC = [];
  274. this.areaList.forEach(area=>{
  275. area.nfclist.forEach(v=>{
  276. if(v.status === 1){
  277. checkNFC.push(v)
  278. }
  279. })
  280. area.checklist.forEach(item=>{
  281. item.checkitemlist.forEach(checkItem=>{
  282. checkItem.protections = checkItem.protectionVo;
  283. checkItem.resRemark = checkItem.resremark;
  284. checkItem.resStatus = checkItem.resstatus;
  285. checkItem.areaId = checkItem.areaid;
  286. checkItem.id = checkItem.pointdataid;
  287. checkItem.pointId = checkItem.pointid;
  288. checkItem.resValue = checkItem.resvalue;
  289. checkItem.resumptionId = this.$route.query.id;
  290. pointdata.push(checkItem);
  291. })
  292. })
  293. });
  294. //验证必填项
  295. let arr = pointdata.filter(v=>{
  296. if(v.resvalue === 1 ){
  297. return !v.resremark || !v.rectificationDeadline
  298. }
  299. })
  300. if(arr.length) return this.$toast(`${arr[0].areaname}-${arr[0].itemname}:信息不完整请填写`);
  301. let data = {
  302. dateTime:new Date(),
  303. isSubmit:0,
  304. resumptionId:this.$route.query.id,
  305. year: this.taskInfo.year,
  306. quarter: this.taskInfo.quarter,
  307. nfcData:checkNFC,
  308. pointdata,
  309. }
  310. saveTaskData(data).then(res=>{
  311. this.$toast('提交成功');
  312. this.$router.go(-1);
  313. })
  314. },
  315. //获取所有检查项数量
  316. getAllCheckItemNum(){
  317. let num = 0;
  318. this.areaList.forEach(v=>{
  319. v.checklist.forEach(item=>{
  320. num += item.checkitemlist.length;
  321. })
  322. });
  323. this.allCheckNum = num;
  324. },
  325. //点击区域
  326. clickArea(area,index){
  327. this.activeArea(area,index);
  328. },
  329. //选中区域时数据变更
  330. activeArea(area,index){
  331. //设置选中样式
  332. this.$nextTick(()=>{
  333. let doms = document.getElementsByClassName('check-area');
  334. Array.prototype.forEach.call(doms,item=>{
  335. item.classList.remove('active');
  336. })
  337. doms[index].classList.add('active');
  338. })
  339. //获取当前选中区域
  340. this.selectArea = area;
  341. //获取当前区域检查项列表
  342. this.checkList = area.checklist;
  343. //设置默认展开项
  344. this.activeNames = this.checkList.map(v=>v.itemname);
  345. //清空nfc图片
  346. this.nfcImage = [];
  347. //回显nfc图片
  348. area.nfclist.forEach( v =>{
  349. if(v.img){
  350. v.url = v.img;
  351. this.nfcImage.push(v)
  352. }
  353. });
  354. //获取当前区域检查项数量
  355. this.getCheckItemNum();
  356. //获取当前区域nfc数量
  357. this.getNFCItemNum();
  358. },
  359. //获取当前区域检查项数量
  360. getCheckItemNum(){
  361. let num = 0;
  362. this.selectArea.checklist.forEach(v=>{
  363. num += v.checkitemlist.length;
  364. });
  365. this.checkNum = num;
  366. },
  367. //获取当前区域nfc数量
  368. getNFCItemNum(){
  369. let num = 0;
  370. this.selectArea.nfclist.forEach(v=>{
  371. if(v.status === 0 || !v.img){
  372. num++;
  373. }
  374. })
  375. this.NFCNum = num;
  376. },
  377. //提交数据
  378. submitData(){
  379. let pointdata = [];
  380. let checkNFC = [];
  381. this.areaList.forEach(area=>{
  382. area.nfclist.forEach(v=>{
  383. if(v.status === 1){
  384. checkNFC.push(v)
  385. }
  386. })
  387. area.checklist.forEach(item=>{
  388. item.checkitemlist.forEach(checkItem=>{
  389. checkItem.protections = checkItem.protectionVo;
  390. checkItem.resRemark = checkItem.resremark;
  391. checkItem.resStatus = checkItem.resstatus;
  392. checkItem.areaId = checkItem.areaid;
  393. checkItem.id = checkItem.pointdataid;
  394. checkItem.pointId = checkItem.pointid;
  395. checkItem.resValue = checkItem.resvalue;
  396. checkItem.resumptionId = this.$route.query.id;
  397. pointdata.push(checkItem);
  398. })
  399. })
  400. })
  401. //验证必填项
  402. let arr = pointdata.filter(v=>{
  403. if(v.resvalue === 1 ){
  404. console.log(v,'验证')
  405. return !v.resremark || !v.rectificationDeadline
  406. }
  407. })
  408. if(arr.length) return this.$toast(`${arr[0].areaname}-${arr[0].itemname}:信息不完整请填写`);
  409. let data = {
  410. dateTime:new Date(),
  411. isSubmit:1,
  412. resumptionId:this.$route.query.id,
  413. year: this.taskInfo.year,
  414. quarter: this.taskInfo.quarter,
  415. nfcData:checkNFC,
  416. pointdata,
  417. }
  418. saveTaskData(data).then(res=>{
  419. this.$toast('提交成功');
  420. this.$router.go(-1);
  421. })
  422. },
  423. //返回
  424. goBack(){
  425. this.$router.go(-1);
  426. this.clearData();
  427. },
  428. //点击NFC图标
  429. clickNFC(){
  430. if(!this.NFCNum) return;
  431. let arr = this.selectArea.nfclist.filter(item=>{
  432. return item.status == 0;
  433. })
  434. this.$refs.NfcPopup.show(arr);
  435. },
  436. //清空数据
  437. clearData(){
  438. this.areaList = [];
  439. this.taskInfo= [];
  440. this.selectArea = [];
  441. this.NFCList = [];
  442. this.checkList = [];
  443. this.checkItemList = [];
  444. this.NFCNum = 0;
  445. this.enable = false;
  446. },
  447. //切换开关时添加操作时间
  448. switchChange(item){
  449. console.log(item,'666')
  450. item.resTime = formatDate(new Date());
  451. },
  452. //添加图片时的回调
  453. changeNfcImg(imgItem){
  454. console.log(imgItem,this.selectArea.nfclist,'imgItem')
  455. this.selectArea.nfclist.forEach(v=>{
  456. if(v.nfccdoe === imgItem.nfcCode){
  457. v.img = imgItem.url;
  458. v.status = 1;
  459. v.scanMethod = 1;
  460. this.nfcImage.push(v);
  461. }
  462. })
  463. console.log( this.selectArea.nfclist,this.nfcImage,'nfcObj')
  464. },
  465. }
  466. }
  467. </script>
  468. <style lang="scss" scoped>
  469. .lz-edit{
  470. height: 100%;
  471. overflow: hidden;
  472. }
  473. .page-container{
  474. height: calc(100vh - 90px);
  475. overflow: auto;
  476. padding: 20px;
  477. }
  478. .flex-box{
  479. display: flex;
  480. justify-content: space-between;
  481. align-items: center;
  482. >span{
  483. margin: 0 20px;
  484. }
  485. }
  486. .card{
  487. margin-bottom: 20px;
  488. box-shadow: 0 10px 10px #eaeaea;
  489. }
  490. .check-area{
  491. background-color: #f1f1f1;
  492. margin: 10px;
  493. padding:20px;
  494. color:#aaa;
  495. border-radius: 6px;
  496. display: flex;
  497. justify-content: space-between;
  498. align-items: center;
  499. box-shadow: 0 2px 6px #ddd;
  500. }
  501. .nfc-icon{
  502. width: 50px;
  503. height: 50px;
  504. margin-left: 20px;
  505. }
  506. .custom-title {
  507. align-self: center;
  508. vertical-align: middle;
  509. }
  510. .upload-box{
  511. margin: 30px;
  512. }
  513. .warning-msg{
  514. color: orange;
  515. text-align: center;
  516. height: 80px;
  517. line-height: 80px;
  518. }
  519. .active{
  520. color: #fff;
  521. background-color: #1989fa;
  522. }
  523. .nfc-img{
  524. display: inline-block;
  525. width: 140px;
  526. height: 140px;
  527. margin: 0 10px;
  528. position: relative;
  529. >img{
  530. width: 100%;
  531. height: 100%;
  532. border: none;
  533. }
  534. >span{
  535. position: absolute;
  536. padding: 0 10px;
  537. bottom: 0;
  538. left: 0;
  539. display: block;
  540. width: 100%;
  541. background-color: rgba(0,0,0,.2 );
  542. color: #eaeaea;
  543. font-size: 20px;
  544. overflow: hidden;
  545. text-overflow: ellipsis;
  546. white-space: nowrap;
  547. line-height: 30px;
  548. height: 30px;
  549. }
  550. }
  551. </style>