@xmszm/core 0.0.4 → 0.0.6

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/dist/style.css CHANGED
@@ -1 +1 @@
1
- .filter-box[data-v-2aba8b9e]{padding:20px;margin:-16px -28px -20px;box-sizing:border-box}.filter-main[data-v-2aba8b9e]{display:flex;align-content:flex-start;flex-wrap:wrap;min-height:500px;max-height:700px;overflow-y:auto;row-gap:20px;padding:0 0 15px;box-sizing:border-box}.filter-main .filter-item[data-v-2aba8b9e]{--info-color: var(--e0ecc754);--n-border-checked: 1px solid var(--info-color) !important;--n-border-focus: 1px solid var(--info-color) !important;--n-color-checked: var(--info-color) !important;--n-box-shadow-focus: 0 0 0 2px #6a1f7403 !important;width:calc(100% / 3)}.filter-footer[data-v-2aba8b9e]{display:flex;justify-content:space-between;align-items:center}.filter-footer .submit-btn[data-v-2aba8b9e]{width:80px}[data-v-9de17e68] .n-data-table-tr--summary{position:sticky;bottom:0;left:0;right:0;z-index:2}[data-v-9de17e68] .n-data-table-tr--summary .n-data-table-td--summary{border-top:1px solid var(--n-merged-border-color)}.upload-box[data-v-54e2cc87]{width:auto}.upload-box[data-v-54e2cc87] .n-upload-file-list.n-upload-file-list--grid{display:flex;flex-wrap:wrap}.upload-box[data-v-54e2cc87] .n-upload-file.n-upload-file--image-card-type{width:var(--image-w);height:var(--image-h)}.upload-box[data-v-54e2cc87] .n-upload-file.n-upload-file--image-card-type .n-image img{object-fit:var(--image-mode)!important}.upload-box[data-v-54e2cc87] .n-upload-trigger--image-card{width:var(--image-w);height:var(--image-h)}.upload-box[data-v-54e2cc87] .n-upload-file--error-status:not(:hover) .n-upload-file-info,.upload-box[data-v-54e2cc87] .n-upload-file--info-status:not(:hover) .n-upload-file-info{position:relative}.upload-box[data-v-54e2cc87] .n-upload-file--error-status:not(:hover) .n-upload-file-info:after,.upload-box[data-v-54e2cc87] .n-upload-file--info-status:not(:hover) .n-upload-file-info:after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;z-index:5;display:block;background-color:#0006}.upload-box[data-v-54e2cc87] .n-upload-file--error-status:not(:hover):after{font-size:12px;white-space:nowrap;content:"上传失败~";position:absolute;color:#ffffffbf;top:50%;left:50%;transform:translate(-50%,-50%);z-index:5;display:block}.upload-box[data-v-54e2cc87] .n-upload-file--info-status:not(:hover):after{font-size:12px;white-space:nowrap;content:"加载中~";position:absolute;color:#ffffffbf;top:50%;left:50%;transform:translate(-50%,-50%);z-index:5;display:block}.svg-icon[data-v-9dbe5f10]{width:inherit;height:inherit;fill:currentColor;vertical-align:middle}.core-dialog-main,.core-dialog-content{box-sizing:border-box;display:flex;align-items:flex-start}.core-dialog-main{min-height:300px}.core-dialog .n-dialog__content{overflow-y:auto;margin:10px -28px 0;box-sizing:border-box;flex:1;border-top:1px solid #91919147;border-bottom:1px solid #91919147;padding:28px}.core-dialog .n-dialog__action{padding:20px 0 0;box-sizing:border-box}.core-dialog-read .n-dialog__content{border-bottom:unset}.select-text[data-v-643f6214]{min-width:100px;max-width:240px;text-align:center}.select-line-text[data-v-643f6214]{text-align:center;white-space:nowrap;display:inline}
1
+ .filter-box[data-v-ffb0cfbf]{padding:20px;margin:-16px -28px -20px;box-sizing:border-box}.filter-main[data-v-ffb0cfbf]{display:flex;align-content:flex-start;flex-wrap:wrap;min-height:500px;max-height:700px;overflow-y:auto;row-gap:20px;padding:0 0 15px;box-sizing:border-box}.filter-main .filter-item[data-v-ffb0cfbf]{--info-color: var(--v56ebba65);--n-border-checked: 1px solid var(--info-color) !important;--n-border-focus: 1px solid var(--info-color) !important;--n-color-checked: var(--info-color) !important;--n-box-shadow-focus: 0 0 0 2px #6a1f7403 !important;width:calc(100% / 3)}.filter-footer[data-v-ffb0cfbf]{display:flex;justify-content:space-between;align-items:center}.filter-footer .submit-btn[data-v-ffb0cfbf]{width:80px}[data-v-057650fc] .n-data-table-tr--summary{position:sticky;bottom:0;left:0;right:0;z-index:2}[data-v-057650fc] .n-data-table-tr--summary .n-data-table-td--summary{border-top:1px solid var(--n-merged-border-color)}.upload-box[data-v-29718977]{width:auto}.upload-box[data-v-29718977] .n-upload-file-list.n-upload-file-list--grid{display:flex;flex-wrap:wrap}.upload-box[data-v-29718977] .n-upload-file.n-upload-file--image-card-type{width:var(--image-w);height:var(--image-h)}.upload-box[data-v-29718977] .n-upload-file.n-upload-file--image-card-type .n-image img{object-fit:var(--image-mode)!important}.upload-box[data-v-29718977] .n-upload-trigger--image-card{width:var(--image-w);height:var(--image-h)}.upload-box[data-v-29718977] .n-upload-file--error-status:not(:hover) .n-upload-file-info,.upload-box[data-v-29718977] .n-upload-file--info-status:not(:hover) .n-upload-file-info{position:relative}.upload-box[data-v-29718977] .n-upload-file--error-status:not(:hover) .n-upload-file-info:after,.upload-box[data-v-29718977] .n-upload-file--info-status:not(:hover) .n-upload-file-info:after{content:"";position:absolute;top:0;left:0;right:0;bottom:0;z-index:5;display:block;background-color:#0006}.upload-box[data-v-29718977] .n-upload-file--error-status:not(:hover):after{font-size:12px;white-space:nowrap;content:"上传失败~";position:absolute;color:#ffffffbf;top:50%;left:50%;transform:translate(-50%,-50%);z-index:5;display:block}.upload-box[data-v-29718977] .n-upload-file--info-status:not(:hover):after{font-size:12px;white-space:nowrap;content:"加载中~";position:absolute;color:#ffffffbf;top:50%;left:50%;transform:translate(-50%,-50%);z-index:5;display:block}.svg-icon[data-v-9dbe5f10]{width:inherit;height:inherit;fill:currentColor;vertical-align:middle}.core-dialog-main,.core-dialog-content{box-sizing:border-box;display:flex;align-items:flex-start}.core-dialog-main{min-height:300px}.core-dialog .n-dialog__content{overflow-y:auto;margin:10px -28px 0;box-sizing:border-box;flex:1;border-top:1px solid #91919147;border-bottom:1px solid #91919147;padding:28px;max-height:70vh}.core-dialog .n-dialog__action{padding:20px 0 0;box-sizing:border-box}.core-dialog-read .n-dialog__content{border-bottom:unset}.flex-1[data-v-e03318bb]{flex:1}.select-text[data-v-e03318bb]{min-width:100px;max-width:240px;text-align:center}.select-line-text[data-v-e03318bb]{text-align:center;white-space:nowrap;display:inline}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xmszm/core",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "naiveui core 组件与工具库",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.cjs",
@@ -26,7 +26,11 @@
26
26
  "require": "./dist/plugin/vite/initRouteMeta.cjs",
27
27
  "types": "./types/plugin/vite/initRouteMeta.d.ts"
28
28
  },
29
- "./dist/style.css": "./dist/style.css",
29
+ "./dist/style.css": {
30
+ "import": "./dist/style.css",
31
+ "require": "./dist/style.css",
32
+ "types": "./types/style.d.ts"
33
+ },
30
34
  "./package.json": "./package.json"
31
35
  },
32
36
  "files": [
@@ -6,6 +6,7 @@ import type { CommonDialogOptions, DialogAction } from '../../types/components'
6
6
  import type { CommonDialogResult } from '../../types'
7
7
  import DataForm from '../form/DataForm.vue'
8
8
  import { dialogDefaultOption } from './utils/dialog'
9
+ import { getDialogConfig } from '../utils/config'
9
10
  import './style/commonDialog.less'
10
11
 
11
12
  // 声明全局 $dialog 变量(外部可能注入)
@@ -238,9 +239,13 @@ export function commonDialogMethod(
238
239
  )
239
240
  : null
240
241
 
242
+ // 获取配置系统中的默认选项,优先使用配置系统的配置
243
+ const configDefaultOption = getDialogConfig()?.defaultOption || {}
244
+ const mergedDefaultOption = { ...dialogDefaultOption, ...configDefaultOption }
245
+
241
246
  const d = dialogInstance.create({
242
247
  type: 'info',
243
- ...dialogDefaultOption,
248
+ ...mergedDefaultOption,
244
249
  ...(!noTitle
245
250
  ? { title: titleRender || (defaultModeEnum[mode]?.sub ?? '') + title }
246
251
  : {}),
@@ -10,6 +10,7 @@
10
10
  .core-dialog-main {
11
11
  min-height: 300px;
12
12
  }
13
+
13
14
  .core-dialog-content {
14
15
  // border-top: 1px solid #91919147;
15
16
  }
@@ -24,6 +25,7 @@
24
25
  border-bottom: 1px solid #91919147;
25
26
  padding: 28px;
26
27
  // max-height: 500px;
28
+ max-height: 70vh;
27
29
  }
28
30
 
29
31
  .n-dialog__action {
@@ -33,7 +35,7 @@
33
35
  }
34
36
 
35
37
 
36
- .core-dialog-read{
38
+ .core-dialog-read {
37
39
  .n-dialog__content {
38
40
  border-bottom: unset;
39
41
  }
@@ -1,9 +1,9 @@
1
1
  <script setup lang="jsx">
2
2
  // import { FilePath } from '@/api/upload'
3
- import dayjs from 'dayjs'
4
- import { ref, watch } from 'vue'
5
- import { customUpload,getFileUrl } from '../utils/upload'
6
-
3
+ import dayjs from "dayjs";
4
+ import { ref, watch } from "vue";
5
+ import { customUpload, getFileUrl } from "../utils/upload";
6
+ import { NUpload, NSpace } from "naive-ui";
7
7
  const props = defineProps({
8
8
  value: {
9
9
  type: [Array, String],
@@ -39,27 +39,27 @@ const props = defineProps({
39
39
  },
40
40
  mode: {
41
41
  type: String,
42
- default: () => 'fill',
42
+ default: () => "fill",
43
43
  },
44
- formData:{
44
+ formData: {
45
45
  type: Object,
46
46
  default: () => {},
47
- }
48
- })
47
+ },
48
+ });
49
49
 
50
- const emit = defineEmits(['update:value', 'complete'])
50
+ const emit = defineEmits(["update:value", "complete"]);
51
51
 
52
- const FilePath = '/admin/file'
52
+ const FilePath = "/admin/file";
53
53
 
54
- const _value = ref([])
54
+ const _value = ref([]);
55
55
  watch(
56
56
  () => props.value,
57
57
  (value) => {
58
- console.log('props.value', value)
59
- _value.value
60
- = props.max === 1
58
+ console.log("props.value", value);
59
+ _value.value =
60
+ props.max === 1
61
61
  ? value
62
- ? typeof value !== 'string'
62
+ ? typeof value !== "string"
63
63
  ? value?.length
64
64
  ? [
65
65
  {
@@ -68,7 +68,7 @@ watch(
68
68
  url: getFileUrl(value[0]),
69
69
  thumbnailUrl: getFileUrl(value[0]),
70
70
  fullPath: value[0],
71
- status: 'finished',
71
+ status: "finished",
72
72
  },
73
73
  ]
74
74
  : []
@@ -79,85 +79,83 @@ watch(
79
79
  url: getFileUrl(value),
80
80
  fullPath: value,
81
81
  thumbnailUrl: getFileUrl(value),
82
- status: 'finished',
82
+ status: "finished",
83
83
  },
84
84
  ]
85
85
  : []
86
86
  : value?.map((v, i) => ({
87
- id: dayjs().valueOf() + i,
88
- name: `img${dayjs().valueOf()}`,
89
- url: getFileUrl(v),
90
- fullPath: v,
91
- thumbnailUrl: getFileUrl(v),
92
- status: 'finished',
93
- })) || []
87
+ id: dayjs().valueOf() + i,
88
+ name: `img${dayjs().valueOf()}`,
89
+ url: getFileUrl(v),
90
+ fullPath: v,
91
+ thumbnailUrl: getFileUrl(v),
92
+ status: "finished",
93
+ })) || [];
94
94
 
95
- console.log('1', _value.value)
95
+ console.log("1", _value.value);
96
96
  },
97
- { immediate: true },
98
- )
97
+ { immediate: true }
98
+ );
99
99
  function customRequestMethod(...arg) {
100
- sendImgRequest(arg[0])
100
+ sendImgRequest(arg[0]);
101
101
  }
102
102
 
103
103
  async function sendImgRequest({ file, onFinish, onError, onProgress }, fn) {
104
- const formData = new FormData()
105
- if (file.status === 'pending') {
106
- formData.append('file', file.file)
107
- if(props.formData && Object.keys(props.formData).length){
108
- Object.keys(props.formData).forEach(key => {
109
- formData.append(key, props.formData[key])
110
- })
104
+ const formData = new FormData();
105
+ if (file.status === "pending") {
106
+ formData.append("file", file.file);
107
+ if (props.formData && Object.keys(props.formData).length) {
108
+ Object.keys(props.formData).forEach((key) => {
109
+ formData.append(key, props.formData[key]);
110
+ });
111
111
  }
112
112
  customUpload({
113
113
  url: FilePath,
114
114
  data: formData,
115
- method: 'post',
115
+ method: "post",
116
116
  onUploadProgress: ({ percent }) => onProgress({ percent }),
117
117
  })
118
118
  .then((res) => {
119
- const { url } = res.data
120
- file.url = getFileUrl(url)
121
- file.fullPath = url
122
- file.thumbnailUrl = getFileUrl(url)
119
+ const { url } = res.data;
120
+ file.url = getFileUrl(url);
121
+ file.fullPath = url;
122
+ file.thumbnailUrl = getFileUrl(url);
123
123
  // onError()
124
- onFinish()
125
- onSubmit()
124
+ onFinish();
125
+ onSubmit();
126
126
  })
127
127
  .catch(() => {
128
- file = null
129
- onError()
128
+ file = null;
129
+ onError();
130
130
  })
131
131
  .finally(() => {
132
- fn && fn()
133
- })
132
+ fn && fn();
133
+ });
134
134
  }
135
135
  }
136
136
 
137
137
  function onSubmit() {
138
- console.log('onSubmit', _value.value)
138
+ console.log("onSubmit", _value.value);
139
139
 
140
140
  const arr = _value.value.reduce((o, n) => {
141
- if (n.status === 'finished' && n?.fullPath) {
142
- o.push(n.fullPath)
141
+ if (n.status === "finished" && n?.fullPath) {
142
+ o.push(n.fullPath);
143
143
  }
144
- return o
145
- }, [])
144
+ return o;
145
+ }, []);
146
146
  if (props.max === 1 && arr.length === 1) {
147
- emit('update:value', arr[0])
148
- }
149
- else if (arr.length) {
150
- emit('update:value', arr)
151
- }
152
- else {
153
- emit('update:value', props.max === 1 ? null : [])
147
+ emit("update:value", arr[0]);
148
+ } else if (arr.length) {
149
+ emit("update:value", arr);
150
+ } else {
151
+ emit("update:value", props.max === 1 ? null : []);
154
152
  }
155
153
  }
156
154
  </script>
157
155
 
158
156
  <template>
159
- <n-space align="end" :wrap-item="false">
160
- <n-upload
157
+ <NSpace align="end" :wrap-item="false">
158
+ <NUpload
161
159
  v-model:file-list="_value"
162
160
  accept=".jpeg,.jpg,.png"
163
161
  list-type="image-card"
@@ -176,9 +174,9 @@ function onSubmit() {
176
174
  ...(props.size
177
175
  ? { '--image-w': `${props.size}px`, '--image-h': `${props.size}px` }
178
176
  : {
179
- '--image-w': `${props.width}px`,
180
- '--image-h': `${props.height}px`,
181
- }),
177
+ '--image-w': `${props.width}px`,
178
+ '--image-h': `${props.height}px`,
179
+ }),
182
180
  '--image-mode': props.mode,
183
181
  }"
184
182
  @finish="
@@ -196,7 +194,7 @@ function onSubmit() {
196
194
  }
197
195
  "
198
196
  />
199
- </n-space>
197
+ </NSpace>
200
198
  </template>
201
199
 
202
200
  <style scoped lang="less">
@@ -224,7 +222,7 @@ function onSubmit() {
224
222
  .n-upload-file-info {
225
223
  position: relative;
226
224
  &::after {
227
- content: '';
225
+ content: "";
228
226
  position: absolute;
229
227
  top: 0;
230
228
  left: 0;
@@ -240,7 +238,7 @@ function onSubmit() {
240
238
  &::after {
241
239
  font-size: 12px;
242
240
  white-space: nowrap;
243
- content: '上传失败~';
241
+ content: "上传失败~";
244
242
  position: absolute;
245
243
  color: rgba(255, 255, 255, 0.75);
246
244
  top: 50%;
@@ -254,7 +252,7 @@ function onSubmit() {
254
252
  &::after {
255
253
  font-size: 12px;
256
254
  white-space: nowrap;
257
- content: '加载中~';
255
+ content: "加载中~";
258
256
  position: absolute;
259
257
  color: rgba(255, 255, 255, 0.75);
260
258
  top: 50%;
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ export {
6
6
  getAllOptions,
7
7
  getOptions,
8
8
  setupOptions,
9
+ default as setupInitOptions
9
10
  } from './options/defaultOptions'
10
11
  export { default as Options } from './options/Options'
11
12
  export { default as CommonQuery } from './query/CommonQuery.vue'
@@ -1,156 +1,167 @@
1
1
  <script setup lang="tsx">
2
- import { RefreshOutline, SearchOutline } from '@vicons/ionicons5'
3
- import type { CommonQueryProps, CommonQueryEmits, FormOption } from '../../types/components'
4
- import DataForm from '../form/DataForm.vue'
5
- import { getOptions } from '../options/defaultOptions'
6
- import { ObjectToArray } from '../utils/object'
7
- import { computed, onMounted, onUnmounted, ref, getCurrentInstance } from 'vue'
8
- import { NButton, NSpace } from 'naive-ui'
9
- import { registerDirectives } from '../directives/auto-register'
2
+ import { RefreshOutline, SearchOutline } from "@vicons/ionicons5";
3
+ import type {
4
+ CommonQueryProps,
5
+ CommonQueryEmits,
6
+ FormOption,
7
+ } from "../../types/components";
8
+ import DataForm from "../form/DataForm.vue";
9
+ import { getOptions } from "../options/defaultOptions";
10
+ import { ObjectToArray } from "../utils/object";
11
+ import { computed, onMounted, onUnmounted, ref, getCurrentInstance } from "vue";
12
+ import { NButton, NSpace } from "naive-ui";
13
+ import { registerDirectives } from "../directives/auto-register";
10
14
 
11
15
  // 自动注册指令
12
- const instance = getCurrentInstance()
16
+ const instance = getCurrentInstance();
13
17
  if (instance?.appContext?.app) {
14
- registerDirectives(instance.appContext.app)
18
+ registerDirectives(instance.appContext.app);
15
19
  }
16
20
 
17
21
  // 防抖函数
18
- function debounce<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void {
19
- let timeoutId: ReturnType<typeof setTimeout> | undefined
22
+ function debounce<T extends (...args: any[]) => any>(
23
+ func: T,
24
+ delay: number
25
+ ): (...args: Parameters<T>) => void {
26
+ let timeoutId: ReturnType<typeof setTimeout> | undefined;
20
27
  return function (...args: Parameters<T>) {
21
- clearTimeout(timeoutId)
28
+ clearTimeout(timeoutId);
22
29
  timeoutId = setTimeout(() => {
23
- func.apply(this, args)
24
- }, delay)
25
- }
30
+ func.apply(this, args);
31
+ }, delay);
32
+ };
26
33
  }
27
- const emit = defineEmits<CommonQueryEmits>()
34
+ const emit = defineEmits<CommonQueryEmits>();
28
35
 
29
36
  const props = withDefaults(defineProps<CommonQueryProps>(), {
30
37
  inlineText: true,
31
38
  options: () => [],
32
39
  query: () => ({}),
33
40
  selectCount: 1,
34
- type: 'primary',
41
+ type: "primary",
35
42
  noButton: false,
36
43
  isRead: false,
37
- btn: () => ['reset', 'search'],
38
- size: 'medium',
39
- })
44
+ btn: () => ["reset", "search"],
45
+ size: "medium",
46
+ });
40
47
 
41
48
  function onBeforeOptions(arr: FormOption[]): FormOption[] {
42
49
  return arr.map((v: FormOption) => ({
43
50
  ...v,
44
51
  props: {
45
52
  ...v.props,
46
- ...((!v.way || v.way === 'input') ? {
47
- onUpdateValue: (...args: any[]) => {
48
- ;(v.props as any)?.onUpdateValue?.(...args)
49
- debouncedSubmit()
50
- }
51
- } : {}),
52
- ...(v?.way === 'select' ? {
53
- onUpdateValue: (...args: any[]) => {
54
- ;(v.props as any)?.onUpdateValue?.(...args)
55
- debouncedSubmit()
56
- }
57
- } : {})
58
- }
59
- }))
53
+ ...(!v.way || v.way === "input"
54
+ ? {
55
+ onUpdateValue: (...args: any[]) => {
56
+ (v.props as any)?.onUpdateValue?.(...args);
57
+ debouncedSubmit();
58
+ },
59
+ }
60
+ : {}),
61
+ ...(v?.way === "select"
62
+ ? {
63
+ onUpdateValue: (...args: any[]) => {
64
+ (v.props as any)?.onUpdateValue?.(...args);
65
+ debouncedSubmit();
66
+ },
67
+ }
68
+ : {}),
69
+ },
70
+ }));
60
71
  }
61
72
 
62
73
  // 创建防抖的提交函数(500ms延迟)
63
74
  const debouncedSubmit = debounce(() => {
64
- emit('submit')
65
- }, 500)
75
+ emit("submit");
76
+ }, 500);
66
77
 
67
78
  function onSubmit() {
68
79
  // loading.value = true
69
- debouncedSubmit()
80
+ debouncedSubmit();
70
81
  // loading.value = false
71
82
  // return false
72
83
  }
73
- const loading = ref(false)
74
- const _query = defineModel('query', {
84
+ const loading = ref(false);
85
+ const _query = defineModel("query", {
75
86
  type: Object,
76
87
  default: () => ({}),
77
- })
88
+ });
78
89
 
79
90
  const defaultFormItemProps = {
80
91
  style: {
81
- width: '33%',
92
+ width: "33%",
82
93
  },
83
- }
94
+ };
84
95
  const _queryOptionsKey = computed(() =>
85
- props.options?.map(v => v?.way || 'input'),
86
- )
87
- const defaultOptions = getOptions(_queryOptionsKey.value)
96
+ props.options?.map((v) => v?.way || "input")
97
+ );
98
+ const defaultOptions = getOptions(_queryOptionsKey.value);
88
99
 
89
100
  const _queryOptions = computed(() => {
90
101
  try {
91
- const arr: FormOption[] = []
102
+ const arr: FormOption[] = [];
92
103
  for (let i = 0; i < (props.options?.length || 0); i++) {
93
- const v = props.options![i]
94
- if (v?.enum && !v?.options)
95
- v.options = ObjectToArray(v.enum)
104
+ const v = props.options![i];
105
+ if (v?.enum && !v?.options) v.options = ObjectToArray(v.enum);
96
106
  if (!v?.props) {
97
107
  v.props = {
98
108
  size: props.size,
99
- }
109
+ };
100
110
  }
101
111
 
102
112
  if (!v?.formItemProps) {
103
- v.formItemProps = { ...defaultFormItemProps }
104
- }
105
- else {
106
- const formItemProps = typeof v.formItemProps === 'function'
107
- ? v.formItemProps({}, {})
108
- : v.formItemProps
113
+ v.formItemProps = { ...defaultFormItemProps };
114
+ } else {
115
+ const formItemProps =
116
+ typeof v.formItemProps === "function"
117
+ ? v.formItemProps({}, {})
118
+ : v.formItemProps;
109
119
  v.formItemProps = {
110
120
  ...defaultFormItemProps,
111
121
  ...formItemProps,
112
- style: { ...defaultFormItemProps.style, ...(formItemProps as any)?.style },
113
- }
122
+ style: {
123
+ ...defaultFormItemProps.style,
124
+ ...(formItemProps as any)?.style,
125
+ },
126
+ };
114
127
  }
115
128
 
116
- const key = v?.key || (v as any)?.value
117
- if (!key)
118
- throw new Error('key no set')
129
+ const key = v?.key || (v as any)?.value;
130
+ if (!key) throw new Error("key no set");
119
131
  arr.push({
120
132
  ...v,
121
133
  key,
122
- })
134
+ });
123
135
  }
124
- return onBeforeOptions(arr)
125
- }
126
- catch (e) {
127
- console.warn('error', e)
128
- return []
136
+ return onBeforeOptions(arr);
137
+ } catch (e) {
138
+ console.warn("error", e);
139
+ return [];
129
140
  }
130
- })
141
+ });
131
142
 
132
143
  const classComponent = {
133
- input: '',
134
- select: '',
135
- dateRange: 'input-range',
136
- dateRangeTime: 'input-range-time',
137
- }
144
+ input: "",
145
+ select: "",
146
+ dateRange: "input-range",
147
+ dateRangeTime: "input-range-time",
148
+ };
138
149
  const defaultBtnProps = {
139
150
  style: {
140
- borderRadius: '3px',
151
+ borderRadius: "3px",
141
152
  },
142
- }
153
+ };
143
154
  const defaultBtn = {
144
155
  search: () => (
145
156
  <NButton
146
157
  type={props.type}
147
158
  loading={loading.value}
148
- default-props={{ attrType: 'submit' }}
159
+ default-props={{ attrType: "submit" }}
149
160
  onClick={() => onSubmit()}
150
161
  {...defaultBtnProps}
151
162
  >
152
163
  {{
153
- default: () => '搜索',
164
+ default: () => "搜索",
154
165
  icon: () => <SearchOutline />,
155
166
  }}
156
167
  </NButton>
@@ -159,53 +170,52 @@ const defaultBtn = {
159
170
  <NButton
160
171
  type="default"
161
172
  onClick={() => {
162
- clearQuery()
173
+ clearQuery();
163
174
  }}
164
175
  {...defaultBtnProps}
165
176
  >
166
177
  {{
167
- default: () => '重置',
178
+ default: () => "重置",
168
179
  icon: () => <RefreshOutline />,
169
180
  }}
170
181
  </NButton>
171
182
  ),
172
- }
183
+ };
173
184
 
174
185
  function clearQuery(): void {
175
186
  props.options?.forEach((v: FormOption) => {
176
- const key = (v?.key as string) || (v as any)?.value
187
+ const key = (v?.key as string) || (v as any)?.value;
177
188
  if (key) {
178
189
  if (v?.queryType) {
179
190
  if (!(_query.value as any)[v.queryType]) {
180
- (_query.value as any)[v.queryType] = {}
191
+ (_query.value as any)[v.queryType] = {};
181
192
  }
182
- (_query.value as any)[v.queryType][key] = null
183
- }
184
- else {
185
- (_query.value as any)[key] = null
193
+ (_query.value as any)[v.queryType][key] = null;
194
+ } else {
195
+ (_query.value as any)[key] = null;
186
196
  }
187
197
  }
188
- })
189
- emit('reset')
198
+ });
199
+ emit("reset");
190
200
  }
191
201
 
192
202
  // 全局监听 Enter 键的方法
193
203
  function handleGlobalEnter(event: KeyboardEvent): void {
194
204
  // 检查是否按下了 Enter 键
195
- if (event.key === 'Enter') {
196
- onSubmit()
205
+ if (event.key === "Enter") {
206
+ onSubmit();
197
207
  }
198
208
  }
199
209
 
200
210
  // 组件挂载时添加全局监听
201
211
  onMounted(() => {
202
- document.addEventListener('keydown', handleGlobalEnter)
203
- })
212
+ document.addEventListener("keydown", handleGlobalEnter);
213
+ });
204
214
 
205
215
  // 组件卸载时移除全局监听
206
216
  onUnmounted(() => {
207
- document.removeEventListener('keydown', handleGlobalEnter)
208
- })
217
+ document.removeEventListener("keydown", handleGlobalEnter);
218
+ });
209
219
  </script>
210
220
 
211
221
  <template>
@@ -233,6 +243,9 @@ onUnmounted(() => {
233
243
  </template>
234
244
 
235
245
  <style scoped lang="less">
246
+ .flex-1 {
247
+ flex: 1;
248
+ }
236
249
  .select-text {
237
250
  min-width: 100px;
238
251
  max-width: 240px;