@longhongguo/form-create-ant-design-vue 3.2.49 → 3.2.51

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.2.49",
3
+ "version": "3.2.51",
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",
@@ -94,6 +94,15 @@ export default defineComponent({
94
94
  bordered: {
95
95
  type: Boolean,
96
96
  default: true
97
+ },
98
+ // 额外查询参数
99
+ extraQuery: {
100
+ type: Object,
101
+ default: () => ({})
102
+ },
103
+ extraQueryFn: {
104
+ type: Function,
105
+ default: () => {}
97
106
  }
98
107
  },
99
108
  emits: ['update:modelValue', 'change'],
@@ -227,6 +236,12 @@ export default defineComponent({
227
236
  : this.serializeForPostMessage(valueToSend)
228
237
 
229
238
  // 发送消息给父窗口,请求打开门店选择弹窗
239
+ const extraQuery = {
240
+ ...this.extraQuery
241
+ }
242
+ if (this.extraQueryFn) {
243
+ Object.assign(extraQuery, this.extraQueryFn())
244
+ }
230
245
  const message = {
231
246
  type: 'OPEN_STORE_SELECT',
232
247
  field: this.field || '',
@@ -234,6 +249,7 @@ export default defineComponent({
234
249
  currentValue: serializedCurrentValue,
235
250
  valueKey: this.valueKey,
236
251
  labelKey: this.labelKey,
252
+ extraQuery,
237
253
  messageId: msgId
238
254
  }
239
255
 
@@ -98,6 +98,14 @@ export default defineComponent({
98
98
  selectType: {
99
99
  type: [String, Number],
100
100
  default: null
101
+ },
102
+ extraQuery: {
103
+ type: Object,
104
+ default: () => ({})
105
+ },
106
+ extraQueryFn: {
107
+ type: Function,
108
+ default: () => {}
101
109
  }
102
110
  },
103
111
  emits: ['update:modelValue', 'change'],
@@ -231,6 +239,13 @@ export default defineComponent({
231
239
  : this.serializeForPostMessage(valueToSend)
232
240
 
233
241
  // 发送消息给父窗口,请求打开用户选择弹窗
242
+ const extraQuery = {
243
+ ...this.extraQuery
244
+ }
245
+ if (this.extraQueryFn) {
246
+ Object.assign(extraQuery, this.extraQueryFn())
247
+ }
248
+
234
249
  const message = {
235
250
  type: 'OPEN_USER_SELECT',
236
251
  field: this.field || '',
@@ -239,6 +254,7 @@ export default defineComponent({
239
254
  valueKey: this.valueKey,
240
255
  labelKey: this.labelKey,
241
256
  selectType: this.selectType,
257
+ extraQuery,
242
258
  messageId: msgId
243
259
  }
244
260
 
@@ -6,6 +6,9 @@ import QuestionCircleOutlined from './icon/QuestionCircleOutlined.vue'
6
6
  import CusSelect from './CusSelect/index.vue'
7
7
  import CusStoreSelect from './CusStoreSelect/index.vue'
8
8
  import CusUserSelect from './CusUserSelect/index.vue'
9
+ import TableForm from './tableForm/TableForm.vue'
10
+ import TableFormView from './tableForm/TableFormView.vue'
11
+ import TableFormColumnView from './tableForm/TableFormColumnView.vue'
9
12
 
10
13
  export default [
11
14
  upload,
@@ -15,5 +18,8 @@ export default [
15
18
  QuestionCircleOutlined,
16
19
  CusSelect,
17
20
  CusStoreSelect,
18
- CusUserSelect
21
+ CusUserSelect,
22
+ TableForm,
23
+ TableFormView,
24
+ TableFormColumnView
19
25
  ]
@@ -0,0 +1,323 @@
1
+ <template>
2
+ <div class="_fc-table-form" :class="{ '_fc-disabled': disabled }">
3
+ <component
4
+ :is="Form"
5
+ :option="options"
6
+ :rule="rule"
7
+ :extendOption="true"
8
+ :disabled="disabled"
9
+ @change="formChange"
10
+ v-model:api="fapi"
11
+ @emit-event="$emit"
12
+ ></component>
13
+ <a-button
14
+ type="link"
15
+ class="fc-clock"
16
+ v-if="addable && (!max || max > this.trs.length)"
17
+ @click="addRaw(true)"
18
+ :disabled="disabled"
19
+ ><i class="fc-icon icon-add-circle" style="font-weight: 700"></i>
20
+ {{ formCreateInject.t('add') || '添加' }}
21
+ </a-button>
22
+ </div>
23
+ </template>
24
+
25
+ <script>
26
+ import { markRaw, reactive } from 'vue'
27
+
28
+ export default {
29
+ name: 'TableForm',
30
+ emits: ['change', 'add', 'delete', 'update:modelValue'],
31
+ props: {
32
+ formCreateInject: Object,
33
+ modelValue: {
34
+ type: Array,
35
+ default: () => []
36
+ },
37
+ columns: {
38
+ type: Array,
39
+ required: true,
40
+ default: () => []
41
+ },
42
+ filterEmptyColumn: {
43
+ type: Boolean,
44
+ default: true
45
+ },
46
+ deletable: {
47
+ type: Boolean,
48
+ default: true
49
+ },
50
+ addable: {
51
+ type: Boolean,
52
+ default: true
53
+ },
54
+ options: {
55
+ type: Object,
56
+ default: () =>
57
+ reactive({
58
+ submitBtn: false,
59
+ resetBtn: false
60
+ })
61
+ },
62
+ min: Number,
63
+ max: Number,
64
+ disabled: Boolean
65
+ },
66
+ watch: {
67
+ modelValue: {
68
+ handler() {
69
+ this.updateTable()
70
+ },
71
+ deep: true
72
+ },
73
+ 'formCreateInject.preview': function (n) {
74
+ this.emptyRule.children[0].props.colspan =
75
+ this.columns.length + (n ? 1 : 2)
76
+ }
77
+ },
78
+ data() {
79
+ return {
80
+ rule: [],
81
+ trs: [],
82
+ fapi: {},
83
+ Form: markRaw(this.formCreateInject.form.$form()),
84
+ copyTrs: '',
85
+ oldValue: '',
86
+ emptyRule: {
87
+ type: 'tr',
88
+ _isEmpty: true,
89
+ native: true,
90
+ subRule: true,
91
+ children: [
92
+ {
93
+ type: 'td',
94
+ style: {
95
+ textAlign: 'center'
96
+ },
97
+ native: true,
98
+ subRule: true,
99
+ props: {
100
+ colspan:
101
+ this.columns.length + (this.formCreateInject.preview ? 1 : 2)
102
+ },
103
+ children: [this.formCreateInject.t('dataEmpty') || '暂无数据']
104
+ }
105
+ ]
106
+ }
107
+ }
108
+ },
109
+ methods: {
110
+ formChange() {
111
+ this.updateValue()
112
+ },
113
+ updateValue() {
114
+ const value = this.trs
115
+ .map((tr, idx) => {
116
+ return {
117
+ ...(this.modelValue[idx] || {}),
118
+ ...this.fapi.getChildrenFormData(tr)
119
+ }
120
+ })
121
+ .filter((v) => {
122
+ if (!this.filterEmptyColumn) {
123
+ return true
124
+ }
125
+ if (v === undefined || v === null) {
126
+ return false
127
+ }
128
+ let flag = false
129
+ Object.keys(v).forEach((k) => {
130
+ flag = flag || (v[k] !== undefined && v[k] !== '' && v[k] !== null)
131
+ })
132
+ return flag
133
+ })
134
+ const str = JSON.stringify(value)
135
+ if (str !== this.oldValue) {
136
+ this.oldValue = str
137
+ this.$emit('update:modelValue', value)
138
+ this.$emit('change', value)
139
+ }
140
+ },
141
+ setRawData(idx, formData) {
142
+ const raw = this.trs[idx]
143
+ this.fapi.setChildrenFormData(raw, formData, true)
144
+ },
145
+ updateTable() {
146
+ const str = JSON.stringify(this.modelValue)
147
+ if (this.oldValue === str) {
148
+ return
149
+ }
150
+ this.oldValue = str
151
+ this.trs = this.trs.splice(0, this.modelValue.length)
152
+ if (!this.modelValue.length) {
153
+ this.addEmpty()
154
+ } else {
155
+ this.clearEmpty()
156
+ }
157
+ this.modelValue.forEach((data, idx) => {
158
+ if (!this.trs[idx]) {
159
+ this.addRaw()
160
+ }
161
+ this.setRawData(idx, data || {})
162
+ })
163
+ this.rule[0].children[1].children = this.trs
164
+ },
165
+ addEmpty() {
166
+ if (this.trs.length) {
167
+ this.trs.splice(0, this.trs.length)
168
+ }
169
+ this.trs.push(this.emptyRule)
170
+ },
171
+ clearEmpty() {
172
+ if (this.trs[0] && this.trs[0]._isEmpty) {
173
+ this.trs.splice(0, 1)
174
+ }
175
+ },
176
+ delRaw(idx) {
177
+ if (
178
+ this.disabled ||
179
+ !this.deletable ||
180
+ (this.min > 0 && this.trs.length <= this.min)
181
+ ) {
182
+ return
183
+ }
184
+ this.trs.splice(idx, 1)
185
+ this.updateValue()
186
+ if (this.trs.length) {
187
+ this.trs.forEach((tr) => this.updateRaw(tr))
188
+ } else {
189
+ this.addEmpty()
190
+ }
191
+ this.$emit('delete', idx)
192
+ },
193
+ addRaw(flag) {
194
+ if (flag && this.disabled) {
195
+ return
196
+ }
197
+ const tr = this.formCreateInject.form.parseJson(this.copyTrs)[0]
198
+ if (this.trs.length === 1 && this.trs[0]._isEmpty) {
199
+ this.trs.splice(0, 1)
200
+ }
201
+ this.trs.push(tr)
202
+ this.updateRaw(tr)
203
+ if (flag) {
204
+ this.$emit('add', this.trs.length)
205
+ this.updateValue()
206
+ }
207
+ },
208
+ updateRaw(tr) {
209
+ 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)
213
+ }
214
+ },
215
+ loadRule() {
216
+ const header = [
217
+ {
218
+ type: 'th',
219
+ native: true,
220
+ class: '_fc-tf-head-idx',
221
+ props: {
222
+ innerText: '#'
223
+ }
224
+ }
225
+ ]
226
+ let body = [
227
+ {
228
+ type: 'td',
229
+ class: '_fc-tf-idx',
230
+ native: true,
231
+ props: {
232
+ innerText: '0'
233
+ }
234
+ }
235
+ ]
236
+ this.columns.forEach((column) => {
237
+ header.push({
238
+ type: 'th',
239
+ native: true,
240
+ style: {
241
+ ...(column.style || {}),
242
+ textAlign: column.align || 'center'
243
+ },
244
+ class: column.required ? '_fc-tf-head-required' : '',
245
+ props: {
246
+ innerText: column.label || ''
247
+ }
248
+ })
249
+ body.push({
250
+ type: 'td',
251
+ native: true,
252
+ children: [...(column.rule || [])]
253
+ })
254
+ })
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: {}
273
+ }
274
+ ]
275
+ })
276
+ this.copyTrs = this.formCreateInject.form.toJson([
277
+ {
278
+ type: 'tr',
279
+ native: true,
280
+ subRule: true,
281
+ children: body
282
+ }
283
+ ])
284
+ this.rule = [
285
+ {
286
+ type: 'table',
287
+ native: true,
288
+ class: '_fc-tf-table',
289
+ props: {
290
+ border: '1',
291
+ cellspacing: '0',
292
+ cellpadding: '0'
293
+ },
294
+ children: [
295
+ {
296
+ type: 'thead',
297
+ native: true,
298
+ children: [
299
+ {
300
+ type: 'tr',
301
+ native: true,
302
+ children: header
303
+ }
304
+ ]
305
+ },
306
+ {
307
+ type: 'tbody',
308
+ native: true,
309
+ children: this.trs
310
+ }
311
+ ]
312
+ }
313
+ ]
314
+ }
315
+ },
316
+ created() {
317
+ this.loadRule()
318
+ },
319
+ mounted() {
320
+ this.updateTable()
321
+ }
322
+ }
323
+ </script>
@@ -0,0 +1,41 @@
1
+ <template>
2
+ <div class="_fd-tf-col" :style="colStyle">
3
+ <div class="_fd-tf-title" :style="{ textAlign: align || 'center' }">
4
+ <span v-if="required" class="_fd-tf-required">*</span>{{ label || '' }}
5
+ </div>
6
+ <div class="_fd-tf-con">
7
+ <slot></slot>
8
+ </div>
9
+ </div>
10
+ </template>
11
+
12
+ <script>
13
+ import is from '@form-create/utils/lib/type'
14
+ import { defineComponent } from 'vue'
15
+
16
+ export default defineComponent({
17
+ name: 'TableFormColumnView',
18
+ props: {
19
+ label: String,
20
+ align: String,
21
+ width: [Number, String],
22
+ color: String,
23
+ required: Boolean
24
+ },
25
+ computed: {
26
+ colStyle() {
27
+ const w = this.width
28
+ const style = {
29
+ width: is.Number(w) ? `${w}px` : !w || w === 'auto' ? '180px' : w
30
+ }
31
+ if (this.color) {
32
+ style.color = this.color
33
+ }
34
+ return style
35
+ }
36
+ },
37
+ data() {
38
+ return {}
39
+ }
40
+ })
41
+ </script>
@@ -0,0 +1,19 @@
1
+ <template>
2
+ <div class="_fd-table-form">
3
+ <div class="_fd-tf-wrap" v-if="$slots.default">
4
+ <slot></slot>
5
+ </div>
6
+ <div class="_fc-child-empty" v-else></div>
7
+ </div>
8
+ </template>
9
+
10
+ <script>
11
+ import { defineComponent } from 'vue'
12
+
13
+ export default defineComponent({
14
+ name: 'TableFormView',
15
+ data() {
16
+ return {}
17
+ }
18
+ })
19
+ </script>
package/src/core/index.js CHANGED
@@ -5,6 +5,7 @@ import manager from './manager'
5
5
  import FormCreateFactory from '@longhongguo/form-create-core/src/index'
6
6
  import makers from './maker'
7
7
  import '../style/index.css'
8
+ import '../style/icon.css'
8
9
  import extendApi from './api'
9
10
  import modelFields from './modelFields'
10
11
  import required from './provider'
Binary file