dsModal.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template>
  2. <a-modal
  3. centered
  4. class="transferOutDs-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="transferOutDs-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 id="transferOutDs-custList" 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="transferOutDs-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="transferOutDs-sendNo"
  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="发货说明">
  45. <a-input
  46. id="transferOutDs-explainInfo"
  47. type="textarea"
  48. :maxLength="500"
  49. v-model.trim="form.explainInfo"
  50. placeholder="请输入发货说明(最多500个字符)"/>
  51. </a-form-model-item>
  52. <a-form-model-item label="备货打印" prop="printState" v-if="showPrint">
  53. <a-radio-group id="transferOutDs-printState" v-model="form.printState">
  54. <a-radio value="NO_PRINT" id="transferOutDs-printState1">
  55. 允许打印
  56. </a-radio>
  57. <a-radio value="UNABLE_PRINT" id="transferOutDs-printState2">
  58. 暂不打印
  59. </a-radio>
  60. <a-radio value="CANCEL_PRINT" id="transferOutDs-printState3">
  61. 取消打印
  62. </a-radio>
  63. </a-radio-group>
  64. </a-form-model-item>
  65. </a-form-model>
  66. <div class="btn-cont">
  67. <a-button type="primary" id="transferOutDs-save" @click="handleSave">确定</a-button>
  68. <a-button id="transferOutDs-back" @click="isShow = false" style="margin-left: 15px;">取消</a-button>
  69. </div>
  70. </a-spin>
  71. </div>
  72. </a-modal>
  73. </template>
  74. <script>
  75. import { commonMixin } from '@/utils/mixin'
  76. // 组件
  77. import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
  78. export default {
  79. name: 'TransferOutDsModal',
  80. mixins: [commonMixin],
  81. components: { dealerSubareaScopeList },
  82. props: {
  83. openModal: { // 弹框显示状态
  84. type: Boolean,
  85. default: false
  86. },
  87. dealerLevel: {
  88. type: String,
  89. default: ''
  90. }
  91. },
  92. data () {
  93. return {
  94. isShow: this.openModal, // 是否打开弹框
  95. spinning: false,
  96. // form表单label布局
  97. formItemLayout: {
  98. labelCol: { span: 4 },
  99. wrapperCol: { span: 18 }
  100. },
  101. // 提交参数
  102. form: {
  103. sendNo: '', // 发货编号
  104. printState: '', // 备货打印状态
  105. receiverSn: '', // 收货客户sn
  106. receiverName: '', // 收货客户名称
  107. explainInfo: ''// 发货说明
  108. },
  109. // 表单验证规则
  110. rules: {
  111. sendNo: [{ required: true, message: '请输入发货编号', trigger: 'change' }],
  112. printState: [{ required: true, message: '请选择备货打印', trigger: 'change' }]
  113. },
  114. detailData: null, // 详情数据
  115. showPrint: false
  116. }
  117. },
  118. methods: {
  119. // 初始化
  120. pageInit (data) {
  121. this.showPrint = !data.sendNo
  122. this.form.sendNo = data.sendNo
  123. this.form.printState = this.showPrint ? data.printState : undefined
  124. this.form.receiverSn = data.receiverSn
  125. this.form.receiverName = data.receiverName
  126. this.form.explainInfo = data.explainInfo
  127. },
  128. // 弹框关闭
  129. handleCancel () {
  130. this.isShow = false
  131. },
  132. // 获取常用发货编号
  133. setSendNo (i) {
  134. this.form.sendNo = i
  135. this.$refs.ruleForm.validateField('sendNo')
  136. },
  137. // 收货客户名称
  138. custChange (val) {
  139. this.form.receiverSn = val.key || ''
  140. this.form.receiverName = val.name || ''
  141. },
  142. // 保存
  143. handleSave () {
  144. const _this = this
  145. _this.$refs.ruleForm.validate(valid => {
  146. if (valid) {
  147. const formData = JSON.parse(JSON.stringify(_this.form))
  148. _this.$emit('ok', formData)
  149. } else {
  150. return false
  151. }
  152. })
  153. },
  154. // 获取详情
  155. setDetail (data) {
  156. this.detailData = data
  157. },
  158. // 重置表单
  159. resetForm () {
  160. this.detailData = null
  161. this.$refs.ruleForm.resetFields()
  162. this.form = {
  163. sendNo: '',
  164. printState: '',
  165. receiverSn: '',
  166. receiverName: ''
  167. }
  168. this.$refs.custList.resetForm()
  169. }
  170. },
  171. watch: {
  172. // 父页面传过来的弹框状态
  173. openModal (newValue, oldValue) {
  174. this.isShow = newValue
  175. },
  176. // 重定义的弹框状态
  177. isShow (newValue, oldValue) {
  178. if (!newValue) {
  179. this.$emit('close')
  180. this.resetForm()
  181. } else {
  182. if (this.form.receiverName && this.dealerLevel != 'OTHER') {
  183. this.$nextTick(() => {
  184. this.$refs.custList.setDufaultVal(this.form.receiverName)
  185. })
  186. }
  187. }
  188. }
  189. }
  190. }
  191. </script>
  192. <style lang="less">
  193. .transferOutDs-modal{
  194. .ant-modal-body {
  195. padding: 40px 40px 24px;
  196. }
  197. .btn-cont {
  198. text-align: center;
  199. margin: 35px 0 10px;
  200. }
  201. }
  202. </style>