|
|
@@ -0,0 +1,467 @@
|
|
|
+<template>
|
|
|
+ <div class="app-container">
|
|
|
+ <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="85px" @submit.native.prevent>
|
|
|
+ <el-form-item label="活动名称" prop="activityName">
|
|
|
+ <el-input v-model="queryParams.activityName"
|
|
|
+ placeholder="请输入活动名称"
|
|
|
+ clearable
|
|
|
+ size="small"
|
|
|
+ @keyup.enter.native="handleQuery" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="活动状态" prop="status">
|
|
|
+ <el-select v-model="queryParams.status" placeholder="请选择活动状态" clearable size="small">
|
|
|
+ <el-option label="未开始" :value="0" />
|
|
|
+ <el-option label="进行中" :value="1" />
|
|
|
+ <el-option label="已结束" :value="2" />
|
|
|
+ <el-option label="已停用" :value="3" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <el-row :gutter="10" class="mb8">
|
|
|
+ <el-col :span="1.5">
|
|
|
+ <el-button type="primary"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ size="mini"
|
|
|
+ @click="handleAdd"
|
|
|
+ v-has-permi="['course:checkinActivity:add']">活动配置</el-button>
|
|
|
+ </el-col>
|
|
|
+ <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
+ </el-row>
|
|
|
+
|
|
|
+ <el-table v-loading="loading" :data="list" border style="width: 100%">
|
|
|
+ <el-table-column label="活动ID" align="center" prop="activityId" min-width="80" />
|
|
|
+ <el-table-column label="活动名称" align="center" prop="activityName" min-width="150" show-overflow-tooltip />
|
|
|
+ <el-table-column label="活动时间" align="center" min-width="200">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>{{ scope.row.startTime }} 至 {{ scope.row.endTime }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="需要打卡天数" align="center" prop="checkinDays" min-width="100" />
|
|
|
+ <el-table-column label="参与公司" align="center" prop="companyNames" min-width="150" show-overflow-tooltip />
|
|
|
+ <el-table-column label="参与项目" align="center" prop="projectNames" min-width="150" show-overflow-tooltip />
|
|
|
+ <el-table-column label="活动状态" align="center" prop="status" min-width="100">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-tag v-if="scope.row.status === 0" type="info">未开始</el-tag>
|
|
|
+ <el-tag v-else-if="scope.row.status === 1" type="success">进行中</el-tag>
|
|
|
+ <el-tag v-else-if="scope.row.status === 2" type="danger">已结束</el-tag>
|
|
|
+ <el-tag v-else-if="scope.row.status === 3" type="warning">已停用</el-tag>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="创建时间" align="center" prop="createTime" min-width="160" />
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="150" fixed="right">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-edit"
|
|
|
+ @click="handleUpdate(scope.row)"
|
|
|
+ v-has-permi="['course:checkinActivity:edit']">修改</el-button>
|
|
|
+ <el-button size="mini"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ @click="handleDelete(scope.row)"
|
|
|
+ v-has-permi="['course:checkinActivity:remove']">删除</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <pagination
|
|
|
+ v-show="total>0"
|
|
|
+ :total="total"
|
|
|
+ :page.sync="queryParams.pageNum"
|
|
|
+ :limit.sync="queryParams.pageSize"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
+
|
|
|
+ <!-- 添加或修改活动配置对话框 -->
|
|
|
+ <el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
|
|
|
+ <el-form :model="form" ref="form" :rules="rules" label-width="120px">
|
|
|
+ <el-form-item label="活动名称" prop="activityName">
|
|
|
+ <el-input v-model="form.activityName" placeholder="请输入活动名称" clearable size="small" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="活动时间" prop="timeRange">
|
|
|
+ <el-date-picker
|
|
|
+ v-model="form.timeRange"
|
|
|
+ type="datetimerange"
|
|
|
+ range-separator="至"
|
|
|
+ start-placeholder="开始时间"
|
|
|
+ end-placeholder="结束时间"
|
|
|
+ value-format="yyyy-MM-dd HH:mm:ss"
|
|
|
+ size="small"
|
|
|
+ style="width: 100%">
|
|
|
+ </el-date-picker>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="参与公司" prop="companyIds">
|
|
|
+ <el-select filterable multiple v-model="form.companyIds" placeholder="请选择参与公司" size="small" style="width: 100%">
|
|
|
+ <el-option
|
|
|
+ v-for="item in companys"
|
|
|
+ :key="item.companyId"
|
|
|
+ :label="item.companyName"
|
|
|
+ :value="item.companyId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="参与项目" prop="projectIds">
|
|
|
+ <el-select filterable multiple v-model="form.projectIds" placeholder="请选择参与项目" size="small" style="width: 100%">
|
|
|
+ <el-option
|
|
|
+ v-for="item in projects"
|
|
|
+ :key="item.dictValue"
|
|
|
+ :label="item.dictLabel"
|
|
|
+ :value="item.dictValue"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="通知模板" prop="notifyTemplate">
|
|
|
+ <el-input
|
|
|
+ v-model="form.notifyTemplate"
|
|
|
+ type="textarea"
|
|
|
+ :rows="3"
|
|
|
+ placeholder="请输入通知模板"
|
|
|
+ size="small" />
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="活动状态" prop="status">
|
|
|
+ <el-select v-model="form.status" placeholder="请选择活动状态" size="small" style="width: 200px">
|
|
|
+ <el-option label="未开始" :value="0" />
|
|
|
+ <el-option label="进行中" :value="1" />
|
|
|
+ <el-option label="已结束" :value="2" />
|
|
|
+ <el-option label="已停用" :value="3" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="奖品类型" prop="prizeType">
|
|
|
+ <el-select v-model="form.prizeType" placeholder="请选择奖品类型" size="small" style="width: 200px">
|
|
|
+ <el-option :label="'红包'" :value="1" />
|
|
|
+ <el-option :label="'积分商品'" :value="2" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item v-if="form.prizeType === 1" label="红包金额" prop="redpacketAmount"
|
|
|
+ :rules="{ required: true, message: '红包金额不能为空', trigger: 'blur' }">
|
|
|
+ <el-input-number v-model="form.redpacketAmount" :min="0.01" :precision="2" :step="0.1" size="small" style="width: 200px" />
|
|
|
+ <span style="margin-left: 10px; color: #999;">元</span>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item v-if="form.prizeType === 2" label="积分商品" prop="prizeGoodsId"
|
|
|
+ :rules="{ required: true, message: '积分商品不能为空', trigger: 'change' }">
|
|
|
+ <el-select filterable v-model="form.prizeGoodsId" placeholder="请选择积分商品" clearable size="small" style="width: 100%" @change="handlePrizeGoodsChange">
|
|
|
+ <el-option
|
|
|
+ v-for="item in integralGoodsList"
|
|
|
+ :key="item.goodsId"
|
|
|
+ :label="item.goodsName"
|
|
|
+ :value="item.goodsId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item v-if="form.prizeType === 2 && form.prizeGoodsName" label="已选商品">
|
|
|
+ <el-tag type="success">{{ form.prizeGoodsName }}</el-tag>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="备注" prop="remark">
|
|
|
+ <el-input v-model="form.remark" type="textarea" :rows="2" placeholder="请输入备注" size="small" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <div slot="footer" class="dialog-footer">
|
|
|
+ <el-button @click="cancel">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getCompanyList } from "@/api/company/company";
|
|
|
+import request from '@/utils/request'
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: "CourseCheckIn",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ loading: true,
|
|
|
+ showSearch: true,
|
|
|
+ total: 0,
|
|
|
+ list: [],
|
|
|
+ companys: [],
|
|
|
+ projects: [],
|
|
|
+ integralGoodsList: [],
|
|
|
+ open: false,
|
|
|
+ title: "",
|
|
|
+ queryParams: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ activityName: null,
|
|
|
+ status: null
|
|
|
+ },
|
|
|
+ form: {
|
|
|
+ activityId: null,
|
|
|
+ activityName: null,
|
|
|
+ timeRange: [],
|
|
|
+ startTime: null,
|
|
|
+ endTime: null,
|
|
|
+ companyIds: [],
|
|
|
+ projectIds: [],
|
|
|
+ notifyTemplate: null,
|
|
|
+ status: 0,
|
|
|
+ prizeType: 1,
|
|
|
+ redpacketAmount: null,
|
|
|
+ prizeGoodsId: null,
|
|
|
+ prizeGoodsName: null,
|
|
|
+ prizeList: [],
|
|
|
+ remark: null
|
|
|
+ },
|
|
|
+ rules: {
|
|
|
+ activityName: [
|
|
|
+ { required: true, message: "活动名称不能为空", trigger: "blur" }
|
|
|
+ ],
|
|
|
+ timeRange: [
|
|
|
+ { required: true, message: "活动时间不能为空", trigger: "change" }
|
|
|
+ ],
|
|
|
+ companyIds: [
|
|
|
+ { required: true, message: "参与公司不能为空", trigger: "change" }
|
|
|
+ ],
|
|
|
+ projectIds: [
|
|
|
+ { required: true, message: "参与项目不能为空", trigger: "change" }
|
|
|
+ ],
|
|
|
+
|
|
|
+ }
|
|
|
+ };
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.getCompanyList();
|
|
|
+ this.getProjectList();
|
|
|
+ this.getIntegralGoodsList();
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getList() {
|
|
|
+ this.loading = true;
|
|
|
+ request({
|
|
|
+ url: '/course/checkinActivity/list',
|
|
|
+ method: 'get',
|
|
|
+ params: this.queryParams
|
|
|
+ }).then(response => {
|
|
|
+ this.list = response.rows || [];
|
|
|
+ this.total = response.total || 0;
|
|
|
+ this.loading = false;
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getCompanyList() {
|
|
|
+ getCompanyList().then(response => {
|
|
|
+ this.companys = response.data || [];
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getProjectList() {
|
|
|
+ this.getDicts("sys_course_project").then(response => {
|
|
|
+ this.projects = response.data || [];
|
|
|
+ });
|
|
|
+ },
|
|
|
+ getIntegralGoodsList() {
|
|
|
+ request({
|
|
|
+ url: '/his/integralGoods/list',
|
|
|
+ method: 'get',
|
|
|
+ params: { pageNum: 1, pageSize: 1000 }
|
|
|
+ }).then(response => {
|
|
|
+ this.integralGoodsList = response.rows || [];
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleQuery() {
|
|
|
+ this.queryParams.pageNum = 1;
|
|
|
+ this.getList();
|
|
|
+ },
|
|
|
+ resetQuery() {
|
|
|
+ this.resetForm("queryForm");
|
|
|
+ this.queryParams = {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ activityName: null,
|
|
|
+ status: null
|
|
|
+ };
|
|
|
+ this.handleQuery();
|
|
|
+ },
|
|
|
+ reset() {
|
|
|
+ this.form = {
|
|
|
+ activityId: null,
|
|
|
+ activityName: null,
|
|
|
+ timeRange: [],
|
|
|
+ startTime: null,
|
|
|
+ endTime: null,
|
|
|
+ companyIds: [],
|
|
|
+ projectIds: [],
|
|
|
+ notifyTemplate: null,
|
|
|
+ status: 0,
|
|
|
+ prizeType: 1,
|
|
|
+ redpacketAmount: null,
|
|
|
+ prizeGoodsId: null,
|
|
|
+ prizeGoodsName: null,
|
|
|
+ prizeList: [],
|
|
|
+ remark: null
|
|
|
+ };
|
|
|
+ },
|
|
|
+ handlePrizeGoodsChange(goodsId) {
|
|
|
+ if (goodsId) {
|
|
|
+ const goods = this.integralGoodsList.find(item => item.goodsId === goodsId);
|
|
|
+ this.form.prizeGoodsName = goods ? goods.goodsName : null;
|
|
|
+ } else {
|
|
|
+ this.form.prizeGoodsName = null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handlePrizeTypeChange(prizeType) {
|
|
|
+ // 切换类型时清空相关字段
|
|
|
+ this.form.redpacketAmount = null;
|
|
|
+ this.form.prizeGoodsId = null;
|
|
|
+ this.form.prizeGoodsName = null;
|
|
|
+ },
|
|
|
+ handleAdd() {
|
|
|
+ this.reset();
|
|
|
+ this.open = true;
|
|
|
+ this.title = "添加打卡活动";
|
|
|
+ // 等待对话框打开后再重置表单验证
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.resetForm("form");
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleUpdate(row) {
|
|
|
+ const activityId = row.activityId;
|
|
|
+ request({
|
|
|
+ url: '/course/checkinActivity/' + activityId,
|
|
|
+ method: 'get'
|
|
|
+ }).then(response => {
|
|
|
+ // 先重置表单
|
|
|
+ this.reset();
|
|
|
+ // 使用 Object.assign 合并数据,保持响应式
|
|
|
+ Object.assign(this.form, response.data);
|
|
|
+ this.$set(this.form, 'timeRange', [this.form.startTime, this.form.endTime]);
|
|
|
+ // 将逗号分隔的字符串转为数组
|
|
|
+ if (this.form.companyIds) {
|
|
|
+ this.$set(this.form, 'companyIds', this.form.companyIds.split(',').map(id => parseInt(id)));
|
|
|
+ } else {
|
|
|
+ this.$set(this.form, 'companyIds', []);
|
|
|
+ }
|
|
|
+ if (this.form.projectIds) {
|
|
|
+ this.$set(this.form, 'projectIds', this.form.projectIds.split(','));
|
|
|
+ } else {
|
|
|
+ this.$set(this.form, 'projectIds', []);
|
|
|
+ }
|
|
|
+ // 处理奖品数据 - 从prizeList解析单个奖品
|
|
|
+ if (this.form.prizeList && this.form.prizeList.length > 0) {
|
|
|
+ const prize = this.form.prizeList[0];
|
|
|
+ this.$set(this.form, 'prizeType', Number(prize.prizeType));
|
|
|
+ if (this.form.prizeType === 1) {
|
|
|
+ this.$set(this.form, 'redpacketAmount', prize.redpacketAmount);
|
|
|
+ } else if (this.form.prizeType === 2) {
|
|
|
+ this.$set(this.form, 'prizeGoodsId', prize.goodsId);
|
|
|
+ this.handlePrizeGoodsChange(prize.goodsId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.open = true;
|
|
|
+ this.title = "修改打卡活动";
|
|
|
+ // 等待对话框打开后再清除验证状态
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if (this.$refs.form) {
|
|
|
+ this.$refs.form.clearValidate();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleDelete(row) {
|
|
|
+ const activityIds = row.activityId;
|
|
|
+ this.$confirm('是否确认删除该打卡活动?', "警告", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(() => {
|
|
|
+ return request({
|
|
|
+ url: '/course/checkinActivity/' + activityIds,
|
|
|
+ method: 'delete'
|
|
|
+ });
|
|
|
+ }).then(() => {
|
|
|
+ this.getList();
|
|
|
+ this.msgSuccess("删除成功");
|
|
|
+ }).catch(() => {});
|
|
|
+ },
|
|
|
+ cancel() {
|
|
|
+ this.open = false;
|
|
|
+ this.reset();
|
|
|
+ },
|
|
|
+ submitForm() {
|
|
|
+ this.$refs["form"].validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+ const prizeList = [];
|
|
|
+ if (this.form.prizeType === 1) {
|
|
|
+ prizeList.push({
|
|
|
+ prizeType: 1,
|
|
|
+ redpacketAmount: this.form.redpacketAmount
|
|
|
+ });
|
|
|
+ } else if (this.form.prizeType === 2) {
|
|
|
+ prizeList.push({
|
|
|
+ prizeType: 2,
|
|
|
+ goodsId: this.form.prizeGoodsId
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ const submitData = {
|
|
|
+ activityId: this.form.activityId,
|
|
|
+ activityName: this.form.activityName,
|
|
|
+ startTime: this.form.timeRange[0],
|
|
|
+ endTime: this.form.timeRange[1],
|
|
|
+ companyIds: this.form.companyIds.join(','),
|
|
|
+ projectIds: this.form.projectIds.join(','),
|
|
|
+ notifyTemplate: this.form.notifyTemplate,
|
|
|
+ status: this.form.status,
|
|
|
+ prizeList: prizeList,
|
|
|
+ remark: this.form.remark
|
|
|
+ };
|
|
|
+
|
|
|
+ if (this.form.activityId != null) {
|
|
|
+ request({
|
|
|
+ url: '/course/checkinActivity/edit',
|
|
|
+ method: 'put',
|
|
|
+ data: submitData
|
|
|
+ }).then(() => {
|
|
|
+ this.msgSuccess("修改成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ request({
|
|
|
+ url: '/course/checkinActivity/add',
|
|
|
+ method: 'post',
|
|
|
+ data: submitData
|
|
|
+ }).then(() => {
|
|
|
+ this.msgSuccess("新增成功");
|
|
|
+ this.open = false;
|
|
|
+ this.getList();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped>
|
|
|
+.prize-item {
|
|
|
+ margin-bottom: 10px;
|
|
|
+}
|
|
|
+.clearfix:before,
|
|
|
+.clearfix:after {
|
|
|
+ display: table;
|
|
|
+ content: "";
|
|
|
+}
|
|
|
+.clearfix:after {
|
|
|
+ clear: both;
|
|
|
+}
|
|
|
+</style>
|