activity.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <basic-container>
  3. <avue-crud id="activity" :option="option" :table-loading="loading" :data="data" :page.sync="page" :permission="permissionList"
  4. :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
  5. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  6. @row-click="rowClick"
  7. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
  8. <template slot="menuLeft">
  9. <el-button type="danger" size="small" icon="el-icon-delete" plain v-if="permission.activity_delete"
  10. @click="handleDelete">删 除
  11. </el-button>
  12. </template>
  13. <template slot="menuLeft">
  14. <el-button type="primary" size="small" icon="el-icon-delete" v-if="permission.activity_add"
  15. @click="showAdd">新增
  16. </el-button>
  17. </template>
  18. <template slot="enable" slot-scope="scope">
  19. <el-switch disabled v-model="scope.row.enable" :active-value="1" :inactive-value="0"></el-switch>
  20. </template>
  21. <template slot-scope="scope" slot="activityTime">
  22. <div style="margin: 20px 0;">
  23. 报名截止:{{scope.row.applyEndTime}}
  24. </div>
  25. <div style="margin: 20px 0;">
  26. 活动开始:{{scope.row.beginTime}}
  27. </div>
  28. <div style="margin: 20px 0;">
  29. 活动结束:{{scope.row.endTime}}
  30. </div>
  31. </template>
  32. <template slot-scope="scope" slot="cover">
  33. <el-image
  34. style="width: 100%; height: 100%"
  35. :src="scope.row.cover"
  36. :preview-src-list="[scope.row.cover]">
  37. </el-image>
  38. </template>
  39. <template slot-scope="scope" slot="poster">
  40. <el-image
  41. style="width: 100px; height: 120px;overflow-y: hidden;"
  42. :src="scope.row.poster"
  43. fit="cover"
  44. :preview-src-list="[scope.row.poster]">
  45. </el-image>
  46. </template>
  47. <template slot-scope="scope" slot="showData">
  48. 参与人数:<div style="background-color: #3296fa;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">{{scope.row.applyNum}}</div><br>
  49. 礼物总值:<div style="background-color: #5bc0de;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">{{ +scope.row.totalCash}}</div><br>
  50. 打榜数量:<div style="background-color: #5bc0de;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">{{scope.row.hitNum}}</div><br>
  51. 打赏数量:<div style="background-color: #99cf99;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">{{scope.row.rewardNum}}</div><br>
  52. </template>
  53. <!-- 操作菜单 -->
  54. <template slot-scope="scope" slot="menu">
  55. <el-button type="text" size="small" icon="el-icon-edit" plain class="none-border"
  56. @click.stop="handleEdit(scope.row)">编辑
  57. </el-button>
  58. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  59. @click.stop="view(scope.row.id,'查看选手')">查看选手
  60. </el-button>
  61. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  62. @click.stop="view(scope.row.id,'查看作品')">查看作品
  63. </el-button>
  64. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  65. @click.stop="view(scope.row.id,'打榜记录')">打榜记录
  66. </el-button>
  67. <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
  68. @click.stop="view(scope.row.id,'打赏记录')">打赏记录
  69. </el-button>
  70. </template>
  71. </avue-crud>
  72. <activity-add ref="addDialog"
  73. @submit="submit"
  74. :form1="data1" :form2="data2" :form3="data3" :form4="data4">
  75. </activity-add>
  76. </basic-container>
  77. </template>
  78. <script>
  79. import activityAdd from "./comps/activity-add.vue"
  80. import {getList, getDetail, createOrUpdate, update, remove} from "@/api/activity/activity";
  81. import {mapGetters} from "vuex";
  82. export default {
  83. components:{
  84. activityAdd
  85. },
  86. data() {
  87. return {
  88. data1:{
  89. id:'',
  90. name:'',
  91. beginTime:'',
  92. endTime:'',
  93. applyEndTime:'',
  94. description:'',
  95. visitBase:0,
  96. tagIds:[]
  97. },
  98. data2:{
  99. cover:'',
  100. poster:'',
  101. ads:''
  102. },
  103. data3:{
  104. bonusProportion:'',
  105. grossProfitRate:'',
  106. classification:'',
  107. personTitle:'',
  108. productionTitle:'',
  109. introductionTitle:'',
  110. ticketDays:1,
  111. ticketHotValue:1
  112. },
  113. data4:{
  114. presentIds:[]
  115. },
  116. form: {},
  117. query: {},
  118. loading: true,
  119. page: {
  120. pageSize: 10,
  121. currentPage: 1,
  122. total: 0
  123. },
  124. selectionList: [],
  125. option: {
  126. height: 'auto',
  127. calcHeight: 30,
  128. tip: false,
  129. searchShow: true,
  130. searchMenuSpan: 6,
  131. border: true,
  132. index: true,
  133. viewBtn: true,
  134. editBtn:false,
  135. addBtn:false,
  136. selection: true,
  137. labelWidth: 150,
  138. size:"medium",
  139. dialogClickModal: false,
  140. column: [
  141. {
  142. label: "封面图",
  143. prop: "cover",
  144. width: 150,
  145. type: "upload",
  146. solt:true,
  147. listType: "picture-img",
  148. action: '/api/putObject',
  149. propsHttp: {
  150. url: 'data'
  151. },
  152. rules: [{
  153. required: true,
  154. message: "请输入活动封面图",
  155. trigger: "blur"
  156. }]
  157. },{
  158. label: "活动主题",
  159. search:true,
  160. prop: "name",
  161. rules: [{
  162. required: true,
  163. message: "请输入活动主题",
  164. trigger: "blur"
  165. }]
  166. },
  167. {
  168. label:"活动时间",
  169. slot:true,
  170. width: 200,
  171. editDisplay:false,
  172. addDisplay:false,
  173. prop:"activityTime"
  174. },
  175. {
  176. label:"数据",
  177. slot:true,
  178. width: 180,
  179. editDisplay:false,
  180. addDisplay:false,
  181. prop:"showData"
  182. },
  183. {
  184. label: "活动开始时间",
  185. width: 140,
  186. hide:true,
  187. prop: "beginTime",
  188. type: 'datetime',
  189. format: "yyyy-MM-dd hh:mm:ss",
  190. valueFormat: "yyyy-MM-dd hh:mm:ss",
  191. rules: [{
  192. required: true,
  193. message: "请输入活动开始时间",
  194. trigger: "blur"
  195. }]
  196. },
  197. {
  198. label: "活动结束时间",
  199. width: 140,
  200. hide:true,
  201. prop: "endTime",
  202. type: 'datetime',
  203. format: "yyyy-MM-dd hh:mm:ss",
  204. valueFormat: "yyyy-MM-dd hh:mm:ss",
  205. rules: [{
  206. required: true,
  207. message: "请输入活动结束时间",
  208. trigger: "blur"
  209. }]
  210. },
  211. {
  212. label: "报名结束时间",
  213. width: 140,
  214. hide:true,
  215. prop: "applyEndTime",
  216. type: 'datetime',
  217. format: "yyyy-MM-dd hh:mm:ss",
  218. valueFormat: "yyyy-MM-dd hh:mm:ss",
  219. rules: [{
  220. required: true,
  221. message: "请输入报名结束时间",
  222. trigger: "blur"
  223. }]
  224. },
  225. {
  226. hide: true,
  227. label: "活动简介",
  228. prop: "description",
  229. type: 'textarea',
  230. rules: [{
  231. required: true,
  232. message: "请输入活动简介",
  233. trigger: "blur"
  234. }]
  235. },
  236. {
  237. label: "活动标签",
  238. prop: "tagIds",
  239. type: "select",
  240. multiple: true,
  241. dicUrl: "/api/cyzh-tag/tag/list?size=500",
  242. props: {
  243. label: "name",
  244. value: "id"
  245. },
  246. dicFormatter: (res) => {
  247. return res.data.records
  248. }
  249. },
  250. {
  251. label: "活动海报",
  252. prop: "poster",
  253. slot:true,
  254. dataType: 'string',
  255. listType: 'picture-img',
  256. propsHttp: {
  257. url: 'data'
  258. },
  259. action: '/api/putObject',
  260. type: 'upload',
  261. rules: [{
  262. required: true,
  263. message: "请选择活动海报",
  264. trigger: "blur"
  265. }]
  266. },
  267. {
  268. label: "活动轮播图",
  269. prop: "ads",
  270. hide:true,
  271. dataType: 'string',
  272. listType: 'picture-card',
  273. propsHttp: {
  274. url: 'data'
  275. },
  276. action: '/api/putObject',
  277. type: 'upload',
  278. rules: [{
  279. required: true,
  280. message: "请选择活动轮播图",
  281. trigger: "blur"
  282. }]
  283. },
  284. {
  285. label: "是否启用",
  286. width: 100,
  287. prop: "enable",
  288. slot:true,
  289. type: 'switch',
  290. dicData: [{
  291. label: '禁用',
  292. value: 0
  293. },
  294. {
  295. label: '启用',
  296. value: 1
  297. }
  298. ]
  299. },
  300. ]
  301. },
  302. data: []
  303. };
  304. },
  305. computed: {
  306. ...mapGetters(["permission"]),
  307. permissionList() {
  308. return {
  309. addBtn: this.vaildData(this.permission.activity_add, false),
  310. viewBtn: this.vaildData(this.permission.activity_view, false),
  311. delBtn: this.vaildData(this.permission.activity_delete, false),
  312. editBtn: this.vaildData(this.permission.activity_edit, false)
  313. };
  314. },
  315. ids() {
  316. let ids = [];
  317. this.selectionList.forEach(ele => {
  318. ids.push(ele.id);
  319. });
  320. return ids.join(",");
  321. }
  322. },
  323. methods: {
  324. rowClick(row,event){
  325. if (event.property=='enable') {
  326. let param={
  327. id:row.id,
  328. enable:row.enable==1?0:1
  329. }
  330. update(param).then(()=>{
  331. this.onLoad(this.page);
  332. })
  333. }
  334. },
  335. showAdd(){
  336. if (!this.$isEmpty(this.data1.id)) {
  337. this.resetData()
  338. }
  339. this.$refs.addDialog.open()
  340. },
  341. resetData(){
  342. this.data1={
  343. id:'',
  344. name:'',
  345. beginTime:'',
  346. endTime:'',
  347. applyEndTime:'',
  348. description:'',
  349. visitBase:0,
  350. tagIds:[]
  351. }
  352. this.data2={
  353. cover:'',
  354. poster:'',
  355. ads:''
  356. }
  357. this.data3={
  358. bonusProportion:0,
  359. grossProfitRate:1,
  360. classification:'',
  361. personTitle:'',
  362. productionTitle:'',
  363. introductionTitle:'',
  364. ticketDays:1,
  365. ticketHotValue:1
  366. }
  367. this.data4={
  368. presentIds:[]
  369. }
  370. },
  371. //编辑
  372. handleEdit(item) {
  373. this.data1={
  374. id:item.id,
  375. name:item.name,
  376. beginTime:item.beginTime,
  377. endTime:item.endTime,
  378. applyEndTime:item.applyEndTime,
  379. description:item.description,
  380. visitBase:item.visitBase,
  381. tagIds:item.tagIds
  382. }
  383. this.data2={
  384. cover:item.cover,
  385. poster:item.poster,
  386. ads:item.ads
  387. }
  388. this.data3={
  389. grossProfitRate:item.grossProfitRate,
  390. bonusProportion:item.bonusProportion,
  391. classification:item.classification,
  392. personTitle:item.personTitle,
  393. productionTitle:item.productionTitle,
  394. introductionTitle:item.introductionTitle,
  395. ticketDays:item.ticketDays,
  396. ticketHotValue:item.ticketHotValue
  397. }
  398. this.data4={
  399. presentIds:item.presentIds
  400. }
  401. this.$refs.addDialog.open()
  402. },
  403. submit(item) {
  404. createOrUpdate(item).then(() => {
  405. this.onLoad(this.page);
  406. this.resetData()
  407. this.$refs.addDialog.close()
  408. this.$message({
  409. type: "success",
  410. message: "操作成功!"
  411. });
  412. }, error => {
  413. window.console.log(error);
  414. });
  415. },
  416. rowSave(row, done, loading) {
  417. createOrUpdate(row).then(() => {
  418. this.onLoad(this.page);
  419. this.$message({
  420. type: "success",
  421. message: "操作成功!"
  422. });
  423. done();
  424. }, error => {
  425. loading();
  426. window.console.log(error);
  427. });
  428. },
  429. rowUpdate(row, index, done, loading) {
  430. update(row).then(() => {
  431. this.onLoad(this.page);
  432. this.$message({
  433. type: "success",
  434. message: "操作成功!"
  435. });
  436. done();
  437. }, error => {
  438. loading();
  439. console.log(error);
  440. });
  441. },
  442. rowDel(row) {
  443. this.$confirm("确定将选择数据删除?", {
  444. confirmButtonText: "确定",
  445. cancelButtonText: "取消",
  446. type: "warning"
  447. })
  448. .then(() => {
  449. return remove(row.id);
  450. })
  451. .then(() => {
  452. this.onLoad(this.page);
  453. this.$message({
  454. type: "success",
  455. message: "操作成功!"
  456. });
  457. });
  458. },
  459. handleDelete() {
  460. if (this.selectionList.length === 0) {
  461. this.$message.warning("请选择至少一条数据");
  462. return;
  463. }
  464. this.$confirm("确定将选择数据删除?", {
  465. confirmButtonText: "确定",
  466. cancelButtonText: "取消",
  467. type: "warning"
  468. })
  469. .then(() => {
  470. return remove(this.ids);
  471. })
  472. .then(() => {
  473. this.onLoad(this.page);
  474. this.$message({
  475. type: "success",
  476. message: "操作成功!"
  477. });
  478. this.$refs.crud.toggleSelection();
  479. });
  480. },
  481. beforeOpen(done, type) {
  482. if (["edit", "view"].includes(type)) {
  483. getDetail(this.form.id).then(res => {
  484. this.form = res.data.data;
  485. });
  486. }
  487. done();
  488. },
  489. searchReset() {
  490. this.query = {};
  491. this.onLoad(this.page);
  492. },
  493. searchChange(params, done) {
  494. this.query = params;
  495. this.page.currentPage = 1;
  496. this.onLoad(this.page, params);
  497. done();
  498. },
  499. selectionChange(list) {
  500. this.selectionList = list;
  501. },
  502. selectionClear() {
  503. this.selectionList = [];
  504. this.$refs.crud.toggleSelection();
  505. },
  506. currentChange(currentPage) {
  507. this.page.currentPage = currentPage;
  508. },
  509. sizeChange(pageSize) {
  510. this.page.pageSize = pageSize;
  511. },
  512. refreshChange() {
  513. this.onLoad(this.page, this.query);
  514. },
  515. onLoad(page, params = {}) {
  516. this.loading = true;
  517. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  518. const data = res.data.data;
  519. this.page.total = data.total;
  520. this.data = data.records;
  521. this.loading = false;
  522. this.selectionClear();
  523. });
  524. },
  525. view(id,name){
  526. this.$router.push({
  527. name,
  528. query: {
  529. id
  530. }
  531. })
  532. },
  533. }
  534. };
  535. </script>
  536. <style>
  537. /* #activity
  538. .el-table__row{
  539. height: 200px;
  540. } */
  541. </style>