sendProductsModal.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <template>
  2. <a-modal
  3. centered
  4. class="promotionList-basicInfo-modal"
  5. :footer="null"
  6. :maskClosable="false"
  7. title="规则设置"
  8. v-model="isShow"
  9. @cancel="isShow=false"
  10. width="70%">
  11. <a-spin :spinning="spinning" tip="Loading...">
  12. <a-form-model
  13. id="promotionList-basicInfo-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="规则门槛" prop="gateFlag">
  20. <a-radio-group v-model="form.gateFlag" button-style="solid" size="small" @change="changeGateFlag">
  21. <a-radio-button value="1">
  22. </a-radio-button>
  23. <a-radio-button value="0">
  24. </a-radio-button>
  25. </a-radio-group>
  26. <div class="ruleDescList" v-if="form.gateFlag && form.gateFlag === '1'">
  27. 购买满
  28. <a-input-number v-model="form.gateAmount" :min="0" :precision="2" size="small"/>
  29. 元门槛产品,可使用
  30. <a-input-number v-model="form.quotaAmount" :min="0" :precision="2" size="small"/>
  31. 元配额,采购规则中的正价商品(配额算销售额)
  32. </div>
  33. </a-form-model-item>
  34. <a-form-model-item label="满赠规则" prop="regularSameFlag">
  35. <div class="ruleDescList">
  36. <a-select default-value="0" :value="form.regularSameFlag" style="width: 100px" size="small">
  37. <a-select-option value="1">
  38. 同款
  39. </a-select-option>
  40. <a-select-option value="0">
  41. 不同款
  42. </a-select-option>
  43. </a-select>
  44. 产品购买满
  45. <a-input-number v-model="form.regularQty" :min="0" :step="1" :precision="0" size="small"/>
  46. 个正价产品,送
  47. <a-input-number v-model="form.promotionQty" :min="0" :step="1" :precision="0" size="small"/>
  48. 个促销产品
  49. </div>
  50. <div class="ruleDescList">
  51. <a-checkbox size="small" :value="form.restrictFlag">
  52. 限制正价产品款数
  53. </a-checkbox>
  54. <a-input-number v-model="form.restrictCategory" :min="0" :step="1" :precision="0" size="small"/>
  55. </div>
  56. </a-form-model-item>
  57. <a-form-model-item label="数量叠加" prop="accrualFlag">
  58. <a-radio-group v-model="form.accrualFlag" button-style="solid" size="small">
  59. <a-radio-button value="1">
  60. </a-radio-button>
  61. <a-radio-button value="0">
  62. </a-radio-button>
  63. </a-radio-group>
  64. <span style="color:gray;">(如:满10送2,数量叠加则:满20送4,满30送6)</span>
  65. </a-form-model-item>
  66. <a-form-model-item prop="minOrderFlag">
  67. <span slot="label">
  68. <a-tooltip title="What do you want others to call you?">
  69. <a-icon type="info-circle" />
  70. </a-tooltip>
  71. 订单起订金额
  72. </span>
  73. <a-select default-value="1" :value="form.minOrderFlag" style="width: 160px" size="small">
  74. <a-select-option value="0">
  75. 不限
  76. </a-select-option>
  77. <a-select-option value="1">
  78. 限制
  79. </a-select-option>
  80. </a-select>
  81. <a-input-number
  82. v-show="form.minOrderFlag && form.minOrderFlag=='1'"
  83. size="small"
  84. style="margin-left:10px;width:300px;"
  85. v-model="form.minOrderAmount"
  86. :min="0"
  87. :step="1"
  88. :precision="2"
  89. placeholder="请输入金额"/>
  90. </a-form-model-item>
  91. <a-form-model-item prop="upperLimitFlag">
  92. <span slot="label">
  93. <a-tooltip title="What do you want others to call you?">
  94. <a-icon type="info-circle" />
  95. </a-tooltip>
  96. 活动经费上限
  97. </span>
  98. <a-select default-value="1" :value="form.upperLimitFlag" style="width: 160px" size="small">
  99. <a-select-option value="0">
  100. 不限
  101. </a-select-option>
  102. <a-select-option value="1">
  103. 限制
  104. </a-select-option>
  105. </a-select>
  106. <a-input-number
  107. v-show="form.upperLimitFlag&&form.upperLimitFlag=='1'"
  108. size="small"
  109. style="margin-left:10px;width:300px;"
  110. v-model="form.upperLimitAmount"
  111. :min="0"
  112. :step="1"
  113. :precision="2"
  114. placeholder="请输入金额"/>
  115. </a-form-model-item>
  116. <a-form-model-item label="促销品与正品一致" prop="regularPromotionSameFlag">
  117. <a-radio-group v-model="form.regularPromotionSameFlag" button-style="solid" size="small">
  118. <a-radio-button value="1">
  119. </a-radio-button>
  120. <a-radio-button value="0">
  121. </a-radio-button>
  122. </a-radio-group>
  123. </a-form-model-item>
  124. </a-form-model>
  125. <a-card size="small" :bordered="false" class="pages-wrap">
  126. <div class="flex">
  127. <a-radio-group v-model="chooseVal" button-style="solid" size="small">
  128. <a-radio-button value="a" v-show="form.gateFlag==='1'">
  129. 门槛产品
  130. </a-radio-button>
  131. <a-radio-button value="b">
  132. 正价产品
  133. </a-radio-button>
  134. <a-radio-button value="c" v-show="form.regularPromotionSameFlag==='0'">
  135. 促销产品
  136. </a-radio-button>
  137. </a-radio-group>
  138. <a-button
  139. size="small"
  140. type="link"
  141. class="button-info"
  142. id="promotionList-edit-btn">+导入产品</a-button>
  143. </div>
  144. <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct" selectType="gateProduct"></tableType1></div>
  145. <div v-show="chooseVal=='b'"><tableType1 ref="normalPriceProduct" selectType="regularProduct"></tableType1></div>
  146. <div v-show="chooseVal=='c'"><tableType2 ref="offerProduct" selectType="specialProductList"></tableType2></div>
  147. </a-card>
  148. <div class="btn-cont">
  149. <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
  150. <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
  151. </div>
  152. </a-spin>
  153. </a-modal>
  154. </template>
  155. <script>
  156. import { commonMixin } from '@/utils/mixin'
  157. import { VSelect } from '@/components'
  158. import tableType1 from './tableType1.vue'
  159. import tableType2 from './tableType2.vue'
  160. import { promotionSave, sparePartsReturnInfo } from '@/api/promotion'
  161. export default {
  162. name: 'PromotionListBasicInfoModal',
  163. mixins: [commonMixin],
  164. components: { VSelect, tableType1, tableType2 },
  165. props: {
  166. openModal: { // 弹框显示状态
  167. type: Boolean,
  168. default: false
  169. },
  170. promotionSn: {
  171. type: [Number, String],
  172. default: ''
  173. }
  174. },
  175. data () {
  176. return {
  177. isShow: this.openModal, // 是否打开弹框
  178. spinning: false,
  179. formItemLayout: {
  180. labelCol: { span: 4 },
  181. wrapperCol: { span: 17 }
  182. },
  183. form: {
  184. promotionRuleType: 'BUY_PROD_GIVE_PROD', // 买产品送产品
  185. gateFlag: '0', // 门槛
  186. gateAmount: '',
  187. quotaAmount: '',
  188. regularSameFlag: '0', // 满赠规则 不同款商品
  189. regularQty: '',
  190. promotionQty: '',
  191. restrictFlag: undefined, // 限制正价产品款数
  192. restrictCategory: '',
  193. accrualFlag: '1', // 数量叠加
  194. minOrderFlag: '1', // 起订金额
  195. minOrderAmount: '',
  196. upperLimitFlag: '1', // 活动经费上限
  197. upperLimitAmount: '',
  198. regularPromotionSameFlag: undefined
  199. },
  200. rules: {
  201. gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
  202. regularSameFlag: [{ required: true, message: '请选择满赠规则', trigger: 'change' }],
  203. accrualFlag: [{ required: true, message: '请选择数量是否叠加', trigger: 'change' }],
  204. minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
  205. upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }],
  206. regularPromotionSameFlag: [{ required: true, message: '请选择促销品与正品是否一致', trigger: 'change' }]
  207. },
  208. chooseVal: 'a'
  209. }
  210. },
  211. methods: {
  212. // 门槛切换 tab 按钮默认显示问题
  213. changeGateFlag (e) {
  214. if (this.chooseVal != 'c') {
  215. if (e.target.value == '0') {
  216. this.chooseVal = 'b'
  217. } else {
  218. this.chooseVal = 'a'
  219. }
  220. }
  221. },
  222. // 保存
  223. handleSave () {
  224. const _this = this
  225. const tableData = this.$refs.cillProduct.getResultVal()
  226. const newtableData = this.$refs.normalPriceProduct.getResultVal()
  227. const newtableData1 = this.$refs.offerProduct.getResultVal()
  228. debugger
  229. this.$refs.ruleForm.validate(valid => {
  230. if (valid) {
  231. const form = JSON.parse(JSON.stringify(_this.form))
  232. form.attachmentList = _this.attachList
  233. _this.spinning = true
  234. promotionSave(form).then(res => {
  235. if (res.status == 200) {
  236. _this.$message.success(res.message)
  237. setTimeout(() => {
  238. _this.isShow = false
  239. _this.$emit('ok', res.data)
  240. _this.spinning = false
  241. }, 1000)
  242. } else {
  243. _this.spinning = false
  244. }
  245. })
  246. } else {
  247. return false
  248. }
  249. })
  250. },
  251. // 获取编辑详情
  252. getDetail () {
  253. sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
  254. if (res.status == 200) {
  255. const resultObj = res.data
  256. this.attachList = resultObj.attachmentList
  257. const obj = {
  258. supplierSn: resultObj.supplierSn,
  259. returnReason: resultObj.returnReason, // 退货原因
  260. explainInfo: resultObj.explainInfo, // 补充说明
  261. warehouseSn: resultObj.warehouseSn,
  262. sparePartsReturnSn: this.itemSn
  263. }
  264. this.$nextTick(() => {
  265. this.$refs.attachList.setFileList(this.attachList)
  266. })
  267. this.form = { ...this.form, ...obj }
  268. } else {
  269. this.detailsData = null
  270. }
  271. })
  272. }
  273. },
  274. watch: {
  275. // 父页面传过来的弹框状态
  276. openModal (newValue, oldValue) {
  277. this.isShow = newValue
  278. },
  279. // 重定义的弹框状态
  280. isShow (newValue, oldValue) {
  281. if (!newValue) {
  282. this.$emit('close')
  283. this.attachList = []
  284. this.supplierName = null
  285. this.$nextTick(() => {
  286. this.$refs.attachList.setFileList('')
  287. this.$refs.ruleForm.resetFields()
  288. })
  289. } else {
  290. if (this.itemSn) {
  291. this.getDetail()
  292. } else {
  293. this.chooseVal = this.form.gateFlag == '0' ? 'b' : 'a'
  294. }
  295. }
  296. }
  297. }
  298. }
  299. </script>
  300. <style lang="less" scoped>
  301. .promotionList-basicInfo-modal{
  302. /deep/.ant-modal-body {
  303. padding: 40px 40px 24px;
  304. max-height: 745px !important;
  305. overflow-y: scroll !important;
  306. }
  307. .ant-radio-button-wrapper{
  308. width:80px;
  309. text-align: center;
  310. }
  311. .ant-form-item{
  312. margin-bottom:5px;
  313. }
  314. .buyerBox{
  315. border:1px solid #d9d9d9;margin-top:10px;border-radius:4px;padding:4px 10px;background:#f2f2f2;max-height:130px;overflow-y:scroll;
  316. }
  317. .btn-cont {
  318. text-align: center;
  319. margin: 35px 0 10px;
  320. }
  321. .flex{
  322. display:flex;
  323. align-items:center;
  324. justify-content:space-between;
  325. }
  326. }
  327. </style>