fix: 换货原因改成下拉
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m37s

This commit is contained in:
sexygoat
2026-05-14 15:52:38 +08:00
parent 38cf7d12e9
commit f3b5444dd8
3 changed files with 69 additions and 7 deletions

View File

@@ -241,7 +241,7 @@ export interface AssetPackageUsageRecord {
* 对应接口GET /api/admin/assets/:asset_type/:id/packages?page=1&page_size=50
*/
export interface AssetPackageUsageRecord {
expiry_base?: ExpiryBase | null // 鍒版湡璁℃椂鍩哄噯
expiry_base?: ExpiryBase | null // 到期计时基准
}
export interface AssetPackageListResponse {

View File

@@ -196,7 +196,7 @@ export function useAssetFormatters() {
return statusMap[status] || 'info'
}
// 鑾峰彇鍒版湡璁℃椂鍩哄噯鏂囨
// 获取到期计时基准文案
const getExpiryBaseLabel = (expiryBase?: string | null) => {
const map: Record<string, string> = {
from_activation: '实名激活时起算',

View File

@@ -51,11 +51,31 @@
>
<ElForm ref="createFormRef" :model="createForm" :rules="createRules" label-width="120px">
<ElFormItem label="换货原因" prop="exchange_reason">
<ElInput
<ElSelect
v-model="createForm.exchange_reason"
placeholder="请选择换货原因"
clearable
style="width: 100%"
@change="handleExchangeReasonChange"
>
<ElOption
v-for="item in exchangeReasonOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</ElSelect>
</ElFormItem>
<ElFormItem
v-if="createForm.exchange_reason === EXCHANGE_REASON_OTHER"
label="其他原因"
prop="exchange_reason_other"
>
<ElInput
v-model="createForm.exchange_reason_other"
type="textarea"
:rows="3"
placeholder="请输入换货原因"
placeholder="请输入其他换货原因"
/>
</ElFormItem>
<ElFormItem label="旧资产类型" prop="old_asset_type">
@@ -224,6 +244,15 @@
const createFormRef = ref<FormInstance>()
const exchangeList = ref<ExchangeResponse[]>([])
const EXCHANGE_REASON_OTHER = '其他'
const exchangeReasonOptions = [
{ label: '管控转卡', value: '管控转卡' },
{ label: '原卡丢失', value: '原卡丢失' },
{ label: '网络问题', value: '网络问题' },
{ label: '锁卡换卡', value: '锁卡换卡' },
{ label: '卡片损坏', value: '卡片损坏' },
{ label: EXCHANGE_REASON_OTHER, value: EXCHANGE_REASON_OTHER }
]
// 搜索表单
const searchForm = reactive({
@@ -237,13 +266,29 @@
// 创建换货单表单
const createForm = reactive({
exchange_reason: '',
exchange_reason_other: '',
old_asset_type: '',
old_identifier: '',
remark: ''
})
const validateOtherExchangeReason = (_rule: any, value: string, callback: any) => {
if (createForm.exchange_reason !== EXCHANGE_REASON_OTHER) {
callback()
return
}
if (!value || !value.trim()) {
callback(new Error('请输入其他换货原因'))
return
}
callback()
}
const createRules = reactive<FormRules>({
exchange_reason: [{ required: true, message: '请输入换货原因', trigger: 'blur' }],
exchange_reason: [{ required: true, message: '请选择换货原因', trigger: 'change' }],
exchange_reason_other: [{ validator: validateOtherExchangeReason, trigger: 'blur' }],
old_asset_type: [{ required: true, message: '请选择旧资产类型', trigger: 'change' }],
old_identifier: [{ required: true, message: '请选择旧资产标识符', trigger: 'change' }]
})
@@ -353,7 +398,7 @@
{
prop: 'new_asset_identifier',
label: '新资产标识符',
width: 180,
width: 220,
formatter: (row: any) => row.new_asset_identifier
},
{
@@ -460,6 +505,13 @@
createDialogVisible.value = true
}
const handleExchangeReasonChange = () => {
if (createForm.exchange_reason !== EXCHANGE_REASON_OTHER) {
createForm.exchange_reason_other = ''
createFormRef.value?.clearValidate('exchange_reason_other')
}
}
// 旧资产类型变更
const handleOldAssetTypeChange = async () => {
// 清空旧资产标识符
@@ -584,7 +636,17 @@
createLoading.value = true
try {
const res = await ExchangeService.createExchange(createForm)
const exchangeReason =
createForm.exchange_reason === EXCHANGE_REASON_OTHER
? createForm.exchange_reason_other.trim()
: createForm.exchange_reason
const res = await ExchangeService.createExchange({
exchange_reason: exchangeReason,
old_asset_type: createForm.old_asset_type,
old_identifier: createForm.old_identifier,
remark: createForm.remark || undefined
})
if (res.code === 0) {
ElMessage.success('换货单创建成功')
createDialogVisible.value = false