scanning.vue 17 KB

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