add.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. <template>
  2. <view class="jpmain ">
  3. <u-navbar title="站点巡检" :bkUrl="!isBack?'/pages/index/index':''"
  4. title-color="#101010"></u-navbar>
  5. <u-picker mode="time" v-model="inspectionTimeShow" @confirm="inspectionTimeConfirm"
  6. :default-time="taskInfo.inspectionTime" :params="params"></u-picker>
  7. <view class="list">
  8. <view class="item">
  9. {{record.stationName}}
  10. <span @click="gotoSelectStation()"
  11. style="color: rgba(16,16,16,1);font-size: 28rpx; float: right; font-weight: 400;">
  12. 切换站点
  13. <u-icon name="arrow-right" size="24" color="#BBBBBB" ></u-icon>
  14. </span>
  15. </view>
  16. <view class="item ">
  17. <view class="name">
  18. 站点地址 {{record.stationAddress}}
  19. </view>
  20. <view class="name">
  21. 上次巡检 {{record.lastInspectionTime}}
  22. </view>
  23. </view>
  24. </view>
  25. <view class="list">
  26. <view class="item ">
  27. 巡检操作记录
  28. </view>
  29. <view class="item item-plus">
  30. <view class="name">
  31. <span style="color: red;">*</span> 处理人员
  32. </view>
  33. <view class="value ">
  34. <u-checkbox-group>
  35. <u-checkbox v-model="item.checked" v-for="(item, index) in memberList" :key="index" @change="memberListchange"
  36. :name="item.name">{{item.name}}</u-checkbox>
  37. </u-checkbox-group>
  38. </view>
  39. </view>
  40. <view class="item item-plus" style=" align-items: center;">
  41. <view class="name">
  42. <span style="color: red;">*</span>处理时间
  43. </view>
  44. <view class="value " @click="inspectionTimeShow=true">
  45. <view class="valueclock">
  46. <u-icon name="clock" size="32" color="#BBBBBB"></u-icon>
  47. {{taskInfo.inspectionTime}}
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="list" v-for="(item,index) in contentList" >
  53. <view class="item ">
  54. {{index+1}} {{item.name}}
  55. </view>
  56. <view class="item item-plus" v-if="item.btn&&item.btn.length">
  57. <view class="name">
  58. <span style="color: red;">*</span>检测结果
  59. </view>
  60. <view class="value ">
  61. <u-radio-group v-model="submitcontent[index].result">
  62. <u-radio
  63. v-for="(it, i) in item.btn" :key="index+'-'+i"
  64. :name="it.value"
  65. >
  66. {{it.name}}
  67. </u-radio>
  68. </u-radio-group>
  69. </view>
  70. </view>
  71. <view class="item item-plus" v-if="submitcontent[index].result==0">
  72. <view class="name">
  73. <span style="color: red;" v-if="item.field" >*</span>{{item.desc}}
  74. </view>
  75. <view class="value ">
  76. <u-input style="background-color: #f1f2f5;"
  77. v-model="submitcontent[index].content"
  78. :placeholder="item.descP"></u-input>
  79. </view>
  80. </view>
  81. <view class="item item-plus" v-if="item.imageRequired">
  82. <view class="name">
  83. <span style="color: red;">*</span>拍照上传(请上传设备状态照片)
  84. </view>
  85. <view class="value" >
  86. <u-upload name="photoFile" :class="'uUpload'+index"
  87. :ref="'uUpload'+index" :width="100" :height="100" uploadText=""
  88. :form-data="formData" :header="header"
  89. :action="action"
  90. :file-list="listPic[index]"></u-upload>
  91. </view>
  92. </view>
  93. </view>
  94. <view class="floating-button" >
  95. <view class="button" @click="submit">
  96. 提交
  97. </view>
  98. </view>
  99. </view>
  100. </template>
  101. <script>
  102. import * as API from '@/apis/pagejs/pagesInspection.js'
  103. import * as WxJsApi from '@/apis/utils/wxJsApi.js'
  104. import {
  105. currentTimeStamp,
  106. parseUnixTime
  107. } from '@/apis/utils'
  108. export default {
  109. data() {
  110. return {
  111. record:{},
  112. memberList: [
  113. ],
  114. listPic: [],
  115. action: "",
  116. formData: {
  117. },
  118. header: {
  119. },
  120. params: {
  121. year: true,
  122. month: true,
  123. day: true,
  124. hour: true,
  125. minute: true,
  126. second: true,
  127. timestamp: true,
  128. },
  129. codeN: "",
  130. selectTaskInfoCode: false,
  131. selectTaskInfoCodeValue: [0],
  132. lockNo: "",
  133. lockName: "",
  134. floorlockInfo: {},
  135. floorlockErrorRecord: {},
  136. parkingInfo: {},
  137. stationInfo:{},
  138. stationId:"",
  139. taskInfo: {
  140. id: "",
  141. desc: "",
  142. images: "",
  143. inspectionTime: "",
  144. },
  145. codeList: [],
  146. id: "",
  147. imgList: [],
  148. repairImageList: [],
  149. inspectionTimeShow: false,
  150. content: [
  151. ],
  152. contentList:[],
  153. submitcontent:[],
  154. isBack:false,
  155. };
  156. },
  157. onLoad(op) {
  158. this.action = process.jphelp.BASE_URL + "uploadPicture"
  159. this.formData.subFolder = "/floorlock/inspection/updateErr"
  160. var token = this.jphelp.getToken()
  161. this.header = {
  162. 'Authorization': token
  163. }
  164. if(op.id){
  165. this.id = op.id
  166. }
  167. if(op.stationId){
  168. this.stationId = op.stationId
  169. this.id=""
  170. }
  171. this.taskInfo.inspectionTime = parseUnixTime(currentTimeStamp())
  172. this.errDetails()
  173. if(op.back){
  174. this.isBack=op.back
  175. }
  176. this.getteamMembers()
  177. },
  178. onReady() {
  179. WxJsApi.getWxConfig(['openLocation']).then((res) => {
  180. // //(res)
  181. }).catch(error => {
  182. //(res)
  183. })
  184. },
  185. methods: {
  186. gotoSelectStation() {
  187. uni.navigateTo({
  188. url: '/pages/inspection/selectStation',
  189. events: {
  190. // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
  191. acceptDataFromOpenerPage: (item) => {
  192. console.log(item)
  193. this.stationId = item.item.id
  194. this.id=""
  195. this.errDetails(1)
  196. this.$forceUpdate()
  197. },
  198. }
  199. })
  200. },
  201. memberListchange(e){
  202. console.log(e)
  203. this.$forceUpdate()
  204. },
  205. getteamMembers() {
  206. uni.showLoading({
  207. title: "加载中",
  208. mask: true,
  209. })
  210. API.teamMembers({
  211. userType:1
  212. }).then((res) => {
  213. var arr = res.data.memberList
  214. this.memberList = arr
  215. this.memberList.forEach(item => {
  216. if (item.id == this.jphelp.getPersonInfo().id) {
  217. item.checked = true
  218. } else {
  219. item.checked = false
  220. }
  221. })
  222. uni.hideLoading();
  223. }).catch(error => {
  224. uni.hideLoading();
  225. uni.showToast({
  226. title: error,
  227. icon: "none"
  228. })
  229. })
  230. },
  231. inspectionTimeConfirm(e) {
  232. this.taskInfo.inspectionTime = parseUnixTime(new Date(e.timestamp * 1000))
  233. },
  234. previewImage(i, name) {
  235. let imgs = this[name];
  236. //imgs.push(img);
  237. uni.previewImage({
  238. urls: imgs,
  239. current: i
  240. })
  241. },
  242. navigate() {
  243. var item = this.parkingInfo
  244. if (!(this.parkingInfo.latitude && this.parkingInfo.longitude)) {
  245. return
  246. }
  247. uni.showLoading({
  248. })
  249. setTimeout(() => {
  250. uni.hideLoading()
  251. }, 3 * 1000)
  252. WxJsApi.openLocation({
  253. latitude: parseFloat(item.latitude), //目的地latitude
  254. longitude: parseFloat(item.longitude), //目的地longitude
  255. name: item.name,
  256. address: item.address,
  257. scale: 15, //地图缩放大小,可根据情况具体调整
  258. success(res) {
  259. uni.hideLoading()
  260. },
  261. complete() {
  262. // uni.hideLoading()
  263. }
  264. });
  265. // //('station'+JSON.stringify(_self.stationDetail.station))
  266. // window.location.href = "https://uri.amap.com/marker?position=" + _self.stationDetail.station.longitude +
  267. // "," + _self.stationDetail.station.latitude + "&name=" + _self.stationDetail.station.name;
  268. },
  269. errDetails( bl) {
  270. uni.showLoading({
  271. title: "加载中",
  272. mask: true,
  273. })
  274. API.recordDetails({
  275. id: this.id,
  276. stationId:this.stationId
  277. }).then((res) => {
  278. this.record=res.data.record
  279. if(!bl){
  280. this.content=res.data.content
  281. uni.hideLoading();
  282. this.contentMethod()
  283. }
  284. }).catch(error => {
  285. uni.hideLoading();
  286. uni.showToast({
  287. title: error,
  288. icon: "none"
  289. })
  290. })
  291. },
  292. contentMethod(){
  293. this.listPic=[]
  294. this.contentList=this.content.map(item=>{
  295. this.listPic.push([])
  296. var obj={
  297. dataId:item.dataId,
  298. name:item.name,
  299. btn:[{
  300. name:"正常",
  301. value:"1"
  302. },{
  303. name:"异常",
  304. value:"0"
  305. }],
  306. desc:"问题描述",
  307. descP:"请简单描述发现的问题",
  308. }
  309. if(item.extended1){
  310. var extended1=JSON.parse(item.extended1)
  311. Object.keys(extended1).forEach(key1 => {
  312. obj[key1]=extended1[key1]
  313. })
  314. }
  315. return obj
  316. })
  317. this.submitcontent=this.contentList.map(item=>{
  318. return {
  319. dataId:item.dataId,
  320. name:item.name,
  321. result:"1",
  322. image:"",
  323. content:""
  324. }
  325. })
  326. },
  327. submitApi() {
  328. uni.showLoading({
  329. title: "加载中",
  330. mask: true,
  331. })
  332. this.taskInfo.content=this.submitcontent
  333. API.recordReport(this.taskInfo).then((res) => {
  334. const eventChannel = this.getOpenerEventChannel();
  335. eventChannel.emit('acceptDataFromOpenerPage', {})
  336. uni.showModal({
  337. title: '提示',
  338. showCancel: false,
  339. content: "操作成功",
  340. success: res1 => {
  341. if (res1.confirm) {
  342. uni.navigateBack()
  343. } else if (res1.cancel) {
  344. //('用户点击取消');
  345. }
  346. }
  347. })
  348. uni.hideLoading();
  349. }).catch(error => {
  350. uni.hideLoading();
  351. uni.showToast({
  352. title: error,
  353. icon: "none"
  354. })
  355. })
  356. },
  357. submit() {
  358. var mp=this.memberList.filter(item=>{
  359. return item.checked
  360. }).map(item=>{
  361. return item.id
  362. })
  363. if (mp.length==0) {
  364. uni.showToast({
  365. title: "请选择上报人员"
  366. })
  367. return
  368. }
  369. this.taskInfo.userIds=mp.join()
  370. //this.taskInfo.id=this.id
  371. this.taskInfo.status=1
  372. this.taskInfo.stationId=this.stationId
  373. var i =0
  374. var bl=false
  375. this.contentList.forEach(item=>{
  376. if(bl==true){
  377. return
  378. }
  379. if(item.imageRequired){
  380. let files = [];
  381. console.log(this.$refs)
  382. console.log(item.imageRequired,i,this.$refs['uUpload'+i])
  383. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  384. files = this.$refs['uUpload'+i][0].lists.filter(val => {
  385. return val.progress == 100;
  386. })
  387. var imgUrl = files.map(item => {
  388. return item.response.data;
  389. })
  390. if(imgUrl.length==0){
  391. uni.showToast({
  392. title: "请上传设备状态照片(第"+(i+1)+"项)"
  393. })
  394. bl=true;
  395. }
  396. this.submitcontent[i].image=imgUrl.join(',');
  397. }
  398. if(item.field){
  399. if(this.submitcontent[i].result==0&&!this.submitcontent[i].content){
  400. uni.showToast({
  401. title: "请填写"+item.name
  402. })
  403. bl=true;
  404. }
  405. this.taskInfo[item.field]=this.submitcontent[i].content
  406. }
  407. i++;
  408. })
  409. if(bl==true){
  410. return
  411. }
  412. console.log(this.taskInfo)
  413. console.log(this.submitcontent)
  414. //this.submitApi()
  415. uni.showModal({
  416. title: '提示',
  417. //showCancel: false,
  418. content: "确认提交内容无误,是否提交?",
  419. success: res1 => {
  420. if (res1.confirm) {
  421. this.submitApi()
  422. } else if (res1.cancel) {
  423. //('用户点击取消');
  424. }
  425. }
  426. })
  427. },
  428. }
  429. }
  430. </script>
  431. <style lang="scss">
  432. .jpmain {
  433. padding-bottom: 120rpx;
  434. }
  435. .list {
  436. background-color: rgba(255, 255, 255, 1);
  437. border-radius: 16rpx;
  438. margin: 20rpx;
  439. .item:first-child {
  440. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  441. font-size: 32rpx;
  442. font-weight: bold;
  443. padding: 28rpx 24rpx;
  444. }
  445. .item {
  446. padding: 20rpx 24rpx;
  447. .name {
  448. // width: 40%;
  449. padding-bottom: 32rpx;
  450. font-size: 32rpx;
  451. color: #777777;
  452. span {
  453. color: red
  454. }
  455. }
  456. .valueplus {
  457. display: flex;
  458. justify-content: space-between;
  459. }
  460. .valueclock {
  461. width: 100%;
  462. border-radius: 8rpx;
  463. padding: 0 16rpx;
  464. height: 64rpx;
  465. line-height: 64rpx;
  466. background-color: rgba(241, 242, 245, 1);
  467. }
  468. .value {
  469. font-size: 32rpx;
  470. display: flex;
  471. align-items: center;
  472. input::placeholder {
  473. color: #AAAAAA;
  474. }
  475. .img {
  476. width: 40rpx;
  477. height: 40rpx;
  478. }
  479. .textarea {
  480. background-color: rgba(241, 242, 245, 1);
  481. width: 100%;
  482. border-radius: 8rpx;
  483. }
  484. .typeN {
  485. font-size: 24rpx;
  486. margin-right: 8rpx;
  487. display: flex;
  488. align-items: center;
  489. border-radius: 8rpx;
  490. padding: 4rpx 8rpx;
  491. color: #fff;
  492. }
  493. .typeN1 {
  494. background-color: #1677ff;
  495. //border: 2rpx solid #1677ff;
  496. }
  497. .typeN2 {
  498. background-color: #19be6b;
  499. //border: 2rpx solid #19be6b;
  500. }
  501. }
  502. }
  503. }
  504. .textareaclass {
  505. padding: 16rpx
  506. }
  507. .floating-button {
  508. z-index: 999;
  509. position: fixed;
  510. bottom: 0;
  511. width: 100%;
  512. display: flex;
  513. height: 120rpx;
  514. justify-content: center;
  515. background-color: rgba(255, 255, 255, 1);
  516. .button {
  517. margin-top: 24rpx;
  518. border-radius: 50px;
  519. height: 80rpx;
  520. width: 80%;
  521. display: flex;
  522. align-items: center;
  523. justify-content: center;
  524. padding: 12rpx;
  525. background-color: rgba(22, 119, 255, 1);
  526. color: rgba(255, 255, 255, 1);
  527. font-size: 36rpx;
  528. }
  529. }
  530. .viewImg {
  531. width: 160rpx;
  532. height: 160rpx;
  533. }
  534. </style>