add.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  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().then((res) => {
  211. var arr = res.data.memberList
  212. this.memberList = arr
  213. this.memberList.forEach(item => {
  214. if (item.id == this.jphelp.getPersonInfo().id) {
  215. item.checked = true
  216. } else {
  217. item.checked = false
  218. }
  219. })
  220. uni.hideLoading();
  221. }).catch(error => {
  222. uni.hideLoading();
  223. uni.showToast({
  224. title: error,
  225. icon: "none"
  226. })
  227. })
  228. },
  229. inspectionTimeConfirm(e) {
  230. this.taskInfo.inspectionTime = parseUnixTime(new Date(e.timestamp * 1000))
  231. },
  232. previewImage(i, name) {
  233. let imgs = this[name];
  234. //imgs.push(img);
  235. uni.previewImage({
  236. urls: imgs,
  237. current: i
  238. })
  239. },
  240. navigate() {
  241. var item = this.parkingInfo
  242. if (!(this.parkingInfo.latitude && this.parkingInfo.longitude)) {
  243. return
  244. }
  245. uni.showLoading({
  246. })
  247. setTimeout(() => {
  248. uni.hideLoading()
  249. }, 3 * 1000)
  250. WxJsApi.openLocation({
  251. latitude: parseFloat(item.latitude), //目的地latitude
  252. longitude: parseFloat(item.longitude), //目的地longitude
  253. name: item.name,
  254. address: item.address,
  255. scale: 15, //地图缩放大小,可根据情况具体调整
  256. success(res) {
  257. uni.hideLoading()
  258. },
  259. complete() {
  260. // uni.hideLoading()
  261. }
  262. });
  263. // //('station'+JSON.stringify(_self.stationDetail.station))
  264. // window.location.href = "https://uri.amap.com/marker?position=" + _self.stationDetail.station.longitude +
  265. // "," + _self.stationDetail.station.latitude + "&name=" + _self.stationDetail.station.name;
  266. },
  267. errDetails( bl) {
  268. uni.showLoading({
  269. title: "加载中",
  270. mask: true,
  271. })
  272. API.recordDetails({
  273. id: this.id,
  274. stationId:this.stationId
  275. }).then((res) => {
  276. this.record=res.data.record
  277. if(!bl){
  278. this.content=res.data.content
  279. uni.hideLoading();
  280. this.contentMethod()
  281. }
  282. }).catch(error => {
  283. uni.hideLoading();
  284. uni.showToast({
  285. title: error,
  286. icon: "none"
  287. })
  288. })
  289. },
  290. contentMethod(){
  291. this.listPic=[]
  292. this.contentList=this.content.map(item=>{
  293. this.listPic.push([])
  294. var obj={
  295. dataId:item.dataId,
  296. name:item.name,
  297. btn:[{
  298. name:"正常",
  299. value:"1"
  300. },{
  301. name:"异常",
  302. value:"0"
  303. }],
  304. desc:"问题描述",
  305. descP:"请简单描述发现的问题",
  306. }
  307. if(item.extended1){
  308. var extended1=JSON.parse(item.extended1)
  309. Object.keys(extended1).forEach(key1 => {
  310. obj[key1]=extended1[key1]
  311. })
  312. }
  313. return obj
  314. })
  315. this.submitcontent=this.contentList.map(item=>{
  316. return {
  317. dataId:item.dataId,
  318. name:item.name,
  319. result:"1",
  320. image:"",
  321. content:""
  322. }
  323. })
  324. },
  325. submitApi() {
  326. uni.showLoading({
  327. title: "加载中",
  328. mask: true,
  329. })
  330. this.taskInfo.content=this.submitcontent
  331. API.recordReport(this.taskInfo).then((res) => {
  332. const eventChannel = this.getOpenerEventChannel();
  333. eventChannel.emit('acceptDataFromOpenerPage', {})
  334. uni.showModal({
  335. title: '提示',
  336. showCancel: false,
  337. content: "操作成功",
  338. success: res1 => {
  339. if (res1.confirm) {
  340. uni.navigateBack()
  341. } else if (res1.cancel) {
  342. //('用户点击取消');
  343. }
  344. }
  345. })
  346. uni.hideLoading();
  347. }).catch(error => {
  348. uni.hideLoading();
  349. uni.showToast({
  350. title: error,
  351. icon: "none"
  352. })
  353. })
  354. },
  355. submit() {
  356. var mp=this.memberList.filter(item=>{
  357. return item.checked
  358. }).map(item=>{
  359. return item.id
  360. })
  361. if (mp.length==0) {
  362. uni.showToast({
  363. title: "请选择上报人员"
  364. })
  365. return
  366. }
  367. this.taskInfo.userIds=mp.join()
  368. //this.taskInfo.id=this.id
  369. this.taskInfo.status=1
  370. this.taskInfo.stationId=this.stationId
  371. var i =0
  372. var bl=false
  373. this.contentList.forEach(item=>{
  374. if(bl==true){
  375. return
  376. }
  377. if(item.imageRequired){
  378. let files = [];
  379. console.log(this.$refs)
  380. console.log(item.imageRequired,i,this.$refs['uUpload'+i])
  381. // 通过filter,筛选出上传进度为100的文件(因为某些上传失败的文件,进度值不为100,这个是可选的操作)
  382. files = this.$refs['uUpload'+i][0].lists.filter(val => {
  383. return val.progress == 100;
  384. })
  385. var imgUrl = files.map(item => {
  386. return item.response.data;
  387. })
  388. if(imgUrl.length==0){
  389. uni.showToast({
  390. title: "请上传设备状态照片(第"+(i+1)+"项)"
  391. })
  392. bl=true;
  393. }
  394. this.submitcontent[i].image=imgUrl.join(',');
  395. }
  396. if(item.field){
  397. if(this.submitcontent[i].result==0&&!this.submitcontent[i].content){
  398. uni.showToast({
  399. title: "请填写"+item.name
  400. })
  401. bl=true;
  402. }
  403. this.taskInfo[item.field]=this.submitcontent[i].content
  404. }
  405. i++;
  406. })
  407. if(bl==true){
  408. return
  409. }
  410. console.log(this.taskInfo)
  411. console.log(this.submitcontent)
  412. //this.submitApi()
  413. uni.showModal({
  414. title: '提示',
  415. //showCancel: false,
  416. content: "确认提交内容无误,是否提交?",
  417. success: res1 => {
  418. if (res1.confirm) {
  419. this.submitApi()
  420. } else if (res1.cancel) {
  421. //('用户点击取消');
  422. }
  423. }
  424. })
  425. },
  426. }
  427. }
  428. </script>
  429. <style lang="scss">
  430. .jpmain {
  431. padding-bottom: 120rpx;
  432. }
  433. .list {
  434. background-color: rgba(255, 255, 255, 1);
  435. border-radius: 16rpx;
  436. margin: 20rpx;
  437. .item:first-child {
  438. border-bottom: 2rpx solid rgba(232, 232, 232, 1);
  439. font-size: 32rpx;
  440. font-weight: bold;
  441. padding: 28rpx 24rpx;
  442. }
  443. .item {
  444. padding: 20rpx 24rpx;
  445. .name {
  446. // width: 40%;
  447. padding-bottom: 32rpx;
  448. font-size: 32rpx;
  449. color: #777777;
  450. span {
  451. color: red
  452. }
  453. }
  454. .valueplus {
  455. display: flex;
  456. justify-content: space-between;
  457. }
  458. .valueclock {
  459. width: 100%;
  460. border-radius: 8rpx;
  461. padding: 0 16rpx;
  462. height: 64rpx;
  463. line-height: 64rpx;
  464. background-color: rgba(241, 242, 245, 1);
  465. }
  466. .value {
  467. font-size: 32rpx;
  468. display: flex;
  469. align-items: center;
  470. input::placeholder {
  471. color: #AAAAAA;
  472. }
  473. .img {
  474. width: 40rpx;
  475. height: 40rpx;
  476. }
  477. .textarea {
  478. background-color: rgba(241, 242, 245, 1);
  479. width: 100%;
  480. border-radius: 8rpx;
  481. }
  482. .typeN {
  483. font-size: 24rpx;
  484. margin-right: 8rpx;
  485. display: flex;
  486. align-items: center;
  487. border-radius: 8rpx;
  488. padding: 4rpx 8rpx;
  489. color: #fff;
  490. }
  491. .typeN1 {
  492. background-color: #1677ff;
  493. //border: 2rpx solid #1677ff;
  494. }
  495. .typeN2 {
  496. background-color: #19be6b;
  497. //border: 2rpx solid #19be6b;
  498. }
  499. }
  500. }
  501. }
  502. .textareaclass {
  503. padding: 16rpx
  504. }
  505. .floating-button {
  506. z-index: 999;
  507. position: fixed;
  508. bottom: 0;
  509. width: 100%;
  510. display: flex;
  511. height: 120rpx;
  512. justify-content: center;
  513. background-color: rgba(255, 255, 255, 1);
  514. .button {
  515. margin-top: 24rpx;
  516. border-radius: 50px;
  517. height: 80rpx;
  518. width: 80%;
  519. display: flex;
  520. align-items: center;
  521. justify-content: center;
  522. padding: 12rpx;
  523. background-color: rgba(22, 119, 255, 1);
  524. color: rgba(255, 255, 255, 1);
  525. font-size: 36rpx;
  526. }
  527. }
  528. .viewImg {
  529. width: 160rpx;
  530. height: 160rpx;
  531. }
  532. </style>