create.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. <template>
  2. <div class="app-container">
  3. <div class="base-info">
  4. <div class="base-info-title">基础信息</div>
  5. <!-- 基础信息 -->
  6. <div class="base-info-form">
  7. <el-form :model="form" :rules="rules" ref="form" label-width="100px">
  8. <el-form-item label="盲票类型" prop="type">
  9. <el-radio-group v-model="form.type" size="small" :disabled="form.disabled" @change="$refs['form'].clearValidate();changeType($event)">
  10. <el-radio label="online">线上盲票</el-radio>
  11. <el-radio label="offline">线下盲票</el-radio>
  12. </el-radio-group>
  13. </el-form-item>
  14. <el-form-item label="盲票组名称" prop="title">
  15. <el-col :xs="{span: 22, offset: 0}" :sm=" {span: 18, offset: 0}" :lg="{span: 10, offset: 0}">
  16. <el-input
  17. v-model="form.title"
  18. size="small"
  19. placeholder="请输入盲票组名称"
  20. ></el-input>
  21. </el-col>
  22. </el-form-item>
  23. <el-form-item label="图片" prop="picUrl">
  24. <Upload v-model="ticketPicUrl" :limit="3" :fileSize="0.5" @change="$refs.form.validateField(['picUrl'])"/>
  25. </el-form-item>
  26. <div class="tip" v-if="form.type != 'offline'">
  27. 请上传图片,jpg、png格式;线上盲票第1张为封面图,第2张为奖品图,第3张为主题图;大小不超过500k
  28. </div>
  29. <div class="tip" v-else>
  30. 上传1张图片,支持jpg、png格式上传,大小不超过500k;
  31. </div>
  32. <el-form-item label="面值" prop="facePrice">
  33. <el-input
  34. v-model="form.facePrice "
  35. style="width: 240px"
  36. size="small"
  37. placeholder="请输入面值" :disabled="form.disabled"
  38. >
  39. <template slot="append">元</template>
  40. </el-input>
  41. </el-form-item>
  42. <el-form-item label="售价" prop="salePrice1" v-if="form.type == 'online' && form.saleChannelType == 2">
  43. <el-input
  44. v-model="form.salePrice"
  45. style="width: 240px"
  46. size="small"
  47. placeholder="请输入售价"
  48. >
  49. <template slot="append">元</template>
  50. </el-input>
  51. </el-form-item>
  52. <el-form-item label="售价" prop="salePrice" v-else>
  53. <el-input
  54. v-model="form.salePrice"
  55. style="width: 240px"
  56. size="small"
  57. placeholder="请输入售价"
  58. >
  59. <template slot="append">元</template>
  60. </el-input>
  61. </el-form-item>
  62. <div class="tip" v-if="form.type == 'online'">线上盲票指定门店后可为0或不填,不填时默认处理为0</div>
  63. <el-form-item label="预付售票价" prop="prePrice">
  64. <el-input
  65. v-model="form.prePrice"
  66. style="width: 240px"
  67. size="small"
  68. placeholder="请输入预付售票价"
  69. >
  70. <template slot="append">元 / 张</template>
  71. </el-input>
  72. </el-form-item>
  73. <div class="tip" v-if="form.type != 'offline'">
  74. 如果为0则不作为预售票购买
  75. </div>
  76. <el-form-item
  77. label="划线价"
  78. prop="originPrice"
  79. v-if="form.type != 'offline'"
  80. >
  81. <el-input
  82. v-model="form.originPrice"
  83. style="width: 240px"
  84. size="small"
  85. placeholder="请输入划线价"
  86. >
  87. <template slot="append">元</template>
  88. </el-input>
  89. </el-form-item>
  90. <div class="tip" v-if="form.type != 'offline'">
  91. 划线价为0或不填,则不显示划线价
  92. </div>
  93. <el-form-item label="盲票总数" prop="quantity">
  94. <el-input
  95. v-model="form.quantity"
  96. style="width: 240px"
  97. size="small"
  98. placeholder="请输入盲票总数" :disabled="form.disabled"
  99. >
  100. <template slot="append">张</template>
  101. </el-input>
  102. </el-form-item>
  103. <el-form-item label="每包张数" prop="pkgUnit">
  104. <el-input
  105. v-model="form.pkgUnit"
  106. style="width: 240px"
  107. size="small"
  108. placeholder="请输入每包张数" :disabled="form.disabled"
  109. >
  110. <template slot="append">张</template>
  111. </el-input>
  112. </el-form-item>
  113. <el-form-item
  114. label="采购单价"
  115. prop="pkgSalePrice"
  116. v-if="form.type == 'offline'"
  117. >
  118. <el-input
  119. v-model="form.pkgSalePrice"
  120. style="width: 240px"
  121. size="small"
  122. placeholder="请输入采购单价"
  123. >
  124. <template slot="append">元/包</template>
  125. </el-input>
  126. </el-form-item>
  127. <el-form-item label="佣金系数" prop="saleCommRate">
  128. <el-input
  129. v-model="form.saleCommRate"
  130. style="width: 240px"
  131. size="small"
  132. placeholder="请输入佣金系数"
  133. >
  134. <template slot="append">%</template>
  135. </el-input>
  136. </el-form-item>
  137. <div class="tip">
  138. 例如:一张盲票用户支付10元,盲票佣金系数90%,门店佣金比例20%,那么门店佣金为10元*90%*20%=1.8元
  139. </div>
  140. <el-form-item label="销售范围" prop="saleChannelType" v-if="form.type == 'online'">
  141. <el-radio-group v-model="form.saleChannelType" :disabled="form.disabled" size="small" @change="$refs['form'].clearValidate()">
  142. <el-radio :label="1">首页售卖</el-radio>
  143. <el-radio :label="2">指定门店</el-radio>
  144. </el-radio-group>
  145. </el-form-item>
  146. <el-form-item label="门店" prop="siteIdList" v-if="form.type == 'online' && form.saleChannelType == 2">
  147. <el-select
  148. v-model="form.siteIdList"
  149. placeholder="请选择门店"
  150. style="width: 240px;"
  151. filterable
  152. clearable
  153. multiple
  154. :filter-method="dataFilter"
  155. >
  156. <el-option
  157. v-for="(item) in siteList"
  158. :key="item.channelId"
  159. :label="item.name"
  160. :value="item.channelId">
  161. <div>
  162. <span style="float: left;">{{item.name}} </span>
  163. <span style="float: right;">{{item.mobile}}</span>
  164. </div>
  165. </el-option>
  166. </el-select>
  167. </el-form-item>
  168. <el-form-item label="销售范围" prop="saleChannelType" v-if="form.type == 'offline'">
  169. <el-radio-group v-model="form.saleChannelType" size="small" @change="$refs['form'].clearValidate()">
  170. <el-radio :label="1">所有渠道</el-radio>
  171. <el-radio :label="2">指定渠道</el-radio>
  172. </el-radio-group>
  173. </el-form-item>
  174. <el-form-item label="渠道" prop="channelIdList" v-if="form.type == 'offline' && form.saleChannelType == 2">
  175. <el-select
  176. v-model="form.channelIdList"
  177. placeholder="请选择渠道"
  178. style="width: 240px;"
  179. filterable
  180. clearable
  181. multiple
  182. :filter-method="dataFilter2"
  183. >
  184. <el-option
  185. v-for="(item) in channelList"
  186. :key="item.channelId"
  187. :label="item.name"
  188. :value="item.channelId">
  189. <div>
  190. <span style="float: left;">{{item.name}} </span>
  191. <span style="float: right;">{{item.mobile}}</span>
  192. </div>
  193. </el-option>
  194. </el-select>
  195. </el-form-item>
  196. <div class="tip" v-if="form.type == 'offline'">注:盲票只对所选渠道下的门店可见</div>
  197. </el-form>
  198. </div>
  199. <!-- 关联商品设置 -->
  200. <div class="base-info-title">商品设置(购买即可提货)</div>
  201. <award-form ref="awardFrom" @close="close" v-model="goodsList" :id="ids" @goodsCommand="goodsCommand"></award-form>
  202. <!-- 奖级设置 -->
  203. <div class="base-info-title" >奖级设置</div>
  204. <!-- 奖级列表 -->
  205. <awards-list ref="awards" :id="ids" v-model="awardsList" @handleCommand="handleCommand" @close="close" />
  206. <!-- 保存 -->
  207. <div class="save-btn">
  208. <el-button size="small" @click="back"> 取 消 </el-button>
  209. <div class="ge"></div>
  210. <el-button type="primary" size="small" @click="submitForm">
  211. 保 存
  212. </el-button>
  213. </div>
  214. </div>
  215. <!-- 添加商品 -->
  216. <goods-add :dialog-visible="goodsTableVisible" @close="close" ticket="goods" :iconic="iconic" @confirmGoodsForm="confirmGoodsForm" @confirmGoods="confirmGoods" v-if="goodsTableVisible" />
  217. <!-- 添加盲票商品 -->
  218. <goods-add :dialog-visible="goodsTableVisible2" @close="close" ticket="ticketGoods" :iconic="iconic" @confirmGoodsForm="confirmGoodsForm" @confirmGoods="confirmGoods" v-if="goodsTableVisible2" />
  219. <!-- 添加券 -->
  220. <coupon-add :dialog-visible="couponTableVisible" :iconic="iconic" @close="close" @confirmCouponForm="confirmCouponForm" @confirmCoupon="confirmCoupon" v-if="couponTableVisible" />
  221. <!-- 添加券包 -->
  222. <coupon-pkg-add :dialog-visible="couponPkgTableVisible" :iconic="iconic" @close="close" @confirmCouponPkgForm="confirmCouponPkgForm" @confirmCouponPkg="confirmCouponPkg" v-if="couponPkgTableVisible" />
  223. <!-- 添加盲豆 -->
  224. <coin-add :dialog-visible="coinTableVisible" @close="close" @confirmCoin="confirmCoin" v-if="coinTableVisible" />
  225. <!-- 添加微信红包 -->
  226. <red-pkg-add :dialog-visible="redPkgTableVisible" @close="close" @confirmRedPkg="confirmRedPkg" v-if="redPkgTableVisible" />
  227. </div>
  228. </template>
  229. <script>
  230. import Upload from '@/components/DragImageUpload'
  231. import { publicFileGetUrl } from "@/api/common";
  232. import CustomFieldsMixin from "@/mixins/CustomFields";
  233. import { ticketBoxCreate, setListDetail, ticketBoxDetail} from "@/api/business/ticket";
  234. import { listAllChannel } from "@/api/admin/channel";
  235. import { listAllSaleSite } from "@/api/admin/salesite";
  236. import { accMul, accDiv } from "@/utils/util";
  237. import AwardsList from "./components/AwardsList"
  238. import GoodsAdd from "./components/GoodsAdd"
  239. import CouponAdd from "./components/CouponAdd"
  240. import CouponPkgAdd from "./components/CouponPkgAdd"
  241. import CoinAdd from "./components/CoinAdd"
  242. import AwardForm from "./components/AwardForm"
  243. import RedPkgAdd from './components/RedPkgAdd.vue';
  244. export default {
  245. name: "TicketCreate",
  246. mixins: [CustomFieldsMixin],
  247. components: {
  248. AwardsList,
  249. GoodsAdd,
  250. CouponAdd,
  251. CouponPkgAdd,
  252. CoinAdd,
  253. Upload,
  254. AwardForm,
  255. RedPkgAdd,
  256. },
  257. data() {
  258. return {
  259. loading: false,
  260. id: this.$route.query.id,
  261. ids: this.$route.query.id?this.$route.query.id:0,
  262. form: {
  263. type: "online", //盲票类型
  264. title: "", // 盲票名称
  265. picUrl: "", // 图片
  266. facePrice: "", // 面值
  267. salePrice: "", // 售价
  268. prePrice: 0, //预购价
  269. quantity: "", // 数量
  270. pkgUnit: 200, // 张数
  271. pkgSalePrice: 0, // 单价
  272. saleCommRate: "", // 基数
  273. originPrice: 0, //划线价
  274. disabled: false,
  275. saleChannelType: 1,//销售范围类型
  276. isHaveRedPkg: 0,
  277. },
  278. // 门店列表
  279. siteList: [],
  280. siteCopyList:[],
  281. // 上级渠道列表
  282. channelList:[],
  283. channelCopyList:[],
  284. rules: {
  285. type: [
  286. { required: true, message: "请选择盲票类型", trigger: "change" },
  287. ],
  288. title: [
  289. { required: true, message: "请输入盲票组名称", trigger: "blur" },
  290. ],
  291. picUrl: [
  292. {
  293. required: true,
  294. message: "请上传盲票图片",
  295. trigger: ["blur", "change"],
  296. },
  297. ],
  298. facePrice: [
  299. { required: true, message: "请输入面值", trigger: "blur" },
  300. {
  301. pattern:
  302. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  303. message: "请输入合法的金额数字,最多两位小数",
  304. trigger: ["blur", "change"],
  305. },
  306. ],
  307. salePrice: [
  308. { required: true, message: "请输入售价", trigger: "blur" },
  309. {
  310. pattern:
  311. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  312. message: "请输入合法的金额数字,最多两位小数",
  313. trigger: ["blur", "change"],
  314. },
  315. ],
  316. salePrice1: [
  317. // { required: true, message: "请输入售价", trigger: "blur" },
  318. {
  319. pattern:
  320. /^([0-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  321. message: "请输入合法的金额数字,最多两位小数",
  322. trigger: ["blur", "change"],
  323. },
  324. ],
  325. prePrice: [
  326. { required: true, message: "请输入预付售票价", trigger: "blur" },
  327. {
  328. pattern:
  329. /^([0-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  330. message: "请输入合法的金额数字,最多两位小数",
  331. trigger: ["blur", "change"],
  332. },
  333. ],
  334. quantity: [
  335. { required: true, message: "请输入数量", trigger: "blur" },
  336. {
  337. pattern: /^([1-9]\d*)$/,
  338. message: "请输入合法的数字",
  339. trigger: ["blur", "change"],
  340. },
  341. ],
  342. originPrice: [{
  343. pattern:
  344. /^([0-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  345. message: "请输入合法的金额数字,最多两位小数",
  346. trigger: ["blur", "change"],
  347. },],
  348. pkgUnit: [
  349. { required: true, message: "请输入每包张数", trigger: "blur" },
  350. {
  351. pattern: /^([1-9]\d*)$/,
  352. message: "请输入合法的数字",
  353. trigger: ["blur", "change"],
  354. },
  355. ],
  356. pkgSalePrice: [
  357. { required: true, message: "请输入采购单价", trigger: "blur" },
  358. {
  359. pattern:
  360. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  361. message: "请输入合法的金额数字,最多两位小数",
  362. trigger: ["blur", "change"],
  363. },
  364. ],
  365. saleCommRate: [
  366. { required: true, message: "请输入分佣基数", trigger: "blur" },
  367. {
  368. pattern:
  369. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  370. message: "请输入合法的数字,最多两位小数",
  371. trigger: ["blur", "change"],
  372. },
  373. ],
  374. saleChannelType: [
  375. { required: true, message: "请选择销售范围", trigger: "change" },
  376. ],
  377. channelIdList: [
  378. { required: true, message: "请选择渠道", trigger: "change" },
  379. ],
  380. siteIdList: [
  381. { required: true, message: "请选择门店", trigger: "change" }
  382. ],
  383. },
  384. // 奖级列表
  385. awardsList: [],
  386. //关联商品列表
  387. goodsList: [],
  388. goodsTableVisible: false, // 添加商品弹框
  389. goodsTableVisible2: false, // 添加盲票商品弹框
  390. couponTitle: "", // 券名称
  391. couponTableVisible: false, // 添加卡券弹框
  392. couponPkgTableVisible: false, // 添加券包弹框
  393. coinTableVisible: false, // 添加盲豆弹框
  394. redPkgTableVisible: false, //添加微信红包
  395. pageParams: {
  396. pageNum: 1,
  397. pageSize: 10,
  398. },
  399. iconic: '',//区分添加的是关联商品还是奖品
  400. };
  401. },
  402. computed: {
  403. ticketPicUrl: {
  404. get() {
  405. return this.form.picUrl ? this.form.picUrl.split(',').map(item => {
  406. return {
  407. fileName: item
  408. }
  409. }) : []
  410. },
  411. set(val) {
  412. this.$set(this.form, 'picUrl', val.map(item => { return item.fileName }).toString())
  413. }
  414. }
  415. },
  416. created() {
  417. this.getChannelList()
  418. this.getSiteList()
  419. if (this.id) {
  420. let data = {
  421. boxId: this.id
  422. }
  423. ticketBoxDetail(data).then(res => {
  424. const { awardsList, goodsList, type, title, picUrl, facePrice, salePrice, prePrice, quantity, originPrice, pkgUnit, pkgSalePrice, saleCommRate, saleChannelType, channelList } = res.data
  425. this.form = {
  426. disabled:true,
  427. title, picUrl, quantity, pkgUnit, saleCommRate, saleChannelType,
  428. channelIdList: saleChannelType == 2 ? channelList.map(item => item.channelId) : [],
  429. siteIdList: saleChannelType == 2 ? channelList.map(item => item.channelId) : [],
  430. type: JSON.parse(type).value,
  431. facePrice:accDiv(facePrice, 100),
  432. salePrice:accDiv(salePrice, 100),
  433. prePrice:accDiv(prePrice,100),
  434. pkgSalePrice:accDiv(pkgSalePrice, 100),
  435. originPrice:accDiv(originPrice, 100)
  436. }
  437. // if(JSON.parse(type).value == 'online' && saleChannelType == 2){
  438. // this.form.siteIdList = channelList[0].channelId
  439. // }
  440. // if(JSON.parse(type).value == 'offline' && saleChannelType == 2){
  441. // this.form.channelIdList = channelList.map(item => item.channelId)
  442. // }
  443. if(awardsList){
  444. awardsList.forEach((item) => {
  445. item.isEdit = true
  446. item.prizeList.forEach((ele) => {
  447. (ele.picUrl = publicFileGetUrl + ele.picUrl.split(',')[0]),
  448. (ele.prizeType = JSON.parse(ele.prizeType).value);
  449. ele.couponDetail = ele.couponDetail ? encodeURI(ele.couponDetail) : ''
  450. });
  451. });
  452. this.$nextTick(() => {
  453. this.$refs.awards.add(3, awardsList)
  454. this.$refs.awards.changetype(JSON.parse(type).value)
  455. })
  456. this.awardsList = awardsList
  457. }
  458. if(goodsList){
  459. goodsList.forEach((item) => {
  460. (item.picUrl = publicFileGetUrl + item.picUrl.split(',')[0]),
  461. // (item.prizeType = JSON.parse(item.prizeType).value);
  462. (item.type = JSON.parse(item.type).value);
  463. });
  464. if(this.$refs.awardFrom) {
  465. this.$nextTick(() => {
  466. this.$refs.awardFrom.add(3,goodsList)
  467. })
  468. }
  469. // this.goodsList = goodsList
  470. }
  471. })
  472. }
  473. },
  474. methods: {
  475. // 获取上级渠道下拉列表
  476. getChannelList(){
  477. listAllChannel().then(response => {
  478. this.channelList = response.data || [];
  479. this.channelCopyList = response.data || [];
  480. });
  481. },
  482. dataFilter2(val) {
  483. if (val) { //val存在
  484. this.channelList = this.channelCopyList.filter((item) => {
  485. if (!!~item.mobile.indexOf(val) || !!~item.mobile.toUpperCase().indexOf(val.toUpperCase())
  486. || !!~item.name.indexOf(val) || !!~item.name.indexOf(val)) {
  487. return true
  488. }
  489. })
  490. } else { //val为空时,还原数组
  491. this.channelList = this.channelCopyList;
  492. }
  493. },
  494. // 获取门店下拉列表
  495. getSiteList() {
  496. listAllSaleSite({}).then(response => {
  497. this.siteList = response.data || [];
  498. this.siteCopyList = response.data || [];
  499. });
  500. },
  501. dataFilter(val) {
  502. if (val) { //val存在
  503. this.siteList = this.siteCopyList.filter((item) => {
  504. if (!!~item.mobile.indexOf(val) || !!~item.mobile.toUpperCase().indexOf(val.toUpperCase())
  505. || !!~item.name.indexOf(val) || !!~item.name.indexOf(val)) {
  506. return true
  507. }
  508. })
  509. } else { //val为空时,还原数组
  510. this.siteList = this.siteCopyList;
  511. }
  512. },
  513. // 保存
  514. submitForm() {
  515. const subForm = this.$refs["form"];
  516. subForm.validate((valid) => {
  517. if (valid) {
  518. // let prizeIndex = this.awardsList.findIndex((item) => {
  519. // return !item.prizeList.length;
  520. // });
  521. // // 判断没有设置奖品的奖级
  522. // if (prizeIndex != -1) {
  523. // this.$message.error(
  524. // `请设置${this.awardsList[prizeIndex].name}的奖品!`
  525. // );
  526. // return;
  527. // }
  528. if (this.form.quantity > 100000) {
  529. this.$message.error("盲票数量超出限制,请重新填写!");
  530. return;
  531. }
  532. this.form.isHaveRedPkg = 0
  533. for (let i = 0; i < this.awardsList.length; i++) {
  534. const item = this.awardsList[i];
  535. for (let j = 0; j < item.prizeList.length; j++) {
  536. if(item.prizeList[j].prizeType == 'red_pkg') {
  537. this.form.isHaveRedPkg = 1
  538. break
  539. }
  540. }
  541. }
  542. let prizeIndex = this.awardsList.findIndex((item) => {
  543. return !item.prizeList.length && item.quantity > 0;
  544. });
  545. // 判断没有设置奖品的奖级
  546. if (prizeIndex != -1) {
  547. this.$message.error(
  548. `请设置${this.awardsList[prizeIndex].name}的奖品!`
  549. );
  550. return;
  551. }
  552. if (this.form.quantity % this.form.pkgUnit != 0) {
  553. this.$message.error("每包数量错误!");
  554. return;
  555. }
  556. let quantityTotal = 0;
  557. this.awardsList.forEach((item) => {
  558. quantityTotal += item.quantity;
  559. });
  560. if (this.form.quantity != quantityTotal) {
  561. this.$message.error("盲票数量和奖品数量不一致!");
  562. return;
  563. }
  564. // if (this.form.saleCommRate > 100) {
  565. // this.$message.error("分佣基数不能大于100!");
  566. // return;
  567. // }
  568. this.awardsList.forEach((item) => {
  569. item.prizeList = item.prizeList.map((ele) => {
  570. return {
  571. ...ele,
  572. refId: ele.goodsId || ele.couponId || ele.id,
  573. prizeType: ele.prizeType,
  574. quantity: ele.quantity,
  575. value: ele.value,
  576. };
  577. });
  578. });
  579. let filterArr = this.awardsList.filter((item) => {
  580. return item.prizeList.length != 0;
  581. });
  582. let filterArr2 = filterArr.filter((item) => {
  583. return item.quantity != 0;
  584. });
  585. // for (let i = 0; i < filterArr2.length; i++) {
  586. // if(filterArr2[i].awardsLabel == "" || filterArr2[i].awardsLabel == undefined){
  587. // this.$message.error("关联奖级不能为空");
  588. // return
  589. // }
  590. // }
  591. if (this.form.type == "offline") {
  592. this.form.originPrice = null
  593. for (let i = 0; i < filterArr2.length; i++) {
  594. for (let j = 0; j < filterArr2[i].prizeList; j++) {
  595. filterArr2[i].prizeList[j].quantity = null
  596. }
  597. }
  598. }
  599. if (this.form.type != "offline" && this.goodsList.length < 1) {
  600. this.$message.error("关联商品不能为空");
  601. return
  602. }
  603. let data = {
  604. ...this.form,
  605. facePrice: accMul(this.form.facePrice, 100),
  606. salePrice: accMul(this.form.salePrice, 100),
  607. prePrice: accMul(this.form.prePrice, 100),
  608. pkgSalePrice: accMul(this.form.pkgSalePrice, 100),
  609. originPrice: accMul(this.form.originPrice, 100),
  610. awardsList: filterArr2,
  611. goodsList: this.goodsList
  612. };
  613. if( data.type == 'online' && data.saleChannelType == 1 ){
  614. data.siteIdList = []
  615. data.channelIdList = []
  616. }
  617. if( data.type == 'online' && data.saleChannelType == 2 ) {
  618. data.channelIdList = data.siteIdList
  619. }
  620. if( data.type == 'offline' && data.saleChannelType == 1 ){
  621. data.siteIdList = []
  622. data.channelIdList = []
  623. }
  624. if (this.id){
  625. data.boxId = this.id
  626. }
  627. let request = this.id ? setListDetail : ticketBoxCreate;
  628. const loading = this.$loading({
  629. lock: true,
  630. text: "保存中",
  631. spinner: "el-icon-loading",
  632. background: "rgba(0, 0, 0, 0.4)",
  633. });
  634. request(data).then((res) => {
  635. loading.close();
  636. if (res.code == 0) {
  637. this.msgSuccess("保存成功");
  638. this.$store.dispatch("tagsView/delView", this.$route);
  639. this.$router.go(-1);
  640. }
  641. })
  642. .catch(() => {
  643. loading.close();
  644. });
  645. } else {
  646. this.getFormErrorMessage(subForm);
  647. return false;
  648. }
  649. });
  650. },
  651. // 关闭弹框
  652. close() {
  653. this.goodsTableVisible = false;
  654. this.goodsTableVisible2 = false;
  655. this.couponTableVisible = false;
  656. this.couponPkgTableVisible = false;
  657. this.coinTableVisible = false;
  658. this.redPkgTableVisible = false;
  659. },
  660. changeType(e) {
  661. this.$refs.awards.changetype(e)
  662. },
  663. // 添加奖品种类
  664. handleCommand(e) {
  665. if (e == "goods") {
  666. this.iconic = 'goods'
  667. this.goodsTableVisible = true;
  668. } else if (e == "coupon") {
  669. this.iconic = 'coupon'
  670. this.couponTableVisible = true;
  671. } else if (e == "coupon_pkg") {
  672. this.iconic = 'couponPkg'
  673. this.couponPkgTableVisible = true;
  674. } else if (e == "coin") {
  675. this.coinTableVisible = true;
  676. }else if(e == "ticketGoods") {
  677. this.iconic = 'goods'
  678. this.goodsTableVisible2 = true;
  679. }else if(e == "red_pkg") {
  680. this.iconic = 'redPacket'
  681. this.redPkgTableVisible = true;
  682. }
  683. },
  684. goodsCommand(e) {
  685. if (e == "goods") {
  686. this.iconic = 'goodsForm'
  687. this.goodsTableVisible = true;
  688. } else if (e == "coupon") {
  689. this.iconic = 'couponForm'
  690. this.couponTableVisible = true;
  691. } else if (e == "coupon_pkg") {
  692. this.iconic = 'couponPkgForm'
  693. this.couponPkgTableVisible = true;
  694. }else if (e == "ticketGoods") {
  695. this.iconic = 'goodsForm'
  696. this.goodsTableVisible2 = true;
  697. }
  698. },
  699. // 确认选中商品
  700. confirmGoods(arr) {
  701. this.$refs.awards.add(1, arr)
  702. },
  703. // 确认选中卡券
  704. confirmCoupon(arr) {
  705. this.$refs.awards.add(1, arr)
  706. },
  707. // 确认选中券包
  708. confirmCouponPkg(arr) {
  709. this.$refs.awards.add(1, arr)
  710. },
  711. // 确认输入盲豆
  712. confirmCoin(obj) {
  713. this.$refs.awards.add(2, obj)
  714. },
  715. // 确认输入金额
  716. confirmRedPkg(obj) {
  717. this.$refs.awards.add(2, obj)
  718. },
  719. //选中的关联商品
  720. confirmGoodsForm(arr) {
  721. this.$refs.awardFrom.add(1,arr)
  722. },
  723. // 确认选中关联卡券
  724. confirmCouponForm(arr) {
  725. this.$refs.awardFrom.add(1, arr)
  726. },
  727. // 确认选中关联券包
  728. confirmCouponPkgForm(arr) {
  729. this.$refs.awardFrom.add(1, arr)
  730. },
  731. // 取消
  732. back() {
  733. this.$store.dispatch("tagsView/delView", this.$route);
  734. this.$router.go(-1);
  735. },
  736. },
  737. };
  738. </script>
  739. <style lang="scss" scoped>
  740. .base-info-title {
  741. padding: 10px;
  742. border-bottom: 1px solid #eaeaea;
  743. margin-bottom: 20px;
  744. }
  745. .tip {
  746. padding-left: 100px;
  747. height: 32px;
  748. margin-bottom: 20px;
  749. color: #828282;
  750. font-size: 14px;
  751. }
  752. .save-btn {
  753. display: flex;
  754. align-content: center;
  755. justify-content: center;
  756. margin-bottom: 100px;
  757. .ge {
  758. width: 100px;
  759. }
  760. }
  761. .prize {
  762. width: 1000px;
  763. margin-bottom: 50px;
  764. background: #f9f9f9;
  765. border: 1px solid #bbbbbb;
  766. font-size: 14px;
  767. &-top {
  768. padding: 10px 20px;
  769. margin-bottom: 10px;
  770. display: flex;
  771. align-content: center;
  772. justify-content: space-around;
  773. border-bottom: 1px solid #bbbbbb;
  774. div {
  775. line-height: 36px;
  776. }
  777. }
  778. &-btn {
  779. border-top: 1px solid #bbbbbb;
  780. padding: 10px;
  781. }
  782. }
  783. .dialog-search {
  784. display: flex;
  785. line-height: 32px;
  786. margin-bottom: 20px;
  787. .ge {
  788. width: 40px;
  789. }
  790. }
  791. .dialog-btn {
  792. display: flex;
  793. align-content: center;
  794. justify-content: flex-end;
  795. padding: 40px 0 0;
  796. .ge {
  797. width: 40px;
  798. }
  799. }
  800. </style>