hlq-cli 1.0.0
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/README.md +18 -0
- package/bin/index.js +16 -0
- package/lib/aesCreate.js +11 -0
- package/lib/axiosCreate.js +11 -0
- package/lib/create.js +172 -0
- package/lib/echartCreate.js +12 -0
- package/lib/jwtDecodeCreate.js +16 -0
- package/lib/rsaCreate.js +11 -0
- package/lib/stateCreate.js +34 -0
- package/lib/websocketCreate.js +16 -0
- package/package.json +21 -0
- package/templates/.env +1 -0
- package/templates/.env.dev +2 -0
- package/templates/.env.pro +2 -0
- package/templates/index.html +15 -0
- package/templates/package-lock.json +4058 -0
- package/templates/package.json +31 -0
- package/templates/public/config.js +1 -0
- package/templates/public/font/iconfont.css +579 -0
- package/templates/public/font/iconfont.js +1 -0
- package/templates/public/font/iconfont.ttf +0 -0
- package/templates/public/font/iconfont.woff +0 -0
- package/templates/public/font/iconfont.woff2 +0 -0
- package/templates/src/App.vue +35 -0
- package/templates/src/components/chart/barChart.vue +103 -0
- package/templates/src/components/chart/color.ts +43 -0
- package/templates/src/components/chart/lineChart.vue +114 -0
- package/templates/src/components/chart/mapChart.vue +135 -0
- package/templates/src/components/chart/mixedChart.vue +148 -0
- package/templates/src/components/chart/pieChart.vue +104 -0
- package/templates/src/components/chart/radarChart.vue +112 -0
- package/templates/src/components/chart/scatterChart.vue +144 -0
- package/templates/src/components/chart/sunburstChart.vue +183 -0
- package/templates/src/components/descript/index.vue +45 -0
- package/templates/src/components/dialog/index.vue +54 -0
- package/templates/src/components/drawer/index.vue +53 -0
- package/templates/src/components/form/component/cascader.vue +65 -0
- package/templates/src/components/form/component/checkbox.vue +31 -0
- package/templates/src/components/form/component/datePicker.vue +39 -0
- package/templates/src/components/form/component/dateRange.vue +36 -0
- package/templates/src/components/form/component/datetimePicker.vue +25 -0
- package/templates/src/components/form/component/fileUpload.vue +80 -0
- package/templates/src/components/form/component/formFun.ts +132 -0
- package/templates/src/components/form/component/imageUpload.vue +92 -0
- package/templates/src/components/form/component/input.vue +41 -0
- package/templates/src/components/form/component/location.vue +79 -0
- package/templates/src/components/form/component/radio.vue +31 -0
- package/templates/src/components/form/component/select.vue +66 -0
- package/templates/src/components/form/component/textarea.vue +26 -0
- package/templates/src/components/form/component/timePicker.vue +28 -0
- package/templates/src/components/form/component/upload.ts +20 -0
- package/templates/src/components/form/formInterface.ts +115 -0
- package/templates/src/components/form/index.vue +193 -0
- package/templates/src/components/form/item.vue +323 -0
- package/templates/src/components/groupForm/index.vue +91 -0
- package/templates/src/components/icon/index.vue +29 -0
- package/templates/src/components/layout/header.vue +238 -0
- package/templates/src/components/layout/index.vue +167 -0
- package/templates/src/components/layout/menu.vue +130 -0
- package/templates/src/components/layout/sideBarItem.vue +49 -0
- package/templates/src/components/searchBox/height.ts +9 -0
- package/templates/src/components/searchBox/index.vue +265 -0
- package/templates/src/components/table/index.vue +371 -0
- package/templates/src/components/table/table.ts +23 -0
- package/templates/src/components/tree/index.vue +222 -0
- package/templates/src/components/tree/lazyTree.vue +136 -0
- package/templates/src/data.d.ts +4 -0
- package/templates/src/main.ts +18 -0
- package/templates/src/router/index.ts +60 -0
- package/templates/src/store/menuInterface.ts +10 -0
- package/templates/src/store/permission.ts +59 -0
- package/templates/src/store/user.ts +24 -0
- package/templates/src/utils/alioss/index.ts +0 -0
- package/templates/src/utils/axios/http.ts +99 -0
- package/templates/src/utils/axios/index.ts +112 -0
- package/templates/src/utils/axios/service.ts +8 -0
- package/templates/src/utils/crypto/index.ts +28 -0
- package/templates/src/utils/rsa/index.ts +18 -0
- package/templates/src/utils/token/index.ts +6 -0
- package/templates/src/utils/tree/index.ts +74 -0
- package/templates/src/utils/websocket/index.ts +136 -0
- package/templates/src/views/login/index.vue +248 -0
- package/templates/src/views/templete/table.vue +122 -0
- package/templates/src/views/templete/tableConfig.ts +153 -0
- package/templates/tsconfig.app.json +19 -0
- package/templates/tsconfig.json +7 -0
- package/templates/tsconfig.node.json +23 -0
- package/templates/vite.config.ts +34 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const upload = (props: any, state: any) => {
|
|
2
|
+
const handlePreview = (file: UploadUserFile) => {}
|
|
3
|
+
const handleFileDownload = (file: UploadUserFile) => {}
|
|
4
|
+
const beforeUpload = (file: UploadUserFile) => {}
|
|
5
|
+
const handleExceed = (file: UploadUserFile) => {}
|
|
6
|
+
const handleSuccess = (file: UploadUserFile) => {}
|
|
7
|
+
const handleRemove = (file: UploadUserFile) => {}
|
|
8
|
+
const httpRequest = (file: UploadUserFile) => {}
|
|
9
|
+
const handlePictureCardPreview = (file: UploadUserFile) => {}
|
|
10
|
+
return {
|
|
11
|
+
handlePreview,
|
|
12
|
+
handleFileDownload,
|
|
13
|
+
beforeUpload,
|
|
14
|
+
handleExceed,
|
|
15
|
+
handleSuccess,
|
|
16
|
+
handleRemove,
|
|
17
|
+
httpRequest,
|
|
18
|
+
handlePictureCardPreview,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// 下拉框数据结构
|
|
2
|
+
interface selectItem {
|
|
3
|
+
value: string | number // 唯一编码
|
|
4
|
+
label: string // 名称
|
|
5
|
+
}
|
|
6
|
+
// 级联框数据结构
|
|
7
|
+
interface cascaderItem {
|
|
8
|
+
value: string | number // 唯一编码
|
|
9
|
+
label: string // 名称
|
|
10
|
+
children?: Array<cascaderItem>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// 表单配置
|
|
14
|
+
interface FormConfig {
|
|
15
|
+
labelPosition?: 'left' | 'right' | 'top' // 标签位置
|
|
16
|
+
inline?: boolean // 是否内联
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// 表单子项配置
|
|
20
|
+
type FormItemConfig = FormItemDataConfig | FormEmptyConfig | FormCostomConfig
|
|
21
|
+
// 表单子项配置(非空)
|
|
22
|
+
type FormItemDataConfig =
|
|
23
|
+
| FormInputConfig
|
|
24
|
+
| FormSelectConfig
|
|
25
|
+
| FormCascaderConfig
|
|
26
|
+
| FormDateConfig
|
|
27
|
+
| FormDateRangeConfig
|
|
28
|
+
| FormUploadConfig
|
|
29
|
+
| FormCheckBoxConfig
|
|
30
|
+
| FormLocationConfig
|
|
31
|
+
// 表单子项公共配置
|
|
32
|
+
interface FormBaseConfig {
|
|
33
|
+
label: string // 名称
|
|
34
|
+
key: string // 字段
|
|
35
|
+
type: string // 类型
|
|
36
|
+
placeholder?: string // 占位符
|
|
37
|
+
disabled?: boolean
|
|
38
|
+
defaultValue?: string | number | boolean | Array<string | number>
|
|
39
|
+
span?: number // 布局
|
|
40
|
+
required?: boolean // 是否必填
|
|
41
|
+
rules?: Array<Data> // 特殊规则
|
|
42
|
+
show?: string // 显示规则
|
|
43
|
+
linkage?: Array<{
|
|
44
|
+
key: string | string[] // 关联字段
|
|
45
|
+
type: 'clear' | 'filter' | 'show' // 联动类型
|
|
46
|
+
}> // 联动属性
|
|
47
|
+
describe?: string // 描述
|
|
48
|
+
}
|
|
49
|
+
interface FormOptionsConfig {
|
|
50
|
+
options: Array<selectItem> // 选项
|
|
51
|
+
optionsProps?: any
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface FormInputConfig extends FormBaseConfig {
|
|
55
|
+
type: 'input' | 'textarea' | 'number' | 'password' // 类型
|
|
56
|
+
}
|
|
57
|
+
interface FormLocationConfig extends FormBaseConfig {
|
|
58
|
+
type: 'location' // 类型
|
|
59
|
+
labels: string[] // 标签名称
|
|
60
|
+
keys: string[] // 字段名称
|
|
61
|
+
}
|
|
62
|
+
interface FormSelectConfig extends FormBaseConfig, FormOptionsConfig {
|
|
63
|
+
type: 'select' // 类型
|
|
64
|
+
isMore?: boolean // 是否多选
|
|
65
|
+
}
|
|
66
|
+
interface FormCascaderConfig extends FormBaseConfig, FormOptionsConfig {
|
|
67
|
+
type: 'cascader' // 类型
|
|
68
|
+
isMore?: boolean // 是否多选
|
|
69
|
+
}
|
|
70
|
+
interface FormDateConfig extends FormBaseConfig {
|
|
71
|
+
type:
|
|
72
|
+
| 'datePicker'
|
|
73
|
+
| 'datetimePicker'
|
|
74
|
+
| 'datesPicker'
|
|
75
|
+
| 'weekPicker'
|
|
76
|
+
| 'yearPicker'
|
|
77
|
+
| 'yearsPicker'
|
|
78
|
+
| 'monthPicker'
|
|
79
|
+
| 'monthsPicker'
|
|
80
|
+
| 'timePicker' // 类型
|
|
81
|
+
format?: string // 展示格式
|
|
82
|
+
valueFormat?: string // 绑定格式
|
|
83
|
+
disabledDate?: (date: Date) => boolean
|
|
84
|
+
}
|
|
85
|
+
interface FormDateRangeConfig extends FormBaseConfig {
|
|
86
|
+
type: 'dateRange' | 'monthRange' | 'yearRange' // 类型
|
|
87
|
+
startPlaceholder?: string // 占位符
|
|
88
|
+
endPlaceholder?: string // 占位符
|
|
89
|
+
format?: string // 展示格式
|
|
90
|
+
valueFormat?: string // 绑定格式
|
|
91
|
+
}
|
|
92
|
+
interface FormCheckBoxConfig extends FormBaseConfig, FormOptionsConfig {
|
|
93
|
+
type: 'checkbox' | 'radio' // 类型
|
|
94
|
+
}
|
|
95
|
+
interface FormUploadConfig extends FormBaseConfig {
|
|
96
|
+
type: 'fileUpload' | 'imageUpload' // 类型
|
|
97
|
+
fileType?: string // 文件类型(以,分隔) 视频:video/* 图片:image/*
|
|
98
|
+
tip?: string // 提示文字
|
|
99
|
+
limit?: number // 最大上传数量(默认10)
|
|
100
|
+
}
|
|
101
|
+
interface FormEmptyConfig {
|
|
102
|
+
span?: number
|
|
103
|
+
type: 'empty'
|
|
104
|
+
show?: string // 显示规则
|
|
105
|
+
}
|
|
106
|
+
interface FormCostomConfig {
|
|
107
|
+
type: 'custom'
|
|
108
|
+
propsCode: string // 自定义组件标识
|
|
109
|
+
span?: number
|
|
110
|
+
show?: string // 显示规则
|
|
111
|
+
label: string // 名称
|
|
112
|
+
key: string // 字段
|
|
113
|
+
required?: boolean // 是否必填
|
|
114
|
+
rules?: Array<Data> // 特殊规则
|
|
115
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="formBox">
|
|
3
|
+
<!-- <div class="clearBox">
|
|
4
|
+
<el-button type="danger" size="small" @click="clear">全部重置</el-button>
|
|
5
|
+
</div> -->
|
|
6
|
+
<el-form
|
|
7
|
+
ref="formRef"
|
|
8
|
+
:model="form"
|
|
9
|
+
label-width="auto"
|
|
10
|
+
:labelPosition="formConfig.labelPosition"
|
|
11
|
+
:inline="true"
|
|
12
|
+
:rules="rules"
|
|
13
|
+
>
|
|
14
|
+
<div class="inlineBox">
|
|
15
|
+
<template v-for="item in state.formItemConfig">
|
|
16
|
+
<el-col
|
|
17
|
+
:span="item.span || 24"
|
|
18
|
+
v-show="item.show ? getShow(item.show, form) : true"
|
|
19
|
+
>
|
|
20
|
+
<el-form-item
|
|
21
|
+
:prop="item.key"
|
|
22
|
+
:label="item.label + ':'"
|
|
23
|
+
v-if="item.type !== 'empty'"
|
|
24
|
+
>
|
|
25
|
+
<!-- type为costom时,使用插槽,外部传入组件 -->
|
|
26
|
+
<template v-if="item.type === 'custom'">
|
|
27
|
+
<slot :name="item.propsCode"></slot>
|
|
28
|
+
</template>
|
|
29
|
+
<template v-else>
|
|
30
|
+
<formItem
|
|
31
|
+
:config="item"
|
|
32
|
+
:formData="form"
|
|
33
|
+
:onlyRead="onlyRead"
|
|
34
|
+
></formItem>
|
|
35
|
+
<template v-if="item.describe">
|
|
36
|
+
<div
|
|
37
|
+
style="
|
|
38
|
+
margin-top: 4px;
|
|
39
|
+
color: #aaa;
|
|
40
|
+
font-size: 12px;
|
|
41
|
+
line-height: 14px;
|
|
42
|
+
"
|
|
43
|
+
v-html="item.describe"
|
|
44
|
+
></div>
|
|
45
|
+
</template>
|
|
46
|
+
</template>
|
|
47
|
+
</el-form-item>
|
|
48
|
+
</el-col>
|
|
49
|
+
</template>
|
|
50
|
+
</div>
|
|
51
|
+
</el-form>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
<script lang="ts" setup>
|
|
55
|
+
import { reactive, ref, watch } from 'vue'
|
|
56
|
+
import formItem from './item.vue'
|
|
57
|
+
import type { FormRules } from 'element-plus'
|
|
58
|
+
import { cloneDeep } from 'lodash'
|
|
59
|
+
import { PublicData } from '@/utils/crypto/index.js'
|
|
60
|
+
|
|
61
|
+
interface Props {
|
|
62
|
+
formItemConfig?: FormItemConfig[]
|
|
63
|
+
formConfig?: FormConfig
|
|
64
|
+
formData?: Data
|
|
65
|
+
onlyRead?: boolean
|
|
66
|
+
}
|
|
67
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
68
|
+
formConfig: () => {
|
|
69
|
+
return {}
|
|
70
|
+
},
|
|
71
|
+
formItemConfig: () => [],
|
|
72
|
+
})
|
|
73
|
+
const form = ref<Data>({ ...props.formData })
|
|
74
|
+
const rules = ref<FormRules>({})
|
|
75
|
+
const formRef = ref()
|
|
76
|
+
const state = reactive({
|
|
77
|
+
formItemConfig: [] as FormItemConfig[],
|
|
78
|
+
oldFormData: {},
|
|
79
|
+
})
|
|
80
|
+
const clear = () => {
|
|
81
|
+
// formRef.value?.resetFields();
|
|
82
|
+
form.value = { ...state.oldFormData }
|
|
83
|
+
}
|
|
84
|
+
let fundata
|
|
85
|
+
const getShow = (val: string, data: Data) => {
|
|
86
|
+
fundata = data
|
|
87
|
+
return eval(val)
|
|
88
|
+
}
|
|
89
|
+
// 校验
|
|
90
|
+
const valid = async () => {
|
|
91
|
+
return new Promise(async (resolve) => {
|
|
92
|
+
await formRef.value.validate((valid: boolean) => {
|
|
93
|
+
resolve(valid)
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
const getFormData = () => {
|
|
98
|
+
const formData = cloneDeep(form.value)
|
|
99
|
+
state.formItemConfig.forEach((item: FormItemConfig) => {
|
|
100
|
+
if (item.type === 'password') {
|
|
101
|
+
if (formData[item.key].length > 20) {
|
|
102
|
+
} else {
|
|
103
|
+
formData[item.key] = formData[item.key]
|
|
104
|
+
? PublicData(formData[item.key])
|
|
105
|
+
: ''
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
return formData
|
|
110
|
+
}
|
|
111
|
+
const getFormBefore = () => {
|
|
112
|
+
return form.value
|
|
113
|
+
}
|
|
114
|
+
const init = () => {
|
|
115
|
+
state.formItemConfig.forEach((item: FormItemConfig) => {
|
|
116
|
+
if (item.type === 'empty' || item.type === 'custom') {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
if (item.rules || item.required) {
|
|
120
|
+
rules.value[item.key] = item.rules || []
|
|
121
|
+
switch (item.type) {
|
|
122
|
+
case 'input':
|
|
123
|
+
case 'textarea':
|
|
124
|
+
if (item.required) {
|
|
125
|
+
;(rules.value[item.key] as Array<Data>).push({
|
|
126
|
+
required: true,
|
|
127
|
+
message: '请输入' + item.label,
|
|
128
|
+
trigger: 'blur',
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
break
|
|
132
|
+
default:
|
|
133
|
+
if (item.required) {
|
|
134
|
+
;(rules.value[item.key] as Array<Data>).push({
|
|
135
|
+
required: true,
|
|
136
|
+
message: '请输入' + item.label,
|
|
137
|
+
trigger: 'blur',
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
break
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
const emits = defineEmits(['dataChange'])
|
|
146
|
+
defineExpose({ getFormData, valid, clear, getFormBefore })
|
|
147
|
+
watch(
|
|
148
|
+
() => props.formData,
|
|
149
|
+
(val) => {
|
|
150
|
+
form.value = { ...val }
|
|
151
|
+
state.oldFormData = { ...val }
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
deep: true,
|
|
155
|
+
},
|
|
156
|
+
)
|
|
157
|
+
watch(
|
|
158
|
+
() => form.value,
|
|
159
|
+
(val) => {
|
|
160
|
+
emits('dataChange', val)
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
deep: true,
|
|
164
|
+
},
|
|
165
|
+
)
|
|
166
|
+
watch(
|
|
167
|
+
() => props.formItemConfig,
|
|
168
|
+
() => {
|
|
169
|
+
state.formItemConfig = cloneDeep(props.formItemConfig)
|
|
170
|
+
init()
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
deep: true,
|
|
174
|
+
immediate: true,
|
|
175
|
+
},
|
|
176
|
+
)
|
|
177
|
+
</script>
|
|
178
|
+
<style lang="scss" scoped>
|
|
179
|
+
:deep() {
|
|
180
|
+
.el-form-item {
|
|
181
|
+
width: 100%;
|
|
182
|
+
margin: 0 0 24px 0;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
.inlineBox {
|
|
186
|
+
display: flex;
|
|
187
|
+
flex-wrap: wrap;
|
|
188
|
+
flex: 1;
|
|
189
|
+
}
|
|
190
|
+
.clearBox {
|
|
191
|
+
margin-bottom: 12px;
|
|
192
|
+
}
|
|
193
|
+
</style>
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<template
|
|
3
|
+
v-if="
|
|
4
|
+
config.type === 'input' ||
|
|
5
|
+
config.type === 'number' ||
|
|
6
|
+
config.type === 'password'
|
|
7
|
+
"
|
|
8
|
+
>
|
|
9
|
+
<FormInput
|
|
10
|
+
:config="config"
|
|
11
|
+
:formData="formData"
|
|
12
|
+
:disabled="disabled"
|
|
13
|
+
:state="state"
|
|
14
|
+
@enter="enter"
|
|
15
|
+
@change="change"
|
|
16
|
+
></FormInput>
|
|
17
|
+
</template>
|
|
18
|
+
<template v-if="config.type === 'textarea'">
|
|
19
|
+
<FormTextarea
|
|
20
|
+
:config="config"
|
|
21
|
+
:formData="formData"
|
|
22
|
+
:state="state"
|
|
23
|
+
:disabled="disabled"
|
|
24
|
+
@change="change"
|
|
25
|
+
></FormTextarea>
|
|
26
|
+
</template>
|
|
27
|
+
<template v-else-if="config.type === 'select'">
|
|
28
|
+
<FormSelect
|
|
29
|
+
:config="config"
|
|
30
|
+
:formData="formData"
|
|
31
|
+
:state="state"
|
|
32
|
+
:disabled="disabled"
|
|
33
|
+
@change="change"
|
|
34
|
+
></FormSelect>
|
|
35
|
+
</template>
|
|
36
|
+
<template v-else-if="config.type === 'cascader'">
|
|
37
|
+
<FormCascader
|
|
38
|
+
:config="config"
|
|
39
|
+
:formData="formData"
|
|
40
|
+
:state="state"
|
|
41
|
+
:disabled="disabled"
|
|
42
|
+
@change="change"
|
|
43
|
+
></FormCascader>
|
|
44
|
+
</template>
|
|
45
|
+
<template
|
|
46
|
+
v-else-if="
|
|
47
|
+
config.type === 'datePicker' ||
|
|
48
|
+
config.type === 'datesPicker' ||
|
|
49
|
+
config.type === 'weekPicker' ||
|
|
50
|
+
config.type === 'yearPicker' ||
|
|
51
|
+
config.type === 'yearsPicker' ||
|
|
52
|
+
config.type === 'monthPicker' ||
|
|
53
|
+
config.type === 'monthsPicker'
|
|
54
|
+
"
|
|
55
|
+
>
|
|
56
|
+
<FormDatePicker
|
|
57
|
+
:config="config"
|
|
58
|
+
:formData="formData"
|
|
59
|
+
:state="state"
|
|
60
|
+
:disabled="disabled"
|
|
61
|
+
@change="change"
|
|
62
|
+
></FormDatePicker>
|
|
63
|
+
</template>
|
|
64
|
+
<template v-if="config.type === 'datetimePicker'">
|
|
65
|
+
<FormDateTimePicker
|
|
66
|
+
:config="config"
|
|
67
|
+
:formData="formData"
|
|
68
|
+
:state="state"
|
|
69
|
+
:disabled="disabled"
|
|
70
|
+
@change="change"
|
|
71
|
+
></FormDateTimePicker>
|
|
72
|
+
</template>
|
|
73
|
+
<template v-if="config.type === 'timePicker'">
|
|
74
|
+
<FormTimePicker
|
|
75
|
+
:config="config"
|
|
76
|
+
:formData="formData"
|
|
77
|
+
:state="state"
|
|
78
|
+
:disabled="disabled"
|
|
79
|
+
@change="change"
|
|
80
|
+
></FormTimePicker>
|
|
81
|
+
</template>
|
|
82
|
+
<template
|
|
83
|
+
v-else-if="
|
|
84
|
+
config.type === 'dateRange' ||
|
|
85
|
+
config.type === 'monthRange' ||
|
|
86
|
+
config.type === 'yearRange'
|
|
87
|
+
"
|
|
88
|
+
>
|
|
89
|
+
<FormDateRange
|
|
90
|
+
:config="config"
|
|
91
|
+
:formData="formData"
|
|
92
|
+
:state="state"
|
|
93
|
+
:disabled="disabled"
|
|
94
|
+
@change="change"
|
|
95
|
+
></FormDateRange>
|
|
96
|
+
</template>
|
|
97
|
+
<template v-else-if="config.type === 'fileUpload'">
|
|
98
|
+
<FormFileUpload
|
|
99
|
+
:config="config"
|
|
100
|
+
:formData="formData"
|
|
101
|
+
:state="state"
|
|
102
|
+
:disabled="disabled"
|
|
103
|
+
@change="change"
|
|
104
|
+
></FormFileUpload>
|
|
105
|
+
</template>
|
|
106
|
+
<template v-else-if="config.type === 'imageUpload'">
|
|
107
|
+
<FormImageUpload
|
|
108
|
+
:config="config"
|
|
109
|
+
:formData="formData"
|
|
110
|
+
:state="state"
|
|
111
|
+
:disabled="disabled"
|
|
112
|
+
@change="change"
|
|
113
|
+
></FormImageUpload>
|
|
114
|
+
</template>
|
|
115
|
+
<template v-else-if="config.type === 'checkbox'">
|
|
116
|
+
<FormCheckbox
|
|
117
|
+
:config="config"
|
|
118
|
+
:formData="formData"
|
|
119
|
+
:state="state"
|
|
120
|
+
:disabled="disabled"
|
|
121
|
+
@change="change"
|
|
122
|
+
></FormCheckbox>
|
|
123
|
+
</template>
|
|
124
|
+
<template v-else-if="config.type === 'radio'">
|
|
125
|
+
<FormRadio
|
|
126
|
+
:config="config"
|
|
127
|
+
:formData="formData"
|
|
128
|
+
:state="state"
|
|
129
|
+
:disabled="disabled"
|
|
130
|
+
@change="change"
|
|
131
|
+
></FormRadio>
|
|
132
|
+
</template>
|
|
133
|
+
<template v-else-if="config.type === 'location'">
|
|
134
|
+
<FormLocation
|
|
135
|
+
:config="config"
|
|
136
|
+
:formData="formData"
|
|
137
|
+
:state="state"
|
|
138
|
+
:disabled="disabled"
|
|
139
|
+
@change="change"
|
|
140
|
+
></FormLocation>
|
|
141
|
+
</template>
|
|
142
|
+
</template>
|
|
143
|
+
<script lang="ts" setup>
|
|
144
|
+
import { type UploadUserFile } from 'element-plus'
|
|
145
|
+
import { computed, onMounted, reactive, ref, watch } from 'vue'
|
|
146
|
+
import { isEmpty } from 'lodash'
|
|
147
|
+
import { useUserStore } from '@/store/user'
|
|
148
|
+
import FormInput from './component/input.vue'
|
|
149
|
+
import FormTextarea from './component/textarea.vue'
|
|
150
|
+
import FormCascader from './component/cascader.vue'
|
|
151
|
+
import FormDateRange from './component/dateRange.vue'
|
|
152
|
+
import FormTimePicker from './component/timePicker.vue'
|
|
153
|
+
import FormFileUpload from './component/fileUpload.vue'
|
|
154
|
+
import FormImageUpload from './component/imageUpload.vue'
|
|
155
|
+
import FormSelect from './component/select.vue'
|
|
156
|
+
import FormCheckbox from './component/checkbox.vue'
|
|
157
|
+
import FormRadio from './component/radio.vue'
|
|
158
|
+
import FormDatePicker from './component/datePicker.vue'
|
|
159
|
+
import FormDateTimePicker from './component/datetimePicker.vue'
|
|
160
|
+
import FormLocation from './component/location.vue'
|
|
161
|
+
import { proessParams } from './component/formFun'
|
|
162
|
+
const userStore = useUserStore()
|
|
163
|
+
interface Props {
|
|
164
|
+
config: FormItemDataConfig
|
|
165
|
+
formData: Data
|
|
166
|
+
onlyRead: boolean
|
|
167
|
+
}
|
|
168
|
+
const props = defineProps<Props>()
|
|
169
|
+
|
|
170
|
+
const state = reactive({
|
|
171
|
+
fileList: [] as UploadUserFile[],
|
|
172
|
+
options: [] as Data[],
|
|
173
|
+
cascaderProp: {
|
|
174
|
+
emitPath: false,
|
|
175
|
+
checkStrictly: true,
|
|
176
|
+
label: 'label',
|
|
177
|
+
value: 'value',
|
|
178
|
+
} as Data,
|
|
179
|
+
hasDynamicState: [] as string[],
|
|
180
|
+
})
|
|
181
|
+
const emits = defineEmits(['enter'])
|
|
182
|
+
const disabled = computed(
|
|
183
|
+
() =>
|
|
184
|
+
props.onlyRead ||
|
|
185
|
+
(userStore.otherMessage &&
|
|
186
|
+
userStore.otherMessage.roleCodeList &&
|
|
187
|
+
userStore.otherMessage.roleCodeList.find(
|
|
188
|
+
(item: string) => item === 'superAdmin',
|
|
189
|
+
)
|
|
190
|
+
? false
|
|
191
|
+
: props.config.disabled || false),
|
|
192
|
+
)
|
|
193
|
+
const enter = () => {
|
|
194
|
+
emits('enter')
|
|
195
|
+
}
|
|
196
|
+
// 默认值赋值
|
|
197
|
+
const setDefaultValue = () => {
|
|
198
|
+
const value = props.formData[props.config.key]
|
|
199
|
+
if (
|
|
200
|
+
(props.config.defaultValue || props.config.defaultValue === false) &&
|
|
201
|
+
((typeof value === 'object' && isEmpty(value)) || value === undefined)
|
|
202
|
+
) {
|
|
203
|
+
if (
|
|
204
|
+
typeof props.config.defaultValue === 'string' &&
|
|
205
|
+
!/\$\{.*?\}/.test(props.config.defaultValue)
|
|
206
|
+
) {
|
|
207
|
+
changeDafultValue()
|
|
208
|
+
} else {
|
|
209
|
+
props.formData[props.config.key] = props.config.defaultValue
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
// 获取选项数据
|
|
214
|
+
const getOptions = async () => {
|
|
215
|
+
if (props.config.type === 'select' || props.config.type === 'cascader') {
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// 初始化
|
|
219
|
+
const init = () => {
|
|
220
|
+
setDefaultValue()
|
|
221
|
+
if (props.config.type === 'select' || props.config.type === 'cascader') {
|
|
222
|
+
if (props.config.isMore) {
|
|
223
|
+
state.cascaderProp.multiple = true
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
getOptions()
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const changeDafultValue = () => {
|
|
230
|
+
if (!props.config.defaultValue) {
|
|
231
|
+
return
|
|
232
|
+
}
|
|
233
|
+
props.formData[props.config.key] = props.config.defaultValue
|
|
234
|
+
}
|
|
235
|
+
const setFileList = async () => {
|
|
236
|
+
if (
|
|
237
|
+
props.config.type === 'fileUpload' ||
|
|
238
|
+
props.config.type === 'imageUpload'
|
|
239
|
+
) {
|
|
240
|
+
state.fileList = [] as any
|
|
241
|
+
const data = props.formData[props.config.key]
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
onMounted(async () => {
|
|
245
|
+
await setFileList()
|
|
246
|
+
})
|
|
247
|
+
// watch(
|
|
248
|
+
// () => props.formData[props.config.key],
|
|
249
|
+
// async () => {
|
|
250
|
+
// await setFileList()
|
|
251
|
+
// },
|
|
252
|
+
// {
|
|
253
|
+
// immediate: true,
|
|
254
|
+
// deep: true,
|
|
255
|
+
// },
|
|
256
|
+
// )
|
|
257
|
+
// 表单值改变,根据联动属性完成对应修改操作
|
|
258
|
+
// 清空/增加查询值/显隐
|
|
259
|
+
const change = () => {
|
|
260
|
+
const linkage = props.config.linkage || []
|
|
261
|
+
linkage.forEach((item) => {
|
|
262
|
+
if (Array.isArray(item.key)) {
|
|
263
|
+
item.key.forEach((key) => {
|
|
264
|
+
if (item.type === 'clear') {
|
|
265
|
+
props.formData[key] = ''
|
|
266
|
+
} else if (item.type === 'filter') {
|
|
267
|
+
getOptions()
|
|
268
|
+
} else if (item.type === 'show') {
|
|
269
|
+
props.config.show = props.config.show || ''
|
|
270
|
+
}
|
|
271
|
+
})
|
|
272
|
+
} else {
|
|
273
|
+
if (item.type === 'clear') {
|
|
274
|
+
props.formData[item.key] = ''
|
|
275
|
+
} else if (item.type === 'filter') {
|
|
276
|
+
} else if (item.type === 'show') {
|
|
277
|
+
props.config.show = props.config.show || ''
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
})
|
|
281
|
+
}
|
|
282
|
+
watch(
|
|
283
|
+
() => props.config,
|
|
284
|
+
() => {
|
|
285
|
+
init()
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
deep: true,
|
|
289
|
+
immediate: true,
|
|
290
|
+
},
|
|
291
|
+
)
|
|
292
|
+
watch(
|
|
293
|
+
() => state.hasDynamicState.map((key) => props.formData[key]),
|
|
294
|
+
() => {
|
|
295
|
+
changeDafultValue()
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
deep: true,
|
|
299
|
+
immediate: true,
|
|
300
|
+
},
|
|
301
|
+
)
|
|
302
|
+
defineExpose({ state })
|
|
303
|
+
</script>
|
|
304
|
+
<style lang="scss" scoped>
|
|
305
|
+
:deep() {
|
|
306
|
+
.el-upload-dragger {
|
|
307
|
+
border: none;
|
|
308
|
+
padding: 0;
|
|
309
|
+
line-height: normal;
|
|
310
|
+
width: 100%;
|
|
311
|
+
height: 100%;
|
|
312
|
+
display: flex;
|
|
313
|
+
justify-content: flex-start;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
.imageBox {
|
|
317
|
+
display: flex;
|
|
318
|
+
align-items: center;
|
|
319
|
+
justify-content: center;
|
|
320
|
+
width: 100%;
|
|
321
|
+
height: 100%;
|
|
322
|
+
}
|
|
323
|
+
</style>
|