lotteryDataList.vue 19 KB

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