lotteryDataList.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  1. <template>
  2. <div class="app-container calendar-list-container">
  3. <!-- 查询和其他操作 -->
  4. <div class="filter-container">
  5. <el-select @change="changepoolId" v-model="listQuery.poolId" placeholder="奖池" class="filter-item"
  6. style="width: 200px">
  7. <el-option :key="item.id" v-for="item in dictNameList" :label="item.title" :value="item.id">
  8. </el-option>
  9. </el-select>
  10. <el-button class="filter-item" type="primary" v-waves icon="el-icon-search"
  11. @click="handleFilter">查找</el-button>
  12. <el-button class="filter-item" type="primary" @click="handleCreate" icon="el-icon-edit">添加</el-button>
  13. <!-- <el-button class="filter-item" type="warning" icon="el-icon-delete" @click="delAll">批量删除</el-button> -->
  14. </div>
  15. <!-- 查询结果 -->
  16. <el-table size="small" :data="list" v-loading="listLoading" @selection-change="handleSelectionChange"
  17. element-loading-text="正在查询中。。。" border fit highlight-current-row>
  18. <!-- <el-table-column type="selection" width="55px"> </el-table-column> -->
  19. <el-table-column align="center" min-width="100px" label="奖品类型" prop="prizeTypeName">
  20. </el-table-column>
  21. <el-table-column align="center" min-width="150px" label="奖品名称" prop="prizeName">
  22. </el-table-column>
  23. <el-table-column align="center" min-width="150px" label="商品券">
  24. <template slot-scope="scope">
  25. <span v-if="scope.row.couponVo">{{ scope.row.couponVo.couponName }}</span>
  26. <span v-else>无</span>
  27. </template>
  28. </el-table-column>
  29. <el-table-column align="center" min-width="100px" label="奖励积分" prop="integral">
  30. </el-table-column>
  31. <el-table-column align="center" min-width="100px" label="奖品权重" prop="prizeWeight">
  32. </el-table-column>
  33. <el-table-column align="center" min-width="100px" label="奖品数量" prop="prizeActualStock">
  34. </el-table-column>
  35. <el-table-column align="center" min-width="100px" label="剩余数量" prop="prizeStock">
  36. </el-table-column>
  37. <el-table-column align="center" min-width="100px" label="是否大奖">
  38. <template slot-scope="scope">
  39. <span v-if="scope.row.isGrandPrize == '0'">否</span>
  40. <span v-if="scope.row.isGrandPrize == '1'">是</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column align="center" min-width="100px" label="状态">
  44. <template slot-scope="scope">
  45. <span v-if="scope.row.status == '0'">关闭</span>
  46. <span v-else>开启</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column align="center" label="操作" width="240px" class-name="small-padding fixed-width">
  50. <template slot-scope="scope">
  51. <el-button type="primary" size="small" @click="handleUpdate(scope.row, false)">编辑</el-button>
  52. <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <!-- 分页 -->
  57. <div class="pagination-container">
  58. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  59. :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50]" :page-size="listQuery.limit"
  60. layout="total, sizes, prev, pager, next, jumper" :total="total">
  61. </el-pagination>
  62. </div>
  63. <!-- 添加或修改对话框 -->
  64. <el-dialog :close-on-click-modal="false" :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible"
  65. width="40%">
  66. <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left"
  67. label-width="80px" style='width: 700px; margin-left:50px;'>
  68. <el-form-item label="奖品类型" prop="prizeType">
  69. <el-select :disabled="dialogStatus == 'update' ? true : false" v-model="dataForm.prizeType" clearable
  70. placeholder="请选择类型" class="filter-item" style="width: 300px" @change="clickPrizeType">
  71. <el-option :key="item.dictValue" v-for="item in dataTypeList" :label="item.dictLabel"
  72. :value="item.dictValue">
  73. </el-option>
  74. </el-select>
  75. </el-form-item>
  76. <el-form-item label="奖品名称" prop="prizeName">
  77. <el-input style="width: 300px" v-model="dataForm.prizeName"></el-input>
  78. </el-form-item>
  79. <el-form-item v-if="dataForm.prizeType == '10'" label="兑换券" prop="couponId">
  80. <el-select v-model="dataForm.couponId" clearable placeholder="请选择兑换券" class="filter-item"
  81. style="width: 300px">
  82. <el-option :key="item.id" v-for="item in couponsList" :label="item.couponName" :value="item.id">
  83. </el-option>
  84. </el-select>
  85. </el-form-item>
  86. <!-- <el-form-item style="width: 800px" label="商品图片" prop="imgUrl">
  87. <el-upload :limit="1" :action="fileImgUrl" list-type="picture-card" :file-list="dataForm.images"
  88. :on-success="handleGallerySucess" :on-exceed="handleExceed" :before-upload="uploadBannerImg"
  89. :on-remove="handleRemove">
  90. <i class="el-icon-plus"></i>
  91. </el-upload>
  92. </el-form-item> -->
  93. <el-form-item v-if="dataForm.prizeType == '20'" label="奖励积分" prop="integral">
  94. <el-input-number style="width: 300px" :precision="0" :step="1"
  95. v-model="dataForm.integral"></el-input-number>
  96. </el-form-item>
  97. <el-form-item label="奖品权重" prop="prizeWeight">
  98. <el-input-number style="width: 300px" :precision="0" :step="1"
  99. v-model="dataForm.prizeWeight"></el-input-number>
  100. </el-form-item>
  101. <el-form-item label="奖品数量" prop="prizeActualStock">
  102. <el-input-number style="width: 300px" :precision="0" :step="1"
  103. v-model="dataForm.prizeActualStock"></el-input-number>
  104. </el-form-item>
  105. <el-form-item label="是否大奖">
  106. <el-radio-group v-model="dataForm.isGrandPrize">
  107. <el-radio :label="'0'">否</el-radio>
  108. <el-radio :label="'1'">是</el-radio>
  109. </el-radio-group>
  110. </el-form-item>
  111. <el-form-item label="状态">
  112. <el-radio-group v-model="dataForm.status">
  113. <el-radio :label="'0'">关闭</el-radio>
  114. <el-radio :label="'1'">开启</el-radio>
  115. </el-radio-group>
  116. </el-form-item>
  117. </el-form>
  118. <div slot="footer" class="dialog-footer">
  119. <el-button @click="dialogFormVisible = false">取消</el-button>
  120. <el-button v-if="dialogStatus == 'create'" type="primary" @click="createData">确定</el-button>
  121. <el-button v-else type="primary" @click="updateData">确定</el-button>
  122. </div>
  123. </el-dialog>
  124. </div>
  125. </template>
  126. <style>
  127. .demo-table-expand {
  128. font-size: 0;
  129. }
  130. .demo-table-expand label {
  131. width: 200px;
  132. color: #99a9bf;
  133. }
  134. .demo-table-expand .el-form-item {
  135. margin-right: 0;
  136. margin-bottom: 0;
  137. }
  138. </style>
  139. <script>
  140. import { dataList, dataAdd, dataEdit, dataRemove, optionSelect } from "@/api/lotteryManage";
  141. import { dataTypeList, couponsList } from "@/api/public";
  142. import waves from "@/directive/waves"; // 水波纹指令
  143. import Tinymce from '@/components/Tinymce'
  144. export default {
  145. components: { Tinymce },
  146. directives: { waves },
  147. data() {
  148. return {
  149. couponsList: [],
  150. dataTypeList: [],
  151. isCoupon: false,
  152. poolId: '',
  153. dictNameList: [],
  154. list: [
  155. ],
  156. delarr: [],
  157. multipleSelection: [],
  158. total: 0,
  159. listLoading: false,
  160. listQuery: {
  161. page: 1,
  162. limit: 10,
  163. poolId: '',
  164. },
  165. dataForm: {
  166. prizeType: undefined,
  167. couponId: undefined,
  168. prizeName: undefined,
  169. imgUrl: undefined,
  170. integral: undefined,
  171. prizeWeight: undefined,
  172. prizeActualStock: undefined,
  173. prizeStock: undefined,
  174. isGrandPrize: '0',
  175. status: '0',
  176. images: [],
  177. },
  178. dialogFormVisible: false,
  179. dialogStatus: '',
  180. textMap: {
  181. update: "编辑",
  182. create: "创建",
  183. },
  184. rules: {
  185. prizeType: [{ required: true, message: "请选择奖品类型", trigger: "blur" }],
  186. couponId: [{ required: true, message: "请选择兑换卷", trigger: "blur" }],
  187. prizeName: [{ required: true, message: "奖品名称不能为空", trigger: "blur" }],
  188. imgUrl: [{ required: true, message: "请上传奖品图片", trigger: "blur" }],
  189. prizeWeight: [{ required: true, message: "奖品权重不能为空", trigger: "blur" }],
  190. integral: [{ required: true, message: "奖励积分不能为空", trigger: "blur" }],
  191. prizeActualStock: [{ required: true, message: "奖品数量不能为空", trigger: "blur" }],
  192. prizeStock: [{ required: true, message: "剩余数量不能为空", trigger: "blur" }],
  193. },
  194. fileImgUrl: this.upLoadUrl,
  195. }
  196. },
  197. created() {
  198. this.poolId = this.$route.params.id;
  199. this.getOptionSelect();
  200. this.getDataTypeList();
  201. this.getCouponsList();
  202. },
  203. methods: {
  204. clickPrizeType() {
  205. this.dataForm.couponId = undefined;
  206. this.dataForm.prizeName = undefined;
  207. this.dataForm.imgUrl = undefined;
  208. this.dataForm.integral = undefined;
  209. this.dataForm.prizeActualStock = undefined;
  210. this.dataForm.prizeStock = undefined;
  211. this.dataForm.isGrandPrize = '0';
  212. this.dataForm.status = '0';
  213. this.dataForm.images = [];
  214. },
  215. handleRemove(file, fileList) {
  216. console.log(file, fileList);
  217. let images = [];
  218. for (let i in fileList) {
  219. let response = fileList[i].response;
  220. let url = response.data.url;
  221. images.push(url);
  222. }
  223. this.dataForm.images = images;
  224. this.dataForm.imgUrl = images.join(",");
  225. },
  226. uploadBannerImg(file) {
  227. const isJPGs = file.type === "image/jpeg";
  228. console.log(isJPGs);
  229. },
  230. handleExceed(files, fileList) {
  231. this.$message.warning(
  232. `当前限制选择 1 个文件,本次选择了 ${files.length} 个文件!,共选择了 ${files.length + fileList.length
  233. } 个文件`
  234. );
  235. },
  236. handleGallerySucess(res, file, fileList) {
  237. this.dataForm.imgUrl = ""; // 清空画廊图片数组
  238. let images = [];
  239. for (let i in fileList) {
  240. let response = fileList[i].response;
  241. if (response.errno && response.errno != "0") {
  242. this.$message.error("该图片上传失败,已被移除,请重新上传!");
  243. // 上传失败移除该 file 对象
  244. fileList.splice(i, 1);
  245. } else {
  246. let url = response.data.url;
  247. images.push(url);
  248. }
  249. }
  250. this.dataForm.images = images;
  251. this.dataForm.imgUrl = images.join(",");
  252. },
  253. getCouponsList() {
  254. couponsList({}).then(response => {
  255. this.couponsList = response.data.data;
  256. }).catch(() => { });
  257. },
  258. getDataTypeList() {
  259. dataTypeList({ dictType: 'draw_prize_type' }).then(response => {
  260. this.dataTypeList = response.data.data;
  261. }).catch(() => { });
  262. },
  263. changepoolId(val) {
  264. this.poolId = val;
  265. this.listQuery.poolId = val;
  266. this.getList();
  267. },
  268. getOptionSelect() {
  269. optionSelect().then(response => {
  270. this.dictNameList = response.data.data;
  271. this.listQuery.poolId = this.poolId;
  272. this.getList();
  273. }).catch(() => { })
  274. },
  275. resetForm() {
  276. this.dataForm = {
  277. prizeType: undefined,
  278. couponId: undefined,
  279. prizeName: undefined,
  280. imgUrl: undefined,
  281. integral: undefined,
  282. prizeWeight: undefined,
  283. prizeActualStock: undefined,
  284. prizeStock: undefined,
  285. isGrandPrize: '0',
  286. status: '0',
  287. images: [],
  288. };
  289. },
  290. handleCreate() {
  291. this.resetForm();
  292. this.dataForm.poolId = this.poolId;
  293. this.dialogFormVisible = true;
  294. this.dialogStatus = "create";
  295. this.$nextTick(() => {
  296. this.$refs["dataForm"].clearValidate();
  297. });
  298. },
  299. createData() {
  300. this.$refs["dataForm"].validate((valid) => {
  301. if (valid) {
  302. dataAdd(this.dataForm)
  303. .then(() => {
  304. this.dialogFormVisible = false;
  305. this.$notify({
  306. title: "成功",
  307. message: "创建成功",
  308. type: "success",
  309. duration: 2000,
  310. });
  311. this.getList()
  312. })
  313. }
  314. });
  315. },
  316. getList() {
  317. this.listLoading = true
  318. dataList(this.listQuery).then(response => {
  319. this.list = response.data.data.items
  320. this.total = response.data.data.total
  321. this.listLoading = false
  322. }).catch(() => {
  323. this.list = []
  324. this.total = 0
  325. this.listLoading = false
  326. })
  327. },
  328. handleFilter() {
  329. this.listQuery.page = 1
  330. this.getList()
  331. },
  332. handleSizeChange(val) {
  333. this.listQuery.limit = val
  334. this.getList()
  335. },
  336. handleCurrentChange(val) {
  337. this.listQuery.page = val
  338. this.getList()
  339. },
  340. handleUpdate(row) {
  341. this.dataForm = Object.assign({}, row);
  342. if (this.dataForm.imgUrl) {
  343. let images = this.dataForm.imgUrl.split(",");
  344. this.dataForm.images = [];
  345. for (let i in images) {
  346. let url = images[i];
  347. let name = "image_" + i;
  348. this.dataForm.images.push({
  349. name: name,
  350. url: url,
  351. response: { error: "0", data: { url: url } },
  352. });
  353. }
  354. }
  355. this.dialogStatus = 'update'
  356. this.dialogFormVisible = true
  357. this.$nextTick(() => {
  358. this.$refs['dataForm'].clearValidate()
  359. })
  360. },
  361. updateData() {
  362. this.$refs['dataForm'].validate((valid) => {
  363. if (valid) {
  364. dataEdit(this.dataForm).then(() => {
  365. this.dialogFormVisible = false
  366. this.$notify({
  367. title: '成功',
  368. message: '更新成功',
  369. type: 'success',
  370. duration: 2000
  371. })
  372. this.getList()
  373. })
  374. }
  375. })
  376. },
  377. handleDelete(row) {
  378. this.$confirm('确认删除吗?', '提示', {
  379. confirmButtonText: '确定',
  380. cancelButtonText: '取消',
  381. type: 'warning'
  382. }).then(() => {
  383. dataRemove({ prizeIds: row.id }).then(response => {
  384. this.$notify({
  385. title: '成功',
  386. message: '删除成功',
  387. type: 'success',
  388. duration: 2000
  389. })
  390. const index = this.list.indexOf(row)
  391. this.list.splice(index, 1)
  392. })
  393. }).catch(() => {
  394. })
  395. },
  396. delAll() {
  397. this.$confirm("确认删除吗?", "提示", {
  398. confirmButtonText: "确定",
  399. cancelButtonText: "取消",
  400. type: "warning",
  401. })
  402. .then(() => {
  403. const length = this.multipleSelection.length;
  404. if (length > 0) {
  405. for (let i = 0; i < length; i++) {
  406. this.delarr.push(this.multipleSelection[i].id);
  407. }
  408. const ids = this.delarr.join(",");
  409. dataRemove({ prizeIds: ids })
  410. .then(() => {
  411. this.$notify({
  412. title: "成功",
  413. message: "删除成功",
  414. type: "success",
  415. duration: 2000,
  416. });
  417. this.getList();
  418. })
  419. .catch(() => { });
  420. } else {
  421. this.$notify({
  422. title: "警告提示",
  423. message: "请选择要删除的信息!",
  424. type: "warning",
  425. });
  426. }
  427. })
  428. .catch(() => { });
  429. },
  430. handleSelectionChange(val) {
  431. this.multipleSelection = val;
  432. },
  433. }
  434. }
  435. </script>
  436. <style>
  437. .ad-avatar-uploader .el-upload {
  438. border: 1px dashed #d9d9d9;
  439. border-radius: 6px;
  440. cursor: pointer;
  441. position: relative;
  442. overflow: hidden;
  443. }
  444. .ad-avatar-uploader .el-upload:hover {
  445. border-color: #409EFF;
  446. }
  447. .ad-avatar-uploader-icon {
  448. font-size: 28px;
  449. color: #8c939d;
  450. width: 178px;
  451. height: 178px;
  452. line-height: 178px;
  453. text-align: center;
  454. }
  455. .ad-avatar {
  456. display: block;
  457. }
  458. </style>