add.vue 12 KB

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