shop_vue/src/views/branch/activity/index.vue
@@ -1,6 +1,13 @@
<template>
  <div>
    <div class="common-level-rail"><el-button size="small" type="primary" icon="el-icon-plus" @click="add">添加活动</el-button></div>
    <div class="common-level-rail">
      <el-button size="small" type="primary" icon="el-icon-plus" @click="add">添加活动</el-button>
      <el-select v-model="searchForm.audit_status" placeholder="审核状态" clearable @change="handleSearch">
        <el-option label="待审核" :value="0"></el-option>
        <el-option label="已通过" :value="10"></el-option>
        <el-option label="已驳回" :value="20"></el-option>
      </el-select>
    </div>
    <div class="table-wrap">
      <el-table :data="tableData" style="width: 100%" v-loading="loading">
        <el-table-column prop="activity_id" label="活动ID" width="60"></el-table-column>
@@ -9,7 +16,12 @@
            <img v-img-url="'image.file_path',scope.row" width="40" height="40" />
          </template>
        </el-table-column>
        <el-table-column prop="name" label="活动标题" min-width="120"></el-table-column>
        <el-table-column prop="name" label="活动标题" min-width="120">
          <template slot-scope="{ row }">
            <div>{{ row.name }}</div>
            <el-tag size="small">{{ row.branch.name }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="category.name" label="活动分类" width="120"></el-table-column>
        <el-table-column prop="fee" label="活动费用" width="90"></el-table-column>
        <el-table-column prop="limit_num" label="已报人数/总人数" width="120">
@@ -27,15 +39,24 @@
            <el-tag :type="tagType(row.status_text.status)">{{ row.status_text.status_text }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="audit_status" label="审核状态" width="100">
          <template slot-scope="{ row }">
            <el-tag :type="auditStatusType(row.audit_status_text.status)">
              {{ row.audit_status_text.text }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="create_time" label="创建时间" width="140"></el-table-column>
        <el-table-column prop="status" label="是否显示" width="100">
            <template slot-scope="scope">
                <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0" active-text="显示" inactive-text="隐藏" :width="55" @change="statusSet($event, scope.row)"></el-switch>
            </template>
        </el-table-column>
        <el-table-column prop="name" label="操作" width="140">
        <el-table-column prop="name" label="操作" width="220">
          <template slot-scope="scope">
            <el-button @click="onDetail(scope.row.activity_id, false)" type="text" size="small">查看</el-button>
            <el-button @click="qrcode(scope.row)" type="text" size="small">核销码</el-button>
            <el-button @click="showAuditDialog(scope.row)" type="text" size="small" v-if="scope.row.audit_status === 0">审核</el-button>
            <el-button @click="onDetail(scope.row.activity_id, true)" type="text" size="small">编辑</el-button>
            <el-button @click="onDelete(scope.row)" type="text" size="small">删除</el-button>
          </template>
@@ -57,15 +78,42 @@
    </div>
    <!-- 活动详情 -->
    <Detail ref="activityDetail" :open="open_detail" @getList="getTableList" @close="closeDrawerDetail"></Detail>
    <!-- 核销码 -->
    <Qrcode :open='isQrcode' :code_id='code_id' @close="closeQrcode"></Qrcode>
    <!-- 审核对话框 -->
    <el-dialog title="审核活动" :visible.sync="auditDialogVisible" width="500px">
      <el-form :model="auditForm" label-width="80px">
        <el-form-item label="审核结果">
          <el-radio-group v-model="auditForm.audit_status">
            <el-radio :label="10">通过</el-radio>
            <el-radio :label="20">驳回</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item label="审核备注" v-if="auditForm.audit_status === 20">
          <el-input
            type="textarea"
            :rows="4"
            v-model="auditForm.audit_remark"
            placeholder="请输入驳回原因"
          ></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer">
        <el-button @click="auditDialogVisible = false">取消</el-button>
        <el-button type="primary" @click="submitAudit">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import BranchApi from '@/api/branch.js';
import Detail from './drawer/detail.vue';
import Qrcode from './dialog/Qrcode.vue';
export default {
  components: {
    Detail
    Detail,
    Qrcode
  },
  data() {
    return {
@@ -89,6 +137,19 @@
      curPage: 1,
      tagTypeData: ['info', '', 'success'],
      open_detail: false,
      isQrcode: false,
      code_id: '',
      /*审核相关*/
      auditDialogVisible: false,
      auditForm: {
        activity_id: 0,
        audit_status: 10,
        audit_remark: ''
      },
      /*搜索条件*/
      searchForm: {
        audit_status: ''
      },
    };
  },
  created() {
@@ -102,6 +163,10 @@
      let Params = {};
      Params.page = self.curPage;
      Params.list_rows = self.pageSize;
      // 添加审核状态筛选
      if (self.searchForm.audit_status !== '') {
        Params.audit_status = self.searchForm.audit_status;
      }
      BranchApi.activityList(Params, true)
        .then(data => {
          self.loading = false;
@@ -160,9 +225,9 @@
        })
        .then(() => {
          self.loading = true;
          BranchApi.delete(
          BranchApi.deleteActivity(
            {
              activity_id: e
              activity_id: e.activity_id
            },
            true
          )
@@ -195,7 +260,51 @@
    tagType(e) {
      return this.tagTypeData[e];
    }
    },
    auditStatusType(e) {
      const typeMap = { 0: 'warning', 10: 'success', 20: 'danger' };
      return typeMap[e] || 'info';
    },
    qrcode(row){
      this.code_id = row.activity_id;
      this.isQrcode = true;
    },
    closeQrcode(){
      this.isQrcode = false;
    },
    /*显示审核对话框*/
    showAuditDialog(row) {
      this.auditForm = {
        activity_id: row.activity_id,
        audit_status: 10,
        audit_remark: ''
      };
      this.auditDialogVisible = true;
    },
    /*提交审核*/
    submitAudit() {
      if (this.auditForm.audit_status === 20 && !this.auditForm.audit_remark) {
        this.$message.warning('请输入驳回原因');
        return;
      }
      BranchApi.auditActivity(this.auditForm, true)
        .then(data => {
          this.$message.success(data.msg);
          this.auditDialogVisible = false;
          this.getTableList();
        })
        .catch(error => {});
    },
    /*搜索*/
    handleSearch() {
      this.curPage = 1;
      this.getTableList();
    },
  }
};
</script>