田源
2023-05-09 549ecbf13b14a4deb74e42828abcd46ccb68a7c0
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<template>
  <el-container>
    <el-header>
      <el-button type="primary" @click="businessAdd">新增</el-button>
      <el-button type="primary" @click="businessEdit">修改</el-button>
      <el-button type="primary" @click="selectFromTable">从已有中获取</el-button>
    </el-header>
    <el-container>
      <el-aside width="240px">
        <basic-container>
          <avue-tree id="basic" :data="treeData" :option="treeOption" @node-click="nodeClick">
            <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="3" :size="size" border>
              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-finished"></i>
                  英文名称
                </template>
                {{ obj.id }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-info"></i>
                  中文名称
                </template>
                {{ obj.name }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-date"></i>
                  数据库表名
                </template>
                {{ obj.tableName }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-folder-opened"></i>
                  所属领域
                </template>
                {{ obj.domain }}
              </el-descriptions-item>
              <!-- <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-s-ticket"></i>
              标签
            </template>
            {{obj.hashtag}}
          </el-descriptions-item> -->
              <!-- <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-arrow-up"></i>
              继承自
            </template>
            {{ obj.sss }}
          </el-descriptions-item> -->
              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-s-check"></i>
                  版本规则
                </template>
                {{ obj.versionRule }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-refresh-right"></i>
                  生命周期
                </template>
                {{ obj.lifeCycleId }}
              </el-descriptions-item>
              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-view"></i>
                  视图
                </template>
                {{ obj.viewFlag }}
              </el-descriptions-item>
              <!-- <el-descriptions-item>
            <template slot="label">
              <i class="el-icon-arrow-down"></i>
              实现类
            </template>
            {{ obj.implClass }}
          </el-descriptions-item> -->
              <el-descriptions-item>
                <template slot="label">
                  <i class="el-icon-chat-line-square"></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 v-model="obj" :data="obj.attributes" :option="loadOption" @row-save="loadSave"></avue-crud>
          </basic-container>
        </el-main>
        <el-dialog :visible="ref.visible" title="从数据库中添加" width="700px" append-to-body @close="dialoghandelfalse">
          选择领域:
          <el-select v-model="domain" placeholder="请选择" @change="refOnLoad">
            <el-option v-for="item in domainOptions" :key="item" :label="item" :value="item">
            </el-option>
          </el-select>
          <avue-crud class="businessCrud" v-model="ref.form" :option="ref.option" :data="ref.data" @selection-change="selectionChange">
          </avue-crud>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialoghandelfalse">取 消</el-button>
            <el-button type="primary" @click="dialoghandeltrue">确 定</el-button>
          </span>
        </el-dialog>
      </el-container>
    </el-container>
    <business-add ref="btmAdd" :btmType="addOption.btmType" :domainOption="domainOptions">
  </business-add>
  </el-container>
</template>
<script>
import {
  initTree,
  refOnLoad,
  getDomain,
  saveFromTable,
  getDetail
} from "@/api/omd/btmType"
export default {
  name: "Business",
  data() {
    return {
      //生命周期对话框状态
      packageLifeBox: false,
      //版本规则状态
      rulesFalg: false,
      obj: {},
      selectionList: [],
      treeData: [],
      treeOption: {
        defaultExpandAll: true,
        title: '业务类型树',
        props: {
          labelText: '',
          label: 'name',
          value: 'oid',
          children: 'childList',
        }
      },
      addOption:{
        btmType:{},
      },
      loadOption: {
        border: true,
        height: 466,
        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: "attrDataType",
            align: 'center'
          },
          {
            label: "默认值",
            prop: "defaultValue",
            align: 'center'
          },
          {
            label: "说明",
            prop: "description",
            align: 'center'
          }
        ]
      },
      domain: null,
      domainOptions: [],
      ref: {
        // 从表中选择dialog状态
        visible: false,
        form: {},
        option: {
          height: "550px",
          selection: true,
          headerAlign: 'center',
          border: true,
          index: true,
          rowKey: 'id',
          tabs: true,
          addBtn: false,
          menu: false,
          highlightCurrentRow: true,
          column: [
            {
              label: '表名',
              prop: 'tableName',
              align: 'center',
              display: false
            },
            {
              label: '描述',
              prop: 'description',
              align: 'center',
              display: false
            }
          ]
        },
        data: [{
          tableName: '1',
          description: '2'
        }]
      }
    }
  },
  created() {
    this.initTreeOnLoad();
    this.initDomainOption();
  },
  methods: {
    //生命周期对话框取消点击事件
    dialoghandelfalse() {
      this.packageLifeBox = false
    },
    //生命周期对话框确定点击事件
    dialoghandeltrue() {
      this.packageLifeBox = false
    },
    //选择生命周期对话框
    handelLife() {
      this.packageLifeBox = true
    },
    //版本规则手动输入和选择框的状态取反
    handelRules() {
      this.rulesFalg = !this.rulesFalg
    },
    //版本规则三个按钮的显示隐藏
    radioChange(val) {
      if (val.value == 0) {
        this.basicOption.group[1].column[1].display = false;
        this.basicOption.group[1].column[2].display = false;
        this.basicOption.group[1].column[3].display = false;
      } else if (val.value == 1) {
        this.basicOption.group[1].column[1].display = true;
        this.basicOption.group[1].column[2].display = true;
        this.basicOption.group[1].column[3].display = false;
      } else if (val.value == 2) {
        this.basicOption.group[1].column[1].display = true;
        this.basicOption.group[1].column[2].display = true;
        this.basicOption.group[1].column[3].display = true;
      }
    },
    nodeClick(data) {
      getDetail(data.oid).then(res => {
        this.obj = res.data.data;
      })
    },
    //  基本信息添加
    basicSave(row, done, loading) {
      add(Object.assign({
        createUser: this.userInfo.name
      }, row)).then(() => {
        this.$message.success('新增成功')
        done();
        this.getList();
      }).catch(() => {
        loading()
      })
    },
    //属性添加
    loadSave(row, done, loading) {
      add(Object.assign({
        createUser: this.userInfo.name
      }, row)).then(() => {
        this.$message.success('新增成功')
        done();
        this.getList();
      }).catch(() => {
        loading()
      })
    },
    selectFromTable() {
      console.log('获取');
      this.ref.visible = true;
    },
    refOnLoad(domain) {
      refOnLoad(domain).then(res => {
        this.ref.data = res.data.data;
      })
    },
    initTreeOnLoad() {
      initTree().then(res => {
        console.log('123');
        this.treeData = res.data.data;
      });
    },
    initDomainOption() {
      getDomain().then(res => {
        this.domainOptions = res.data.data;
      })
    },
    selectionChange(list) {
      this.selectionList = list;
      console.log(this.selectionList);
    },
    dialoghandelfalse() {
      this.ref.visible = false;
      this.selectionList = [];
      this.domain = null;
    },
    dialoghandeltrue() {
      saveFromTable(this.selectionList, this.domain).then(res => {
        this.$message.success('保存成功');
        this.dialoghandelfalse();
        this.initTreeOnLoad();
      })
    },
    businessAdd(){
      this.$refs.btmAdd.showSubmitDialog = true;
      console.log('添加');
    },
    businessEdit(){
      this.addOption.btmType = this.obj;
      this.$refs.addOption.showSubmitDialog = true;
      console.log('编辑');
    }
  },
}
</script>
 
<style lang="scss">
#basic {
  height: 770px;
  border-radius: 10px;
}
 
.businessCrud > .el-card > .el-card__body > .avue-crud_menu{
        display: none!important;
    }
</style>