create.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925
  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="奖品图片">
  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.value) }}</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. width="500px"
  351. >
  352. <el-form
  353. :model="coinForm"
  354. :rules="coinRules"
  355. ref="coinForm"
  356. label-width="100px"
  357. >
  358. <el-form-item label="盲豆数量" prop="quantity">
  359. <el-input
  360. v-model="coinForm.quantity"
  361. size="small"
  362. placeholder="请输入盲豆数量"
  363. style="width: 200px"
  364. />
  365. </el-form-item>
  366. </el-form>
  367. <div class="dialog-btn">
  368. <el-button size="small" @click="close"> 取 消 </el-button>
  369. <div class="ge"></div>
  370. <el-button type="primary" size="small" @click="confirmCoin">
  371. 确 认
  372. </el-button>
  373. </div>
  374. </el-dialog>
  375. </div>
  376. </template>
  377. <script>
  378. import CustomFieldsMixin from "@/mixins/CustomFields";
  379. import { getGoodsList } from "@/api/business/goods";
  380. import { getCouponList } from "@/api/business/coupon";
  381. import { ticketBoxCreate } from "@/api/business/ticket";
  382. import { publicFileGetUrl } from "@/api/common";
  383. import { accMul } from "@/utils/util";
  384. export default {
  385. name: "TicketCreate",
  386. mixins: [CustomFieldsMixin],
  387. data() {
  388. return {
  389. loading: false,
  390. form: {
  391. type: "online", //盲票类型
  392. title: "", // 盲票名称
  393. picUrl: [], // 图片
  394. facePrice: "", // 面值
  395. salePrice: "", // 售价
  396. quantity: "", // 数量
  397. pkgUnit: 200, // 张数
  398. pkgSalePrice: 0, // 单价
  399. saleCommRate: "", // 基数
  400. },
  401. rules: {
  402. type: [
  403. { required: true, message: "请选择盲票类型", trigger: "change" },
  404. ],
  405. title: [
  406. { required: true, message: "请输入盲票组名称", trigger: "blur" },
  407. ],
  408. picUrl: [
  409. {
  410. type: "array",
  411. required: true,
  412. message: "请上传盲票图片",
  413. trigger: "change",
  414. },
  415. ],
  416. facePrice: [
  417. { required: true, message: "请输入面值", trigger: "blur" },
  418. {
  419. pattern:
  420. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  421. message: "请输入合法的金额数字,最多两位小数",
  422. trigger: ["blur", "change"],
  423. },
  424. ],
  425. salePrice: [
  426. { required: true, message: "请输入售价", trigger: "blur" },
  427. {
  428. pattern:
  429. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  430. message: "请输入合法的金额数字,最多两位小数",
  431. trigger: ["blur", "change"],
  432. },
  433. ],
  434. quantity: [
  435. { required: true, message: "请输入数量", trigger: "blur" },
  436. {
  437. pattern: /^([1-9]\d*)$/,
  438. message: "请输入合法的数字",
  439. trigger: ["blur", "change"],
  440. },
  441. ],
  442. pkgUnit: [
  443. { required: true, message: "请输入每包张数", trigger: "blur" },
  444. {
  445. pattern: /^([1-9]\d*)$/,
  446. message: "请输入合法的数字",
  447. trigger: ["blur", "change"],
  448. },
  449. ],
  450. pkgSalePrice: [
  451. { required: true, message: "请输入采购单价", trigger: "blur" },
  452. {
  453. pattern:
  454. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  455. message: "请输入合法的金额数字,最多两位小数",
  456. trigger: ["blur", "change"],
  457. },
  458. ],
  459. saleCommRate: [
  460. { required: true, message: "请输入分佣基数", trigger: "blur" },
  461. {
  462. pattern:
  463. /^([1-9]\d*(\.\d{1,2})?|([0](\.([0][1-9]|[1-9]\d{0,1}))))$/,
  464. message: "请输入合法的数字,最多两位小数",
  465. trigger: ["blur", "change"],
  466. },
  467. ],
  468. },
  469. // 奖级列表
  470. awardsList: [
  471. {
  472. name: "奖品一",
  473. sort: 1,
  474. quantity: 0,
  475. prizeList: [],
  476. },
  477. {
  478. name: "奖品二",
  479. sort: 2,
  480. quantity: 0,
  481. prizeList: [],
  482. },
  483. {
  484. name: "奖品三",
  485. sort: 3,
  486. quantity: 0,
  487. prizeList: [],
  488. },
  489. {
  490. name: "奖品四",
  491. sort: 4,
  492. quantity: 0,
  493. prizeList: [],
  494. },
  495. {
  496. name: "奖品五",
  497. sort: 5,
  498. quantity: 0,
  499. prizeList: [],
  500. },
  501. {
  502. name: "奖品六",
  503. sort: 6,
  504. quantity: 0,
  505. prizeList: [],
  506. },
  507. {
  508. name: "奖品七",
  509. sort: 7,
  510. quantity: 0,
  511. prizeList: [],
  512. },
  513. {
  514. name: "奖品八",
  515. sort: 8,
  516. quantity: 0,
  517. prizeList: [],
  518. },
  519. {
  520. name: "奖品九",
  521. sort: 9,
  522. quantity: 0,
  523. prizeList: [],
  524. },
  525. {
  526. name: "奖品十",
  527. sort: 10,
  528. quantity: 0,
  529. prizeList: [],
  530. },
  531. ],
  532. prizeIndex: null, // 奖级下标
  533. goodsTitle: "", // 商品名称
  534. goodsTableVisible: false, // 添加商品弹框
  535. goodsList: [], // 商品列表
  536. goodsTotal: 0, // 商品总数
  537. selectGoodsList: [], // 选中商品
  538. couponTitle: "", // 券名称
  539. couponTableVisible: false, // 添加卡券弹框
  540. couponList: [], // 卡券列表
  541. couponTotal: 0, // 卡券总数
  542. selectCouponList: [], // 选中卡券
  543. coinTableVisible: false, // 添加盲豆弹框
  544. coinForm: { quantity: "" },
  545. coinRules: {
  546. quantity: [
  547. { required: true, message: "请输入数量", trigger: "blur" },
  548. {
  549. pattern: /^([1-9]\d*)$/,
  550. message: "请输入合法的数字",
  551. trigger: ["blur", "change"],
  552. },
  553. ],
  554. },
  555. pageParams: {
  556. pageNum: 1,
  557. pageSize: 10,
  558. },
  559. };
  560. },
  561. created() {
  562. this.getGoodsList();
  563. this.getCouponList();
  564. },
  565. methods: {
  566. // 商品列表
  567. getGoodsList() {
  568. this.loading = true;
  569. getGoodsList(
  570. "pageNum=" +
  571. this.pageParams.pageNum +
  572. "&pageSize=" +
  573. this.pageParams.pageSize +
  574. "&",
  575. { title: this.goodsTitle, status: "on" }
  576. ).then((res) => {
  577. this.goodsList = res.rows.map((item) => {
  578. return {
  579. ...item,
  580. picUrl: publicFileGetUrl + item.picUrl.split(',')[0],
  581. };
  582. });
  583. this.goodsTotal = res.total;
  584. this.loading = false;
  585. });
  586. },
  587. // 卡券列表
  588. getCouponList() {
  589. this.loading = true;
  590. getCouponList(
  591. "pageNum=" +
  592. this.pageParams.pageNum +
  593. "&pageSize=" +
  594. this.pageParams.pageSize +
  595. "&",
  596. { title: this.couponTitle, status: "on" }
  597. ).then((res) => {
  598. this.couponList = res.rows.map((item) => {
  599. return {
  600. ...item,
  601. type: JSON.parse(item.type),
  602. useArea: JSON.parse(item.useArea),
  603. picUrl: publicFileGetUrl + item.picUrl,
  604. };
  605. });
  606. this.couponTotal = res.total;
  607. this.loading = false;
  608. });
  609. },
  610. // 保存
  611. submitForm() {
  612. const subForm = this.$refs["form"];
  613. subForm.validate((valid) => {
  614. if (valid) {
  615. // let prizeIndex = this.awardsList.findIndex((item) => {
  616. // return !item.prizeList.length;
  617. // });
  618. // // 判断没有设置奖品的奖级
  619. // if (prizeIndex != -1) {
  620. // this.$message.error(
  621. // `请设置${this.awardsList[prizeIndex].name}的奖品!`
  622. // );
  623. // return;
  624. // }
  625. let prizeIndex = this.awardsList.findIndex((item) => {
  626. return !item.prizeList.length && item.quantity > 0;
  627. });
  628. // 判断没有设置奖品的奖级
  629. if (prizeIndex != -1) {
  630. this.$message.error(
  631. `请设置${this.awardsList[prizeIndex].name}的奖品!`
  632. );
  633. return;
  634. }
  635. if (this.form.quantity % this.form.pkgUnit != 0) {
  636. this.$message.error("每包数量错误!");
  637. return;
  638. }
  639. let quantityTotal = 0;
  640. this.awardsList.forEach((item) => {
  641. quantityTotal += item.quantity;
  642. });
  643. if (this.form.quantity != quantityTotal) {
  644. this.$message.error("盲票数量和奖品数量不一致!");
  645. return;
  646. }
  647. // if (this.form.saleCommRate > 100) {
  648. // this.$message.error("分佣基数不能大于100!");
  649. // return;
  650. // }
  651. this.awardsList.forEach((item) => {
  652. item.prizeList = item.prizeList.map((ele) => {
  653. return {
  654. ...ele,
  655. refId: ele.goodsId || ele.couponId,
  656. prizeType: ele.prizeType,
  657. quantity: ele.quantity,
  658. value: Number(ele.coinValue),
  659. };
  660. });
  661. });
  662. let filterArr = this.awardsList.filter((item) => {
  663. return item.prizeList.length != 0;
  664. });
  665. let filterArr2 = filterArr.filter((item) => {
  666. return item.quantity != 0;
  667. });
  668. let data = {
  669. ...this.form,
  670. picUrl: this.form.picUrl[0].fileName,
  671. facePrice: accMul(this.form.facePrice, 100),
  672. salePrice: accMul(this.form.salePrice, 100),
  673. pkgSalePrice: accMul(this.form.pkgSalePrice, 100),
  674. awardsList: filterArr2,
  675. };
  676. const loading = this.$loading({
  677. lock: true,
  678. text: "保存中",
  679. spinner: "el-icon-loading",
  680. background: "rgba(0, 0, 0, 0.4)",
  681. });
  682. ticketBoxCreate(data)
  683. .then((res) => {
  684. loading.close();
  685. if (res.code == 0) {
  686. this.msgSuccess("保存成功");
  687. this.$store.dispatch("tagsView/delView", this.$route);
  688. this.$router.go(-1);
  689. }
  690. })
  691. .catch(() => {
  692. loading.close();
  693. });
  694. } else {
  695. this.getFormErrorMessage(subForm);
  696. return false;
  697. }
  698. });
  699. },
  700. // 添加图片
  701. pictureSelect(data) {
  702. this.form.picUrl = data;
  703. },
  704. // 改变奖级数量
  705. handleChangeAll(e, item) {
  706. this.$set(item, "quantity", e);
  707. this.$forceUpdate();
  708. // this.getQuantity();
  709. },
  710. // 改变奖品数量
  711. handleChange(e, index) {
  712. this.prizeIndex = index;
  713. this.$forceUpdate();
  714. // this.getQuantity();
  715. },
  716. // 奖级商品删除
  717. handleDel(index, item) {
  718. this.prizeIndex = item.sort - 1;
  719. let list = item.prizeList;
  720. list.splice(index, 1);
  721. this.$set(item, "prizeList", list);
  722. // this.getQuantity();
  723. },
  724. // 关闭弹框
  725. close() {
  726. this.goodsTableVisible = false;
  727. this.couponTableVisible = false;
  728. this.coinTableVisible = false;
  729. this.coinForm.quantity = "";
  730. },
  731. // 添加奖品种类
  732. handleCommand(e, index) {
  733. this.prizeIndex = index;
  734. if (e == "goods") {
  735. this.goodsTableVisible = true;
  736. } else if (e == "coupon") {
  737. this.couponTableVisible = true;
  738. } else if (e == "coin") {
  739. this.coinTableVisible = true;
  740. }
  741. },
  742. // 查询商品
  743. handleQueryGoods() {
  744. this.getGoodsList();
  745. },
  746. // 查询券
  747. handleQueryCoupon() {
  748. this.getCouponList();
  749. },
  750. // 选中商品
  751. handleSelectionGoods(e) {
  752. this.selectGoodsList = e.map((item) => {
  753. return {
  754. prizeType: "goods",
  755. // quantity: 1,
  756. goodsId: item.goodsId,
  757. picUrl: item.picUrl,
  758. title: item.title,
  759. };
  760. });
  761. },
  762. // 选中卡券
  763. handleSelectionCoupon(e) {
  764. this.selectCouponList = e.map((item) => {
  765. return {
  766. prizeType: "coupon",
  767. // quantity: 1,
  768. couponId: item.couponId,
  769. picUrl: item.picUrl,
  770. title: item.title,
  771. };
  772. });
  773. },
  774. // 确认选中商品
  775. confirmGoods() {
  776. this.awardsList[this.prizeIndex].prizeList = this.awardsList[
  777. this.prizeIndex
  778. ].prizeList.concat(this.selectGoodsList);
  779. // this.getQuantity();
  780. this.getGoodsList();
  781. this.close();
  782. },
  783. // 确认选中卡券
  784. confirmCoupon() {
  785. this.awardsList[this.prizeIndex].prizeList = this.awardsList[
  786. this.prizeIndex
  787. ].prizeList.concat(this.selectCouponList);
  788. // this.getQuantity();
  789. this.getCouponList();
  790. this.close();
  791. },
  792. // 确认输入盲豆
  793. confirmCoin() {
  794. let coin = {
  795. prizeType: "coin",
  796. // quantity: 1,
  797. title: `盲豆 x${this.coinForm.quantity}`,
  798. picUrl: publicFileGetUrl + "md.jpeg",
  799. coinValue: this.coinForm.quantity,
  800. };
  801. this.$refs["coinForm"].validate((valid) => {
  802. if (valid) {
  803. this.awardsList[this.prizeIndex].prizeList.push(coin);
  804. // this.getQuantity();
  805. this.close();
  806. } else {
  807. return false;
  808. }
  809. });
  810. },
  811. // 计算奖级数量
  812. getQuantity() {
  813. let num = 0;
  814. this.awardsList[this.prizeIndex].prizeList.forEach((item) => {
  815. num += item.quantity;
  816. });
  817. this.awardsList[this.prizeIndex].quantity = num;
  818. },
  819. // 取消
  820. back() {
  821. this.$store.dispatch("tagsView/delView", this.$route);
  822. this.$router.go(-1);
  823. },
  824. },
  825. };
  826. </script>
  827. <style lang="scss" scoped>
  828. .base-info-title {
  829. padding: 10px;
  830. border-bottom: 1px solid #eaeaea;
  831. margin-bottom: 20px;
  832. }
  833. .tip {
  834. padding-left: 100px;
  835. height: 32px;
  836. margin-bottom: 20px;
  837. color: #828282;
  838. font-size: 14px;
  839. }
  840. .save-btn {
  841. display: flex;
  842. align-content: center;
  843. justify-content: center;
  844. margin-bottom: 100px;
  845. .ge {
  846. width: 100px;
  847. }
  848. }
  849. .prize {
  850. width: 1000px;
  851. margin-bottom: 50px;
  852. background: #f9f9f9;
  853. border: 1px solid #bbbbbb;
  854. font-size: 14px;
  855. &-top {
  856. padding: 10px 20px;
  857. margin-bottom: 10px;
  858. display: flex;
  859. align-content: center;
  860. justify-content: space-around;
  861. border-bottom: 1px solid #bbbbbb;
  862. div {
  863. line-height: 36px;
  864. }
  865. }
  866. &-btn {
  867. border-top: 1px solid #bbbbbb;
  868. padding: 10px;
  869. }
  870. }
  871. .dialog-search {
  872. display: flex;
  873. line-height: 32px;
  874. margin-bottom: 20px;
  875. .ge {
  876. width: 40px;
  877. }
  878. }
  879. .dialog-btn {
  880. display: flex;
  881. align-content: center;
  882. justify-content: flex-end;
  883. padding: 40px 0 0;
  884. .ge {
  885. width: 40px;
  886. }
  887. }
  888. </style>