|
@@ -0,0 +1,145 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <m-form ref="form" :items="formItems" v-model="formValues">
|
|
|
+ <template #childrenId="{ item }">
|
|
|
+ <search-nodes v-model="item.value" v-bind="item.options" :search-value="item.search"></search-nodes>
|
|
|
+ </template>
|
|
|
+ </m-form>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+
|
|
|
+import MForm from '@/components/MForm'
|
|
|
+// import { combinationTagsPage } from '@/api/dataBook'
|
|
|
+import {
|
|
|
+ metadata,
|
|
|
+ frequency,
|
|
|
+ sensitivity
|
|
|
+} from '@/utils/dataGovernance'
|
|
|
+import SearchNodes from '../../components/searchNodes.vue'
|
|
|
+import { api } from '@/api/dataGovernance'
|
|
|
+export default {
|
|
|
+ name: 'edit-base',
|
|
|
+ props: {
|
|
|
+ itemData: {
|
|
|
+ type: Object,
|
|
|
+ default: () => ({})
|
|
|
+ }
|
|
|
+ },
|
|
|
+ components: { MForm, SearchNodes },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ formValues: {
|
|
|
+ name: null,
|
|
|
+ en_name: null,
|
|
|
+ category: '应用类',
|
|
|
+ organization: this.$store.getters.userInfo.username,
|
|
|
+ leader: this.$store.getters.userInfo.username,
|
|
|
+ childrenId: [],
|
|
|
+ frequency: '日',
|
|
|
+ data_sensitivity: '低',
|
|
|
+ tag: null,
|
|
|
+ describe: null,
|
|
|
+ status: true
|
|
|
+ },
|
|
|
+ tagItems: [],
|
|
|
+ pageInfo: {
|
|
|
+ size: 10,
|
|
|
+ current: 1
|
|
|
+ },
|
|
|
+ total: 0,
|
|
|
+ loading: false
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ formItems () {
|
|
|
+ return [
|
|
|
+ { type: 'text', key: 'name', label: '名称 *', rules: [v => !!v || '请输入名称'] },
|
|
|
+ { type: 'text', key: 'en_name', label: '英文名称 *', rules: [v => !!v || '请输入英文名称'] },
|
|
|
+ { type: 'autocomplete', key: 'category', label: '分类 *', rules: [v => !!v || '请选择分类'], items: metadata },
|
|
|
+ { type: 'text', key: 'organization', label: '所属机构 *', rules: [v => !!v || '请输入所属机构'] },
|
|
|
+ { type: 'text', key: 'leader', label: '负责人 *', rules: [v => !!v || '请输入负责人'] },
|
|
|
+ {
|
|
|
+ key: 'childrenId',
|
|
|
+ slotName: 'childrenId',
|
|
|
+ search: null,
|
|
|
+ options: {
|
|
|
+ label: '数据来源',
|
|
|
+ attach: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { type: 'autocomplete', key: 'frequency', label: '更新频率 *', rules: [v => !!v || '请选择更新频率'], items: frequency },
|
|
|
+ { type: 'autocomplete', key: 'data_sensitivity', label: '数据敏感度 *', rules: [v => !!v || '请选择数据敏感度'], items: sensitivity },
|
|
|
+ { type: 'autocomplete', key: 'tag', label: '标签', itemText: 'name', itemValue: 'id', items: this.tagItems },
|
|
|
+ { type: 'text', key: 'describe', label: '描述' },
|
|
|
+ {
|
|
|
+ type: 'ifRadio',
|
|
|
+ key: 'status',
|
|
|
+ label: '启用',
|
|
|
+ width: 120,
|
|
|
+ items: [{ label: '是', value: true }, { label: '否', value: false }]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.init()
|
|
|
+ if (!Object.keys(this.itemData).length) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ Object.keys(this.formValues).forEach(key => {
|
|
|
+ if (!Object.prototype.hasOwnProperty.call(this.itemData, key)) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (key === 'childrenId') {
|
|
|
+ if (this.itemData.childrenId.length === 1 && this.itemData.childrenId[0].id === null) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.formValues[key] = this.itemData.childrenId.map(e => {
|
|
|
+ return {
|
|
|
+ value: e.id,
|
|
|
+ text: e.name
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (key === 'tag') {
|
|
|
+ this.formValues[key] = this.itemData.tag?.id ?? null
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.formValues[key] = this.itemData[key]
|
|
|
+ })
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ async init () {
|
|
|
+ try {
|
|
|
+ this.loading = true
|
|
|
+ try {
|
|
|
+ const { data } = await api.dataLabelList({
|
|
|
+ ...this.pageInfo
|
|
|
+ })
|
|
|
+ this.tagItems = data.records
|
|
|
+ this.total = data.total
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ } finally {
|
|
|
+ this.loading = false
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ this.$snackbar.error(error)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getValue () {
|
|
|
+ if (!this.$refs.form.validate()) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ return this.formValues
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+
|
|
|
+</style>
|