田源
2023-09-18 da6cc144cc4d60805e4693e4adc5ebdf78b5b37d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<template>
    <el-container>
        <!-- 顶端按钮 -->
        <el-header class="businessHeader" style="height: 40px;">
                <el-button-group>
                    <el-button type="primary" @click="linkTypeAdd" size="small">
                        <i class="el-icon-plus"></i>&nbsp;
                        新增
                    </el-button>
                    <el-button type="primary" @click="linkTypeEdit" size="small">
                        <i class="el-icon-edit"></i>&nbsp;
                        修改
                    </el-button>
                </el-button-group>
            </el-header>
        <!-- 侧边栏树 -->
        <el-container>
            <el-aside width="240px">
                <basic-container class="businessTreeContainer">
                    <p style="margin-top: 10px;font-weight: 570;font-size: 19px">{{ treeOption.title }}</p>
                    <avue-tree id="basic" :data="treeData" :option="treeOption" @node-click="nodeClick"
                        class="businessTree">
                        <span class="el-tree-node__label" slot-scope="{ node, data }">
                            <span>
                                <i class="el-icon-star-on"></i>
                                {{ (node || {}).label }}
                            </span>
                        </span>
                    </avue-tree>
                </basic-container>
            </el-aside>
            <el-container>
                <el-main>
                    <basic-container>
                        <p style="margin-top: 10px;font-weight: 570;font-size: 19px">基本信息</p>
                        <el-descriptions class="margin-top" :column="2" size="medium" border>
                            <el-descriptions-item :labelStyle="descriptionOption.labelStyle"
                                :contentStyle="descriptionOption.contentStyle">
                                <template slot="label">
                                    <i :class="icons.id"></i>
                                    英文名称
                                </template>
                                {{ obj.id }}
                            </el-descriptions-item>
                            <el-descriptions-item :labelStyle="descriptionOption.labelStyle"
                                :contentStyle="descriptionOption.contentStyle">
                                <template slot="label">
                                    <i :class="icons.name"></i>
                                    中文名称
                                </template>
                                {{ obj.name }}
                            </el-descriptions-item>
                            <el-descriptions-item :labelStyle="descriptionOption.labelStyle"
                                :contentStyle="descriptionOption.contentStyle">
                                <template slot="label">
                                    <i :class="icons.tableName"></i>
                                    数据库表名
                                </template>
                                {{ obj.tableName }}
                            </el-descriptions-item>
                            <el-descriptions-item :labelStyle="descriptionOption.labelStyle"
                                :contentStyle="descriptionOption.contentStyle">
                                <template slot="label">
                                    <i :class="icons.domain"></i>
                                    所属领域
                                </template>
                                <el-tag v-if="obj.domainText" size="small">
                                    {{ obj.domainText }}
                                </el-tag>
                            </el-descriptions-item>
                        </el-descriptions>
                        <el-descriptions class="margin-top" direction="vertical" :column="2" border>
                            <el-descriptions-item :labelStyle="descriptionOption.labelStyle"
                                :contentStyle="descriptionOption.contentStyle">
                                <template slot="label">
                                    <i :class="icons.from"></i>
                                    From端类型
                                </template>
                                <span v-for="item in obj.fromBtmTypes" style="margin-left:2px;">
                                    <el-tag size="small" effect="plain" style="margin-top: 2px;">
                                        {{ item.id + '(' + item.name + ')' }}
                                    </el-tag>
                                </span>
                            </el-descriptions-item>
                            <el-descriptions-item :labelStyle="descriptionOption.labelStyle"
                                :contentStyle="descriptionOption.contentStyle">
                                <template slot="label">
                                    <i :class="icons.to"></i>
                                    To段类型
                                </template>
                                <span v-for="item in obj.toBtmTypes" style="margin-left:2px">
                                    <el-tag size="small" effect="plain" style="margin-top: 2px;">
                                        {{ item.id + '(' + item.name + ')' }}
                                    </el-tag>
                                </span>
                            </el-descriptions-item>
                        </el-descriptions>
 
                       <el-descriptions class="margin-top" :column="2" size="medium" border>
                        <!--
                            <el-descriptions-item :labelStyle="descriptionOption.labelStyle"
                                :contentStyle="descriptionOption.contentStyle">
                                <template slot="label">
                                    <i :class="icons.main"></i>
                                    主类型
                                </template>
                                {{ obj.fromBtmTypeName }}
                            </el-descriptions-item>
                            <el-descriptions-item :labelStyle="descriptionOption.labelStyle"
                                :contentStyle="descriptionOption.contentStyle">
                                <template slot="label">
                                    <i :class="icons.main"></i>
                                    主类型
                                </template>
                                {{ obj.toBtmTypeName }}
                            </el-descriptions-item>
                            -->
                            <el-descriptions-item span='2' labelStyle="text-align:center;width:120px">
                                <template slot="label">
                                    <i :class="icons.desc"></i>
                                    描述
                                </template>
                                {{ obj.description }}
                            </el-descriptions-item>
                        </el-descriptions>
                    </basic-container>
                    <!-- 属性列表-->
                    <basic-container>
                        <p style="margin-top: 10px;font-weight: 570;font-size: 19px">属性列表</p>
                        <avue-crud class="attributeCrud" v-model="obj" :data="obj.attributes" :option="loadOption">
                            <template slot="attrDataTypeText" slot-scope="{row}">
                                <el-tag>{{ row.attrDataTypeText }}</el-tag>
                            </template>
                        </avue-crud>
                    </basic-container>
                </el-main>
            </el-container>
        </el-container>
        <link-type-add ref="linkAdd" :linkType="addOption.linkType" :domainOption="domainOptions" :icons="icons"
            @refreshTable="initTreeOnLoad">
        </link-type-add>
 
    </el-container>
</template>
 
<script>
import {
    initTree,
    refOnLoad,
    getDomain,
    saveFromTable,
    getDetail
} from "@/api/omd/linkType"
export default {
    name: "LinkType",
    data() {
        return {
            addOption: {
                linkType: {
                    attributes:[]
                },
            },
            domain: null,
            domainOptions: [],
            icons: {
                id: 'el-icon-finished',
                name: 'el-icon-tickets',
                tableName: 'el-icon-date',
                domain: 'el-icon-folder-opened',
                from: 'el-icon-sort-down',
                to: 'el-icon-sort-up',
                main: 'el-icon-warning-outline',
                desc: 'el-icon-chat-line-square'
            },
            treeData: [],
            descriptionOption: {
                labelStyle: 'text-align:center;width:120px',
                contentStyle: 'width:240px;text-align:center;word-break;break-all;'
            },
            loadOption: {
                border: true,
                height: 395,
                editBtn: false,
                addBtn: false,
                menu: false,
                highlightCurrentRow: true,
                refreshBtn: false,
                columnBtn: false,
                column: [
                    {
                        label: '英文名称',
                        prop: 'id',
                        align: 'center'
                    }, {
                        label: '中文名称',
                        prop: 'name',
                        align: 'center'
                    },
                    {
                        label: '类型',
                        prop: 'attrDataTypeText',
                        align: 'center',
                        slot: true
                    },
                    {
                        label: '默认值',
                        prop: 'defaultValue',
                        align: 'center'
                    },
                    {
                        label: '说明',
                        prop: 'description',
                        align: 'center'
                    }
                ]
            },
            obj: {},
            treeOption: {
                defaultExpandAll: true,
                title: '链接类型树',
                addBtn: false,
                props: {
                    labelText: '',
                    label: 'label',
                    value: 'oid',
                    children: 'childList',
                }
            },
        }
    },
    created() {
        this.initTreeOnLoad();
        this.initDomainOption();
    },
 
    methods: {
        // 树点击
        nodeClick(data) {
            getDetail(data.oid).then(res => {
                this.obj = res.data.data;
            })
        },
        // 添加按钮点击事件
        linkTypeAdd() {
            this.$refs.linkAdd.linkType = {};
            this.$refs.linkAdd.showSubmitDialog = true;
        },
        // 编辑按钮点击事件
        linkTypeEdit() {
            var linktype = this.obj;
            linktype.fromBtmValues = this.obj.fromBtmTypes;
            linktype.toBtmValues = this.obj.toBtmTypes;
            linktype.attributes = this.obj.attributes;
            var json = JSON.stringify(linktype);
            this.addOption.linkType = JSON.parse(json);
            this.$refs.linkAdd.linkType = this.addOption.linkType;
            this.$refs.linkAdd.showSubmitDialog = true;
        },
        // 从已有中获取按钮点击事件
        selectFromTable() {
 
        },
        // 加载服务树
        initTreeOnLoad() {
            initTree().then(res => {
                this.treeData = res.data.data;
            });
        },
        // 加载服务下拉框
        initDomainOption() {
            getDomain().then(res => {
                this.domainOptions = res.data.data;
            })
        },
 
    }
}
</script>
 
<style lang="scss">
.attributeCrud>.el-card:nth-of-type(2)>.el-card__body>.avue-crud__menu {
    display: none !important;
}
</style>