baseModal.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <a-modal
  3. v-model="opened"
  4. :title="title"
  5. centered
  6. :maskClosable="false"
  7. :width="600"
  8. :footer="null"
  9. @cancel="cancel"
  10. >
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="chooseCustom-form"
  14. ref="ruleForm"
  15. :model="form"
  16. :rules="rules"
  17. :label-col="formItemLayout.labelCol"
  18. :wrapper-col="formItemLayout.wrapperCol">
  19. <a-form-model-item label="客户名称">
  20. {{ form.dealerName }}
  21. </a-form-model-item>
  22. <a-form-model-item label="备注" prop="remarks">
  23. <a-textarea :rows="4" :maxLength="300" placeholder="请输入备注(最多300个字符)" v-model="form.remarks"></a-textarea>
  24. </a-form-model-item>
  25. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;margin-top: 50px;">
  26. <a-button @click="cancel" style="margin-right: 15px" id="chooseCustom-btn-back">取消</a-button>
  27. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
  28. </a-form-model-item>
  29. </a-form-model>
  30. </a-spin>
  31. </a-modal>
  32. </template>
  33. <script>
  34. import { commonMixin } from '@/utils/mixin'
  35. import { VSelect } from '@/components'
  36. import { verifyAccountBillCreate } from '@/api/verifyAccount.js'
  37. export default {
  38. name: 'ASBaseModal',
  39. mixins: [commonMixin],
  40. components: { VSelect },
  41. props: {
  42. show: [Boolean],
  43. itemSn: {
  44. type: String,
  45. default: ''
  46. }
  47. },
  48. data () {
  49. return {
  50. opened: this.show,
  51. spinning: false,
  52. disabled: false,
  53. title: '新增对账单',
  54. confirmLoading: false,
  55. formItemLayout: {
  56. labelCol: { span: 4 },
  57. wrapperCol: { span: 18 }
  58. },
  59. form: {
  60. dealerSn: undefined,
  61. dealerName: undefined,
  62. remarks: ''
  63. },
  64. rules: {
  65. remarks: [{ required: true, message: '请输入备注', trigger: ['change', 'blur'] }]
  66. }
  67. }
  68. },
  69. methods: {
  70. // 保存
  71. handleSubmit (e) {
  72. e.preventDefault()
  73. const _this = this
  74. this.$refs.ruleForm.validate(valid => {
  75. if (valid) {
  76. _this.salesSaveFun()
  77. } else {
  78. return false
  79. }
  80. })
  81. },
  82. // 新建或编辑销售单
  83. salesSaveFun () {
  84. const _this = this
  85. const form = JSON.parse(JSON.stringify(_this.form))
  86. _this.spinning = true
  87. verifyAccountBillCreate(form).then(res => {
  88. if (res.status == 200) {
  89. _this.$message.success(res.message)
  90. _this.$emit('refashData', res.data)
  91. _this.cancel()
  92. }
  93. _this.spinning = false
  94. })
  95. },
  96. cancel () {
  97. this.opened = false
  98. this.$emit('cancel')
  99. this.$refs.ruleForm.resetFields()
  100. },
  101. async pageInit (data) {
  102. this.$nextTick(() => {
  103. this.$refs.ruleForm.resetFields()
  104. })
  105. this.form = {
  106. dealerSn: data.dealer.dealerSn,
  107. dealerName: data.dealer.dealerName,
  108. remarks: ''
  109. }
  110. }
  111. },
  112. watch: {
  113. show (newValue, oldValue) {
  114. this.opened = newValue
  115. }
  116. }
  117. }
  118. </script>