e09d7712 by fanguang Committed by lihua

元数据标准

1 parent bf8d502e
......@@ -272,4 +272,38 @@ export const updateStandardCode = (params) => request({
export const getStandardCodeDetail = (guid) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/detail?guid=${guid}`,
method: 'get',
})
/** 元数据-标准代码删除 */
export const deleteStandardCode = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/delete`,
method: 'delete',
data: params
})
/** 元数据-查询标准列表 */
export const getStandardCodeStandard = (standardTypeCode) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/get-standard?standardTypeCode=${standardTypeCode}`,
method: 'get'
})
/** 元数据-查询代码列表 */
export const getStandardCodeDataList = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/get-data`,
method: 'post',
data: params
})
/** 元数据-查询代码字段数据 */
export const getStandardCodeFields = (standardGuid) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/get-field?standardGuid=${standardGuid}`,
method: 'get'
})
/** 元数据-保存标准代码数据 */
export const saveStandardCodeFieldsData = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/save-data`,
method: 'post',
data: params
})
/** 元数据-删除标准代码数据 */
export const deleteStandardCodeFieldsData = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/remove-data`,
method: 'post',
data: params
})
\ No newline at end of file
......
<route lang="yaml">
name: dictFileds
</route>
<script lang="ts" setup name="dictFileds">
import { ref } from 'vue'
import router from '@/router'
import { ElMessage, ElMessageBox } from "element-plus";
import Table from '@/components/Table/index.vue'
// import Dialog from '@/components/Dialog/index.vue'
import useCatchStore from "@/store/modules/catch";
import { chunk } from '@/utils/common'
import { getStandardCodeDataList, getStandardCodeFields, saveStandardCodeFieldsData, deleteStandardCodeFieldsData } from '@/api/modules/dataMetaService'
import {
saveDictionaryData,
getDictionaryFileds,
deleteDictionaryData,
checkDictionaryData,
showDictionary,
getDictionaryRuleData
} from '@/api/modules/dataInventory';
const emits = defineEmits(["exportData"])
const { proxy } = getCurrentInstance() as any;
const cacheStore = useCatchStore()
const standardGuid = ref("")
const tableSearchInput = ref('')
const tableFields: any = ref([])
const orginData: any = ref([])
const currTableData: any = ref<Object>({});
const selectRowData = ref([])
const page = ref({
limit: 50,
curr: 1,
// sizes: [
// { label: "100", value: 100 },
// { label: "200", value: 200 },
// { label: "300", value: 300 },
// { label: "400", value: 400 },
// { label: "500", value: 500 },
// ],
});
const tableChunkData: any = ref([])
const tableData: any = ref([])
const tableInfo: any = ref({
id: 'data-fileds-table',
multiple: true,
fields: [],
data: [],
page: {
type: "count",
rows: 0,
...page.value,
},
// showPage: false,
actionInfo: {
label: "操作",
type: "btn",
width: 92,
btns: (scope) => {
return [
{ label: "编辑", value: "edit", visible: scope.row['STATE'] !== 'Running' },
{ label: "删除", value: "remove", visible: scope.row['STATE'] !== 'Running' },
// { label: "保存", value: "save", visible: scope.row['STATE'] === 'Running' },
{ label: "取消", value: "cancel", visible: scope.row['STATE'] === 'Running' },
]
},
},
editInfo: {},
loading: false
})
const uploadFiles = ref([])
const uploadInfo = ref({
type: 'upload',
title: '',
col: '',
uploadInfo: {
id: 'upload-file-form',
type: 'panel',
action: '',
auto: false,
cover: true,
fileList: [],
accept: '.xlsx, .xls',
triggerBtn: {
label: '导入',
value: 'import_file',
icon: 'Upload',
},
tips: '当前支持xls、xlsx文件,默认使用第一个sheet'
},
})
const dialogInfo = ref({
visible: false,
size: 640,
direction: "column",
header: {
title: "新建",
},
type: '',
contents: [
uploadInfo.value
],
footer: {
visible: true,
btns: [
{ type: "default", label: "取消", value: "cancel" },
{ type: "primary", label: "开始导入", value: "submit" },
],
},
})
const getFirstPageData = () => {
toSearch({})
}
const toSearch = (val: any, clear: boolean = false) => {
let params = {
pageIndex: 1,
pageSize: -1,
standardGuid : standardGuid.value
}
getTableData(params);
};
const getTableData = (params) => {
tableInfo.value.loading = true
Promise.all([getStandardCodeFields(standardGuid.value), getStandardCodeDataList(params)]).then((resList:any) => {
console.log(resList)
let schemaDataVOS = resList[0].data || []
let jsonArray = resList[1].data.records || []
setUploadDataInfo({schemaDataVOS,jsonArray}, true)
}).finally(() => tableInfo.value.loading = false)
};
const tableSelectionChange = (val, tId) => {
selectRowData.value = val;
};
const tablePageChange = (info) => {
page.value.curr = Number(info.curr);
if (page.value.limit != Number(info.limit)) {
page.value.limit = Number(info.limit);
chunkData()
} else {
tableData.value = tableChunkData.value[page.value.curr - 1]
tableInfo.value.data = tableData.value
tableInfo.value.page.limit = page.value.limit
tableInfo.value.page.curr = page.value.curr
}
};
const toolBtnClick = (btn) => {
console.log('btnType', btn)
const type = btn.value
if (type == 'export') {
exportData()
} else if (type == 'import') {
const info = {
type: 'dictionary',
standardGuid: standardGuid.value
}
cacheStore.setCatch('uploadSetting', info)
nextTick(() => {
router.push({
path: '/data-inventory/data-dictionary/import-file',
});
})
} else if (type == 'submit') {
saveData()
} else if (type == 'add_row') {
const params = {
guid: standardGuid.value
}
getDictionaryRuleData(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data ?? {}
let rowInfo: any = {}
tableFields.value.map(item => {
rowInfo[item.field] = data[item.field] ?? ''
})
rowInfo.guid = undefined;
rowInfo.STATE = 'Running'
rowInfo.STATUS = 'edit'
rowInfo.ROWID = `upload_${tableData.value.length}`
tableData.value.unshift(rowInfo)
orginData.value.unshift(rowInfo)
tableInfo.value.page.rows = tableData.value.length
// orginData.value.unshift(rowInfo)
// page.value.curr = 1
// chunkData()
} else {
ElMessage({
type: 'error',
message: res.msg
})
}
})
}
}
const tableBtnClick = (scope, btn) => {
const type = btn.value;
let row = scope.row;
currTableData.value = row;
if (type == "edit") {
row.STATE = 'Running'
row.STATUS = 'edit'
tableData.value[scope.$index] = row
} else if (type == 'save') {
saveData(scope)
} else if (type == 'cancel') {
if (row.guid != undefined) {
// row = orginData.value[(page.value.curr - 1) * page.value.limit + scope.$index]
row = JSON.parse(JSON.stringify(orginData.value[scope.$index]))
row.STATE = ''
row.STATUS = ''
tableData.value[scope.$index] = row
} else {
tableData.value.splice(scope.$index, 1)
orginData.value.splice(scope.$index, 1)
// orginData.value.splice((page.value.curr - 1) * page.value.limit + scope.$index, 1)
// if (scope.$index == 0) {
// page.value.curr = (page.value.curr - 1 > 1) ? page.value.curr - 1 : 1
// }
// chunkData()
}
tableInfo.value.page.rows = tableData.value.length
} else if (type == 'remove') {
open("是否确定删除所选数据?", "warning");
}
};
const onUpload = (file, fileList) => {
uploadFiles.value = fileList
}
const uploadBtnClick = (btn) => {
exportData('model')
}
const exportData = (type: any = null) => {
emits('exportData', type)
}
const importData = (file: any = null) => {
let params = new FormData()
if (file) {
params.append("file", file.raw);
} else {
if (uploadFiles.value.length) {
uploadFiles.value.forEach((item: any, index: number) => {
params.append("file", item.raw);
});
}
}
params.append("standardGuid", standardGuid.value);
showDictionary(params).then((res: any) => {
if (res.code == proxy.$passCode) {
dialogInfo.value.visible = false
let data = res.data ?? []
// data.map((item: any, i) => {
// item.index = tableData.value.length + i
// })
const tData = { jsonArray: data }
setUploadDataInfo(tData)
// saveData(null, tData)
} else {
ElMessage({
type: "error",
message: res.msg,
});
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
}
}).catch(() => {
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
});
}
const checkSave = () => {
const toSaveData = tableData.value.filter(item => item.STATE === 'Running')
return toSaveData.length == 0 ? true : false
}
const checkParamsData = (scope: any = null) => {
let addJsonArray: any = [], upJsonArray: any = [], jsonArray: any = [], pass = true
let passArr = scope ? [scope.row] : tableData.value
passArr.map((item, index) => {
const obj = JSON.parse(JSON.stringify(item))
delete obj.STATUS
delete obj.NOTES
delete obj.STATE
delete obj.ROWID
// if (item.STATE === 'Running') {
for (var i in obj) {
if (obj[i] == '') {
pass = false
}
}
// }
if (obj.guid !== undefined) {
upJsonArray.push(obj)
} else {
addJsonArray.push(obj)
}
if (scope) {
// obj.index = scope.$index
jsonArray.push(obj)
} else {
// obj.index = index
jsonArray.push(obj)
}
})
return { pass, addJsonArray, upJsonArray, jsonArray }
}
const loading = ref(false)
const saveData = async (scope: any = null, checkParamData: any = null) => {
let passInfo: any = {}
if (checkParamData) {
passInfo = checkParamData
} else {
passInfo = await checkParamsData(scope)
if (!passInfo.pass) {
ElMessage({
type: 'error',
message: '请填写所有数据项'
})
return
}
}
let params = passInfo.jsonArray.map(item => {
let standardCodeValue = {}
tableFields.value.forEach(fieldObj => {
standardCodeValue[fieldObj.field] = item[fieldObj.field]
})
let obj = {
standardGuid: standardGuid.value,
standardCodeValue,
guid: item.guid || null,
standardCodeId: item.standardCodeId || null,
parentId: item.parentId || null
}
return obj
})
loading.value = true
saveStandardCodeFieldsData(params).then((res: any) => {
if (res.code == proxy.$passCode) {
getFirstPageData();
ElMessage({
type: 'success',
message: '保存成功'
})
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
}).finally(() => loading.value = false)
}
const addColumn = (info: any = null) => {
const fields = tableFields.value
const existIndex = fields.findIndex(item => item.field == 'NOTES')
if (info) {
if (existIndex == -1) {
fields.push({
label: '备注',
field: 'NOTES',
width: 200
})
}
for (var d in info) {
tableData.value[d].NOTES = info[d].join(',')
}
} else {
if (existIndex > -1) {
fields.splice(existIndex, 1)
}
}
}
// 生成表头
const setUploadDataFields = (data) => {
let fields: any = [], editInfo: any = {}
data.map(item => {
let fieldItem: any = {
label: item.fieldName, field: item.fieldName, width: 140
}
fieldItem.type = 'edit'
fieldItem.columClass = 'edit-colum'
editInfo[item.fieldName] = {
label: '',
type: 'input',
placeholder: '',
maxlength: 50,
field: item.fieldName,
default: '',
disabled: item.codeRuleGuid ? true : false,
clearable: true,
}
fields.push(fieldItem)
})
tableFields.value = fields
tableInfo.value.fields = tableFields.value
tableInfo.value.editInfo = editInfo
}
// 生成表数据
const setUploadDataInfo = async (info, setField = false) => {
if (setField) {
const fields = info.schemaDataVOS ?? []
await setUploadDataFields(fields)
}
let data = info.jsonArray ?? []
// 设置表数据
// data.map((item, i) => {
// item.ROWID = `upload_${tableData.value.length + i}`
// })
data.forEach(item => {
Object.keys(item.standardCodeValue).forEach(key => {
item[key] = item.standardCodeValue[key]
})
})
if (setField) {
tableData.value = data
} else {
tableData.value = [...tableData.value, ...data]
}
orginData.value = JSON.parse(JSON.stringify(tableData.value))
tableInfo.value.data = tableData.value
tableInfo.value.page.rows = tableData.value.length
// if (setField) {
// orginData.value = data
// } else {
// orginData.value = [...orginData.value, ...data]
// }
// chunkData()
}
const chunkData = () => {
const data = orginData.value
tableChunkData.value = chunk(data, page.value.limit)
tableData.value = tableChunkData.value[page.value.curr - 1]
tableInfo.value.data = tableData.value
tableInfo.value.page.limit = page.value.limit
tableInfo.value.page.curr = page.value.curr
tableInfo.value.page.rows = orginData.value.length
}
const batching = (type) => {
if (type == 'delete') {
if (selectRowData.value.length == 0) {
ElMessage({
type: 'error',
message: '请选择需要删除的数据',
})
return
}
open("是否确定删除所选数据?", "warning", true);
}
};
const open = (msg, type, isBatch = false) => {
ElMessageBox.confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: type,
}).then(() => {
let guids: any = []
if (isBatch) {
const list = selectRowData.value.filter((item: any) => item.guid !== undefined)
if (list.length) {
guids = list.map((l: any) => l.guid)
}
const newRows = selectRowData.value.filter((item: any) => item.guid == undefined)
newRows.map((n: any, r) => {
const existIndex = tableData.value.findIndex(t => t.ROWID == n.ROWID)
if (existIndex > -1) {
tableData.value.splice(existIndex, 1)
orginData.value.splice(existIndex, 1)
}
// const existIndex = orginData.value.findIndex(t => t.id == n.id)
// existIndex > -1 && orginData.value.splice(existIndex, 1)
// if (r == newRows.length - 1) {
// page.value.curr = 1
// chunkData()
// }
})
tableInfo.value.page.rows = tableData.value.length
} else {
guids = [currTableData.value.guid]
}
if (guids.length) {
const params = {
guid: standardGuid.value,
delGuids: guids
}
// console.log(params)
// return
deleteStandardCodeFieldsData(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
getFirstPageData();
ElMessage({
type: "success",
message: "删除成功",
});
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
});
}
});
};
const dialogBtnClick = (btn, info) => {
if (btn.value == 'submit') {
// dialogInfo.value.footer.btns.map((item: any) => item.disabled = true)
importData()
} else if (btn.value == 'cancel') {
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
nextTick(() => {
dialogInfo.value.visible = false;
})
}
};
defineExpose({
standardGuid,
getFirstPageData,
checkSave
});
</script>
<template>
<div class="container_wrap full flex">
<div class="main_wrap">
<div class="table_tool_wrap">
<div class="tools_btns">
<el-button type="primary" @click="toolBtnClick({ value: 'add_row' })" v-preReClick :disabled="loading">新增行</el-button>
<el-button type="primary" plain @click="toolBtnClick({ value: 'submit' })" v-preReClick :disabled="loading">保存数据</el-button>
<el-button @click="batching('delete')" v-preReClick :disabled="loading">批量删除</el-button>
<el-button @click="toolBtnClick({ value: 'import' })" v-preReClick :disabled="loading">导入数据</el-button>
<el-button @click="toolBtnClick({ value: 'export' })" v-preReClick :disabled="loading">导出数据</el-button>
</div>
<!-- <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="输入名称搜索" :suffix-icon="Search" clearable
@change="val => toSearch({})" /> -->
</div>
<div class="table_panel_wrap full">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
@tablePageChange="tablePageChange" />
</div>
</div>
<!-- <Dialog :dialogInfo="dialogInfo" @btnClick="dialogBtnClick" @onUpload="onUpload" @uploadBtnClick="uploadBtnClick" /> -->
</div>
</template>
<style lang="scss" scoped>
.container_wrap {
width: calc(100% - 200px);
.main_wrap {
width: 100%;
.table_panel_wrap {
height: calc(100% - 44px);
}
}
}
</style>
......@@ -9,11 +9,14 @@ import { Search } from '@element-plus/icons-vue'
import Tree from '@/components/Tree/index.vue'
import Table from '@/components/Table/index.vue'
import Drawer from '@/components/Drawer/index.vue'
// import DictFileds from './dictFileds.vue'
import DictFileds from './components/dictFileds.vue'
import useCatchStore from "@/store/modules/catch";
import { download } from '@/utils/common'
import { getParamsList } from '@/api/modules/dataAsset'
import { getStandardCodeList, saveStandardCode, updateStandardCode, getStandardCodeDetail } from '@/api/modules/dataMetaService'
import { getStandardCodeList, saveStandardCode,
updateStandardCode, getStandardCodeDetail,
deleteStandardCode, getStandardCodeStandard
} from '@/api/modules/dataMetaService'
import {
addDictionary,
deleteDictionary,
......@@ -71,13 +74,16 @@ const treeInfo = ref({
props: {
label: "label",
value: "value",
isLeaf: "isLeaf",
},
lazy: true,
nodeKey: 'value',
expandedKey: ['01'],
currentNodeKey: '01',
data: [],
expandOnNodeClick: false,
loading: false
loading: false,
currentObj: {}
});
const standardOptions = ref([])
......@@ -106,7 +112,8 @@ const tableInfo: any = ref({
{ label: '代码名称', field: 'codeName', width: 140 },
{ label: '标准号', field: 'standard', width: 140 },
{ label: '标准名称', field: 'standardName', width: 140 },
{ label: '启用状态', field: 'bizState', type: 'switch', activeText: '启用', inactiveText: '停用', activeValue: 1, inactiveValue: 0, switchWidth: 56, width: 100, align: 'center' },
// { label: '启用状态', field: 'bizState', type: 'switch', activeText: '启用', inactiveText: '停用', activeValue: 1, inactiveValue: 0, switchWidth: 56, width: 100, align: 'center' },
{ label: '启用状态', field: 'bizState', type: 'tag', width: 100, align: 'center' },
{ label: '创建时间', field: 'createTime', width: 140 }
],
data: [],
......@@ -260,7 +267,7 @@ const formItems: any = ref([
{
label: '发布单位',
type: 'select',
placeholder: '请输入',
placeholder: '请选择',
field: 'publishingUnitCode',
default: '',
options: publishingUnitCodeOptions,
......@@ -287,7 +294,7 @@ const formItems: any = ref([
},
{
label: '代码类型',
type: 'select',
type: 'radio-panel',
placeholder: '请选择',
field: 'typeCode',
default: '1',
......@@ -332,57 +339,19 @@ const formItems: any = ref([
field: 'hierarchy',
default: '',
clearable: true,
required: true
visible: true
}
])
const formRules: any = ref({
chName: [
{
required: true,
message: "请填写中文名",
trigger: "blur",
},
],
enName: [
{
required: true,
message: "请填写英文名",
trigger: "blur",
},
],
orderNum: [{
validator: (rule: any, value: any, callback: any) => {
if (value === 0) {
callback();
return;
}
if (!value) {
callback(new Error('请填写排序'));
return;
}
const r = /(^[0-9]([0-9]*)$|^[0-9]$)/; // 正整数(可以以0打头)
if (value && !r.test(value)) {
callback(new Error('请填写大于或等于零整数'));
return;
}
callback();
},
trigger: "blur",
}],
codeColumn: [
{
required: true,
message: "请填写编码字段",
trigger: "blur",
},
],
codeName: [
{
required: true,
message: "请填写编码名称",
trigger: "blur",
},
],
standardTypeCode: { required: true, message: '请选择标准类型' },
codeName: { required: true, message: '请输入代码名称' },
standard: { required: true, message: '请输入标准号' },
standardName: { required: true, message: '请输入标准名称' },
publishingUnitCode: { required: true, message: '请选择发布单位' },
orderNum: { required: true, message: '请输入排序' },
typeCode: { required: true, message: '请选择代码类型' },
codeFields: { required: true, message: '请选择编码字段' },
codeFieldName: { required: true, message: '请选择编码名称' }
})
const formInfo = ref({
type: 'form',
......@@ -477,7 +446,7 @@ const formTable = ref({
col: 'float-right',
visible: true,
btns: [
{ label: "新增行", value: "add-row", type: 'primary', plain: true },
{ label: "新增行", value: "add-row", type: 'primary' },
{ label: "批量删除", value: "remove_batch" },
]
},
......@@ -708,79 +677,27 @@ const getCodeRuleData = () => {
const treePromise = ref();
// 获取数据字典树形数据
// const getTreeData = (needClick = false, currData = {}) => {
// const params = {
// paramCode: '标准类型'
// }
// treeInfo.value.loading = true
// treePromise.value = getDictionaryTree(params).then((res: any) => {
// treePromise.value = null;
// if (res.code == proxy.$passCode) {
// const data = res.data ?? []
// const treeList = data.filter(item => item.children && item.children.length)
// treeData.value = treeList
// treeInfo.value.data = treeList
// if (treeList.length) {
// dictType.value = dictType.value == -1 ? Number(treeList[0].dictionaryType) : dictType.value;
// expandedKey.value = expandedKey.value.length == 0 ? [treeList[0].guid] : expandedKey.value;
// if (!needClick && !cacheStore.getCatch('dictionaryGuid')) {
// currentNodeKey.value = currentNodeKey.value == '' ? treeList[0].guid : currentNodeKey.value
// nextTick(() => {
// treeInfo.value.currentNodeKey = currentNodeKey.value
// treeInfo.value.expandedKey = expandedKey.value
// })
// } else {
// nextTick(() => {
// treeInfo.value.expandedKey = expandedKey.value;
// });
// }
// getFirstPageData()
// } else {//处理数据被删除完成,表格没刷新的情况。
// tableInfo.value.data = [];
// tableInfo.value.page.rows = 0;
// }
// } else {
// ElMessage({
// type: 'error',
// message: res.msg,
// })
// }
// treeInfo.value.loading = false;
// if (needClick) {
// nextTick(() => {
// nodeClick(currData);
// });
// }
// }).catch(() => {
// treeInfo.value.loading = false
// })
// }
const getTreeData = (needClick = false, currData = {}) => {
getParamsList({ dictType: '标准类型'}).then((res:any) => {
if (res.code === proxy.$passCode) {
const data = res.data || []
data.forEach(item => {
item.treeLevel = 1
})
treeInfo.value.data = data
standardOptions.value = data
// 默认展开第一个
if (data.length === 0) return
let params = {
pageIndex: 1,
pageSize: -1,
pageSize: 50,
standardTypeCode: data[0].value,
// codeName: '标准类型'
}
getStandardCodeList(params).then((res:any) => {
if (res.code === proxy.$passCode) {
let data = res.data
let list = res.data.records || []
list = list.map(item => {
item.label = item.codeName
item.value = item.guid
return item
})
treeInfo.value.data[0].children = list
tableInfo.value.data = list
tableInfo.value.data = data.records
tableInfo.value.page.limit = data.pageSize
tableInfo.value.page.curr = data.pageIndex
tableInfo.value.page.rows = data.totalRows
......@@ -797,11 +714,17 @@ const getFirstPageData = () => {
const toSearch = (val: any, clear: boolean = false) => {
let params: any = Object.keys(val).length ? { ...val } : {}
let { currentNodeKey, currentObj } = treeInfo.value
console.log('currentObj', currentObj)
params.pageIndex = page.value.curr;
params.pageSize = page.value.limit;
params.standardTypeCode = treeInfo.value.currentNodeKey
// params.dictionaryType = dictType.value
// params.name = tableSearchInput.value
params.codeName = tableSearchInput.value
if (currentObj.treeLevel === 1) {
params.standardTypeCode = currentNodeKey
} else if (currentObj.treeLevel === 2) {
params.standardTypeCode = currentObj.standardTypeCode
params.standardName = currentObj.value
}
getTableData(params);
};
......@@ -1066,62 +989,11 @@ const tableBtnClick = (scope, btn) => {
formTable.value.tableInfo.loading = false
drawerInfo.value.loading = false;
})
} else if (type == 'remove') {
const rowIndex = scope.$index
if (formItems.value.length == 2) {
uploadTableData.value.splice(rowIndex, 1)
} else {
if (row.guid !== undefined) {
formTable.value.tableInfo.loading = true
checkDelete().then((res: any) => {
if (res) {
ElMessageBox.confirm("数据字典有数据, 确定是否继续删除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: 'warning',
}).then(() => {
formTableData.value.splice(rowIndex, 1)
})
} else {
formTableData.value.splice(rowIndex, 1)
}
formTable.value.tableInfo.loading = false
}).catch(xhr => {
ElMessage({
type: 'error',
message: xhr
})
formTable.value.tableInfo.loading = false
})
} else {
formTableData.value.splice(rowIndex, 1)
}
}
} else if (type == "delete") {
currTableData.value = row;
tableInfo.value.loading = true
checkDelete().then((res: any) => {
if (res.used) {
ElMessage({
type: 'error',
message: '数据字典被引用,请解除引用关系后再删除'
})
} else {
const unused = res.data.filter(item => item.have.length > 0)
if (unused.length) {
open("数据字典有数据, 确定是否继续删除?", "warning");
} else {
open("此操作将永久删除, 是否继续?", "warning");
}
}
tableInfo.value.loading = false
}).catch(xhr => {
ElMessage({
type: 'error',
message: xhr
})
tableInfo.value.loading = false
})
open("此操作将永久删除, 是否继续?", "warning");
tableInfo.value.loading = false
}
};
......@@ -1183,9 +1055,9 @@ const open = (msg, type, isBatch = false) => {
guids = selectRowData.value
}
tableInfo.value.loading = true
deleteDictionary(guids).then((res: any) => {
deleteStandardCode(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
getTreeData();
getFirstPageData()
ElMessage({
type: "success",
message: "删除成功",
......@@ -1363,28 +1235,8 @@ const batching = (type) => {
return
}
tableInfo.value.loading = true
checkDelete().then((res: any) => {
if (res.used) {
ElMessage({
type: 'error',
message: '数据字典被引用,请解除引用关系后再删除'
})
} else {
const unused = res.data.filter(item => !item.have || item.have.length == 0)
if (unused.length) {
open("数据字典有数据, 确定是否继续删除?", "warning", true);
} else {
open("此操作将永久删除, 是否继续?", "warning", true);
}
}
tableInfo.value.loading = false
}).catch(xhr => {
ElMessage({
type: 'error',
message: xhr
})
tableInfo.value.loading = false
})
open("此操作将永久删除, 是否继续?", "warning", true);
tableInfo.value.loading = false
}
};
......@@ -1392,25 +1244,19 @@ const nodeClick = (data) => {
console.log('treeNodeClick', data)
drawerInfo.value.visible = false
const changeCont = () => {
// dictGuid.value = data.guid
// const info = {
// type: 'dictionary',
// dictionaryGuid: dictGuid.value
// }
// cacheStore.setCatch('uploadSetting', info)
// if (data.type == 1) {
// showFiledsPage.value = false
// dictType.value = Number(data.dictionaryType)
// } else {
// showFiledsPage.value = true
// nextTick(() => {
// dictFiledsRef.value.dictionaryGuid = dictGuid.value
// dictFiledsRef.value.getFirstPageData()
// })
// }
nextTick(() => {
treeInfo.value.currentNodeKey = data.value
getFirstPageData()
treeInfo.value.currentObj = data
if (data.isLeaf) {
showFiledsPage.value = true
nextTick(() => {
dictFiledsRef.value.standardGuid = data.value
dictFiledsRef.value.getFirstPageData()
})
} else {
showFiledsPage.value = false
getFirstPageData()
}
})
}
if (showFiledsPage.value) {
......@@ -1436,6 +1282,48 @@ const nodeClick = (data) => {
changeCont()
}
}
function loadTreeNode (node, resolve) {
console.log('node', node)
if (node.isLeaf) {
return resolve([]);
}
if (node.level === 1) {
let standardTypeCode = node.data.value
getStandardCodeStandard(standardTypeCode).then((res:any) => {
if (res.code === proxy.$passCode) {
let data = res.data || []
let uniqList = Array.from(new Set(data)).map(item => {
return {
label: item,
value: item,
treeLevel: 2,
standardTypeCode
}
})
resolve(uniqList)
}
})
}
if (node.level === 2) {
let params = {
pageIndex: 1,
pageSize: -1,
standardTypeCode: node.data.standardTypeCode,
standardName: node.data.value
}
getStandardCodeList(params).then((res:any) => {
if (res.code === proxy.$passCode) {
const list = res.data.records || []
list.forEach(item => {
item.isLeaf = true
item.label = item.codeName
item.value = item.guid
})
resolve(list)
}
})
}
}
// 设置详情信息
const setDetailInfo = () => {
......@@ -1468,62 +1356,21 @@ const setDetailInfo = () => {
drawerInfo.value.visible = true
}
const checkParamsData = () => {
let addJsonArray: any = [], upJsonArray: any = [], jsonArray: any = [], pass = true
let passArr = uploadTableData.value
passArr.map((item, index) => {
const obj = JSON.parse(JSON.stringify(item))
delete obj.STATE
delete obj.STATUS
delete obj.NOTES
delete obj.ROWID
for (var i in obj) {
if (obj[i] == '') {
pass = false
}
}
if (obj.guid !== undefined) {
upJsonArray.push(obj)
} else {
addJsonArray.push(obj)
}
obj.index = index
jsonArray.push(obj)
})
return { pass, addJsonArray, upJsonArray, jsonArray }
}
const saveData = async (params) => {
// const passInfo = await checkParamsData()
console.log('params', params)
saveStandardCode(params).then((res:any) => {
let request = drawerInfo.value.type === 'add' ? saveStandardCode : updateStandardCode
request(params).then((res:any) => {
if (res.code === proxy.$passCode) {
ElMessage.success('操作成功')
getTreeData()
drawerInfo.value.visible = false
}
}).finally(() => {
drawerInfo.value.footer.btns.map((item: any) => item.disabled = true)
})
}
const addColumn = (info: any = null) => {
const fields = uploadTableFields.value
const existIndex = fields.findIndex(item => item.field == 'NOTES')
if (info) {
if (existIndex == -1) {
fields.push({
label: '备注',
field: 'NOTES',
width: 276
})
}
for (var d in info) {
uploadTableData.value[d].NOTES = info[d].join(',')
}
} else {
if (existIndex > -1) {
fields.splice(existIndex, 1)
}
}
}
const scrollTable = (rowInfo) => {
nextTick(() => {
const drawerBody = document.getElementsByClassName('el-drawer__body')[0];
......@@ -1546,7 +1393,11 @@ const drawerBtnClick = (btn, info) => {
console.log('table', formTable.value)
let params = {
standardCodeFields: formTable.value.tableInfo.data.map(item => {
let obj = { fieldName: item.fieldName }
let obj = {
fieldName: item.fieldName,
guid: item.guid || null,
standardGuid: item.standardGuid || null
}
return obj
}),
...info
......@@ -1554,7 +1405,11 @@ const drawerBtnClick = (btn, info) => {
if (params.typeCode === '1') {
delete params.hierarchy
}
if (drawerInfo.value.type === 'edit') {
params.guid = currTableData.value.guid
}
if (btn.value == 'submit' || btn.value == 'saveAndAdd') {
drawerInfo.value.footer.btns.map((item: any) => item.disabled = true)
saveData(params)
} else {
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
......@@ -1564,60 +1419,6 @@ const drawerBtnClick = (btn, info) => {
}
}
const getTableFiled = () => {
const guid = currTableData.value.guid;
fieldTableInfo.value.tableInfo.loading = true;
drawerInfo.value.container.contents = contents.value['field']
getDictionaryFileds(guid).then((res: any) => {
fieldTableInfo.value.tableInfo.loading = false;
if (res.code == proxy.$passCode) {
const data = res.data ?? {}
currTableData.value.detailInfo = data
setUploadDataInfo(data)
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
}).catch(() => {
fieldTableInfo.value.tableInfo.loading = false;
})
}
const getDictionaryDataDetail = (params) => {
uploadTableInfo.value.loading = true
getDictionaryFileds(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data ?? {}
setContents(data)
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
uploadTableInfo.value.loading = false
}).catch(xhr => {
uploadTableInfo.value.loading = false
})
}
// 设置添加数据面板信息
const setContents = async (info) => {
formItems.value.splice(2)
formItems.value.map(item => {
item.default = fieldSheetInfo.value[item.field]
item.disabled = true
})
const fields = info.schemaDataVOS ?? []
await setUploadDataFields(fields)
uploadTableData.value = []
uploadTableInfo.value.data = []
uploadInfo.value.tableInfo = uploadTableInfo.value
drawerInfo.value.container.contents = contents.value['upload']
}
const radioGroupChange = async (val, info) => {
dictionaryType.value = Number(val)
await setFormItems(info)
......@@ -1647,25 +1448,25 @@ const setGroup = () => {
}
onActivated(() => {
getCodeRuleData();
let guid = cacheStore.getCatch('dictionaryGuid');
if (guid) {
nextTick(() => {
if (treePromise.value) {
treePromise.value.then(() => {
nodeClick({ guid: guid, dictionaryType: '1', type: 2 });
cacheStore.setCatch('dictionaryGuid', null);
});
} else {
nodeClick({ guid: guid, type: 1 });
cacheStore.setCatch('dictionaryGuid', null);
}
});
}
// getCodeRuleData();
// let guid = cacheStore.getCatch('dictionaryGuid');
// if (guid) {
// nextTick(() => {
// if (treePromise.value) {
// treePromise.value.then(() => {
// nodeClick({ guid: guid, dictionaryType: '1', type: 2 });
// cacheStore.setCatch('dictionaryGuid', null);
// });
// } else {
// nodeClick({ guid: guid, type: 1 });
// cacheStore.setCatch('dictionaryGuid', null);
// }
// });
// }
})
onBeforeMount(() => {
getDataType()
// getDataType()
getTreeData()
getParamsList({ dictType: '发布单位' }).then((res:any) => {
if (res.code === proxy.$passCode) {
......@@ -1695,16 +1496,16 @@ onMounted(() => {
<div class="container_wrap full flex">
<div class="aside_wrap">
<div class="aside_title">数据字典列表</div>
<Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" />
<Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" @loadNode="loadTreeNode"/>
</div>
<!-- <DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" /> -->
<div class="main_wrap">
<DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" />
<div class="main_wrap" v-else>
<div class="table_tool_wrap">
<div class="tools_btns">
<el-button type="primary" @click="loadDrawer" v-preReClick>新建</el-button>
<el-button @click="batching('delete')" v-preReClick>批量删除</el-button>
</div>
<el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入字典中/英文名搜索"
<el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入代码名称搜索"
:suffix-icon="Search" clearable @change="val => getFirstPageData()" />
</div>
<div class="table_panel_wrap full">
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!