@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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.6",
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.1.6",
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",
@@ -1,53 +1,55 @@
1
1
  <template>
2
- <teleport to="body">
3
- <div class="m-form-dialog" v-show="dialogVisible">
4
- <el-dialog
5
- v-model="dialogVisible"
6
- top="20px"
7
- :title="title"
8
- :width="width"
9
- :fullscreen="fullscreen"
10
- :close-on-click-modal="false"
11
- @close="closeHandler"
12
- >
13
- <div class="m-dialog-body" :style="`max-height: ${bodyHeight}; overflow-y: auto; overflow-x: hidden;`">
14
- <m-form
15
- v-model="stepActive"
16
- ref="form"
17
- :size="size"
18
- :config="config"
19
- :init-values="values"
20
- :parent-values="parentValues"
21
- :label-width="labelWidth"
22
- @change="changeHandler"
23
- ></m-form>
24
- <slot></slot>
25
- </div>
26
-
27
- <template #footer>
28
- <el-row class="dialog-footer">
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
- </teleport>
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">
@@ -26,7 +26,7 @@
26
26
  </template>
27
27
 
28
28
  <script lang="ts">
29
- import { defineComponent, inject, onBeforeMount, onMounted, PropType, Ref, ref, watch } from 'vue';
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
- watch(
268
- () => mForm?.values,
269
- () => {
270
- typeof props.config.options === 'function' &&
271
- Promise.resolve(
272
- props.config.options(mForm, {
273
- model: props.model,
274
- prop: props.prop,
275
- formValues: mForm?.values,
276
- formValue: mForm?.values,
277
- config: props.config,
278
- }),
279
- ).then((data) => {
280
- options.value = data;
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
- watch(
290
- () => props.config.options,
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;