submitted_ministry.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. <template>
  2. <view>
  3. <uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="维修工单报工" @clickLeft="goBack">
  4. <!-- <view class="nav-right" slot="right">
  5. <view class="text-box" @click="goRegister" style="width: 150rpx">备件使用登记</view>
  6. </view> -->
  7. </uni-nav-bar>
  8. <view class="content">
  9. <view class="fixed-top-bar">
  10. <view class="item">
  11. {{ worksheetInfo.deviceName }}
  12. </view>
  13. <view class="item">
  14. {{ worksheetInfo.workOrderCode }}
  15. </view>
  16. </view>
  17. <view class="bxjlbh-wrap">
  18. <view class="item">
  19. <view class="label">工单编号</view>
  20. <view class="value-wrap text">
  21. {{ worksheetInfo.code }}
  22. </view>
  23. </view>
  24. </view>
  25. <view class="clsm">
  26. <view class="title">处理说明</view>
  27. <textarea class="textarea" v-model="form.repairReportExplain"></textarea>
  28. </view>
  29. <view class="sc-wrap">
  30. <view class="title">附件</view>
  31. <fileMain v-model="form.attachments"></fileMain>
  32. <!-- <uni-file-picker :limit="4" v-model="FileImgList" fileMediatype="image" mode="grid" @select="handlImageSelect" @delete="handlImagDeletee" /> -->
  33. </view>
  34. <view class="sc-wrap" style="margin-top: 38rpx;">
  35. <view class="photo_btn" @click="chooseImage">拍照</view>
  36. <view class="photo_list">
  37. <PreviewPhoto type="edit" @imagedelete="imagedelete" :imageList="form.photoList" />
  38. </view>
  39. </view>
  40. <view class="bpbj" v-if="form.stockOutApplyPartList.length > 0">
  41. <view class="title">备件使用登记</view>
  42. <view class="detail-content">
  43. <view class="col" v-for="(item, index) in form.stockOutApplyPartList" :key="index">
  44. {{ item.name }}({{ item.code + '/' + item.model }}
  45. <u-number-box v-model="item.usedNum" :step="1" :min="0" :max="item.max"
  46. :disabledInput="true"></u-number-box>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <view class="fixed-bottom-bar">
  52. <view class="item s1" @click="submit">提交</view>
  53. <view class="item s2" @click="goBack">返回</view>
  54. </view>
  55. <u-toast ref="uToast"></u-toast>
  56. </view>
  57. </template>
  58. <script>
  59. import PreviewPhoto from '@/pages/maintenance/check/components/PreviewPhoto.vue'
  60. import {
  61. getWorkOrderDetail,
  62. getDeviceList,
  63. startExecuting,
  64. signingWork,
  65. devicestatistics
  66. } from '@/api/myTicket/index.js'
  67. import {
  68. get,
  69. postJ,
  70. post
  71. } from '@/utils/api.js'
  72. import fileMain from "@/pages/doc/index.vue"
  73. export default {
  74. components: {
  75. fileMain,
  76. PreviewPhoto
  77. },
  78. data() {
  79. return {
  80. form: {
  81. // 图片
  82. workOrderImg: [],
  83. // 说明
  84. repairReportExplain: '',
  85. // 工单id
  86. workOrderId: '',
  87. // 备品备件
  88. stockOutApplyPartList: [],
  89. attachments: [],
  90. // 拍照列表
  91. photoList: []
  92. },
  93. workOrderCode: '',
  94. // 选择的图片
  95. FileImgList: [],
  96. // 工单信息
  97. worksheetInfo: {},
  98. equiCode: ''
  99. }
  100. },
  101. async onLoad(options) {
  102. this.worksheetInfo = options
  103. // this.equiCode = options.equiCode
  104. // await this.getInfo()
  105. // this.getbpbj()
  106. },
  107. onShow() {},
  108. methods: {
  109. // 请求信息
  110. getInfo() {
  111. return get(this.apiUrl + '/repair/info/getWorkOrderDetail/' + this.workOrderCode).then(res => {
  112. if (res.success) {
  113. this.worksheetInfo = res.data
  114. }
  115. })
  116. },
  117. // 图片删除
  118. imagedelete(index) {
  119. this.form.photoList.splice(index, 1);
  120. },
  121. // *** 新增拍照功能
  122. chooseImage() {
  123. const _this = this
  124. if (_this.form.photoList.length >= 9) {
  125. _this.$refs.uToast.show({
  126. type: "warning",
  127. message: "最多上传9张照片",
  128. })
  129. return
  130. }
  131. uni.chooseImage({
  132. count: 9, //默认9
  133. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  134. sourceType: ['camera'], //从相册选择
  135. success: function(res) {
  136. uni.showLoading({
  137. title: '加载中'
  138. })
  139. _this.uploadFile(res.tempFilePaths).then(res => {
  140. res.forEach(item => {
  141. let fileNames = item.storePath.split('/')
  142. let url = _this.apiUrl +
  143. '/main/file/getFile?objectName=' + item.storePath +
  144. '&fullfilename=' + fileNames[fileNames.length -
  145. 1]
  146. let photoList = _this.form.photoList;
  147. // 不能存储超过 9 张
  148. if (photoList.length < 9) {
  149. _this.form.photoList.push(url);
  150. }
  151. })
  152. uni.hideLoading()
  153. })
  154. }
  155. });
  156. },
  157. uploadFile(list) {
  158. let PromiseAll = []
  159. const apiUrl = this.apiUrl
  160. const token = uni.getStorageSync("token"); //取存本地的token
  161. list.forEach(item => {
  162. PromiseAll.push(
  163. new Promise((resolve, reject) => {
  164. uni.uploadFile({
  165. url: apiUrl + '/main/file/upload',
  166. filePath: item,
  167. name: 'multiPartFile',
  168. header: {
  169. authorization: token
  170. },
  171. success: (uploadFileRes) => {
  172. let data = JSON.parse(uploadFileRes.data)
  173. resolve(data.data)
  174. }
  175. });
  176. }),
  177. )
  178. })
  179. return Promise.all(PromiseAll)
  180. },
  181. // 返回
  182. goBack() {
  183. uni.navigateBack({
  184. delta: 1
  185. })
  186. },
  187. // 选择图片
  188. async handlImageSelect(e) {
  189. let element = e.tempFiles[0]
  190. let url = await this.uploadFiles(element.path)
  191. if (url) {
  192. // element.url = url
  193. this.form.workOrderImg.push(url)
  194. }
  195. },
  196. // 图片删除
  197. handlImagDeletee(e) {
  198. let index = this.form.workOrderImg.findIndex(n => {
  199. return n.uuid == e.tempFile.uuid
  200. })
  201. if (index !== -1) {
  202. this.form.workOrderImg.splice(index, 1)
  203. }
  204. },
  205. // 文件上传
  206. uploadFiles(tempFilePaths) {
  207. let that = this
  208. return new Promise((resolve, reject) => {
  209. uni.uploadFile({
  210. url: this.apiUrl + '/main/file/upload', //后端用于处理图片并返回图片地址的接口
  211. filePath: tempFilePaths,
  212. name: 'multiPartFile',
  213. header: {
  214. Authorization: wx.getStorageSync('token')
  215. },
  216. formData: {
  217. module: 'eam'
  218. },
  219. success: res => {
  220. console.log(res)
  221. let data = JSON.parse(res.data) //返回的是字符串,需要转成对象格式
  222. console.log('res-----------')
  223. console.log(data)
  224. resolve(data.data.storePath)
  225. },
  226. fail: err => {
  227. reject(null)
  228. uni.showToast({
  229. title: '图片上传失败',
  230. icon: 'none'
  231. })
  232. }
  233. })
  234. })
  235. },
  236. // 提交
  237. async submit() {
  238. signingWork({
  239. id: this.worksheetInfo.id,
  240. remark: this.form.repairReportExplain,
  241. attachments: this.form.attachments,
  242. // workOrderImg: this.form.workOrderImg.join(',')
  243. photoList: this.form.photoList
  244. }).then(() => {
  245. uni.showToast({
  246. title: '报工成功',
  247. icon: 'success',
  248. duration: 2000
  249. })
  250. this.back()
  251. })
  252. // let par = JSON.parse(JSON.stringify(this.form))
  253. // par.stockOutApplyPartList = par.stockOutApplyPartList.map(n => {
  254. // delete n.max
  255. // return n
  256. // })
  257. // par.workOrderId = this.worksheetInfo.workOrderId
  258. // let workOrderImg = par.workOrderImg.map(n => {
  259. // return n.url
  260. // })
  261. // par.workOrderImg = workOrderImg.join(',')
  262. // postJ(this.apiUrl + '/workOrder/repairReportWork', par).then(res => {
  263. // if (res.success) {
  264. // uni.showToast({
  265. // title: '报工成功',
  266. // icon: 'success',
  267. // duration: 2000
  268. // })
  269. // this.back()
  270. // }
  271. // })
  272. },
  273. // 获取备品备件
  274. getbpbj() {
  275. post(this.apiUrl + '/stockOutApply/getApplyEquiPartList', {
  276. workOrderId: this.worksheetInfo.workOrderId
  277. }).then(res => {
  278. if (res.success) {
  279. this.form.stockOutApplyPartList = res.data.map(n => {
  280. n.max = n.usedNum
  281. n.usedNum = 0
  282. delete n.id
  283. delete n.createTime
  284. delete n.updateTime
  285. return n
  286. })
  287. }
  288. })
  289. },
  290. // 返回
  291. back() {
  292. uni.navigateBack({
  293. delta: 1
  294. })
  295. },
  296. // 跳转到备品备件使用登记页面
  297. goRegister() {
  298. uni.navigateTo({
  299. url: `/pages/maintenance/check/register?workOrderCode=${this.workOrderCode}&equipmentCode=${this.equiCode}&from=maintain_service`
  300. })
  301. }
  302. }
  303. }
  304. </script>
  305. <style lang="scss" scoped>
  306. .photo_btn {
  307. background-color: #157a2c;
  308. width: 140rpx;
  309. height: 60rpx;
  310. line-height: 60rpx;
  311. font-size: 24rpx;
  312. color: #fff;
  313. text-align: center;
  314. border-radius: 8rpx;
  315. margin-bottom: 12rpx;
  316. display: inline-block;
  317. }
  318. .fixed-top-bar {
  319. display: flex;
  320. background: #fff;
  321. width: 100%;
  322. height: 80rpx;
  323. justify-content: space-between;
  324. align-items: center;
  325. padding: 0 20rpx;
  326. box-sizing: border-box;
  327. .item {
  328. font-size: 28rpx;
  329. color: #333333;
  330. font-weight: bold;
  331. }
  332. }
  333. .content {
  334. margin: 0 0 81rpx 0;
  335. padding: 0 20rpx;
  336. position: relative;
  337. }
  338. .bxjlbh-wrap {
  339. margin-top: 30rpx;
  340. .item {
  341. height: 30px;
  342. display: flex;
  343. border: 1px solid #d7d7d7;
  344. &+.item {
  345. margin-top: 3px;
  346. }
  347. .label {
  348. width: 100px;
  349. height: 100%;
  350. line-height: 30px;
  351. text-align: center;
  352. background: #d7d7d7;
  353. font-size: 32rpx;
  354. color: rgb(62, 62, 62);
  355. }
  356. .value-wrap {
  357. flex: 1;
  358. display: flex;
  359. align-items: center;
  360. padding-left: 10px;
  361. &.text {
  362. background: #f2f2f2;
  363. font-size: 32rpx;
  364. }
  365. .picker {
  366. width: 100%;
  367. color: rgb(153, 153, 153);
  368. font-size: 32rpx;
  369. }
  370. }
  371. }
  372. }
  373. .clsm {
  374. margin-top: 20rpx;
  375. .textarea {
  376. width: 100%;
  377. border: 1px solid #f2f2f2;
  378. margin-top: 10rpx;
  379. box-sizing: border-box;
  380. }
  381. }
  382. .sc-wrap {
  383. margin-top: 20rpx;
  384. .title {
  385. margin-bottom: 7px;
  386. }
  387. }
  388. .bpbj {
  389. margin-top: 20rpx;
  390. .title {
  391. margin-bottom: 7px;
  392. }
  393. .detail-content {
  394. border: 1rpx solid rgba(242, 242, 242, 1);
  395. .col {
  396. font-size: 28rpx;
  397. border-bottom: 1rpx solid rgba(242, 242, 242, 1);
  398. display: flex;
  399. padding: 10rpx;
  400. align-items: center;
  401. justify-content: space-between;
  402. background-color: rgba(242, 242, 242, 0.372549019607843);
  403. }
  404. .plus {
  405. width: 40rpx;
  406. height: 40rpx;
  407. line-height: 38rpx;
  408. text-align: center;
  409. background-color: $j-primary-border-green;
  410. color: #fff;
  411. margin: 16rpx 0 0 16rpx;
  412. }
  413. }
  414. /deep/.u-number-box {
  415. .u-number-box__minus,
  416. .u-number-box__plus,
  417. .u-number-box__input {
  418. font-size: 30rpx;
  419. height: 1.6em !important;
  420. }
  421. .u-number-box__input {
  422. width: 2em !important;
  423. }
  424. .u-number-box__minus,
  425. .u-number-box__plus {
  426. background-color: $j-primary-border-green !important;
  427. .u-icon__icon {
  428. color: #fff !important;
  429. }
  430. }
  431. }
  432. }
  433. .fixed-bottom-bar {
  434. display: flex;
  435. position: fixed;
  436. bottom: 0;
  437. left: 0;
  438. width: 100%;
  439. height: 80rpx;
  440. box-sizing: border-box;
  441. border-top: 1px solid #f2f2f2;
  442. .item {
  443. flex: 1;
  444. height: 100%;
  445. line-height: 80rpx;
  446. text-align: center;
  447. &.s1 {
  448. background-color: #157a2c;
  449. color: #fff;
  450. }
  451. }
  452. }
  453. </style>