@longhongguo/form-create-ant-design-vue 3.3.15 → 3.3.17

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longhongguo/form-create-ant-design-vue",
3
- "version": "3.3.15",
3
+ "version": "3.3.17",
4
4
  "description": "AntDesignVue版本低代码表单|FormCreate 是一个可以通过 JSON 生成具有动态渲染、数据收集、验证和提交功能的低代码表单生成组件。支持6个UI框架,适配移动端,并且支持生成任何 Vue 组件。内置20种常用表单组件和自定义组件,再复杂的表单都可以轻松搞定。",
5
5
  "main": "./dist/form-create.min.js",
6
6
  "module": "./dist/form-create.esm.js",
@@ -61,7 +61,23 @@ export default {
61
61
  },
62
62
  min: Number,
63
63
  max: Number,
64
- disabled: Boolean
64
+ disabled: Boolean,
65
+ showIndexColumn: {
66
+ type: Boolean,
67
+ default: true
68
+ },
69
+ showOperationColumn: {
70
+ type: Boolean,
71
+ default: true
72
+ },
73
+ headerBackgroundColor: {
74
+ type: String,
75
+ default: ''
76
+ },
77
+ emptyText: {
78
+ type: String,
79
+ default: ''
80
+ }
65
81
  },
66
82
  watch: {
67
83
  modelValue: {
@@ -71,8 +87,21 @@ export default {
71
87
  deep: true
72
88
  },
73
89
  'formCreateInject.preview': function (n) {
74
- this.emptyRule.children[0].props.colspan =
75
- this.columns.length + (n ? 1 : 2)
90
+ this.emptyRule.children[0].props.colspan = this.getEmptyColspan()
91
+ },
92
+ showIndexColumn() {
93
+ this.loadRule()
94
+ this.updateTable()
95
+ },
96
+ showOperationColumn() {
97
+ this.loadRule()
98
+ this.updateTable()
99
+ },
100
+ headerBackgroundColor() {
101
+ this.loadRule()
102
+ },
103
+ emptyText() {
104
+ this.updateEmptyRule()
76
105
  }
77
106
  },
78
107
  data() {
@@ -97,16 +126,26 @@ export default {
97
126
  native: true,
98
127
  subRule: true,
99
128
  props: {
100
- colspan:
101
- this.columns.length + (this.formCreateInject.preview ? 1 : 2)
129
+ colspan: this.getEmptyColspan()
102
130
  },
103
- children: [this.formCreateInject.t('dataEmpty') || '暂无数据']
131
+ children: [
132
+ this.emptyText ||
133
+ this.formCreateInject.t('dataEmpty') ||
134
+ '暂无数据'
135
+ ]
104
136
  }
105
137
  ]
106
138
  }
107
139
  }
108
140
  },
109
141
  methods: {
142
+ getEmptyColspan() {
143
+ return (
144
+ this.columns.length +
145
+ (this.showIndexColumn ? 1 : 0) +
146
+ (this.showOperationColumn ? (this.formCreateInject.preview ? 0 : 1) : 0)
147
+ )
148
+ },
110
149
  formChange() {
111
150
  this.updateValue()
112
151
  },
@@ -162,10 +201,32 @@ export default {
162
201
  })
163
202
  this.rule[0].children[1].children = this.trs
164
203
  },
204
+ updateEmptyRule() {
205
+ const emptyTextValue =
206
+ this.emptyText || this.formCreateInject.t('dataEmpty') || '暂无数据'
207
+ if (
208
+ this.emptyRule &&
209
+ this.emptyRule.children &&
210
+ this.emptyRule.children[0]
211
+ ) {
212
+ this.emptyRule.children[0].children = [emptyTextValue]
213
+ }
214
+ // 更新已经显示的空数据行
215
+ this.trs.forEach((tr) => {
216
+ if (tr._isEmpty && tr.children && tr.children[0]) {
217
+ tr.children[0].children = [emptyTextValue]
218
+ }
219
+ })
220
+ // 更新规则中的空数据行
221
+ if (this.rule[0] && this.rule[0].children && this.rule[0].children[1]) {
222
+ this.rule[0].children[1].children = this.trs
223
+ }
224
+ },
165
225
  addEmpty() {
166
226
  if (this.trs.length) {
167
227
  this.trs.splice(0, this.trs.length)
168
228
  }
229
+ this.updateEmptyRule()
169
230
  this.trs.push(this.emptyRule)
170
231
  },
171
232
  clearEmpty() {
@@ -207,39 +268,62 @@ export default {
207
268
  },
208
269
  updateRaw(tr) {
209
270
  const idx = this.trs.indexOf(tr)
210
- tr.children[0].props.innerText = idx + 1
211
- tr.children[tr.children.length - 1].children[0].props.onClick = () => {
212
- this.delRaw(idx)
271
+ // 更新序号列
272
+ if (this.showIndexColumn && tr.children[0]) {
273
+ tr.children[0].props.innerText = idx + 1
274
+ }
275
+ // 更新操作列的删除按钮
276
+ if (this.showOperationColumn && tr.children[tr.children.length - 1]) {
277
+ const operationCell = tr.children[tr.children.length - 1]
278
+ if (operationCell.children && operationCell.children[0]) {
279
+ operationCell.children[0].props.onClick = () => {
280
+ this.delRaw(idx)
281
+ }
282
+ }
213
283
  }
214
284
  },
215
285
  loadRule() {
216
- const header = [
217
- {
286
+ const header = []
287
+ let body = []
288
+
289
+ // 序号列
290
+ if (this.showIndexColumn) {
291
+ header.push({
218
292
  type: 'th',
219
293
  native: true,
220
294
  class: '_fc-tf-head-idx',
295
+ style: this.headerBackgroundColor
296
+ ? {
297
+ backgroundColor: this.headerBackgroundColor
298
+ }
299
+ : {},
221
300
  props: {
222
301
  innerText: '#'
223
302
  }
224
- }
225
- ]
226
- let body = [
227
- {
303
+ })
304
+ body.push({
228
305
  type: 'td',
229
306
  class: '_fc-tf-idx',
230
307
  native: true,
231
308
  props: {
232
309
  innerText: '0'
233
310
  }
234
- }
235
- ]
311
+ })
312
+ }
313
+
314
+ // 数据列
236
315
  this.columns.forEach((column) => {
237
316
  header.push({
238
317
  type: 'th',
239
318
  native: true,
240
319
  style: {
241
320
  ...(column.style || {}),
242
- textAlign: column.align || 'center'
321
+ textAlign: column.align || 'center',
322
+ ...(this.headerBackgroundColor
323
+ ? {
324
+ backgroundColor: this.headerBackgroundColor
325
+ }
326
+ : {})
243
327
  },
244
328
  class: column.required ? '_fc-tf-head-required' : '',
245
329
  props: {
@@ -252,27 +336,36 @@ export default {
252
336
  children: [...(column.rule || [])]
253
337
  })
254
338
  })
255
- header.push({
256
- type: 'th',
257
- native: true,
258
- class: '_fc-tf-edit fc-clock',
259
- props: {
260
- innerText: this.formCreateInject.t('operation') || '操作'
261
- }
262
- })
263
- body.push({
264
- type: 'td',
265
- native: true,
266
- class: '_fc-tf-btn fc-clock',
267
- children: [
268
- {
269
- type: 'i',
270
- native: true,
271
- class: 'fc-icon icon-delete',
272
- props: {}
339
+
340
+ // 操作列
341
+ if (this.showOperationColumn) {
342
+ header.push({
343
+ type: 'th',
344
+ native: true,
345
+ class: '_fc-tf-edit fc-clock',
346
+ style: this.headerBackgroundColor
347
+ ? {
348
+ backgroundColor: this.headerBackgroundColor
349
+ }
350
+ : {},
351
+ props: {
352
+ innerText: this.formCreateInject.t('operation') || '操作'
273
353
  }
274
- ]
275
- })
354
+ })
355
+ body.push({
356
+ type: 'td',
357
+ native: true,
358
+ class: '_fc-tf-btn fc-clock',
359
+ children: [
360
+ {
361
+ type: 'i',
362
+ native: true,
363
+ class: 'fc-icon icon-delete',
364
+ props: {}
365
+ }
366
+ ]
367
+ })
368
+ }
276
369
  this.copyTrs = this.formCreateInject.form.toJson([
277
370
  {
278
371
  type: 'tr',