fix: bug
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m43s

This commit is contained in:
sexygoat
2026-03-14 15:16:21 +08:00
parent d43de4cd06
commit 8f31526499
11 changed files with 489 additions and 119 deletions

View File

@@ -0,0 +1,59 @@
<template>
<ElButton @click="handleGenerate">
{{ buttonText }}
</ElButton>
</template>
<script setup lang="ts">
import { ElMessage } from 'element-plus'
import {
generateSeriesCode,
generatePackageCode,
generateShopCode
} from '@/utils/codeGenerator'
interface Props {
// 编码类型: series(套餐系列) | package(套餐) | shop(店铺)
codeType: 'series' | 'package' | 'shop'
// 按钮文字
buttonText?: string
// 表单字段名,用于清除验证
fieldName?: string
}
const props = withDefaults(defineProps<Props>(), {
buttonText: '生成编码'
})
const emit = defineEmits<{
(e: 'generated', code: string): void
}>()
// 生成编码
const handleGenerate = () => {
let code = ''
switch (props.codeType) {
case 'series':
code = generateSeriesCode()
break
case 'package':
code = generatePackageCode()
break
case 'shop':
code = generateShopCode()
break
default:
ElMessage.error('未知的编码类型')
return
}
// 触发生成事件,将编码传递给父组件
emit('generated', code)
ElMessage.success('编码生成成功')
}
</script>
<style lang="scss" scoped>
// 可以添加特定样式
</style>

View File

@@ -75,6 +75,7 @@
import ArtSearchSelect from './widget/art-search-select/index.vue'
import ArtSearchRadio from './widget/art-search-radio/index.vue'
import ArtSearchDate from './widget/art-search-date/index.vue'
import ArtSearchTreeSelect from './widget/art-search-tree-select/index.vue'
import { SearchComponentType, SearchFormItem } from '@/types'
const { width } = useWindowSize()
@@ -131,6 +132,7 @@
const componentsMap: Record<string, any> = {
input: ArtSearchInput,
select: ArtSearchSelect,
'tree-select': ArtSearchTreeSelect,
radio: ArtSearchRadio,
datetime: ArtSearchDate,
date: ArtSearchDate,

View File

@@ -0,0 +1,46 @@
<template>
<el-tree-select v-model="value" v-bind="config" @change="(val) => changeValue(val)" />
</template>
<script setup lang="ts">
import { SearchFormItem } from '@/types'
import { useI18n } from 'vue-i18n'
const { t } = useI18n()
// 定义组件值类型
export type ValueVO = unknown
// 定义组件props
const prop = defineProps<{
value: ValueVO // 树形选择框的值
item: SearchFormItem // 表单项配置
}>()
// 定义emit事件
const emit = defineEmits<{
(e: 'update:value', value: ValueVO): void // 更新树形选择框值的事件
}>()
// 计算属性:处理v-model双向绑定
const value = computed({
get: () => prop.value,
set: (value: ValueVO) => emit('update:value', value)
})
// 合并默认配置和自定义配置
const config = reactive({
placeholder: `${t('table.searchBar.searchSelectPlaceholder')}${prop.item.label}`,
...(prop.item.config || {})
})
// 树形选择框值变化处理函数
const changeValue = (val: unknown): void => {
if (prop.item.onChange) {
prop.item.onChange({
prop: prop.item.prop,
val
})
}
}
</script>