service-add.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. <template>
  2. <view class="mx3">
  3. <view class="main-color-bg" style="height: 100rpx; margin: 0 -30rpx"></view>
  4. <view class="p3 bg-color-white" style="margin-top: -50rpx; border-radius: 20rpx">
  5. <u-form :model="form" ref="uForm" :label-width="150">
  6. <!-- <view class="报修单号 f-size-32 f-weight-6 mt-2">基本信息</view>
  7. <u-form-item label="维修单号">
  8. <u-input v-model="form.no" disabled />
  9. </u-form-item>
  10. <view class="main-color-text f-size-32 f-weight-6 mt-2">报修信息</view>
  11. <u-form-item label="报修人">
  12. <u-input v-model="form.userName" disabled />
  13. </u-form-item>-->
  14. <view class="main-color-text f-size-32 f-weight-6 mt-2">维修信息</view>
  15. <!-- <u-form-item label="故障类别" prop="badType">
  16. <u-input v-model="form.badType" disabled @click="badState = true" type="select" />
  17. <u-select v-model="badState" :list="badList" @confirm="badSubmit"></u-select>
  18. </u-form-item>-->
  19. <!-- <u-form-item label="维修耗时">
  20. <u-input type="number" v-model="form.minutes" />
  21. <template slot="right">
  22. <view>分钟</view>
  23. </template>
  24. </u-form-item>-->
  25. <!-- <u-form-item label="维修动作" prop="descripitionType">
  26. <u-input v-model="form.descripitionType" disabled @click="descripitionState = true" type="select" />
  27. <u-select v-model="descripitionState" :list="descripitionList" @confirm="descripitionSubmit"></u-select>
  28. </u-form-item>-->
  29. <!-- <u-form-item label="备注">
  30. <u-input v-model="form.remark" type="textarea" :height="50" />
  31. </u-form-item> -->
  32. <u-form-item label="维修描述" required prop="repairContent" :label-width="150">
  33. <u-input v-model="form.repairContent" type="textarea" :height="50" placeholder="请输入维修描述" />
  34. </u-form-item>
  35. <!-- <u-form-item label="维修时间">
  36. <u-input v-model="form.wxtime" disabled @click="wxtimeShow = true" />
  37. <u-picker v-model="wxtimeShow" mode="time" @confirm="handleWxTime"></u-picker>
  38. </u-form-item> -->
  39. <u-form-item label="工单类别" required prop="category" :label-width="150">
  40. <u-input v-model="category" disabled @click="categoryState = true" type="select" />
  41. <u-select v-model="categoryState" :list="categoryMap" @confirm="categorySubmit"></u-select>
  42. </u-form-item>
  43. <u-form-item label="是否停机" required prop="halt" :label-width="150">
  44. <u-input v-model="form.halt" disabled @click="haltState = true" placeholder="请选择是否停机"
  45. type="select" />
  46. <u-select v-model="haltState" :list="haltList" @confirm="haltSubmit"
  47. :default-value="haltDefaultValue"></u-select>
  48. </u-form-item>
  49. <u-form-item label="完成时间" prop="repairEndTime" :label-width="150">
  50. <u-input v-model="form.repairEndTime" disabled @click="endTimeShow = true" placeholder="请选择完成时间"
  51. type="select" />
  52. <u-picker mode="time" v-model="endTimeShow" :params="dateTimeParams"
  53. @confirm="endTimeSubmit"></u-picker>
  54. </u-form-item>
  55. <u-form-item label="维修图片">
  56. <u-upload width="180" height="180" max-count="3" :action="action" :file-list="fileList"
  57. @on-success="uploadSuccess" @on-remove="uploadRemove" :header="header"></u-upload>
  58. </u-form-item>
  59. </u-form>
  60. <view class="p-fixed d-flex j-around a-center footer">
  61. <!-- <view class="main-color-bg text-color-white common" @tap="goUseRepair">备件</view>-->
  62. <view class="main-color-bg text-color-white common" @tap="handleSubmit">完成</view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. export default {
  69. data() {
  70. return {
  71. form: {
  72. badType: '',
  73. // wxremarks: '',
  74. // photo: '',
  75. // wxtime: '',
  76. category: '',
  77. descripitionType: '',
  78. no: '',
  79. halt: '',
  80. needStop: '',
  81. userName: '',
  82. repairErrorTypeId: '',
  83. repairMinutes: '',
  84. repairRemark: '',
  85. repairContent: '',
  86. repairEndTime: ''
  87. },
  88. wxtimeShow: false,
  89. endTimeShow: false, // 完成时间
  90. dateTimeParams: {
  91. year: true,
  92. month: true,
  93. day: true,
  94. hour: true,
  95. minute: true,
  96. second: true
  97. },
  98. badState: false,
  99. categoryState: false,
  100. category: '',
  101. badList: [],
  102. categoryMap: [],
  103. haltState: false, // 是否停机
  104. haltList: [],
  105. descripitionState: false,
  106. descripitionList: [],
  107. action: this.$BaseTool.UserUtil.getUploadUrl(),
  108. header: {
  109. Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
  110. },
  111. fileList: [],
  112. imagesList: [],
  113. detailId: '',
  114. descripitionMap: {},
  115. needStopMap: {},
  116. haltDefaultValue: [0],
  117. rules: {
  118. halt: [
  119. {
  120. required: true,
  121. message: '请选择是否停机',
  122. trigger: ['blur', 'change']
  123. }
  124. ],
  125. category: [
  126. {
  127. required: true,
  128. message: '请选择工单类别',
  129. trigger: ['blur', 'change']
  130. }
  131. ],
  132. repairContent: [
  133. {
  134. required: true,
  135. message: '请输入维修描述',
  136. trigger: ['blur', 'change']
  137. }
  138. ]
  139. /* badType: [{
  140. required: true,
  141. message: '请选择故障类别',
  142. trigger: ['blur', 'change']
  143. }],
  144. descripitionType: [{
  145. required: true,
  146. message: '请选择维修描述',
  147. trigger: ['blur', 'change']
  148. }] */
  149. }
  150. };
  151. },
  152. onLoad(options) {
  153. if (options) {
  154. this.detailId = options.id
  155. this.form.id = options.id
  156. }
  157. this.descripitionMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIRE_ACTION)
  158. const temp = []
  159. for (const key in this.descripitionMap) {
  160. temp.push({
  161. label: this.descripitionMap[key],
  162. value: key
  163. })
  164. this.descripitionList = temp
  165. }
  166. const categoryMap = this.$DictCache.getLabelByValueMapByType(
  167. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
  168. )
  169. for (const key in categoryMap) {
  170. this.categoryMap.push({
  171. label: categoryMap[key],
  172. value: key
  173. });
  174. }
  175. this.needStopMap = this.$DictCache.getLabelByValueMapByType(
  176. this.$DictCache.TYPE.YES_NO
  177. );
  178. for (const key in this.needStopMap) {
  179. this.haltList.push({
  180. label: this.needStopMap[key],
  181. value: key
  182. });
  183. }
  184. this.form.halt = this.haltList[this.haltDefaultValue].label;
  185. this.form.needStop = this.haltList[this.haltDefaultValue].value;
  186. this.initData()
  187. this.getType()
  188. },
  189. onReady() {
  190. this.$refs.uForm.setRules(this.rules);
  191. },
  192. methods: {
  193. descripitionSubmit(data) {
  194. this.form.descripitionType = data[0].label;
  195. this.form.descripition = data[0].value;
  196. },
  197. // 领用备件
  198. goUseRepair() {
  199. uni.navigateTo({
  200. url: '../use-repair/use-repair'
  201. });
  202. },
  203. categorySubmit(data) {
  204. this.category = data[0].label;
  205. this.form.category = data[0].value;
  206. // 与 PC 端 FinishForm 联动逻辑一致:计划性维修默认停机,其余默认不停机
  207. const needStopValue = data[0].value == 1 ? '1' : '0';
  208. this.form.needStop = needStopValue;
  209. const haltItem = this.haltList.find(item => item.value == needStopValue);
  210. if (haltItem) {
  211. this.form.halt = haltItem.label;
  212. }
  213. },
  214. badSubmit(data) {
  215. this.form.badType = data[0].label;
  216. this.form.errorTypeId = data[0].value;
  217. },
  218. // 时间
  219. // handleWxTime(e) {
  220. // this.form.wxtime = e.year + '-' + e.month + '-' + e.day;
  221. // },
  222. // 提交
  223. handleSubmit() {
  224. const params = {
  225. ...this.form
  226. }
  227. // 维修图片按 PC 端 FinishForm 的文件 DTO 结构提交(type 12 为维修图片)
  228. params.repairFileList = this.imagesList.map(item => ({
  229. type: 12,
  230. name: item.name,
  231. fileName: item.fileName,
  232. fileFormat: item.fileFormat,
  233. url: item.url
  234. }))
  235. this.$refs.uForm.validate(valid => {
  236. if (valid) {
  237. this.$Http
  238. .finish(params)
  239. .then((res) => {
  240. uni.redirectTo({
  241. url: '/pages/service-detail/service-detail?id=' + this.detailId
  242. })
  243. })
  244. }
  245. })
  246. },
  247. haltSubmit(data) {
  248. this.form.halt = data[0].label;
  249. this.form.needStop = data[0].value;
  250. },
  251. // 完成时间
  252. endTimeSubmit(e) {
  253. this.form.repairEndTime = `${e.year}-${e.month}-${e.day} ${e.hour}:${e.minute}:${e.second}`;
  254. },
  255. // 删除成功
  256. uploadRemove(index, lists, name) {
  257. this.fileList = lists;
  258. // 同步移除已收集的图片,避免删除后仍提交给后端
  259. this.imagesList.splice(index, 1);
  260. },
  261. // 上传成功
  262. uploadSuccess(data, index, lists, name) {
  263. this.fileList = lists;
  264. // 后端返回 { code, data: 文件实体 },只收集文件实体,避免把响应包装对象提交给后端
  265. if (data && data.data) {
  266. this.imagesList.push(data.data)
  267. }
  268. },
  269. getType() {
  270. this.$Http
  271. .fetchErrorTypeTree({
  272. id: this.detailId
  273. })
  274. .then((res) => {
  275. const temp = []
  276. res.data.forEach(item => {
  277. temp.push({
  278. label: item.title,
  279. value: item.id
  280. })
  281. })
  282. this.badList = temp
  283. })
  284. },
  285. initData() {
  286. this.$Http
  287. .fetchRepairApplicationForm({
  288. id: this.detailId
  289. })
  290. .then((res) => {
  291. this.form.no = res.data.no;
  292. this.form.category = res.data.category
  293. this.category = this.categoryMap.find(item => item.value == res.data.category).label
  294. this.form.userName = res.data.userName;
  295. this.form.repairMinutes = res.data.minutes
  296. this.form.repairRemark = res.data.repairRemark
  297. this.form.descripitionType = this.descripitionMap[res.data.descripition]
  298. this.form.repairContent = res.data.repairContent
  299. this.form.repairErrorTypeId = res.data.repairErrorTypeId
  300. this.form.badType = res.data.errorTypeName ? res.data.errorTypeName : ''
  301. });
  302. }
  303. }
  304. };
  305. </script>
  306. <style lang="less" scoped>
  307. .submit {
  308. align-items: center;
  309. justify-content: space-around;
  310. view {
  311. width: 240rpx;
  312. padding: 15rpx 0;
  313. border-radius: 40rpx;
  314. text-align: center;
  315. }
  316. }
  317. .footer {
  318. bottom: 0;
  319. left: 0;
  320. right: 0;
  321. background-color: #fff;
  322. z-index: 10000;
  323. border-top: 1rpx solid #f4f4f4;
  324. height: 100rpx;
  325. .common {
  326. padding: 15rpx 100rpx;
  327. border-radius: 40rpx;
  328. background-color: #0082ff;
  329. color: #fff;
  330. &:last-child {
  331. background-color: #fff;
  332. color: #0082ff;
  333. border: 1rpx solid #0082ff;
  334. }
  335. }
  336. }
  337. </style>