|
|
@ -24,6 +24,19 @@ |
|
|
|
<el-form-item label="元数据元素" prop="infoName"> |
|
|
|
<el-input v-model="mform.infoName" /> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="对应字段" prop="fieldName"> |
|
|
|
<el-select v-model="mform.fieldName" style="width: 225px;" @change="changField"> |
|
|
|
<el-option v-for="item in fieldOptions" :key="item.id" :label="item.label" :value="item.value" /> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="排序" prop="isSequence"> |
|
|
|
<el-input-number |
|
|
|
v-model.number="mform.isSequence" |
|
|
|
:min="0" |
|
|
|
:max="999" |
|
|
|
controls-position="right" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
<el-form-item label="顶级元数据" prop="isTop"> |
|
|
|
<el-radio-group v-model="mform.isTop" :disabled="isEdit"> |
|
|
|
<el-radio label="1">是</el-radio> |
|
|
@ -57,12 +70,18 @@ |
|
|
|
<el-table-column type="index" label="序号" /> |
|
|
|
<el-table-column prop="infoCode" label="编号" /> |
|
|
|
<el-table-column :show-overflow-tooltip="true" prop="infoName" label="元数据元素" /> |
|
|
|
<el-table-column prop="fieldName" label="对应字段"> |
|
|
|
<template slot-scope="scope"> |
|
|
|
<span v-if="scope.row.fieldCnName && scope.row.fieldName">{{ scope.row.fieldCnName + " - " + scope.row.fieldName }}</span> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
|
|
|
|
<script> |
|
|
|
import { FetchGetMetaInfo, FetchDelMetadataInfos, FetchEditMetadataInfo } from '@/api/system/metaData' |
|
|
|
import { FetchFindGroupType } from '@/api/system/field' |
|
|
|
export default { |
|
|
|
name: 'MetaDataList', |
|
|
|
props: { |
|
|
@ -84,7 +103,9 @@ export default { |
|
|
|
metadataTitle: '新增元数据', |
|
|
|
metadataVisible: false, |
|
|
|
selectOptions: [], |
|
|
|
mform: { id: null, infoCode: null, infoName: null, isTop: '1', parentInfoId: null }, |
|
|
|
fieldOptions: [], |
|
|
|
fieldItem: null, |
|
|
|
mform: { id: null, infoCode: null, infoName: null, isTop: '1', parentInfoId: null, fieldName: null, isSequence: null, fieldCnName: null }, |
|
|
|
rules: { |
|
|
|
infoCode: [ |
|
|
|
{ required: true, message: '编号不可为空', trigger: 'blur' } |
|
|
@ -97,6 +118,9 @@ export default { |
|
|
|
], |
|
|
|
parentInfoId: [ |
|
|
|
{ required: true, message: '请选择父级元数据', trigger: 'change' } |
|
|
|
], |
|
|
|
isSequence: [ |
|
|
|
{ required: true, message: '排序不可为空', trigger: 'blur' } |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
@ -111,6 +135,9 @@ export default { |
|
|
|
this.getList() |
|
|
|
} |
|
|
|
}, |
|
|
|
mounted() { |
|
|
|
this.getFieldCommon() |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getList() { |
|
|
|
this.loading = true |
|
|
@ -118,7 +145,9 @@ export default { |
|
|
|
FetchGetMetaInfo({ metadataId: this.selectedTreeItem.id }).then((res) => { |
|
|
|
if (res.infos) { |
|
|
|
const resData = JSON.parse(res.infos) |
|
|
|
this.tableData = resData |
|
|
|
// this.tableData = resData |
|
|
|
this.tableData = resData.filter(item => item.isSequence).sort((a, b) => a.isSequence - b.isSequence) |
|
|
|
console.log(this.tableData) |
|
|
|
resData.map((item, index) => { |
|
|
|
const json = {} |
|
|
|
json.id = item.id |
|
|
@ -132,6 +161,23 @@ export default { |
|
|
|
this.loading = false |
|
|
|
}) |
|
|
|
}, |
|
|
|
getFieldCommon() { |
|
|
|
FetchFindGroupType({ isType: 2 }).then((res) => { |
|
|
|
if (res.length !== 0) { |
|
|
|
this.fieldOptions = res.map((item, index) => { |
|
|
|
const json = {} |
|
|
|
json.id = item.id |
|
|
|
json.label = item.fieldCnName + '-' + item.fieldName |
|
|
|
json.value = item.fieldCnName + '-' + item.fieldName |
|
|
|
return json |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
changField(val) { |
|
|
|
console.log('val', val) |
|
|
|
this.fieldItem = val |
|
|
|
}, |
|
|
|
toAdd() { |
|
|
|
this.isEdit = false |
|
|
|
this.metadataVisible = true |
|
|
@ -142,6 +188,7 @@ export default { |
|
|
|
this.metadataVisible = true |
|
|
|
this.metadataTitle = '编辑元数据' |
|
|
|
const form = JSON.parse(JSON.stringify(data[0])) |
|
|
|
console.log(form) |
|
|
|
if (form.infoParentId) { |
|
|
|
form.isTop = '0' |
|
|
|
form.parentInfoId = form.infoParentId |
|
|
@ -150,20 +197,31 @@ export default { |
|
|
|
form.parentInfoId = null |
|
|
|
} |
|
|
|
this.mform = form |
|
|
|
this.mform.fieldName = this.mform.fieldCnName + '-' + this.mform.fieldName |
|
|
|
}, |
|
|
|
handleComfire() { |
|
|
|
this.$refs['mform'].validate((valid) => { |
|
|
|
if (valid) { |
|
|
|
if (this.fieldItem) { |
|
|
|
[this.mform.fieldCnName, this.mform.fieldName] = this.fieldItem.split('-') |
|
|
|
} else { |
|
|
|
this.mform.fieldCnName = this.mform.fieldName = null |
|
|
|
} |
|
|
|
|
|
|
|
const params = { |
|
|
|
'metadataId': this.selectedTreeItem.id, |
|
|
|
'info': [{ |
|
|
|
'metadataInfoId': this.mform.id, |
|
|
|
'parentInfoId': this.mform.parentInfoId, |
|
|
|
'infoCode': this.mform.infoCode, |
|
|
|
'infoName': this.mform.infoName |
|
|
|
'infoName': this.mform.infoName, |
|
|
|
'fieldName': this.mform.fieldName, |
|
|
|
'fieldCnName': this.mform.fieldCnName, |
|
|
|
'isSequence': this.mform.isSequence |
|
|
|
}] |
|
|
|
} |
|
|
|
delete this.mform.isTop |
|
|
|
console.log(params) |
|
|
|
FetchEditMetadataInfo(params).then((res) => { |
|
|
|
if (res) { |
|
|
|
this.metadataVisible = false |
|
|
|