free-fe-core-modules 0.0.37 → 0.0.38

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.
@@ -3,16 +3,16 @@
3
3
  <free-field
4
4
  v-for="(field, idx) in Field.Options?.Fields"
5
5
  :Field="field"
6
- :values="fieldData"
6
+ :values="fieldData.value"
7
7
  :key="idx"
8
8
  ref="fieldsToValidate"
9
- @input="$emit('input', field)"></free-field>
9
+ @input="changed"></free-field>
10
10
  </div>
11
11
  </template>
12
12
 
13
13
  <script>
14
14
  import { defineComponent } from 'vue';
15
- import { freeFieldProps } from '../composible/useFreeField';
15
+ import { freeFieldProps, useFreeField } from '../composible/useFreeField';
16
16
  import { useFormValidator} from '../../composible/useFormValidator';
17
17
 
18
18
  export default defineComponent({
@@ -119,13 +119,21 @@ export default defineComponent({
119
119
  ],
120
120
  Description: '',
121
121
  },
122
- setup(props) {
122
+ emits: ['input'],
123
+ setup(props, { emit }) {
123
124
  if(!props.Field) return () => null;
124
125
 
126
+ const { fieldData } = useFreeField(props);
125
127
  const { validate } = useFormValidator('fieldsToValidate');
126
128
 
127
129
  return {
130
+ fieldData,
128
131
  validate,
132
+
133
+ changed: (fld) => {
134
+ const newValue = props.Field.Name === '.' ? Object.nestValue(fieldData, fld.Name) : fieldData;
135
+ emit('input', newValue, props.Field.Name === '.' ? fld : props.Field);
136
+ }
129
137
  }
130
138
  },
131
139
  computed: {
@@ -165,6 +165,7 @@
165
165
  round size="20px"
166
166
  @click="showPreview=false"></q-icon>
167
167
  <q-img
168
+ fit="contain"
168
169
  v-if="previewType === 'image'"
169
170
  contain :src="previewFile"
170
171
  @click="showPreview=false"
@@ -3,17 +3,16 @@
3
3
  <free-field
4
4
  v-for="(field, idx) in Field.Options?.Fields"
5
5
  :Field="field"
6
- :values="fieldData"
6
+ :values="fieldData.value"
7
7
  :key="idx"
8
8
  ref="fieldsToValidate"
9
- @input="$emit('input', field)"></free-field>
9
+ @input="changed"></free-field>
10
10
  </div>
11
11
  </template>
12
12
 
13
13
  <script>
14
- // TODO: correct the validations
15
14
  import { defineComponent } from 'vue';
16
- import { freeFieldProps } from '../composible/useFreeField';
15
+ import { freeFieldProps, useFreeField } from '../composible/useFreeField';
17
16
  import { useFormValidator} from '../../composible/useFormValidator';
18
17
 
19
18
  export default defineComponent({
@@ -120,13 +119,21 @@ export default defineComponent({
120
119
  ],
121
120
  Description: '',
122
121
  },
123
- setup(props) {
122
+ emits: ['input'],
123
+ setup(props, { emit }) {
124
124
  if(!props.Field) return () => null;
125
125
 
126
+ const { fieldData } = useFreeField(props);
126
127
  const { validate } = useFormValidator('fieldsToValidate');
127
128
 
128
129
  return {
130
+ fieldData,
129
131
  validate,
132
+
133
+ changed: (fld) => {
134
+ const newValue = props.Field.Name === '.' ? Object.nestValue(fieldData, fld.Name) : fieldData;
135
+ emit('input', newValue, props.Field.Name === '.' ? fld : props.Field);
136
+ }
130
137
  }
131
138
  },
132
139
  computed: {
@@ -28,7 +28,7 @@
28
28
  <q-table
29
29
  :flat="Field.Options?.Flat"
30
30
  :bordered="Field.Options?.Bordered"
31
- :rows="searchData ? searchData.docs : []"
31
+ :rows="searchData.docs || []"
32
32
  :columns="searchColumns"
33
33
  row-key="id"
34
34
  :pagination="searchPagination"
@@ -200,6 +200,12 @@ export default defineComponent({
200
200
  Name: 'Options.SearchField',
201
201
  Default: 'id',
202
202
  },
203
+ {
204
+ Type: 'String',
205
+ Label: '搜索传输字段名',
206
+ Name: 'Options.SearchKeyName',
207
+ Default: 'search',
208
+ },
203
209
  {
204
210
  Type: 'String',
205
211
  Label: '显示字段',
@@ -423,9 +429,12 @@ export default defineComponent({
423
429
  return;
424
430
  }
425
431
 
432
+ const reqBody = {...(p ? {page: p} : {})};
433
+ reqBody[this.Field.Options?.SearchKeyName || 'search'] = this.searchKey;
434
+
426
435
  this.getRequest(
427
436
  this.Field.Options.SearchUrl,
428
- {search: this.searchKey, ...(p ? {page: p} : {})}
437
+ reqBody,
429
438
  )
430
439
  .then((d) => {
431
440
  if (d && d.msg === 'OK') {
@@ -196,8 +196,13 @@ export default defineComponent({
196
196
  props.Field.ReadOnly ? "free-field--readonly" : "",
197
197
  !shouldHide.value && hasError.value ? "hasError" : "",
198
198
  ],
199
- onInput: () => {
200
- emit("input", props.Field);
199
+ /**
200
+ *
201
+ * @param {any} _ value of the changed field
202
+ * @param {Field} fld the changed field (optional)
203
+ */
204
+ onInput: (_, fld) => {
205
+ emit("input", fld || props.Field);
201
206
  },
202
207
  ...compEmits.value,
203
208
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-fe-core-modules",
3
- "version": "0.0.37",
3
+ "version": "0.0.38",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/freeeis/free-fe-core-modules.git",
6
6
  "author": "zhiquan",