This commit is contained in:
@@ -241,7 +241,7 @@ export interface AssetPackageUsageRecord {
|
|||||||
* 对应接口:GET /api/admin/assets/:asset_type/:id/packages?page=1&page_size=50
|
* 对应接口:GET /api/admin/assets/:asset_type/:id/packages?page=1&page_size=50
|
||||||
*/
|
*/
|
||||||
export interface AssetPackageUsageRecord {
|
export interface AssetPackageUsageRecord {
|
||||||
expiry_base?: ExpiryBase | null // 鍒版湡璁℃椂鍩哄噯
|
expiry_base?: ExpiryBase | null // 到期计时基准
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AssetPackageListResponse {
|
export interface AssetPackageListResponse {
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ export function useAssetFormatters() {
|
|||||||
return statusMap[status] || 'info'
|
return statusMap[status] || 'info'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 鑾峰彇鍒版湡璁℃椂鍩哄噯鏂囨
|
// 获取到期计时基准文案
|
||||||
const getExpiryBaseLabel = (expiryBase?: string | null) => {
|
const getExpiryBaseLabel = (expiryBase?: string | null) => {
|
||||||
const map: Record<string, string> = {
|
const map: Record<string, string> = {
|
||||||
from_activation: '实名激活时起算',
|
from_activation: '实名激活时起算',
|
||||||
|
|||||||
@@ -51,11 +51,31 @@
|
|||||||
>
|
>
|
||||||
<ElForm ref="createFormRef" :model="createForm" :rules="createRules" label-width="120px">
|
<ElForm ref="createFormRef" :model="createForm" :rules="createRules" label-width="120px">
|
||||||
<ElFormItem label="换货原因" prop="exchange_reason">
|
<ElFormItem label="换货原因" prop="exchange_reason">
|
||||||
<ElInput
|
<ElSelect
|
||||||
v-model="createForm.exchange_reason"
|
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"
|
type="textarea"
|
||||||
:rows="3"
|
:rows="3"
|
||||||
placeholder="请输入换货原因"
|
placeholder="请输入其他换货原因"
|
||||||
/>
|
/>
|
||||||
</ElFormItem>
|
</ElFormItem>
|
||||||
<ElFormItem label="旧资产类型" prop="old_asset_type">
|
<ElFormItem label="旧资产类型" prop="old_asset_type">
|
||||||
@@ -224,6 +244,15 @@
|
|||||||
const createFormRef = ref<FormInstance>()
|
const createFormRef = ref<FormInstance>()
|
||||||
|
|
||||||
const exchangeList = ref<ExchangeResponse[]>([])
|
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({
|
const searchForm = reactive({
|
||||||
@@ -237,13 +266,29 @@
|
|||||||
// 创建换货单表单
|
// 创建换货单表单
|
||||||
const createForm = reactive({
|
const createForm = reactive({
|
||||||
exchange_reason: '',
|
exchange_reason: '',
|
||||||
|
exchange_reason_other: '',
|
||||||
old_asset_type: '',
|
old_asset_type: '',
|
||||||
old_identifier: '',
|
old_identifier: '',
|
||||||
remark: ''
|
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>({
|
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_asset_type: [{ required: true, message: '请选择旧资产类型', trigger: 'change' }],
|
||||||
old_identifier: [{ required: true, message: '请选择旧资产标识符', trigger: 'change' }]
|
old_identifier: [{ required: true, message: '请选择旧资产标识符', trigger: 'change' }]
|
||||||
})
|
})
|
||||||
@@ -353,7 +398,7 @@
|
|||||||
{
|
{
|
||||||
prop: 'new_asset_identifier',
|
prop: 'new_asset_identifier',
|
||||||
label: '新资产标识符',
|
label: '新资产标识符',
|
||||||
width: 180,
|
width: 220,
|
||||||
formatter: (row: any) => row.new_asset_identifier
|
formatter: (row: any) => row.new_asset_identifier
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -460,6 +505,13 @@
|
|||||||
createDialogVisible.value = true
|
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 () => {
|
const handleOldAssetTypeChange = async () => {
|
||||||
// 清空旧资产标识符
|
// 清空旧资产标识符
|
||||||
@@ -584,7 +636,17 @@
|
|||||||
|
|
||||||
createLoading.value = true
|
createLoading.value = true
|
||||||
try {
|
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) {
|
if (res.code === 0) {
|
||||||
ElMessage.success('换货单创建成功')
|
ElMessage.success('换货单创建成功')
|
||||||
createDialogVisible.value = false
|
createDialogVisible.value = false
|
||||||
|
|||||||
Reference in New Issue
Block a user