Commit 0a79756d by wanglizhen

知识库模块

parent 709d2046
import request from '@/utils/request'
/**
* 知识库 - 查询字典类型
* @param {*} query
* @returns
*/
export function dictinaryTypes(query) {
return request({
url: '/core/dictionary/getDictinaryTypes',
method: 'get',
params: query
})
}
/**
* 知识库 - 查询table数据
* @param {*} data
* @returns
*/
export function query(data) {
return request({
url: '/core/dictionary/query',
method: 'post',
data: data
})
}
/**
* 知识库 - 检测分类名称是否存在
* @param {*} query
* @returns
*/
export function checkNameExitType(query) {
return request({
url: '/core/dictionary/checkNameExitType',
method: 'get',
params: query
})
}
/**
* 知识库 - 添加修改分类
* @param {*} data
* @returns
*/
export function addDictionaryType(data) {
return request({
url: '/core/dictionary/addDictionaryType',
method: 'post',
data: data
})
}
/**
* 知识库 - 查询分类详情
* @param {*} data
* @returns
*/
export function initEditType(data) {
return request({
url: '/core/dictionary/initEditType',
method: 'post',
data: data
})
}
/**
* 知识库 - 删除分类
* @param {*} data
* @returns
*/
export function delDictionaryType(data) {
return request({
url: '/core/dictionary/delDictionaryType',
method: 'post',
data: data
})
}
/**
* 知识库 - 添加修改值
* @param {*} data
* @returns
*/
export function add(data) {
return request({
url: '/core/dictionary/add',
method: 'post',
data: data
})
}
/**
* 知识库 - 删除值
* @param {*} data
* @returns
*/
export function delValue(data) {
return request({
url: '/core/dictionary/del',
method: 'post',
data: data
})
}
......@@ -89,16 +89,18 @@ const collapseAdd = (item) => {
// 删除事件
const collapseDelete = (item) => {
console.log('删除事件', item)
const { name } = item
delData.value = item
modalData.show = true
modalData.icon = 'error'
modalData.text = '确认删除[' + item.name + ']?'
modalData.text = '确认删除[' + name + ']?'
}
// 删除回调
const modalConfirm = () => {
const { id } = delData.value
const data = {
relationid: delData.value.id
relationid: id
}
del(data).then(res => {
const { flag } = res
......@@ -133,9 +135,10 @@ const getQueryenc = () => {
queryenc({}).then((res) => {
const { data } = res;
encryptionList.value = data.map((item) => {
const { encryption_name, id } = item;
return {
value: item.id,
label: item.encryption_name,
value: id,
label: encryption_name,
};
});
});
......
......@@ -108,9 +108,10 @@ const getQuerysec = () => {
querysec({ encryption_id: form.value.encryption_id }).then((res) => {
const { data } = res;
secretkeyList.value = data.map((item) => {
const { id, secret_key_name } = item;
return {
value: item.id,
label: item.secret_key_name,
value: id,
label: secret_key_name,
};
});
});
......
<script setup name="Dictionary">
import { onMounted, ref, toRefs } from 'vue'
import { Split } from 'view-ui-plus';
import { ElMessage } from "element-plus";
import ModalPop from "@/components/EditPop/ModalPop.vue"
import AddClass from './modules/AddClass.vue' // 分类
import AddValue from './modules/AddValue.vue' // 值
import uploadModule from './modules/uploadModule.vue' // 上传模块
import { dictinaryTypes, query, delDictionaryType, delValue } from '@/api/ruleConfig/dictionary'
const splitNum = ref(0.31) // 左右分割比例
const data = reactive({
queryParams: {
pageNum: 1,
pageSize: 10,
},
addClassForm: {
name: "",
pageno: 1,
pagesize: 10,
typecode: '',
typename: '',
value: '',
parvalue: ''
},
addValueForm: {
name: "",
}
addClassForm: {},
addValueForm: {},
delData: {}
});
const { addClassForm, addValueForm, queryParams } = toRefs(data);
const { addClassForm, addValueForm, queryParams, delData } = toRefs(data);
const total = ref(4)
const classList = ref([])
const modalData = reactive({
show: false,
text: '',
......@@ -40,28 +44,10 @@ const modalPopData = reactive({
operation: ''
})
const tableData = ref([
{
date: '2016-05-02',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄',
},
{
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1517 弄',
},
{
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1519 弄',
},
{
date: '2016-05-03',
name: '王小虎',
address: '上海市普陀区金沙江路 1516 弄',
},
])
const tableData = reactive({
list: [],
total: 0
})
// 新增关闭
......@@ -72,9 +58,8 @@ const modalPopCancel = () => {
// 新增/编辑 分类
const addClassClick = (type, item) => {
modalPopData.operation = type
if (modalPopData.operation === 'add') {
addClassForm.value = {}
} else if (modalPopData.operation === 'edit') {
if (modalPopData.operation === 'edit') {
addClassForm.value = item
}
modalPopData.title = '字典分类'
modalPopData.type = 'class'
......@@ -85,8 +70,11 @@ const addClassClick = (type, item) => {
const addValueClick = (type, item) => {
modalPopData.operation = type
if (modalPopData.operation === 'add') {
addValueForm.value = {}
addValueForm.value = {
typecode: queryParams.value.typecode,
}
} else if (modalPopData.operation === 'edit') {
addValueForm.value = item
}
modalPopData.title = '字典数据'
modalPopData.type = 'value'
......@@ -95,45 +83,81 @@ const addValueClick = (type, item) => {
// 删除值
const valueDelete = (item) => {
console.log('删除值', item)
const { value } = item
delData.value = item
modalData.type = 'value'
modalData.icon = 'error'
modalData.text = '删除后无法恢复,是否确认删除[' + item.name + ']?'
modalData.text = '删除后无法恢复,是否确认删除[' + value + ']?'
modalData.show = true
}
// 删除分类
const classDelete = (item) => {
console.log('删除分类事件', item)
const { value } = item
delData.value = item
modalData.type = 'class'
modalData.icon = 'error'
modalData.text = '删除后无法恢复,是否确认删除[' + item.name + ']?'
modalData.text = '删除后无法恢复,是否确认删除[' + value + ']?'
modalData.show = true
}
// 提示回调
const modalConfirm = () => {
if (modalData.type === 'class') {
console.log('删除分类确认')
const { value, text } = delData.value
const data = {
dictionaryTypeCode: value,
dictionaryTypeName: text
}
delDictionaryType(data).then(res => {
const { flag } = res
if (flag) {
ElMessage.success('删除成功')
} else {
ElMessage.error('删除失败')
}
if (value === queryParams.value.typecode) {
getData()
}else{
getData('class')
}
})
} else if (modalData.type === 'value') {
console.log('删除值确认')
const { id, name } = delData.value
const data = {
dicId: id,
dicName: name
}
delValue(data).then(res => {
const { flag } = res
if (flag) {
ElMessage.success('删除成功')
} else {
ElMessage.error('删除失败')
}
getTableData()
})
}
modalData.show = false
}
// 分类查看
const classView = (item) => {
// editDomainForm.value = item
if(queryParams.value.typecode === item.value) return
queryParams.value.typecode = item.value
queryParams.value.typename = item.text
getTableData()
}
// 新增确认
const AddDomainConfirm = (item) => {
if (modalPopData.type === 'class') {
console.log('新增分类确认', item)
getData('class')
} else if (modalPopData.type === 'value') {
console.log('新增值确认', item)
getTableData()
} else if (modalPopData.type === 'upload') {
console.log('导入', item)
getTableData()
}
modalPopData.show = false
}
......@@ -145,13 +169,39 @@ const importClick = () => {
modalPopData.show = true
}
// 获取分类名称
const getClassName = (value) => {
const item = classList.value.find(item => item.value === value)
return item? item.text : ''
}
// 获取列表数据
const getList = () => {
const getData = (type) => {
dictinaryTypes({}).then(res => {
const { data } = res;
classList.value = data
if (classList.value.length <= 0) return
if (type === 'class') {
getTableData()
}else {
queryParams.value.typecode = classList.value[0].value
queryParams.value.typename = classList.value[0].text
getTableData()
}
})
}
// 获取列表table数据
const getTableData = () => {
query(queryParams.value).then(res => {
const { data } = res;
tableData.list = data.list
tableData.total = data.total
})
}
onMounted(() => {
getData()
})
</script>
......@@ -171,13 +221,14 @@ onMounted(() => {
</div>
<div style="width: 100%;flex: 1;overflow: auto;">
<el-scrollbar>
<div class="left_item" @click="classView">
<span>单姓1(1)</span>
<div class="left_item" :class="queryParams.typecode === item.value ? 'active' : ''"
v-for="(item, index) in classList" :key="index" @click="classView(item)">
<span>{{ item.text }}{{ item.value }}</span>
<div class="left_item_btn">
<el-icon :size="16" @click.stop="addClassClick('edit')">
<el-icon :size="16" @click.stop="addClassClick('edit', item)">
<edit />
</el-icon>
<el-icon :size="16" style="margin-left: 10px;" @click.stop="classDelete">
<el-icon :size="16" style="margin-left: 10px;" @click.stop="classDelete(item)">
<delete />
</el-icon>
</div>
......@@ -190,9 +241,9 @@ onMounted(() => {
<div class="right">
<div style="display: flex;justify-content: space-between;">
<el-form-item label="值:">
<el-input placeholder="" v-model="input3" class="input-with-select">
<el-input placeholder="" v-model="queryParams.value" class="input-with-select">
<template #append>
<el-button icon="Search"></el-button>
<el-button icon="Search" @click="getTableData"></el-button>
</template>
</el-input>
</el-form-item>
......@@ -202,28 +253,26 @@ onMounted(() => {
<el-button icon="Plus" type="primary" @click="addValueClick('add')">新增值</el-button>
</div>
</div>
<el-table :data="tableData" stripe style="width: 100%;flex:1;">
<el-table-column prop="date" label="分类" align="center"></el-table-column>
<el-table-column prop="name" label="分类编码" align="center"></el-table-column>
<el-table-column prop="address" label="值" align="center"></el-table-column>
<el-table-column prop="address" label="名称" align="center"></el-table-column>
<el-table-column prop="address" label="父值" align="center"></el-table-column>
<el-table :data="tableData.list" stripe style="width: 100%;flex:1;">
<el-table-column prop="date" label="分类" align="center">
<template #default="scope">
{{ getClassName(scope.row.typecode) }}
</template>
</el-table-column>
<el-table-column prop="typecode" label="分类编码" align="center"></el-table-column>
<el-table-column prop="value" label="值" align="center"></el-table-column>
<el-table-column prop="name" label="名称" align="center"></el-table-column>
<el-table-column prop="parentvalue" label="父值" align="center"></el-table-column>
<el-table-column label="操作" align="center">
<template #default="scope">
<el-button type="primary" link @click="addValueClick('edit')">编辑</el-button>
<el-button type="primary" link @click="addValueClick('edit',scope.row)">编辑</el-button>
<el-divider direction="vertical"></el-divider>
<el-button type="danger" link @click="valueDelete">删除</el-button>
<el-button type="danger" link @click="valueDelete(scope.row)">删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:isTextShow="true"
v-model:page="queryParams.pageNum"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
<pagination v-show="tableData.total>0" :total="tableData.total" :isTextShow="true"
v-model:page="queryParams.pageno" v-model:limit="queryParams.pagesize" @pagination="getTableData" />
</div>
</template>
</Split>
......@@ -236,10 +285,10 @@ onMounted(() => {
<!-- 新增分类 / 新增值 -->
<ModalPop :width="'600'" v-model="modalPopData.show" :title="modalPopData.title" @cancel="modalPopCancel">
<template #content>
<AddClass v-model="addClassForm" :type="modalPopData.operation" @cancel="modalPopCancel" @confirm="AddDomainConfirm"
v-if="modalPopData.type === 'class'" />
<AddValue v-model="addValueForm" :type="modalPopData.operation" @cancel="modalPopCancel" @confirm="AddDomainConfirm"
v-if="modalPopData.type === 'value'" />
<AddClass :itemData="addClassForm" :type="modalPopData.operation" @cancel="modalPopCancel"
@confirm="AddDomainConfirm" v-if="modalPopData.type === 'class'" />
<AddValue :itemData="addValueForm" :type="modalPopData.operation" :classDict="classList" @cancel="modalPopCancel"
@confirm="AddDomainConfirm" v-if="modalPopData.type === 'value'" />
<uploadModule @cancel="modalPopCancel" @confirm="AddDomainConfirm" v-if="modalPopData.type === 'upload'" />
</template>
</ModalPop>
......@@ -294,7 +343,7 @@ onMounted(() => {
height: 100%;
display: flex;
flex-direction: column;
:deep(.el-table .el-table__header-wrapper th){
:deep(.el-table .el-table__header-wrapper th) {
background-color: #e9f5fe !important;
color: #2c9ef7;
}
......
<script setup lang="ts" name="AddClass">
import { onMounted, reactive, ref, toRefs, watch } from "vue";
import type { FormInstance } from "element-plus";
import { ElMessage } from "element-plus";
import { checkNameExitType, addDictionaryType, initEditType } from '@/api/ruleConfig/dictionary'
const props = defineProps<{
modelValue: boolean;
itemData: boolean;
type: string;
}>();
const emit = defineEmits(["update:modelValue", 'cancel','confirm']);
const emit = defineEmits(["cancel", "confirm"]);
const data = reactive({
rules: {},
form: <any>{
id: "",
remark: "",
typename: "",
},
rules: {
typename: [
{
required: true,
message: "请输入字典分类名称",
trigger: ["blur"],
},
],
},
});
const { rules } = toRefs(data);
const { form, rules } = toRefs(data);
const formRef = ref<FormInstance>();
// 重置
const reset = () => {
form.value = {
id: "",
remark: "",
typename: "",
};
};
// 取消
const cancel = () => {
if (props.type === 'edit') {
emit("cancel");
};
}else if (props.type === 'add') {
const confirm = () => {
formRef.value?.validate((valid) => {
if (valid) {
getcheckNameExitType()
} else {
}
});
};
// 检验数据域名称
const getcheckNameExitType = () => {
const data = {
typename: form.value.typename
}
checkNameExitType(data).then(res => {
const { flag, data } = res
if (flag) {
addDictionaryTypeFun()
}
emit('cancel')
})
}
const confirm = () => {
if (props.type === 'edit') {
// 添加数据域
const addDictionaryTypeFun = () => {
addDictionaryType({dictionaryType: form.value}).then(res => {
const { flag } = res
if (flag) {
ElMessage.success(props.type === "add" ? "新增成功" : "修改成功");
emit("confirm");
reset()
}
emit('confirm')
})
}
const getInitEditType = (id) => {
initEditType({ typeId: id }).then(res => {
const { flag, data } = res
const { tConsoleDictionarytype } = data
const { id, remark, typename } = tConsoleDictionarytype
if (flag) {
form.value.id = id
form.value.remark = remark
form.value.typename = typename
}
})
}
watch(
() => props.itemData,
(newVal) => {
if (props.type === "edit" && props.itemData) {
const { id } = JSON.parse(JSON.stringify(props.itemData));
getInitEditType(id)
}
},
{ deep: true, immediate: true }
);
</script>
<template>
<div>
<el-form ref="formRef" :model="modelValue" label-width="100px">
<el-form-item label="字典分类" required>
<el-input v-model="modelValue.name" placeholder="请输入字典分类"></el-input>
<el-form ref="formRef" :model="form" :rules="rules" label-width="100px">
<el-form-item label="字典分类" prop="typename" required>
<el-input v-model="form.typename" placeholder="请输入字典分类"></el-input>
</el-form-item>
<el-form-item label="备注">
<el-input type="textarea" v-model="modelValue.name" placeholder="请输入备注" rows="2" maxlength="200" show-word-limit></el-input>
<el-input type="textarea" v-model="form.remark" placeholder="请输入备注" rows="2" maxlength="200"
show-word-limit></el-input>
</el-form-item>
</el-form>
<div class="btn">
......@@ -57,4 +129,9 @@ const confirm = () => {
display: flex;
justify-content: center;
}
:deep(.el-form-item__error) {
left: auto;
right: 30px;
top: 24%;
}
</style>
\ No newline at end of file
<script setup lang="ts" name="AddValue">
import { onMounted, reactive, ref, toRefs, watch } from "vue";
import type { FormInstance } from "element-plus";
import { ElMessage } from "element-plus";
import { add } from "@/api/ruleConfig/dictionary";
const props = defineProps<{
modelValue: boolean;
itemData: boolean;
type: string;
classDict: any;
}>();
const emit = defineEmits(["update:modelValue", 'cancel', 'confirm']);
const emit = defineEmits(["cancel", "confirm"]);
const data = reactive({
rules: {},
form: <any>{
id: null,
name: "",
parentid: "",
parentvalue: "",
typecode: "",
typename: "",
value: "",
},
rules: {
value: [
{
required: true,
message: "请输入值",
trigger: ["blur"],
},
],
},
});
const { rules } = toRefs(data);
const { form, rules } = toRefs(data);
const formRef = ref<FormInstance>();
const classDictList = ref<any[]>([]);
// 重置
const reset = () => {
form.value = {
id: null,
name: "",
parentid: "",
parentvalue: "",
typecode: "",
typename: "",
value: "",
};
};
// 取消
const cancel = () => {
if (props.type === 'edit') {
} else if (props.type === 'add') {
}
emit('cancel')
}
emit("cancel");
};
const confirm = () => {
if (props.type === 'edit') {
} else if (props.type === 'add') {
formRef.value?.validate((valid) => {
if (valid) {
addFunc();
} else {
}
});
};
// 添加数据域
const addFunc = () => {
add({ dictionary: form.value }).then((res) => {
const { flag } = res;
if (flag) {
ElMessage.success(props.type === "add" ? "新增成功" : "修改成功");
emit("confirm");
reset();
}
emit('confirm')
}
});
};
watch(
() => props.itemData,
(newVal) => {
if (props.itemData) {
const data = JSON.parse(JSON.stringify(props.itemData))
form.value = {...form.value, ...data}
}
},
{ deep: true, immediate: true }
);
watch(
() => props.classDict,
(newVal) => {
classDictList.value = props.classDict;
},
{ deep: true, immediate: true }
);
</script>
<template>
<div>
<el-form ref="formRef" :model="modelValue" label-width="70px" :disabled="readOnly">
<el-form ref="formRef" :model="form" :rules="rules" label-width="70px">
<el-form-item label="字典分类">
<el-select v-model="modelValue.name" v-if="!readOnly" placeholder="请选择字典分类">
<el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
<el-select v-model="form.typecode" placeholder="请选择字典分类">
<el-option v-for="item in classDictList" :key="item.value" :label="item.text" :value="item.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="值" required>
<el-input v-model="modelValue.name" placeholder="请输入值"></el-input>
<el-form-item label="值" prop="value" required>
<el-input v-model="form.value" placeholder="请输入值"></el-input>
</el-form-item>
<el-form-item label="名称" required>
<el-input v-model="modelValue.name" placeholder="请输入名称"></el-input>
<el-form-item label="名称">
<el-input v-model="form.name" placeholder="请输入名称"></el-input>
</el-form-item>
<el-form-item label="父值" required>
<el-input v-model="modelValue.name" placeholder="请输入父值"></el-input>
<el-form-item label="父值">
<el-input v-model="form.parentvalue" placeholder="请输入父值"></el-input>
</el-form-item>
</el-form>
<div class="btn">
......@@ -68,4 +129,9 @@ const confirm = () => {
display: flex;
justify-content: center;
}
:deep(.el-form-item__error) {
left: auto;
right: 30px;
top: 24%;
}
</style>
\ No newline at end of file
......@@ -99,33 +99,33 @@ const collapseAdd = (item) => {
// 删除发现规则
const collapseDelete = (item) => {
console.log('删除发现规则', item)
const { name } = item
delData.value = item
modalData.type = 'rules'
modalData.cancel = true
modalData.icon = 'error'
modalData.text = '删除后无法恢复,是否确认删除[' + item.name + ']?'
modalData.text = '删除后无法恢复,是否确认删除[' + name + ']?'
modalData.show = true
}
// 删除数据域
const collapseMainDeletion = (item) => {
console.log('删除数据域事件', item)
const { dataarea } = item
delData.value = item
modalData.type = 'domain'
modalData.cancel = false
modalData.icon = 'error'
modalData.text = '删除后无法恢复,是否确认删除[' + item.dataarea + ']?'
modalData.text = '删除后无法恢复,是否确认删除[' + dataarea + ']?'
modalData.show = true
}
// 提示回调
const modalConfirm = () => {
if (modalData.type === 'domain') {
console.log('删除数据域确认')
const { id, dataarea } = delData.value
const data = {
areaid: delData.value.id,
areaname: delData.value.dataarea
areaid: id,
areaname: dataarea
}
delDataArea(data).then(res => {
const { flag } = res
......@@ -137,11 +137,11 @@ const modalConfirm = () => {
}
})
} else if (modalData.type === 'rules') {
console.log('删除发现规则确认')
const { ruleid, name, tid } = delData.value
const data = {
ruleid: delData.value.ruleid,
rulename: delData.value.name,
tid: delData.value.tid
ruleid: ruleid,
rulename: name,
tid: tid
}
delRule(data).then(res => {
const { flag } = res
......@@ -153,10 +153,10 @@ const modalConfirm = () => {
}
})
} else if (modalData.type === 'default') {
console.log('设置默认项')
const { ruleid, name } = delData.value
const data = {
ruleid: delData.value.ruleid,
rulename: delData.value.name,
ruleid: ruleid,
rulename: name,
}
setdefault(data).then(res => {
const { flag } = res
......@@ -192,21 +192,20 @@ const collapseChange = (item) => {
// 发现规则设置默认项
const collapseDefault = (item) => {
const { name } = item
delData.value = item
modalData.type = 'default'
modalData.cancel = false
modalData.icon = 'error'
modalData.text = '确定设置[' + item.name + ']为默认规则?'
modalData.text = '确定设置[' + name + ']为默认规则?'
modalData.show = true
}
// 新增确认
const AddFormConfirm = (item) => {
if (modalPopData.type === 'domain') {
console.log('新增数据域确认', item)
getCollapse()
} else if (modalPopData.type === 'rules') {
console.log('新增发现规则确认', item)
getCollapse()
}
modalPopData.show = false
......
......@@ -31,9 +31,16 @@ const readOnly = ref(true);
const formRef = ref<FormInstance>();
watch(
() => [props.type, props.itemData],
() => props.type,
(newVal) => {
readOnly.value = props.type === 'edit' ? true : false;
},
{ deep: true, immediate: true }
);
watch(
() => props.itemData,
(newVal) => {
if (props.type === 'edit' && props.itemData) {
form.value = JSON.parse(JSON.stringify(props.itemData))
}
......@@ -127,4 +134,9 @@ const addDataAreaFun = () => {
display: flex;
justify-content: center;
}
:deep(.el-form-item__error) {
left: auto;
right: 30px;
top: 24%;
}
</style>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论