|
|
@@ -90,6 +90,30 @@
|
|
|
</el-dropdown>
|
|
|
</el-col>
|
|
|
|
|
|
+ <el-col :span="1.5" v-if="isAdmin">
|
|
|
+ <el-dropdown
|
|
|
+ @command="handleHeadquartersCommand"
|
|
|
+ trigger="click"
|
|
|
+ placement="bottom-start"
|
|
|
+ >
|
|
|
+ <el-dropdown-menu slot="dropdown" style="width: 120px;">
|
|
|
+ <el-dropdown-item
|
|
|
+ v-for="option in sysQwSopType"
|
|
|
+ :key="option.dictValue"
|
|
|
+ :command="option.dictValue"
|
|
|
+ >
|
|
|
+ <i :class="option.iconClass" style="margin-right: 10px;"></i>
|
|
|
+ {{ option.dictLabel }}
|
|
|
+ </el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ <span class="el-dropdown-link">
|
|
|
+ <el-button type="success" icon="el-icon-plus" plain size="mini">
|
|
|
+ 创建总后台模板
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
+ </el-dropdown>
|
|
|
+ </el-col>
|
|
|
+
|
|
|
<el-col :span="1.5">
|
|
|
<el-button
|
|
|
type="danger"
|
|
|
@@ -125,7 +149,15 @@
|
|
|
<el-tag v-for="item in companys" v-if="scope.row.companyId == item.companyId">{{ item.companyName }}</el-tag>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
- <el-table-column label="模板标题" align="center" prop="name"/>
|
|
|
+ <el-table-column label="模板标题" align="center" prop="name">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <span>
|
|
|
+ <el-tag v-if="scope.row.isTop === 1" type="warning" size="mini" style="margin-right: 5px;">置顶</el-tag>
|
|
|
+ <el-tag v-if="scope.row.templateType === 1" type="primary" size="mini" style="margin-right: 5px;">总后台</el-tag>
|
|
|
+ {{ scope.row.name }}
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="模板类型" align="center" prop="sendType">
|
|
|
<template slot-scope="scope">
|
|
|
<dict-tag :options="sysQwSopType" :value="scope.row.sendType"/>
|
|
|
@@ -160,6 +192,7 @@
|
|
|
>详情
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
+ v-if="canEdit(scope.row)"
|
|
|
size="mini"
|
|
|
type="text"
|
|
|
icon="el-icon-edit"
|
|
|
@@ -168,6 +201,7 @@
|
|
|
>修改
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
+ v-if="canEdit(scope.row)"
|
|
|
size="mini"
|
|
|
type="text"
|
|
|
icon="el-icon-edit"
|
|
|
@@ -180,7 +214,7 @@
|
|
|
type="text"
|
|
|
icon="el-icon-edit"
|
|
|
@click="handleUpdateRed(scope.row)"
|
|
|
- v-if="scope.row.sendType == 5"
|
|
|
+ v-if="scope.row.sendType == 5 && canEdit(scope.row)"
|
|
|
v-hasPermi="['qw:sopTemp:edit']"
|
|
|
>红包设置
|
|
|
</el-button>
|
|
|
@@ -229,6 +263,15 @@
|
|
|
</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="是否置顶" v-if="isHeadquarters">
|
|
|
+ <el-switch
|
|
|
+ v-model="form.isTop"
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="0"
|
|
|
+ active-text="是"
|
|
|
+ inactive-text="否">
|
|
|
+ </el-switch>
|
|
|
+ </el-form-item>
|
|
|
<el-form-item label="所属项目" prop="project" v-if="form.sendType != 5">
|
|
|
<el-select v-model="form.project" placeholder="请选择项目" filterable clearable size="small">
|
|
|
<el-option
|
|
|
@@ -308,6 +351,8 @@
|
|
|
<script>
|
|
|
import {
|
|
|
addTemp,
|
|
|
+ addHeadquartersTemplate,
|
|
|
+ toggleTop,
|
|
|
copyTemplate,
|
|
|
delSopTemp,
|
|
|
exportSopTemp,
|
|
|
@@ -327,6 +372,10 @@ export default {
|
|
|
name: "SopTemp",
|
|
|
data() {
|
|
|
return {
|
|
|
+ // 是否为总后台用户
|
|
|
+ isAdmin: false,
|
|
|
+ // 是否为总后台模板操作
|
|
|
+ isHeadquarters: false,
|
|
|
// 遮罩层
|
|
|
loading: true,
|
|
|
companysloading: false,
|
|
|
@@ -422,6 +471,10 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
+ // 检查是否为总后台用户(admin角色)
|
|
|
+ const roles = this.$store.getters.roles || [];
|
|
|
+ this.isAdmin = roles.includes('admin');
|
|
|
+
|
|
|
this.getList();
|
|
|
this.getDicts("sys_company_status").then(response => {
|
|
|
this.statusOptions = response.data;
|
|
|
@@ -479,6 +532,8 @@ export default {
|
|
|
time: "",
|
|
|
timeList: [{value: ""}],
|
|
|
status: "1",
|
|
|
+ isTop: 0,
|
|
|
+ templateType: this.isHeadquarters ? 1 : 0,
|
|
|
};
|
|
|
this.resetForm("form");
|
|
|
},
|
|
|
@@ -498,12 +553,21 @@ export default {
|
|
|
// this.$router.push('/qw/sopTemp/addAiChatTemp')
|
|
|
// }else{
|
|
|
this.sendType = command;
|
|
|
+ this.isHeadquarters = false;
|
|
|
this.title = "新增";
|
|
|
this.reset();
|
|
|
this.open = true;
|
|
|
// this.$router.push('/qw/sopTemp/addTemp/'+command)
|
|
|
// }
|
|
|
},
|
|
|
+ /** 创建总后台模板命令 */
|
|
|
+ handleHeadquartersCommand(command) {
|
|
|
+ this.sendType = command;
|
|
|
+ this.isHeadquarters = true;
|
|
|
+ this.title = "创建总后台模板";
|
|
|
+ this.reset();
|
|
|
+ this.open = true;
|
|
|
+ },
|
|
|
// 多选框选中数据
|
|
|
handleSelectionChange(selection) {
|
|
|
this.ids = selection.map(item => item.id)
|
|
|
@@ -530,6 +594,30 @@ export default {
|
|
|
this.$router.push(`/course/sopTempe/updateSopTemp/${row.id}/3`)
|
|
|
// }
|
|
|
},
|
|
|
+ /** 判断是否可以编辑 */
|
|
|
+ canEdit(row) {
|
|
|
+ // 总后台用户可以编辑所有模板
|
|
|
+ if (this.isAdmin) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 子公司用户不能编辑总后台模板
|
|
|
+ if (row.templateType === 1) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ /** 判断是否可以删除 */
|
|
|
+ canDelete(row) {
|
|
|
+ // 总后台用户可以删除所有模板
|
|
|
+ if (this.isAdmin) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ // 子公司用户不能删除总后台模板
|
|
|
+ if (row.templateType === 1) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
|
// if (row.sendType==4) {
|
|
|
@@ -578,26 +666,43 @@ export default {
|
|
|
* 复制模板
|
|
|
*/
|
|
|
copyTemplate(row) {
|
|
|
- // if(row.sendType==4){
|
|
|
- // this.$router.push(`/qw/sopTemp/updateAiChatTemp/${row.id}/2`)
|
|
|
- // }else{
|
|
|
- this.getInfo(row.id, 2);
|
|
|
- // this.$router.push(`/qw/sopTemp/updateSopTemp/${row.id}/2`)
|
|
|
- // }
|
|
|
+ // 如果是总后台模板,弹出确认对话框
|
|
|
+ if (row.templateType === 1) {
|
|
|
+ this.$confirm('您正在复制【总后台模板】,复制后将成为您公司的普通模板,是否继续?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ this.getInfo(row.id, 2);
|
|
|
+ }).catch(() => {
|
|
|
+ // 用户取消操作
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 普通模板直接复制
|
|
|
+ this.getInfo(row.id, 2);
|
|
|
+ }
|
|
|
},
|
|
|
getInfo(id, command) {
|
|
|
getSopTemp(id).then(response => {
|
|
|
this.command = command;
|
|
|
if (command == 2) {
|
|
|
this.title = "复制";
|
|
|
+ this.isHeadquarters = false;
|
|
|
}
|
|
|
if (command == 1) {
|
|
|
this.title = "修改";
|
|
|
+ this.isHeadquarters = response.data.templateType === 1;
|
|
|
}
|
|
|
this.form = response.data;
|
|
|
if(response.data.project){
|
|
|
this.form.project = String(response.data.project)
|
|
|
}
|
|
|
+ // 复制总后台模板时,将templateType设置为0(普通模板)
|
|
|
+ if (command == 2 && response.data.templateType === 1) {
|
|
|
+ this.form.templateType = 0;
|
|
|
+ this.form.isTop = 0;
|
|
|
+ this.form.name = response.data.name + '_副本';
|
|
|
+ }
|
|
|
this.open = true;
|
|
|
});
|
|
|
},
|
|
|
@@ -617,27 +722,51 @@ export default {
|
|
|
background: 'rgba(0, 0, 0, 0.7)'
|
|
|
});
|
|
|
if (this.command == 2) {
|
|
|
+ // 复制模板
|
|
|
copyTemplate(f).then(response => {
|
|
|
this.msgSuccess("复制成功");
|
|
|
this.open = false;
|
|
|
loading.close();
|
|
|
this.getList();
|
|
|
+ }).catch(() => {
|
|
|
+ loading.close();
|
|
|
});
|
|
|
} else {
|
|
|
if (f.id != null) {
|
|
|
+ // 修改模板
|
|
|
updateTemp(f).then(response => {
|
|
|
this.msgSuccess("修改成功");
|
|
|
this.open = false;
|
|
|
loading.close();
|
|
|
this.getList();
|
|
|
- });
|
|
|
- } else {
|
|
|
- addTemp(f).then(response => {
|
|
|
- this.msgSuccess("新增成功");
|
|
|
- this.open = false;
|
|
|
+ }).catch(() => {
|
|
|
loading.close();
|
|
|
- this.getList();
|
|
|
});
|
|
|
+ } else {
|
|
|
+ // 新增模板:判断是否为总后台模板
|
|
|
+ if (this.isHeadquarters) {
|
|
|
+ // 调用新增总后台模板接口
|
|
|
+ f.templateType = 1;
|
|
|
+ addHeadquartersTemplate(f).then(response => {
|
|
|
+ this.msgSuccess("新增总后台模板成功");
|
|
|
+ this.open = false;
|
|
|
+ loading.close();
|
|
|
+ this.getList();
|
|
|
+ }).catch(() => {
|
|
|
+ loading.close();
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ // 调用普通模板接口
|
|
|
+ f.templateType = 0;
|
|
|
+ addTemp(f).then(response => {
|
|
|
+ this.msgSuccess("新增成功");
|
|
|
+ this.open = false;
|
|
|
+ loading.close();
|
|
|
+ this.getList();
|
|
|
+ }).catch(() => {
|
|
|
+ loading.close();
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|