create.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923
  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">
  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-input
  16. v-model="form.title"
  17. style="width: 587px"
  18. size="small"
  19. placeholder="请输入盲票组名称"
  20. ></el-input>
  21. </el-form-item>
  22. <el-form-item label="图片" prop="picUrl">
  23. <image-upload
  24. :limit="1"
  25. :value="form.picUrl"
  26. :file-size="50"
  27. :is-public="true"
  28. @input="pictureSelect"
  29. />
  30. </el-form-item>
  31. <div class="tip">
  32. 上传1张图片,支持jpg、png格式上传,建议使用尺寸800x800像素以上、大小不超过1M的正方形图片;
  33. </div>
  34. <el-form-item label="面值" prop="facePrice">
  35. <el-input
  36. v-model="form.facePrice"
  37. style="width: 240px"
  38. size="small"
  39. placeholder="请输入面值"
  40. >
  41. <template slot="append">元</template>
  42. </el-input>
  43. </el-form-item>
  44. <el-form-item label="售价" prop="salePrice">
  45. <el-input
  46. v-model="form.salePrice"
  47. style="width: 240px"
  48. size="small"
  49. placeholder="请输入售价"
  50. >
  51. <template slot="append">元</template>
  52. </el-input>
  53. </el-form-item>
  54. <el-form-item label="盲票总数" prop="quantity">
  55. <el-input
  56. v-model="form.quantity"
  57. style="width: 240px"
  58. size="small"
  59. placeholder="请输入盲票总数"
  60. >
  61. <template slot="append">张</template>
  62. </el-input>
  63. </el-form-item>
  64. <el-form-item label="每包张数" prop="pkgUnit">
  65. <el-input
  66. v-model="form.pkgUnit"
  67. style="width: 240px"
  68. size="small"
  69. placeholder="请输入每包张数"
  70. >
  71. <template slot="append">张</template>
  72. </el-input>
  73. </el-form-item>
  74. <el-form-item
  75. label="采购单价"
  76. prop="pkgSalePrice"
  77. v-if="form.type == 'offline'"
  78. >
  79. <el-input
  80. v-model="form.pkgSalePrice"
  81. style="width: 240px"
  82. size="small"
  83. placeholder="请输入采购单价"
  84. >
  85. <template slot="append">元/包</template>
  86. </el-input>
  87. </el-form-item>
  88. <el-form-item label="分佣基数" prop="saleCommRate">
  89. <el-input
  90. v-model="form.saleCommRate"
  91. style="width: 240px"
  92. size="small"
  93. placeholder="请输入分佣基数"
  94. >
  95. <template slot="append">%</template>
  96. </el-input>
  97. </el-form-item>
  98. <div class="tip">
  99. 例如:盲票面值10元,分佣基数90%,经销商佣金比例20%,那么每卖一张票,经销商佣金为10元*90%*20%=1.8元
  100. </div>
  101. </el-form>
  102. </div>
  103. <div class="base-info-title">奖级设置</div>
  104. <!-- 奖级设置 -->
  105. <div class="prize" v-for="(item, index) in awardsList" :key="index">
  106. <div class="prize-top">
  107. <div>奖级名称:{{ item.name }}</div>
  108. <div>奖级:{{ item.sort }}</div>
  109. <div>
  110. 奖级数量:
  111. <el-input-number
  112. v-model="item.quantity"
  113. controls-position="right"
  114. @change="handleChangeAll($event, item)"
  115. :min="0"
  116. size="small"
  117. ></el-input-number>
  118. </div>
  119. </div>
  120. <div class="prize-table">
  121. <el-table :data="item.prizeList" class="el-table">
  122. <el-table-column label="奖品图片" prop="storeName">
  123. <template slot-scope="scope">
  124. <el-image
  125. style="width: 70px; height: 70px"
  126. :src="scope.row.picUrl"
  127. :preview-src-list="[scope.row.picUrl]"
  128. >
  129. </el-image>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="奖品名称" prop="title" />
  133. <el-table-column label="奖品类型">
  134. <template slot-scope="scope">
  135. <div v-if="scope.row.prizeType == 'goods'">商品</div>
  136. <div v-if="scope.row.prizeType == 'coupon'">券</div>
  137. <div v-if="scope.row.prizeType == 'coin'">盲豆</div>
  138. </template>
  139. </el-table-column>
  140. <!-- <el-table-column label="奖品数量" prop="storeName">
  141. <template slot-scope="scope">
  142. <div>
  143. <el-input-number
  144. v-model="scope.row.quantity"
  145. controls-position="right"
  146. @change="handleChange($event, index)"
  147. :min="1"
  148. size="small"
  149. ></el-input-number>
  150. </div>
  151. </template>
  152. </el-table-column> -->
  153. <el-table-column label="操作" align="center">
  154. <template slot-scope="scope">
  155. <el-button
  156. size="mini"
  157. type="text"
  158. @click="handleDel(scope.$index, item)"
  159. >删除</el-button
  160. >
  161. </template>
  162. </el-table-column>
  163. </el-table>
  164. </div>
  165. <div class="prize-btn">
  166. <el-dropdown @command="handleCommand($event, index)">
  167. <el-button type="primary" size="small">
  168. 添加奖品<i class="el-icon-arrow-down el-icon--right"></i>
  169. </el-button>
  170. <el-dropdown-menu slot="dropdown">
  171. <el-dropdown-item command="goods">商品</el-dropdown-item>
  172. <el-dropdown-item command="coupon">券</el-dropdown-item>
  173. <el-dropdown-item command="coin">盲豆</el-dropdown-item>
  174. </el-dropdown-menu>
  175. </el-dropdown>
  176. </div>
  177. </div>
  178. <!-- 保存 -->
  179. <div class="save-btn">
  180. <el-button size="small" @click="back"> 取 消 </el-button>
  181. <div class="ge"></div>
  182. <el-button type="primary" size="small" @click="submitForm">
  183. 保 存
  184. </el-button>
  185. </div>
  186. </div>
  187. <!-- 添加商品 -->
  188. <el-dialog
  189. title="添加实物奖品"
  190. width="1000px"
  191. :visible.sync="goodsTableVisible"
  192. :before-close="close"
  193. >
  194. <div class="dialog-search">
  195. <div>商品名称:</div>
  196. <el-input
  197. v-model="goodsTitle"
  198. placeholder="请输入商品名称"
  199. clearable
  200. size="small"
  201. style="width: 240px"
  202. @keyup.enter.native="handleQueryGoods"
  203. />
  204. <div class="ge"></div>
  205. <el-button
  206. type="primary"
  207. icon="el-icon-search"
  208. size="mini"
  209. @click="handleQueryGoods"
  210. >查询</el-button
  211. >
  212. </div>
  213. <el-table
  214. v-loading="loading"
  215. :data="goodsList"
  216. @selection-change="handleSelectionGoods"
  217. class="el-table"
  218. >
  219. <el-table-column
  220. type="selection"
  221. width="55"
  222. align="center"
  223. fixed="left"
  224. />
  225. <el-table-column label="商品ID" prop="goodsId" />
  226. <el-table-column label="商品图片">
  227. <template slot-scope="{ row }">
  228. <div v-if="row.picUrl">
  229. <el-image
  230. style="width: 100px; height: 100px"
  231. :src="row.picUrl.split(',')[0]"
  232. :preview-src-list="row.picUrl.split(',')"
  233. >
  234. </el-image>
  235. </div>
  236. <p v-else>-</p>
  237. </template>
  238. </el-table-column>
  239. <el-table-column label="商品名称" prop="title" min-width="85" />
  240. <el-table-column label="商品价格" min-width="85">
  241. <template slot-scope="scope">
  242. <div>¥{{ $numberFormat(scope.row.exchangePrice) }}</div>
  243. </template>
  244. </el-table-column>
  245. <el-table-column label="商品库存" prop="quantity" width="80" />
  246. </el-table>
  247. <pagination
  248. v-show="goodsTotal > 0"
  249. :total="goodsTotal"
  250. :page.sync="pageParams.pageNum"
  251. :limit.sync="pageParams.pageSize"
  252. @pagination="getGoodsList"
  253. />
  254. <div class="dialog-btn">
  255. <el-button size="small" @click="close"> 取 消 </el-button>
  256. <div class="ge"></div>
  257. <el-button type="primary" size="small" @click="confirmGoods">
  258. 确 认
  259. </el-button>
  260. </div>
  261. </el-dialog>
  262. <!-- 添加卡券 -->
  263. <el-dialog
  264. title="添加券奖品"
  265. width="1000px"
  266. :visible.sync="couponTableVisible"
  267. :before-close="close"
  268. >
  269. <div class="dialog-search">
  270. <div>券名称:</div>
  271. <el-input
  272. v-model="couponTitle"
  273. placeholder="请输入券名称"
  274. clearable
  275. size="small"
  276. style="width: 240px"
  277. @keyup.enter.native="handleQueryCoupon"
  278. />
  279. <div class="ge"></div>
  280. <el-button
  281. type="primary"
  282. icon="el-icon-search"
  283. size="mini"
  284. @click="handleQueryCoupon"
  285. >查询</el-button
  286. >
  287. </div>
  288. <el-table
  289. v-loading="loading"
  290. :data="couponList"
  291. @selection-change="handleSelectionCoupon"
  292. class="el-table"
  293. >
  294. <el-table-column
  295. type="selection"
  296. width="55"
  297. align="center"
  298. fixed="left"
  299. />
  300. <el-table-column label="券ID" prop="couponId" />
  301. <el-table-column label="券图片">
  302. <template slot-scope="scope">
  303. <div>
  304. <el-image
  305. style="width: 100px; height: 100px"
  306. :src="scope.row.picUrl"
  307. :preview-src-list="[scope.row.picUrl]"
  308. >
  309. </el-image>
  310. </div>
  311. </template>
  312. </el-table-column>
  313. <el-table-column label="券名称" prop="title" min-width="85" />
  314. <el-table-column label="使用场景" min-width="85">
  315. <template slot-scope="scope">
  316. <div>{{ scope.row.type.desc }}</div>
  317. </template>
  318. </el-table-column>
  319. <el-table-column label="券价格" min-width="85">
  320. <template slot-scope="scope">
  321. <div>¥{{ $numberFormat(scope.row.discount) }}</div>
  322. </template>
  323. </el-table-column>
  324. <el-table-column label="有效期限" min-width="85">
  325. <template slot-scope="scope">
  326. <div>{{ scope.row.useArea.desc }}</div>
  327. </template>
  328. </el-table-column>
  329. </el-table>
  330. <pagination
  331. v-show="couponTotal > 0"
  332. :total="couponTotal"
  333. :page.sync="pageParams.pageNum"
  334. :limit.sync="pageParams.pageSize"
  335. @pagination="getCouponList"
  336. />
  337. <div class="dialog-btn">
  338. <el-button size="small" @click="close"> 取 消 </el-button>
  339. <div class="ge"></div>
  340. <el-button type="primary" size="small" @click="confirmCoupon">
  341. 确 认
  342. </el-button>
  343. </div>
  344. </el-dialog>
  345. <!-- 添加盲豆 -->
  346. <el-dialog
  347. title="添加盲豆奖品"
  348. :visible.sync="coinTableVisible"
  349. :before-close="close"
  350. >
  351. <el-form
  352. :model="coinForm"
  353. :rules="coinRules"
  354. ref="coinForm"
  355. label-width="100px"
  356. >
  357. <el-form-item label="盲豆数量" prop="quantity">
  358. <el-input
  359. v-model="coinForm.quantity"
  360. size="small"
  361. placeholder="请输入盲豆数量"
  362. />
  363. </el-form-item>
  364. </el-form>
  365. <div class="dialog-btn">
  366. <el-button size="small" @click="close"> 取 消 </el-button>
  367. <div class="ge"></div>
  368. <el-button type="primary" size="small" @click="confirmCoin">
  369. 确 认
  370. </el-button>
  371. </div>
  372. </el-dialog>
  373. </div>
  374. </template>
  375. <script>
  376. import CustomFieldsMixin from "@/mixins/CustomFields";
  377. import { getGoodsList } from "@/api/business/goods";
  378. import { getCouponList } from "@/api/business/coupon";
  379. import { ticketBoxCreate } from "@/api/business/ticket";
  380. import { publicFileGetUrl } from "@/api/common";
  381. import { accMul } from "@/utils/util";
  382. export default {
  383. name: "TicketCreate",
  384. mixins: [CustomFieldsMixin],
  385. data() {
  386. return {
  387. loading: false,
  388. form: {
  389. type: "online", //盲票类型
  390. title: "", // 盲票名称
  391. picUrl: [], // 图片
  392. facePrice: "", // 面值
  393. salePrice: "", // 售价
  394. quantity: "", // 数量
  395. pkgUnit: 200, // 张数
  396. pkgSalePrice: 0, // 单价
  397. saleCommRate: "", // 基数
  398. },
  399. rules: {
  400. type: [
  401. { required: true, message: "请选择盲票类型", trigger: "change" },
  402. ],
  403. title: [
  404. { required: true, message: "请输入盲票组名称", trigger: "blur" },
  405. ],
  406. picUrl: [
  407. {
  408. type: "array",
  409. required: true,
  410. message: "请上传盲票图片",
  411. trigger: "change",
  412. },
  413. ],
  414. facePrice: [
  415. { required: true, message: "请输入面值", trigger: "blur" },
  416. {
  417. pattern:
  418. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  419. message: "请输入合法的金额数字,最多两位小数",
  420. trigger: ["blur", "change"],
  421. },
  422. ],
  423. salePrice: [
  424. { required: true, message: "请输入售价", trigger: "blur" },
  425. {
  426. pattern:
  427. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  428. message: "请输入合法的金额数字,最多两位小数",
  429. trigger: ["blur", "change"],
  430. },
  431. ],
  432. quantity: [
  433. { required: true, message: "请输入数量", trigger: "blur" },
  434. {
  435. pattern: /^([1-9]\d*)$/,
  436. message: "请输入合法的数字",
  437. trigger: ["blur", "change"],
  438. },
  439. ],
  440. pkgUnit: [
  441. { required: true, message: "请输入每包张数", trigger: "blur" },
  442. {
  443. pattern: /^([1-9]\d*)$/,
  444. message: "请输入合法的数字",
  445. trigger: ["blur", "change"],
  446. },
  447. ],
  448. pkgSalePrice: [
  449. { required: true, message: "请输入采购单价", trigger: "blur" },
  450. {
  451. pattern:
  452. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  453. message: "请输入合法的金额数字,最多两位小数",
  454. trigger: ["blur", "change"],
  455. },
  456. ],
  457. saleCommRate: [
  458. { required: true, message: "请输入分佣基数", trigger: "blur" },
  459. {
  460. pattern:
  461. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  462. message: "请输入合法的数字,最多两位小数",
  463. trigger: ["blur", "change"],
  464. },
  465. ],
  466. },
  467. // 奖级列表
  468. awardsList: [
  469. {
  470. name: "奖品一",
  471. sort: 1,
  472. quantity: 0,
  473. prizeList: [],
  474. },
  475. {
  476. name: "奖品二",
  477. sort: 2,
  478. quantity: 0,
  479. prizeList: [],
  480. },
  481. {
  482. name: "奖品三",
  483. sort: 3,
  484. quantity: 0,
  485. prizeList: [],
  486. },
  487. {
  488. name: "奖品四",
  489. sort: 4,
  490. quantity: 0,
  491. prizeList: [],
  492. },
  493. {
  494. name: "奖品五",
  495. sort: 5,
  496. quantity: 0,
  497. prizeList: [],
  498. },
  499. {
  500. name: "奖品六",
  501. sort: 6,
  502. quantity: 0,
  503. prizeList: [],
  504. },
  505. {
  506. name: "奖品七",
  507. sort: 7,
  508. quantity: 0,
  509. prizeList: [],
  510. },
  511. {
  512. name: "奖品八",
  513. sort: 8,
  514. quantity: 0,
  515. prizeList: [],
  516. },
  517. {
  518. name: "奖品九",
  519. sort: 9,
  520. quantity: 0,
  521. prizeList: [],
  522. },
  523. {
  524. name: "奖品十",
  525. sort: 10,
  526. quantity: 0,
  527. prizeList: [],
  528. },
  529. ],
  530. prizeIndex: null, // 奖级下标
  531. goodsTitle: "", // 商品名称
  532. goodsTableVisible: false, // 添加商品弹框
  533. goodsList: [], // 商品列表
  534. goodsTotal: 0, // 商品总数
  535. selectGoodsList: [], // 选中商品
  536. couponTitle: "", // 券名称
  537. couponTableVisible: false, // 添加卡券弹框
  538. couponList: [], // 卡券列表
  539. couponTotal: 0, // 卡券总数
  540. selectCouponList: [], // 选中卡券
  541. coinTableVisible: false, // 添加盲豆弹框
  542. coinForm: { quantity: "" },
  543. coinRules: {
  544. quantity: [
  545. { required: true, message: "请输入数量", trigger: "blur" },
  546. {
  547. pattern: /^([1-9]\d*)$/,
  548. message: "请输入合法的数字",
  549. trigger: ["blur", "change"],
  550. },
  551. ],
  552. },
  553. pageParams: {
  554. pageNum: 1,
  555. pageSize: 10,
  556. },
  557. };
  558. },
  559. created() {
  560. this.getGoodsList();
  561. this.getCouponList();
  562. },
  563. methods: {
  564. // 商品列表
  565. getGoodsList() {
  566. this.loading = true;
  567. getGoodsList(
  568. "pageNum=" +
  569. this.pageParams.pageNum +
  570. "&pageSize=" +
  571. this.pageParams.pageSize +
  572. "&",
  573. { title: this.goodsTitle, status: "on" }
  574. ).then((res) => {
  575. this.goodsList = res.rows.map((item) => {
  576. return {
  577. ...item,
  578. picUrl: publicFileGetUrl + item.picUrl.split(',')[0],
  579. };
  580. });
  581. this.goodsTotal = res.total;
  582. this.loading = false;
  583. });
  584. },
  585. // 卡券列表
  586. getCouponList() {
  587. this.loading = true;
  588. getCouponList(
  589. "pageNum=" +
  590. this.pageParams.pageNum +
  591. "&pageSize=" +
  592. this.pageParams.pageSize +
  593. "&",
  594. { title: this.couponTitle, status: "on" }
  595. ).then((res) => {
  596. this.couponList = res.rows.map((item) => {
  597. return {
  598. ...item,
  599. type: JSON.parse(item.type),
  600. useArea: JSON.parse(item.useArea),
  601. picUrl: publicFileGetUrl + item.picUrl,
  602. };
  603. });
  604. this.couponTotal = res.total;
  605. this.loading = false;
  606. });
  607. },
  608. // 保存
  609. submitForm() {
  610. const subForm = this.$refs["form"];
  611. subForm.validate((valid) => {
  612. if (valid) {
  613. // let prizeIndex = this.awardsList.findIndex((item) => {
  614. // return !item.prizeList.length;
  615. // });
  616. // // 判断没有设置奖品的奖级
  617. // if (prizeIndex != -1) {
  618. // this.$message.error(
  619. // `请设置${this.awardsList[prizeIndex].name}的奖品!`
  620. // );
  621. // return;
  622. // }
  623. let prizeIndex = this.awardsList.findIndex((item) => {
  624. return !item.prizeList.length && item.quantity > 0;
  625. });
  626. // 判断没有设置奖品的奖级
  627. if (prizeIndex != -1) {
  628. this.$message.error(
  629. `请设置${this.awardsList[prizeIndex].name}的奖品!`
  630. );
  631. return;
  632. }
  633. if (this.form.quantity % this.form.pkgUnit != 0) {
  634. this.$message.error("每包数量错误!");
  635. return;
  636. }
  637. let quantityTotal = 0;
  638. this.awardsList.forEach((item) => {
  639. quantityTotal += item.quantity;
  640. });
  641. if (this.form.quantity != quantityTotal) {
  642. this.$message.error("盲票数量和奖品数量不一致!");
  643. return;
  644. }
  645. if (this.form.saleCommRate > 100) {
  646. this.$message.error("分佣基数不能大于100!");
  647. return;
  648. }
  649. this.awardsList.forEach((item) => {
  650. item.prizeList = item.prizeList.map((ele) => {
  651. return {
  652. ...ele,
  653. refId: ele.goodsId || ele.couponId,
  654. prizeType: ele.prizeType,
  655. quantity: ele.quantity,
  656. value: Number(ele.coinValue),
  657. };
  658. });
  659. });
  660. let filterArr = this.awardsList.filter((item) => {
  661. return item.prizeList.length != 0;
  662. });
  663. let filterArr2 = filterArr.filter((item) => {
  664. return item.quantity != 0;
  665. });
  666. let data = {
  667. ...this.form,
  668. picUrl: this.form.picUrl[0].fileName,
  669. facePrice: accMul(this.form.facePrice, 100),
  670. salePrice: accMul(this.form.salePrice, 100),
  671. pkgSalePrice: accMul(this.form.pkgSalePrice, 100),
  672. awardsList: filterArr2,
  673. };
  674. const loading = this.$loading({
  675. lock: true,
  676. text: "保存中",
  677. spinner: "el-icon-loading",
  678. background: "rgba(0, 0, 0, 0.4)",
  679. });
  680. ticketBoxCreate(data)
  681. .then((res) => {
  682. loading.close();
  683. if (res.code == 0) {
  684. this.msgSuccess("保存成功");
  685. this.$store.dispatch("tagsView/delView", this.$route);
  686. this.$router.go(-1);
  687. }
  688. })
  689. .catch(() => {
  690. loading.close();
  691. });
  692. } else {
  693. this.getFormErrorMessage(subForm);
  694. return false;
  695. }
  696. });
  697. },
  698. // 添加图片
  699. pictureSelect(data) {
  700. this.form.picUrl = data;
  701. },
  702. // 改变奖级数量
  703. handleChangeAll(e, item) {
  704. this.$set(item, "quantity", e);
  705. this.$forceUpdate();
  706. // this.getQuantity();
  707. },
  708. // 改变奖品数量
  709. handleChange(e, index) {
  710. this.prizeIndex = index;
  711. this.$forceUpdate();
  712. // this.getQuantity();
  713. },
  714. // 奖级商品删除
  715. handleDel(index, item) {
  716. this.prizeIndex = item.sort - 1;
  717. let list = item.prizeList;
  718. list.splice(index, 1);
  719. this.$set(item, "prizeList", list);
  720. // this.getQuantity();
  721. },
  722. // 关闭弹框
  723. close() {
  724. this.goodsTableVisible = false;
  725. this.couponTableVisible = false;
  726. this.coinTableVisible = false;
  727. this.coinForm.quantity = "";
  728. },
  729. // 添加奖品种类
  730. handleCommand(e, index) {
  731. this.prizeIndex = index;
  732. if (e == "goods") {
  733. this.goodsTableVisible = true;
  734. } else if (e == "coupon") {
  735. this.couponTableVisible = true;
  736. } else if (e == "coin") {
  737. this.coinTableVisible = true;
  738. }
  739. },
  740. // 查询商品
  741. handleQueryGoods() {
  742. this.getGoodsList();
  743. },
  744. // 查询券
  745. handleQueryCoupon() {
  746. this.getCouponList();
  747. },
  748. // 选中商品
  749. handleSelectionGoods(e) {
  750. this.selectGoodsList = e.map((item) => {
  751. return {
  752. prizeType: "goods",
  753. // quantity: 1,
  754. goodsId: item.goodsId,
  755. picUrl: item.picUrl,
  756. title: item.title,
  757. };
  758. });
  759. },
  760. // 选中卡券
  761. handleSelectionCoupon(e) {
  762. this.selectCouponList = e.map((item) => {
  763. return {
  764. prizeType: "coupon",
  765. // quantity: 1,
  766. couponId: item.couponId,
  767. picUrl: item.picUrl,
  768. title: item.title,
  769. };
  770. });
  771. },
  772. // 确认选中商品
  773. confirmGoods() {
  774. this.awardsList[this.prizeIndex].prizeList = this.awardsList[
  775. this.prizeIndex
  776. ].prizeList.concat(this.selectGoodsList);
  777. // this.getQuantity();
  778. this.getGoodsList();
  779. this.close();
  780. },
  781. // 确认选中卡券
  782. confirmCoupon() {
  783. this.awardsList[this.prizeIndex].prizeList = this.awardsList[
  784. this.prizeIndex
  785. ].prizeList.concat(this.selectCouponList);
  786. // this.getQuantity();
  787. this.getCouponList();
  788. this.close();
  789. },
  790. // 确认输入盲豆
  791. confirmCoin() {
  792. let coin = {
  793. prizeType: "coin",
  794. // quantity: 1,
  795. title: `盲豆 x${this.coinForm.quantity}`,
  796. picUrl: publicFileGetUrl + "md.jpeg",
  797. coinValue: this.coinForm.quantity,
  798. };
  799. this.$refs["coinForm"].validate((valid) => {
  800. if (valid) {
  801. this.awardsList[this.prizeIndex].prizeList.push(coin);
  802. // this.getQuantity();
  803. this.close();
  804. } else {
  805. return false;
  806. }
  807. });
  808. },
  809. // 计算奖级数量
  810. getQuantity() {
  811. let num = 0;
  812. this.awardsList[this.prizeIndex].prizeList.forEach((item) => {
  813. num += item.quantity;
  814. });
  815. this.awardsList[this.prizeIndex].quantity = num;
  816. },
  817. // 取消
  818. back() {
  819. this.$store.dispatch("tagsView/delView", this.$route);
  820. this.$router.go(-1);
  821. },
  822. },
  823. };
  824. </script>
  825. <style lang="scss" scoped>
  826. .base-info-title {
  827. padding: 10px;
  828. border-bottom: 1px solid #eaeaea;
  829. margin-bottom: 20px;
  830. }
  831. .tip {
  832. padding-left: 100px;
  833. height: 32px;
  834. margin-bottom: 20px;
  835. color: #828282;
  836. font-size: 14px;
  837. }
  838. .save-btn {
  839. display: flex;
  840. align-content: center;
  841. justify-content: center;
  842. margin-bottom: 100px;
  843. .ge {
  844. width: 100px;
  845. }
  846. }
  847. .prize {
  848. width: 1000px;
  849. margin-bottom: 50px;
  850. background: #f9f9f9;
  851. border: 1px solid #bbbbbb;
  852. font-size: 14px;
  853. &-top {
  854. padding: 10px 20px;
  855. margin-bottom: 10px;
  856. display: flex;
  857. align-content: center;
  858. justify-content: space-around;
  859. border-bottom: 1px solid #bbbbbb;
  860. div {
  861. line-height: 36px;
  862. }
  863. }
  864. &-btn {
  865. border-top: 1px solid #bbbbbb;
  866. padding: 10px;
  867. }
  868. }
  869. .dialog-search {
  870. display: flex;
  871. line-height: 32px;
  872. margin-bottom: 20px;
  873. .ge {
  874. width: 40px;
  875. }
  876. }
  877. .dialog-btn {
  878. display: flex;
  879. align-content: center;
  880. justify-content: flex-end;
  881. padding: 40px 0 0;
  882. .ge {
  883. width: 40px;
  884. }
  885. }
  886. </style>