Files
admin-ui/src/views/customerService/script/index.vue

224 lines
5.4 KiB
Vue
Raw Normal View History

2025-11-22 16:39:01 +08:00
<template>
2025-11-24 16:55:18 +08:00
<div class="system-role-container">
<el-card shadow="hover">
<div class="system-user-search mb15">
<el-form :inline="true">
<el-form-item>
<el-button size="default" type="success" class="ml10" @click="onOpenAddRole">
<el-icon>
<ele-FolderAdd />
</el-icon>
新增话术
</el-button>
</el-form-item>
</el-form>
</div>
<el-table :data="tableData.data" style="width: 100%">
<el-table-column type="index" label="序号" width="60" />
<el-table-column prop="label" label="标签" show-overflow-tooltip></el-table-column>
<el-table-column prop="creator" label="创建人" show-overflow-tooltip></el-table-column>
<el-table-column prop="creator" label="修改人" show-overflow-tooltip></el-table-column>
<el-table-column prop="createdAt" label="创建时间" show-overflow-tooltip></el-table-column>
<el-table-column prop="createdAt" label="修改时间" show-overflow-tooltip></el-table-column>
<el-table-column label="操作" width="220">
<template #default="scope">
<el-button size="small" text type="primary" @click="onOpenEditRole(scope.row)"
><el-icon><ele-EditPen /></el-icon>修改</el-button
>
<el-button size="small" text type="primary" @click="onRowDel(scope.row)"
><el-icon><ele-DeleteFilled /></el-icon>删除</el-button
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="tableData.total > 0"
:total="tableData.total"
v-model:page="tableData.param.pageNum"
v-model:limit="tableData.param.pageSize"
@pagination="roleList"
/>
</el-card>
<EditRole ref="editRoleRef" @getRoleList="roleList" />
</div>
2025-11-22 16:39:01 +08:00
</template>
2025-11-24 16:55:18 +08:00
<script lang="ts" setup>
2025-11-22 16:39:01 +08:00
import { toRefs, reactive, onMounted, ref, defineComponent, toRaw, getCurrentInstance } from 'vue';
import { ElMessageBox, ElMessage } from 'element-plus';
import EditRole from '/@/views/customerService/script/component/editRole.vue';
2025-11-25 17:02:31 +08:00
import { deleteRole, getRoleList } from '/@/api/customerService/script';
2025-11-22 16:39:01 +08:00
// 定义接口来定义对象的类型
interface TableData {
2025-11-24 16:55:18 +08:00
id: number;
status: number;
listOrder: number;
name: string;
remark: string;
dataScope: number;
createdAt: string;
2025-11-22 16:39:01 +08:00
}
interface TableDataState {
2025-11-24 16:55:18 +08:00
data: Array<TableData>;
total: number;
loading: boolean;
param: {
roleName: string;
roleStatus: string;
pageNum: number;
pageSize: number;
};
2025-11-22 16:39:01 +08:00
}
2025-11-24 16:55:18 +08:00
//模拟数据
2025-11-22 16:39:01 +08:00
const dateList = ref([
2025-11-24 16:55:18 +08:00
{
id: 1,
status: 1,
listOrder: 0,
name: '987698789',
remark: '小红书',
dataScope: 3,
createdAt: '2022-04-01 11:38:39',
updatedAt: '2022-04-28 10:00:15',
label: '产品介绍',
creator: '张三',
},
{
id: 2,
status: 1,
listOrder: 0,
name: '987698789',
remark: '抖音',
dataScope: 3,
createdAt: '2022-04-01 11:38:39',
updatedAt: '2022-04-28 10:01:34',
label: '公司介绍',
creator: '张三',
},
{
id: 3,
status: 1,
listOrder: 0,
name: '987698789',
remark: '快手',
dataScope: 3,
createdAt: '2022-04-01 11:38:39',
updatedAt: '2022-04-01 11:38:39',
label: '病症询问',
creator: '王五',
},
{
id: 4,
status: 1,
listOrder: 0,
name: '987698789',
remark: '抖音',
dataScope: 3,
createdAt: '2022-04-01 11:38:39',
updatedAt: '2022-04-01 11:38:39',
label: '资质问题',
creator: '李四',
},
{
id: 5,
status: 1,
listOrder: 0,
name: '987698789',
remark: '抖音',
dataScope: 2,
createdAt: '2022-04-01 11:38:39',
updatedAt: '2022-04-01 11:38:39',
label: '常用沟通',
creator: '张三',
},
{
id: 8,
status: 1,
listOrder: 0,
name: '987698789',
remark: '快手',
dataScope: 2,
createdAt: '2022-04-01 11:38:39',
updatedAt: '2022-04-06 09:53:40',
label: '公司介绍',
creator: '张三',
},
]);
2025-11-22 16:39:01 +08:00
2025-11-24 16:55:18 +08:00
const { proxy } = getCurrentInstance() as any;
const addRoleRef = ref();
const editRoleRef = ref();
const dataScopeRef = ref();
const tableData = reactive<TableDataState>({
data: [],
total: 0,
loading: false,
param: {
roleName: '',
roleStatus: '',
pageNum: 1,
pageSize: 10,
},
});
// 初始化表格数据
const initTableData = () => {
roleList();
};
const roleList = () => {
const data: Array<TableData> = [];
getRoleList(tableData.param).then((res) => {
const list = res.data.list ?? [];
list.map((item: TableData) => {
data.push({
id: item.id,
status: item.status,
listOrder: item.listOrder,
name: item.name,
remark: item.remark,
dataScope: item.dataScope,
createdAt: item.createdAt,
});
});
tableData.data = dateList.value;
tableData.total = dateList.value.length;
});
};
// 打开新增角色弹窗
const onOpenAddRole = () => {
editRoleRef.value.openDialog();
};
// 打开修改角色弹窗
const onOpenEditRole = (row: Object) => {
editRoleRef.value.openDialog(toRaw(row));
};
2025-11-22 16:39:01 +08:00
2025-11-24 16:55:18 +08:00
// 删除角色
const onRowDel = (row: any) => {
ElMessageBox.confirm(`此操作将永久删除角色:“${row.name}”,是否继续?`, '提示', {
confirmButtonText: '确认',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
deleteRole(row.id).then(() => {
ElMessage.success('删除成功');
proxy.$refs['editRoleRef'].resetMenuSession();
roleList();
});
})
.catch(() => {});
};
// 分页改变
const onHandleSizeChange = (val: number) => {
tableData.param.pageSize = val;
};
// 分页改变
const onHandleCurrentChange = (val: number) => {
tableData.param.pageNum = val;
};
// 页面加载时
onMounted(() => {
initTableData();
2025-11-22 16:39:01 +08:00
});
</script>