ap-dev 1.2.24 → 1.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,644 +1,468 @@
1
1
  <template>
2
- <ap-container>
3
- <ap-aside margin="1111">
4
- <div class="layout-aside-header">
5
- <div class="layout-aside-header-title">
6
- 字段类型
7
- </div>
8
- <div class="layout-aside-header-icon">
9
- <i class="el-icon-plus" @click="addTable" />
10
- <i class="el-icon-edit-outline" @click="editTable" />
11
- <i class="el-icon-delete" @click="deleteTable" />
12
- <el-popover ref="popoverRef" placement="bottom" trigger="click">
13
- <el-button-group>
14
- <el-button type="primary" icon="el-icon-top" @click="sortTypeBefore">上移</el-button>
15
- <el-button type="primary" icon="el-icon-bottom" @click="sortTypeAfter">下移</el-button>
16
- <el-button type="primary" icon="el-icon-s-operation" @click="sortTypeByIndex">
17
- 一键排序
18
- </el-button>
19
- </el-button-group>
20
- <i slot="reference" class="el-icon-sort" />
21
- </el-popover>
22
- </div>
23
- </div>
24
- <div>
25
- <el-input v-model="filterText" placeholder="关键字过滤" />
26
- </div>
27
- <div v-loading="loadingTreeFlag" class="layout-aside-content">
28
- <el-tree
29
- ref="typeTree"
30
- class="filter-tree"
31
- node-key="fdId"
32
- :data="typeTreeList"
33
- :props="defaultProps"
34
- default-expand-all
35
- show-checkbox
36
- :check-on-click-node="true"
37
- :highlight-current="true"
38
- :expand-on-click-node="false"
39
- :check-strictly="false"
40
- :filter-node-method="filterNode"
41
- @check="nodeClickEvent"
42
- />
43
- </div>
44
- </ap-aside>
45
- <ap-split-panel />
46
2
  <ap-container>
47
- <ap-header margin="1110">
48
- <el-form
49
- ref="searchFormRef"
50
- :model="searchForm"
51
- :inline="true"
52
- class="layout-header-form"
53
- >
54
- <el-form-item label="搜索:" class="layout-header-form-item" prop="likeStr">
55
- <el-input v-model="searchForm.likeStr" placeholder="字段名/注释" />
56
- </el-form-item>
57
- </el-form>
58
- <el-button type="primary" @click="searchEvent">查询</el-button>
59
- </ap-header>
60
- <ap-main margin="0110">
61
- <ap-table ref="devDbFieldGrid" :options.sync="tableOpt" />
62
- </ap-main>
63
- </ap-container>
3
+ <ap-main margin="1111" class="flex-justify-start">
4
+ <div class="flex-col" style="height: 100%;width: 1000px;">
5
+ <div class="flex-justify-start">
6
+ <div style="width: 60px;"></div>
7
+ <div class="flex-justify-start flex-1">
8
+ <div style="width: 230px">
9
+ <span style="font-weight: bold;">来源库:</span>
10
+ <el-select v-model="sourceId" placeholder="来源数据库" filterable style="width: 120px">
11
+ <el-option v-for="item in dbSourceList" :key="item.fdId" :label="item.fdName" :value="item.fdId"/>
12
+ </el-select>
13
+ </div>
14
+ <div class="flex-1 flex-justify-start">
15
+ <div>
16
+ <span style="font-weight: bold;">目标库:</span><br>
17
+ <span style="font-size: 12px;" class="ap-color-gray">要操作的库</span>
18
+ </div>
19
+ <el-select v-model="targetId" placeholder="目标数据库" filterable style="width: 120px" @change="targetChange">
20
+ <el-option v-for="item in dbSourceList" :key="item.fdId" :label="item.fdName" :value="item.fdId"/>
21
+ </el-select>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ <div class="flex-1 flex-col" style="overflow-y: scroll;border: 1px solid #cccccc;">
26
+ <div class="flex-justify-start ctn" style="border-bottom: 1px solid #cccccc;">
27
+ <div class="flex-center operate-type ap-bg-green">创<br/>建<br/>表</div>
28
+ <div class="flex-1">
29
+ <template v-for="item in addList">
30
+ <div class="flex-justify-start flex-1 row">
31
+ <div class="operate">
32
+ <el-checkbox v-model="checkedTable" :label="item.tableName"></el-checkbox>
33
+ </div>
34
+ <div class="source-ctn"> {{ item.tableName }}</div>
35
+ <div class="flex-1 ap-color-green new-table" @click="showTableCol(item.tableName)">
36
+ <i class="el-icon-circle-plus-outline"/>
37
+ <span class="table-name">{{ item.tableName }}</span>
38
+ <span class="dev-table-comment">{{ item.tableComment }}</span>
39
+ </div>
40
+ </div>
41
+ <div v-if="currentTable == item.tableName" v-for="col in item.tableColumns" class="flex-justify-start row-col">
42
+ <div class="operate"></div>
43
+ <div class="source-ctn"></div>
44
+ <div class="flex-1 flex-justify-start row-cell ap-color-gray">
45
+ <div class="row-cell-col">
46
+ {{ col.columnName }}
47
+ </div>
48
+ <div v-html="col.colInfo"></div>
49
+ </div>
50
+ </div>
64
51
 
52
+ </template>
53
+ </div>
54
+ </div>
55
+ <div class="flex-justify-start ctn" style="border-bottom: 1px solid #cccccc;">
56
+ <div class="flex-center operate-type ap-bg-red">删<br/>除<br/>表</div>
57
+ <div class="flex-1">
58
+ <template v-for="item in delList">
59
+ <div class="flex-justify-start flex-1 row">
60
+ <div class="operate">
61
+ <el-checkbox v-model="checkedTable" :label="item.tableName"></el-checkbox>
62
+ </div>
63
+ <div class="source-ctn"></div>
64
+ <div class="flex-1 ap-color-red new-table" @click="showTableCol(item.tableName)">
65
+ <i class="el-icon-trash-o"/>
66
+ <span class="table-name">{{ item.tableName }}</span>
67
+ <span class="dev-table-comment">{{ item.tableComment }}</span>
68
+ </div>
69
+ </div>
70
+ <div v-if="currentTable == item.tableName" v-for="col in item.tableColumns" class="flex-justify-start row-col">
71
+ <div class="operate"></div>
72
+ <div class="source-ctn"></div>
73
+ <div class="flex-1 flex-justify-start row-cell ap-color-gray">
74
+ <div class="row-cell-col">
75
+ {{ col.columnName }}
76
+ </div>
77
+ <div v-html="col.colInfo"></div>
78
+ </div>
79
+ </div>
65
80
 
66
- <el-dialog
67
- :title="dialogTitle"
68
- :visible.sync="dialogVisible"
69
- width="35%"
70
- >
71
- <el-form ref="dialogForm" :model="dialogForm" :rules="dialogFormRules" label-width="80px">
81
+ </template>
82
+ </div>
83
+ </div>
84
+ <div class="flex-justify-start ctn" style="border-bottom: 1px solid #cccccc;">
85
+ <div class="flex-center operate-type ap-bg-blue">更<br/>新<br/>表</div>
86
+ <div class="flex-1">
87
+ <template v-for="item in updateList">
88
+ <div class="flex-justify-start row">
89
+ <div class="operate">
90
+ <el-checkbox v-model="checkedTable" :label="item.tableName"></el-checkbox>
91
+ </div>
92
+ <div class="source-ctn">{{ item.tableName }}</div>
93
+ <div class="flex-1 ap-color-blue new-table" @click="showTableCol(item.tableName)">
94
+ <i class="el-icon-transfer"/>
95
+ <span class="table-name">{{ item.tableName }} </span>
96
+ <span v-html="showTableComment(item)"></span>
97
+ </div>
98
+ </div>
99
+ <div v-if="currentTable == item.tableName" v-for="col in item.tableColumnsUpdate" class="flex-justify-start row-col">
100
+ <div class="operate"></div>
101
+ <div class="source-ctn"></div>
102
+ <!-- 0相同 1添加 2修改 3删除-->
103
+ <div v-if="col.compareType==0" class="flex-1 flex-justify-start row-cell ap-color-gray">
104
+ <div class="row-cell-col">
105
+ <i class="el-icon-denghao"/>
106
+ {{ col.columnName }}
107
+ </div>
108
+ <div v-html="col.colInfoCompare"></div>
109
+ </div>
110
+ <div v-if="col.compareType==1" class="flex-1 flex-justify-start row-cell ap-color-green">
111
+ <div class="row-cell-col">
112
+ <i class="el-icon-plus"/>
113
+ {{ col.columnName }}
114
+ </div>
115
+ <div v-html="col.colInfoCompare"></div>
116
+ </div>
117
+ <div v-if="col.compareType==2" :title="col.compareStr" class="flex-1 flex-justify-start row-cell ap-color-gray">
118
+ <div class="row-cell-col ap-color-blue">
119
+ <i class="el-icon-edit-outline"/>
120
+ {{ col.columnName }}
121
+ </div>
122
+ <div v-html="col.colInfoCompare"></div>
123
+ </div>
124
+ <div v-if="col.compareType==3" class="flex-1 flex-justify-start row-cell ap-color-red">
125
+ <div class="row-cell-col">
126
+ <i class="el-icon-close"/>
127
+ {{ col.columnName }}
128
+ </div>
129
+ <div v-html="col.colInfo"></div>
130
+ </div>
131
+ </div>
132
+ </template>
133
+ </div>
134
+ </div>
135
+ <div class="flex-justify-start flex-1 ctn">
136
+ <div class="flex-center operate-type ap-bg-gray">相<br/>同<br/>表</div>
137
+ <div class="flex-1">
138
+ <template v-for="item in sameList">
139
+ <div class="flex-justify-start flex-1 row">
140
+ <div class="operate">
141
+ </div>
142
+ <div class="source-ctn ap-color-gray"> {{ item.tableName }}</div>
143
+ <div class="flex-1 ap-color-gray new-table" @click="showTableCol(item.tableName)">
144
+ <i class="el-icon-denghao"/> {{ item.tableName }}
145
+ <span class="dev-table-comment">{{ item.tableComment }}</span>
146
+ </div>
147
+ </div>
148
+ <div v-if="currentTable == item.tableName" v-for="col in item.tableColumns" class="flex-justify-start row-col">
149
+ <div class="operate"></div>
150
+ <div class="source-ctn"></div>
151
+ <div class="flex-1 flex-justify-start row-cell ap-color-gray">
152
+ <div class="row-cell-col">
153
+ {{ col.columnName }}
154
+ </div>
155
+ <div v-html="col.colInfo"></div>
156
+ </div>
157
+ </div>
72
158
 
73
- <el-form-item label="父类别">
74
- <el-select v-model="dialogForm.fdParentId" filterable placeholder="请选择父节点">
75
- <el-option label="无" value="" />
76
- <el-option
77
- v-for="item in typeList"
78
- :key="item.fdId"
79
- :label="item.fdName"
80
- :value="item.fdId"
81
- />
82
- </el-select>
83
- </el-form-item>
159
+ </template>
160
+ </div>
161
+ </div>
162
+ </div>
163
+ </div>
164
+ <div class="flex-col" style="padding: 0 5px">
165
+ <div>
166
+ <ap-button type="primary" :click="doCompare" icon="el-icon-exchange">结构比对</ap-button>
167
+ </div>
168
+ <div style="margin-top: 10px">
169
+ <ap-button type="primary" :click="getSql" icon="el-icon-tickets">生成脚本</ap-button>
170
+ </div>
171
+ <div style="margin-top: 10px">
172
+ <ap-button type="primary" :click="doTableUpdate" icon="el-icon-upload">脚本部署</ap-button>
173
+ </div>
174
+ </div>
175
+ <div class="flex-1 flex-col" style="height: 100%">
176
+ <div style="height: 38px" class="flex-justify-start">
177
+ <span style="font-weight: bold;">{{ targetName }}</span><span v-html="msg"></span>
178
+ </div>
179
+ <div class="flex-1 sql-str" style="height: 100%;width: 100%">
180
+ <el-input v-model="sqlStr" type="textarea" rows=4 style="height: 100%;width: 100%"></el-input>
181
+ </div>
182
+ </div>
183
+ </ap-main>
184
+ </ap-container>
185
+ </template>
84
186
 
85
- <el-form-item label="类别名称" prop="fdName">
86
- <el-input v-model="dialogForm.fdName" />
87
- </el-form-item>
187
+ <script>
88
188
 
89
- <el-form-item label="排序" prop="fdSort">
90
- <el-input-number v-model="dialogForm.fdSort" controls-position="right" />
91
- </el-form-item>
92
- </el-form>
189
+ export default {
190
+ name: 'DevDbSync',
191
+ data() {
192
+ return {
193
+ sourceId: "",
194
+ targetId: "",
195
+ targetName: "",
196
+ dbSourceList: [],
197
+ addList: [],
198
+ delList: [],
199
+ sameList: [],
200
+ updateList: [],
201
+ checkedTable: [],
202
+ currentTable: "",
203
+ msg: "",
204
+ sqlStr: "",
93
205
 
206
+ }
207
+ },
208
+ watch: {},
209
+ created() {
210
+ this.initDbSource()
211
+ },
212
+ methods: {
213
+ initDbSource() {
214
+ this.$request({
215
+ url: '/apd/db/TDevDbAuth/getDbSourceList',
216
+ method: 'post'
217
+ }).then(response => {
218
+ this.dbSourceList = response.data;
219
+ })
220
+ },
221
+ getCompareFlag() {
222
+ return hasSource && hasTarget;
223
+ },
224
+ hasTable(list, tableName) {
225
+ if (list == null) {
226
+ return false;
227
+ }
228
+ for (let i = 0; i < list.length; i++) {
229
+ if (list[i].tableName == tableName) {
230
+ return true;
231
+ }
232
+ }
233
+ return false;
234
+ },
235
+ getTableByName(list, name) {
236
+ for (let i = 0; i < list.length; i++) {
237
+ if (list[i].tableName == name) {
238
+ return list[i];
239
+ }
240
+ }
241
+ return null;
242
+ },
243
+ showTableComment(item) {
244
+ let oldTableComment = item.oldTableComment;
245
+ let tableComment = item.tableComment;
246
+ if (tableComment == oldTableComment) {
247
+ return `<span class="ap-color-gray dev-table-comment"> ${tableComment}</span>`
248
+ }
249
+ if (oldTableComment == null || oldTableComment == "") {
250
+ return `<span class="ap-color-green dev-table-comment"> ${tableComment}</span>`
251
+ }
252
+ return `<span class="ap-color-blue dev-table-comment"> ${tableComment}</span>`
253
+ },
254
+ targetChange(val) {
255
+ let list = this.dbSourceList;
256
+ for (let i = 0; i < list.length; i++) {
257
+ if (val == list[i].fdId) {
258
+ this.targetName = list[i].fdName + ":";
259
+ return;
260
+ }
261
+ }
262
+ this.targetName = "";
263
+ },
264
+ showTableCol(table) {
265
+ if (this.currentTable == table) {
266
+ this.currentTable = "";
267
+ return;
268
+ }
269
+ this.currentTable = table;
270
+ },
271
+ getSql() {
272
+ return new Promise((resolve) => {
273
+ let tables = this.checkedTable;
274
+ if (tables == null || tables.length < 1) {
275
+ this.$message.error("请先选择需要同步的表");
276
+ resolve()
277
+ return;
278
+ }
94
279
 
95
- <span slot="footer" class="dialog-footer">
96
- <el-button @click="dialogVisible = false">取 消</el-button>
97
- <el-button type="primary" @click="saveTable">确 定</el-button>
98
- </span>
99
- </el-dialog>
100
- </ap-container>
101
- </template>
280
+ let addCount = 0;
281
+ let delCount = 0;
282
+ let updateCount = 0;
283
+ for (let i = 0; i < tables.length; i++) {
284
+ let item = tables[i];
285
+ if (this.hasTable(this.addList, item)) {
286
+ addCount++;
287
+ continue;
288
+ }
289
+ if (this.hasTable(this.delList, item)) {
290
+ delCount++;
291
+ continue;
292
+ }
293
+ if (this.hasTable(this.updateList, item)) {
294
+ updateCount++;
295
+ continue;
296
+ }
297
+ }
298
+ let msg = "";
299
+ if (addCount > 0) {
300
+ msg += "<span class='ap-color-green' style='font-weight: bold;margin-right: 15px'>创建 " + addCount + " 个</span>";
301
+ }
302
+ if (delCount > 0) {
303
+ msg += "<span class='ap-color-red' style='font-weight: bold;margin-right: 15px'>删除 " + delCount + " 个</span>";
304
+ }
305
+ if (updateCount > 0) {
306
+ msg += "<span class='ap-color-blue' style='font-weight: bold;margin-right: 15px'>更新 " + updateCount + " 个</span>";
307
+ }
308
+ this.msg = msg;
102
309
 
103
- <script>
104
- import { convertToArrayData, convertToTreeData } from 'ap-util/util/DataUtil'
310
+ this.$request({
311
+ url: '/apd/db/DevDbTable/getSyncSql',
312
+ method: 'post',
313
+ data: {
314
+ sourceId: this.sourceId,
315
+ targetId: this.targetId,
316
+ tables: JSON.stringify(this.checkedTable)
317
+ }
318
+ }).then(response => {
319
+ this.sqlStr = response.data;
320
+ }).finally(() => {
321
+ resolve()
322
+ });
323
+
324
+ });
105
325
 
106
- export default {
107
- name: 'DevDbField',
108
- data() {
109
- const columns = [
110
- {
111
- prop: 'fdFieldTypeId',
112
- label: '字段类型',
113
- type: 'select',
114
- addDefaultValue: this.addDefaultValueFn,
115
- selectOptionsRemote: 'typeList',
116
- selectOptionsKey: { label: 'fdName', value: 'fdId' },
117
- rules: [
118
- { required: true, message: '请选择类型' }
119
- ]
120
- },
121
- {
122
- prop: 'fdName',
123
- label: '字段名称',
124
- type: 'input',
125
- rules: [
126
- { required: true, message: '字段名称必填' },
127
- { min: 1, max: 30, message: '长度在 1 到 30 个字符' }
128
- ]
129
- },
130
- {
131
- prop: 'fdComment',
132
- label: '默认注释',
133
- type: 'input',
134
- rules: [
135
- { required: true, message: '字段注释必填' },
136
- { min: 1, max: 30, message: '长度在 1 到 30 个字符' }
137
- ]
138
- }, {
139
- prop: 'fdDataType',
140
- label: '数据类型',
141
- type: 'select',
142
- selectOptions: [
143
- {
144
- label: '常用',
145
- options: [
146
- { label: 'char(255)', value: 'char' },
147
- { label: 'varchar(6.5万)', value: 'varchar' },
148
- { label: 'tinyint(255)', value: 'tinyint' },
149
- { label: 'datetime(年月日时分秒)', value: 'datetime' }
150
- ]
151
- },
152
- {
153
- label: '字符串',
154
- options: [
155
- { label: 'char(255)', value: 'char' },
156
- { label: 'varchar(6.5万)', value: 'varchar' },
157
- { label: 'text(长文本)', value: 'text' }
158
- ]
159
- },
160
- {
161
- label: '整型数值',
162
- options: [
163
- { label: 'tinyint(255)', value: 'tinyint' },
164
- { label: 'smallint(6.5万)', value: 'smallint' },
165
- { label: 'mediumint(1.6千万)', value: 'mediumint' },
166
- { label: 'int(4.2亿)', value: 'int' },
167
- { label: 'bigint(极大)', value: 'bigint' }
168
- ]
169
- },
170
- {
171
- label: '浮点数值',
172
- options: [
173
- { label: 'float(单精度)', value: 'float' },
174
- { label: 'double(双精度)', value: 'double' },
175
- { label: 'decimal(小数值)', value: 'decimal' }
176
- ]
177
- },
178
- {
179
- label: '日期时间',
180
- options: [
181
- { label: 'date(年月日)', value: 'date' },
182
- { label: 'time(时分秒)', value: 'time' },
183
- { label: 'year(年)', value: 'year' },
184
- { label: 'datetime(年月日时分秒)', value: 'datetime' },
185
- { label: 'timestamp(时间戳)', value: 'timestamp' }
186
- ]
187
- }
188
- ],
189
- selectFilterable: true,
190
- selectIsGroup: true,
191
- selectPlaceholder: '选择数据类型',
192
- rules: [
193
- { required: true, message: '数据类型必选' }
194
- ]
195
- }, {
196
- prop: 'fdSort',
197
- label: '排序',
198
- type: 'inputNumber',
199
- inputNumberMin: 0,
200
- // inputNumberMax: 10,
201
- sortable: true,
202
- rules: [
203
- { required: true, message: '请输入排序' }
204
- ],
205
- addDefaultValue: 0
206
- }, {
207
- prop: 'fdDeleted',
208
- label: '删除',
209
- type: 'input',
210
- hide: true,
211
- addDefaultValue: 0
212
- }]
213
- const tableOpt = {
214
- title: '字段列表',
215
- columns: columns,
216
- pagination: {
217
- pageSizes: [30, 60, 90],
218
- pageSize: 30
219
- },
220
- dataUrl: '/apd/db/DevDbField/getTDevDbFieldGridList',
221
- saveUrl: '/apd/db/DevDbField/saveTDevDbFieldGridData',
222
- editPk: 'fdId',
223
- deletePk: 'fdId',
224
- deleteUrl: '/apd/db/DevDbField/deleteTDevDbFieldByFdId',
225
- toolbarBtn: ['add', 'edit', 'del', 'cancel', 'refresh', 'save', 'separator',
226
- {
227
- btnType: 'primary',
228
- text: '上移',
229
- icon: 'el-icon-top',
230
- onClick: () => {
231
- this.sortBefore()
232
- }
233
326
  },
234
- {
235
- btnType: 'primary',
236
- text: '下移',
237
- icon: 'el-icon-bottom',
238
- onClick: () => {
239
- this.sortAfter()
240
- }
327
+ doCompare() {
328
+ return new Promise((resolve) => {
329
+ if (this.sourceId == null || this.sourceId == '' || this.targetId == null || this.targetId == '') {
330
+ this.$message.error("请先选择数据源");
331
+ resolve()
332
+ return;
333
+ }
334
+ this.$request({
335
+ url: '/apd/db/DevDbTable/getTableCompareList',
336
+ method: 'post',
337
+ data: {
338
+ sourceId: this.sourceId,
339
+ targetId: this.targetId
340
+ }
341
+ }).then(response => {
342
+ let res = response.data;
343
+ this.addList = res.addList;
344
+ this.delList = res.delList;
345
+ this.sameList = res.sameList;
346
+ this.updateList = res.updateList;
347
+ }).finally(() => {
348
+ resolve()
349
+ });
350
+ });
241
351
  },
242
- {
243
- btnType: 'primary',
244
- text: '一键排序',
245
- icon: 'el-icon-s-operation',
246
- onClick: () => {
247
- this.doSortByIndex()
248
- }
249
- }, , {
250
- btnType: 'info',
251
- text: '帮助',
252
- icon: 'el-icon-question',
253
- onClick: () => {
254
- this.openHelp()
255
- }
256
- }],
257
- initData: false,
258
- beforeAdd: this.beforeAddFn,
259
- params: () => {
260
- return {
261
- fdFieldTypeIds: this.selectedFieldTypeIds,
262
- likeStr: this.searchForm.likeStr
352
+ doTableUpdate() {
353
+ return new Promise((resolve) => {
354
+ let sqlStr = this.sqlStr;
355
+ if (sqlStr == null || sqlStr == "") {
356
+ this.$message.error("SQL脚本为空,请先【生成脚本】");
357
+ resolve()
358
+ return;
359
+ }
360
+
361
+ this.$confirm(`确定要同步表架构?`, '提示', {
362
+ confirmButtonText: '确定同步',
363
+ cancelButtonText: '取消',
364
+ type: 'warning'
365
+ }).then(() => {
366
+ this.$request({
367
+ url: '/apd/db/DevDbTable/updateTableStruct',
368
+ method: 'post',
369
+ data: {
370
+ targetId: this.targetId,
371
+ sqlStr: sqlStr
372
+ }
373
+ }).then(response => {
374
+ this.$message.success(`同步成功!`);
375
+ this.sqlStr = "";
376
+ this.checkedTable = [];
377
+ this.doCompare();
378
+ this.msg = "";
379
+ this.currentTable = "";
380
+ }).finally(() => {
381
+ resolve()
382
+ });
383
+ }).finally(() => {
384
+ resolve()
385
+ });
386
+ });
263
387
  }
264
- }
265
- }
266
388
 
267
- return {
268
- // ----- 左侧树 -----
269
- loadingTreeFlag: false,
270
- filterText: '',
271
- typeTreeList: [],
272
- defaultProps: {
273
- children: 'children',
274
- label: 'fdName'
275
- },
276
- selectedFieldTypeIds: '',
277
- // ----- dialog -----
278
- typeList: [],
279
- dialogVisible: false,
280
- dialogTitle: '', // dialog标题
281
- isAddDialog: true, // 添加类型dialog
282
- dialogForm: {
283
- fdName: '',
284
- fdParentId: '',
285
- fdId: '',
286
- fdSort: undefined
287
- },
288
- dialogFormRules: {
289
- fdSort: [
290
- { type: 'number', message: '请输入数字', trigger: 'change' }
291
- ],
292
- fdName: [
293
- { required: true, message: '请输入类型名称', trigger: 'blur' },
294
- { min: 1, max: 10, message: '长度在 1 到 10 个字符', trigger: 'blur' }
295
- ]
296
- },
297
- // ----- 表格 -----
298
- searchForm: {
299
- listStr: ''
300
- },
301
- tableOpt: tableOpt
302
- }
303
- },
304
- watch: {
305
- filterText(val) {
306
- this.$refs.typeTree.filter(val)
307
389
  }
308
- },
309
- created() {
310
- this.loadTreeData()
311
- },
312
- methods: {
313
- // 左侧树:加载数据
314
- loadTreeData() {
315
- this.loadingTreeFlag = true
316
- this.$request({
317
- url: '/apd/db/DevDbField/getDbFieldTypeList',
318
- method: 'post'
319
- }).then(response => {
320
- this.typeList = JSON.parse(JSON.stringify(response.data))
321
- this.typeTreeList = convertToTreeData(response.data, {
322
- idKey: 'fdId',
323
- parentKey: 'fdParentId',
324
- childrenKey: 'children'
325
- })
326
- }).finally(() => {
327
- this.loadingTreeFlag = false
328
- })
329
- },
330
- // 左侧树:初始化数据
331
- initTreeData() {
332
- // 重置当前选择节点
333
- this.$refs.typeTree.setCurrentKey()
334
- this.loadTreeData()
335
- },
336
- // 左侧树:过滤节点
337
- filterNode(value, data) {
338
- if (!value) return true
339
- return data.fdName.indexOf(value) !== -1
340
- },
341
- // 选择勾选事件
342
- nodeClickEvent(data, node, comp) {
343
- const parentKeys = this.$refs.typeTree.getHalfCheckedKeys()
344
- const selectKeys = this.$refs.typeTree.getCheckedKeys(false)
345
- this.selectedFieldTypeIds = parentKeys.concat(selectKeys).join(',')
346
- this.$refs.devDbFieldGrid.refresh()
347
- },
348
- // dialog:重置表单
349
- resetDialogForm() {
350
- this.dialogForm = {
351
- fdName: '',
352
- fdParentId: '',
353
- fdId: '',
354
- fdSort: null
355
- }
356
- },
357
- getCurrentNode() {
358
- return this.$refs.typeTree.getCurrentNode() || {}
359
- },
360
- // dialog:添加数据
361
- addTable() {
362
- this.resetDialogForm()
363
- this.dialogVisible = true
364
- this.dialogTitle = '添加字段类型'
365
- this.isAddDialog = true
366
- this.dialogForm.fdParentId = this.getCurrentNode().fdId
367
- },
368
- // dialog:编辑数据
369
- editTable() {
370
- const currentNodeFdId = this.getCurrentNode().fdId
371
- if (!currentNodeFdId) {
372
- this.$message.error('请选择需要编辑的数据!')
373
- return
374
- }
390
+ }
391
+ </script>
375
392
 
376
- this.resetDialogForm()
377
- this.dialogVisible = true
378
- this.dialogTitle = '编辑字段类型'
379
- this.isAddDialog = false
380
- this.dialogForm.fdId = currentNodeFdId
393
+ <style scoped>
394
+ .board {
395
+ border: 1px solid #cccccc;
396
+ }
381
397
 
382
- this.$request({
383
- url: '/apd/db/DevDbField/getDbFieldTypeByFdId',
384
- method: 'post',
385
- data: {
386
- fdId: currentNodeFdId
387
- }
388
- }).then(response => {
389
- this.dialogForm.fdId = response.data.fdId
390
- this.dialogForm.fdName = response.data.fdName
391
- this.dialogForm.fdParentId = response.data.fdParentId
392
- this.dialogForm.fdSort = response.data.fdSort
393
- })
394
- },
395
- // 删除类型数据
396
- deleteTable() {
397
- const currentNode = this.getCurrentNode()
398
- const currentNodeFdId = currentNode.fdId
399
- if (!currentNodeFdId) {
400
- this.$message.error('请选择需要删除的数据!')
401
- return
402
- }
398
+ .ctn {
399
+ align-items: stretch;
400
+ border-right: 1px solid #cccccc;
401
+ }
403
402
 
404
- this.$confirm(`确定要删除【${currentNode.fdName}】?`, '提示', {
405
- confirmButtonText: '确定',
406
- cancelButtonText: '取消',
407
- type: 'warning'
408
- }).then(() => {
409
- this.$request({
410
- url: '/apd/db/DevDbField/deleteDbFieldType',
411
- method: 'post',
412
- data: {
413
- fdId: currentNodeFdId
414
- }
415
- }).then(response => {
416
- this.$message.success(`删除成功!已删除${response.data}条数据!`)
417
- this.initTreeData()
418
- })
419
- })
420
- },
421
- checkTypeSort() {
422
- const currentNode = this.getCurrentNode()
423
- if (currentNode == null) {
424
- this.$message.error(`请选择需要操作的节点!`)
425
- return null
426
- }
427
- return currentNode
428
- },
429
- // 修改排序
430
- doTypeSortChange(rowFdId, rowFdSort, exchangeRowFdId, exchangeRowFdSort) {
431
- this.$request({
432
- url: '/apd/db/DevDbField/updateDbFieldTypeSort',
433
- method: 'post',
434
- data: { rowFdId, rowFdSort, exchangeRowFdId, exchangeRowFdSort }
435
- }).then(response => {
436
- this.$message.success(`修改成功!`)
437
- this.$refs.popoverRef.doClose()
438
- this.loadTreeData()
439
- })
440
- },
441
- // 排序调整:向上
442
- sortTypeBefore() {
443
- const currentNode = this.checkTypeSort()
444
- if (currentNode == null) {
445
- return
446
- }
403
+ .row {
404
+ padding: 3px;
405
+ align-items: stretch;
406
+ }
447
407
 
448
- const arrayData = convertToArrayData(this.typeTreeList)
449
- let currentNodeIndex = 0
450
- for (let i = 0; i < arrayData.length; i++) {
451
- if (arrayData[i].fdId == currentNode.fdId) {
452
- currentNodeIndex = i
453
- break
454
- }
455
- }
456
- if (currentNodeIndex == 0) {
457
- this.$message.success(`已经是第一个啦!`)
458
- return
459
- }
408
+ .row-col {
409
+ font-size: 12px;
410
+ padding: 1px 0;
411
+ }
460
412
 
461
- const exchangeRow = arrayData[currentNodeIndex - 1]
413
+ .row-cell {
414
+ margin-left: 30px;
415
+ border-bottom: 1px solid #f3f3f3;
416
+ }
462
417
 
463
- this.doTypeSortChange(currentNode.fdId, exchangeRow.fdSort, exchangeRow.fdId, currentNode.fdSort)
464
- },
465
- // 排序调整:向下
466
- sortTypeAfter() {
467
- const currentNode = this.checkTypeSort()
468
- if (currentNode == null) {
469
- return
470
- }
471
- const arrayData = convertToArrayData(this.typeTreeList)
472
- let currentNodeIndex = 0
473
- for (let i = 0; i < arrayData.length; i++) {
474
- if (arrayData[i].fdId == currentNode.fdId) {
475
- currentNodeIndex = i
476
- break
477
- }
478
- }
418
+ .row-cell-col {
419
+ width: 150px;
420
+ }
479
421
 
480
- if (currentNodeIndex == arrayData.length - 1) {
481
- this.$message.success(`字段已经是最后一个啦!`)
482
- return
483
- }
422
+ .col {
423
+ margin-left: 20px;
424
+ }
484
425
 
485
- const exchangeRow = arrayData[currentNodeIndex + 1]
426
+ .source-ctn {
427
+ width: 230px;
428
+ overflow: hidden;
429
+ }
486
430
 
487
- this.doTypeSortChange(currentNode.fdId, exchangeRow.fdSort, exchangeRow.fdId, currentNode.fdSort)
488
- },
489
- // 一键排序
490
- sortTypeByIndex() {
491
- const arrayData = convertToArrayData(this.typeTreeList)
492
- const list = []
493
- for (let i = 0; i < arrayData.length; i++) {
494
- list.push({
495
- fdId: arrayData[i].fdId,
496
- fdSort: i + 1
497
- })
498
- }
499
- this.$request({
500
- url: '/apd/db/DevDbField/updateDbFieldTypeSortList',
501
- method: 'post',
502
- data: { list: JSON.stringify(list) }
503
- }).then(response => {
504
- this.$message.success(`排序成功!`)
505
- this.$refs.popoverRef.doClose()
506
- this.loadTreeData()
507
- })
508
- },
509
- // dialog:保存类型数据
510
- saveTable() {
511
- this.$refs.dialogForm.validate((valid) => {
512
- if (!valid) {
513
- this.$message.error(`数据校验失败,请重新填写信息!`)
514
- return false
515
- }
516
- if (this.isAddDialog) {
517
- // 添加数据
518
- this.$request({
519
- url: '/apd/db/DevDbField/insertDbFieldType',
520
- method: 'post',
521
- data: this.dialogForm
522
- }).then(response => {
523
- this.$message.success(`添加成功!已添加${response.data}条数据!`)
524
- this.dialogVisible = false
525
- this.initTreeData()
526
- })
527
- } else {
528
- // 更新数据
529
- this.$request({
530
- url: '/apd/db/DevDbField/updateDbFieldType',
531
- method: 'post',
532
- data: this.dialogForm
533
- }).then(response => {
534
- this.$message.success(`更新成功!已更新${response.data}条数据!`)
535
- this.dialogVisible = false
536
- this.initTreeData()
537
- })
538
- }
539
- })
540
- },
541
- // 添加行:数据类型默认值
542
- beforeAddFn() {
543
- const fdFieldTypeIds = this.selectedFieldTypeIds
544
- if (fdFieldTypeIds == null || fdFieldTypeIds == '') {
545
- this.$message.error(`请先选择字段类型!`)
546
- return false
547
- }
548
- return true
549
- },
550
- addDefaultValueFn() {
551
- return this.getCurrentNode().fdId
552
- },
553
- checkSort() {
554
- const selection = this.$refs.devDbFieldGrid.getSelection()
555
- if (selection.length == 0) {
556
- this.$message.error(`请选择需要操作的行!`)
557
- return null
558
- } else if (selection.length > 1) {
559
- this.$message.error(`只能选择一行!`)
560
- return null
561
- }
562
- return selection[0]
563
- },
564
- // 修改排序
565
- doSortChange(rowFdId, rowFdSort, exchangeRowFdId, exchangeRowFdSort) {
566
- this.$request({
567
- url: '/apd/db/DevDbField/updateDbFieldSort',
568
- method: 'post',
569
- data: { rowFdId, rowFdSort, exchangeRowFdId, exchangeRowFdSort }
570
- }).then(response => {
571
- this.$message.success(`修改成功!`)
572
- this.$refs.devDbFieldGrid.refresh()
573
- })
574
- },
575
- // 排序调整:向上
576
- sortBefore() {
577
- const rowData = this.checkSort()
578
- if (rowData == null) {
579
- return
580
- }
581
- const dataIdx = rowData.dataIdx
582
- if (dataIdx == 1) {
583
- this.$message.success(`字段已经是第一个啦!`)
584
- return
585
- }
431
+ .table-name {
432
+ font-weight: bold;
433
+ margin-left: 5px;
434
+ }
586
435
 
587
- const exchangeRow = this.tableOpt.data[dataIdx - 2]
436
+ .operate-type {
437
+ width: 30px;
438
+ font-size: 13px;
439
+ padding: 3px;
440
+ }
588
441
 
589
- this.doSortChange(rowData.fdId, exchangeRow.fdSort, exchangeRow.fdId, rowData.fdSort)
590
- },
591
- // 排序调整:向下
592
- sortAfter() {
593
- const rowData = this.checkSort()
594
- if (rowData == null) {
595
- return
596
- }
597
- const dataIdx = rowData.dataIdx
598
- if (dataIdx >= this.tableOpt.data.length) {
599
- this.$message.success(`字段已经是最后一个啦!`)
600
- return
601
- }
602
- const exchangeRow = this.tableOpt.data[dataIdx]
442
+ .operate {
443
+ width: 25px;
444
+ }
603
445
 
604
- this.doSortChange(rowData.fdId, exchangeRow.fdSort, exchangeRow.fdId, rowData.fdSort)
605
- },
606
- doSortByIndex() {
607
- const data = this.$refs.devDbFieldGrid.getData()
608
- const list = []
609
- for (let i = 0; i < data.length; i++) {
610
- list.push({
611
- fdId: data[i].fdId,
612
- fdSort: data[i].dataIdx
613
- })
614
- }
615
- this.$request({
616
- url: '/apd/db/DevDbField/updateDbFieldSortList',
617
- method: 'post',
618
- data: { list: JSON.stringify(list) }
619
- }).then(response => {
620
- this.$message.success(`排序成功!`)
621
- this.$refs.devDbFieldGrid.refresh()
622
- })
623
- },
624
- searchEvent() {
625
- this.$refs.devDbFieldGrid.refresh()
626
- },
627
- openHelp() {
628
- const msg = `
629
- <b>一、通用字段:</b><br>
630
- 1、标识类型(0、1):放在【默认-标识】下。<br>
631
- 2、日期:放在【默认-日期】下。<br>
632
- 3、字符串、数字:放在【默认-常用】下。<br>
633
- 注意:只要是比较通用的字段,都应该放在【默认】的分类下。<br>
634
- <b>二、特殊字段:</b><br>
635
- 1、字段是业务模块特有的,放在【业务】下的模块。如:固定资产编码fd_asset_type_code,应该放在固定资产下。<br>
636
- `
637
- this.$alert(msg, '字段规范说明', { dangerouslyUseHTMLString: true })
638
- }
639
- }
446
+ .operate /deep/ .el-checkbox__label {
447
+ display: none;
640
448
  }
641
- </script>
642
449
 
643
- <style scoped>
450
+ .new-table:hover {
451
+ cursor: pointer;
452
+ }
453
+
454
+ .sql-str /deep/ .el-textarea__inner {
455
+ width: 100%;
456
+ height: 100%;
457
+ }
458
+ </style>
459
+ <style>
460
+ .left-7 {
461
+ margin-left: 7px;
462
+ }
463
+
464
+ .dev-table-comment {
465
+ font-size: 13px;
466
+ margin-left: 10px;
467
+ }
644
468
  </style>