baseModal.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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="tireSubsidyYf">
  44. <a-radio-group name="radioGroup" v-model="form.tireSubsidyYf">
  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="tireSubsidyFwf">
  54. <a-radio-group name="radioGroup" v-model="form.tireSubsidyFwf">
  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="tireSubsidyZl">
  64. <a-radio-group name="radioGroup1" v-model="form.tireSubsidyZl">
  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-row :gutter="15">
  72. <a-col :span="20">
  73. <a-form-model-item label="供应商返利" prop="tireSubsidyGc">
  74. <a-radio-group name="radioGroup2" v-model="form.tireSubsidyGc">
  75. <a-radio value="1">剔除</a-radio>
  76. <a-radio value="0">不剔除</a-radio>
  77. </a-radio-group>
  78. </a-form-model-item>
  79. </a-col>
  80. </a-row>
  81. <a-form-model-item :wrapper-col="{ span: 12, offset: 6 }" style="text-align: center;">
  82. <a-button @click="cancel" style="margin-right: 15px" id="chooseCustom-btn-back">取消</a-button>
  83. <a-button type="primary" :loading="confirmLoading" @click="handleSubmit" id="chooseCustom-btn-submit">保存</a-button>
  84. </a-form-model-item>
  85. </a-form-model>
  86. </a-spin>
  87. </a-modal>
  88. </template>
  89. <script>
  90. import { commonMixin } from '@/utils/mixin'
  91. import { VSelect } from '@/components'
  92. import debounce from 'lodash/debounce'
  93. import warehouse from '@/views/common/chooseWarehouse.js'
  94. import { bizRemoveConfigCreate, bizRemoveConfigModify, bizRemoveConfigDetail, salesReturnDetailByNo } from '@/api/bizRemove'
  95. export default {
  96. name: 'BaseModal',
  97. mixins: [commonMixin],
  98. components: { VSelect, warehouse },
  99. props: {
  100. show: [Boolean]
  101. },
  102. data () {
  103. this.lastFetchId = 0
  104. this.fetchUser = debounce(this.fetchUser, 800)
  105. return {
  106. opened: this.show,
  107. spinning: false,
  108. title: '新增配置',
  109. confirmLoading: false,
  110. formItemLayout: {
  111. labelCol: { span: 8 },
  112. wrapperCol: { span: 16 }
  113. },
  114. form: {
  115. bizNo: '',
  116. dealerSn: undefined,
  117. configType: 'TIRE_SUBSIDY',
  118. bizSn: undefined, // bizsn
  119. tireSubsidyYf: undefined,
  120. tireSubsidyFwf: undefined,
  121. tireSubsidyZl: undefined,
  122. tireSubsidyGc: undefined
  123. },
  124. rules: {
  125. bizNo: [{ required: true, message: '请输入业务单号', trigger: ['change', 'blur'] }],
  126. dealerSn: [{ required: true, message: '请选择客户', trigger: ['change', 'blur'] }],
  127. tireSubsidyYf: [{ required: true, message: '请选择', trigger: ['change', 'blur'] }],
  128. tireSubsidyFwf: [{ required: true, message: '请选择', trigger: ['change', 'blur'] }],
  129. tireSubsidyZl: [{ required: true, message: '请选择', trigger: ['change', 'blur'] }],
  130. tireSubsidyGc: [{ required: true, message: '请选择', trigger: ['change', 'blur'] }]
  131. },
  132. fetching: false,
  133. dealerData: null,
  134. bizSn: undefined
  135. }
  136. },
  137. methods: {
  138. fetchUser () {
  139. if (!this.form.bizNo) return
  140. this.lastFetchId += 1
  141. const fetchId = this.lastFetchId
  142. this.dealerData = null
  143. this.spinning = true
  144. this.fetching = true
  145. salesReturnDetailByNo({ bizNo: this.form.bizNo, configType: 'TIRE_SUBSIDY' }).then(res => {
  146. if (fetchId !== this.lastFetchId) {
  147. return
  148. }
  149. if (res.data) {
  150. this.dealerData = res.data
  151. this.form.dealerSn = res.data.dealerSn
  152. this.form.bizSn = res.data.bizSn
  153. } else {
  154. this.dealerData = null
  155. this.form.dealerSn = undefined
  156. this.form.bizSn = undefined
  157. }
  158. this.fetching = false
  159. this.spinning = false
  160. })
  161. },
  162. // 保存
  163. handleSubmit (e) {
  164. e.preventDefault()
  165. const _this = this
  166. this.$refs.ruleForm.validate(valid => {
  167. if (valid) {
  168. // 保存
  169. _this.salesSaveFun()
  170. } else {
  171. return false
  172. }
  173. })
  174. },
  175. // 新建业务单
  176. salesSaveFun () {
  177. const _this = this
  178. const form = this.form
  179. const funs = !this.bizSn ? bizRemoveConfigCreate : bizRemoveConfigModify
  180. _this.spinning = true
  181. funs(form).then(res => {
  182. if (res.status == 200) {
  183. _this.$message.success(res.message)
  184. _this.$emit('ok', res.data)
  185. _this.cancel()
  186. }
  187. _this.spinning = false
  188. })
  189. },
  190. cancel () {
  191. this.opened = false
  192. this.form = {
  193. configType: 'TIRE_SUBSIDY',
  194. bizNo: '',
  195. dealerSn: undefined,
  196. bizSn: undefined, // bizsn
  197. tireSubsidyYf: undefined,
  198. tireSubsidyFwf: undefined,
  199. tireSubsidyZl: undefined,
  200. tireSubsidyGc: undefined
  201. }
  202. this.bizSn = undefined
  203. this.dealerData = null
  204. this.$refs.ruleForm.resetFields()
  205. this.$emit('cancel')
  206. },
  207. getDetail () {
  208. bizRemoveConfigDetail({ bizSn: this.bizSn, configType: 'TIRE_SUBSIDY' }).then(res => {
  209. const { bizSn, bizNo, dealerSn, dealerName, tireSubsidyYf, tireSubsidyFwf, tireSubsidyZl, tireSubsidyGc } = res.data
  210. this.dealerData = { dealerName: dealerName }
  211. this.form = Object.assign(this.form, {
  212. bizNo: bizNo,
  213. dealerSn: dealerSn,
  214. bizSn: bizSn,
  215. tireSubsidyYf: tireSubsidyYf,
  216. tireSubsidyFwf: tireSubsidyFwf,
  217. tireSubsidyZl: tireSubsidyZl,
  218. tireSubsidyGc: tireSubsidyGc
  219. })
  220. })
  221. },
  222. edit (row) {
  223. if (row && row.bizSn) {
  224. this.title = '编辑配置'
  225. this.bizSn = row.bizSn
  226. this.getDetail()
  227. } else {
  228. this.title = '新增配置'
  229. this.bizSn = undefined
  230. }
  231. }
  232. },
  233. watch: {
  234. show (newValue, oldValue) {
  235. this.opened = newValue
  236. }
  237. }
  238. }
  239. </script>