CheckForm.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.labelCol2"
  19. :wrapperCol="BaseTool.Constant.wrapperCol2"
  20. >
  21. <a-textarea
  22. :rows="4"
  23. v-decorator="['checkContent', {rules: [{required: true, message: '原因不能为空'}]}]"/>
  24. </a-form-item>
  25. </row-item>
  26. </row-list>
  27. </a-form>
  28. <template slot="footer">
  29. <a-button :loading="confirmLoading" type="primary" @click="save()">保存</a-button>
  30. </template>
  31. </a-modal>
  32. </template>
  33. <script>
  34. import pick from 'lodash.pick'
  35. import { returnRepair } from '@/api/repair/application-form'
  36. import { queryUser } from '@/api/upms/user'
  37. export default {
  38. name: 'BaseRepairApplicationForm',
  39. data () {
  40. return {
  41. confirmLoading: false,
  42. modalTitle: null,
  43. form: this.$form.createForm(this),
  44. visible: false,
  45. // 下拉框map
  46. sourceMap: {},
  47. levelMap: {},
  48. needStopMap: {},
  49. descripitionMap: {},
  50. statusMap: {},
  51. model: null,
  52. userList: []
  53. }
  54. },
  55. components: {
  56. },
  57. props: {
  58. },
  59. created () {
  60. // 下拉框map
  61. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  62. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  63. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  64. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  65. this.getUsers()
  66. },
  67. methods: {
  68. base (record) {
  69. console.log('11111')
  70. this.visible = true
  71. this.model = record
  72. // 如果是空标识添加
  73. if (this.BaseTool.Object.isBlank(record)) {
  74. this.modalTitle = '添加'
  75. return
  76. }
  77. this.modalTitle = '驳回'
  78. const { form: { setFieldsValue } } = this
  79. // 日期处理
  80. record.applyTime = this.BaseTool.Moment(record.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  81. this.$nextTick(() => {
  82. setFieldsValue(Object.assign(pick(record, [
  83. 'id'
  84. ])))
  85. })
  86. },
  87. getUsers () {
  88. queryUser({ status: 1 }).then(res => {
  89. this.userList = res.data
  90. })
  91. },
  92. save () {
  93. const { form: { validateFieldsAndScroll } } = this
  94. this.confirmLoading = true
  95. validateFieldsAndScroll((errors, values) => {
  96. if (errors) {
  97. this.confirmLoading = false
  98. return
  99. }
  100. // 日期处理
  101. returnRepair(values)
  102. .then(() => {
  103. this.handleCancel(values)
  104. }).catch(() => {
  105. this.confirmLoading = false
  106. })
  107. })
  108. },
  109. handleCancel (values) {
  110. this.visible = false
  111. this.confirmLoading = false
  112. this.form.resetFields()
  113. if (this.BaseTool.Object.isNotBlank(values)) {
  114. this.$emit('ok')
  115. }
  116. }
  117. }
  118. }
  119. </script>