index.vue 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="直播间ID" prop="liveId">
  5. <el-input
  6. v-model="queryParams.liveId"
  7. placeholder="请输入直播间ID"
  8. clearable
  9. size="small"
  10. :disabled="canLiveId"
  11. @keyup.enter.native="handleQuery"
  12. />
  13. </el-form-item>
  14. <el-form-item label="参与方式" prop="require">
  15. <el-select v-model="queryParams.require" placeholder="请输入参与抽奖方式">
  16. <el-option v-for="(item,index) in requireOptions" :key="item.dictValue+index" :label="item.dictLabel" :value="item.dictValue" />
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="抽奖状态" prop="require">
  20. <el-select v-model="queryParams.lottery_status" placeholder="请输入参与抽奖方式">
  21. <el-option v-for="(item,index) in lotteryStatusOptions" :key="item.dictValue+index" :label="item.dictLabel" :value="item.dictValue" />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item label="抽奖标题" prop="desc">
  25. <el-input
  26. v-model="queryParams.desc"
  27. placeholder="请输入描述"
  28. clearable
  29. size="small"
  30. @keyup.enter.native="handleQuery"
  31. />
  32. </el-form-item>
  33. <el-form-item label="创建日期" prop="createTime">
  34. <el-date-picker clearable size="small"
  35. v-model="queryParams.createTime"
  36. type="date"
  37. value-format="yyyy-MM-dd"
  38. placeholder="选择创建日期">
  39. </el-date-picker>
  40. </el-form-item>
  41. <el-form-item>
  42. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  43. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  44. </el-form-item>
  45. </el-form>
  46. <el-row :gutter="10" class="mb8">
  47. <el-col :span="1.5">
  48. <el-button
  49. type="primary"
  50. plain
  51. icon="el-icon-plus"
  52. size="mini"
  53. @click="handleAdd"
  54. v-hasPermi="['live:liveLotteryConf:add']"
  55. >新增</el-button>
  56. </el-col>
  57. <el-col :span="1.5">
  58. <el-button
  59. type="success"
  60. plain
  61. icon="el-icon-edit"
  62. size="mini"
  63. :disabled="single"
  64. @click="handleUpdate"
  65. v-hasPermi="['live:liveLotteryConf:edit']"
  66. >修改</el-button>
  67. </el-col>
  68. <!-- <el-col :span="1.5">
  69. <el-button
  70. type="danger"
  71. plain
  72. icon="el-icon-delete"
  73. size="mini"
  74. :disabled="multiple"
  75. @click="handleDelete"
  76. v-hasPermi="['live:liveLotteryConf:remove']"
  77. >删除</el-button>
  78. </el-col>-->
  79. <el-col :span="1.5">
  80. <el-button
  81. type="warning"
  82. plain
  83. icon="el-icon-download"
  84. size="mini"
  85. :loading="exportLoading"
  86. @click="handleExport"
  87. v-hasPermi="['live:liveLotteryConf:export']"
  88. >导出</el-button>
  89. </el-col>
  90. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  91. </el-row>
  92. <el-table border v-loading="loading" :data="liveLotteryConfList" @selection-change="handleSelectionChange">
  93. <el-table-column type="selection" width="55" align="center" />
  94. <el-table-column label="抽奖ID" align="center" prop="lotteryId" />
  95. <el-table-column label="操作商品" align="center" class-name="small-padding fixed-width">
  96. <template slot-scope="scope">
  97. <el-button v-if="scope.row.lotteryStatus+'' === '0'" @click="handleUpdateProduct(scope.row)">编辑商品</el-button>
  98. <el-button v-else @click="handleDetailProduct(scope.row)">查看商品</el-button>
  99. </template>
  100. </el-table-column>
  101. <el-table-column label="直播间ID" align="center" prop="liveId" />
  102. <el-table-column label="参与方式" align="center" prop="require" :formatter="requireFormatter"/>
  103. <el-table-column label="抽奖状态" align="center" prop="lotteryStatus" :formatter="lotteryStatusFormatter"/>
  104. <el-table-column label="配置" align="center" prop="requireConf" />
  105. <el-table-column label="持续时间" align="center" prop="duration" />
  106. <el-table-column label="抽奖标题" align="center" prop="desc" />
  107. <el-table-column label="创建日期" align="center" prop="createTime" width="180">
  108. <template slot-scope="scope">
  109. <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
  110. </template>
  111. </el-table-column>
  112. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  113. <template slot-scope="scope">
  114. <el-button
  115. size="mini"
  116. type="text"
  117. icon="el-icon-edit"
  118. @click="handleUpdate(scope.row)"
  119. v-hasPermi="['live:liveLotteryConf:edit']"
  120. style="margin-left: 10px"
  121. >修改</el-button>
  122. <!-- 开始 -->
  123. <el-button
  124. size="mini"
  125. type="text"
  126. icon="el-icon-delete"
  127. @click="handleStatusChange(scope.row,'1')"
  128. v-hasPermi="['live:liveLotteryConf:edit']"
  129. >开始</el-button>
  130. <!-- 暂停 -->
  131. <el-button
  132. size="mini"
  133. type="text"
  134. icon="el-icon-delete"
  135. @click="handleStatusChange(scope.row,'3')"
  136. v-hasPermi="['live:liveLotteryConf:edit']"
  137. >暂停</el-button>
  138. <!-- 结算 -->
  139. <el-button
  140. size="mini"
  141. type="text"
  142. icon="el-icon-delete"
  143. @click="handleStatusChange(scope.row,'2')"
  144. v-hasPermi="['live:liveLotteryConf:edit']"
  145. >结算</el-button>
  146. <el-button
  147. size="mini"
  148. type="text"
  149. icon="el-icon-delete"
  150. @click="handleDelete(scope.row)"
  151. v-hasPermi="['live:liveLotteryConf:edit']"
  152. >删除</el-button>
  153. </template>
  154. </el-table-column>
  155. </el-table>
  156. <pagination
  157. v-show="total>0"
  158. :total="total"
  159. :page.sync="queryParams.pageNum"
  160. :limit.sync="queryParams.pageSize"
  161. @pagination="getList"
  162. />
  163. <!-- 添加或修改直播抽奖配置对话框 -->
  164. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  165. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  166. <el-form-item label="直播间ID" prop="liveId">
  167. <el-input v-model="form.liveId" placeholder="请输入直播间ID"
  168. :disabled="canLiveId"/>
  169. </el-form-item>
  170. <el-form-item label="参与方式" prop="require">
  171. <el-select v-model="form.require" placeholder="请输入参与抽奖方式">
  172. <el-option v-for="(item,index) in requireOptions" :key="item.dictValue+index" :label="item.dictLabel" :value="item.dictValue" />
  173. </el-select>
  174. </el-form-item>
  175. <el-form-item label="方式配置" prop="requireConf">
  176. <el-input v-model="form.requireConf" placeholder="请输入参与抽奖方式" />
  177. <span style="font-size: 10px; font-family: Arial,serif">当参与方式选择为“送礼参与”或“下单参与”时,此处填写商品ID及数量</span>
  178. </el-form-item>
  179. <el-form-item label="持续时间" prop="duration">
  180. <el-input v-model="form.duration" placeholder="请输入持续时间 单位:分" />
  181. </el-form-item>
  182. <el-form-item label="抽奖标题" prop="desc">
  183. <el-input v-model="form.desc" placeholder="请输入描述" />
  184. </el-form-item>
  185. </el-form>
  186. <div slot="footer" class="dialog-footer">
  187. <el-button type="primary" @click="submitForm">确 定</el-button>
  188. <el-button @click="cancel">取 消</el-button>
  189. </div>
  190. </el-dialog>
  191. <el-dialog :title="titleProduct" :visible.sync="openProduct" width="800px" append-to-body>
  192. <el-form ref="form1" :model="form1" :rules="rules1" label-width="100px" :disabled="isDetail">
  193. <!-- 基础信息 -->
  194. <el-row :gutter="20">
  195. <el-col :span="12">
  196. <el-form-item label="抽奖ID" prop="lotteryId">
  197. <el-input v-model="form1.lotteryId" placeholder="请输入抽奖ID" />
  198. </el-form-item>
  199. </el-col>
  200. <el-col :span="12">
  201. <!-- <el-form-item label="直播间ID" prop="liveId">
  202. <el-input v-model="form1.liveId" placeholder="请输入直播间ID" />
  203. </el-form-item>-->
  204. </el-col>
  205. </el-row>
  206. <!-- 动态奖品配置 -->
  207. <el-divider content-position="left">奖品配置</el-divider>
  208. <el-card v-for="(prize, index) in form1.prizes" :key="index" class="prize-card" shadow="hover">
  209. <div slot="header" class="prize-header">
  210. <span><b>奖品等级 :{{ prize.prizeLevel }}</b></span>
  211. <el-button
  212. v-if="form1.prizes.length > 1"
  213. @click="removePrize(index)"
  214. type="danger"
  215. icon="el-icon-delete"
  216. size="mini"
  217. circle
  218. ></el-button>
  219. </div>
  220. <el-row :gutter="20">
  221. <el-col :span="12">
  222. <el-form-item
  223. label="商品ID"
  224. :prop="'prizes.' + index + '.productId'"
  225. :rules="[{ required: true, message: '请输入商品', trigger: 'blur' }]">
  226. <!-- <el-input v-model="prize.productId" placeholder="请输入商品ID" />-->
  227. <el-select
  228. v-model="prize.productId"
  229. filterable
  230. clearable
  231. remote
  232. reserve-keyword
  233. placeholder="请输入关键字搜索"
  234. :remote-method="fetchProducts"
  235. :loading="loadingProducts"
  236. size="small"
  237. style="width: 180px"
  238. >
  239. <el-option
  240. v-for="product in productOptions"
  241. :key="product.goodsId"
  242. :label="product.productName"
  243. :value="product.goodsId"
  244. />
  245. <span style="float: left">{{ product.goodsId }}</span>
  246. <span style="margin-left: 30px ;">{{product.productName}}</span>
  247. </el-select>
  248. </el-form-item>
  249. </el-col>
  250. <el-col :span="12">
  251. <el-form-item
  252. label="奖品等级"
  253. :prop="'prizes.' + index + '.prizeLevel'"
  254. :rules="[{ required: true, message: '请输入奖品等级', trigger: 'blur' }]">
  255. <el-input v-model="prize.prizeLevel" placeholder="请输入奖品等级" />
  256. </el-form-item>
  257. </el-col>
  258. </el-row>
  259. <el-row :gutter="20">
  260. <el-col :span="12">
  261. <el-form-item
  262. label="单奖数量"
  263. :prop="'prizes.' + index + '.perLotteryNum'"
  264. :rules="[
  265. { required: true, message: '请输入单次中奖数量', trigger: 'blur' },
  266. { type: 'number', message: '必须为数字值' }
  267. ]">
  268. <el-input-number
  269. v-model="prize.perLotteryNum"
  270. :min="1"
  271. :max="100"
  272. controls-position="right"
  273. placeholder="单次中奖数量" />
  274. </el-form-item>
  275. </el-col>
  276. <el-col :span="12">
  277. <el-form-item
  278. label="奖励总份数"
  279. :prop="'prizes.' + index + '.totalLots'"
  280. :rules="[
  281. { required: true, message: '请输入奖励总份数', trigger: 'blur' },
  282. { type: 'number', message: '必须为数字值' }
  283. ]">
  284. <el-input-number
  285. v-model="prize.totalLots"
  286. :min="1"
  287. controls-position="right"
  288. placeholder="奖励总份数" />
  289. </el-form-item>
  290. </el-col>
  291. </el-row>
  292. <el-row :gutter="20">
  293. <el-col :span="12">
  294. <el-form-item
  295. label="实发份数"
  296. :prop="'prizes.' + index + '.totalSend'"
  297. >
  298. <el-input-number
  299. v-model="prize.totalSend"
  300. :min="0"
  301. :max="prize.totalLots"
  302. controls-position="right"
  303. placeholder="实际发放份数"
  304. :disabled="true"/>
  305. </el-form-item>
  306. </el-col>
  307. </el-row>
  308. </el-card>
  309. <div class="add-prize-btn">
  310. <el-button
  311. @click="addPrize"
  312. type="primary"
  313. icon="el-icon-plus"
  314. plain
  315. size="small">
  316. 添加奖品配置
  317. </el-button>
  318. </div>
  319. </el-form>
  320. <div slot="footer" class="dialog-footer">
  321. <el-button @click="cancel1">取 消</el-button>
  322. <el-button type="primary" @click="submitForm1">确 定</el-button>
  323. </div>
  324. </el-dialog>
  325. </div>
  326. </template>
  327. <script>
  328. import { listLiveLotteryConf, getLiveLotteryConf, delLiveLotteryConf, addLiveLotteryConf, updateLiveLotteryConf, exportLiveLotteryConf } from "@/api/live/liveLotteryConf";
  329. import LiveLotteryProductConf from '@/views/live/liveLotteryProductConf/index.vue'
  330. import {
  331. listStoreProduct,
  332. updateLiveLotteryProductConf
  333. } from '@/api/live/liveLotteryProductConf'
  334. import { listLiveGoods } from '@/api/live/liveGoods'
  335. export default {
  336. name: "LiveLotteryConf",
  337. components: { LiveLotteryProductConf },
  338. data() {
  339. return {
  340. //字典
  341. requireOptions: [],
  342. // 抽奖状态
  343. lotteryStatusOptions: [],
  344. //加载商品
  345. loadingProducts: false,
  346. //
  347. productOptions: [],
  348. isDetail: false,
  349. canLiveId:false,
  350. //parentLiveId
  351. parentLiveId : null,
  352. liveId: null,
  353. // 遮罩层
  354. loading: true,
  355. // 导出遮罩层
  356. exportLoading: false,
  357. // 选中数组
  358. ids: [],
  359. // 非单个禁用
  360. single: true,
  361. // 非多个禁用
  362. multiple: true,
  363. // 显示搜索条件
  364. showSearch: true,
  365. // 总条数
  366. total: 0,
  367. // 直播抽奖配置表格数据
  368. liveLotteryConfList: [],
  369. // 弹出层标题
  370. title: "",
  371. titleProduct: "编辑抽奖商品",
  372. // 是否显示弹出层
  373. open: false,
  374. openProduct: false,
  375. // 查询参数
  376. queryParams: {
  377. pageNum: 1,
  378. pageSize: 10,
  379. liveId: null,
  380. require: null,
  381. desc: null,
  382. createTime: null,
  383. lottery_status: null
  384. },
  385. //商品信息列表
  386. productList: [],
  387. // 商品信息
  388. product: {
  389. productId: null,
  390. prizeLevel: null,
  391. perLotteryNum: null,
  392. totalLots: null,
  393. totalSend: null
  394. },
  395. // 表单参数
  396. form:{
  397. lotteryId: '',
  398. liveId: '',
  399. require: '',
  400. requireConf: '',
  401. duration: null,
  402. desc: null
  403. },
  404. // 表单参数
  405. form1: {
  406. liveId: '',
  407. lotteryId: '',
  408. prizes: [this.getDefaultPrize()]
  409. },
  410. // 表单校验
  411. rules: {
  412. liveId: [
  413. { required: true, message: "直播间ID不能为空", trigger: "blur" }
  414. ],
  415. require: [
  416. { required: true, message: "参与抽奖方式", trigger: "blur" }
  417. ],
  418. //如果require为2或3,requireConf不能为空
  419. requireConf: [
  420. { validator: this.validRequireConf,message: "当参与方式选择为“送礼参与”或“下单参与”时,对应的配置:送礼数量/指定商品Id及数量不能为空", trigger: "blur" }
  421. ],
  422. duration: [
  423. { required: true, message: "持续时间 单位:分不能为空", trigger: "blur" }
  424. ],
  425. desc: [
  426. { required: true, message: "描述不能为空", trigger: "blur" }
  427. ],
  428. },
  429. //抽奖商品表单
  430. rules1: {
  431. lotteryId: [
  432. { required: true, message: '请输入抽奖ID', trigger: 'blur' }
  433. ],
  434. liveId: [
  435. { required: true, message: '请输入直播间ID', trigger: 'blur' }
  436. ]
  437. }
  438. };
  439. },
  440. created() {
  441. this.getDicts("sys_live_lottery_require").then(response => {
  442. this.requireOptions = response.data;
  443. });
  444. this.getDicts("sys_live_lottery_status").then(response => {
  445. this.lotteryStatusOptions = response.data;
  446. });
  447. this.liveId = this.$route.query.liveId;
  448. this.parentLiveId = this.liveId;
  449. this.queryParams.liveId = this.parentLiveId;
  450. if(this.queryParams.liveId){
  451. this.form.liveId = this.parentLiveId;
  452. //设置查询条件直播间ID不可修改
  453. this.canLiveId = true;
  454. }
  455. this.getList();
  456. },
  457. mounted() {
  458. this.$watch(
  459. () => this.form.require,
  460. (newVal) => {
  461. this.$refs.form.validateField('requireConf');
  462. }
  463. );
  464. },
  465. methods: {
  466. async fetchProducts(query) {
  467. if (!query) {
  468. this.productOptions = [];
  469. return;
  470. }
  471. const queryParam = {
  472. liveId : this.liveId,
  473. keywords: query
  474. }
  475. this.loadingProducts = true;
  476. try {
  477. listLiveGoods(queryParam).then(response => {
  478. this.productOptions = response.rows;
  479. })
  480. } catch (err) {
  481. console.error('查询商品失败:', err);
  482. this.productOptions = [];
  483. } finally {
  484. this.loadingProducts = false;
  485. }
  486. },
  487. // 获取默认奖品配置
  488. getDefaultPrize() {
  489. return {
  490. productId: '',
  491. prizeLevel: '',
  492. perLotteryNum: 1,
  493. totalLots: 1,
  494. totalSend: 0
  495. }
  496. },
  497. // 添加奖品配置
  498. addPrize() {
  499. this.form1.prizes.push(this.getDefaultPrize())
  500. },
  501. // 删除奖品配置
  502. removePrize(index) {
  503. if (this.form1.prizes.length <= 1) {
  504. this.$message.warning('至少需要保留一个奖品配置')
  505. return
  506. }
  507. this.form1.prizes.splice(index, 1)
  508. },
  509. requireFormatter(row, column) {
  510. return this.selectDictLabel(this.requireOptions, row.require);
  511. },
  512. lotteryStatusFormatter(row, column) {
  513. return this.selectDictLabel(this.lotteryStatusOptions, row.lotteryStatus);
  514. },
  515. validRequireConf(rule, value, callback) {
  516. if(this.form.require+"" === "2" || this.form.require+"" === "3"){
  517. if(!value){
  518. callback(new Error());
  519. return false;
  520. }
  521. }
  522. callback();
  523. return true;
  524. },
  525. /** 查询直播抽奖配置列表 */
  526. getList() {
  527. this.loading = true;
  528. listLiveLotteryConf(this.queryParams).then(response => {
  529. this.liveLotteryConfList = response.rows;
  530. this.total = response.total;
  531. this.loading = false;
  532. });
  533. },
  534. // 取消按钮
  535. cancel() {
  536. this.open = false;
  537. this.reset();
  538. },
  539. // 取消
  540. cancel1() {
  541. this.openProduct = false;
  542. },
  543. // 重置表单
  544. resetForm1() {
  545. this.form1 = {
  546. lotteryId: '',
  547. liveId: '',
  548. prizes: [this.getDefaultPrize()]
  549. }
  550. },
  551. // 表单重置
  552. reset() {
  553. this.form = {
  554. lotteryId: null,
  555. liveId: null,
  556. require: null,
  557. requireConf: null,
  558. duration: null,
  559. desc: null
  560. };
  561. this.resetForm("form");
  562. this.checkParentLiveId();
  563. },
  564. /** 搜索按钮操作 */
  565. handleQuery() {
  566. this.queryParams.pageNum = 1;
  567. this.getList();
  568. },
  569. /** 重置按钮操作 */
  570. resetQuery() {
  571. this.resetForm("queryForm");
  572. this.checkParentLiveId();
  573. this.handleQuery();
  574. },
  575. //判断父页面传入参数
  576. checkParentLiveId(){
  577. if(this.parentLiveId){
  578. this.form.liveId = this.parentLiveId;
  579. this.queryParams.liveId = this.parentLiveId;
  580. }
  581. },
  582. // 多选框选中数据
  583. handleSelectionChange(selection) {
  584. this.ids = selection.map(item => item.lotteryId)
  585. this.single = selection.length!==1
  586. this.multiple = !selection.length
  587. },
  588. /** 新增按钮操作 */
  589. handleAdd() {
  590. this.reset();
  591. this.open = true;
  592. this.title = "添加直播抽奖配置";
  593. },
  594. /** 修改按钮操作 */
  595. handleUpdate(row) {
  596. this.reset();
  597. const lotteryId = row.lotteryId || this.ids
  598. //只能对未开始或暂停的抽奖进行修改
  599. if(row.lotteryStatus+"" !== "0" && row.lotteryStatus+"" !== "3"){
  600. this.msgError("只能对未开始或暂停的抽奖进行修改");
  601. return;
  602. }
  603. getLiveLotteryConf(lotteryId).then(response => {
  604. this.form = response.data;
  605. this.open = true;
  606. this.title = "修改直播抽奖配置";
  607. });
  608. },
  609. /** 修改按钮操作 */
  610. handleUpdateProduct(row) {
  611. this.form1.lotteryId = row.lotteryId;
  612. //如果状态为已结束,则不能修改
  613. if(row.lotteryStatus+"" === "2"){
  614. this.msgError("已结束的抽奖不能修改");
  615. return;
  616. }
  617. this.openProduct = true;
  618. this.isDetail = false;
  619. listStoreProduct(row.lotteryId).then(response => {
  620. this.form1 = response.data;
  621. if(this.form1.prizes.length === 0)
  622. this.form1.prizes = [this.getDefaultPrize()]
  623. this.form1.liveId = row.liveId;
  624. });
  625. },
  626. /** 详情按钮操作 */
  627. handleDetailProduct(row) {
  628. this.form1.lotteryId = row.lotteryId;
  629. //如果状态为已结束,则不能修改
  630. if(row.status+"" === "2"){
  631. this.msgError("已结束的抽奖不能修改");
  632. return;
  633. }
  634. this.openProduct = true;
  635. this.isDetail = true;
  636. listStoreProduct(row.lotteryId).then(response => {
  637. this.form1 = response.data;
  638. this.form1.liveId = row.liveId;
  639. });
  640. },
  641. /** 抽奖状态修改 */
  642. handleStatusChange(row, status) {
  643. //结束的抽奖不能进行操作
  644. if(row.lotteryStatus+"" === "2"){
  645. this.msgError("已结束的抽奖不能进行操作");
  646. return;
  647. }
  648. switch (status+"") {
  649. case "1":
  650. //只能对未开启的抽奖进行操作
  651. if(row.lotteryStatus+"" !== "0" && row.lotteryStatus+"" !== "3"){
  652. this.msgError("只能对未开启或暂停的抽奖进行开始操作");
  653. return;
  654. }
  655. break;
  656. case "2":
  657. //只能对进行中或暂停的抽奖进行结算
  658. if(row.lotteryStatus+"" !== "1" && row.lotteryStatus+"" !== "3"){
  659. this.msgError("只能对进行中或暂停的抽奖进行结算");
  660. return;
  661. }
  662. break;
  663. case "3":
  664. //只能对进行中的抽奖执行暂停操作
  665. if(row.lotteryStatus+"" !== "1"){
  666. this.msgError("只能对进行中的抽奖执行暂停操作");
  667. return;
  668. }
  669. break;
  670. default:
  671. return;
  672. }
  673. const doLotteryParam = {
  674. lotteryId: row.lotteryId,
  675. lotteryStatus: status
  676. };
  677. updateLiveLotteryConf(doLotteryParam).then(response => {
  678. if(response.code === 200){
  679. this.$store.state.liveWs.sendWs("lottery",response.msg, row.lotteryId,this.liveId);
  680. this.msgSuccess("修改成功");
  681. }else{
  682. this.msgError(response.msg);
  683. }
  684. this.open = false;
  685. this.getList();
  686. });
  687. },
  688. /** 提交按钮 */
  689. submitForm() {
  690. console.log("this.submitForm()")
  691. this.$refs["form"].validate(valid => {
  692. if (valid) {
  693. if (this.form.lotteryId != null) {
  694. updateLiveLotteryConf(this.form).then(response => {
  695. this.msgSuccess("修改成功");
  696. this.open = false;
  697. this.getList();
  698. });
  699. } else {
  700. addLiveLotteryConf(this.form).then(response => {
  701. this.msgSuccess("新增成功");
  702. this.open = false;
  703. this.getList();
  704. });
  705. }
  706. }
  707. });
  708. },
  709. submitForm1() {
  710. this.$refs["form1"].validate(valid => {
  711. if (valid) {
  712. updateLiveLotteryProductConf(this.form1).then(response => {
  713. //200 成功
  714. this.msgSuccess("保存成功");
  715. this.openProduct = false;
  716. this.resetForm1();
  717. });
  718. }
  719. });
  720. },
  721. /** 删除按钮操作 */
  722. handleDelete(row) {
  723. //如果抽奖状态不为0,则不能删除
  724. if(row.lotteryStatus+"" !== "0"){
  725. this.msgError("只能删除未开始的抽奖配置");
  726. return;
  727. }
  728. const lotteryIds = row.lotteryId || this.ids;
  729. this.$confirm('是否确认删除直播抽奖配置编号为"' + lotteryIds + '"的数据项?', "警告", {
  730. confirmButtonText: "确定",
  731. cancelButtonText: "取消",
  732. type: "warning"
  733. }).then(function() {
  734. return delLiveLotteryConf(lotteryIds);
  735. }).then(() => {
  736. this.getList();
  737. this.msgSuccess("删除成功");
  738. }).catch(() => {});
  739. },
  740. /** 导出按钮操作 */
  741. handleExport() {
  742. const queryParams = this.queryParams;
  743. this.$confirm('是否确认导出所有直播抽奖配置数据项?', "警告", {
  744. confirmButtonText: "确定",
  745. cancelButtonText: "取消",
  746. type: "warning"
  747. }).then(() => {
  748. this.exportLoading = true;
  749. return exportLiveLotteryConf(queryParams);
  750. }).then(response => {
  751. this.download(response.msg);
  752. this.exportLoading = false;
  753. }).catch(() => {});
  754. }
  755. }
  756. };
  757. </script>
  758. <style scoped>
  759. .prize-card {
  760. margin-bottom: 20px;
  761. }
  762. .prize-header {
  763. display: flex;
  764. justify-content: space-between;
  765. align-items: center;
  766. }
  767. .add-prize-btn {
  768. margin-top: 10px;
  769. text-align: center;
  770. }
  771. .dialog-footer {
  772. text-align: right;
  773. }
  774. </style>