baseModal.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. <template>
  2. <a-modal
  3. v-model="opened"
  4. :title="title"
  5. centered
  6. :maskClosable="false"
  7. :confirmLoading="confirmLoading"
  8. :width="560"
  9. :footer="null"
  10. @cancel="cancel"
  11. >
  12. <a-spin :spinning="spinning" tip="Loading...">
  13. <a-form-model
  14. id="chooseCustom-form"
  15. ref="ruleForm"
  16. :model="form"
  17. :rules="rules"
  18. :label-col="formItemLayout.labelCol"
  19. :wrapper-col="formItemLayout.wrapperCol"
  20. >
  21. <a-row :gutter="15">
  22. <a-col :span="20">
  23. <a-form-model-item label="业务单号" prop="bizNo">
  24. <a-input
  25. id="base-bizNo"
  26. :disabled="bizSn"
  27. v-model.trim="form.bizNo"
  28. @change="fetchUser"
  29. allowClear
  30. placeholder="请输入业务单号"/>
  31. </a-form-model-item>
  32. </a-col>
  33. </a-row>
  34. <a-row :gutter="15">
  35. <a-col :span="20">
  36. <a-form-model-item label="客户名称" prop="dealerSn">
  37. {{ dealerData&&dealerData.dealerName||'--' }}
  38. </a-form-model-item>
  39. </a-col>
  40. </a-row>
  41. <a-row :gutter="15">
  42. <a-col :span="20">
  43. <a-form-model-item label="运费、服务费" prop="tireSubsidyYfFwf">
  44. <a-radio-group name="radioGroup" v-model="form.tireSubsidyYfFwf">
  45. <a-radio value="1">剔除</a-radio>
  46. <a-radio value="0">不剔除</a-radio>
  47. </a-radio-group>
  48. </a-form-model-item>
  49. </a-col>
  50. </a-row>
  51. <a-row :gutter="15">
  52. <a-col :span="20">
  53. <a-form-model-item label="增量补贴" prop="tireSubsidyZl">
  54. <a-radio-group name="radioGroup1" v-model="form.tireSubsidyZl">
  55. <a-radio value="1">剔除</a-radio>
  56. <a-radio value="0">不剔除</a-radio>
  57. </a-radio-group>
  58. </a-form-model-item>
  59. </a-col>
  60. </a-row>
  61. <a-row :gutter="15">
  62. <a-col :span="20">
  63. <a-form-model-item label="供应商返利" prop="tireSubsidyGc">
  64. <a-radio-group name="radioGroup2" v-model="form.tireSubsidyGc">
  65. <a-radio value="1">剔除</a-radio>
  66. <a-radio value="0">不剔除</a-radio>
  67. </a-radio-group>
  68. </a-form-model-item>
  69. </a-col>
  70. </a-row>
  71. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;">
  72. <a-button @click="cancel" style="margin-right: 15px" id="chooseCustom-btn-back">取消</a-button>
  73. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
  74. </a-form-model-item>
  75. </a-form-model>
  76. </a-spin>
  77. </a-modal>
  78. </template>
  79. <script>
  80. import { commonMixin } from '@/utils/mixin'
  81. import { VSelect } from '@/components'
  82. import debounce from 'lodash/debounce'
  83. import warehouse from '@/views/common/chooseWarehouse.js'
  84. import { bizRemoveConfigCreate, bizRemoveConfigModify, bizRemoveConfigDetail, salesReturnDetailByNo } from '@/api/bizRemove'
  85. export default {
  86. name: 'BaseModal',
  87. mixins: [commonMixin],
  88. components: { VSelect, warehouse },
  89. props: {
  90. show: [Boolean]
  91. },
  92. data () {
  93. this.lastFetchId = 0
  94. this.fetchUser = debounce(this.fetchUser, 800)
  95. return {
  96. opened: this.show,
  97. spinning: false,
  98. title: '新增配置',
  99. confirmLoading: false,
  100. formItemLayout: {
  101. labelCol: { span: 8 },
  102. wrapperCol: { span: 16 }
  103. },
  104. form: {
  105. bizNo: '',
  106. dealerSn: undefined,
  107. configType: 'TIRE_SUBSIDY',
  108. bizSn: undefined, // bizsn
  109. tireSubsidyYfFwf: undefined,
  110. tireSubsidyZl: undefined,
  111. tireSubsidyGc: undefined
  112. },
  113. rules: {
  114. bizNo: [{ required: true, message: '请输入业务单号', trigger: ['change', 'blur'] }],
  115. dealerSn: [{ required: true, message: '请选择客户', trigger: ['change', 'blur'] }],
  116. tireSubsidyYfFwf: [{ required: true, message: '请选择', trigger: ['change', 'blur'] }],
  117. tireSubsidyZl: [{ required: true, message: '请选择', trigger: ['change', 'blur'] }],
  118. tireSubsidyGc: [{ required: true, message: '请选择', trigger: ['change', 'blur'] }]
  119. },
  120. fetching: false,
  121. dealerData: null,
  122. bizSn: undefined
  123. }
  124. },
  125. methods: {
  126. fetchUser () {
  127. if (!this.form.bizNo) return
  128. this.lastFetchId += 1
  129. const fetchId = this.lastFetchId
  130. this.dealerData = null
  131. this.spinning = true
  132. this.fetching = true
  133. salesReturnDetailByNo({ bizNo: this.form.bizNo, configType: 'TIRE_SUBSIDY' }).then(res => {
  134. if (fetchId !== this.lastFetchId) {
  135. return
  136. }
  137. if (res.data) {
  138. this.dealerData = res.data
  139. this.form.dealerSn = res.data.dealerSn
  140. this.form.bizSn = res.data.bizSn
  141. } else {
  142. this.dealerData = null
  143. this.form.dealerSn = undefined
  144. this.form.bizSn = undefined
  145. }
  146. this.fetching = false
  147. this.spinning = false
  148. })
  149. },
  150. // 保存
  151. handleSubmit (e) {
  152. e.preventDefault()
  153. const _this = this
  154. this.$refs.ruleForm.validate(valid => {
  155. if (valid) {
  156. // 保存
  157. _this.salesSaveFun()
  158. } else {
  159. return false
  160. }
  161. })
  162. },
  163. // 新建业务单
  164. salesSaveFun () {
  165. const _this = this
  166. const form = this.form
  167. const funs = !this.bizSn ? bizRemoveConfigCreate : bizRemoveConfigModify
  168. _this.spinning = true
  169. funs(form).then(res => {
  170. if (res.status == 200) {
  171. _this.$message.success(res.message)
  172. _this.$emit('ok', res.data)
  173. _this.cancel()
  174. }
  175. _this.spinning = false
  176. })
  177. },
  178. cancel () {
  179. this.opened = false
  180. this.form = {
  181. configType: 'TIRE_SUBSIDY',
  182. bizNo: '',
  183. dealerSn: undefined,
  184. bizSn: undefined, // bizsn
  185. tireSubsidyYfFwf: undefined,
  186. tireSubsidyZl: undefined,
  187. tireSubsidyGc: undefined
  188. }
  189. this.bizSn = undefined
  190. this.dealerData = null
  191. this.$refs.ruleForm.resetFields()
  192. this.$emit('cancel')
  193. },
  194. getDetail () {
  195. bizRemoveConfigDetail({ bizSn: this.bizSn, configType: 'TIRE_SUBSIDY' }).then(res => {
  196. const { bizSn, bizNo, dealerSn, dealerName, tireSubsidyYfFwf, tireSubsidyZl, tireSubsidyGc } = res.data
  197. this.dealerData = { dealerName: dealerName }
  198. this.form = Object.assign(this.form, {
  199. bizNo: bizNo,
  200. dealerSn: dealerSn,
  201. bizSn: bizSn,
  202. tireSubsidyYfFwf: tireSubsidyYfFwf,
  203. tireSubsidyZl: tireSubsidyZl,
  204. tireSubsidyGc: tireSubsidyGc
  205. })
  206. })
  207. },
  208. edit (row) {
  209. if (row && row.bizSn) {
  210. this.title = '编辑配置'
  211. this.bizSn = row.bizSn
  212. this.getDetail()
  213. } else {
  214. this.title = '新增配置'
  215. this.bizSn = undefined
  216. }
  217. }
  218. },
  219. watch: {
  220. show (newValue, oldValue) {
  221. this.opened = newValue
  222. }
  223. }
  224. }
  225. </script>