| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 |
- <template>
- <basic-container>
- <avue-crud id="activity" :option="option" :table-loading="loading" :data="data" :page.sync="page" :permission="permissionList"
- :before-open="beforeOpen" v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
- @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
- @row-click="rowClick"
- @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
- <template slot="menuLeft">
- <el-button type="danger" size="small" icon="el-icon-delete" plain v-if="permission.activity_delete"
- @click="handleDelete">删 除
- </el-button>
- </template>
- <template slot="menuLeft">
- <el-button type="primary" size="small" icon="el-icon-delete" v-if="permission.activity_add"
- @click="showAdd">新增
- </el-button>
- </template>
- <template slot="enable" slot-scope="scope">
- <el-switch disabled v-model="scope.row.enable" :active-value="1" :inactive-value="0"></el-switch>
- </template>
- <template slot-scope="scope" slot="activityTime">
- <div style="margin: 20px 0;">
- 报名截止:{{scope.row.applyEndTime}}
- </div>
- <div style="margin: 20px 0;">
- 活动开始:{{scope.row.beginTime}}
- </div>
- <div style="margin: 20px 0;">
- 活动结束:{{scope.row.endTime}}
- </div>
- </template>
- <template slot-scope="scope" slot="cover">
- <el-image
- style="width: 100%; height: 100%"
- :src="scope.row.cover"
- :preview-src-list="[scope.row.cover]">
- </el-image>
- </template>
- <template slot-scope="scope" slot="poster">
- <el-image
- style="width: 100px; height: 120px;overflow-y: hidden;"
- :src="scope.row.poster"
- fit="cover"
- :preview-src-list="[scope.row.poster]">
- </el-image>
- </template>
- <template slot-scope="scope" slot="showData">
- 参与人数:<div style="background-color: #3296fa;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">{{scope.row.applyNum}}</div><br>
- 礼物总值:<div style="background-color: #5bc0de;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">{{ +scope.row.totalCash}}</div><br>
- 打榜数量:<div style="background-color: #5bc0de;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">{{scope.row.hitNum}}</div><br>
- 打赏数量:<div style="background-color: #99cf99;color: white; border-radius: 5px; margin:10px; padding:0 10px 0 10px ; display:inline;">{{scope.row.rewardNum}}</div><br>
- </template>
- <!-- 操作菜单 -->
- <template slot-scope="scope" slot="menu">
- <el-button type="text" size="small" icon="el-icon-edit" plain class="none-border"
- @click.stop="handleEdit(scope.row)">编辑
- </el-button>
- <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
- @click.stop="view(scope.row.id,'查看选手')">查看选手
- </el-button>
- <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
- @click.stop="view(scope.row.id,'查看作品')">查看作品
- </el-button>
- <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
- @click.stop="view(scope.row.id,'打榜记录')">打榜记录
- </el-button>
- <el-button type="text" size="small" icon="el-icon-view" plain class="none-border"
- @click.stop="view(scope.row.id,'打赏记录')">打赏记录
- </el-button>
- </template>
- </avue-crud>
- <activity-add ref="addDialog"
- @submit="submit"
- :form1="data1" :form2="data2" :form3="data3" :form4="data4">
- </activity-add>
- </basic-container>
- </template>
- <script>
- import activityAdd from "./comps/activity-add.vue"
- import {getList, getDetail, createOrUpdate, update, remove} from "@/api/activity/activity";
- import {mapGetters} from "vuex";
- export default {
- components:{
- activityAdd
- },
- data() {
- return {
- data1:{
- id:'',
- name:'',
- beginTime:'',
- endTime:'',
- applyEndTime:'',
- description:'',
- visitBase:0,
- tagIds:[]
- },
- data2:{
- cover:'',
- poster:'',
- ads:''
- },
- data3:{
- bonusProportion:'',
- grossProfitRate:'',
- classification:'',
- personTitle:'',
- productionTitle:'',
- introductionTitle:'',
- ticketDays:1,
- ticketHotValue:1
- },
- data4:{
- presentIds:[]
- },
- form: {},
- query: {},
- loading: true,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- selectionList: [],
- option: {
- height: 'auto',
- calcHeight: 30,
- tip: false,
- searchShow: true,
- searchMenuSpan: 6,
- border: true,
- index: true,
- viewBtn: true,
- editBtn:false,
- addBtn:false,
- selection: true,
- labelWidth: 150,
- size:"medium",
- dialogClickModal: false,
- column: [
- {
- label: "封面图",
- prop: "cover",
- width: 150,
- type: "upload",
- solt:true,
- listType: "picture-img",
- action: '/api/putObject',
- propsHttp: {
- url: 'data'
- },
- rules: [{
- required: true,
- message: "请输入活动封面图",
- trigger: "blur"
- }]
- },{
- label: "活动主题",
- search:true,
- prop: "name",
- rules: [{
- required: true,
- message: "请输入活动主题",
- trigger: "blur"
- }]
- },
- {
- label:"活动时间",
- slot:true,
- width: 200,
- editDisplay:false,
- addDisplay:false,
- prop:"activityTime"
- },
- {
- label:"数据",
- slot:true,
- width: 180,
- editDisplay:false,
- addDisplay:false,
- prop:"showData"
- },
- {
- label: "活动开始时间",
- width: 140,
- hide:true,
- prop: "beginTime",
- type: 'datetime',
- format: "yyyy-MM-dd hh:mm:ss",
- valueFormat: "yyyy-MM-dd hh:mm:ss",
- rules: [{
- required: true,
- message: "请输入活动开始时间",
- trigger: "blur"
- }]
- },
- {
- label: "活动结束时间",
- width: 140,
- hide:true,
- prop: "endTime",
- type: 'datetime',
- format: "yyyy-MM-dd hh:mm:ss",
- valueFormat: "yyyy-MM-dd hh:mm:ss",
- rules: [{
- required: true,
- message: "请输入活动结束时间",
- trigger: "blur"
- }]
- },
- {
- label: "报名结束时间",
- width: 140,
- hide:true,
- prop: "applyEndTime",
- type: 'datetime',
- format: "yyyy-MM-dd hh:mm:ss",
- valueFormat: "yyyy-MM-dd hh:mm:ss",
- rules: [{
- required: true,
- message: "请输入报名结束时间",
- trigger: "blur"
- }]
- },
- {
- hide: true,
- label: "活动简介",
- prop: "description",
- type: 'textarea',
- rules: [{
- required: true,
- message: "请输入活动简介",
- trigger: "blur"
- }]
- },
- {
- label: "活动标签",
- prop: "tagIds",
- type: "select",
- multiple: true,
- dicUrl: "/api/cyzh-tag/tag/list?size=500",
- props: {
- label: "name",
- value: "id"
- },
- dicFormatter: (res) => {
- return res.data.records
- }
- },
- {
- label: "活动海报",
- prop: "poster",
- slot:true,
- dataType: 'string',
- listType: 'picture-img',
- propsHttp: {
- url: 'data'
- },
- action: '/api/putObject',
- type: 'upload',
- rules: [{
- required: true,
- message: "请选择活动海报",
- trigger: "blur"
- }]
- },
- {
- label: "活动轮播图",
- prop: "ads",
- hide:true,
- dataType: 'string',
- listType: 'picture-card',
- propsHttp: {
- url: 'data'
- },
- action: '/api/putObject',
- type: 'upload',
- rules: [{
- required: true,
- message: "请选择活动轮播图",
- trigger: "blur"
- }]
- },
- {
- label: "是否启用",
- width: 100,
- prop: "enable",
- slot:true,
- type: 'switch',
- dicData: [{
- label: '禁用',
- value: 0
- },
- {
- label: '启用',
- value: 1
- }
- ]
- },
- ]
- },
- data: []
- };
- },
- computed: {
- ...mapGetters(["permission"]),
- permissionList() {
- return {
- addBtn: this.vaildData(this.permission.activity_add, false),
- viewBtn: this.vaildData(this.permission.activity_view, false),
- delBtn: this.vaildData(this.permission.activity_delete, false),
- editBtn: this.vaildData(this.permission.activity_edit, false)
- };
- },
- ids() {
- let ids = [];
- this.selectionList.forEach(ele => {
- ids.push(ele.id);
- });
- return ids.join(",");
- }
- },
- methods: {
- rowClick(row,event){
- if (event.property=='enable') {
- let param={
- id:row.id,
- enable:row.enable==1?0:1
- }
- update(param).then(()=>{
- this.onLoad(this.page);
- })
- }
- },
- showAdd(){
- if (!this.$isEmpty(this.data1.id)) {
- this.resetData()
- }
- this.$refs.addDialog.open()
- },
- resetData(){
- this.data1={
- id:'',
- name:'',
- beginTime:'',
- endTime:'',
- applyEndTime:'',
- description:'',
- visitBase:0,
- tagIds:[]
- }
- this.data2={
- cover:'',
- poster:'',
- ads:''
- }
- this.data3={
- bonusProportion:0,
- grossProfitRate:1,
- classification:'',
- personTitle:'',
- productionTitle:'',
- introductionTitle:'',
- ticketDays:1,
- ticketHotValue:1
- }
- this.data4={
- presentIds:[]
- }
- },
- //编辑
- handleEdit(item) {
- this.data1={
- id:item.id,
- name:item.name,
- beginTime:item.beginTime,
- endTime:item.endTime,
- applyEndTime:item.applyEndTime,
- description:item.description,
- visitBase:item.visitBase,
- tagIds:item.tagIds
- }
- this.data2={
- cover:item.cover,
- poster:item.poster,
- ads:item.ads
- }
- this.data3={
- grossProfitRate:item.grossProfitRate,
- bonusProportion:item.bonusProportion,
- classification:item.classification,
- personTitle:item.personTitle,
- productionTitle:item.productionTitle,
- introductionTitle:item.introductionTitle,
- ticketDays:item.ticketDays,
- ticketHotValue:item.ticketHotValue
- }
- this.data4={
- presentIds:item.presentIds
- }
- this.$refs.addDialog.open()
- },
- submit(item) {
- createOrUpdate(item).then(() => {
- this.onLoad(this.page);
- this.resetData()
- this.$refs.addDialog.close()
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- }, error => {
- window.console.log(error);
- });
- },
- rowSave(row, done, loading) {
- createOrUpdate(row).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- }, error => {
- loading();
- window.console.log(error);
- });
- },
- rowUpdate(row, index, done, loading) {
- update(row).then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- done();
- }, error => {
- loading();
- console.log(error);
- });
- },
- rowDel(row) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(row.id);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- });
- },
- handleDelete() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(this.ids);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$refs.crud.toggleSelection();
- });
- },
- beforeOpen(done, type) {
- if (["edit", "view"].includes(type)) {
- getDetail(this.form.id).then(res => {
- this.form = res.data.data;
- });
- }
- done();
- },
- searchReset() {
- this.query = {};
- this.onLoad(this.page);
- },
- searchChange(params, done) {
- this.query = params;
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- selectionClear() {
- this.selectionList = [];
- this.$refs.crud.toggleSelection();
- },
- currentChange(currentPage) {
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize) {
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- this.onLoad(this.page, this.query);
- },
- onLoad(page, params = {}) {
- this.loading = true;
- getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
- const data = res.data.data;
- this.page.total = data.total;
- this.data = data.records;
- this.loading = false;
- this.selectionClear();
- });
- },
- view(id,name){
- this.$router.push({
- name,
- query: {
- id
- }
- })
- },
- }
- };
- </script>
- <style>
- /* #activity
- .el-table__row{
- height: 200px;
- } */
- </style>
|