parent
d09210a735
commit
ab87fa37ce
@ -0,0 +1,143 @@
|
||||
<!--
|
||||
* @description: 编辑提示词
|
||||
* @fileName: EditPrompt
|
||||
* @author: 17076
|
||||
* @date: 2024/11/14-上午9:40
|
||||
* @version: V1.0.0
|
||||
-->
|
||||
|
||||
<template>
|
||||
<el-drawer
|
||||
:size="800"
|
||||
append-to-body
|
||||
v-model="dialogVisible"
|
||||
:show-close="false"
|
||||
:with-header="false"
|
||||
:before-close="closeDialog"
|
||||
custom-class="AddEdit"
|
||||
>
|
||||
<div class="AddEdit">
|
||||
<div class="header-title">
|
||||
<div class="tip" />
|
||||
<span>编辑提示词</span>
|
||||
</div>
|
||||
<div class="line" />
|
||||
<el-form
|
||||
ref="refForm"
|
||||
:model="formData"
|
||||
:rules="rules"
|
||||
label-width="100px"
|
||||
>
|
||||
<el-form-item label="模板类型" prop="commonType">
|
||||
<el-select
|
||||
v-model="formData.commonType"
|
||||
placeholder="请选择模板类型"
|
||||
style="width: 100%"
|
||||
:disabled="isEditFlag"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in typeOptions"
|
||||
:key="item.value"
|
||||
:value="item.value"
|
||||
:label="item.label"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="提示词名称" prop="attributeName">
|
||||
<el-input
|
||||
v-model="formData.attributeName"
|
||||
placeholder="请输入提示词名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="提示词" prop="attributeParam">
|
||||
<el-input
|
||||
v-model="formData.attributeParam"
|
||||
type="textarea"
|
||||
:rows="5"
|
||||
placeholder="请输入提示词"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="footer_btn">
|
||||
<div class="reset" @click="resetForm">重置</div>
|
||||
<div class="main" @click="submit(refForm)">确定</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-drawer>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import { FormInstance } from "element-plus";
|
||||
import {
|
||||
createMedicalRecAiManage,
|
||||
modifyMedicalRecAiManage
|
||||
} from "@/api/generalRules";
|
||||
import { message } from "@/utils/message";
|
||||
const isEditFlag = ref(false);
|
||||
const dialogVisible = ref(false);
|
||||
const formData = ref({
|
||||
commonType: "",
|
||||
attributeName: "",
|
||||
attributeParam: ""
|
||||
});
|
||||
const typeOptions = [
|
||||
{ label: "通用模板", value: "00" },
|
||||
{ label: "属性模板", value: "01" }
|
||||
];
|
||||
const refForm = ref<FormInstance>();
|
||||
const rules = {
|
||||
commonType: [
|
||||
{ required: true, message: "模板类型不能为空!", trigger: "blur" }
|
||||
],
|
||||
attributeName: [
|
||||
{ required: true, message: "提示词名称不能为空!", trigger: "blur" }
|
||||
],
|
||||
attributeParam: [
|
||||
{ required: true, message: "提示词不能为空!", trigger: "blur" }
|
||||
]
|
||||
};
|
||||
const resetForm = (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
formEl.resetFields();
|
||||
};
|
||||
const closeDialog = () => {
|
||||
dialogVisible.value = false;
|
||||
resetForm();
|
||||
};
|
||||
const emit = defineEmits(["update"]);
|
||||
|
||||
const submit = async (formEl: FormInstance | undefined) => {
|
||||
if (!formEl) return;
|
||||
await formEl.validate(async valid => {
|
||||
if (valid) {
|
||||
if (isEditFlag.value) {
|
||||
const res: any = await modifyMedicalRecAiManage(formData.value);
|
||||
if (res.code === 200) {
|
||||
message("修改成功", { type: "success" });
|
||||
emit("update");
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
} else {
|
||||
const res = await createMedicalRecAiManage(formData.value);
|
||||
if (res.code === 200) {
|
||||
message("新增成功", { type: "success" });
|
||||
emit("update");
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
defineExpose({
|
||||
show(data, isEdit) {
|
||||
isEditFlag.value = isEdit;
|
||||
formData.value = isEdit ? Object.assign({}, data) : {};
|
||||
dialogVisible.value = true;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
@ -0,0 +1,167 @@
|
||||
<!--
|
||||
* @description: 提示词管理
|
||||
* @fileName: index
|
||||
* @author: 17076
|
||||
* @date: 2024/11/14-上午9:39
|
||||
* @version: V1.0.0
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="app-main-content">
|
||||
<div class="seach">
|
||||
<el-form :model="searchForm">
|
||||
<el-row>
|
||||
<el-form-item label="属性名称:">
|
||||
<el-input size="large" v-model="searchForm.attribute_name" />
|
||||
</el-form-item>
|
||||
|
||||
<el-button class="ml-8" size="large" @click="search" type="primary"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button size="large" @click="reset">重置</el-button>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
<div class="main-table">
|
||||
<div class="main-table-title">
|
||||
<div class="title">
|
||||
<div class="line" />
|
||||
<span>提示词配置</span>
|
||||
</div>
|
||||
<el-row class="mb-6">
|
||||
<el-button size="large" @click="handleAdd" type="primary"
|
||||
>新建</el-button
|
||||
>
|
||||
</el-row>
|
||||
</div>
|
||||
<pure-table
|
||||
align-whole="center"
|
||||
show-overflow-tooltip
|
||||
table-layout="auto"
|
||||
:loading="loading"
|
||||
adaptive
|
||||
:data="dataList"
|
||||
:columns="columns"
|
||||
:pagination="pagination"
|
||||
:header-cell-style="{
|
||||
background: 'var(--el-table-row-hover-bg-color)',
|
||||
color: 'var(--el-text-color-primary)'
|
||||
}"
|
||||
@page-size-change="handleSizeChange"
|
||||
@page-current-change="handleCurrentChange"
|
||||
>
|
||||
<template #operation="{ row }">
|
||||
<el-button link type="primary" @click="handleEdit(row)"
|
||||
>编辑</el-button
|
||||
>
|
||||
<el-button link type="danger" @click="handleDelete(row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</pure-table>
|
||||
</div>
|
||||
<!--编辑提示词-->
|
||||
<edit-prompt ref="edit" @update="getData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from "vue";
|
||||
import { PaginationProps } from "@pureadmin/table";
|
||||
import {
|
||||
deleteMedicalRecAiManage,
|
||||
queryMedicalRecAiManage
|
||||
} from "@/api/generalRules";
|
||||
import EditPrompt from "@/views/generalRules/promptManage/components/EditPrompt.vue";
|
||||
import { ElMessageBox } from "element-plus";
|
||||
import { message } from "@/utils/message";
|
||||
|
||||
const dataList = ref([{}]);
|
||||
const loading = ref(false);
|
||||
const edit = ref(null);
|
||||
const searchForm = reactive({
|
||||
attribute_name: ""
|
||||
});
|
||||
const pagination = reactive<PaginationProps>({
|
||||
total: 0,
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
background: true
|
||||
});
|
||||
const columns: TableColumnList = [
|
||||
{
|
||||
label: "类型",
|
||||
prop: "commonName",
|
||||
minWidth: 240
|
||||
},
|
||||
{
|
||||
label: "属性名称",
|
||||
prop: "attributeName",
|
||||
minWidth: 240
|
||||
},
|
||||
{
|
||||
label: "提示词",
|
||||
prop: "attributeParam",
|
||||
minWidth: 240
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
fixed: "right",
|
||||
slot: "operation"
|
||||
}
|
||||
];
|
||||
const getData = async () => {
|
||||
const params = {
|
||||
pageNum: pagination.currentPage,
|
||||
pageSize: pagination.pageSize,
|
||||
...searchForm
|
||||
};
|
||||
const res: any = await queryMedicalRecAiManage(params);
|
||||
dataList.value = res.data.records;
|
||||
pagination.total = res.data.total;
|
||||
};
|
||||
function handleSizeChange(val: number) {
|
||||
pagination.pageSize = val;
|
||||
getData();
|
||||
}
|
||||
|
||||
function handleCurrentChange(val: number) {
|
||||
pagination.currentPage = val;
|
||||
getData();
|
||||
}
|
||||
const search = () => {
|
||||
pagination.currentPage = 1;
|
||||
pagination.pageSize = 10;
|
||||
getData();
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
seachForm.description = "";
|
||||
seachForm.similarityDescription = "";
|
||||
search();
|
||||
};
|
||||
const handleAdd = () => {
|
||||
edit.value.show(undefined, false);
|
||||
};
|
||||
const handleEdit = item => {
|
||||
edit.value.show(item, true);
|
||||
};
|
||||
// 删除
|
||||
const handleDelete = item => {
|
||||
ElMessageBox.confirm("确定删除此项吗?", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
callback: async () => {
|
||||
const res = await deleteMedicalRecAiManage({ id: item.id });
|
||||
res.code === 200
|
||||
? message(res.msg || "删除成功!", { type: "success" })
|
||||
: message(res.msg || "删除失败!", { type: "error" });
|
||||
await getData();
|
||||
}
|
||||
});
|
||||
};
|
||||
onMounted(() => {
|
||||
getData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss"></style>
|
Loading…
Reference in New Issue