add.vue 13 KB

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