ap-dev 1.2.26 → 1.2.28

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,631 +1,641 @@
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-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
+ <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>
64
64
 
65
65
 
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">
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">
72
72
 
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>
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>
84
84
 
85
- <el-form-item label="类别名称" prop="fdName">
86
- <el-input v-model="dialogForm.fdName" />
87
- </el-form-item>
85
+ <el-form-item label="类别名称" prop="fdName">
86
+ <el-input v-model="dialogForm.fdName"/>
87
+ </el-form-item>
88
88
 
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>
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>
93
93
 
94
94
 
95
- <span slot="footer" class="dialog-footer">
95
+ <span slot="footer" class="dialog-footer">
96
96
  <el-button @click="dialogVisible = false">取 消</el-button>
97
97
  <el-button type="primary" @click="saveTable">确 定</el-button>
98
98
  </span>
99
- </el-dialog>
100
- </ap-container>
99
+ </el-dialog>
100
+ </ap-container>
101
101
  </template>
102
102
 
103
103
  <script>
104
- import { convertToArrayData, convertToTreeData } from 'ap-util/util/DataUtil'
104
+ import {convertToArrayData, convertToTreeData} from 'ap-util/util/DataUtil'
105
105
 
106
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
- },
234
- {
235
- btnType: 'primary',
236
- text: '下移',
237
- icon: 'el-icon-bottom',
238
- onClick: () => {
239
- this.sortAfter()
240
- }
241
- },
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
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(6.5万)', value: 'text'},
158
+ {label: 'mediumtext(1600万)', value: 'mediumtext'},
159
+ {label: 'longtext(极长)', value: 'longtext'},
160
+ ]
161
+ },
162
+ {
163
+ label: '整型数值',
164
+ options: [
165
+ {label: 'tinyint(255)', value: 'tinyint'},
166
+ {label: 'smallint(6.5万)', value: 'smallint'},
167
+ {label: 'mediumint(1.6千万)', value: 'mediumint'},
168
+ {label: 'int(4.2亿)', value: 'int'},
169
+ {label: 'bigint(极大)', value: 'bigint'}
170
+ ]
171
+ },
172
+ {
173
+ label: '浮点数值',
174
+ options: [
175
+ {label: 'float(单精度)', value: 'float'},
176
+ {label: 'double(双精度)', value: 'double'},
177
+ {label: 'decimal(小数值)', value: 'decimal'}
178
+ ]
179
+ },
180
+ {
181
+ label: '日期时间',
182
+ options: [
183
+ {label: 'date(年月日)', value: 'date'},
184
+ {label: 'time(时分秒)', value: 'time'},
185
+ {label: 'year()', value: 'year'},
186
+ {label: 'datetime(年月日时分秒)', value: 'datetime'},
187
+ {label: 'timestamp(时间戳)', value: 'timestamp'}
188
+ ]
189
+ },
190
+ {
191
+ label: '二进制:图片/文件',
192
+ options: [
193
+ {label: 'blob(6.5万)', value: 'blob'},
194
+ {label: 'mediumblob(1600万)', value: 'mediumblob'},
195
+ {label: 'longblob(极长)', value: 'longblob'},
196
+ ]
197
+ }
198
+ ],
199
+ selectFilterable: true,
200
+ selectIsGroup: true,
201
+ selectPlaceholder: '选择数据类型',
202
+ rules: [
203
+ {required: true, message: '数据类型必选'}
204
+ ]
205
+ }, {
206
+ prop: 'fdSort',
207
+ label: '排序',
208
+ type: 'inputNumber',
209
+ inputNumberMin: 0,
210
+ // inputNumberMax: 10,
211
+ sortable: true,
212
+ rules: [
213
+ {required: true, message: '请输入排序'}
214
+ ],
215
+ addDefaultValue: 0
216
+ }, {
217
+ prop: 'fdDeleted',
218
+ label: '删除',
219
+ type: 'input',
220
+ hide: true,
221
+ addDefaultValue: 0
222
+ }]
223
+ const tableOpt = {
224
+ title: '字段列表',
225
+ columns: columns,
226
+ pagination: {
227
+ pageSizes: [30, 60, 90],
228
+ pageSize: 30
229
+ },
230
+ dataUrl: '/apd/db/DevDbField/getTDevDbFieldGridList',
231
+ saveUrl: '/apd/db/DevDbField/saveTDevDbFieldGridData',
232
+ editPk: 'fdId',
233
+ deletePk: 'fdId',
234
+ deleteUrl: '/apd/db/DevDbField/deleteTDevDbFieldByFdId',
235
+ toolbarBtn: ['add', 'edit', 'del', 'cancel', 'refresh', 'save', 'separator',
236
+ {
237
+ btnType: 'primary',
238
+ text: '上移',
239
+ icon: 'el-icon-top',
240
+ onClick: () => {
241
+ this.sortBefore()
242
+ }
243
+ },
244
+ {
245
+ btnType: 'primary',
246
+ text: '下移',
247
+ icon: 'el-icon-bottom',
248
+ onClick: () => {
249
+ this.sortAfter()
250
+ }
251
+ },
252
+ {
253
+ btnType: 'primary',
254
+ text: '一键排序',
255
+ icon: 'el-icon-s-operation',
256
+ onClick: () => {
257
+ this.doSortByIndex()
258
+ }
259
+ }, , {
260
+ btnType: 'info',
261
+ text: '帮助',
262
+ icon: 'el-icon-question',
263
+ onClick: () => {
264
+ this.openHelp()
265
+ }
266
+ }],
267
+ initData: false,
268
+ beforeAdd: this.beforeAddFn,
269
+ params: () => {
270
+ return {
271
+ fdFieldTypeIds: this.selectedFieldTypeIds,
272
+ likeStr: this.searchForm.likeStr
273
+ }
274
+ }
263
275
  }
264
- }
265
- }
266
276
 
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
- }
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
- }
277
+ return {
278
+ // ----- 左侧树 -----
279
+ loadingTreeFlag: false,
280
+ filterText: '',
281
+ typeTreeList: [],
282
+ defaultProps: {
283
+ children: 'children',
284
+ label: 'fdName'
285
+ },
286
+ selectedFieldTypeIds: '',
287
+ // ----- dialog -----
288
+ typeList: [],
289
+ dialogVisible: false,
290
+ dialogTitle: '', // dialog标题
291
+ isAddDialog: true, // 添加类型dialog
292
+ dialogForm: {
293
+ fdName: '',
294
+ fdParentId: '',
295
+ fdId: '',
296
+ fdSort: undefined
297
+ },
298
+ dialogFormRules: {
299
+ fdSort: [
300
+ {type: 'number', message: '请输入数字', trigger: 'change'}
301
+ ],
302
+ fdName: [
303
+ {required: true, message: '请输入类型名称', trigger: 'blur'},
304
+ {min: 1, max: 10, message: '长度在 1 到 10 个字符', trigger: 'blur'}
305
+ ]
306
+ },
307
+ // ----- 表格 -----
308
+ searchForm: {
309
+ listStr: ''
310
+ },
311
+ tableOpt: tableOpt
312
+ }
356
313
  },
357
- getCurrentNode() {
358
- return this.$refs.typeTree.getCurrentNode() || {}
314
+ watch: {
315
+ filterText(val) {
316
+ this.$refs.typeTree.filter(val)
317
+ }
359
318
  },
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
319
+ created() {
320
+ this.loadTreeData()
367
321
  },
368
- // dialog:编辑数据
369
- editTable() {
370
- const currentNodeFdId = this.getCurrentNode().fdId
371
- if (!currentNodeFdId) {
372
- this.$message.error('请选择需要编辑的数据!')
373
- return
374
- }
322
+ methods: {
323
+ // 左侧树:加载数据
324
+ loadTreeData() {
325
+ this.loadingTreeFlag = true
326
+ this.$request({
327
+ url: '/apd/db/DevDbField/getDbFieldTypeList',
328
+ method: 'post'
329
+ }).then(response => {
330
+ this.typeList = JSON.parse(JSON.stringify(response.data))
331
+ this.typeTreeList = convertToTreeData(response.data, {
332
+ idKey: 'fdId',
333
+ parentKey: 'fdParentId',
334
+ childrenKey: 'children'
335
+ })
336
+ }).finally(() => {
337
+ this.loadingTreeFlag = false
338
+ })
339
+ },
340
+ // 左侧树:初始化数据
341
+ initTreeData() {
342
+ // 重置当前选择节点
343
+ this.$refs.typeTree.setCurrentKey()
344
+ this.loadTreeData()
345
+ },
346
+ // 左侧树:过滤节点
347
+ filterNode(value, data) {
348
+ if (!value) return true
349
+ return data.fdName.indexOf(value) !== -1
350
+ },
351
+ // 选择勾选事件
352
+ nodeClickEvent(data, node, comp) {
353
+ const parentKeys = this.$refs.typeTree.getHalfCheckedKeys()
354
+ const selectKeys = this.$refs.typeTree.getCheckedKeys(false)
355
+ this.selectedFieldTypeIds = parentKeys.concat(selectKeys).join(',')
356
+ this.$refs.devDbFieldGrid.refresh()
357
+ },
358
+ // dialog:重置表单
359
+ resetDialogForm() {
360
+ this.dialogForm = {
361
+ fdName: '',
362
+ fdParentId: '',
363
+ fdId: '',
364
+ fdSort: null
365
+ }
366
+ },
367
+ getCurrentNode() {
368
+ return this.$refs.typeTree.getCurrentNode() || {}
369
+ },
370
+ // dialog:添加数据
371
+ addTable() {
372
+ this.resetDialogForm()
373
+ this.dialogVisible = true
374
+ this.dialogTitle = '添加字段类型'
375
+ this.isAddDialog = true
376
+ this.dialogForm.fdParentId = this.getCurrentNode().fdId
377
+ },
378
+ // dialog:编辑数据
379
+ editTable() {
380
+ const currentNodeFdId = this.getCurrentNode().fdId
381
+ if (!currentNodeFdId) {
382
+ this.$message.error('请选择需要编辑的数据!')
383
+ return
384
+ }
375
385
 
376
- this.resetDialogForm()
377
- this.dialogVisible = true
378
- this.dialogTitle = '编辑字段类型'
379
- this.isAddDialog = false
380
- this.dialogForm.fdId = currentNodeFdId
386
+ this.resetDialogForm()
387
+ this.dialogVisible = true
388
+ this.dialogTitle = '编辑字段类型'
389
+ this.isAddDialog = false
390
+ this.dialogForm.fdId = currentNodeFdId
381
391
 
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
- }
392
+ this.$request({
393
+ url: '/apd/db/DevDbField/getDbFieldTypeByFdId',
394
+ method: 'post',
395
+ data: {
396
+ fdId: currentNodeFdId
397
+ }
398
+ }).then(response => {
399
+ this.dialogForm.fdId = response.data.fdId
400
+ this.dialogForm.fdName = response.data.fdName
401
+ this.dialogForm.fdParentId = response.data.fdParentId
402
+ this.dialogForm.fdSort = response.data.fdSort
403
+ })
404
+ },
405
+ // 删除类型数据
406
+ deleteTable() {
407
+ const currentNode = this.getCurrentNode()
408
+ const currentNodeFdId = currentNode.fdId
409
+ if (!currentNodeFdId) {
410
+ this.$message.error('请选择需要删除的数据!')
411
+ return
412
+ }
403
413
 
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
- }
414
+ this.$confirm(`确定要删除【${currentNode.fdName}】?`, '提示', {
415
+ confirmButtonText: '确定',
416
+ cancelButtonText: '取消',
417
+ type: 'warning'
418
+ }).then(() => {
419
+ this.$request({
420
+ url: '/apd/db/DevDbField/deleteDbFieldType',
421
+ method: 'post',
422
+ data: {
423
+ fdId: currentNodeFdId
424
+ }
425
+ }).then(response => {
426
+ this.$message.success(`删除成功!已删除${response.data}条数据!`)
427
+ this.initTreeData()
428
+ })
429
+ })
430
+ },
431
+ checkTypeSort() {
432
+ const currentNode = this.getCurrentNode()
433
+ if (currentNode == null) {
434
+ this.$message.error(`请选择需要操作的节点!`)
435
+ return null
436
+ }
437
+ return currentNode
438
+ },
439
+ // 修改排序
440
+ doTypeSortChange(rowFdId, rowFdSort, exchangeRowFdId, exchangeRowFdSort) {
441
+ this.$request({
442
+ url: '/apd/db/DevDbField/updateDbFieldTypeSort',
443
+ method: 'post',
444
+ data: {rowFdId, rowFdSort, exchangeRowFdId, exchangeRowFdSort}
445
+ }).then(response => {
446
+ this.$message.success(`修改成功!`)
447
+ this.$refs.popoverRef.doClose()
448
+ this.loadTreeData()
449
+ })
450
+ },
451
+ // 排序调整:向上
452
+ sortTypeBefore() {
453
+ const currentNode = this.checkTypeSort()
454
+ if (currentNode == null) {
455
+ return
456
+ }
447
457
 
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
- }
458
+ const arrayData = convertToArrayData(this.typeTreeList)
459
+ let currentNodeIndex = 0
460
+ for (let i = 0; i < arrayData.length; i++) {
461
+ if (arrayData[i].fdId == currentNode.fdId) {
462
+ currentNodeIndex = i
463
+ break
464
+ }
465
+ }
466
+ if (currentNodeIndex == 0) {
467
+ this.$message.success(`已经是第一个啦!`)
468
+ return
469
+ }
460
470
 
461
- const exchangeRow = arrayData[currentNodeIndex - 1]
471
+ const exchangeRow = arrayData[currentNodeIndex - 1]
462
472
 
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
- }
473
+ this.doTypeSortChange(currentNode.fdId, exchangeRow.fdSort, exchangeRow.fdId, currentNode.fdSort)
474
+ },
475
+ // 排序调整:向下
476
+ sortTypeAfter() {
477
+ const currentNode = this.checkTypeSort()
478
+ if (currentNode == null) {
479
+ return
480
+ }
481
+ const arrayData = convertToArrayData(this.typeTreeList)
482
+ let currentNodeIndex = 0
483
+ for (let i = 0; i < arrayData.length; i++) {
484
+ if (arrayData[i].fdId == currentNode.fdId) {
485
+ currentNodeIndex = i
486
+ break
487
+ }
488
+ }
479
489
 
480
- if (currentNodeIndex == arrayData.length - 1) {
481
- this.$message.success(`字段已经是最后一个啦!`)
482
- return
483
- }
490
+ if (currentNodeIndex == arrayData.length - 1) {
491
+ this.$message.success(`字段已经是最后一个啦!`)
492
+ return
493
+ }
484
494
 
485
- const exchangeRow = arrayData[currentNodeIndex + 1]
495
+ const exchangeRow = arrayData[currentNodeIndex + 1]
486
496
 
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
- }
497
+ this.doTypeSortChange(currentNode.fdId, exchangeRow.fdSort, exchangeRow.fdId, currentNode.fdSort)
498
+ },
499
+ // 一键排序
500
+ sortTypeByIndex() {
501
+ const arrayData = convertToArrayData(this.typeTreeList)
502
+ const list = []
503
+ for (let i = 0; i < arrayData.length; i++) {
504
+ list.push({
505
+ fdId: arrayData[i].fdId,
506
+ fdSort: i + 1
507
+ })
508
+ }
509
+ this.$request({
510
+ url: '/apd/db/DevDbField/updateDbFieldTypeSortList',
511
+ method: 'post',
512
+ data: {list: JSON.stringify(list)}
513
+ }).then(response => {
514
+ this.$message.success(`排序成功!`)
515
+ this.$refs.popoverRef.doClose()
516
+ this.loadTreeData()
517
+ })
518
+ },
519
+ // dialog:保存类型数据
520
+ saveTable() {
521
+ this.$refs.dialogForm.validate((valid) => {
522
+ if (!valid) {
523
+ this.$message.error(`数据校验失败,请重新填写信息!`)
524
+ return false
525
+ }
526
+ if (this.isAddDialog) {
527
+ // 添加数据
528
+ this.$request({
529
+ url: '/apd/db/DevDbField/insertDbFieldType',
530
+ method: 'post',
531
+ data: this.dialogForm
532
+ }).then(response => {
533
+ this.$message.success(`添加成功!已添加${response.data}条数据!`)
534
+ this.dialogVisible = false
535
+ this.initTreeData()
536
+ })
537
+ } else {
538
+ // 更新数据
539
+ this.$request({
540
+ url: '/apd/db/DevDbField/updateDbFieldType',
541
+ method: 'post',
542
+ data: this.dialogForm
543
+ }).then(response => {
544
+ this.$message.success(`更新成功!已更新${response.data}条数据!`)
545
+ this.dialogVisible = false
546
+ this.initTreeData()
547
+ })
548
+ }
549
+ })
550
+ },
551
+ // 添加行:数据类型默认值
552
+ beforeAddFn() {
553
+ const fdFieldTypeIds = this.selectedFieldTypeIds
554
+ if (fdFieldTypeIds == null || fdFieldTypeIds == '') {
555
+ this.$message.error(`请先选择字段类型!`)
556
+ return false
557
+ }
558
+ return true
559
+ },
560
+ addDefaultValueFn() {
561
+ return this.getCurrentNode().fdId
562
+ },
563
+ checkSort() {
564
+ const selection = this.$refs.devDbFieldGrid.getSelection()
565
+ if (selection.length == 0) {
566
+ this.$message.error(`请选择需要操作的行!`)
567
+ return null
568
+ } else if (selection.length > 1) {
569
+ this.$message.error(`只能选择一行!`)
570
+ return null
571
+ }
572
+ return selection[0]
573
+ },
574
+ // 修改排序
575
+ doSortChange(rowFdId, rowFdSort, exchangeRowFdId, exchangeRowFdSort) {
576
+ this.$request({
577
+ url: '/apd/db/DevDbField/updateDbFieldSort',
578
+ method: 'post',
579
+ data: {rowFdId, rowFdSort, exchangeRowFdId, exchangeRowFdSort}
580
+ }).then(response => {
581
+ this.$message.success(`修改成功!`)
582
+ this.$refs.devDbFieldGrid.refresh()
583
+ })
584
+ },
585
+ // 排序调整:向上
586
+ sortBefore() {
587
+ const rowData = this.checkSort()
588
+ if (rowData == null) {
589
+ return
590
+ }
591
+ const dataIdx = rowData.dataIdx
592
+ if (dataIdx == 1) {
593
+ this.$message.success(`字段已经是第一个啦!`)
594
+ return
595
+ }
586
596
 
587
- const exchangeRow = this.tableOpt.data[dataIdx - 2]
597
+ const exchangeRow = this.tableOpt.data[dataIdx - 2]
588
598
 
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]
599
+ this.doSortChange(rowData.fdId, exchangeRow.fdSort, exchangeRow.fdId, rowData.fdSort)
600
+ },
601
+ // 排序调整:向下
602
+ sortAfter() {
603
+ const rowData = this.checkSort()
604
+ if (rowData == null) {
605
+ return
606
+ }
607
+ const dataIdx = rowData.dataIdx
608
+ if (dataIdx >= this.tableOpt.data.length) {
609
+ this.$message.success(`字段已经是最后一个啦!`)
610
+ return
611
+ }
612
+ const exchangeRow = this.tableOpt.data[dataIdx]
603
613
 
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 = `
614
+ this.doSortChange(rowData.fdId, exchangeRow.fdSort, exchangeRow.fdId, rowData.fdSort)
615
+ },
616
+ doSortByIndex() {
617
+ const data = this.$refs.devDbFieldGrid.getData()
618
+ const list = []
619
+ for (let i = 0; i < data.length; i++) {
620
+ list.push({
621
+ fdId: data[i].fdId,
622
+ fdSort: data[i].dataIdx
623
+ })
624
+ }
625
+ this.$request({
626
+ url: '/apd/db/DevDbField/updateDbFieldSortList',
627
+ method: 'post',
628
+ data: {list: JSON.stringify(list)}
629
+ }).then(response => {
630
+ this.$message.success(`排序成功!`)
631
+ this.$refs.devDbFieldGrid.refresh()
632
+ })
633
+ },
634
+ searchEvent() {
635
+ this.$refs.devDbFieldGrid.refresh()
636
+ },
637
+ openHelp() {
638
+ const msg = `
629
639
  <b>一、通用字段:</b><br>
630
640
  1、标识类型(0、1):放在【默认-标识】下。<br>
631
641
  2、日期:放在【默认-日期】下。<br>
@@ -634,9 +644,9 @@ export default {
634
644
  <b>二、特殊字段:</b><br>
635
645
  1、字段是业务模块特有的,放在【业务】下的模块。如:固定资产编码fd_asset_type_code,应该放在固定资产下。<br>
636
646
  `
637
- this.$alert(msg, '字段规范说明', { dangerouslyUseHTMLString: true })
647
+ this.$alert(msg, '字段规范说明', {dangerouslyUseHTMLString: true})
648
+ }
638
649
  }
639
- }
640
650
  }
641
651
  </script>
642
652