fix(ts): 精确补全 Mall 表单字段类型,修复 TS2322
- 表单状态字段按需标注 number/string | undefined(不使用 Partial,不改共享 VO) - UploadImgs 用 computed 兜底 [],避免传入 undefined - spu 路由 categoryId 从 query 读取转 Number - 必填字符串字段用 || '' 收口;skuData 改 ref<Sku>() 并由模板 v-if 兜底 ts:check 768 → 748,无新增类型错误master
parent
e566d9f60a
commit
9c95bebc26
|
|
@ -60,16 +60,16 @@ const dialogTitle = ref('') // 弹窗的标题
|
|||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
userId: undefined,
|
||||
userNickname: undefined,
|
||||
userAvatar: undefined,
|
||||
id: undefined as number | undefined,
|
||||
userId: undefined as number | undefined,
|
||||
userNickname: undefined as string | undefined,
|
||||
userAvatar: undefined as string | undefined,
|
||||
spuId: 0,
|
||||
skuId: undefined,
|
||||
skuId: undefined as number | undefined,
|
||||
descriptionScores: 5,
|
||||
benefitScores: 5,
|
||||
content: undefined,
|
||||
picUrls: []
|
||||
content: undefined as string | undefined,
|
||||
picUrls: [] as string[]
|
||||
})
|
||||
const formRules = reactive({
|
||||
spuId: [{ required: true, message: '商品不能为空', trigger: 'blur' }],
|
||||
|
|
@ -81,11 +81,7 @@ const formRules = reactive({
|
|||
benefitScores: [{ required: true, message: '服务星级不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const skuData = ref({
|
||||
id: -1,
|
||||
name: '',
|
||||
picUrl: ''
|
||||
})
|
||||
const skuData = ref<ProductSpuApi.Sku>()
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ const { t } = useI18n() // 国际化
|
|||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
replyContent: undefined
|
||||
id: undefined as number | undefined,
|
||||
replyContent: undefined as string | undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
replyContent: [{ required: true, message: '回复内容不能为空', trigger: 'blur' }]
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="属性编号" prop="category">
|
||||
<el-input v-model="formData.propertyId" disabled="" />
|
||||
<el-input v-model="formData.propertyId" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入名称" />
|
||||
|
|
@ -35,11 +35,16 @@ const dialogVisible = ref(false) // 弹窗的是否展示
|
|||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
propertyId: undefined,
|
||||
const formData = ref<{
|
||||
id?: number
|
||||
propertyId?: number
|
||||
name: string
|
||||
remark?: string
|
||||
}>({
|
||||
id: undefined as number | undefined,
|
||||
propertyId: undefined as number | undefined,
|
||||
name: '',
|
||||
remark: ''
|
||||
remark: undefined as string | undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
propertyId: [{ required: true, message: '属性不能为空', trigger: 'blur' }],
|
||||
|
|
@ -98,7 +103,7 @@ const resetForm = () => {
|
|||
id: undefined,
|
||||
propertyId: undefined,
|
||||
name: '',
|
||||
remark: ''
|
||||
remark: undefined
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ const queryParams = ref({
|
|||
pageSize: 10,
|
||||
tabType: 0,
|
||||
name: '',
|
||||
categoryId: undefined,
|
||||
categoryId: undefined as number | undefined,
|
||||
createTime: undefined
|
||||
}) // 查询参数
|
||||
const queryFormRef = ref() // 搜索的表单Ref
|
||||
|
|
@ -434,7 +434,7 @@ onActivated(() => {
|
|||
onMounted(async () => {
|
||||
// 解析路由的 categoryId
|
||||
if (route.query.categoryId) {
|
||||
queryParams.value.categoryId = route.query.categoryId
|
||||
queryParams.value.categoryId = Number(route.query.categoryId)
|
||||
}
|
||||
// 获得商品信息
|
||||
await getTabsCount()
|
||||
|
|
|
|||
|
|
@ -51,11 +51,11 @@ const dialogTitle = ref('') // 弹窗的标题
|
|||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
picUrl: undefined,
|
||||
status: undefined,
|
||||
sort: undefined
|
||||
id: undefined as number | undefined,
|
||||
name: undefined as string | undefined,
|
||||
picUrl: undefined as string | undefined,
|
||||
status: undefined as number | undefined,
|
||||
sort: undefined as number | undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
name: [{ required: true, message: '分类名称不能为空', trigger: 'blur' }],
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="秒杀轮播图" prop="sliderPicUrls">
|
||||
<UploadImgs v-model="formData.sliderPicUrls" placeholder="请输入秒杀轮播图" />
|
||||
<UploadImgs v-model="sliderPicUrls" placeholder="请输入秒杀轮播图" />
|
||||
</el-form-item>
|
||||
<el-form-item label="活动状态" prop="status">
|
||||
<el-radio-group v-model="formData.status">
|
||||
|
|
@ -61,12 +61,12 @@ const dialogTitle = ref('') // 弹窗的标题
|
|||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
name: undefined,
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
sliderPicUrls: undefined,
|
||||
status: undefined
|
||||
id: undefined as number | undefined,
|
||||
name: undefined as string | undefined,
|
||||
startTime: undefined as string | undefined,
|
||||
endTime: undefined as string | undefined,
|
||||
sliderPicUrls: undefined as string[] | undefined,
|
||||
status: undefined as number | undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
name: [{ required: true, message: '秒杀时段名称不能为空', trigger: 'blur' }],
|
||||
|
|
@ -75,6 +75,12 @@ const formRules = reactive({
|
|||
status: [{ required: true, message: '活动状态不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const sliderPicUrls = computed({
|
||||
get: () => formData.value.sliderPicUrls || [],
|
||||
set: (val: string[]) => {
|
||||
formData.value.sliderPicUrls = val
|
||||
}
|
||||
})
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ const message = useMessage() // 消息弹窗
|
|||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formData = ref({
|
||||
const formData = ref<{
|
||||
id: number | null | undefined
|
||||
auditReason: string
|
||||
}>({
|
||||
id: undefined, // 售后订单编号
|
||||
auditReason: '' // 审批备注
|
||||
})
|
||||
|
|
@ -37,7 +40,7 @@ const open = async (row: AfterSaleApi.TradeAfterSaleVO) => {
|
|||
resetForm()
|
||||
// 设置数据
|
||||
formData.value.id = row.id
|
||||
formData.value.auditReason = row.auditReason
|
||||
formData.value.auditReason = row.auditReason || ''
|
||||
dialogVisible.value = true
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ const message = useMessage() // 消息弹窗
|
|||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
auditReason: undefined
|
||||
id: undefined as number | undefined,
|
||||
auditReason: undefined as string | undefined
|
||||
})
|
||||
const formRules = reactive({
|
||||
auditReason: [{ required: true, message: '驳回原因不能为空', trigger: 'blur' }]
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ const queryParams = reactive({
|
|||
username: undefined,
|
||||
mobile: undefined,
|
||||
status: undefined,
|
||||
deptId: undefined,
|
||||
deptId: undefined as number | undefined,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
|
|
|||
|
|
@ -31,18 +31,17 @@ const message = useMessage() // 消息弹窗
|
|||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formData = ref({
|
||||
id: undefined, // 订单编号
|
||||
id: undefined as number | undefined, // 订单编号
|
||||
adjustPrice: 0, // 订单调价
|
||||
payPrice: '', // 应付金额(总)
|
||||
newPayPrice: '' // 调价后应付金额(总)
|
||||
})
|
||||
watch(
|
||||
() => formData.value.adjustPrice,
|
||||
(adjustPrice: number | string) => {
|
||||
(adjustPrice) => {
|
||||
const numMatch = formData.value.payPrice.match(/\d+(\.\d+)?/)
|
||||
if (numMatch) {
|
||||
const payPriceNum = parseFloat(numMatch[0])
|
||||
adjustPrice = typeof adjustPrice === 'string' ? parseFloat(adjustPrice) : adjustPrice
|
||||
formData.value.newPayPrice = (payPriceNum + adjustPrice).toFixed(2) + '元'
|
||||
}
|
||||
}
|
||||
|
|
@ -55,7 +54,7 @@ const open = async (row: TradeOrderApi.OrderVO) => {
|
|||
resetForm()
|
||||
formData.value.id = row.id!
|
||||
// 设置数据
|
||||
formData.value.adjustPrice = formatToFraction(row.adjustPrice!)
|
||||
formData.value.adjustPrice = Number(formatToFraction(row.adjustPrice!))
|
||||
formData.value.payPrice = floatToFixed2(row.payPrice!) + '元'
|
||||
formData.value.newPayPrice = formData.value.payPrice
|
||||
dialogVisible.value = true
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ const message = useMessage() // 消息弹窗
|
|||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formData = ref({
|
||||
const formData = ref<{
|
||||
id: number | null | undefined
|
||||
remark: string
|
||||
}>({
|
||||
id: undefined, // 订单编号
|
||||
remark: '' // 订单备注
|
||||
})
|
||||
|
|
@ -37,7 +40,7 @@ const open = async (row: TradeOrderApi.OrderVO) => {
|
|||
resetForm()
|
||||
// 设置数据
|
||||
formData.value.id = row.id
|
||||
formData.value.remark = row.remark
|
||||
formData.value.remark = row.remark || ''
|
||||
dialogVisible.value = true
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
|
|
|||
Loading…
Reference in New Issue