ffcb886e by fanguang Committed by lihua

fix

1 parent 81346ba4
......@@ -342,3 +342,14 @@ export const getMetaStandardDetail = (guid) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/meta-standard/detail?guid=${guid}`,
method: 'get'
})
/** 元数据标准-标准数据 */
export const getMetaStandardDataList = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/meta-standard/data/page-list`,
method: 'post',
data: params
})
/** 元数据标准-标准字段 */
export const getMetaStandardDataFields = (metaStandardGuid) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/meta-standard/get-standard-field?metaStandardGuid=${metaStandardGuid}`,
method: 'get'
})
\ No newline at end of file
......
......@@ -28,6 +28,7 @@ import {
const emits = defineEmits(["exportData"])
const { proxy } = getCurrentInstance() as any;
const tableEl = ref()
const cacheStore = useCatchStore()
const standardGuid = ref("")
const standardName = ref('')
......@@ -154,22 +155,32 @@ const tableSelectionChange = (val, tId) => {
};
const tablePageChange = (info) => {
const toChange = checkSave()
const changeCont = () => {
console.log('info', info)
page.value.curr = Number(info.curr);
page.value.limit = Number(info.limit);
toSearch({});
// 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
// }
page.value.curr = Number(info.curr)
page.value.limit = Number(info.limit)
toSearch({})
}
if (!toChange) {
ElMessageBox.confirm(
'存在未保存的数据,切换后会丢失,是否确定切换',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
changeCont()
})
} else {
changeCont()
}
};
const saveDisabled = ref(true)
const toolBtnClick = (btn) => {
const type = btn.value
if (type == 'export') {
......@@ -188,15 +199,9 @@ const toolBtnClick = (btn) => {
} 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[item.field] = ''
})
rowInfo.guid = undefined;
rowInfo.STATE = 'Running'
......@@ -205,16 +210,13 @@ const toolBtnClick = (btn) => {
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
})
}
})
saveDisabled.value = false
// 表格滚动到第一行
tableEl.value.setCurrentRow(rowInfo)
let table = tableEl.value.layout.table.refs
let tableScrollEle =
table.bodyWrapper.firstElementChild.firstElementChild
tableScrollEle.scrollTop = tableScrollEle.scrollHeight
}
}
......@@ -226,6 +228,7 @@ const tableBtnClick = (scope, btn) => {
row.STATE = 'Running'
row.STATUS = 'edit'
tableData.value[scope.$index] = row
saveDisabled.value = false
} else if (type == 'save') {
saveData(scope)
} else if (type == 'cancel') {
......@@ -245,6 +248,7 @@ const tableBtnClick = (scope, btn) => {
// chunkData()
}
tableInfo.value.page.rows = tableData.value.length
saveDisabled.value = true
} else if (type == 'remove') {
open("是否确定删除所选数据?", "warning");
}
......@@ -580,7 +584,7 @@ defineExpose({
<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 type="primary" plain @click="toolBtnClick({ value: 'submit' })" v-preReClick :disabled="saveDisabled || 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>
......@@ -590,8 +594,14 @@ defineExpose({
@change="val => toSearch({})" /> -->
</div>
<div class="table_panel_wrap full">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
@tablePageChange="tablePageChange" />
<Table
ref="tableEl"
:tableInfo="tableInfo"
height="400px"
@tableBtnClick="tableBtnClick"
@tableSelectionChange="tableSelectionChange"
@tablePageChange="tablePageChange"
/>
</div>
</div>
......
......@@ -51,7 +51,7 @@
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="自定义字段选择" v-if="form.fieldRQVOS.length">
<el-form-item label="自定义字段选择" v-if="form.fieldRQVOS && form.fieldRQVOS.length">
<div class="table-form">
<div class="table-form-wrapper" v-for="item,index in form.fieldRQVOS" :key="index">
<div class="table-form-item">
......@@ -112,10 +112,6 @@ const { proxy } = getCurrentInstance() as any;
const props = defineProps({
modelValue: Boolean,
title: {
type: String,
default: '新建'
},
standardOptions: {
type: Array,
default: () => ([])
......@@ -138,6 +134,9 @@ const visible = computed({
emit('update:modelValue', val);
}
})
const title = computed(() => {
return props.type === 'add' ? '新建元标准' : '编辑元标准'
})
/**
* 配置项列表
......@@ -215,10 +214,11 @@ function inputTypeChange (val, item) {
}
function getDetail () {
console.log('testsetse')
getMetaStandardDetail(props.guid).then((res:any) => {
if (res.code === proxy.$passCode) {
const data = res.data
data.fieldRQVOS = data.fieldRSVOS
form.value = { ...data }
}
})
}
......@@ -228,9 +228,11 @@ function confirm () {
if (!valid) return
let body = { ...form.value }
console.log(body)
delete body.fieldRSVOS
// return
const request = props.type === 'add' ? saveMetaStandard : updateMetaStandard
confirmLoading.value = true
saveMetaStandard(body).then((res:any) => {
request(body).then((res:any) => {
if (res.code === proxy.$passCode) {
ElMessage.success('操作成功')
emit('success')
......
......@@ -13,7 +13,9 @@ import DictFileds from './components/dictFileds.vue'
import useCatchStore from "@/store/modules/catch";
import { download } from '@/utils/common'
import { getParamsList } from '@/api/modules/dataAsset'
import { getMetaStandardTree } from '@/api/modules/dataMetaService'
import { getMetaStandardTree, deleteMetaStandard,
getMetaStandardDataList, getMetaStandardDataFields
} from '@/api/modules/dataMetaService'
import router from '@/router'
import { TableColumnWidth } from '@/utils/enum';
import StandardDialog from './components/standardDialog.vue'
......@@ -46,47 +48,10 @@ const treeInfo = ref({
className: 'tree-list'
})
function nodeClick (data) {
// drawerInfo.value.visible = false
const changeCont = () => {
nextTick(() => {
treeInfo.value.currentNodeKey = data.value
console.log('nodeData', data)
treeInfo.value.currentObj = data
if (data.isLeaf) {
showFiledsPage.value = true
nextTick(() => {
dictFiledsRef.value.standardGuid = data.value
dictFiledsRef.value.standardName = data.label
treeCurrentNodeKey.value = data.value
dictFiledsRef.value.getFirstPageData()
})
} else {
showFiledsPage.value = false
getFirstPageData()
}
})
}
if (showFiledsPage.value) {
const toChange = dictFiledsRef.value.checkSave()
if (!toChange) {
ElMessageBox.confirm(
'存在未保存的数据,切换后会丢失,是否确定切换',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
changeCont()
}).catch(() => {
treeInfo.value.currentNodeKey = dictGuid.value
})
} else {
changeCont()
}
} else {
changeCont()
}
getTableFields()
}
function treeCustomClick (node, type) {
console.log(node, type)
......@@ -97,6 +62,14 @@ function treeCustomClick (node, type) {
standardDialog.visible = true
return
}
if (type === 'delete') {
// 删除
ElMessageBox.confirm('确定删除吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => deleteTreeNode(node.data.guid))
}
}
function getTree () {
getMetaStandardTree().then((res:any) => {
......@@ -106,6 +79,19 @@ function getTree () {
item.showEdit = true
})
treeInfo.value.data = data
treeInfo.value.expandedKey = [data[0].guid]
treeInfo.value.currentNodeKey = data[0].guid
nodeClick(data[0])
}
})
}
function deleteTreeNode (guid) {
deleteMetaStandard([guid]).then((res:any) => {
if (res.code === proxy.$passCode) {
ElMessage.success('删除成功')
getTree()
} else {
ElMessage.error(res.msg)
}
})
}
......@@ -131,11 +117,11 @@ const tableInfo: any = ref({
fixedSelection: true,
fields: [
{ label: "序号", type: "index", width: 56, align: "center" },
{ label: '数据源标识符', field: 'codeName', width: 140 },
{ label: '数据元名称', field: 'standard', width: 140 },
{ label: '定义', field: 'standardName', width: 140 },
{ label: '数据类型', field: '', width: 120 },
{ label: '表示格式', field: 'createTime', width: TableColumnWidth }
// { label: '数据源标识符', field: 'codeName', width: 140 },
// { label: '数据元名称', field: 'standard', width: 140 },
// { label: '定义', field: 'standardName', width: 140 },
// { label: '数据类型', field: '', width: 120 },
// { label: '表示格式', field: 'createTime', width: TableColumnWidth }
],
data: [],
page: {
......@@ -156,6 +142,61 @@ const tableInfo: any = ref({
},
loading: false
})
function getFirstPageData () {
page.value.curr = 1
toSearch({})
}
function toSearch (val: any, clear: boolean = false) {
let params: any = Object.keys(val).length ? { ...val } : {}
let { currentNodeKey, currentObj } = treeInfo.value
params.pageIndex = page.value.curr;
params.pageSize = page.value.limit;
params.metaStandardGuid = currentObj.guid
getTable(params)
}
function getTable (params) {
tableInfo.value.loading = true
getMetaStandardDataList(params).then((res:any) => {
if (res.code === proxy.$passCode) {
let data = res.data
let list = res.data.records || []
list.forEach((item:any) => {
Object.keys(item.metaStandardValue).forEach(key => {
item[key] = item.metaStandardValue[key]
})
})
tableInfo.value.data = list
tableInfo.value.page.limit = data.pageSize
tableInfo.value.page.curr = data.pageIndex
tableInfo.value.page.rows = data.totalRows
}
}).finally(() => tableInfo.value.loading = false)
}
function getTableFields () {
let { currentObj } = treeInfo.value
const indexField = { label: '序号', type: 'index', width: 56, align: 'center' }
getMetaStandardDataFields(currentObj.guid).then((res:any) => {
if (res.code === proxy.$passCode && res.data) {
const data = res.data
const fields = data.map(item => {
return {
label: item.fileNameCodeName,
field: item.fileNameCode,
width: 140
}
})
fields.unshift(indexField)
tableInfo.value.fields = fields
} else {
tableInfo.value.fields = [indexField]
}
})
}
function tablePageChange (info) {
page.value.curr = Number(info.curr)
page.value.limit = Number(info.limit)
toSearch({})
}
const formItems: any = ref([
{
......@@ -290,6 +331,7 @@ const standardDialog = reactive({
guid: null
})
function openStandardDialog () {
standardDialog.type = 'add'
standardDialog.visible = true
}
......@@ -326,7 +368,7 @@ onBeforeMount(() => {
</div>
<div class="table_panel_wrap full">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
@tablePageChange="tablePageChange" @tableSwitchBeforeChange="tableSwitchBeforeChange" />
@tablePageChange="tablePageChange"/>
</div>
</div>
<StandardDialog
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!