FinishOutForm.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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="1">
  15. <row-item>
  16. <a-form-item
  17. label="维修情况"
  18. :labelCol="BaseTool.Constant.labelCol2"
  19. :wrapperCol="BaseTool.Constant.wrapperCol2"
  20. >
  21. <a-textarea
  22. :rows="4"
  23. v-decorator="['finishRemark', {rules: [{required: true, message: '维修情况不能为空'}]}]"/>
  24. </a-form-item>
  25. </row-item>
  26. <row-item>
  27. <a-form-item
  28. label="上传图片"
  29. :labelCol="BaseTool.Constant.labelCol2"
  30. :wrapperCol="BaseTool.Constant.wrapperCol2"
  31. >
  32. <a-upload
  33. :action="uploadUrl"
  34. :multiple="true"
  35. list-type="picture"
  36. :file-list="defaultFinishFileList"
  37. @change="handleFinishFileChange"
  38. accept="image/*"
  39. :headers="headers"
  40. >
  41. <a-button> <a-icon type="upload" /> 上传图片 </a-button>
  42. </a-upload>
  43. </a-form-item>
  44. </row-item>
  45. <row-item>
  46. <a-form-item
  47. label="上传附件"
  48. :labelCol="BaseTool.Constant.labelCol2"
  49. :wrapperCol="BaseTool.Constant.wrapperCol2"
  50. >
  51. <a-upload
  52. :action="uploadUrl"
  53. :multiple="true"
  54. :file-list="defaultAttachmentList"
  55. @change="handleAttachmentChange"
  56. :headers="headers"
  57. >
  58. <a-button> <a-icon type="upload" /> 上传附件 </a-button>
  59. </a-upload>
  60. </a-form-item>
  61. </row-item>
  62. </row-list>
  63. </a-form>
  64. <template slot="footer">
  65. <a-button :loading="confirmLoading" type="primary" @click="save()">完成</a-button>
  66. </template>
  67. </a-modal>
  68. </template>
  69. <script>
  70. import { finishRepairEntrust } from '@/api/repair/entrust'
  71. import { uploadUrl } from '@/api/upms/file'
  72. import Vue from 'vue'
  73. import { ACCESS_TOKEN } from '@/store/mutation-types'
  74. export default {
  75. name: 'FinishOutForm',
  76. data () {
  77. return {
  78. model: null,
  79. confirmLoading: false,
  80. modalTitle: '委外完成',
  81. form: this.$form.createForm(this),
  82. visible: false,
  83. headers: {
  84. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  85. },
  86. uploadUrl: uploadUrl,
  87. defaultFinishFileList: [],
  88. defaultAttachmentList: [],
  89. finishFileList: [],
  90. finishAttachmentList: []
  91. }
  92. },
  93. components: {
  94. },
  95. created () {
  96. },
  97. methods: {
  98. base (record) {
  99. this.visible = true
  100. this.model = record
  101. this.defaultFinishFileList = []
  102. this.defaultAttachmentList = []
  103. this.finishFileList = []
  104. this.finishAttachmentList = []
  105. const { form: { setFieldsValue } } = this
  106. this.$nextTick(() => {
  107. setFieldsValue({
  108. id: record.id
  109. })
  110. })
  111. },
  112. handleFinishFileChange (info) {
  113. this.defaultFinishFileList = info.fileList
  114. this.finishFileList = this.setFileList(info)
  115. },
  116. handleAttachmentChange (info) {
  117. this.defaultAttachmentList = info.fileList
  118. this.finishAttachmentList = this.setFileList(info)
  119. },
  120. setFileList (info) {
  121. const file = info.file
  122. const fileList = info.fileList
  123. if (file.status === 'done') {
  124. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, 12)
  125. } else if (file.status === 'removed') {
  126. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, 12)
  127. } else if (file.status === 'error') {
  128. this.$message.error('上传失败')
  129. return []
  130. }
  131. },
  132. save () {
  133. const { form: { validateFieldsAndScroll } } = this
  134. this.confirmLoading = true
  135. validateFieldsAndScroll((errors, values) => {
  136. if (errors) {
  137. this.confirmLoading = false
  138. return
  139. }
  140. values.finishFileList = this.finishFileList
  141. values.finishAttachmentList = this.finishAttachmentList
  142. finishRepairEntrust(values.id, values).then(() => {
  143. this.handleCancel(values)
  144. }).catch(() => {
  145. this.confirmLoading = false
  146. })
  147. })
  148. },
  149. handleCancel (values) {
  150. this.visible = false
  151. this.confirmLoading = false
  152. this.form.resetFields()
  153. if (this.BaseTool.Object.isNotBlank(values)) {
  154. this.$emit('ok')
  155. }
  156. }
  157. }
  158. }
  159. </script>