submitted_ministry.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490
  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. let workOrderImg = JSON.stringify(this.form.photoList);
  239. signingWork({
  240. id: this.worksheetInfo.id,
  241. remark: this.form.repairReportExplain,
  242. attachments: this.form.attachments,
  243. // workOrderImg: this.form.workOrderImg.join(',')
  244. workOrderImg: workOrderImg
  245. }).then(() => {
  246. uni.showToast({
  247. title: '报工成功',
  248. icon: 'success',
  249. duration: 2000
  250. })
  251. this.back()
  252. })
  253. // let par = JSON.parse(JSON.stringify(this.form))
  254. // par.stockOutApplyPartList = par.stockOutApplyPartList.map(n => {
  255. // delete n.max
  256. // return n
  257. // })
  258. // par.workOrderId = this.worksheetInfo.workOrderId
  259. // let workOrderImg = par.workOrderImg.map(n => {
  260. // return n.url
  261. // })
  262. // par.workOrderImg = workOrderImg.join(',')
  263. // postJ(this.apiUrl + '/workOrder/repairReportWork', par).then(res => {
  264. // if (res.success) {
  265. // uni.showToast({
  266. // title: '报工成功',
  267. // icon: 'success',
  268. // duration: 2000
  269. // })
  270. // this.back()
  271. // }
  272. // })
  273. },
  274. // 获取备品备件
  275. getbpbj() {
  276. post(this.apiUrl + '/stockOutApply/getApplyEquiPartList', {
  277. workOrderId: this.worksheetInfo.workOrderId
  278. }).then(res => {
  279. if (res.success) {
  280. this.form.stockOutApplyPartList = res.data.map(n => {
  281. n.max = n.usedNum
  282. n.usedNum = 0
  283. delete n.id
  284. delete n.createTime
  285. delete n.updateTime
  286. return n
  287. })
  288. }
  289. })
  290. },
  291. // 返回
  292. back() {
  293. uni.navigateBack({
  294. delta: 1
  295. })
  296. },
  297. // 跳转到备品备件使用登记页面
  298. goRegister() {
  299. uni.navigateTo({
  300. url: `/pages/maintenance/check/register?workOrderCode=${this.workOrderCode}&equipmentCode=${this.equiCode}&from=maintain_service`
  301. })
  302. }
  303. }
  304. }
  305. </script>
  306. <style lang="scss" scoped>
  307. .photo_btn {
  308. background-color: #157a2c;
  309. width: 140rpx;
  310. height: 60rpx;
  311. line-height: 60rpx;
  312. font-size: 24rpx;
  313. color: #fff;
  314. text-align: center;
  315. border-radius: 8rpx;
  316. margin-bottom: 12rpx;
  317. display: inline-block;
  318. }
  319. .fixed-top-bar {
  320. display: flex;
  321. background: #fff;
  322. width: 100%;
  323. height: 80rpx;
  324. justify-content: space-between;
  325. align-items: center;
  326. padding: 0 20rpx;
  327. box-sizing: border-box;
  328. .item {
  329. font-size: 28rpx;
  330. color: #333333;
  331. font-weight: bold;
  332. }
  333. }
  334. .content {
  335. margin: 0 0 81rpx 0;
  336. padding: 0 20rpx;
  337. position: relative;
  338. }
  339. .bxjlbh-wrap {
  340. margin-top: 30rpx;
  341. .item {
  342. height: 30px;
  343. display: flex;
  344. border: 1px solid #d7d7d7;
  345. &+.item {
  346. margin-top: 3px;
  347. }
  348. .label {
  349. width: 100px;
  350. height: 100%;
  351. line-height: 30px;
  352. text-align: center;
  353. background: #d7d7d7;
  354. font-size: 32rpx;
  355. color: rgb(62, 62, 62);
  356. }
  357. .value-wrap {
  358. flex: 1;
  359. display: flex;
  360. align-items: center;
  361. padding-left: 10px;
  362. &.text {
  363. background: #f2f2f2;
  364. font-size: 32rpx;
  365. }
  366. .picker {
  367. width: 100%;
  368. color: rgb(153, 153, 153);
  369. font-size: 32rpx;
  370. }
  371. }
  372. }
  373. }
  374. .clsm {
  375. margin-top: 20rpx;
  376. .textarea {
  377. width: 100%;
  378. border: 1px solid #f2f2f2;
  379. margin-top: 10rpx;
  380. box-sizing: border-box;
  381. }
  382. }
  383. .sc-wrap {
  384. margin-top: 20rpx;
  385. .title {
  386. margin-bottom: 7px;
  387. }
  388. }
  389. .bpbj {
  390. margin-top: 20rpx;
  391. .title {
  392. margin-bottom: 7px;
  393. }
  394. .detail-content {
  395. border: 1rpx solid rgba(242, 242, 242, 1);
  396. .col {
  397. font-size: 28rpx;
  398. border-bottom: 1rpx solid rgba(242, 242, 242, 1);
  399. display: flex;
  400. padding: 10rpx;
  401. align-items: center;
  402. justify-content: space-between;
  403. background-color: rgba(242, 242, 242, 0.372549019607843);
  404. }
  405. .plus {
  406. width: 40rpx;
  407. height: 40rpx;
  408. line-height: 38rpx;
  409. text-align: center;
  410. background-color: $j-primary-border-green;
  411. color: #fff;
  412. margin: 16rpx 0 0 16rpx;
  413. }
  414. }
  415. /deep/.u-number-box {
  416. .u-number-box__minus,
  417. .u-number-box__plus,
  418. .u-number-box__input {
  419. font-size: 30rpx;
  420. height: 1.6em !important;
  421. }
  422. .u-number-box__input {
  423. width: 2em !important;
  424. }
  425. .u-number-box__minus,
  426. .u-number-box__plus {
  427. background-color: $j-primary-border-green !important;
  428. .u-icon__icon {
  429. color: #fff !important;
  430. }
  431. }
  432. }
  433. }
  434. .fixed-bottom-bar {
  435. display: flex;
  436. position: fixed;
  437. bottom: 0;
  438. left: 0;
  439. width: 100%;
  440. height: 80rpx;
  441. box-sizing: border-box;
  442. border-top: 1px solid #f2f2f2;
  443. .item {
  444. flex: 1;
  445. height: 100%;
  446. line-height: 80rpx;
  447. text-align: center;
  448. &.s1 {
  449. background-color: #157a2c;
  450. color: #fff;
  451. }
  452. }
  453. }
  454. </style>