CheckForm.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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="['remark', {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="defaultVerifyImages"
  37. @change="handleRepairFileChange"
  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-list>
  46. </a-form>
  47. <template slot="footer">
  48. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  49. </template>
  50. </a-modal>
  51. </template>
  52. <script>
  53. import pick from 'lodash.pick'
  54. import { examine, returnRepair } from '@/api/repair/application-form'
  55. import { uploadUrl } from '@/api/upms/file'
  56. import Vue from 'vue'
  57. import { ACCESS_TOKEN } from '@/store/mutation-types'
  58. export default {
  59. name: 'BaseRepairApplicationForm',
  60. data () {
  61. return {
  62. confirmLoading: false,
  63. modalTitle: null,
  64. form: this.$form.createForm(this),
  65. visible: false,
  66. // 下拉框map
  67. statusMap: {},
  68. model: null,
  69. headers: {
  70. Authorization: 'Bearer ' + Vue.ls.get(ACCESS_TOKEN)
  71. },
  72. uploadUrl: uploadUrl,
  73. defaultVerifyImages: [],
  74. verifyImages: [] // 图片,
  75. }
  76. },
  77. components: {
  78. },
  79. props: {
  80. },
  81. created () {
  82. // 下拉框map
  83. },
  84. methods: {
  85. base (record, type) {
  86. this.visible = true
  87. this.model = record
  88. this.model.type = type
  89. const { form: { setFieldsValue } } = this
  90. // 日期处理
  91. record.applyTime = this.BaseTool.Moment(record.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  92. this.$nextTick(() => {
  93. setFieldsValue(Object.assign(pick(record, [
  94. 'id'
  95. ])))
  96. })
  97. if (type === 1) {
  98. this.modalTitle = '报修审核驳回'
  99. } else if (type === 2) {
  100. this.modalTitle = '提交报修审核'
  101. }
  102. },
  103. handleRepairFileChange (info) {
  104. this.defaultVerifyImages = info.fileList
  105. this.verifyImages = this.setFileList(info, 12)
  106. },
  107. setFileList (info, type) {
  108. const file = info.file
  109. const fileList = info.fileList
  110. if (file.status === 'done') {
  111. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  112. } else if (file.status === 'removed') {
  113. return this.BaseTool.UPLOAD.getUploadFileDTO(fileList, type)
  114. } else if (file.status === 'error') {
  115. this.$message.error('上传失败')
  116. return []
  117. }
  118. },
  119. save () {
  120. const { form: { validateFieldsAndScroll } } = this
  121. this.confirmLoading = true
  122. validateFieldsAndScroll((errors, values) => {
  123. if (errors) {
  124. this.confirmLoading = false
  125. return
  126. }
  127. values.verifyImages = this.verifyImages
  128. // 日期处理
  129. if (this.model.type === 1) {
  130. returnRepair(values)
  131. .then(() => {
  132. this.handleCancel(values)
  133. }).catch(() => {
  134. this.confirmLoading = false
  135. })
  136. } else if (this.model.type === 2) {
  137. examine(values).then(() => {
  138. this.$message.info('已提交,请等待审核')
  139. setTimeout(() => {
  140. this.handleCancel(values)
  141. }, 2000)
  142. }).catch(() => {
  143. this.confirmLoading = false
  144. })
  145. }
  146. })
  147. },
  148. handleCancel (values) {
  149. this.visible = false
  150. this.confirmLoading = false
  151. this.form.resetFields()
  152. if (this.BaseTool.Object.isNotBlank(values)) {
  153. this.$emit('ok')
  154. }
  155. }
  156. }
  157. }
  158. </script>