patroldetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <view class="u-flex f-d-c m-w ccc">
  3. <view class="m-w u-m-t-30 u-p-l-20 u-p-r-20" style="background: #ffffff">
  4. <!-- <view @click="lintext(content.pointNo)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  5. <view class="item-name">记录单号</view>
  6. <view class="u-line-1 item-config u-text-right" style="width: 342rpx;">{{content.pointNo}}</view>
  7. </view> -->
  8. <view @click="lintext(content.roomName)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  9. <view class="item-name">房间名称</view>
  10. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ content.roomName }}</view>
  11. </view>
  12. <view @click="lintext(content.roomNumber)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  13. <view class="item-name">房间编号</view>
  14. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ content.roomNumber }}</view>
  15. </view>
  16. <view @click="lintext(content.buildingName + content.floorName)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  17. <view class="item-name">房间位置</view>
  18. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ content.buildingName }}{{ content.floorName }}</view>
  19. </view>
  20. <view @click="lintext(content.name)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  21. <view class="item-name">巡检计划</view>
  22. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ content.name }}</view>
  23. </view>
  24. <view @click="lintext(content.time)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  25. <view class="item-name">巡检时间</view>
  26. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ content.time }}</view>
  27. </view>
  28. <view @click="lintext(content.username)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  29. <view class="item-name">巡检人员</view>
  30. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ content.username }}</view>
  31. </view>
  32. <view @click="lintext(content.qualified)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  33. <view class="item-name">是否合格</view>
  34. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ content.qualified == true ? '合格' : '不合格' }}</view>
  35. </view>
  36. <view @click="lintext(content.score)" class="u-flex u-row-between border-bottom u-p-b-28 u-p-t-28">
  37. <view class="item-name">评分</view>
  38. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ content.score }}</view>
  39. </view>
  40. <!-- 巡检项目头 -->
  41. <view class="collect_tit u-flex u-row-left u-col-center">
  42. <view class="tit">巡检项目</view>
  43. <image :src="icon1"></image>
  44. <span>设备:{{ content.devices.length + 1 }}件</span>
  45. <image :src="icon2"></image>
  46. <span>项目:{{ checkItemCount }}个</span>
  47. </view>
  48. <block>
  49. <!--自带项目-设备名 -->
  50. <label class="sel_point u-flex u-row-between u-m-b-34" @click="sel_show1">
  51. <view class="sel_tit u-flex u-row-left u-m-l-26">
  52. <span>{{ content.roomName }}自带项目</span>
  53. <!-- <sup class="sup">*</sup> -->
  54. </view>
  55. <view class="triangle u-m-r-26" :style="tri_style1"></view>
  56. </label>
  57. <!-- 检查项 -->
  58. <block class="scan_itm1" v-if="itm1_show">
  59. <view v-for="(iam, i) in content.checkItems" :key="i">
  60. <!-- <view @click="lintext(iam.value)" class="u-flex u-row-between border-bottom u-p-b-34 u-p-t-34">
  61. <view class="item-name">{{iam.checkItemName}}</view>
  62. <view class="u-line-1 item-config u-text-right" style="width: 342rpx;">{{iam.value}}</view>
  63. </view> -->
  64. <!-- 数字项与选择项 -->
  65. <view v-if="iam.checkItemType == 2 || iam.checkItemType == 1" @click="lintext(iam.value)" class="u-flex u-row-between border-bottom u-m-b-34 u-p-b-34">
  66. <view class="item-name">{{ iam.checkItemName }}</view>
  67. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ iam.value == '' ? '暂无数据' : iam.value }}</view>
  68. </view>
  69. <!-- 文本项 -->
  70. <view v-else-if="iam.checkItemType == 3" @click="lintext(iam.value)" class="border-bottom u-m-b-34">
  71. <view class="item-name">{{ iam.checkItemName }}:</view>
  72. <view v-if="iam.value != ''" class="text_box u-m-t-18">{{ iam.value }}</view>
  73. <block v-else>
  74. <u-empty text="数据为空"></u-empty>
  75. </block>
  76. </view>
  77. <!-- 图片项 -->
  78. <view v-else class="img_box u-m-b-34 u-p-b-2">
  79. <view class="item-name">{{ iam.checkItemName }}</view>
  80. <!-- <view v-if="iam.value != ''" class="img_itms u-m-t-18">
  81. <view class="img_itm" v-for="(index,key) in iam.value" :key="key">
  82. <u-image @click="previewImage(key,iam.value)" width="139rpx" height="139rpx" :src="index"></u-image>
  83. </view>
  84. </view> -->
  85. <view v-if="iam.value != ''" class="u-m-t-18" v-for="(index, key) in iam.value" :key="key">
  86. <view class="titl u-flex u-row-left u-m-t-12 u-m-l-8">
  87. <span>{{ key + 1 }}.{{ index.name }}</span>
  88. </view>
  89. <view class="img_itms">
  90. <view class="img_itm" v-for="(img, imgIndex) in index.value" :key="key">
  91. <u-image @click="previewImage(imgIndex, index.value)" width="139rpx" height="139rpx" :src="img"></u-image>
  92. </view>
  93. </view>
  94. </view>
  95. <block v-else>
  96. <u-empty text="数据为空"></u-empty>
  97. </block>
  98. </view>
  99. </view>
  100. </block>
  101. </block>
  102. <block v-for="(item, i) in content.devices" :key="item.id">
  103. <!--巡检设备-设备名 -->
  104. <label class="sel_point u-flex u-row-between u-m-b-40" @click="sel_show(i)">
  105. <view class="sel_tit u-flex u-row-left u-m-l-26">
  106. <span>{{ item.deviceName }}</span>
  107. <!-- <sup class="sup">*</sup> -->
  108. </view>
  109. <view class="triangle u-m-r-26" :style="sel_style[i].tri_style"></view>
  110. </label>
  111. <!-- 检查项 -->
  112. <block class="scan_itm1" v-if="sel_style[i].it_show">
  113. <view v-for="ite in item.checkItems" :key="ite.id">
  114. <!-- 选择项或数字项 -->
  115. <view v-if="ite.checkItemType == 1 || ite.checkItemType == 2" @click="lintext(ite.value)" class="u-flex u-row-between border-bottom u-p-b-34 u-m-b-34">
  116. <view class="item-name">{{ ite.checkItemName }}</view>
  117. <view class="u-line-1 item-config u-text-right" style="width: 342rpx">{{ ite.value == '' ? '数据为空' : ite.value }}</view>
  118. </view>
  119. <!-- 文本项 -->
  120. <view v-else-if="ite.checkItemType == 3" @click="lintext(ite.value)" class="u-m-b-34 border-bottom">
  121. <view class="item-name">{{ ite.checkItemName }}:</view>
  122. <view v-if="iam.value != ''" class="text_box u-m-t-18">{{ ite.value }}</view>
  123. <block v-else>
  124. <u-empty text="数据为空"></u-empty>
  125. </block>
  126. </view>
  127. <!-- 图片项 -->
  128. <view v-else class="img_box u-m-b-34">
  129. <view class="item-name">{{ ite.checkItemName }}</view>
  130. <view v-if="ite.value != ''" class="u-m-t-18" v-for="(index, key) in ite.value" :key="key">
  131. <view class="titl u-flex u-row-left u-m-t-12 u-m-l-8">
  132. <span>{{ key + 1 }}.{{ index.name }}</span>
  133. </view>
  134. <view class="img_itms">
  135. <view class="img_itm" v-for="(img, imgIndex) in index.value" :key="key">
  136. <u-image @click="previewImage(imgIndex, index.value)" width="139rpx" height="139rpx" :src="img"></u-image>
  137. </view>
  138. </view>
  139. </view>
  140. <block v-else>
  141. <u-empty text="数据为空"></u-empty>
  142. </block>
  143. </view>
  144. </view>
  145. </block>
  146. </block>
  147. </view>
  148. <u-top-tips ref="chektost"></u-top-tips>
  149. </view>
  150. </template>
  151. <script>
  152. import icon1 from '@/static/img/devi.png'
  153. import icon2 from '@/static/img/proj.png'
  154. import dayjs from 'dayjs'
  155. import { partinfo } from '@/api/index.js'
  156. export default {
  157. data() {
  158. return {
  159. icon1: icon1,
  160. icon2: icon2,
  161. checkItemCount: 0, //项目数量
  162. tri_style1: '', //自带项目三角形样式变化
  163. itm1_show: true, //自带项目三角形样式变化
  164. // tri_style: '',
  165. // it_show: true,
  166. sel_style: [],
  167. content: null, //列表数据
  168. finishStatus: ['', '按时完成', '尚未巡检(正常时效内未检)', '超时漏检(超过时效后未检)', '提前完成', '延时完成']
  169. }
  170. },
  171. onLoad(option) {
  172. this.init(option.taskId, option.roomId)
  173. },
  174. methods: {
  175. //自带项目三角样式变化
  176. sel_show1() {
  177. this.itm1_show = !this.itm1_show
  178. if (!this.itm1_show) {
  179. this.tri_style1 = 'margin-top: 0rpx;margin-bottom:10rpx;border-top-color:transparent;border-bottom-color: #808080;'
  180. } else {
  181. this.tri_style1 = 'margin-top: 10rpx;margin-bottom:0rpx;border-top-color:#808080;border-bottom-color: transparent;'
  182. }
  183. },
  184. //设备三角形样式变化
  185. sel_show(index) {
  186. // obj.tri_style
  187. // obj.it_show
  188. this.sel_style[index].it_show = !this.sel_style[index].it_show
  189. if (!this.sel_style[index].it_show) {
  190. this.sel_style[index].tri_style = 'margin-top: 0rpx;margin-bottom:10rpx;border-top-color:transparent;border-bottom-color: #808080;'
  191. } else {
  192. this.sel_style[index].tri_style = 'margin-top: 10rpx;margin-bottom:0rpx;border-top-color:#808080;border-bottom-color: transparent;'
  193. }
  194. },
  195. //预览图片
  196. previewImage(index, i) {
  197. uni.previewImage({
  198. current: index, //预览图片的下标
  199. urls: i //预览图片的地址,必须要数组形式,如果不是数组形式就转换成数组形式就可以
  200. })
  201. },
  202. // 获取页面数据
  203. async init(taskId, roomId) {
  204. let { data, code, message } = await partinfo({
  205. taskId,
  206. roomId
  207. })
  208. if (code != 200) {
  209. uni.showToast({
  210. title: message,
  211. type: 'warning'
  212. })
  213. }
  214. data.time = dayjs(data.time).format('YYYY-MM-DD HH:mm:ss')
  215. //一、自带巡检项目-数据处理
  216. data.checkItems.forEach((i) => {
  217. let checkItem = JSON.parse(i.checkItem)
  218. //图片数据处理
  219. if (i.checkItemType == 4) {
  220. let imgValue = JSON.parse(i.value)
  221. i.value = []
  222. let b = undefined //查找项
  223. imgValue.forEach((j) => {
  224. let a = j.value.match(/[^\,]+/g) // 图片数组
  225. b = checkItem.photoPoints.find((ite, index) => {
  226. return ite.id == j.id
  227. })
  228. if (a && b) {
  229. let imgItem = {}
  230. imgItem.name = b.name
  231. imgItem.value = a
  232. i.value.push(imgItem)
  233. } else {
  234. return i.value
  235. }
  236. })
  237. }
  238. //选择项数据处理
  239. if (i.checkItemType == 1) {
  240. if (i.value !== '') {
  241. let selArr = i.value.match(/[^\,]+/g)
  242. let resStr = ''
  243. let rightItem = undefined
  244. selArr.forEach((sel) => {
  245. rightItem = checkItem.options.find((ite) => {
  246. return ite.id == sel
  247. })
  248. resStr == '' ? (resStr = rightItem.optionName) : (resStr = resStr + ',' + rightItem.optionName)
  249. })
  250. i.value = resStr
  251. } else {
  252. i.value = ''
  253. }
  254. }
  255. })
  256. //二、巡检设备-数据处理
  257. data.devices.forEach((item) => {
  258. //计算巡检项目数
  259. this.checkItemCount += item.checkItems.length
  260. //收缩框虚拟DOM
  261. let obj = {}
  262. obj.tri_style = 'margin-top: 10rpx;margin-bottom:0rpx;border-top-color:#808080;border-bottom-color: transparent;'
  263. obj.it_show = true
  264. this.sel_style.push(obj)
  265. //数据
  266. item.checkItems.forEach((i) => {
  267. let checkItem = JSON.parse(i.checkItem)
  268. //处理图片数据
  269. if (i.checkItemType == 4) {
  270. let imgValue = JSON.parse(i.value)
  271. i.value = []
  272. let rightItem = undefined //查找项
  273. imgValue.forEach((j) => {
  274. let imgArr = j.value.match(/[^\,]+/g) // 图片数组
  275. rightItem = checkItem.options.find((ite, index) => {
  276. return ite.id == j.id
  277. })
  278. if (imgArr && rightItem) {
  279. let imgItem = {}
  280. imgItem.name = rightItem.name
  281. imgItem.value = imgArr
  282. i.value.push(imgItem)
  283. } else {
  284. return i.value
  285. }
  286. })
  287. }
  288. //选择项数据处理
  289. if (i.checkItemType == 1) {
  290. if (i.value != '') {
  291. let selArr = i.value.match(/[^\,]+/g)
  292. let resStr = ''
  293. let a = undefined //查找项
  294. selArr.forEach((sel) => {
  295. a = checkItem.options.find((ite, index) => {
  296. return ite.id == sel
  297. })
  298. resStr == '' ? (resStr = a.optionName) : (resStr = resStr + ',' + a.optionName)
  299. })
  300. i.value = resStr
  301. } else {
  302. i.value = ''
  303. }
  304. }
  305. })
  306. })
  307. //三、巡检项目数
  308. this.checkItemCount += data.checkItems.length
  309. this.content = data
  310. console.log(this.content)
  311. },
  312. // 点击顶部提示文字
  313. lintext(text) {
  314. this.$refs.chektost.show({
  315. title: text,
  316. type: 'primary',
  317. duration: '2300'
  318. })
  319. }
  320. }
  321. }
  322. </script>
  323. <style lang="scss">
  324. page {
  325. width: 100%;
  326. height: 100%;
  327. background: #ffffff;
  328. }
  329. .border-bottom {
  330. border-bottom: 2rpx solid #e6e6e6;
  331. }
  332. .item-name {
  333. font-size: 28rpx;
  334. font-family: Microsoft YaHei-3970(82674968);
  335. font-weight: 400;
  336. color: #333333;
  337. box-sizing: border-box;
  338. }
  339. .item-config {
  340. font-size: 28rpx;
  341. font-family: Microsoft YaHei-3970(82674968);
  342. font-weight: 400;
  343. color: #808080;
  344. box-sizing: border-box;
  345. }
  346. .reacakye {
  347. font-size: 28rpx;
  348. font-family: Microsoft YaHei-3970(82674968);
  349. font-weight: 400;
  350. color: #333333;
  351. }
  352. .collect_tit {
  353. width: 710rpx;
  354. height: 104rpx;
  355. .tit {
  356. width: 128rpx;
  357. height: 33rpx;
  358. margin-left: 30rpx;
  359. font-size: 32rpx;
  360. font-weight: bold;
  361. color: #010101;
  362. }
  363. image {
  364. max-width: 24rpx;
  365. max-height: 24rpx;
  366. margin-left: 42rpx;
  367. margin-top: 12rpx;
  368. }
  369. span {
  370. height: 24rpx;
  371. margin-left: 10rpx;
  372. font-size: 24rpx;
  373. font-family: Microsoft YaHei-3970(82674968);
  374. font-weight: 400;
  375. color: #808080;
  376. }
  377. }
  378. .sel_point {
  379. width: 710rpx;
  380. height: 70rpx;
  381. background: #ebf8ff;
  382. .sup {
  383. color: red;
  384. }
  385. .triangle {
  386. margin-top: 10rpx;
  387. display: inline-block;
  388. /* Base Style */
  389. border: solid 10rpx transparent;
  390. border-top-color: #808080;
  391. }
  392. }
  393. .img_box {
  394. // width: 690rpx;
  395. }
  396. .img_itms {
  397. display: flex;
  398. flex-direction: row;
  399. flex-wrap: wrap;
  400. justify-content: flex-start;
  401. align-items: center;
  402. align-content: space-between;
  403. }
  404. .img_itm {
  405. display: inline-block;
  406. width: 139rpx;
  407. height: 139rpx;
  408. margin-right: 20rpx;
  409. }
  410. .text_box {
  411. height: 150rpx;
  412. max-height: 210rpx;
  413. color: #808080;
  414. text-indent: 40rpx;
  415. }
  416. </style>