free-fe-core-modules 0.1.12 → 0.1.14

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.
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, ref, getCurrentInstance, defineExpose } from 'vue';
1
+ import { defineComponent, h, ref, getCurrentInstance, watch } from 'vue';
2
2
  import { QCheckbox, QIcon } from 'quasar';
3
3
  import { useFreeField, freeFieldProps } from '../composible/useFreeField';
4
4
 
@@ -21,7 +21,7 @@ export default defineComponent({
21
21
  ...freeFieldProps,
22
22
  },
23
23
  emits: ['input'],
24
- setup(props, { emit }){
24
+ setup(props, { emit, expose }){
25
25
  if (!props.Field) return {};
26
26
 
27
27
  const { proxy:vm } = getCurrentInstance();
@@ -86,7 +86,8 @@ export default defineComponent({
86
86
  const validate = () => {
87
87
  if (props.Field.Required) {
88
88
  hasError.value = typeof fieldData.value === 'undefined' || !fieldData.value;
89
- return !hasError.value;
89
+
90
+ if (hasError.value) return false;
90
91
  }
91
92
 
92
93
  const rules = Array.isArray(typeof props.Field.Rules)
@@ -100,13 +101,19 @@ export default defineComponent({
100
101
  if (typeof r === 'function') {
101
102
  isValid = isValid && r(fieldData.value);
102
103
  }
104
+
105
+ if (!isValid) return false;
103
106
  }
104
107
 
105
108
  hasError.value = !isValid;
106
109
  return isValid;
107
110
  };
108
111
 
109
- defineExpose({
112
+ watch(() => fieldData.value, () => {
113
+ validate();
114
+ });
115
+
116
+ expose({
110
117
  validate,
111
118
  })
112
119
 
@@ -69,7 +69,7 @@ export default defineComponent({
69
69
  ...freeFieldProps,
70
70
  },
71
71
  emits: ['input'],
72
- setup(props, { emit, slots }){
72
+ setup(props, { emit, slots, expose }){
73
73
  if (!props.Field) return {};
74
74
 
75
75
  const { fieldData, setFieldData } = useFreeField(props);
@@ -86,6 +86,14 @@ export default defineComponent({
86
86
  class: 'field-label-empty'
87
87
  });
88
88
 
89
+ const validate = () => {
90
+ if (props.Field?.Required) {
91
+ return fieldData.value === true;
92
+ }
93
+
94
+ return true;
95
+ };
96
+
89
97
  const checkboxNode = () => h(QCheckbox, {
90
98
  disable: props.Field?.ReadOnly,
91
99
  label: props.Field?.showLabel ? '' : props.Field?.Label,
@@ -96,6 +104,10 @@ export default defineComponent({
96
104
  'onUpdate:modelValue': (v) => {
97
105
  setFieldData(v, emit);
98
106
  },
107
+ });
108
+
109
+ expose({
110
+ validate,
99
111
  })
100
112
 
101
113
  return () => h('div', {
@@ -114,7 +114,7 @@ function parseStaticResourceParams(paramStr, route) {
114
114
 
115
115
  let finalParamStr = paramStr || '';
116
116
 
117
- const paramList = paramStr.match(/\{[^\}]+\}/g);
117
+ const paramList = paramStr.match(/\{[^\\}]+\}/g);
118
118
  const paramValuesMap = {};
119
119
  for (let i = 0; i < paramList.length; i += 1) {
120
120
  const varItem = paramList[i];
@@ -136,7 +136,7 @@ function parseStaticResourceParams(paramStr, route) {
136
136
 
137
137
  let finalParamStr = paramStr || '';
138
138
 
139
- const paramList = paramStr.match(/\{[^\}]+\}/g);
139
+ const paramList = paramStr.match(/\{[^\\}]+\}/g);
140
140
  const paramValuesMap = {};
141
141
  for (let i = 0; i < paramList.length; i += 1) {
142
142
  const varItem = paramList[i];
@@ -121,7 +121,7 @@ export default defineComponent({
121
121
  {
122
122
  Label: '标题',
123
123
  Name: 'Label',
124
- style: 'max-width: 300px; min-width: 100px',
124
+ style: 'max-width: 300px; min-width: 100px;white-space: wrap; text-align: left;',
125
125
  sortable: true,
126
126
  },
127
127
  {
@@ -123,7 +123,7 @@ function parseStaticResourceParams(paramStr, route) {
123
123
 
124
124
  let finalParamStr = paramStr || '';
125
125
 
126
- const paramList = paramStr.match(/\{[^\}]+\}/g);
126
+ const paramList = paramStr.match(/\{[^\\}]+\}/g);
127
127
  const paramValuesMap = {};
128
128
  for (let i = 0; i < paramList.length; i += 1) {
129
129
  const varItem = paramList[i];
@@ -115,7 +115,7 @@ function parseStaticResourceParams(paramStr, route) {
115
115
 
116
116
  let finalParamStr = paramStr || '';
117
117
 
118
- const paramList = paramStr.match(/\{[^\}]+\}/g);
118
+ const paramList = paramStr.match(/\{[^\\}]+\}/g);
119
119
  const paramValuesMap = {};
120
120
  for (let i = 0; i < paramList.length; i += 1) {
121
121
  const varItem = paramList[i];
@@ -138,7 +138,11 @@ export default defineComponent({
138
138
  },
139
139
  computed: {
140
140
  rowClasses() {
141
- return this.Field.Options?.NoWrap ? 'nowrap' : '' + this.Field.Options?.ItemsAlign + ' ' + this.Field.Options?.JustifyAlign;
141
+ const wrap = this.Field.Options?.NoWrap ? 'nowrap' : '';
142
+ const itemsAlign = this.Field.Options?.ItemsAlign || '';
143
+ const justifyAlign = this.Field.Options?.JustifyAlign || '';
144
+
145
+ return [wrap, itemsAlign, justifyAlign].filter((cls) => cls).join(' ');
142
146
  },
143
147
  },
144
148
  });
@@ -68,7 +68,7 @@
68
68
  @keyup.stop
69
69
  @input="innerExtraFieldInput(fld)"
70
70
  v-for="(fld, idx) in selectedOptionsExtra" :key="idx"
71
- :Field="{...fld, ReadOnly: Field.ReadOnly || fld.ReadOnly}"
71
+ :Field="{...fld, ReadOnly: Field.ReadOnly || fld?.ReadOnly}"
72
72
  :values="values"
73
73
  ref="fieldToValid">
74
74
  </free-field>
@@ -128,7 +128,7 @@
128
128
  @keyup.stop
129
129
  @input="innerExtraFieldInput(fld)"
130
130
  v-for="(fld, idx) in option.InnerExtra || []" :key="idx"
131
- :Field="{...fld, ReadOnly: Field.ReadOnly || fld.ReadOnly}"
131
+ :Field="{...fld, ReadOnly: Field.ReadOnly || fld?.ReadOnly}"
132
132
  :values="values"
133
133
  ref="fieldToValid">
134
134
  </free-field>
@@ -470,7 +470,7 @@ export default defineComponent({
470
470
  opts = (localOptions.value || []).filter((opt) => opt.Value === fieldData.value);
471
471
  }
472
472
 
473
- return opts.map((opt) => opt.Extra).flat();
473
+ return opts.map((opt) => opt.Extra).flat().filter((f) => f?.Name || f?.Label);
474
474
  });
475
475
 
476
476
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-fe-core-modules",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/freeeis/free-fe-core-modules.git",
6
6
  "author": "zhiquan",