feat: 项目和方案

This commit is contained in:
zhanghao 2025-11-26 13:34:32 +08:00
parent 710f7f191e
commit f05537cb7e
4 changed files with 126 additions and 67 deletions

View File

@ -0,0 +1,9 @@
import request from '@/utils/request'
export const getDictList = (params) => {
return request({
url: '/system/dict/data/list',
method: 'get',
params
})
}

View File

@ -104,10 +104,6 @@ import { ElImageViewer } from 'element-plus'
import { getFunction } from '@/api/is/func/index' import { getFunction } from '@/api/is/func/index'
const props = defineProps({ const props = defineProps({
corpusIds: {
type: String,
default: "",
},
selectNode: { selectNode: {
type: Object, type: Object,
default: () => {} default: () => {}

View File

@ -1,23 +1,20 @@
<template> <template>
<div> <div>
<div class="btn-container"> <div class="btn-container">
<el-button type="primary" @click="openDialog">方案选择</el-button> <el-button type="primary" @click="openDialog">功能选择</el-button>
</div> </div>
<el-table :data="selectList" height="260"> <el-table :data="selectList" height="260">
<el-table-column <el-table-column
label="功能名称" label="功能名称"
align="center" align="center"
prop="corpusName" prop="dictLabel"
width="150"
show-overflow-tooltip /> show-overflow-tooltip />
<el-table-column <el-table-column
label="功能图片" label="功能图片"
align="center" align="center"
prop="textContent" prop="textContent"
width="150"
show-overflow-tooltip show-overflow-tooltip
/> />
<el-table-column label="功能/界面" align="center" prop="voiceType" />
</el-table> </el-table>
<el-dialog title="选择功能" v-model="open" width="700px"> <el-dialog title="选择功能" v-model="open" width="700px">
@ -27,9 +24,9 @@
:inline="true" :inline="true"
label-width="68px" label-width="68px"
> >
<el-form-item label="功能名称" prop="corpusName"> <el-form-item label="功能名称" prop="dictLabel">
<el-input <el-input
v-model="queryParams.corpusName" v-model="queryParams.dictLabel"
placeholder="请输入功能名称" placeholder="请输入功能名称"
clearable clearable
@keyup.enter="getList" @keyup.enter="getList"
@ -44,10 +41,11 @@
</el-form> </el-form>
<el-table <el-table
ref="tableRef" ref="tableRef"
:data="corpusList" :data="functionList"
:tree-props="{ checkStrictly: true }" :tree-props="{ checkStrictly: true }"
:row-key="rowKey" :row-key="rowKey"
:height="400" :height="400"
@row-click="rowClick"
> >
<el-table-column <el-table-column
type="selection" type="selection"
@ -59,18 +57,10 @@
<el-table-column <el-table-column
label="功能名称" label="功能名称"
align="center" align="center"
prop="corpusName" prop="dictLabel"
min-width="100" min-width="100"
show-overflow-tooltip show-overflow-tooltip
/> />
<el-table-column
label="功能图片"
align="center"
prop="textContent"
min-width="200"
show-overflow-tooltip
/>
<el-table-column label="是否功能" align="center" prop="voiceType" />
</el-table> </el-table>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -83,18 +73,23 @@
</template> </template>
<script setup> <script setup>
import { onMounted } from "vue"; import { onMounted } from "vue";
import { getDictList } from '@/api/is/project/index'
const props = defineProps({ const props = defineProps({
corpusIds: { selectIds: {
type: String, type: Array,
default: "", default: () => []
}, },
funcIds: {
type: String,
default: ''
}
}); });
const emits = defineEmits(["updateSelectRows"]); const emits = defineEmits(["updateSelectRows"]);
const selectList = ref([]); const selectList = ref([]);
const corpusList = ref([]); const functionList = ref([]);
const open = ref(false); const open = ref(false);
const openDialog = () => { const openDialog = () => {
@ -106,21 +101,16 @@ const openDialog = () => {
const toggleRowSelection = () => { const toggleRowSelection = () => {
if (selectList.value.length > 0) { if (selectList.value.length > 0) {
corpusList.value.forEach((row) => { functionList.value.forEach((row) => {
selectList.value.forEach((item) => { selectList.value.forEach((item) => {
if (
item.parentId + (item?.corpusId || "") ===
row.parentId + (row?.corpusId || "")
) {
tableRef.value.toggleRowSelection(row, true);
}
}); });
}); });
} }
}; };
const rowKey = (row) => { const rowKey = (row) => {
return row.parentId + (row?.corpusId || ""); return row.dictCode;
}; };
const selectable = (row) => { const selectable = (row) => {
@ -134,15 +124,22 @@ const selectable = (row) => {
const queryParams = ref({ const queryParams = ref({
pageNum: 1, pageNum: 1,
pageSize: 100000, pageSize: 100000,
corpusName: '', dictLabel: '',
continuous: 1 continuous: 1
}) })
const getList = () => {
const getList = async () => {
const res = await getDictList({
dictType: 'ti_function_config',
dictLabel: queryParams.value.dictLabel
})
if (res.code === 200) {
functionList.value = res.rows
}
}; };
const resetForm = () => { const resetForm = () => {
queryParams.value.corpusName = '' queryParams.value.dictLabel = ''
getList() getList()
} }
@ -164,6 +161,10 @@ const getSelectList = (corpusIds) => {
}; };
const rowClick = (row) => {
tableRef.value.toggleRowSelection(row)
}
onMounted(() => { onMounted(() => {
getList(); getList();
if (props.corpusIds) { if (props.corpusIds) {

View File

@ -43,28 +43,6 @@
>新增</el-button >新增</el-button
> >
</el-col> </el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="Edit"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:scheme:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="Delete"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:scheme:remove']"
>删除</el-button
>
</el-col>
<right-toolbar <right-toolbar
v-model:showSearch="showSearch" v-model:showSearch="showSearch"
@queryTable="getList" @queryTable="getList"
@ -82,6 +60,11 @@
<el-table-column type="selection" width="55" align="center" /> <el-table-column type="selection" width="55" align="center" />
<el-table-column label="方案ID" align="center" prop="schemeId" min-width="150" show-overflow-tooltip /> <el-table-column label="方案ID" align="center" prop="schemeId" min-width="150" show-overflow-tooltip />
<el-table-column label="所属项目ID" align="center" prop="projectId" min-width="150" show-overflow-tooltip /> <el-table-column label="所属项目ID" align="center" prop="projectId" min-width="150" show-overflow-tooltip />
<el-table-column label="场景" align="center" prop="projectId" min-width="150">
<template #default="{row}">
<div>{{ formatSceneType(row.sceneType) }}</div>
</template>
</el-table-column>
<el-table-column label="方案名称" align="center" prop="schemeName" min-width="150" show-overflow-tooltip /> <el-table-column label="方案名称" align="center" prop="schemeName" min-width="150" show-overflow-tooltip />
<el-table-column label="排序" align="center" prop="sort" /> <el-table-column label="排序" align="center" prop="sort" />
<el-table-column label="备注" align="center" prop="remark" min-width="150" show-overflow-tooltip /> <el-table-column label="备注" align="center" prop="remark" min-width="150" show-overflow-tooltip />
@ -130,7 +113,7 @@
:append-to-body="false" :append-to-body="false"
body-class="plan_dialog" body-class="plan_dialog"
> >
<el-form ref="schemeRef" :model="form" :rules="rules" label-width="100px"> <el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="方案名称" prop="schemeName"> <el-form-item label="方案名称" prop="schemeName">
<el-input v-model="form.schemeName" placeholder="请输入方案名称" /> <el-input v-model="form.schemeName" placeholder="请输入方案名称" />
</el-form-item> </el-form-item>
@ -160,7 +143,7 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
<FunctionSelection /> <FunctionSelection :funcIds="form.funcIds" :selectIds="selectIds" @updateSelectRows="getSelectRows" />
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
@ -193,15 +176,12 @@ const total = ref(0);
const title = ref(""); const title = ref("");
const data = reactive({ const data = reactive({
form: { form: {},
corpusIds: null,
},
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
projectId: route.params.id, projectId: route.params.id,
schemeName: null, schemeName: null,
corpusIds: null,
}, },
rules: { rules: {
projectId: [ projectId: [
@ -220,10 +200,30 @@ function getList() {
schemeList.value = [ schemeList.value = [
{ {
schemeId: 1, schemeId: 1,
schemeName: 'test', schemeName: 'test1',
projectId: 1, projectId: 1,
sceneType: 1,
sort: 1, sort: 1,
remark: '1111', remark: 'test1',
funcIds: '129'
},
{
schemeId: 2,
schemeName: 'test2',
projectId: 1,
sort: 2,
sceneType: 2,
remark: 'test2',
funcIds: '130'
},
{
schemeId: 3,
schemeName: 'test3',
projectId: 1,
sceneType: 3,
sort: 3,
remark: 'test3',
funcIds: '131'
} }
] ]
} }
@ -241,9 +241,15 @@ function reset() {
schemeName: null, schemeName: null,
corpusIds: null, corpusIds: null,
remark: null, remark: null,
sceneType: null,
funcIds: ''
}; };
} }
const formatSceneType = (sceneType) => {
return settingOptions.find(item => item.value === sceneType).label
}
/** 搜索按钮操作 */ /** 搜索按钮操作 */
function handleQuery() { function handleQuery() {
queryParams.value.pageNum = 1; queryParams.value.pageNum = 1;
@ -268,12 +274,59 @@ const settingOptions = [
{ value: 3, label: "连续对话场景" }, { value: 3, label: "连续对话场景" },
]; ];
const isAdd = ref(true)
/** 新增按钮操作 */ /** 新增按钮操作 */
function handleAdd() { function handleAdd() {
reset(); reset();
open.value = true; open.value = true;
isAdd.value = true
title.value = "添加方案"; title.value = "添加方案";
} }
const selectIds = ref([])
const getSelectRows = (arr) => {
selectIds.value = arr.map(item => item.id);
};
const formRef = ref()
const submitForm = () => {
if (!formRef.value) return
if (isAdd.value) {
schemeList.value.unshift(
{
...form.value,
schemeId: new Date().getTime(),
projectId: 1
}
)
}
reset();
open.value = false
}
const handleUpdate = (row) => {
reset();
open.value = true;
isAdd.value = false
title.value = "修改测试项目";
form.value = row
}
const handleDelete = (row) => {
ElMessageBox.confirm(
`确定要删除项目"${row.schemeName}"吗?`,
'警告',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
).then(async () => {
schemeList.value = schemeList.value.filter(item => item.schemeId !== row.schemeId)
})
}
onMounted(() => { onMounted(() => {
getList(); getList();
}); });