detail.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. <template>
  2. <div class="page_box">
  3. <van-form ref="resumption_form">
  4. <div class="panel">
  5. <NavBar :go="{ type: 'push', path: '/resumption' }" />
  6. <van-panel :title="resumptionData.taskName">
  7. <div class="tts">
  8. <van-row>
  9. <van-col span="12">
  10. <div class="total_panel">
  11. <div class="title">履职项</div>
  12. <div class="content">
  13. <span class="con_num ok">已查 {{ resumptionData.yesPointNums }}</span>
  14. <span class="con_num no">未查 {{ resumptionData.noPointNums }}</span>
  15. </div>
  16. </div>
  17. </van-col>
  18. <van-col span="12">
  19. <div class="total_panel" @click="showDetail()">
  20. <div class="title">NFC</div>
  21. <div class="content">
  22. <span class="con_num ok">已扫 {{ resumptionData.yesNFCNums }}</span>
  23. <span class="con_num no">未扫 {{ resumptionData.noNFCNums }}</span>
  24. </div>
  25. </div>
  26. </van-col>
  27. </van-row>
  28. </div>
  29. </van-panel>
  30. </div>
  31. <div class="progress">
  32. <van-progress
  33. :percentage="
  34. (
  35. ((resumptionData.yesPointNums + resumptionData.yesNFCNums) /
  36. (resumptionData.yesPointNums +
  37. resumptionData.noPointNums +
  38. resumptionData.yesNFCNums +
  39. resumptionData.noNFCNums)) *
  40. 100
  41. ).toFixed(2)
  42. "
  43. />
  44. </div>
  45. <!-- 检查区域 -->
  46. <div class="card">
  47. <van-panel title="巡检区域">
  48. <div style="padding: 5px">
  49. <van-row>
  50. <van-col span="8" v-for="(va, i) in areas" :key="va.areaId">
  51. <div :class="{ active: i === 0 }" class="check-area" @click="clickArea(va, i)">
  52. <div class="ysj">
  53. <van-icon name="checked" :color="areaColor.complete" v-if="va.areaStatus === '1'" />
  54. <van-icon name="info" :color="areaColor.loading" v-if="va.areaStatus === '2'" />
  55. <van-icon name="info" :color="areaColor.noOpen" v-if="va.areaStatus === '0'" />
  56. </div>
  57. {{ va.areaName }}
  58. </div>
  59. </van-col>
  60. </van-row>
  61. </div>
  62. </van-panel>
  63. </div>
  64. <van-action-sheet v-model="total_show">
  65. <div class="content">
  66. <van-tabs>
  67. <van-tab title="已扫描" name="a">
  68. <van-list finished-text="没有更多了" @load="onLoad">
  69. <van-cell v-for="item in yesList" :key="item.nfcCode" :title="item.nfcName"></van-cell>
  70. </van-list>
  71. </van-tab>
  72. <van-tab title="未扫描" name="b">
  73. <van-list finished-text="没有更多了" @load="onLoad">
  74. <van-cell v-for="item in noList" :key="item.nfcCode" :title="item.nfcName">
  75. <!-- <img :src="require('../../../assets/svg/NFC.svg')" class="nfc-icon"/>-->
  76. </van-cell>
  77. </van-list>
  78. </van-tab>
  79. </van-tabs>
  80. </div>
  81. </van-action-sheet>
  82. <div class="card">
  83. <van-row>
  84. <van-col span="16">
  85. <van-cell>
  86. <template #title>
  87. <span>NFC</span>
  88. </template>
  89. <template #extra>
  90. <span style="display: inline-block; color: #26850c">{{ yesNFCnums }}</span>
  91. <span style="display: inline-block; color: #0e0e0e">/</span>
  92. <span style="display: inline-block; color: #0e0e0e">{{ NFCnums }}</span>
  93. <img :src="require('../../../assets/svg/NFC.svg')" class="nfc-icon" @click="clickNFC" />
  94. </template>
  95. </van-cell>
  96. </van-col>
  97. <van-col span="8">
  98. <van-cell>
  99. <div class="okAll">
  100. <van-radio-group v-if="enable" v-model="selectRadio" @change="changeSwitch">
  101. <van-radio name="1" icon-size="20px">一键填充</van-radio>
  102. </van-radio-group>
  103. </div>
  104. </van-cell>
  105. </van-col>
  106. </van-row>
  107. <van-row>
  108. <van-col span="24">
  109. <van-cell v-show="currentImgNFC.length > 0" :border="false">
  110. <div
  111. v-if="v.areaId === areaId && v.img"
  112. class="nfc-img"
  113. v-for="(v, i) in nfcs"
  114. :key="v.img"
  115. @click="preViewNFC(i)"
  116. >
  117. <img :src="imgUrl(v.img)" alt="" />
  118. <span>{{ v.nfcName }}</span>
  119. <div v-if="enable" class="cancel_icon" @click="cancelImg(v)">
  120. <van-icon name="clear" />
  121. </div>
  122. </div>
  123. </van-cell>
  124. </van-col>
  125. </van-row>
  126. <van-collapse v-model="activeNames">
  127. <van-collapse-item
  128. v-show="areaId === item.areaId"
  129. v-for="item in checks"
  130. :title="item.itemName + '(' + item.points.length + ')'"
  131. :name="item.itemName"
  132. :key="item.areaId"
  133. >
  134. <div v-for="(point, index) in item.points">
  135. <van-cell>
  136. <template #title>
  137. <pre>{{ point.pointName }}</pre>
  138. </template>
  139. <template #right-icon>
  140. <van-switch
  141. style="margin-left: 10px"
  142. v-model="point.resValue"
  143. v-show="point.dataStatus === 2"
  144. v-if="enable"
  145. :active-value="1"
  146. :inactive-value="0"
  147. inactive-color="#4fc08d"
  148. active-color="#ee0a24"
  149. size="18"
  150. />
  151. <span v-else>
  152. <van-tag v-if="point.resValue === 1" type="warning">异常</van-tag>
  153. <van-tag v-else type="success">正常</van-tag>
  154. </span>
  155. <van-switch
  156. style="margin-left: 10px"
  157. v-model="point.dataStatus"
  158. v-show="point.dataStatus === 1"
  159. :active-value="2"
  160. :inactive-value="1"
  161. inactive-color="#fcfcfc"
  162. active-color="#ee0a24"
  163. size="18"
  164. @change="changeCurrentSwitch(item.areaId)"
  165. />
  166. </template>
  167. </van-cell>
  168. <van-cell-group v-show="point.resValue">
  169. <select-cell
  170. :required="enable"
  171. :disabled="!enable"
  172. title="整改期限"
  173. name="rectificationDeadline"
  174. v-model="point.rectificationDeadline"
  175. :data-list="dayList"
  176. />
  177. <van-field
  178. :rules="[{ required: enable, message: '请输入情况描述' }]"
  179. :required="enable"
  180. v-model="point.resRemark"
  181. :readonly="!enable"
  182. rows="1"
  183. name="resRemark"
  184. autosize
  185. label="情况描述"
  186. type="textarea"
  187. placeholder="请输入情况描述"
  188. />
  189. <div class="upload-box">
  190. <uploader :maxCount="5" v-if="enable" v-model="point.imgs" />
  191. <van-cell v-else>
  192. <div
  193. class="nfc-img van-hairline--surround"
  194. v-for="(v, i) in point.imgs"
  195. :key="v.imgPath"
  196. @click="clickWarnImage(point.imgs, i)"
  197. >
  198. <img :src="imgUrl(v.imgPath)" alt="" />
  199. <span>{{ v.checkName }}</span>
  200. </div>
  201. </van-cell>
  202. </div>
  203. </van-cell-group>
  204. </div>
  205. </van-collapse-item>
  206. </van-collapse>
  207. </div>
  208. <div class="bottomClass" v-if="enable">
  209. <van-row>
  210. <van-col span="12">
  211. <van-button type="default" @click="resumptionDataSave">保存</van-button>
  212. </van-col>
  213. <van-col span="12">
  214. <van-button type="info" @click="submitResumptionData">提交</van-button>
  215. </van-col>
  216. </van-row>
  217. </div>
  218. <!-- nfc弹窗 -->
  219. <nfc-popup v-if="enable" ref="NfcPopup" @change="changeNfcImg"></nfc-popup>
  220. </van-form>
  221. </div>
  222. </template>
  223. <script>
  224. import { ImagePreview, Dialog } from 'vant'
  225. import NavBar from '@/components/NavBar/index.vue'
  226. import Uploader from '@/components/upload/uploader.vue'
  227. import SelectCell from '@/components/selectCell/index.vue'
  228. import { getDict } from '@/api/toConsult'
  229. import { saveTask, taskDetail } from '@/views/menu/resumption/api'
  230. import NfcPopup from '@/components/nfcPopup/more'
  231. import { imgUrl } from '@/utils'
  232. import dayjs from 'dayjs'
  233. import { mapGetters } from 'vuex'
  234. import { ref } from 'vue'
  235. export default {
  236. components: {
  237. SelectCell,
  238. Uploader,
  239. NavBar,
  240. NfcPopup,
  241. imgUrl,
  242. [Dialog.Component.name]: Dialog.Component
  243. },
  244. data() {
  245. return {
  246. areaColor: {
  247. // 已完成
  248. complete: '#26850c',
  249. // 未开始
  250. noOpen: '#1989fa',
  251. // 进行中
  252. loading: '#ffa500'
  253. },
  254. NFCnums: 0,
  255. yesNFCnums: 0,
  256. currentImgNFC: [],
  257. areaId: null,
  258. resumptionData: {},
  259. areas: [],
  260. checks: [],
  261. nfcs: [],
  262. selectRadio: 0,
  263. total_show: false,
  264. enable: false,
  265. activeNames: [],
  266. dayList: [15, 30, 90, 180],
  267. yesList: [],
  268. noList: [],
  269. loading: false,
  270. finished: false,
  271. selectArea: null,
  272. preViewImages: {
  273. images: [],
  274. startPosition: 0
  275. }
  276. }
  277. },
  278. computed: {
  279. ...mapGetters(['id'])
  280. },
  281. mounted() {
  282. this.getResumptionData()
  283. },
  284. created() {
  285. getDict('rectification_deadline').then(res => {
  286. let { data } = res
  287. this.dayList = data
  288. })
  289. },
  290. methods: {
  291. preViewNFC(i) {
  292. this.preViewImages.images = this.currentImgNFC.map(v => imgUrl(v.img))
  293. this.preViewImages.startPosition = i
  294. ImagePreview(this.preViewImages)
  295. },
  296. clickWarnImage(arr, i) {
  297. this.preViewImages.images = arr.map(v => imgUrl(v.imgPath))
  298. this.preViewImages.startPosition = i
  299. ImagePreview(this.preViewImages)
  300. },
  301. getResumptionData() {
  302. let data = {
  303. taskId: this.$route.query.id,
  304. taskDate: this.$route.query.taskDate
  305. }
  306. taskDetail(data).then(res => {
  307. let { taskId, taskName, yesPointNums, noPointNums, yesNFCNums, noNFCNums, status } = res.data
  308. this.resumptionData = {
  309. taskId,
  310. taskName,
  311. yesPointNums,
  312. noPointNums,
  313. yesNFCNums,
  314. noNFCNums,
  315. status
  316. }
  317. this.enable = this.resumptionData.status === 1 || this.resumptionData.status === 2
  318. this.checks = res.data.checks
  319. this.nfcs = res.data.nfcs
  320. this.areas = res.data.areas
  321. this.activeArea(this.areas[0], 0)
  322. if (!this.enable) {
  323. this.openCollapseItems()
  324. }
  325. })
  326. },
  327. openCollapseItems() {
  328. let len = this.checks.length
  329. for (let i = 0; i < len; i++) {
  330. let title = this.checks[i].itemName
  331. this.activeNames.push(title)
  332. }
  333. },
  334. changeSwitch() {
  335. let num = 0
  336. for (let i = 0; i < this.checks.length; i++) {
  337. for (let j = 0; j < this.checks[i].points.length; j++) {
  338. this.checks[i].points[j].dataStatus = 2
  339. num++
  340. }
  341. }
  342. this.resumptionData.yesPointNums = num
  343. this.resumptionData.noPointNums = 0
  344. this.areas.forEach((item, index) => {
  345. this.validateArea(item.areaId)
  346. })
  347. this.openCollapseItems()
  348. },
  349. changeCurrentSwitch(areaId) {
  350. this.resumptionData.yesPointNums = this.resumptionData.yesPointNums + 1
  351. this.resumptionData.noPointNums = this.resumptionData.noPointNums - 1
  352. this.validateArea(areaId)
  353. },
  354. validateArea(areaId) {
  355. let total = 0
  356. let yes = 0
  357. this.checks.forEach(item => {
  358. let pointList = item.points
  359. pointList.forEach(point => {
  360. if (item.areaId === areaId) {
  361. total++
  362. if (point.dataStatus === 2) {
  363. yes++
  364. }
  365. }
  366. })
  367. })
  368. let noNfc = this.nfcs.filter((item, index) => {
  369. return item.areaId === areaId && item.status === 0
  370. })
  371. let areaStatus = '0'
  372. if (total === yes && noNfc.length === 0) {
  373. areaStatus = '1'
  374. } else if (yes === 0 && noNfc.length === this.NFCnums) {
  375. areaStatus = '0'
  376. } else {
  377. areaStatus = '2'
  378. }
  379. this.areas.forEach((item, index) => {
  380. if (item.areaId === areaId) {
  381. this.areas[index].areaStatus = areaStatus
  382. }
  383. })
  384. },
  385. clickNFC() {
  386. let arr = this.nfcs.filter(item => {
  387. return item.areaId === this.areaId && item.status === 0
  388. })
  389. if (arr.length > 0) {
  390. let nfcs = []
  391. for (const nfc of arr) {
  392. let pro = {}
  393. pro.checkName = nfc.nfcName
  394. pro.nfccdoe = nfc.nfcCode
  395. nfcs.push(pro)
  396. }
  397. this.$refs.NfcPopup.show(nfcs)
  398. }
  399. },
  400. cancelImg(imgItem) {
  401. let areaId = null
  402. this.nfcs.forEach(v => {
  403. if (v.nfcCode === imgItem.nfcCode) {
  404. areaId = v.areaId
  405. v.img = imgItem.url
  406. v.status = 0
  407. v.scanMethod = null
  408. }
  409. })
  410. let now = this.currentImgNFC.filter(v => {
  411. return v.nfcCode !== imgItem.nfcCode
  412. })
  413. this.currentImgNFC = now
  414. this.yesNFCnums--
  415. this.resumptionData.yesNFCNums--
  416. this.resumptionData.noNFCNums++
  417. this.validateArea(areaId)
  418. },
  419. changeNfcImg(imgItem) {
  420. let areaId = null
  421. this.nfcs.forEach(v => {
  422. if (v.nfcCode === imgItem.nfcCode) {
  423. areaId = v.areaId
  424. v.img = imgItem.url
  425. v.status = 1
  426. v.scanMethod = 1
  427. v.submitTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
  428. v.submitBy = this.id
  429. this.currentImgNFC.push(v)
  430. }
  431. })
  432. this.yesNFCnums++
  433. this.resumptionData.yesNFCNums++
  434. this.resumptionData.noNFCNums--
  435. this.validateArea(areaId)
  436. },
  437. showDetail() {
  438. this.total_show = true
  439. },
  440. onLoad() {
  441. // 异步更新数据
  442. // setTimeout 仅做示例,真实场景中一般为 ajax 请求
  443. this.yesList = []
  444. this.noList = []
  445. this.nfcs.forEach((item, index) => {
  446. if (item.status === 1) {
  447. this.yesList.push(item)
  448. } else {
  449. this.noList.push(item)
  450. }
  451. })
  452. },
  453. //点击区域
  454. clickArea(area, index) {
  455. this.activeArea(area, index)
  456. },
  457. //选中区域时数据变更
  458. activeArea(area, index) {
  459. //获取当前选中区域
  460. this.areaId = area.areaId
  461. //设置选中样式
  462. this.$nextTick(() => {
  463. let doms = document.getElementsByClassName('check-area')
  464. Array.prototype.forEach.call(doms, item => {
  465. item.classList.remove('active')
  466. })
  467. doms[index].classList.add('active')
  468. })
  469. let nfcs = 0
  470. let yesNfc = 0
  471. let current = []
  472. for (let i = 0; i < this.nfcs.length; i++) {
  473. let nfc = this.nfcs[i]
  474. let areaId = nfc.areaId
  475. if (areaId === area.areaId) {
  476. nfcs++
  477. if (nfc.status === 1) {
  478. yesNfc++
  479. }
  480. if (nfc.img) {
  481. current.push(nfc)
  482. }
  483. }
  484. }
  485. this.currentImgNFC = current
  486. this.yesNFCnums = yesNfc
  487. this.NFCnums = nfcs
  488. this.selectArea = area
  489. },
  490. //保存数据
  491. resumptionDataSave() {
  492. //组装数据
  493. let data = {}
  494. data.taskId = this.resumptionData.taskId
  495. data.checks = this.checks
  496. data.nfcs = this.nfcs
  497. data.subType = 1
  498. saveTask(data).then(res => {
  499. this.$toast('保存成功')
  500. this.$router.go(-1)
  501. })
  502. },
  503. submitResumptionData() {
  504. //验证数据
  505. let noNfc = this.nfcs.filter((item, index) => {
  506. return item.status === 0
  507. })
  508. if (noNfc.length > 0) {
  509. Dialog.alert({
  510. message: 'NFC标签还未扫描完成,请完成后提交!'
  511. })
  512. return false
  513. }
  514. let isOk = true
  515. this.checks.forEach(item => {
  516. let pointList = item.points
  517. pointList.forEach(point => {
  518. if (point.dataStatus === 1) {
  519. Dialog.alert({
  520. message: '还有未完成的内容,请先完成再提交?'
  521. })
  522. throw new Error('有项目未完成')
  523. } else {
  524. if (point.resValue === 1) {
  525. if (!point.rectificationDeadline || !point.resRemark) {
  526. this.changeSwitch()
  527. this.areas.forEach((area, i) => {
  528. if (area.areaId === item.areaId) {
  529. this.activeArea(area, i)
  530. //切换后验证表单
  531. this.$refs.resumption_form.validate()
  532. this.$toast({
  533. message: '请完成异常情况的信息填写!',
  534. position: 'top'
  535. })
  536. }
  537. })
  538. throw new Error('有异常项目未完成')
  539. }
  540. }
  541. }
  542. })
  543. })
  544. let data = {}
  545. data.taskId = this.resumptionData.taskId
  546. data.checks = this.checks
  547. data.nfcs = this.nfcs
  548. data.subType = 2
  549. saveTask(data).then(res => {
  550. this.$toast('提交成功')
  551. this.$router.go(-1)
  552. })
  553. }
  554. }
  555. }
  556. </script>
  557. <style lang="scss" scoped>
  558. .van-progress {
  559. z-index: 999;
  560. width: 98%;
  561. left: 6px;
  562. right: 6px;
  563. }
  564. .page_box {
  565. height: calc(100vh - 60px);
  566. overflow: scroll;
  567. }
  568. .content {
  569. padding: 16px 16px 10px;
  570. }
  571. .panel {
  572. background-color: white;
  573. border-radius: 10px;
  574. border: 1px solid #ffffff;
  575. display: flex;
  576. flex-direction: column;
  577. box-shadow: 0 8px 12px #ebedf0;
  578. margin-bottom: 10px;
  579. .van-cell__title {
  580. font-weight: bold;
  581. }
  582. }
  583. .total_panel {
  584. text-align: center;
  585. .title {
  586. padding-top: 10px;
  587. }
  588. .content {
  589. padding-top: 10px;
  590. padding-bottom: 10px;
  591. .con_num {
  592. padding: 15px;
  593. }
  594. .ok {
  595. color: #26850c;
  596. }
  597. .no {
  598. color: #98632d;
  599. }
  600. }
  601. }
  602. .card {
  603. box-shadow: 0 10px 10px #eaeaea;
  604. height: 50px;
  605. }
  606. .van-popup {
  607. height: 50%;
  608. }
  609. .check-area {
  610. //background-color: #f1f1f1;
  611. text-align: center;
  612. margin: 10px;
  613. padding: 20px;
  614. //color: #aaa;
  615. border-radius: 6px;
  616. justify-content: space-between;
  617. align-items: center;
  618. box-shadow: 0 2px 6px #ddd;
  619. position: relative;
  620. .ysj {
  621. position: absolute;
  622. right: 5px;
  623. top: 5px;
  624. }
  625. }
  626. .active {
  627. background-color: #bdbdbd;
  628. color: #333;
  629. }
  630. .complete {
  631. color: #fff;
  632. background-color: #1989fa;
  633. }
  634. .nfc-icon {
  635. width: 50px;
  636. height: 50px;
  637. margin-left: 20px;
  638. }
  639. .bottomClass {
  640. position: fixed;
  641. width: 100%;
  642. bottom: 0;
  643. z-index: 999;
  644. background: #ebedf0;
  645. text-align: center;
  646. .van-button {
  647. width: 95%;
  648. margin-top: 10px;
  649. }
  650. }
  651. .okAll {
  652. background-color: #fff;
  653. display: flex;
  654. justify-content: center;
  655. align-items: center;
  656. height: 50px;
  657. }
  658. .nfc-img {
  659. display: inline-block;
  660. width: 160px;
  661. height: 160px;
  662. margin: 0 10px;
  663. position: relative;
  664. > img {
  665. width: 100%;
  666. height: 100%;
  667. border: none;
  668. }
  669. > span {
  670. position: absolute;
  671. padding: 0 10px;
  672. bottom: 0;
  673. left: 0;
  674. display: block;
  675. width: 100%;
  676. background-color: rgba(0, 0, 0, 0.2);
  677. color: #eaeaea;
  678. font-size: 5px;
  679. overflow: hidden;
  680. text-overflow: ellipsis;
  681. line-height: 30px;
  682. white-space: break-spaces;
  683. height: 30px;
  684. }
  685. .cancel_icon {
  686. position: absolute;
  687. font-size: 30px;
  688. right: 5px;
  689. top: 2px;
  690. }
  691. }
  692. </style>