patroldetail.vue 15 KB

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