fix: 回调配置, 调整信用位置, 套餐
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 6m55s

This commit is contained in:
luo
2026-07-29 18:20:42 +08:00
parent 4394ae0f78
commit 17d2eeebc5
39 changed files with 2687 additions and 1532 deletions

View File

@@ -136,6 +136,7 @@
style="width: 100%"
clearable
@change="handleOldIdentifierChange"
@focus="handleOldIotCardsFocus"
>
<ElOption
v-for="card in oldIotCardOptions"
@@ -151,6 +152,9 @@
</div>
</ElOption>
</ElSelect>
<div v-if="oldIotCardEmptyMessage" class="exchange-field-error">
{{ oldIotCardEmptyMessage }}
</div>
</ElFormItem>
<ElFormItem
v-if="createForm.old_asset_type === 'device'"
@@ -169,6 +173,7 @@
style="width: 100%"
clearable
@change="handleOldIdentifierChange"
@focus="handleOldDevicesFocus"
>
<ElOption
v-for="device in oldDeviceOptions"
@@ -184,6 +189,9 @@
</div>
</ElOption>
</ElSelect>
<div v-if="oldDeviceEmptyMessage" class="exchange-field-error">
{{ oldDeviceEmptyMessage }}
</div>
</ElFormItem>
<ElFormItem v-if="createOldAssetShopDisplay" label="旧资产所属店铺">
<ElInput :model-value="createOldAssetShopDisplay" readonly disabled />
@@ -204,6 +212,7 @@
no-data-text="暂无同店铺可用的新资产"
style="width: 100%"
clearable
@focus="handleCreateNewIotCardsFocus"
>
<ElOption
v-for="card in newIotCardOptions"
@@ -219,6 +228,9 @@
</div>
</ElOption>
</ElSelect>
<div v-if="createNewIotCardEmptyMessage" class="exchange-field-error">
{{ createNewIotCardEmptyMessage }}
</div>
</ElFormItem>
<ElFormItem
v-if="createForm.flow_type === 'direct' && createForm.old_asset_type === 'device'"
@@ -236,6 +248,7 @@
no-data-text="暂无同店铺可用的新资产"
style="width: 100%"
clearable
@focus="handleCreateNewDevicesFocus"
>
<ElOption
v-for="device in newDeviceOptions"
@@ -251,6 +264,9 @@
</div>
</ElOption>
</ElSelect>
<div v-if="createNewDeviceEmptyMessage" class="exchange-field-error">
{{ createNewDeviceEmptyMessage }}
</div>
</ElFormItem>
<ElFormItem v-if="createDirectInheritedShopHint" label="归属提示">
<div class="exchange-shop-hint">{{ createDirectInheritedShopHint }}</div>
@@ -308,6 +324,8 @@
no-data-text="暂无可用的新资产"
style="width: 100%"
clearable
@change="handleShipNewIdentifierChange"
@focus="handleShipNewIotCardsFocus"
>
<ElOption
v-for="card in newIotCardOptions"
@@ -323,6 +341,9 @@
</div>
</ElOption>
</ElSelect>
<div v-if="shipNewIotCardEmptyMessage" class="exchange-field-error">
{{ shipNewIotCardEmptyMessage }}
</div>
</ElFormItem>
<ElFormItem
v-else-if="shipAssetType === 'device'"
@@ -340,6 +361,8 @@
no-data-text="暂无可用的新资产"
style="width: 100%"
clearable
@change="handleShipNewIdentifierChange"
@focus="handleShipNewDevicesFocus"
>
<ElOption
v-for="device in newDeviceOptions"
@@ -355,6 +378,9 @@
</div>
</ElOption>
</ElSelect>
<div v-if="shipNewDeviceEmptyMessage" class="exchange-field-error">
{{ shipNewDeviceEmptyMessage }}
</div>
</ElFormItem>
<ElFormItem v-if="shipInheritedShopDisplayText" label="归属提示">
<div class="exchange-shop-hint">{{ shipInheritedShopDisplayText }}</div>
@@ -534,6 +560,42 @@
const newDeviceSearchLoading = ref(false)
const completeLoadingId = ref<number | null>(null)
type AssetFilterOption = {
label: string
value: string
}
const oldAssetFilterOptions = ref<AssetFilterOption[]>([])
const newAssetFilterOptions = ref<AssetFilterOption[]>([])
const oldAssetFilterLoading = ref(false)
const newAssetFilterLoading = ref(false)
const oldIotCardEmptyMessage = computed(() =>
oldCardSearchLoading.value || oldIotCardOptions.value.length > 0 ? '' : '暂无可用的旧资产'
)
const oldDeviceEmptyMessage = computed(() =>
oldDeviceSearchLoading.value || oldDeviceOptions.value.length > 0 ? '' : '暂无可用的旧资产'
)
const createNewIotCardEmptyMessage = computed(() => {
if (newCardSearchLoading.value || newIotCardOptions.value.length > 0) return ''
return createForm.old_identifier ? '暂无同店铺可用的新资产' : '请先选择旧资产'
})
const createNewDeviceEmptyMessage = computed(() => {
if (newDeviceSearchLoading.value || newDeviceOptions.value.length > 0) return ''
return createForm.old_identifier ? '暂无同店铺可用的新资产' : '请先选择旧资产'
})
const shipNewIotCardEmptyMessage = computed(() =>
newCardSearchLoading.value || newIotCardOptions.value.length > 0 ? '' : '暂无可用的新资产'
)
const shipNewDeviceEmptyMessage = computed(() =>
newDeviceSearchLoading.value || newDeviceOptions.value.length > 0 ? '' : '暂无可用的新资产'
)
// 发货表单
const shipForm = reactive({
new_identifier: '',
@@ -543,11 +605,90 @@
})
const shipRules = reactive<FormRules>({
new_identifier: [{ required: true, message: '请输入新资产标识符', trigger: 'blur' }],
new_identifier: [{ required: true, message: '请选择新资产标识符', trigger: 'change' }],
express_company: [{ required: true, message: '请输入快递公司', trigger: 'blur' }],
express_no: [{ required: true, message: '请输入快递单号', trigger: 'blur' }]
})
const handleShipNewIdentifierChange = () => {
shipFormRef.value?.clearValidate('new_identifier')
}
const handleShipNewIotCardsFocus = async () => {
if (newCardSearchLoading.value || newIotCardOptions.value.length > 0) return
await loadDefaultShipNewIotCards()
}
const handleShipNewDevicesFocus = async () => {
if (newDeviceSearchLoading.value || newDeviceOptions.value.length > 0) return
await loadDefaultShipNewDevices()
}
const handleOldIotCardsFocus = async () => {
if (oldCardSearchLoading.value || oldIotCardOptions.value.length > 0) return
await loadDefaultIotCards()
}
const handleOldDevicesFocus = async () => {
if (oldDeviceSearchLoading.value || oldDeviceOptions.value.length > 0) return
await loadDefaultDevices()
}
const handleCreateNewIotCardsFocus = async () => {
if (newCardSearchLoading.value || newIotCardOptions.value.length > 0) return
await loadDefaultNewIotCards()
}
const handleCreateNewDevicesFocus = async () => {
if (newDeviceSearchLoading.value || newDeviceOptions.value.length > 0) return
await loadDefaultNewDevices()
}
const searchFilterAssets = async (query: string, target: 'old' | 'new') => {
const options = target === 'old' ? oldAssetFilterOptions : newAssetFilterOptions
const loading = target === 'old' ? oldAssetFilterLoading : newAssetFilterLoading
loading.value = true
try {
const keyword = query.trim() || undefined
const [cardRes, deviceRes] = await Promise.all([
CardService.getStandaloneIotCards({
is_standalone: true,
keyword,
page: 1,
page_size: 10
}),
DeviceService.getDevices({
keyword,
page: 1,
page_size: 10
})
])
const cardOptions: AssetFilterOption[] =
cardRes.code === 0
? (cardRes.data?.items || []).map((card) => ({
label: `${card.iccid} (IoT卡)`,
value: card.iccid
}))
: []
const deviceOptions: AssetFilterOption[] =
deviceRes.code === 0
? (deviceRes.data?.items || []).map((device) => ({
label: `${device.virtual_no} (设备)`,
value: device.virtual_no
}))
: []
options.value = [...cardOptions, ...deviceOptions]
} catch (error) {
console.error('加载资产筛选选项失败:', error)
options.value = []
} finally {
loading.value = false
}
}
type ShopSelectableOption = {
shop_id?: number | null
shop_name?: string | null
@@ -644,7 +785,7 @@
})
// 搜索表单配置
const searchFormItems: SearchFormItem[] = [
const searchFormItems = computed<SearchFormItem[]>(() => [
{
label: '换货状态',
prop: 'status',
@@ -677,19 +818,31 @@
{
label: '旧资产',
prop: 'old_asset_keyword',
type: 'input',
type: 'select',
options: () => oldAssetFilterOptions.value,
config: {
placeholder: '请输入旧资产标识',
clearable: true
placeholder: '请选择或搜索旧资产标识',
clearable: true,
filterable: true,
remote: true,
reserveKeyword: true,
loading: oldAssetFilterLoading.value,
remoteMethod: (query: string) => searchFilterAssets(query, 'old')
}
},
{
label: '新资产',
prop: 'new_asset_keyword',
type: 'input',
type: 'select',
options: () => newAssetFilterOptions.value,
config: {
placeholder: '请输入新资产标识',
clearable: true
placeholder: '请选择或搜索新资产标识',
clearable: true,
filterable: true,
remote: true,
reserveKeyword: true,
loading: newAssetFilterLoading.value,
remoteMethod: (query: string) => searchFilterAssets(query, 'new')
}
},
{
@@ -704,7 +857,7 @@
valueFormat: 'YYYY-MM-DD'
}
}
]
])
// 动态列配置
const { columnChecks, columns } = useCheckedColumns(() => [
@@ -1037,9 +1190,6 @@
})
if (res.code === 0 && res.data) {
oldIotCardOptions.value = res.data.items || []
if (oldIotCardOptions.value.length === 0) {
ElMessage.info('暂无可用的IoT卡')
}
}
} catch (error) {
console.error('加载IoT卡列表失败:', error)
@@ -1059,9 +1209,6 @@
})
if (res.code === 0 && res.data) {
oldDeviceOptions.value = res.data.items || []
if (oldDeviceOptions.value.length === 0) {
ElMessage.info('暂无可用的设备')
}
}
} catch (error) {
console.error('加载设备列表失败:', error)
@@ -1089,9 +1236,6 @@
})
if (res.code === 0 && res.data) {
oldIotCardOptions.value = res.data.items || []
if (oldIotCardOptions.value.length === 0) {
ElMessage.info('未找到匹配的IoT卡')
}
}
} catch (error) {
console.error('搜索IoT卡失败:', error)
@@ -1118,9 +1262,6 @@
})
if (res.code === 0 && res.data) {
oldDeviceOptions.value = res.data.items || []
if (oldDeviceOptions.value.length === 0) {
ElMessage.info('未找到匹配的设备')
}
}
} catch (error) {
console.error('搜索设备失败:', error)
@@ -1141,7 +1282,6 @@
const shopId = getCreateOldAssetShopId()
if (shopId === undefined) {
newIotCardOptions.value = []
ElMessage.warning('请先选择旧资产')
return
}
@@ -1155,9 +1295,6 @@
})
if (res.code === 0 && res.data) {
newIotCardOptions.value = res.data.items || []
if (newIotCardOptions.value.length === 0) {
ElMessage.info('未找到匹配的IoT卡')
}
}
} catch (error) {
console.error('搜索IoT卡失败:', error)
@@ -1184,9 +1321,6 @@
})
if (res.code === 0 && res.data) {
newIotCardOptions.value = res.data.items || []
if (newIotCardOptions.value.length === 0) {
ElMessage.info('未找到匹配的IoT卡')
}
}
} catch (error) {
console.error('搜索IoT卡失败:', error)
@@ -1213,9 +1347,6 @@
})
if (res.code === 0 && res.data) {
newIotCardOptions.value = res.data.items || []
if (newIotCardOptions.value.length === 0) {
ElMessage.info('暂无同店铺可用的新资产')
}
}
} catch (error) {
console.error('加载IoT卡列表失败:', error)
@@ -1234,8 +1365,8 @@
page: 1,
page_size: 10
})
if (res.code === 0 && res.data) {
newIotCardOptions.value = res.data.items || []
if (res.code === 0) {
newIotCardOptions.value = res.data?.items || []
}
} catch (error) {
console.error('加载IoT卡列表失败:', error)
@@ -1256,7 +1387,6 @@
const shopId = getCreateOldAssetShopId()
if (shopId === undefined) {
newDeviceOptions.value = []
ElMessage.warning('请先选择旧资产')
return
}
@@ -1269,9 +1399,6 @@
})
if (res.code === 0 && res.data) {
newDeviceOptions.value = res.data.items || []
if (newDeviceOptions.value.length === 0) {
ElMessage.info('未找到匹配的设备')
}
}
} catch (error) {
console.error('搜索设备失败:', error)
@@ -1297,9 +1424,6 @@
})
if (res.code === 0 && res.data) {
newDeviceOptions.value = res.data.items || []
if (newDeviceOptions.value.length === 0) {
ElMessage.info('未找到匹配的设备')
}
}
} catch (error) {
console.error('搜索设备失败:', error)
@@ -1325,9 +1449,6 @@
})
if (res.code === 0 && res.data) {
newDeviceOptions.value = res.data.items || []
if (newDeviceOptions.value.length === 0) {
ElMessage.info('暂无同店铺可用的新资产')
}
}
} catch (error) {
console.error('加载设备列表失败:', error)
@@ -1345,8 +1466,8 @@
page: 1,
page_size: 10
})
if (res.code === 0 && res.data) {
newDeviceOptions.value = res.data.items || []
if (res.code === 0) {
newDeviceOptions.value = res.data?.items || []
}
} catch (error) {
console.error('加载设备列表失败:', error)
@@ -1641,6 +1762,8 @@
// 初始化
onMounted(() => {
loadExchangeList()
searchFilterAssets('', 'old')
searchFilterAssets('', 'new')
})
</script>
@@ -1657,5 +1780,13 @@
border: 1px solid var(--el-color-primary-light-7);
border-radius: 6px;
}
.exchange-field-error {
width: 100%;
margin-top: 4px;
color: var(--el-color-danger);
font-size: 12px;
line-height: 1.2;
}
}
</style>