starfish-form-custom 1.0.18 → 1.0.20

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.
@@ -37,10 +37,12 @@
37
37
  :disabled="item.data.state === 'disabled' || item.data.state === 'readonly'"
38
38
  v-if="drag"
39
39
  />
40
+ <!-- 只读展示文字 -->
41
+ <span v-if="!drag && item.data.state === 'readonly'">{{ formatReadonlyNumber(data[item.data.fieldName], item.data.precision) }}</span>
40
42
  <el-input-number
41
43
  v-model="data[item.data.fieldName]"
42
44
  width="240px"
43
- v-if="!drag"
45
+ v-else-if="!drag"
44
46
  :controls-position="item.data.type == 2 ? 'right' : ''"
45
47
  :disabled="item.data.state === 'disabled' || item.data.state === 'readonly'"
46
48
  :precision="item.data.precision"
@@ -78,7 +80,30 @@ export default defineComponent({
78
80
  setup(props) {
79
81
  const vm = getCurrentInstance() as ComponentInternalInstance;
80
82
  useWatch(props);
83
+ // 格式化只读数字显示
84
+ const formatReadonlyNumber = (value: any, precision: number) => {
85
+ if (value === null || value === undefined || value === '') {
86
+ return '-';
87
+ }
88
+
89
+ // 转换为数字
90
+ const numValue = Number(value);
91
+
92
+ // 检查是否为有效数字
93
+ if (isNaN(numValue)) {
94
+ return String(value);
95
+ }
96
+
97
+ // 如果有精度设置,进行格式化
98
+ if (precision !== undefined && precision !== null) {
99
+ return numValue.toFixed(precision);
100
+ }
101
+
102
+ // 如果没有精度设置,直接返回数字
103
+ return String(numValue);
104
+ };
81
105
  return {
106
+ formatReadonlyNumber,
82
107
  execFunc(type: string) {
83
108
  if (props.item.data.action && props.item.data.action[type]) {
84
109
  window.VApp.$Flex.funcExec(props.item.data.action[type], vm.proxy, [
@@ -29,8 +29,9 @@
29
29
  class="control"
30
30
  :style="{ marginLeft: labelalign != 'top' ? labelWidth + 'px' : '' }"
31
31
  >
32
+ <span v-if="!drag && item.data.state === 'readonly'">{{ data[item.data.fieldName] || '--' }}</span>
32
33
  <el-radio-group
33
- v-if="!drag"
34
+ v-else-if="!drag"
34
35
  v-model="data[item.data.fieldName]"
35
36
  :size="size"
36
37
  :class="{'vertical-group': item.data.arrangeMent === 'vertical'}"
@@ -24,11 +24,24 @@
24
24
  class="control"
25
25
  :style="{ marginLeft: labelalign != 'top' ? labelWidth + 'px' : '' }"
26
26
  >
27
- <el-collapse
27
+ <el-dropdown @command="handleDropdown" style="margin-top: 10px">
28
+ <el-button type="success">
29
+ 新增规则<i class="el-icon-arrow-down el-icon--right"></i>
30
+ </el-button>
31
+ <template #dropdown>
32
+ <el-dropdown-menu>
33
+ <el-dropdown-item command="enum">默认枚举</el-dropdown-item>
34
+ <el-dropdown-item command="func">自定义函数规则</el-dropdown-item>
35
+ <el-dropdown-item command="high">高级模式</el-dropdown-item>
36
+ </el-dropdown-menu>
37
+ </template>
38
+ </el-dropdown>
39
+ <el-collapse
28
40
  v-if="
29
41
  Array.isArray(data[item.data.fieldName]) &&
30
42
  data[item.data.fieldName].length > 0
31
43
  "
44
+ style="margin-top: 16px;"
32
45
  >
33
46
  <el-collapse-item
34
47
  :title="itemList.title"
@@ -68,28 +81,9 @@
68
81
  >规则表单编辑</el-button
69
82
  >
70
83
  </div>
71
- <el-button
72
- type="danger"
73
- circle
74
- @click="deleteRule(index)"
75
- style="margin-left: 10px"
76
- >
77
- <el-icon><Delete /></el-icon>
78
- </el-button>
84
+ <el-icon @click="deleteRule(index)" style="margin-left: 10px" :size="14"><Delete /></el-icon>
79
85
  </el-collapse-item>
80
86
  </el-collapse>
81
- <el-dropdown @command="handleDropdown" style="margin-top: 10px">
82
- <el-button type="success">
83
- 新增规则<i class="el-icon-arrow-down el-icon--right"></i>
84
- </el-button>
85
- <template #dropdown>
86
- <el-dropdown-menu>
87
- <el-dropdown-item command="enum">默认枚举</el-dropdown-item>
88
- <el-dropdown-item command="func">自定义函数规则</el-dropdown-item>
89
- <el-dropdown-item command="high">高级模式</el-dropdown-item>
90
- </el-dropdown-menu>
91
- </template>
92
- </el-dropdown>
93
87
  </div>
94
88
  <CustomDialog ref="codeMyDialog">
95
89
  <div
@@ -43,11 +43,12 @@
43
43
  :value="items.value"
44
44
  />
45
45
  </el-select>
46
+ <span v-if="!drag && item.data.state === 'readonly'">{{ data[item.data.fieldName] || '--' }}</span>
46
47
  <el-select
47
48
  v-model="data[item.data.fieldName]"
48
49
  width="240px"
49
50
  :placeholder="item.data.placeholder"
50
- v-if="!drag"
51
+ v-else-if="!drag"
51
52
  :size="size"
52
53
  :disabled="item.data.state === 'disabled' || item.data.state === 'readonly'"
53
54
  @focus="execFunc('onFocus')"
@@ -44,11 +44,12 @@
44
44
  :value="items.value"
45
45
  />
46
46
  </el-select>
47
+ <span v-if="!drag && item.data.state === 'readonly'">{{ data[item.data.fieldName].join(',') || '--' }}</span>
47
48
  <el-select
48
49
  v-model="data[item.data.fieldName]"
49
50
  width="240px"
50
51
  :placeholder="item.data.placeholder"
51
- v-if="!drag"
52
+ v-else-if="!drag"
52
53
  multiple
53
54
  :size="size"
54
55
  :disabled="item.data.state === 'disabled' || item.data.state === 'readonly'"
@@ -30,7 +30,7 @@
30
30
  >
31
31
  <el-input
32
32
  v-model="item.data.default"
33
- width="240px"
33
+ width="200px"
34
34
  :placeholder="item.data.placeholder"
35
35
  v-if="drag"
36
36
  :size="size"
@@ -39,17 +39,20 @@
39
39
  :readonly="item.data.state === 'readonly'"
40
40
  :maxlength="item.data.maxLength"
41
41
  :minlength="item.data.minLength"
42
+ :class="'input-' + item.data.align"
42
43
  />
44
+ <span v-if="!drag && item.data.state === 'readonly'">{{ data[item.data.fieldName] || '--' }}</span>
43
45
  <el-input
44
46
  v-model="data[item.data.fieldName]"
45
- width="240px"
47
+ width="200px"
46
48
  :placeholder="item.data.placeholder"
47
- v-if="!drag"
49
+ v-else-if="!drag"
48
50
  :size="size"
49
51
  :disabled="item.data.state === 'disabled'"
50
52
  :readonly="item.data.state === 'readonly'"
51
53
  :maxlength="item.data.maxLength"
52
54
  :minlength="item.data.minLength"
55
+ :class="'input-' + item.data.align"
53
56
  clearable
54
57
  @focus="execFunc('onFocus')"
55
58
  @blur="execFunc('onBlur')"
@@ -76,6 +79,8 @@ export default defineComponent({
76
79
  { fieldName: "maxLength", component: "InputNumber" },
77
80
  { fieldName: "minLength", component: "InputNumber" },
78
81
  { fieldName: "state", component: "Radio" },
82
+ { fieldName: "align", component: "Radio" },
83
+ { fieldName: "rule", component: "Rule" },
79
84
  ]),
80
85
  actionType: ["onChange", "onFocus", "onBlur"],
81
86
  props: {
@@ -40,9 +40,10 @@
40
40
  :autosize="item.data.autoHeight"
41
41
  :size="size"
42
42
  />
43
+ <span v-if="!drag && item.data.state === 'readonly'">{{ data[item.data.fieldName] || '--' }}</span>
43
44
  <el-input
44
45
  type="textarea"
45
- v-if="!drag"
46
+ v-else-if="!drag"
46
47
  v-model="data[item.data.fieldName]"
47
48
  :placeholder="item.data.placeholder"
48
49
  :disabled="item.data.state === 'disabled'"
@@ -42,14 +42,29 @@
42
42
  flex-direction: column;
43
43
  align-items: flex-start;
44
44
  }
45
+ .input-left {
46
+ .el-input__inner {
47
+ text-align: left;
48
+ }
49
+ }
50
+ .input-right {
51
+ .el-input__inner {
52
+ text-align: right;
53
+ }
54
+ }
55
+ .input-center {
56
+ .el-input__inner {
57
+ text-align: center;
58
+ }
59
+ }
45
60
  .el-input.el-input--default.el-input--suffix,
46
61
  .el-select.el-select--default,
47
62
  .el-input-number.el-input-number--default,
48
63
  .el-input.el-input--default.el-date-editor.el-date-editor--date {
49
- width: 240px;
64
+ width: 200px;
50
65
  }
51
66
  .el-input__wrapper {
52
- width: 220px;
67
+ width: 200px;
53
68
  }
54
69
  }
55
70
  }
@@ -27,7 +27,7 @@ export interface fields {
27
27
  /**
28
28
  * 校验规则
29
29
  */
30
- // rule: string;
30
+ rule?: string;
31
31
  /**
32
32
  * 默认内容
33
33
  */
@@ -171,6 +171,7 @@ const fieldsMap: any = {
171
171
  maxLength: 100,
172
172
  minLength: 0,
173
173
  state: "normal", // 状态:normal, disabled, readonly
174
+ align: 'left'
174
175
  },
175
176
  Info: {
176
177
  fieldName: "",
@@ -529,7 +530,9 @@ type fieldMap =
529
530
  | "autoHeight"
530
531
  | "format"
531
532
  | "precision"
532
- | "arrangeMent";
533
+ | "arrangeMent"
534
+ | "align"
535
+ | "rule";
533
536
 
534
537
  type morenFields = Partial<Record<fieldMap, FormConfig>>;
535
538
 
@@ -548,7 +551,7 @@ function getMoren(
548
551
  placeholder: "",
549
552
  showRule: "{}",
550
553
  required: false,
551
- rule: "[]",
554
+ rule: "[]"
552
555
  },
553
556
  },
554
557
  placeholder: {
@@ -563,6 +566,18 @@ function getMoren(
563
566
  rule: "[]",
564
567
  },
565
568
  },
569
+ rule: {
570
+ ControlType: "Rule",
571
+ data: {
572
+ fieldName: "rule",
573
+ tip: "",
574
+ label: "校验规则",
575
+ showRule: "{}",
576
+ required: false,
577
+ rule: "[]",
578
+ default: "[]",
579
+ },
580
+ },
566
581
  precision: {
567
582
  ControlType: "InputNumber",
568
583
  data: {
@@ -622,6 +637,26 @@ function getMoren(
622
637
  },
623
638
  },
624
639
  },
640
+ align: {
641
+ ControlType: "Radio",
642
+ data: {
643
+ fieldName: "align",
644
+ tip: "",
645
+ label: "对齐方式",
646
+ placeholder: "",
647
+ showRule: "{}",
648
+ required: false,
649
+ rule: "[]",
650
+ itemConfig: {
651
+ value: "left",
652
+ items: [
653
+ { label: "左", value: "left" },
654
+ { label: "中", value: "center" },
655
+ { label: "右", value: "right" },
656
+ ],
657
+ },
658
+ },
659
+ },
625
660
  arrangeMent: {
626
661
  ControlType: "Radio",
627
662
  data: {
@@ -933,6 +968,7 @@ interface Config {
933
968
  fieldName: string;
934
969
  component: string;
935
970
  label?: string;
971
+ format?: string;
936
972
  }
937
973
 
938
974
  interface FormConfigReturn {