service-add.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  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="维修时间">
  33. <u-input v-model="form.wxtime" disabled @click="wxtimeShow = true" />
  34. <u-picker v-model="wxtimeShow" mode="time" @confirm="handleWxTime"></u-picker>
  35. </u-form-item> -->
  36. <u-form-item label="工单类别" required prop="category" :label-width="150">
  37. <u-input v-model="category" disabled @click="categoryState = true" type="select" />
  38. <u-select v-model="categoryState" :list="categoryMap" @confirm="categorySubmit"></u-select>
  39. </u-form-item>
  40. <u-form-item
  41. label="是否停机"
  42. required
  43. prop="halt"
  44. :label-width="150"
  45. >
  46. <u-input
  47. v-model="form.halt"
  48. disabled
  49. @click="haltState = true"
  50. placeholder="请选择是否停机"
  51. type="select"
  52. />
  53. <u-select
  54. v-model="haltState"
  55. :list="haltList"
  56. @confirm="haltSubmit"
  57. :default-value="haltDefaultValue"
  58. ></u-select>
  59. </u-form-item>
  60. <u-form-item label="维修图片">
  61. <u-upload
  62. width="180"
  63. height="180"
  64. max-count="3"
  65. :action="action"
  66. :file-list="fileList"
  67. @on-success="uploadSuccess"
  68. @on-remove="uploadRemove"
  69. :header="header"></u-upload>
  70. </u-form-item>
  71. </u-form>
  72. <view class="p-fixed d-flex j-around a-center footer">
  73. <!-- <view class="main-color-bg text-color-white common" @tap="goUseRepair">备件</view>-->
  74. <view class="main-color-bg text-color-white common" @tap="handleSubmit">完成</view>
  75. </view>
  76. </view>
  77. </view>
  78. </template>
  79. <script>
  80. export default {
  81. data() {
  82. return {
  83. form: {
  84. badType: '',
  85. // wxremarks: '',
  86. // photo: '',
  87. // wxtime: '',
  88. category: '',
  89. descripitionType: '',
  90. no: '',
  91. halt: '',
  92. needStop: '',
  93. userName: '',
  94. repairErrorTypeId: '',
  95. repairMinutes: '',
  96. repairRemark: '',
  97. repairContent: ''
  98. },
  99. wxtimeShow: false,
  100. badState: false,
  101. categoryState: false,
  102. category: '',
  103. badList: [],
  104. categoryMap: [],
  105. haltState: false, // 是否停机
  106. haltList: [],
  107. descripitionState: false,
  108. descripitionList: [],
  109. action: this.$BaseTool.UserUtil.getUploadUrl(),
  110. header: {
  111. Authorization: 'Bearer ' + uni.getStorageSync('accessToken')
  112. },
  113. fileList: [],
  114. imagesList: [],
  115. detailId: '',
  116. descripitionMap: {},
  117. needStopMap: {},
  118. haltDefaultValue: [0],
  119. rules: {
  120. halt: [
  121. {
  122. required: true,
  123. message: '请选择是否停机',
  124. trigger: ['blur', 'change']
  125. }
  126. ]
  127. /* badType: [{
  128. required: true,
  129. message: '请选择故障类别',
  130. trigger: ['blur', 'change']
  131. }],
  132. descripitionType: [{
  133. required: true,
  134. message: '请选择维修描述',
  135. trigger: ['blur', 'change']
  136. }] */
  137. }
  138. };
  139. },
  140. onLoad(options) {
  141. if (options) {
  142. this.detailId = options.id
  143. this.form.id = options.id
  144. }
  145. this.descripitionMap = this.$DictCache.getLabelByValueMapByType(this.$DictCache.TYPE.REPAIRE_ACTION)
  146. const temp = []
  147. for (const key in this.descripitionMap) {
  148. temp.push({
  149. label: this.descripitionMap[key],
  150. value: key
  151. })
  152. this.descripitionList = temp
  153. }
  154. const categoryMap = this.$DictCache.getLabelByValueMapByType(
  155. this.$DictCache.TYPE.REPAIR_APPLICATION_FORM_CATEGORY
  156. )
  157. for (const key in categoryMap) {
  158. this.categoryMap.push({
  159. label: categoryMap[key],
  160. value: key
  161. });
  162. }
  163. this.needStopMap = this.$DictCache.getLabelByValueMapByType(
  164. this.$DictCache.TYPE.YES_NO
  165. );
  166. for (const key in this.needStopMap) {
  167. this.haltList.push({
  168. label: this.needStopMap[key],
  169. value: key
  170. });
  171. }
  172. this.form.halt = this.haltList[this.haltDefaultValue].label;
  173. this.form.needStop = this.haltList[this.haltDefaultValue].value;
  174. this.initData()
  175. this.getType()
  176. },
  177. onReady() {
  178. // this.$refs.uForm.setRules(this.rules);
  179. },
  180. methods: {
  181. descripitionSubmit(data) {
  182. this.form.descripitionType = data[0].label;
  183. this.form.descripition = data[0].value;
  184. },
  185. // 领用备件
  186. goUseRepair() {
  187. uni.navigateTo({
  188. url: '../use-repair/use-repair'
  189. });
  190. },
  191. categorySubmit(data) {
  192. this.category = data[0].label;
  193. this.form.category = data[0].value;
  194. },
  195. badSubmit(data) {
  196. this.form.badType = data[0].label;
  197. this.form.errorTypeId = data[0].value;
  198. },
  199. // 时间
  200. // handleWxTime(e) {
  201. // this.form.wxtime = e.year + '-' + e.month + '-' + e.day;
  202. // },
  203. // 提交
  204. handleSubmit() {
  205. const params = {
  206. ...this.form
  207. }
  208. params.repairFileList = this.imagesList
  209. this.$Http
  210. .finish(params)
  211. .then((res) => {
  212. uni.redirectTo({
  213. url: '/pages/service-detail/service-detail?id=' + this.detailId
  214. })
  215. })
  216. },
  217. haltSubmit(data) {
  218. this.form.halt = data[0].label;
  219. this.form.needStop = data[0].value;
  220. },
  221. // 删除成功
  222. uploadRemove(index, lists, name) {
  223. this.fileList = lists;
  224. },
  225. // 上传成功
  226. uploadSuccess(data, index, lists, name) {
  227. this.fileList = lists;
  228. this.imagesList.push(data.data)
  229. },
  230. getType() {
  231. this.$Http
  232. .fetchErrorTypeTree({
  233. id: this.detailId
  234. })
  235. .then((res) => {
  236. const temp = []
  237. res.data.forEach(item => {
  238. temp.push({
  239. label: item.title,
  240. value: item.id
  241. })
  242. })
  243. this.badList = temp
  244. })
  245. },
  246. initData() {
  247. this.$Http
  248. .fetchRepairApplicationForm({
  249. id: this.detailId
  250. })
  251. .then((res) => {
  252. this.form.no = res.data.no;
  253. this.form.category = res.data.category
  254. this.category = this.categoryMap.find(item => item.value == res.data.category).label
  255. this.form.userName = res.data.userName;
  256. this.form.repairMinutes = res.data.minutes
  257. this.form.repairRemark = res.data.repairRemark
  258. this.form.descripitionType = this.descripitionMap[res.data.descripition]
  259. this.form.repairContent = res.data.repairContent
  260. this.form.repairErrorTypeId = res.data.repairErrorTypeId
  261. this.form.badType = res.data.errorTypeName ? res.data.errorTypeName : ''
  262. });
  263. }
  264. }
  265. };
  266. </script>
  267. <style lang="less" scoped>
  268. .submit {
  269. align-items: center;
  270. justify-content: space-around;
  271. view {
  272. width: 240rpx;
  273. padding: 15rpx 0;
  274. border-radius: 40rpx;
  275. text-align: center;
  276. }
  277. }
  278. .footer {
  279. bottom: 0;
  280. left: 0;
  281. right: 0;
  282. background-color: #fff;
  283. z-index: 10000;
  284. border-top: 1rpx solid #f4f4f4;
  285. height: 100rpx;
  286. .common {
  287. padding: 15rpx 100rpx;
  288. border-radius: 40rpx;
  289. background-color: #0082ff;
  290. color: #fff;
  291. &:last-child {
  292. background-color: #fff;
  293. color: #0082ff;
  294. border: 1rpx solid #0082ff;
  295. }
  296. }
  297. }
  298. </style>