修改
This commit is contained in:
@@ -36,6 +36,17 @@
|
||||
label-key="label"
|
||||
value-key="value"
|
||||
/>
|
||||
<wd-picker
|
||||
v-if="showEffectiveYear"
|
||||
v-model="formData.effectiveYear"
|
||||
:columns="effectiveYearOptions"
|
||||
label="生效年限"
|
||||
label-width="180rpx"
|
||||
prop="effectiveYear"
|
||||
placeholder="请选择生效年限"
|
||||
label-key="label"
|
||||
value-key="value"
|
||||
/>
|
||||
<wd-textarea
|
||||
v-model="formData.productContent"
|
||||
label="产品内容"
|
||||
@@ -77,10 +88,10 @@
|
||||
import type { FormInstance } from 'wot-design-uni/components/wd-form/types'
|
||||
import type { RenewalProductVO } from '@/api/car/renewalproduct'
|
||||
import { onLoad } from '@dcloudio/uni-app'
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { computed, onMounted, ref, watch } from 'vue'
|
||||
import { useToast } from 'wot-design-uni'
|
||||
import { createRenewalProduct, getRenewalProduct, updateRenewalProduct } from '@/api/car/renewalproduct'
|
||||
import { getStrDictOptions } from '@/hooks/useDict'
|
||||
import { getDictLabel, getStrDictOptions } from '@/hooks/useDict'
|
||||
import { navigateBackPlus } from '@/utils'
|
||||
import { DICT_TYPE } from '@/utils/constants'
|
||||
|
||||
@@ -107,10 +118,41 @@ const productTypeOptions = computed(() => {
|
||||
}))
|
||||
})
|
||||
|
||||
// 生效年限选项(仅产品类别为「无忧」时展示)
|
||||
const effectiveYearOptions = computed(() => {
|
||||
return getStrDictOptions(DICT_TYPE.CAR_RENEWAL_YEAR).map(item => ({
|
||||
label: item.label,
|
||||
value: item.value,
|
||||
}))
|
||||
})
|
||||
|
||||
/** 仅当产品类别为「无忧」或「无忧延保」时显示生效年限 */
|
||||
const showEffectiveYear = computed(() => {
|
||||
const label = getDictLabel(DICT_TYPE.CAR_RENEWAL_PRODUCT_TYPE, formData.value.productType) || ''
|
||||
return label === '无忧' || label === '无忧延保'
|
||||
})
|
||||
|
||||
// 产品类别切换为「无忧」或「无忧延保」时设置生效年限默认值,切换为其他时清空
|
||||
watch(
|
||||
() => formData.value.productType,
|
||||
(type) => {
|
||||
const label = getDictLabel(DICT_TYPE.CAR_RENEWAL_PRODUCT_TYPE, type) || ''
|
||||
if (label === '无忧' || label === '无忧延保') {
|
||||
const opts = getStrDictOptions(DICT_TYPE.CAR_RENEWAL_YEAR)
|
||||
if (opts.length > 0 && !formData.value.effectiveYear) {
|
||||
formData.value.effectiveYear = opts[0].value
|
||||
}
|
||||
} else {
|
||||
formData.value.effectiveYear = undefined
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const formData = ref<RenewalProductVO>({
|
||||
productName: undefined,
|
||||
productContent: undefined,
|
||||
productType: undefined,
|
||||
effectiveYear: undefined,
|
||||
remark: undefined,
|
||||
})
|
||||
|
||||
@@ -161,6 +203,8 @@ async function handleSubmit() {
|
||||
await createRenewalProduct(formData.value)
|
||||
toast.success('新增成功')
|
||||
}
|
||||
// 标记列表页需要刷新,返回后列表会重新拉取数据
|
||||
uni.setStorageSync('renewalproduct_list_need_refresh', true)
|
||||
setTimeout(() => {
|
||||
navigateBackPlus()
|
||||
}, 500)
|
||||
|
||||
Reference in New Issue
Block a user