specialOfferModal.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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">
  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">
  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 prop="minOrderFlag">
  35. <span slot="label">
  36. <a-tooltip title="What do you want others to call you?">
  37. <a-icon type="info-circle" />
  38. </a-tooltip>
  39. 订单起订金额
  40. </span>
  41. <a-select default-value="1" :value="form.minOrderFlag" style="width: 160px" size="small">
  42. <a-select-option value="0">
  43. 不限
  44. </a-select-option>
  45. <a-select-option value="1">
  46. 限制
  47. </a-select-option>
  48. </a-select>
  49. <a-input-number
  50. v-show="form.minOrderFlag && form.minOrderFlag=='1'"
  51. size="small"
  52. style="margin-left:10px;width:300px;"
  53. v-model="form.minOrderAmount"
  54. :min="0"
  55. :step="1"
  56. :precision="2"
  57. placeholder="请输入金额"/>
  58. </a-form-model-item>
  59. <a-form-model-item prop="upperLimitFlag">
  60. <span slot="label">
  61. <a-tooltip title="What do you want others to call you?">
  62. <a-icon type="info-circle" />
  63. </a-tooltip>
  64. 活动经费上限
  65. </span>
  66. <a-select default-value="1" :value="form.upperLimitFlag" style="width: 160px" size="small">
  67. <a-select-option value="0">
  68. 不限
  69. </a-select-option>
  70. <a-select-option value="1">
  71. 限制
  72. </a-select-option>
  73. </a-select>
  74. <a-input-number
  75. v-show="form.upperLimitFlag&&form.upperLimitFlag=='1'"
  76. size="small"
  77. style="margin-left:10px;width:300px;"
  78. v-model="form.upperLimitAmount"
  79. :min="0"
  80. :step="1"
  81. :precision="2"
  82. placeholder="请输入金额"/>
  83. </a-form-model-item>
  84. </a-form-model>
  85. <a-card size="small" :bordered="false" class="pages-wrap">
  86. <div class="flex">
  87. <a-radio-group v-model="chooseVal" button-style="solid" size="small">
  88. <a-radio-button value="a" v-show="form.gateFlag==='1'">
  89. 门槛产品
  90. </a-radio-button>
  91. <a-radio-button value="c">
  92. 促销产品
  93. </a-radio-button>
  94. </a-radio-group>
  95. <div>
  96. <a-button
  97. size="small"
  98. type="link"
  99. class="button-info"
  100. id="promotionList-edit-btn">+导入产品</a-button>
  101. <a-button
  102. style="margin-left:10px;"
  103. size="small"
  104. type="link"
  105. class="button-error"
  106. id="promotionList-edit-btn">+新增产品</a-button>
  107. </div>
  108. </div>
  109. <div v-show="chooseVal=='a'"><tableType1 ref="cillProduct" selectType="gateProduct"></tableType1></div>
  110. <div v-show="chooseVal=='c'"> <tableType3></tableType3></div>
  111. </a-card>
  112. <div class="btn-cont">
  113. <a-button id="promotionList-basicInfo-modal-back" @click="isShow = false">取消</a-button>
  114. <a-button style="margin-left: 15px;" type="primary" id="promotionList-modal-save" @click="handleSave">确定</a-button>
  115. </div>
  116. </a-spin>
  117. </a-modal>
  118. </template>
  119. <script>
  120. import { commonMixin } from '@/utils/mixin'
  121. import { VSelect } from '@/components'
  122. import tableType1 from './tableType1.vue'
  123. import tableType3 from './tableType3.vue'
  124. import { sparePartsReturnSave, sparePartsReturnInfo } from '@/api/sparePartsReturn'
  125. export default {
  126. name: 'PromotionListBasicInfoModal',
  127. mixins: [commonMixin],
  128. components: { VSelect, tableType1, tableType3 },
  129. props: {
  130. openModal: { // 弹框显示状态
  131. type: Boolean,
  132. default: false
  133. },
  134. itemSn: {
  135. type: [Number, String],
  136. default: ''
  137. }
  138. },
  139. data () {
  140. return {
  141. isShow: this.openModal, // 是否打开弹框
  142. spinning: false,
  143. formItemLayout: {
  144. labelCol: { span: 4 },
  145. wrapperCol: { span: 17 }
  146. },
  147. form: {
  148. promotionRuleType: 'PROMO_PROD', // 特价产品
  149. gateFlag: '0', // 门槛
  150. gateAmount: '',
  151. quotaAmount: '',
  152. minOrderFlag: '1', // 起订金额
  153. minOrderAmount: '',
  154. upperLimitFlag: '1', // 活动经费上限
  155. upperLimitAmount: ''
  156. },
  157. rules: {
  158. gateFlag: [ { required: true, message: '请选择规则门槛', trigger: 'change' } ],
  159. minOrderFlag: [{ required: true, message: '请选择订单起订金额', trigger: 'change' }],
  160. upperLimitFlag: [{ required: true, message: '请选择活动经费上限', trigger: 'change' }]
  161. },
  162. chooseVal: 'a'
  163. }
  164. },
  165. methods: {
  166. // 附件上传
  167. changeAttach (file) {
  168. this.attachList = JSON.parse(file)
  169. this.attachList.map(item => {
  170. item.fileType = item.extName
  171. })
  172. },
  173. // 选择参与客户
  174. handleDealerModal () {
  175. this.openDealerModal = true
  176. const _this = this
  177. if (_this.chooseDealerList.length == 0) {
  178. _this.form.promoBuyerList = []
  179. }
  180. const arr = _this.chooseDealerList.map(item => {
  181. return item.buyerSn
  182. })
  183. // 选择经销商回显
  184. _this.$nextTick(() => {
  185. _this.$refs.dealerChoose.pageInit(arr)
  186. })
  187. },
  188. // 添加经销商
  189. handleAddDealer (list) {
  190. this.chooseDealerList = list.map(con => {
  191. return {
  192. buyerSn: con.dealerSn,
  193. buyerName: con.dealerName
  194. }
  195. })
  196. this.openDealerModal = false
  197. // 移除表单必填项
  198. this.$refs.ruleForm.clearValidate('promoBuyerList')
  199. },
  200. // 保存
  201. handleSave () {
  202. const _this = this
  203. this.$refs.ruleForm.validate(valid => {
  204. if (valid) {
  205. const form = JSON.parse(JSON.stringify(_this.form))
  206. form.attachmentList = _this.attachList
  207. _this.spinning = true
  208. sparePartsReturnSave(form).then(res => {
  209. if (res.status == 200) {
  210. _this.$message.success(res.message)
  211. setTimeout(() => {
  212. _this.isShow = false
  213. _this.$emit('ok', res.data)
  214. _this.spinning = false
  215. }, 1000)
  216. } else {
  217. _this.spinning = false
  218. }
  219. })
  220. } else {
  221. return false
  222. }
  223. })
  224. },
  225. // 获取编辑详情
  226. getDetail () {
  227. sparePartsReturnInfo({ sn: this.itemSn }).then(res => {
  228. if (res.status == 200) {
  229. const resultObj = res.data
  230. this.attachList = resultObj.attachmentList
  231. const obj = {
  232. supplierSn: resultObj.supplierSn,
  233. returnReason: resultObj.returnReason, // 退货原因
  234. explainInfo: resultObj.explainInfo, // 补充说明
  235. warehouseSn: resultObj.warehouseSn,
  236. sparePartsReturnSn: this.itemSn
  237. }
  238. this.$nextTick(() => {
  239. this.$refs.attachList.setFileList(this.attachList)
  240. })
  241. this.form = { ...this.form, ...obj }
  242. } else {
  243. this.detailsData = null
  244. }
  245. })
  246. },
  247. // 不可选日期
  248. disabledDate (date, dateStrings) {
  249. return date && date.valueOf('day') < moment().subtract(1, 'day') // 今天以后,包含今天
  250. }
  251. },
  252. watch: {
  253. // 父页面传过来的弹框状态
  254. openModal (newValue, oldValue) {
  255. this.isShow = newValue
  256. },
  257. // 重定义的弹框状态
  258. isShow (newValue, oldValue) {
  259. if (!newValue) {
  260. this.$emit('close')
  261. this.attachList = []
  262. this.supplierName = null
  263. this.$nextTick(() => {
  264. this.$refs.attachList.setFileList('')
  265. this.$refs.ruleForm.resetFields()
  266. })
  267. } else {
  268. if (this.itemSn) {
  269. this.getDetail()
  270. } else {
  271. this.chooseVal = this.form.gateFlag == '0' ? 'c' : 'a'
  272. }
  273. }
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="less" scoped>
  279. .promotionList-basicInfo-modal{
  280. /deep/.ant-modal-body {
  281. padding: 40px 40px 24px;
  282. max-height: 745px !important;
  283. overflow-y: scroll !important;
  284. }
  285. .ant-radio-button-wrapper{
  286. width:80px;
  287. text-align: center;
  288. }
  289. .ant-form-item{
  290. margin-bottom:5px;
  291. }
  292. .buyerBox{
  293. border:1px solid #d9d9d9;margin-top:10px;border-radius:4px;padding:4px 10px;background:#f2f2f2;max-height:130px;overflow-y:scroll;
  294. }
  295. .btn-cont {
  296. text-align: center;
  297. margin: 35px 0 10px;
  298. }
  299. .flex{
  300. display:flex;
  301. align-items:center;
  302. justify-content:space-between;
  303. }
  304. }
  305. </style>