scanning.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. <template>
  2. <view class="ccc scning">
  3. <view style="width: 200rpx">
  4. <u-tabs bar-width="80" item-width="80" :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
  5. </view>
  6. <scroll-view :scroll-y="true" class="u-p-l-30 u-p-r-30 u-p-b-48 scrll-height u-p-t-26">
  7. <block v-if="current == 0">
  8. <u-cell-group>
  9. <u-cell-item
  10. :value="scmdata.name"
  11. bg-color="#ffffff"
  12. :border-bottom="true"
  13. :border-top="false"
  14. :title-style="{ fontSize: '28rpx', color: '#333333', fontWeight: 'bold' }"
  15. :value-style="{ fontSize: '28rpx', color: '#808080' }"
  16. :arrow="false"
  17. title="点位名称"
  18. ></u-cell-item>
  19. <u-cell-item
  20. :value="scmdata.id"
  21. bg-color="#ffffff"
  22. :border-bottom="true"
  23. :border-top="false"
  24. :title-style="{ fontSize: '28rpx', color: '#333333', fontWeight: 'bold' }"
  25. :value-style="{ fontSize: '28rpx', color: '#808080' }"
  26. :arrow="false"
  27. title="房间编号"
  28. ></u-cell-item>
  29. <u-cell-item
  30. :value="scmdata.buildingName + scmdata.floorName"
  31. bg-color="#ffffff"
  32. :border-bottom="true"
  33. :border-top="false"
  34. :title-style="{ fontSize: '28rpx', color: '#333333', fontWeight: 'bold' }"
  35. :value-style="{ fontSize: '28rpx', color: '#808080' }"
  36. :arrow="false"
  37. title="房间位置"
  38. ></u-cell-item>
  39. <u-cell-item
  40. :value="scmdata.taskName"
  41. bg-color="#ffffff"
  42. :border-bottom="true"
  43. :border-top="false"
  44. :title-style="{ fontSize: '28rpx', color: '#333333', fontWeight: 'bold' }"
  45. :value-style="{ fontSize: '28rpx', color: '#808080' }"
  46. :arrow="false"
  47. title="巡检计划"
  48. ></u-cell-item>
  49. </u-cell-group>
  50. <view class="collect_tit u-row-left u-flex">
  51. <view class="tit">巡检项目</view>
  52. <image :src="icon1"></image>
  53. <span>设备:{{ scmdata.devices.length }}件</span>
  54. <image :src="icon2"></image>
  55. <span>项目:{{ checkItemCount }}个</span>
  56. </view>
  57. <!-- 自带项目巡检-设备名 -->
  58. <view class="zidai_xiangmu">
  59. <label class="sel_point u-flex u-row-between" @click="sel_show1()">
  60. <view class="sel_tit u-flex u-row-left u-m-l-26">
  61. <span>{{ scmdata.name }}自带项目</span>
  62. <sup class="sup">*</sup>
  63. </view>
  64. <view class="triangle u-m-r-26" :style="tri_style1"></view>
  65. </label>
  66. <!-- 巡检项目名 -->
  67. <view class="scan_itm1" v-show="itm1_show" v-for="(item1, i) in scmdata.checkItems" :key="item1.id">
  68. <view class="tit u-m-t-32">
  69. <view class="u-flex u-row-left u-col-center">
  70. <span>{{ i + 1 }}.{{ item1.checkItem.checkItem.itemName }}</span>
  71. <sup class="sup" v-if="item1.checkItem.checkItem.isRequired">*</sup>
  72. </view>
  73. <view class="u-m-t-12">
  74. <span style="color: #b3b3b3; font-size: 24rpx" v-if="item1.checkItem.extra.validMinValue != null">
  75. {{ '填值范围:' + item1.checkItem.extra.validMinValue + '~' + item1.checkItem.extra.validMaxValue }}
  76. </span>
  77. </view>
  78. </view>
  79. <!-- 选择类巡检操作 -->
  80. <!-- 单选 -->
  81. <block v-if="item1.checkItem.checkItem.itemType == 1 && item1.checkItem.allowMultiple == false">
  82. <scaradio ref="scarad" :scan_id="item1.id" :options="item1.checkItem.options" />
  83. </block>
  84. <!-- 多选 -->
  85. <block v-if="item1.checkItem.checkItem.itemType == 1 && item1.checkItem.allowMultiple == true">
  86. <scachebox v-if="item1" ref="scachb" :scan_id="item1.id" :options="item1.checkItem.options" />
  87. </block>
  88. <!-- 数字类巡检操作 -->
  89. <block v-if="item1.checkItem.checkItem.itemType == 2">
  90. <scanum
  91. v-if="item1"
  92. ref="scanum"
  93. :scan_id="item1.id"
  94. :min="item1.checkItem.extra.validMinValue"
  95. :max="item1.checkItem.extra.validMaxValue"
  96. :places="item1.checkItem.extra.decimalPlaces"
  97. />
  98. </block>
  99. <!-- 文本类巡检操作 -->
  100. <block v-if="item1.checkItem.checkItem.itemType == 3">
  101. <scatex v-if="item1" :defaultValue="item1.checkItem.checkItem.defaultValue" ref="scatex" :scan_id="item1.id" />
  102. </block>
  103. <!-- 拍照类巡检操作 -->
  104. <block v-if="item1.checkItem.checkItem.itemType == 4">
  105. <scaimg v-if="item1" ref="scaimg" :scan_id="item1.id" :photoPoints="item1.checkItem.photoPoints" />
  106. </block>
  107. </view>
  108. </view>
  109. <!-- 巡检设备-设备名 -->
  110. <block class="xunjain_shebei" v-for="(item3, j) in scmdata.devices" :key="j">
  111. <label class="sel_point u-flex u-row-between u-m-t-40" @click="sel_show(j)">
  112. <view class="sel_tit u-flex u-row-left u-m-l-26">
  113. <span>{{ item3.deviceName }}</span>
  114. <sup class="sup">*</sup>
  115. </view>
  116. <view class="triangle u-m-r-26" :style="sel_style[j].tri_style"></view>
  117. </label>
  118. <!-- 巡检项目名 -->
  119. <view v-show="sel_style[j].it_show">
  120. <block class="scan_itm1" v-for="(item4, i) in item3.checkItems" :key="item4.id">
  121. <view class="tit u-m-t-32">
  122. <view class="u-flex u-row-left u-col-center">
  123. <span>{{ i + 1 }}.{{ item4.checkItem.checkItem.itemName }}</span>
  124. <sup class="sup" v-if="item4.checkItem.checkItem.isRequired">*</sup>
  125. </view>
  126. <view class="u-m-t-12">
  127. <span style="color: #b3b3b3; font-size: 24rpx" v-if="item4.checkItem.extra.validMinValue != null">
  128. {{ '填值范围:' + item4.checkItem.extra.validMinValue + '~' + item4.checkItem.extra.validMaxValue }}
  129. </span>
  130. </view>
  131. </view>
  132. <!-- 选择类巡检操作 -->
  133. <!-- 单选 -->
  134. <block v-if="item4.checkItem.checkItem.itemType == 1 && item4.checkItem.allowMultiple == false">
  135. <scaradio v-if="item4" ref="scarad" :scan_id="item4.id" :options="item4.checkItem.options" />
  136. </block>
  137. <!-- 多选 -->
  138. <block v-if="item4.checkItem.checkItem.itemType == 1 && item4.checkItem.allowMultiple == true">
  139. <scachebox v-if="item4" ref="scachb" :scan_id="item4.id" :options="item4.checkItem.options" />
  140. </block>
  141. <!-- 数字类巡检操作 -->
  142. <block v-if="item4.checkItem.checkItem.itemType == 2">
  143. <scanum
  144. v-if="item4"
  145. ref="scanum"
  146. :scan_id="item4.id"
  147. :min="item4.checkItem.extra.validMinValue"
  148. :max="item4.checkItem.extra.validMaxValue"
  149. :places="item4.checkItem.extra.decimalPlaces"
  150. />
  151. </block>
  152. <!-- 文本类巡检操作 -->
  153. <block v-if="item4.checkItem.checkItem.itemType == 3">
  154. <scatex v-if="item4" :defaultValue="item4.checkItem.checkItem.defaultValue" ref="scatex" :scan_id="item4.id" />
  155. </block>
  156. <!-- 拍照类巡检操作 -->
  157. <block v-if="item4.checkItem.checkItem.itemType == 4">
  158. <scaimg v-if="item4" ref="scaimg" :scan_id="item4.id" :photoPoints="item4.checkItem.photoPoints" />
  159. </block>
  160. </block>
  161. </view>
  162. </block>
  163. <u-button :hair-line="false" ripple-bg-color="blue" :disabled="guan" @click="scabtnclick" :custom-style="customStyle">确定</u-button>
  164. </block>
  165. <block v-else>
  166. <protow :option="option" :taskName="scmdata.taskName" :position="scmdata.buildingName + scmdata.floorName" />
  167. </block>
  168. </scroll-view>
  169. <!-- <u-tabbar :list="tabbar" :mid-button="true"></u-tabbar> -->
  170. <!-- 记录页面 -->
  171. <u-toast ref="sacast" />
  172. </view>
  173. </template>
  174. <script>
  175. import icon1 from '@/static/img/devi.png'
  176. import icon2 from '@/static/img/proj.png'
  177. // import jia from '@/static/img/jia.png'
  178. import { mapState } from 'vuex'
  179. import { partinfo, checkItemlist, patrolRecord, listForMobile } from '@/api/index.js'
  180. import dayjs from 'dayjs'
  181. import scaradio from './scanItem/scanradio.vue'
  182. import scachebox from './scanItem/scanchebox.vue'
  183. import scanum from './scanItem/scannum.vue'
  184. import scatex from './scanItem/scantex.vue'
  185. import scaimg from './scanItem/scanimg.vue'
  186. import protow from './protow'
  187. export default {
  188. name: 'sacnning',
  189. components: {
  190. scaradio,
  191. scachebox,
  192. scanum,
  193. scatex,
  194. scaimg,
  195. protow
  196. },
  197. data() {
  198. return {
  199. icon1: icon1,
  200. icon2: icon2,
  201. tri_style1: '', //自带项目三角形样式变化
  202. itm1_show: true, //自带项目三角形样式变化
  203. sel_style: [], //设备巡检下拉虚拟DOM数组
  204. //上方导航项
  205. list: [
  206. {
  207. name: '巡检'
  208. },
  209. {
  210. name: '记录'
  211. }
  212. ],
  213. current: 0, //跳转栏
  214. option: undefined, //跳转页面的option
  215. scmdata: undefined, //巡检数据
  216. checkItemCount: 0, //项目数
  217. guan: false,
  218. uploadlist: [],
  219. // uploadlist1:[],
  220. dataindex: 1,
  221. fromcasl: {},
  222. timerefs: new Date().getTime(), //因为用了$set的原因 多列表会不刷新 加入一个key 会让子组件重新渲染
  223. finishStatus: ['', '按时完成', '尚未巡检', '超时漏检', '提前完成', '延时完成'],
  224. fromarray: [],
  225. user: uni.getStorageSync('user'),
  226. customStyle: {
  227. width: '690rpx',
  228. height: '90rpx',
  229. marginBottom: '48rpx',
  230. background: '#4A8BFF',
  231. borderRadius: '4rpx',
  232. border: 'none',
  233. fontSize: '28rpx',
  234. fontFamily: 'Microsoft YaHei-3970(82674968)',
  235. fontWeight: 'bold',
  236. color: '#FFFFFF',
  237. textAlign: 'center',
  238. lineHeight: '90rpx !important',
  239. marginTop: '48rpx'
  240. }
  241. }
  242. },
  243. computed: {
  244. ...mapState({
  245. tabbar: (state) => state.tabbar.tabbar,
  246. timer: (state) => state.user.timer
  247. })
  248. },
  249. onLoad(option) {
  250. if (this.option) {
  251. this.init(option.roomId, option.taskId)
  252. } else {
  253. this.option = option
  254. this.init(option.roomId, option.taskId)
  255. }
  256. },
  257. methods: {
  258. //自带项目三角样式变化
  259. sel_show1() {
  260. this.itm1_show = !this.itm1_show
  261. if (!this.itm1_show) {
  262. this.tri_style1 = 'margin-top: 0rpx;margin-bottom:10rpx;border-top-color:transparent;border-bottom-color: #808080;'
  263. } else {
  264. this.tri_style1 = 'margin-top: 10rpx;margin-bottom:0rpx;border-top-color:#808080;border-bottom-color: transparent;'
  265. }
  266. },
  267. //设备三角形样式变化
  268. sel_show(index) {
  269. // obj.tri_style
  270. // obj.it_show
  271. this.sel_style[index].it_show = !this.sel_style[index].it_show
  272. if (!this.sel_style[index].it_show) {
  273. this.sel_style[index].tri_style = 'margin-top: 0rpx;margin-bottom:10rpx;border-top-color:transparent;border-bottom-color: #808080;'
  274. } else {
  275. this.sel_style[index].tri_style = 'margin-top: 10rpx;margin-bottom:0rpx;border-top-color:#808080;border-bottom-color: transparent;'
  276. }
  277. },
  278. // 顶部跳转栏
  279. change(index) {
  280. this.current = index
  281. },
  282. //处理提交数据
  283. async scabtnclick() {
  284. this.guan = true
  285. this.customStyle.background = 'grey'
  286. try {
  287. await this.sumitComponent()
  288. console.log('数据提交前确认', this.$store.state.user.items) // TODO isRequired
  289. this.scanSubmit()
  290. } catch {
  291. this.$refs.sacast.show({
  292. title: '提交失败,请稍后再试'
  293. })
  294. //开启按钮
  295. this.customStyle.background = '#4A8BFF'
  296. this.guan = false
  297. }
  298. },
  299. async sumitComponent() {
  300. if (this.$refs.scaimg) {
  301. for (let i = 0; i < this.$refs.scaimg.length; i++) {
  302. await this.$refs.scaimg[i].submit()
  303. }
  304. this.$refs.sacast.show({
  305. title: '图片上传中...'
  306. // 如果不传此type参数,默认为default,也可以手动写上 type: 'default'
  307. // type: 'success',
  308. // 如果不需要图标,请设置为false
  309. // icon: false
  310. })
  311. }
  312. if (this.$refs.scatex) {
  313. this.$refs.scatex.forEach((i) => {
  314. i.submit()
  315. })
  316. }
  317. if (this.$refs.scanum) {
  318. this.$refs.scanum.forEach((i) => {
  319. i.submit()
  320. })
  321. }
  322. if (this.$refs.scarad) {
  323. this.$refs.scarad.forEach((i) => {
  324. i.submit()
  325. })
  326. }
  327. if (this.$refs.scachb) {
  328. this.$refs.scachb.forEach((i) => {
  329. i.submit()
  330. })
  331. }
  332. },
  333. //提交数据接口
  334. async scanSubmit() {
  335. //能改
  336. setTimeout(() => {
  337. //开启按钮
  338. this.customStyle.background = '#4A8BFF'
  339. this.guan = false
  340. }, 3000)
  341. let { message, code, data } = await patrolRecord({
  342. roomId: this.option.roomId,
  343. taskId: this.option.taskId,
  344. items: this.$store.state.user.items
  345. })
  346. if (code == 200) {
  347. //清空提交巡检数据数组
  348. this.$store.state.user.items = []
  349. this.$refs.sacast.show({
  350. title: '巡检完成',
  351. type: 'success'
  352. })
  353. //跳转巡检记录
  354. this.change(1)
  355. } else {
  356. //清空提交巡检数据数组
  357. console.log('this.$store.state.user.items', this.$store.state.user.items)
  358. this.$store.state.user.items = []
  359. this.$refs.sacast.show({
  360. title: message,
  361. type: 'warning'
  362. })
  363. }
  364. },
  365. //重置表单(未用到,只需更新items为空数组,其他会随组件刷新)
  366. scanReset() {
  367. this.$nextTick(() => {
  368. if (this.$refs.scatex) {
  369. this.$refs.scatex.forEach((i) => {
  370. i.reset()
  371. })
  372. }
  373. if (this.$refs.scanum) {
  374. this.$refs.scanum.forEach((i) => {
  375. i.reset()
  376. })
  377. }
  378. if (this.$refs.scarad) {
  379. this.$refs.scarad.forEach((i) => {
  380. i.reset()
  381. })
  382. }
  383. if (this.$refs.scaimg) {
  384. this.$refs.scaimg.forEach((i) => {
  385. i.reset()
  386. })
  387. }
  388. if (this.$refs.scachb) {
  389. this.$refs.scachb.forEach((i) => {
  390. i.reset()
  391. })
  392. }
  393. })
  394. },
  395. //获取巡检房间信息与巡检检查项目规则
  396. init(roomId, taskId) {
  397. checkItemlist({
  398. taskId,
  399. roomId
  400. }).then(({ data }) => {
  401. //处理自带巡检项目数据
  402. if (data.checkItems.length != 0) {
  403. //处理自带巡检项JSON数据
  404. data.checkItems.forEach((i) => {
  405. i.checkItem = JSON.parse(i.checkItem)
  406. })
  407. }
  408. //计算巡检项目数量
  409. this.checkItemCount += data.checkItems.length
  410. //处理设备巡检项目数据
  411. if (data.devices.length != 0) {
  412. data.devices.forEach((i) => {
  413. this.checkItemCount += i.checkItems.length
  414. let obj = {}
  415. obj.tri_style = 'margin-top: 10rpx;margin-bottom:0rpx;border-top-color:#808080;border-bottom-color: transparent;'
  416. obj.it_show = true
  417. this.sel_style.push(obj)
  418. //处理设备巡检项JSON数据
  419. i.checkItems.forEach((h) => {
  420. h.checkItem = JSON.parse(h.checkItem)
  421. })
  422. })
  423. }
  424. this.scmdata = data
  425. console.log(this.scmdata)
  426. })
  427. },
  428. recyle(e) {
  429. const { key, boll, name } = e
  430. this.$set(this.from.aircondparol, key, {
  431. name,
  432. boll: !boll
  433. }) //与组件那边同步刷新
  434. this.timerefs = new Date().getTime() //刷新父组件
  435. // this.$forceUpdate()
  436. },
  437. raidodx(index) {
  438. let fromarray = this.fromarray
  439. if (fromarray.length == 0) {
  440. this.fromarray.push(index)
  441. } else {
  442. let sum
  443. let a = fromarray.find((index2, key) => {
  444. sum = -1
  445. if (index2.itemId == index.itemId) {
  446. sum = key
  447. return key
  448. } else {
  449. sum = -1
  450. }
  451. })
  452. if (sum != -1) {
  453. this.fromarray.splice(sum, 1)
  454. }
  455. this.fromarray.push(index)
  456. }
  457. }
  458. }
  459. }
  460. </script>
  461. <style lang="scss">
  462. .scning .scrll-height {
  463. width: 100%;
  464. box-sizing: border-box;
  465. height: calc(100vh - 78rpx);
  466. background: #ffffff;
  467. }
  468. // .scning view {
  469. // line-height: 1;
  470. // }
  471. .left-boto-txt {
  472. position: absolute;
  473. left: 30rpx;
  474. top: 107rpx;
  475. font-size: 28rpx;
  476. }
  477. .xianchang {
  478. width: auto;
  479. font-size: 14px;
  480. color: #333333;
  481. font-weight: bold;
  482. padding: 26rpx 32rpx;
  483. }
  484. .collect_tit {
  485. width: 690rpx;
  486. height: 104rpx;
  487. .tit {
  488. width: 128rpx;
  489. // height: 33rpx;
  490. line-height: 33rpx;
  491. margin-left: 30rpx;
  492. font-size: 32rpx;
  493. font-family: Microsoft YaHei-3970(82674968);
  494. font-weight: bold;
  495. color: #010101;
  496. }
  497. image {
  498. max-width: 24rpx;
  499. max-height: 24rpx;
  500. margin-left: 42rpx;
  501. }
  502. span {
  503. line-height: 33rpx;
  504. // height: 24rpx;
  505. margin-left: 10rpx;
  506. font-size: 24rpx;
  507. font-family: Microsoft YaHei-3970(82674968);
  508. font-weight: 400;
  509. color: #808080;
  510. }
  511. }
  512. .sup {
  513. color: red;
  514. }
  515. .sel_point {
  516. width: 690rpx;
  517. height: 70rpx;
  518. background: #ebf8ff;
  519. .triangle {
  520. margin-top: 10rpx;
  521. display: inline-block;
  522. /* Base Style */
  523. border: solid 10rpx transparent;
  524. border-top-color: #808080;
  525. }
  526. }
  527. .u-radio,
  528. .u-checkbox {
  529. margin-top: 29rpx;
  530. }
  531. .u-radio__label,
  532. .u-checkbox__label {
  533. color: #333333 !important;
  534. width: 100%;
  535. }
  536. input {
  537. width: 100%;
  538. height: 100%;
  539. // text-indent: 20rpx;
  540. }
  541. .inp {
  542. width: 690rpx;
  543. height: 80rpx;
  544. padding: 18rpx;
  545. border: 1rpx solid #bfbfbf;
  546. border-radius: 6rpx;
  547. }
  548. .tex {
  549. width: 690rpx;
  550. height: 210rpx;
  551. border: 1rpx solid #bfbfbf;
  552. border-radius: 6rpx;
  553. }
  554. textarea {
  555. width: 100%;
  556. height: 100%;
  557. margin-top: 10rpx;
  558. text-indent: 20rpx;
  559. }
  560. .upload-image {
  561. width: 139rpx;
  562. height: 139rpx;
  563. margin-right: 45rpx;
  564. // background-image: url(../../static/img/jia.png);
  565. // background-repeat: no-repeat;
  566. // background-size: 100%;
  567. // line-height: 32px !important;
  568. }
  569. .scan-item-hidden {
  570. display: none;
  571. }
  572. .scan-form-item-show {
  573. display: block;
  574. }
  575. </style>