activity.vue 18 KB

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