@tmagic/form 1.1.6 → 1.2.0-beta.2
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/dist/tmagic-form.mjs +126 -141
- package/dist/tmagic-form.mjs.map +1 -1
- package/dist/tmagic-form.umd.js +125 -140
- package/dist/tmagic-form.umd.js.map +1 -1
- package/package.json +2 -2
- package/src/FormDialog.vue +50 -48
- package/src/fields/Select.vue +18 -29
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.2.0-beta.2",
|
|
3
3
|
"name": "@tmagic/form",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"dist/*",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@element-plus/icons-vue": "^2.0.9",
|
|
38
|
-
"@tmagic/utils": "1.
|
|
38
|
+
"@tmagic/utils": "1.2.0-beta.2",
|
|
39
39
|
"element-plus": "^2.2.17",
|
|
40
40
|
"lodash-es": "^4.17.21",
|
|
41
41
|
"sortablejs": "^1.14.0",
|
package/src/FormDialog.vue
CHANGED
|
@@ -1,53 +1,55 @@
|
|
|
1
1
|
<template>
|
|
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
|
-
<el-col :span="12" style="text-align: left">
|
|
30
|
-
<div style="min-height: 1px">
|
|
31
|
-
<slot name="left"></slot>
|
|
32
|
-
</div>
|
|
33
|
-
</el-col>
|
|
34
|
-
<el-col :span="12">
|
|
35
|
-
<slot name="footer">
|
|
36
|
-
<el-button @click="cancel" size="small">取 消</el-button>
|
|
37
|
-
<el-button v-if="hasStep && stepActive > 1" type="info" size="small" @click="preStep">上一步</el-button>
|
|
38
|
-
<el-button v-if="hasStep && stepCount > stepActive" type="info" size="small" @click="nextStep"
|
|
39
|
-
>下一步</el-button
|
|
40
|
-
>
|
|
41
|
-
<el-button v-else type="primary" size="small" :loading="saveFetch" @click="save">{{
|
|
42
|
-
confirmText
|
|
43
|
-
}}</el-button>
|
|
44
|
-
</slot>
|
|
45
|
-
</el-col>
|
|
46
|
-
</el-row>
|
|
47
|
-
</template>
|
|
48
|
-
</el-dialog>
|
|
2
|
+
<el-dialog
|
|
3
|
+
v-model="dialogVisible"
|
|
4
|
+
class="m-form-dialog"
|
|
5
|
+
top="20px"
|
|
6
|
+
append-to-body
|
|
7
|
+
:title="title"
|
|
8
|
+
:width="width"
|
|
9
|
+
:fullscreen="fullscreen"
|
|
10
|
+
:close-on-click-modal="false"
|
|
11
|
+
@close="closeHandler"
|
|
12
|
+
>
|
|
13
|
+
<div
|
|
14
|
+
v-if="dialogVisible"
|
|
15
|
+
class="m-dialog-body"
|
|
16
|
+
:style="`max-height: ${bodyHeight}; overflow-y: auto; overflow-x: hidden;`"
|
|
17
|
+
>
|
|
18
|
+
<m-form
|
|
19
|
+
v-model="stepActive"
|
|
20
|
+
ref="form"
|
|
21
|
+
:size="size"
|
|
22
|
+
:config="config"
|
|
23
|
+
:init-values="values"
|
|
24
|
+
:parent-values="parentValues"
|
|
25
|
+
:label-width="labelWidth"
|
|
26
|
+
@change="changeHandler"
|
|
27
|
+
></m-form>
|
|
28
|
+
<slot></slot>
|
|
49
29
|
</div>
|
|
50
|
-
|
|
30
|
+
|
|
31
|
+
<template #footer>
|
|
32
|
+
<el-row class="dialog-footer">
|
|
33
|
+
<el-col :span="12" style="text-align: left">
|
|
34
|
+
<div style="min-height: 1px">
|
|
35
|
+
<slot name="left"></slot>
|
|
36
|
+
</div>
|
|
37
|
+
</el-col>
|
|
38
|
+
<el-col :span="12">
|
|
39
|
+
<slot name="footer">
|
|
40
|
+
<el-button @click="cancel" size="small">取 消</el-button>
|
|
41
|
+
<el-button v-if="hasStep && stepActive > 1" type="info" size="small" @click="preStep">上一步</el-button>
|
|
42
|
+
<el-button v-if="hasStep && stepCount > stepActive" type="info" size="small" @click="nextStep"
|
|
43
|
+
>下一步</el-button
|
|
44
|
+
>
|
|
45
|
+
<el-button v-else type="primary" size="small" :loading="saveFetch" @click="save">{{
|
|
46
|
+
confirmText
|
|
47
|
+
}}</el-button>
|
|
48
|
+
</slot>
|
|
49
|
+
</el-col>
|
|
50
|
+
</el-row>
|
|
51
|
+
</template>
|
|
52
|
+
</el-dialog>
|
|
51
53
|
</template>
|
|
52
54
|
|
|
53
55
|
<script lang="ts">
|
package/src/fields/Select.vue
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
28
|
<script lang="ts">
|
|
29
|
-
import { defineComponent, inject, onBeforeMount, onMounted, PropType, Ref, ref,
|
|
29
|
+
import { defineComponent, inject, onBeforeMount, onMounted, PropType, Ref, ref, watchEffect } from 'vue';
|
|
30
30
|
|
|
31
31
|
import { FormState, SelectConfig, SelectGroupOption, SelectOption } from '../schema';
|
|
32
32
|
import { getConfig } from '../utils/config';
|
|
@@ -264,35 +264,24 @@ export default defineComponent({
|
|
|
264
264
|
};
|
|
265
265
|
|
|
266
266
|
if (typeof props.config.options === 'function') {
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
props.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
});
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
deep: true,
|
|
285
|
-
immediate: true,
|
|
286
|
-
},
|
|
287
|
-
);
|
|
267
|
+
watchEffect(() => {
|
|
268
|
+
typeof props.config.options === 'function' &&
|
|
269
|
+
Promise.resolve(
|
|
270
|
+
props.config.options(mForm, {
|
|
271
|
+
model: props.model,
|
|
272
|
+
prop: props.prop,
|
|
273
|
+
formValues: mForm?.values,
|
|
274
|
+
formValue: mForm?.values,
|
|
275
|
+
config: props.config,
|
|
276
|
+
}),
|
|
277
|
+
).then((data) => {
|
|
278
|
+
options.value = data;
|
|
279
|
+
});
|
|
280
|
+
});
|
|
288
281
|
} else if (Array.isArray(props.config.options)) {
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
options.value = props.config.options as SelectOption[] | SelectGroupOption[];
|
|
293
|
-
},
|
|
294
|
-
{ immediate: true },
|
|
295
|
-
);
|
|
282
|
+
watchEffect(() => {
|
|
283
|
+
options.value = props.config.options as SelectOption[] | SelectGroupOption[];
|
|
284
|
+
});
|
|
296
285
|
} else if (props.config.option) {
|
|
297
286
|
onBeforeMount(() => {
|
|
298
287
|
if (!props.model) return;
|