dsModal.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <template>
  2. <a-modal
  3. centered
  4. class="dealerAccountEdit-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="提交调拨单"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. :width="800">
  11. <!-- 表单 -->
  12. <div>
  13. <a-spin :spinning="spinning" tip="Loading...">
  14. <a-form-model
  15. id="dealerAccountEdit-form"
  16. ref="ruleForm"
  17. :model="form"
  18. :rules="rules"
  19. :label-col="formItemLayout.labelCol"
  20. :wrapper-col="formItemLayout.wrapperCol"
  21. >
  22. <a-form-model-item label="收货客户名称" v-if="dealerLevel != 'OTHER'">
  23. <dealerSubareaScopeList ref="custList" defValKey="buyerSn" @change="custChange" v-model="form.receiverSn" />
  24. </a-form-model-item>
  25. <a-form-model-item label="收货客户名称" v-else>
  26. <a-input
  27. id="dealerAccountEdit-receiverName"
  28. :maxLength="30"
  29. v-model.trim="form.receiverName"
  30. placeholder="请输入收货客户名称"
  31. allowClear />
  32. </a-form-model-item>
  33. <a-form-model-item label="发货编号" prop="sendNo">
  34. <a-input
  35. id="dealerAccountEdit-phone"
  36. :maxLength="10"
  37. v-model.trim="form.sendNo"
  38. placeholder="请输入发货编号"
  39. allowClear />
  40. <div style="height: 24px;line-height: normal;">
  41. 常用:<a-button size="small" v-for="i in 5" @click="setSendNo(i)" type="link">{{ i }}</a-button>
  42. </div>
  43. </a-form-model-item>
  44. <a-form-model-item label="备货打印" prop="printState">
  45. <a-radio-group v-model="form.printState">
  46. <a-radio value="NO_PRINT">
  47. 允许打印
  48. </a-radio>
  49. <a-radio value="UNABLE_PRINT">
  50. 暂不打印
  51. </a-radio>
  52. <a-radio value="CANCEL_PRINT">
  53. 取消打印
  54. </a-radio>
  55. </a-radio-group>
  56. </a-form-model-item>
  57. </a-form-model>
  58. <div class="btn-cont">
  59. <a-button type="primary" id="dealerAccountEdit-save" @click="handleSave">确定</a-button>
  60. <a-button id="dealerAccountEdit-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  61. </div>
  62. </a-spin>
  63. </div>
  64. </a-modal>
  65. </template>
  66. <script>
  67. import { commonMixin } from '@/utils/mixin'
  68. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  69. export default {
  70. name: 'DealerAccountEditModal',
  71. mixins: [commonMixin],
  72. components: { dealerSubareaScopeList },
  73. props: {
  74. openModal: { // 弹框显示状态
  75. type: Boolean,
  76. default: false
  77. },
  78. dealerLevel: {
  79. type: String,
  80. default: ''
  81. }
  82. },
  83. data () {
  84. return {
  85. isShow: this.openModal, // 是否打开弹框
  86. spinning: false,
  87. formItemLayout: {
  88. labelCol: { span: 4 },
  89. wrapperCol: { span: 18 }
  90. },
  91. form: {
  92. sendNo: '',
  93. printState: '',
  94. receiverSn: '',
  95. receiverName: ''
  96. },
  97. rules: {
  98. sendNo: [{ required: true, message: '请输入发货编号', trigger: 'change' }],
  99. printState: [{ required: true, message: '请选择备货打印', trigger: 'change' }]
  100. },
  101. detailData: null // 详情数据
  102. }
  103. },
  104. methods: {
  105. setSendNo (i) {
  106. this.form.sendNo = i
  107. this.$refs.ruleForm.validateField('sendNo')
  108. },
  109. custChange (val) {
  110. this.form.receiverSn = val.key || ''
  111. this.form.receiverName = val.name || ''
  112. },
  113. // 保存
  114. handleSave () {
  115. const _this = this
  116. _this.$refs.ruleForm.validate(valid => {
  117. if (valid) {
  118. const formData = JSON.parse(JSON.stringify(_this.form))
  119. _this.$emit('ok', formData)
  120. } else {
  121. return false
  122. }
  123. })
  124. },
  125. // 获取详情
  126. setDetail (data) {
  127. this.detailData = data
  128. },
  129. // 重置表单
  130. resetForm () {
  131. this.detailData = null
  132. this.$refs.ruleForm.resetFields()
  133. this.form = {
  134. sendNo: '',
  135. printState: '',
  136. receiverSn: '',
  137. receiverName: ''
  138. }
  139. this.$refs.custList.resetForm()
  140. }
  141. },
  142. watch: {
  143. // 父页面传过来的弹框状态
  144. openModal (newValue, oldValue) {
  145. this.isShow = newValue
  146. },
  147. // 重定义的弹框状态
  148. isShow (newValue, oldValue) {
  149. if (!newValue) {
  150. this.$emit('close')
  151. this.resetForm()
  152. }
  153. },
  154. itemId (newValue, oldValue) {
  155. if (this.isShow && newValue) {
  156. this.getDetail()
  157. }
  158. }
  159. }
  160. }
  161. </script>
  162. <style lang="less">
  163. .dealerAccountEdit-modal{
  164. .ant-modal-body {
  165. padding: 40px 40px 24px;
  166. }
  167. .btn-cont {
  168. text-align: center;
  169. margin: 35px 0 10px;
  170. }
  171. }
  172. </style>