FinishOutForm.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <a-modal
  3. :title="modalTitle"
  4. :width="800"
  5. :visible="visible"
  6. :confirmLoading="confirmLoading"
  7. class="ant-modal2"
  8. @cancel="handleCancel"
  9. >
  10. <a-form :form="form">
  11. <a-form-item v-show="false" >
  12. <a-input v-decorator="['id']" type="hidden"/>
  13. </a-form-item>
  14. <row-list :col="2">
  15. <row-item>
  16. <a-form-item
  17. label="委外订单号"
  18. :labelCol="BaseTool.Constant.labelCol"
  19. :wrapperCol="BaseTool.Constant.wrapperCol"
  20. >
  21. <a-input
  22. disabled="disabled"
  23. v-decorator="['no', {rules: [{required: false, message: '委外订单号不能为空'}]}]"/>
  24. </a-form-item>
  25. </row-item>
  26. <row-item>
  27. <a-form-item
  28. label="委外类别"
  29. :labelCol="BaseTool.Constant.labelCol"
  30. :wrapperCol="BaseTool.Constant.wrapperCol"
  31. >
  32. <a-select v-decorator="['outType']" placeholder="请选择">
  33. <a-select-option
  34. v-for="(label,value) in outTypeMap"
  35. :key="value"
  36. :label="label"
  37. :value="parseInt(value)">{{ label }}
  38. </a-select-option>
  39. </a-select>
  40. </a-form-item>
  41. </row-item>
  42. </row-list>
  43. <row-list :col="1">
  44. <row-item>
  45. <a-form-item
  46. label="故障描述"
  47. :labelCol="BaseTool.Constant.labelCol2"
  48. :wrapperCol="BaseTool.Constant.wrapperCol2"
  49. >
  50. <a-textarea v-decorator="['content', {rules: [{required: true, message: '故障描述不能为空'}]}]"/>
  51. </a-form-item>
  52. </row-item>
  53. </row-list>
  54. <row-list :col="1">
  55. <row-item>
  56. <a-form-item
  57. label="维修描述"
  58. :labelCol="BaseTool.Constant.labelCol2"
  59. :wrapperCol="BaseTool.Constant.wrapperCol2"
  60. >
  61. <a-textarea v-decorator="['repairContent', {rules: [{required: true, message: '维修描述不能为空'}]}]"/>
  62. </a-form-item>
  63. </row-item>
  64. <row-item>
  65. <a-form-item
  66. label="维修图片"
  67. :labelCol="BaseTool.Constant.labelCol2"
  68. :wrapperCol="BaseTool.Constant.wrapperCol2"
  69. >
  70. <a-upload
  71. :action="uploadUrl"
  72. :multiple="true"
  73. list-type="picture"
  74. :file-list="defaultRepairFileList"
  75. @change="handleRepairFileChange"
  76. accept="image/*"
  77. :headers="headers"
  78. >
  79. <a-button> <a-icon type="upload" /> 上传图片 </a-button>
  80. </a-upload>
  81. </a-form-item>
  82. </row-item>
  83. </row-list>
  84. </a-form>
  85. <spare-part-used-select-modal ref="sparePartUsedSelectModal" />
  86. <template slot="footer">
  87. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  88. </template>
  89. </a-modal>
  90. </template>
  91. <script>
  92. import pick from 'lodash.pick'
  93. import { finish } from '@/api/repair/application-form'
  94. import { queryUser } from '@/api/upms/user'
  95. import { fetchErrorTypeTree } from '@/api/repair/errortype'
  96. import SparePartUsedSelectModal from '@/views/sqarepartmanage/sparepartused/modules/SparePartUsedSelectModal'
  97. import { uploadUrl } from '@/api/upms/file'
  98. import Vue from 'vue'
  99. import { ACCESS_TOKEN } from '@/store/mutation-types'
  100. export default {
  101. name: 'BaseRepairApplicationForm',
  102. data () {
  103. return {
  104. model: null,
  105. confirmLoading: false,
  106. modalTitle: null,
  107. form: this.$form.createForm(this),
  108. visible: false,
  109. // 下拉框map
  110. treeData: [],
  111. descripitionMap: {},
  112. sourceMap: {},
  113. outTypeMap: {},
  114. levelMap: {},
  115. needStopMap: {},
  116. statusMap: {},
  117. headers: {
  118. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  119. },
  120. uploadUrl: uploadUrl,
  121. defaultRepairFileList: [],
  122. repairFileList: [], // 维修图片,
  123. userList: []
  124. }
  125. },
  126. components: {
  127. SparePartUsedSelectModal
  128. },
  129. props: {
  130. },
  131. created () {
  132. // 下拉框map
  133. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  134. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  135. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  136. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  137. this.descripitionMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIRE_ACTION)
  138. this.outTypeMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_OUT_TYPE)
  139. },
  140. methods: {
  141. base (record) {
  142. this.setTree()
  143. this.visible = true
  144. this.model = record
  145. // 如果是空标识添加
  146. if (this.BaseTool.Object.isBlank(record)) {
  147. this.modalTitle = '添加'
  148. return
  149. }
  150. this.modalTitle = '委外完成'
  151. const { form: { setFieldsValue } } = this
  152. // 日期处理
  153. this.$nextTick(() => {
  154. setFieldsValue(Object.assign(pick(record, [
  155. 'id',
  156. 'no',
  157. 'outType',
  158. 'content'
  159. ])))
  160. })
  161. },
  162. getUsers () {
  163. queryUser({ status: 1 }).then(res => {
  164. this.userList = res.data
  165. })
  166. },
  167. handleRepairFileChange (info) {
  168. this.defaultRepairFileList = info.fileList
  169. this.repairFileList = this.setFileList(info, 12)
  170. },
  171. setFileList (info, type) {
  172. const file = info.file
  173. const fileList = info.fileList
  174. if (file.status === 'done') {
  175. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  176. } else if (file.status === 'removed') {
  177. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  178. } else if (file.status === 'error') {
  179. this.$message.error('上传失败')
  180. return []
  181. }
  182. },
  183. save () {
  184. const { form: { validateFieldsAndScroll } } = this
  185. this.confirmLoading = true
  186. validateFieldsAndScroll((errors, values) => {
  187. if (errors) {
  188. this.confirmLoading = false
  189. return
  190. }
  191. // 日期处理
  192. values.repairFileList = this.repairFileList
  193. console.log(values)
  194. finish(values).then(() => {
  195. this.handleCancel(values)
  196. }).catch(() => {
  197. this.confirmLoading = false
  198. })
  199. })
  200. },
  201. handleCancel (values) {
  202. this.visible = false
  203. this.confirmLoading = false
  204. this.form.resetFields()
  205. if (this.BaseTool.Object.isNotBlank(values)) {
  206. this.$emit('ok')
  207. }
  208. },
  209. handleSbSelect () {
  210. this.$refs.sbInfoSelectModal.base({}, { filter: 0, status: 2 })
  211. },
  212. handleSbSelectd (keys, rows) {
  213. const [ key ] = keys
  214. const [ row ] = rows
  215. const { form: { setFieldsValue } } = this
  216. // 日期处理
  217. this.$nextTick(() => {
  218. setFieldsValue(Object.assign({
  219. 'sbId': key,
  220. 'sbName': row.name
  221. }))
  222. })
  223. },
  224. handlePartSelect () {
  225. const sbId = this.form.getFieldValue('sbId')
  226. this.$refs.partInfoSelectModal.base({ sbId })
  227. },
  228. handlePartSelected (keys, rows) {
  229. const [ key ] = keys
  230. const [ row ] = rows
  231. const { form: { setFieldsValue } } = this
  232. this.$nextTick(() => {
  233. setFieldsValue(Object.assign({
  234. 'partId': key,
  235. 'partName': row.name
  236. }))
  237. })
  238. },
  239. /**
  240. * 设置类别树
  241. */
  242. setTree (record = {}) {
  243. fetchErrorTypeTree({ id: record.id }).then(res => {
  244. this.treeData = res.data
  245. })
  246. },
  247. handleAddPartUsed () {
  248. /* const modal = this.$refs.repairFeeModal
  249. modal.base(null, record) */
  250. this.$refs.sparePartUsedSelectModal.base(this.model, { sbId: this.model.sbId, modelId: this.model.modelId })
  251. }
  252. }
  253. }
  254. </script>