starfish-form-custom 1.0.25 → 1.0.27

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.
@@ -11,7 +11,7 @@ import 'element-plus/es/components/button/style/css';
11
11
  import 'element-plus/es/components/tooltip/style/css';
12
12
  import { defineComponent, inject, ref, getCurrentInstance, reactive, onMounted, resolveComponent, openBlock, createElementBlock, normalizeClass, normalizeStyle, createElementVNode, toDisplayString, createCommentVNode, createBlock, withCtx, createVNode, Fragment, renderList, withModifiers, createTextVNode } from 'vue';
13
13
  import { Codemirror } from 'vue-codemirror';
14
- import { _ as _export_sfc } from './main-c64812d2.mjs';
14
+ import { _ as _export_sfc } from './main-7d7122a6.mjs';
15
15
  import 'element-plus/es/components/icon/style/css';
16
16
  import 'element-plus/es/components/checkbox/style/css';
17
17
  import '@element-plus/icons-vue';
@@ -13,9 +13,9 @@ import 'element-plus/es/components/dropdown-item/style/css';
13
13
  import 'element-plus/es/components/button/style/css';
14
14
  import 'element-plus/es/components/tooltip/style/css';
15
15
  import { defineComponent, getCurrentInstance, inject, computed, ref, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, toDisplayString, createCommentVNode, createBlock, withCtx, createVNode, Fragment, renderList, createTextVNode } from 'vue';
16
- import { _ as _export_sfc, a as _, f as fieldProps, r as ruleList, b as ruleJsonData } from './main-c64812d2.mjs';
16
+ import { _ as _export_sfc, a as _, f as fieldProps, r as ruleList, b as ruleJsonData } from './main-7d7122a6.mjs';
17
17
  import { Delete } from '@element-plus/icons-vue';
18
- import Dynamicform from './starfish-form-1b37792d.mjs';
18
+ import Dynamicform from './starfish-form-96426334.mjs';
19
19
  import { Codemirror } from 'vue-codemirror';
20
20
  import 'element-plus/es/components/input/style/css';
21
21
  import 'element-plus/es/components/checkbox/style/css';
@@ -3,7 +3,7 @@ import 'element-plus/es/components/base/style/css';
3
3
  import 'element-plus/es/components/tooltip/style/css';
4
4
  import { defineComponent, ref, onMounted, onUnmounted, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, toDisplayString, createCommentVNode, createBlock, withCtx } from 'vue';
5
5
  import E from 'wangeditor';
6
- import { _ as _export_sfc, g as getFormConfig, f as fieldProps, u as useWatch } from './main-c64812d2.mjs';
6
+ import { _ as _export_sfc, g as getFormConfig, f as fieldProps, u as useWatch } from './main-7d7122a6.mjs';
7
7
  import 'element-plus/es/components/icon/style/css';
8
8
  import 'element-plus/es/components/input/style/css';
9
9
  import 'element-plus/es/components/checkbox/style/css';
@@ -6,7 +6,7 @@ import 'element-plus/es/components/button/style/css';
6
6
  import 'element-plus/es/components/main/style/css';
7
7
  import 'element-plus/es/components/tooltip/style/css';
8
8
  import { defineComponent, ref, onMounted, watch, nextTick, resolveComponent, openBlock, createElementBlock, normalizeClass, createElementVNode, normalizeStyle, toDisplayString, createCommentVNode, createBlock, withCtx, createVNode, createTextVNode } from 'vue';
9
- import { _ as _export_sfc, a as _, g as getFormConfig, f as fieldProps, u as useWatch } from './main-c64812d2.mjs';
9
+ import { _ as _export_sfc, a as _, g as getFormConfig, f as fieldProps, u as useWatch } from './main-7d7122a6.mjs';
10
10
  import JSONEditor from 'jsoneditor';
11
11
  import 'element-plus/es/components/icon/style/css';
12
12
  import 'element-plus/es/components/input/style/css';
@@ -4392,7 +4392,6 @@ const _sfc_main$2 = defineComponent({
4392
4392
  await nextTick();
4393
4393
  formStore.setFormCurrentId(gridList.value[index].list[e.oldIndex]?.id);
4394
4394
  formStore.setFormCurrentIndex(e.oldIndex);
4395
- console.log("grid", gridList.value[index].list);
4396
4395
  store.set("curList", gridList.value[index].list);
4397
4396
  };
4398
4397
  const currentId = computed(() => {
@@ -4555,27 +4554,28 @@ const _sfc_main$1 = defineComponent({
4555
4554
  useWatch(props);
4556
4555
  return {
4557
4556
  currentId,
4558
- async chooseClick(e, list, trIndex, tdIndex) {
4559
- props.item.data.trs[trIndex].tds[tdIndex].list = list.map((item) => {
4560
- return proxy.$Flex.jsonToForm(item);
4557
+ chooseClick(e, list) {
4558
+ list[e.oldIndex] = proxy.$Flex.jsonToForm(list[e.oldIndex]);
4559
+ nextTick(() => {
4560
+ formStore.setFormCurrentId(list[e.oldIndex].id);
4561
+ formStore.setFormCurrentIndex(e.oldIndex);
4562
+ store.set("curList", list);
4561
4563
  });
4562
- await nextTick();
4563
- formStore.setFormCurrentId(list[e.oldIndex].id);
4564
- formStore.setFormCurrentIndex(e.oldIndex);
4565
- console.log("table", list);
4566
- store.set("curList", list);
4567
4564
  },
4568
4565
  changePos(e, list) {
4569
4566
  formStore.setFormCurrentId(list[e.newIndex]?.id);
4570
4567
  formStore.setFormCurrentIndex(e.newIndex);
4571
4568
  store.set("curList", list);
4572
4569
  },
4573
- async addControl(e, list, trIndex, tdIndex) {
4574
- props.item.data.trs[trIndex].tds[tdIndex].list = list.map((item) => {
4575
- return proxy.$Flex.jsonToForm(item);
4576
- });
4577
- await nextTick();
4578
- formStore.setFormCurrentId(props.item.data.trs[trIndex].tds[tdIndex].list[e.newIndex].id);
4570
+ addControl(e, list, trIndex, tdIndex) {
4571
+ props.item.data.trs[trIndex].tds[tdIndex].list = list.map(
4572
+ (item) => {
4573
+ return proxy.$Flex.jsonToForm(item);
4574
+ }
4575
+ );
4576
+ formStore.setFormCurrentId(
4577
+ props.item.data.trs[trIndex].tds[tdIndex].list[e.newIndex].id
4578
+ );
4579
4579
  formStore.setFormCurrentIndex(e.newIndex);
4580
4580
  store.set("curList", props.item.data.trs[trIndex].tds[tdIndex].list);
4581
4581
  }
@@ -5317,7 +5317,7 @@ Object.keys(files).forEach((fileName) => {
5317
5317
  }
5318
5318
  });
5319
5319
  const RichText = defineAsyncComponent({
5320
- loader: () => import('./index-e4264580.mjs'),
5320
+ loader: () => import('./index-a4faf6fb.mjs'),
5321
5321
  loadingComponent: Loading
5322
5322
  });
5323
5323
  RichText.ControlType = "RichText";
@@ -5326,7 +5326,7 @@ RichText.icon = "icon-textEdit";
5326
5326
  RichText.formConfig = getFormConfig("RichText");
5327
5327
  utilFuns[RichText.ControlType] = RichText;
5328
5328
  const jsonEditor = defineAsyncComponent({
5329
- loader: () => import('./index-2e818bbe.mjs'),
5329
+ loader: () => import('./index-e0c4eec0.mjs'),
5330
5330
  loadingComponent: Loading
5331
5331
  });
5332
5332
  jsonEditor.ControlType = "JsonEditor";
@@ -5336,14 +5336,14 @@ jsonEditor.formConfig = getFormConfig("JsonEditor", [{ fieldName: "default", com
5336
5336
  jsonEditor.rule = _.getJsonValidate();
5337
5337
  utilFuns[jsonEditor.ControlType] = jsonEditor;
5338
5338
  const formAction = defineAsyncComponent({
5339
- loader: () => import('./formAction-a969e2cf.mjs'),
5339
+ loader: () => import('./formAction-5fbc8d53.mjs'),
5340
5340
  loadingComponent: Loading
5341
5341
  });
5342
5342
  formAction.ControlType = "FormAction";
5343
5343
  formAction.isHide = true;
5344
5344
  utilFuns[formAction.ControlType] = formAction;
5345
5345
  const Rule = defineAsyncComponent({
5346
- loader: () => import('./index-d613dbb1.mjs'),
5346
+ loader: () => import('./index-2249b02f.mjs'),
5347
5347
  loadingComponent: Loading
5348
5348
  });
5349
5349
  Rule.ControlType = "Rule";
@@ -5352,7 +5352,7 @@ utilFuns[Rule.ControlType] = Rule;
5352
5352
  const install = (app) => {
5353
5353
  app.config.globalProperties.$formcomponents = utilFuns;
5354
5354
  };
5355
- const Dynamicform = defineAsyncComponent(() => import('./starfish-form-1b37792d.mjs'));
5355
+ const Dynamicform = defineAsyncComponent(() => import('./starfish-form-96426334.mjs'));
5356
5356
  const main = {
5357
5357
  install
5358
5358
  };
@@ -3,7 +3,7 @@ import 'element-plus/es/components/base/style/css';
3
3
  import 'element-plus/es/components/form/style/css';
4
4
  import 'element-plus/es/components/form-item/style/css';
5
5
  import { defineComponent, getCurrentInstance, ref, onMounted, openBlock, createElementBlock, createVNode, mergeProps, withCtx, Fragment, renderList, createBlock, resolveDynamicComponent, createCommentVNode, toRaw } from 'vue';
6
- import { _ as _export_sfc } from './main-c64812d2.mjs';
6
+ import { _ as _export_sfc } from './main-7d7122a6.mjs';
7
7
  import 'element-plus/es/components/icon/style/css';
8
8
  import 'element-plus/es/components/input/style/css';
9
9
  import 'element-plus/es/components/checkbox/style/css';
@@ -56,6 +56,10 @@ const _sfc_main = defineComponent({
56
56
  default() {
57
57
  return {};
58
58
  }
59
+ },
60
+ readonly: {
61
+ type: Boolean,
62
+ default: false
59
63
  }
60
64
  },
61
65
  setup(props, { emit }) {
@@ -78,7 +82,9 @@ const _sfc_main = defineComponent({
78
82
  });
79
83
  } else if (item.type == "func") {
80
84
  const mainData = props.formResult;
81
- const func = eval(`((rule, value, callback, mainData = mainData) => {${item.value.func}})`);
85
+ const func = eval(
86
+ `((rule, value, callback, mainData = mainData) => {${item.value.func}})`
87
+ );
82
88
  result.push({
83
89
  validator: func,
84
90
  trigger: "blur"
@@ -167,7 +173,9 @@ const _sfc_main = defineComponent({
167
173
  } else {
168
174
  try {
169
175
  if (Array.isArray(item2.data.showRule)) {
170
- item2.show = conditionChange(transformData(toRaw(item2.data.showRule)));
176
+ item2.show = conditionChange(
177
+ transformData(toRaw(item2.data.showRule))
178
+ );
171
179
  } else {
172
180
  item2.show = conditionChange(toRaw(item2.data.showRule));
173
181
  }
@@ -315,11 +323,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
315
323
  ref: "controlObj",
316
324
  onChange: _ctx.handleControlChange
317
325
  }, _ctx.globalConfig, {
326
+ readonly: _ctx.readonly,
318
327
  item: item2,
319
328
  data: _ctx.formResult || "{}",
320
329
  drag: false,
321
330
  size: "default"
322
- }), null, 16, ["onChange", "item", "data"]))
331
+ }), null, 16, ["onChange", "readonly", "item", "data"]))
323
332
  ]),
324
333
  _: 2
325
334
  }, 1032, ["prop"])) : item2.show ? (openBlock(), createBlock(resolveDynamicComponent(item2.ControlType), mergeProps({
@@ -329,11 +338,12 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
329
338
  onChange: _ctx.handleControlChange,
330
339
  key: item2.id
331
340
  }, _ctx.globalConfig, {
341
+ readonly: _ctx.readonly,
332
342
  item: item2,
333
343
  data: _ctx.formResult || "{}",
334
344
  drag: false,
335
345
  size: "default"
336
- }), null, 16, ["onChange", "item", "data"])) : createCommentVNode("", true)
346
+ }), null, 16, ["onChange", "readonly", "item", "data"])) : createCommentVNode("", true)
337
347
  ], 64);
338
348
  }), 256))
339
349
  ]),
@@ -1,4 +1,4 @@
1
- export { D as Dynamicform, m as default } from './main-c64812d2.mjs';
1
+ export { D as Dynamicform, m as default } from './main-7d7122a6.mjs';
2
2
  import 'vue';
3
3
  import 'element-plus/es';
4
4
  import 'element-plus/es/components/base/style/css';
@@ -14,6 +14,10 @@ export declare const Dynamicform: DefineComponent<{
14
14
  type: ObjectConstructor;
15
15
  default(): {};
16
16
  };
17
+ readonly: {
18
+ type: BooleanConstructor;
19
+ default: boolean;
20
+ };
17
21
  }, {
18
22
  rules: any;
19
23
  ruleForm: Ref<any>;
@@ -34,10 +38,15 @@ export declare const Dynamicform: DefineComponent<{
34
38
  type: ObjectConstructor;
35
39
  default(): {};
36
40
  };
41
+ readonly: {
42
+ type: BooleanConstructor;
43
+ default: boolean;
44
+ };
37
45
  }>>, {
38
46
  allFormList: any;
39
47
  formResult: Record<string, any>;
40
48
  globalConfig: Record<string, any>;
49
+ readonly: boolean;
41
50
  }>;
42
51
  declare const _default: {
43
52
  install: (app: App<any>) => void;
@@ -14,6 +14,10 @@ declare const _sfc_main: DefineComponent<{
14
14
  type: ObjectConstructor;
15
15
  default(): {};
16
16
  };
17
+ readonly: {
18
+ type: BooleanConstructor;
19
+ default: boolean;
20
+ };
17
21
  }, {
18
22
  rules: any;
19
23
  ruleForm: Ref<any>;
@@ -34,9 +38,14 @@ declare const _sfc_main: DefineComponent<{
34
38
  type: ObjectConstructor;
35
39
  default(): {};
36
40
  };
41
+ readonly: {
42
+ type: BooleanConstructor;
43
+ default: boolean;
44
+ };
37
45
  }>>, {
38
46
  allFormList: any;
39
47
  formResult: Record<string, any>;
40
48
  globalConfig: Record<string, any>;
49
+ readonly: boolean;
41
50
  }>;
42
51
  export default _sfc_main;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starfish-form-custom",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "main": "dist/starfish-form.mjs",
5
5
  "style": "dist/style.css",
6
6
  "module": "dist/starfish-form.mjs",
@@ -62,7 +62,6 @@
62
62
  await nextTick();
63
63
  formStore.setFormCurrentId(gridList.value[index].list[e.oldIndex]?.id);
64
64
  formStore.setFormCurrentIndex(e.oldIndex);
65
- console.log('grid', gridList.value[index].list)
66
65
  store.set("curList", gridList.value[index].list);
67
66
  };
68
67
  const currentId = computed(() => {
@@ -1,22 +1,71 @@
1
1
  <template>
2
2
  <div class="starfish-table_box">
3
- <table class="table_layout" :class="item.data.borderShow ? 'table_layout_border' : ''">
3
+ <table
4
+ class="table_layout"
5
+ :class="item.data.borderShow ? 'table_layout_border' : ''"
6
+ >
4
7
  <tr v-for="(trItem, index) in item.data.trs" :key="index">
5
8
  <td v-for="(tdItem, tdIndex) in trItem.tds" :key="tdIndex">
6
9
  <template v-if="drag">
7
- <draggable class="draggable-box" animation="300" ghostClass="itemGhost" v-model="tdItem.list" @add="addControl($event, tdItem.list, index, tdIndex)" group="starfish-form" @choose="chooseClick($event, tdItem.list, index, tdIndex)" item-key="id" @update="changePos($event, tdItem.list)">
10
+ <draggable
11
+ class="draggable-box"
12
+ animation="300"
13
+ ghostClass="itemGhost"
14
+ v-model="tdItem.list"
15
+ @add="addControl($event, tdItem.list, index, tdIndex)"
16
+ group="starfish-form"
17
+ @choose="chooseClick($event, tdItem.list, index, tdIndex)"
18
+ item-key="id"
19
+ @update="changePos($event, tdItem.list)"
20
+ >
8
21
  <template #item="{ element, index }">
9
- <Shape v-if="element.data" :active="currentId == element.id" :currentIndex="index" :currentId="element.id" :len="tdItem.list.length" :item="element"> <component :is="element.ControlType" size="default" :drag="true" :item="element" :data="{}"></component></Shape>
22
+ <Shape
23
+ v-if="element.data"
24
+ :active="currentId == element.id"
25
+ :currentIndex="index"
26
+ :currentId="element.id"
27
+ :len="tdItem.list.length"
28
+ :item="element"
29
+ >
30
+ <component
31
+ :is="element.ControlType"
32
+ size="default"
33
+ :drag="true"
34
+ :item="element"
35
+ :data="{}"
36
+ ></component
37
+ ></Shape>
10
38
  </template>
11
39
  </draggable>
12
40
  </template>
13
41
  <template v-else-if="!drag && tdItem.list.length > 0">
14
42
  <template v-for="listItem in tdItem.list">
15
- <el-form-item :prop="listItem.data.fieldName" :key="listItem.id" v-if="!listItem.layout">
16
- <component ref="controlObj" @change="$emit('change')" :is="listItem.ControlType" :item="listItem" :data="data || '{}'" size="default" :drag="false" ></component>
43
+ <el-form-item
44
+ :prop="listItem.data.fieldName"
45
+ :key="listItem.id"
46
+ v-if="!listItem.layout"
47
+ >
48
+ <component
49
+ ref="controlObj"
50
+ @change="$emit('change')"
51
+ :is="listItem.ControlType"
52
+ :item="listItem"
53
+ :data="data || '{}'"
54
+ size="default"
55
+ :drag="false"
56
+ ></component>
17
57
  </el-form-item>
18
58
  <template v-else>
19
- <component ref="controlObj" @change="$emit('change')" size="default" :key="listItem.id" :is="listItem.ControlType" :item="listItem" :data="data || '{}'" :drag="false" ></component>
59
+ <component
60
+ ref="controlObj"
61
+ @change="$emit('change')"
62
+ size="default"
63
+ :key="listItem.id"
64
+ :is="listItem.ControlType"
65
+ :item="listItem"
66
+ :data="data || '{}'"
67
+ :drag="false"
68
+ ></component>
20
69
  </template>
21
70
  </template>
22
71
  </template>
@@ -26,61 +75,67 @@
26
75
  </div>
27
76
  </template>
28
77
  <script lang="ts">
29
- import { defineComponent, getCurrentInstance, inject, computed, nextTick } from "vue";
30
- import { getFormConfig } from "../utils/fieldConfig";
31
- import fieldProps from "../utils/fieldProps";
32
- import { useWatch } from "../utils/customHooks";
33
- export default defineComponent({
34
- ControlType: "TableLayout",
35
- nameCn: "表格布局",
36
- icon: "icon-biaoge1",
37
- layout: true,
38
- props: {
39
- ...fieldProps,
40
- },
41
- formConfig: getFormConfig(
42
- "TableLayout",
43
- [
44
- // { fieldName: "borderShow", component: "Switch", label: "是否显示边框" },
45
- // {fieldName: 'borderWidth', component: 'InputNumber', label: "边框宽度"}
46
- ],
47
- ["required", "rule", "tip", "label"]
48
- ),
49
- setup(props) {
50
- const { proxy } = getCurrentInstance() as any;
51
- const { formStore, store } = inject("control") || {};
52
- const currentId = computed(() => {
53
- return formStore.get("currentId");
54
- });
55
- useWatch(props);
56
- return {
57
- currentId,
58
- async chooseClick(e: any, list: any[], trIndex: number, tdIndex: number) {
59
- props.item.data.trs[trIndex].tds[tdIndex].list = list.map((item: any) => {
60
- return proxy.$Flex.jsonToForm(item);
61
- });
62
- await nextTick();
78
+ import {
79
+ defineComponent,
80
+ getCurrentInstance,
81
+ inject,
82
+ computed,
83
+ nextTick,
84
+ } from "vue";
85
+ import { getFormConfig } from "../utils/fieldConfig";
86
+ import fieldProps from "../utils/fieldProps";
87
+ import { useWatch } from "../utils/customHooks";
88
+ export default defineComponent({
89
+ ControlType: "TableLayout",
90
+ nameCn: "表格布局",
91
+ icon: "icon-biaoge1",
92
+ layout: true,
93
+ props: {
94
+ ...fieldProps,
95
+ },
96
+ formConfig: getFormConfig(
97
+ "TableLayout",
98
+ [
99
+ // { fieldName: "borderShow", component: "Switch", label: "是否显示边框" },
100
+ // {fieldName: 'borderWidth', component: 'InputNumber', label: "边框宽度"}
101
+ ],
102
+ ["required", "rule", "tip", "label"]
103
+ ),
104
+ setup(props) {
105
+ const { proxy } = getCurrentInstance() as any;
106
+ const { formStore, store } = inject("control") || {};
107
+ const currentId = computed(() => {
108
+ return formStore.get("currentId");
109
+ });
110
+ useWatch(props);
111
+ return {
112
+ currentId,
113
+ chooseClick(e: any, list: any[]) {
114
+ list[e.oldIndex] = proxy.$Flex.jsonToForm(list[e.oldIndex]);
115
+ nextTick(() => {
63
116
  formStore.setFormCurrentId(list[e.oldIndex].id);
64
117
  formStore.setFormCurrentIndex(e.oldIndex);
65
- console.log('table', list);
66
- store.set("curList", list);
67
- },
68
- changePos(e: any, list: any[]) {
69
- formStore.setFormCurrentId(list[e.newIndex]?.id);
70
- formStore.setFormCurrentIndex(e.newIndex);
71
118
  store.set("curList", list);
72
- },
73
- async addControl(e: any, list: any[], trIndex: number, tdIndex: number) {
74
- props.item.data.trs[trIndex].tds[tdIndex].list = list.map((item: any) => {
119
+ });
120
+ },
121
+ changePos(e: any, list: any[]) {
122
+ formStore.setFormCurrentId(list[e.newIndex]?.id);
123
+ formStore.setFormCurrentIndex(e.newIndex);
124
+ store.set("curList", list);
125
+ },
126
+ addControl(e: any, list: any[], trIndex: number, tdIndex: number) {
127
+ props.item.data.trs[trIndex].tds[tdIndex].list = list.map(
128
+ (item: any) => {
75
129
  return proxy.$Flex.jsonToForm(item);
76
- });
77
- await nextTick();
78
- formStore.setFormCurrentId(props.item.data.trs[trIndex].tds[tdIndex].list[e.newIndex].id);
79
- formStore.setFormCurrentIndex(e.newIndex);
80
- store.set("curList", props.item.data.trs[trIndex].tds[tdIndex].list);
81
- },
82
- };
83
- },
84
- });
130
+ }
131
+ );
132
+ formStore.setFormCurrentId(
133
+ props.item.data.trs[trIndex].tds[tdIndex].list[e.newIndex].id
134
+ );
135
+ formStore.setFormCurrentIndex(e.newIndex);
136
+ store.set("curList", props.item.data.trs[trIndex].tds[tdIndex].list);
137
+ },
138
+ };
139
+ },
140
+ });
85
141
  </script>
86
-