ExamineForm.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 { examineOk } from '@/api/repair/application-form'
  36. export default {
  37. name: 'BaseRepairApplicationForm',
  38. data () {
  39. return {
  40. confirmLoading: false,
  41. modalTitle: null,
  42. form: this.$form.createForm(this),
  43. visible: false,
  44. // 下拉框map
  45. sourceMap: {},
  46. levelMap: {},
  47. needStopMap: {},
  48. descripitionMap: {},
  49. statusMap: {},
  50. model: null,
  51. userList: []
  52. }
  53. },
  54. components: {
  55. },
  56. props: {
  57. },
  58. created () {
  59. // 下拉框map
  60. this.sourceMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_SOURCE)
  61. this.levelMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_LEVEL)
  62. this.statusMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.REPAIR_APPLICATION_FORM_STATUS)
  63. this.needStopMap = this.DictCache.getLabelByValueMapByType(this.DictCache.TYPE.YES_NO)
  64. },
  65. methods: {
  66. base (record) {
  67. this.visible = true
  68. this.model = record
  69. // 如果是空标识添加
  70. if (this.BaseTool.Object.isBlank(record)) {
  71. this.modalTitle = '添加'
  72. return
  73. }
  74. this.modalTitle = '驳回'
  75. const { form: { setFieldsValue } } = this
  76. // 日期处理
  77. record.applyTime = this.BaseTool.Moment(record.applyTime, this.BaseTool.Date.PICKER_NORM_DATETIME_PATTERN)
  78. this.$nextTick(() => {
  79. setFieldsValue(Object.assign(pick(record, [
  80. 'id'
  81. ])))
  82. })
  83. },
  84. save () {
  85. const { form: { validateFieldsAndScroll } } = this
  86. this.confirmLoading = true
  87. validateFieldsAndScroll((errors, values) => {
  88. if (errors) {
  89. this.confirmLoading = false
  90. return
  91. }
  92. // 日期处理
  93. examineOk(0, values)
  94. .then(() => {
  95. this.handleCancel(values)
  96. }).catch(() => {
  97. this.confirmLoading = false
  98. })
  99. })
  100. },
  101. handleCancel (values) {
  102. this.visible = false
  103. this.confirmLoading = false
  104. this.form.resetFields()
  105. if (this.BaseTool.Object.isNotBlank(values)) {
  106. this.$emit('ok')
  107. }
  108. }
  109. }
  110. }
  111. </script>