edit.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768
  1. <template>
  2. <div class="promotionEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="promotionEdit-cont" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="promotionEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" />返回列表</a>
  8. <span v-if="$route.params.sn" style="margin: 0 10px 0 20px;color: #666;font-size: 14px;font-weight: 600;">促销名称:{{ promotionName||'--' }}</span>
  9. </template>
  10. </a-page-header>
  11. <!-- 表单 -->
  12. <a-card :bordered="false" class="promotionEdit-cont">
  13. <a-form-model
  14. id="promotionEdit-form"
  15. ref="ruleForm"
  16. :model="form"
  17. :rules="rules"
  18. :label-col="formItemLayout.labelCol"
  19. :wrapper-col="formItemLayout.wrapperCol"
  20. >
  21. <a-row>
  22. <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
  23. <a-form-model-item label="促销名称" prop="promoName" :label-col="{span:4}" :wrapper-col="{span:16}">
  24. <a-input
  25. id="promotionEdit-promoName"
  26. :maxLength="20"
  27. v-model.trim="form.promoName"
  28. placeholder="请输入促销名称(最多20个字符)"
  29. allowClear/>
  30. </a-form-model-item>
  31. </a-col>
  32. <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
  33. <a-form-model-item label="促销时间" prop="time" :label-col="{span:4}" :wrapper-col="{span:16}">
  34. <a-range-picker
  35. style="width:100%"
  36. id="promotionAdd-time"
  37. v-model="form.time"
  38. :format="dateFormat"
  39. :disabled-date="disabledDate"
  40. @change="dateChange"
  41. :placeholder="['开始时间', '结束时间']" />
  42. </a-form-model-item>
  43. </a-col>
  44. <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
  45. <a-form-model-item label="排序" prop="sort" :label-col="{span:4}" :wrapper-col="{span:16}">
  46. <a-input-number
  47. style="width:100%"
  48. id="promotionEdit-sort"
  49. :disabled="isDisabled"
  50. allowClear
  51. placeholder="请输入排序数字(数字越大越靠后)"
  52. v-model="form.sort"
  53. :min="0"
  54. :max="99999999"/>
  55. </a-form-model-item>
  56. </a-col>
  57. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  58. <a-form-model-item label="参与经销商" prop="allDealerFlag">
  59. <a-row :gutter="15">
  60. <a-col :md="10" :sm="24">
  61. <a-select
  62. style="width:98%;"
  63. id="promotionList-allDealerFlag"
  64. v-model="form.allDealerFlag"
  65. placeholder="请选择参与经销商"
  66. @change="changeDealerScope"
  67. :disabled="true"
  68. allowClear>
  69. <a-select-option id="promotionList-dealerScope-all" value="1">全部经销商</a-select-option>
  70. <a-select-option id="promotionList-dealerScope-some" value="0">部分经销商</a-select-option>
  71. </a-select>
  72. </a-col>
  73. <a-col :md="3" :sm="24" v-show="form.dealerScope && form.dealerScope!='ALL_DEALER' ">
  74. <a-button id="promotionList-basicInfo-dealerScope" type="primary" :loading="spinning" @click="handleDealerModal">选择</a-button>
  75. </a-col>
  76. <a-col :md="5" :sm="24" v-show="chooseDealerList && chooseDealerList.length>0">
  77. 已{{ chooseDealerList.length }}选项
  78. </a-col>
  79. <a-col :md="24" :sm="24" v-show="chooseDealerList && chooseDealerList.length>0">
  80. <div class="buyerBox">
  81. <a-tag closable v-for="con in chooseDealerList" id="promotionList-dealerSn" :key="con.dealerSn" @close="delBuyerName(con)">
  82. {{ con.dealerName }}
  83. </a-tag>
  84. </div>
  85. </a-col>
  86. </a-row>
  87. </a-form-model-item>
  88. </a-col>
  89. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  90. <a-form-model-item label="封面图片" prop="imageUrl" class="promotionEdit-img">
  91. <Upload
  92. class="upload"
  93. id="promotionEdit-imageUrl"
  94. v-model="form.imageUrl"
  95. ref="imageSet"
  96. :fileSize="10"
  97. :maxNums="1"
  98. @change="changeImage"
  99. listType="picture-card"></Upload>
  100. <span class="upload-desc">说明:单张大小小于10Mb;建议尺寸:宽(420px)*高(230px)</span>
  101. </a-form-model-item>
  102. </a-col>
  103. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  104. <a-form-model-item label="促销描述" prop="description">
  105. <a-input
  106. v-model="form.description"
  107. :disabled="isDisabled"
  108. type="textarea"
  109. id="promotionEdit-description"
  110. placeholder="请输入促销描述(最多500个字符)"
  111. :maxLength="500" />
  112. </a-form-model-item>
  113. </a-col>
  114. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  115. <a-form-model-item label="加盟商开关权限" prop="dealerOpenFlag">
  116. <v-select
  117. v-model="form.dealerOpenFlag"
  118. id="promotion-dealerOpenFlag"
  119. code="FLAG"
  120. showType="radio"
  121. :disabled="true"
  122. allowClear></v-select>
  123. </a-form-model-item>
  124. </a-col>
  125. <!-- 买产品送代金券 -->
  126. <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
  127. <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
  128. <a-form-model-item label="券名称" :label-col="{span:4}" :wrapper-col="{span:16}" prop="validName">
  129. <a-input
  130. id="promotionEdit-validName"
  131. :maxLength="20"
  132. v-model.trim="form.validName"
  133. placeholder="请输入券名称(最多20个字符)"
  134. allowClear />
  135. </a-form-model-item>
  136. </a-col>
  137. <a-col :xs="12" :sm="12" :md="12" :lg="12" :xl="12">
  138. <a-form-model-item label="券副标题" :label-col="{span:4}" :wrapper-col="{span:16}">
  139. <a-input
  140. id="promotionEdit-validTitle"
  141. :maxLength="20"
  142. v-model.trim="form.validTitle"
  143. placeholder="请输入券副标题(最多20个字符)"
  144. allowClear />
  145. </a-form-model-item>
  146. </a-col>
  147. <!-- <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  148. <a-form-model-item label="生成方式" prop="validBaseType">
  149. <v-select
  150. style="width:40%;"
  151. v-model="form.validBaseType"
  152. id="promotionEdit-ruleBaseType"
  153. code="SHOP_PROMO_VALID_BASE_TYPE"
  154. placeholder="请选择生成方式"
  155. allowClear></v-select>
  156. </a-form-model-item>
  157. </a-col> -->
  158. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  159. <a-form-model-item label="券有效期" prop="validType">
  160. <v-select
  161. style="width:40%;"
  162. v-model="form.validType"
  163. placeholder="请选择券有效期"
  164. id="promotionEdit-validType"
  165. code="SHOP_PROMO_VALID_TYPE"
  166. @change="handleValidType"
  167. allowClear></v-select>
  168. <a-range-picker
  169. v-show="form.validType==='FIXED'"
  170. style="width:40%;margin-left:10px;"
  171. v-model="timeLimit"
  172. :format="dateFormat"
  173. id="promotionEdit-time"
  174. @change="dateLimitChange"
  175. :disabled-date="disabledDate"
  176. :placeholder="['开始时间', '结束时间']" />
  177. <span style="width:40%;margin-left:10px;" v-show="form.validType==='LIMIT'">
  178. 有效期<a-input-number
  179. style="margin:0 5px;"
  180. v-model="form.validDays"
  181. :step="1"
  182. id="promotionEdit-validDays"
  183. :max="99999999"
  184. :min="1"
  185. :precision="0"/>天
  186. </span>
  187. </a-form-model-item>
  188. </a-col>
  189. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  190. <a-form-model-item class="productName" label="券适用范围" prop="validScope">
  191. 全部产品
  192. </a-form-model-item>
  193. </a-col>
  194. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  195. <a-form-model-item label="使用说明" prop="validInfo">
  196. <a-input
  197. v-model="form.validInfo"
  198. type="textarea"
  199. id="promotionEdit-validInfo"
  200. placeholder="请输入使用说明(最多50个字符)"
  201. :maxLength="50" />
  202. </a-form-model-item>
  203. </a-col>
  204. </div>
  205. <div v-if="isShowNextStep">
  206. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  207. <a-form-model-item prop="productNum" :label="pageType==='BUY_PROD_GIVE_PROD'?'满赠规则': pageType==='PROMO_PROD'?'优惠方式':'返券产品'">
  208. <div class="productInfo flex-center">
  209. <!-- 买产品送产品 -->
  210. <div v-if="pageType==='BUY_PROD_GIVE_PROD'">
  211. 同款产品买<a-input-number
  212. v-model="conditionValue"
  213. style="margin:0 5px;"
  214. :min="1"
  215. :step="1"
  216. :precision="0"
  217. :max="99999999"
  218. id="promotionEdit-conditionValue"
  219. size="small"/>赠
  220. <a-input-number
  221. v-model="resultValue"
  222. style="margin:0 5px;"
  223. :min="0"
  224. :step="1"
  225. :precision="0"
  226. :max="99999999"
  227. id="promotionEdit-resultValue"
  228. size="small"/>个(数量叠加)
  229. <a-button
  230. type="primary"
  231. id="promotionEdit-addSet-btn"
  232. class="button-primary"
  233. size="small"
  234. @click="handleBatchAdd">批量设置</a-button>
  235. </div>
  236. <!-- 特价产品 -->
  237. <div v-if="pageType==='PROMO_PROD'" style="width:80%;">
  238. <v-select
  239. v-model="form.discountType"
  240. ref="promoState"
  241. id="promotionList-discountType"
  242. code="SHOP_PROMO_DISCOUNT_TYPE"
  243. size="small"
  244. style="width:15%;margin-right:5px;"
  245. @change="handleDiscountType"
  246. placeholder="请选择"
  247. allowClear></v-select>
  248. <span>{{ form.discountType==='STRAIGHT_DOWN'? '直降':'折扣' }}</span>
  249. <a-input-number
  250. v-model="resultValue"
  251. style="width:15%;margin:0 5px;"
  252. :min="0"
  253. :step="1"
  254. :precision="2"
  255. :max="99999999"
  256. id="promotionEdit-resultValue"
  257. size="small"/>{{ form.discountType==='STRAIGHT_DOWN'? '元':'%' }}
  258. <a-button
  259. type="primary"
  260. id="promotionEdit-addSet-btn"
  261. class="button-primary"
  262. size="small"
  263. @click="handleBatchAdd">批量设置</a-button>
  264. </div>
  265. <!-- 买产品返代金券 -->
  266. <div v-if="pageType=='BUY_PROD_GIVE_VALID'">
  267. 返券金额
  268. <a-input-number
  269. v-model="resultValue"
  270. style="margin:0 5px;"
  271. :min="0"
  272. :step="1"
  273. :precision="2"
  274. :max="99999999"
  275. id="promotionEdit-resultValue"
  276. size="small"/>元
  277. <a-button
  278. type="primary"
  279. id="promotionEdit-addSet-btn"
  280. :disabled="isDisabled"
  281. class="button-primary"
  282. size="small"
  283. @click="handleBatchAdd">批量设置</a-button>
  284. </div>
  285. <a-button type="primary" id="promotionEdit-add-btn" :disabled="isDisabled" @click="handleAddProduct" size="small">选择产品</a-button>
  286. </div>
  287. </a-form-model-item>
  288. </a-col>
  289. <a-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  290. <div style="width: 83%;margin:0 auto 10px;">
  291. <productTable ref="chooseProductList" :promoActiveSn="form.promoSn" :discountType="form.discountType" :activeType="pageType"></productTable>
  292. </div>
  293. </a-col>
  294. </div>
  295. </a-row>
  296. </a-form-model>
  297. </a-card>
  298. </a-spin>
  299. <div class="affix-cont">
  300. <a-button
  301. type="primary"
  302. class="button-primary"
  303. :disabled="spinning"
  304. id="productInfoEdit-submit-btn"
  305. size="large"
  306. @click="handleSave('all')"
  307. v-if="isShowNextStep"
  308. style="padding: 0 60px;">保存</a-button>
  309. <a-button
  310. type="primary"
  311. class="button-primary"
  312. style="padding: 0 30px;"
  313. size="large"
  314. v-if="!isShowNextStep"
  315. @click="handleSave('part')">保存后设置产品</a-button>
  316. </div>
  317. <!-- 添加产品 -->
  318. <chooseProduct
  319. ref="chooseProduct"
  320. :chooseType="chooseTypeList"
  321. :itemSn="$route.params.sn"
  322. :openModal="showProModal"
  323. @ok="addProductSuccess"
  324. @close="closeProductModal"></chooseProduct>
  325. <!-- 选择经销商 -->
  326. <chooseDealer :openModal="openDealerModal" @close="closeDealerModal" @ok="addDealerOk"></chooseDealer>
  327. </div>
  328. </template>
  329. <script>
  330. import { commonMixin } from '@/utils/mixin'
  331. import moment from 'moment'
  332. // 组件
  333. import { VSelect, Upload } from '@/components'
  334. import Editor from '@/components/WEeditor'
  335. import chooseDealer from '@/views/easyPassManagement/homepageCarouselImg/chooseDealer'
  336. import productTable from './productTable'
  337. import chooseProduct from './chooseProductsModal.vue'
  338. // 接口
  339. import { saveChooseProduct, saveShopPromo, shopPromoDetail } from '@/api/shopPromo'
  340. export default {
  341. name: 'ProductBrandEditModal',
  342. mixins: [commonMixin],
  343. components: { VSelect, Upload, Editor, productTable, chooseDealer, chooseProduct },
  344. data () {
  345. return {
  346. spinning: false,
  347. // 表单 label 设置
  348. formItemLayout: {
  349. labelCol: { span: 2 },
  350. wrapperCol: { span: 20 }
  351. },
  352. productRangeList: [], // 产品范围列表
  353. dateFormat: 'YYYY-MM-DD', // 促销时间显示格式
  354. openDealerModal: false,
  355. pageType: undefined, // 促销类型
  356. // 链接配置内容
  357. form: {
  358. promoType: undefined, // 促销类型
  359. promoName: '', // '促销名称'
  360. time: [], // 促销时间
  361. promoStartDate: undefined, // 促销时间-开始
  362. promoEndDate: undefined, // 促销时间-结束
  363. sort: undefined, // 排序
  364. allDealerFlag: '1', // 全部经销商 1 部分经销商0'
  365. imageUrl: undefined, // 促销封面图
  366. description: '', // '促销描述'
  367. dealerEditFlag: '0', // 加盟商编辑 0否 1是
  368. dealerOpenFlag: '0', // 加盟商开关权限 0否 1是
  369. rangeList: [], // 选择产品列表
  370. discountType: 'STRAIGHT_DOWN', // 特价产品 - 优惠方式'
  371. validName: '', // 券名称
  372. validTitle: '', // 券副标题
  373. validBaseType: 'category', // 券生成方式
  374. validType: undefined, // 券有效期类型
  375. validStartDate: undefined, // 券生效时间
  376. validEndDate: undefined, // 券失效时间
  377. validDays: undefined, // 券有效期天数
  378. validScope: '1', // 券适用范围标记 1-全部 0-指定 死值 1
  379. validInfo: '', // 使用说明
  380. productNum: 0
  381. },
  382. conditionValue: undefined, // 买产品送产品 买
  383. resultValue: undefined, // 买产品送产品 赠 返券金额
  384. chooseDealerList: [], // 所选经销商数据
  385. timeLimit: [], // 有效期
  386. promotionName: '', // 促销名称
  387. showProModal: false, // 打开产品弹窗
  388. isShowNextStep: false, // 是否显示下一步 并提交一半配置产品
  389. isDisabled: false, // 控制页面是否能编辑
  390. chooseTypeList: [], // 已选中产品范围
  391. imageSet: [], // 回显显示图片数据
  392. productTypeList: [], // 产品范围 列表数据
  393. // 表单验证规则
  394. rules: {
  395. promoName: [{ required: true, message: '请输入促销名称', trigger: 'blur' }],
  396. time: [{ required: true, message: '请选择促销时间', trigger: 'change' }],
  397. sort: [{ required: true, message: '请输入排序数字', trigger: 'blur' }],
  398. allDealerFlag: [{ required: true, message: '请选择参与经销商', trigger: 'change' }],
  399. imageUrl: [{ required: true, message: '请选择要上传的封面图片', trigger: 'change' }],
  400. description: [{ required: true, message: '请输入促销描述内容', trigger: 'blur' }],
  401. dealerOpenFlag: [{ required: true, message: '请选择加盟商开关权限', trigger: 'change' }],
  402. rangeList: [{ required: true, message: '请选择促销产品', trigger: 'change' }],
  403. validName: [{ required: true, message: '请输入券名称', trigger: ['change', 'blur'] }],
  404. validBaseType: [{ required: true, message: '请选择生成方式', trigger: 'change' }],
  405. validType: [{ required: true, message: '请选择券有效期类型', trigger: 'change' }],
  406. validScope: [{ required: true, message: '请选择券适用范围', trigger: 'blur' }],
  407. productNum: [{ required: true, message: '选择产品不能为空', trigger: 'blur' }]
  408. }
  409. }
  410. },
  411. methods: {
  412. changeDealerScope () {},
  413. addDealerOk () {},
  414. // 选择经销商
  415. handleDealerModal () {
  416. this.openDealerModal = true
  417. },
  418. // 关闭经销商弹窗
  419. closeDealerModal () {
  420. this.openDealerModal = false
  421. },
  422. // 禁用日期时间
  423. disabledDate (current) {
  424. return current && current < moment().startOf('day')
  425. },
  426. // 促销时间 change
  427. dateChange (date, dateStrings) {
  428. if (dateStrings && dateStrings[0]) {
  429. this.form.time = dateStrings
  430. this.form.promoStartDate = date.length ? dateStrings[0] + ' 00:00:00' : ''
  431. this.form.promoEndDate = date.length ? dateStrings[1] + ' 23:59:59' : ''
  432. } else {
  433. this.form.time = []
  434. }
  435. },
  436. // 有效期
  437. dateLimitChange (date, dateStrings) {
  438. if (dateStrings && dateStrings[0]) {
  439. this.timeLimit = dateStrings
  440. this.form.validStartDate = date.length ? dateStrings[0] + ' 00:00:00' : ''
  441. this.form.validEndDate = date.length ? dateStrings[1] + ' 23:59:59' : ''
  442. } else {
  443. this.timeLimit = []
  444. }
  445. },
  446. // 打开产品弹窗
  447. insterProduct (obj) {
  448. if (obj && Object.keys(obj).length > 0) {
  449. this.chooseTypeList = obj.typeArr
  450. }
  451. this.showProModal = true
  452. },
  453. handleDiscountType (val) {
  454. this.form.discountType = val
  455. this.resultValue = undefined
  456. },
  457. // 关闭产品弹窗
  458. closeProductModal () {
  459. this.showProModal = false
  460. },
  461. // 返回列表
  462. handleBack () {
  463. this.$router.push({ name: 'promotionalActivities', query: { closeLastOldTab: true } })
  464. },
  465. // 详情
  466. async getDetail (ajaxData) {
  467. const _this = this
  468. const res = await shopPromoDetail(ajaxData)
  469. if (res.status == 200) {
  470. if (res.data.promoStartDate && res.data.promoEndDate) {
  471. const startTime = res.data.promoStartDate.split(' ')[0]
  472. const endTime = res.data.promoEndDate.split(' ')[0]
  473. res.data.time = [startTime, endTime]
  474. }
  475. if (res.data.imageUrl) {
  476. _this.$refs.imageSet.setFileList(res.data.imageUrl)
  477. }
  478. _this.form = res.data
  479. _this.form.productNum = 0
  480. _this.isShowNextStep = true
  481. if (_this.$route.params.pageType === 'edit') {
  482. _this.pageType = res.data.promoType
  483. _this.promotionName = res.data.promoName
  484. }
  485. _this.$nextTick(() => {
  486. _this.$refs.chooseProductList.pageInit()
  487. })
  488. _this.form.productNum = _this.$refs.chooseProductList.getChooseProductNum()
  489. }
  490. },
  491. // 券有效期 change
  492. handleValidType (con) {
  493. this.form.validType = con
  494. if (con === 'FIXED') {
  495. this.form.validDays = undefined
  496. } else {
  497. this.timeLimit = []
  498. this.form.validStartDate = undefined
  499. this.form.validEndDate = undefined
  500. }
  501. },
  502. // 确定保存 验证必填
  503. handleSave (type) {
  504. const _this = this
  505. // 验证组件必填项
  506. console.log('_this.form.productNum ', _this.form.productNum)
  507. _this.$refs.ruleForm.validate(valid => {
  508. if (valid) {
  509. _this.savePartInfo(type)
  510. }
  511. })
  512. },
  513. // 保存
  514. savePartInfo (type) {
  515. const _this = this
  516. _this.form.promoType = _this.pageType
  517. var formData = JSON.parse(JSON.stringify(_this.form))
  518. if (type === 'all') {
  519. formData.productNum = _this.$refs.chooseProductList.getChooseProductNum()
  520. if (formData.productNum && formData.productNum == 0) {
  521. _this.$message.warning('请选择返券产品!')
  522. return
  523. }
  524. if (formData.promoType === 'BUY_PROD_GIVE_VALID') {
  525. if (formData.validType === 'FIXED') {
  526. if (!formData.validStartDate || !formData.validEndDate) {
  527. _this.$message.warning('请输入券有效期!')
  528. return false
  529. }
  530. } else {
  531. if (!formData.validDays) {
  532. _this.$message.warning('请输入券有效期!')
  533. return false
  534. }
  535. }
  536. }
  537. delete formData.productNum
  538. }
  539. delete formData.time
  540. _this.spinning = true
  541. saveShopPromo(formData).then(res => {
  542. if (res.status == 200) {
  543. _this.spinning = false
  544. if (res.data.errorMsg && res.data.errorMsg.length > 0) {
  545. this.$confirm({
  546. title: '提示',
  547. content: res.data.errorMsg.map((item, i) => { return <p>{i * 1 + 1}、{item}</p> }),
  548. centered: true,
  549. okText: '知道了',
  550. cancelText: '取消', // 将cancelText设置为空字符串或去掉该属性可以隐藏取消按钮
  551. cancelButtonProps: {
  552. style: {
  553. display: 'none' // 通过设置样式隐藏取消按钮
  554. }
  555. },
  556. onOk () {
  557. console.log('知道了')
  558. }
  559. })
  560. return
  561. }
  562. _this.$message.success(res.message)
  563. if (type === 'all') {
  564. _this.$nextTick(() => {
  565. _this.handleBack()
  566. _this.resetSearchForm()
  567. })
  568. } else {
  569. _this.isShowNextStep = true
  570. _this.getDetail({ sn: res.data.shopPromo.promoSn })
  571. }
  572. } else {
  573. _this.spinning = false
  574. }
  575. })
  576. },
  577. // 封面图片上传
  578. changeImage (file) {
  579. this.form.imageUrl = file
  580. },
  581. // 重置
  582. resetSearchForm () {
  583. if (this.pageType == 'add' || (this.pageType == 'edit' && !this.isDisabled)) {
  584. if (this.$refs.imageSet) {
  585. this.$refs.imageSet.setFileList('')
  586. }
  587. if (this.$refs.videoSet) {
  588. this.$refs.videoSet.setFileList('')
  589. }
  590. }
  591. if (this.$refs.editor) {
  592. this.$refs.editor.setHtml('')
  593. }
  594. this.form = {
  595. promoType: undefined, // 促销类型
  596. promoName: '', // '促销名称'
  597. time: [], // 促销时间
  598. promoStartDate: undefined, // 促销时间-开始
  599. promoEndDate: undefined, // 促销时间-结束
  600. sort: undefined, // 排序
  601. allDealerFlag: '1', // 全部经销商 1 部分经销商0'
  602. imageUrl: undefined, // 促销封面图
  603. description: '', // '促销描述'
  604. dealerEditFlag: '0', // 加盟商编辑 0否 1是
  605. dealerOpenFlag: '0', // 加盟商开关权限 0否 1是
  606. rangeList: [], // 选择产品列表
  607. discountType: 'STRAIGHT_DOWN', // 特价产品 - 优惠方式'
  608. validName: '', // 券名称
  609. validTitle: '', // 券副标题
  610. validBaseType: 'category', // 券生成方式
  611. validType: undefined, // 券有效期类型
  612. validStartDate: undefined, // 券生效时间
  613. validEndDate: undefined, // 券失效时间
  614. validDays: undefined, // 券有效期天数
  615. validScope: '1', // 券适用范围标记 1-全部 0-指定 死值 1
  616. validInfo: '', // 使用说明
  617. productNum: 0
  618. }
  619. this.isShowNextStep = false
  620. this.isDisabled = false
  621. if (this.$refs.ruleForm) {
  622. this.$refs.ruleForm.resetFields()
  623. }
  624. if (this.$refs.ruleForm) {
  625. this.$refs.ruleForm.resetFields()
  626. }
  627. },
  628. // 添加产品
  629. handleAddProduct () {
  630. this.chooseTypeList = this.productRangeList
  631. this.showProModal = true
  632. },
  633. // 批量设置
  634. handleBatchAdd () {
  635. if (!this.conditionValue && !this.resultValue) {
  636. this.$message.warning('请输入促销优惠规则!')
  637. return
  638. }
  639. this.$refs.chooseProductList.editMorePrice({ conditionValue: this.conditionValue, resultValue: this.resultValue })
  640. },
  641. // 添加产品成功
  642. addProductSuccess (list) {
  643. const productArr = list.map(item => {
  644. return {
  645. promoSn: this.form.promoSn,
  646. shopProductSn: item.shopProductSn,
  647. productSn: item.productSn,
  648. productCode: item.productCode
  649. }
  650. })
  651. saveChooseProduct(productArr).then(res => {
  652. if (res.status == 200) {
  653. this.showProModal = false
  654. // 获取产品列表 有分页
  655. this.$refs.chooseProductList.pageInit()
  656. }
  657. })
  658. },
  659. // 初始化
  660. pageInit () {
  661. if (this.$route.params.pageType === 'edit') {
  662. this.getDetail({ sn: this.$route.params.sn })
  663. } else {
  664. this.pageType = this.$route.params.pageType
  665. }
  666. }
  667. },
  668. mounted () {
  669. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  670. this.pageInit()
  671. }
  672. },
  673. activated () {
  674. // 如果是新页签打开,则重置当前页面
  675. if (this.$store.state.app.isNewTab) {
  676. this.pageInit()
  677. }
  678. // 仅刷新列表,不重置页面
  679. if (this.$store.state.app.updateList) {
  680. this.pageInit()
  681. }
  682. },
  683. beforeRouteEnter (to, from, next) {
  684. next(vm => {})
  685. }
  686. }
  687. </script>
  688. <style lang="less" scoped>
  689. .promotionEdit-wrap{
  690. position: relative;
  691. height: 100%;
  692. box-sizing: border-box;
  693. padding-bottom:51px;
  694. .buyerBox{
  695. border:1px solid #d9d9d9;
  696. margin-top:10px;
  697. border-radius:4px;
  698. padding:4px 10px;
  699. background:#f2f2f2;
  700. max-height:130px;
  701. overflow-y:scroll;
  702. scrollbar-width: none;
  703. }
  704. >.ant-spin-nested-loading{
  705. overflow-y: scroll;
  706. height: 100%;
  707. }
  708. /deep/.ant-form-item{
  709. margin-bottom:8px;
  710. }
  711. // .ant-form-item-control
  712. .promotionEdit-cont{
  713. margin-bottom: 10px;
  714. }
  715. .upload{
  716. width: 100%!important;
  717. }
  718. // 文本编辑器 工具栏样式换行
  719. .promotionEdit-editor{
  720. .w-e-toolbar{
  721. flex-wrap: wrap;
  722. z-index: 0;
  723. }
  724. }
  725. // 商品图片描述
  726. .upload-desc{
  727. font-size: 12px;
  728. color: #808695;
  729. }
  730. #promotionEdit-attachList{
  731. height: auto;
  732. }
  733. .box{
  734. border:1px solid #d9d9d9;
  735. border-radius:4px;
  736. padding:4px 11px;
  737. color:rgba(0, 0, 0, 0.25);
  738. cursor: not-allowed;
  739. background:#fdfdfd;
  740. }
  741. .affix{
  742. .ant-affix{
  743. z-index: 101;
  744. display:inline-block
  745. }
  746. }
  747. /deep/.ant-radio-disabled + span{
  748. color:#000!important;
  749. }
  750. .tip{
  751. margin-left:10px;
  752. }
  753. .productInfo{
  754. display:flex;
  755. justify-content: space-between;
  756. }
  757. #setPromotion-productRange{
  758. /deep/.ant-select-dropdown{
  759. max-height:30vh !important;
  760. }
  761. }
  762. }
  763. </style>