feat: 项目和方案
This commit is contained in:
parent
710f7f191e
commit
f05537cb7e
9
src/api/is/project/index.js
Normal file
9
src/api/is/project/index.js
Normal file
@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export const getDictList = (params) => {
|
||||
return request({
|
||||
url: '/system/dict/data/list',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
@ -104,10 +104,6 @@ import { ElImageViewer } from 'element-plus'
|
||||
import { getFunction } from '@/api/is/func/index'
|
||||
|
||||
const props = defineProps({
|
||||
corpusIds: {
|
||||
type: String,
|
||||
default: "",
|
||||
},
|
||||
selectNode: {
|
||||
type: Object,
|
||||
default: () => {}
|
||||
|
||||
@ -1,23 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="btn-container">
|
||||
<el-button type="primary" @click="openDialog">方案选择</el-button>
|
||||
<el-button type="primary" @click="openDialog">功能选择</el-button>
|
||||
</div>
|
||||
<el-table :data="selectList" height="260">
|
||||
<el-table-column
|
||||
label="功能名称"
|
||||
align="center"
|
||||
prop="corpusName"
|
||||
width="150"
|
||||
prop="dictLabel"
|
||||
show-overflow-tooltip />
|
||||
<el-table-column
|
||||
label="功能图片"
|
||||
align="center"
|
||||
prop="textContent"
|
||||
width="150"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="功能/界面" align="center" prop="voiceType" />
|
||||
</el-table>
|
||||
|
||||
<el-dialog title="选择功能" v-model="open" width="700px">
|
||||
@ -27,9 +24,9 @@
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="功能名称" prop="corpusName">
|
||||
<el-form-item label="功能名称" prop="dictLabel">
|
||||
<el-input
|
||||
v-model="queryParams.corpusName"
|
||||
v-model="queryParams.dictLabel"
|
||||
placeholder="请输入功能名称"
|
||||
clearable
|
||||
@keyup.enter="getList"
|
||||
@ -44,10 +41,11 @@
|
||||
</el-form>
|
||||
<el-table
|
||||
ref="tableRef"
|
||||
:data="corpusList"
|
||||
:data="functionList"
|
||||
:tree-props="{ checkStrictly: true }"
|
||||
:row-key="rowKey"
|
||||
:height="400"
|
||||
@row-click="rowClick"
|
||||
>
|
||||
<el-table-column
|
||||
type="selection"
|
||||
@ -59,18 +57,10 @@
|
||||
<el-table-column
|
||||
label="功能名称"
|
||||
align="center"
|
||||
prop="corpusName"
|
||||
prop="dictLabel"
|
||||
min-width="100"
|
||||
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>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@ -83,18 +73,23 @@
|
||||
</template>
|
||||
<script setup>
|
||||
import { onMounted } from "vue";
|
||||
import { getDictList } from '@/api/is/project/index'
|
||||
|
||||
const props = defineProps({
|
||||
corpusIds: {
|
||||
type: String,
|
||||
default: "",
|
||||
selectIds: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
funcIds: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
});
|
||||
|
||||
const emits = defineEmits(["updateSelectRows"]);
|
||||
|
||||
const selectList = ref([]);
|
||||
const corpusList = ref([]);
|
||||
const functionList = ref([]);
|
||||
|
||||
const open = ref(false);
|
||||
const openDialog = () => {
|
||||
@ -106,21 +101,16 @@ const openDialog = () => {
|
||||
|
||||
const toggleRowSelection = () => {
|
||||
if (selectList.value.length > 0) {
|
||||
corpusList.value.forEach((row) => {
|
||||
functionList.value.forEach((row) => {
|
||||
selectList.value.forEach((item) => {
|
||||
if (
|
||||
item.parentId + (item?.corpusId || "") ===
|
||||
row.parentId + (row?.corpusId || "")
|
||||
) {
|
||||
tableRef.value.toggleRowSelection(row, true);
|
||||
}
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const rowKey = (row) => {
|
||||
return row.parentId + (row?.corpusId || "");
|
||||
return row.dictCode;
|
||||
};
|
||||
|
||||
const selectable = (row) => {
|
||||
@ -134,15 +124,22 @@ const selectable = (row) => {
|
||||
const queryParams = ref({
|
||||
pageNum: 1,
|
||||
pageSize: 100000,
|
||||
corpusName: '',
|
||||
dictLabel: '',
|
||||
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 = () => {
|
||||
queryParams.value.corpusName = ''
|
||||
queryParams.value.dictLabel = ''
|
||||
getList()
|
||||
}
|
||||
|
||||
@ -164,6 +161,10 @@ const getSelectList = (corpusIds) => {
|
||||
|
||||
};
|
||||
|
||||
const rowClick = (row) => {
|
||||
tableRef.value.toggleRowSelection(row)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
if (props.corpusIds) {
|
||||
|
||||
@ -43,28 +43,6 @@
|
||||
>新增</el-button
|
||||
>
|
||||
</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
|
||||
v-model:showSearch="showSearch"
|
||||
@queryTable="getList"
|
||||
@ -82,6 +60,11 @@
|
||||
<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="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="sort" />
|
||||
<el-table-column label="备注" align="center" prop="remark" min-width="150" show-overflow-tooltip />
|
||||
@ -130,7 +113,7 @@
|
||||
:append-to-body="false"
|
||||
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-input v-model="form.schemeName" placeholder="请输入方案名称" />
|
||||
</el-form-item>
|
||||
@ -160,7 +143,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<FunctionSelection />
|
||||
<FunctionSelection :funcIds="form.funcIds" :selectIds="selectIds" @updateSelectRows="getSelectRows" />
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
@ -193,15 +176,12 @@ const total = ref(0);
|
||||
const title = ref("");
|
||||
|
||||
const data = reactive({
|
||||
form: {
|
||||
corpusIds: null,
|
||||
},
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId: route.params.id,
|
||||
schemeName: null,
|
||||
corpusIds: null,
|
||||
},
|
||||
rules: {
|
||||
projectId: [
|
||||
@ -220,10 +200,30 @@ function getList() {
|
||||
schemeList.value = [
|
||||
{
|
||||
schemeId: 1,
|
||||
schemeName: 'test',
|
||||
schemeName: 'test1',
|
||||
projectId: 1,
|
||||
sceneType: 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,
|
||||
corpusIds: null,
|
||||
remark: null,
|
||||
sceneType: null,
|
||||
funcIds: ''
|
||||
};
|
||||
}
|
||||
|
||||
const formatSceneType = (sceneType) => {
|
||||
return settingOptions.find(item => item.value === sceneType).label
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1;
|
||||
@ -268,12 +274,59 @@ const settingOptions = [
|
||||
{ value: 3, label: "连续对话场景" },
|
||||
];
|
||||
|
||||
const isAdd = ref(true)
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset();
|
||||
open.value = true;
|
||||
isAdd.value = true
|
||||
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(() => {
|
||||
getList();
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user