🐛 毛利分析增加查询条件校验
This commit is contained in:
@@ -5,13 +5,13 @@
|
||||
<el-row :gutter="16">
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="客户区域" class="filter-item">
|
||||
<el-select v-model="query.customerArea" placeholder="请选择客户区域" class="filter-control" @change="handleSearch">
|
||||
<el-select v-model="query.customerArea" placeholder="请选择客户区域" class="filter-control">
|
||||
<el-option v-for="area in customer_area" :key="area.value" :label="area.label" :value="area.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="计费日期" class="filter-item">
|
||||
<el-form-item label="计费日期" class="filter-item" required>
|
||||
<el-date-picker
|
||||
v-model="dateRange"
|
||||
type="daterange"
|
||||
@@ -24,7 +24,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="客户名称" class="filter-item">
|
||||
<el-form-item label="客户名称" class="filter-item" required>
|
||||
<customer-select
|
||||
v-model="query.customerCode"
|
||||
:fetch-options="listProfitCustomerOptions"
|
||||
@@ -61,7 +61,7 @@
|
||||
</el-col>
|
||||
<el-col v-if="dimension === 'order'" :xs="24" :sm="12" :lg="8">
|
||||
<el-form-item label="应收状态" class="filter-item">
|
||||
<el-select v-model="arBillStatus" clearable placeholder="全部状态" class="filter-control">
|
||||
<el-select v-model="arBillStatus" clearable placeholder="全部状态" class="filter-control" @change="clearReportResults">
|
||||
<el-option label="未出账" value="UNBILLED" />
|
||||
<el-option label="部分出账" value="PARTIAL" />
|
||||
<el-option label="已出账" value="BILLED" />
|
||||
@@ -142,7 +142,7 @@
|
||||
icon="Download"
|
||||
v-hasPermi="['report:profit:export']"
|
||||
:loading="exporting"
|
||||
:disabled="!hasProfitRule()"
|
||||
:disabled="!hasProfitRule() || !hasSearched"
|
||||
@click="handleExport"
|
||||
>导出当前维度</el-button>
|
||||
</div>
|
||||
@@ -199,7 +199,7 @@
|
||||
<template #default="{ row }">{{ arBillStatusLabel(row.arBillStatus) }}</template>
|
||||
</el-table-column>
|
||||
</template>
|
||||
<template #empty><el-empty description="暂无符合条件的数据" /></template>
|
||||
<template #empty><el-empty :description="hasSearched ? '暂无符合条件的数据' : '请选择计费日期和客户名称后点击搜索'" /></template>
|
||||
</el-table>
|
||||
</div>
|
||||
|
||||
@@ -339,6 +339,7 @@ let summaryRequestVersion = 0
|
||||
const rows = ref([])
|
||||
let rowsRequestVersion = 0
|
||||
const loading = ref(false)
|
||||
const hasSearched = ref(false)
|
||||
const exporting = ref(false)
|
||||
const exportLogVisible = ref(false)
|
||||
const exportLogLoading = ref(false)
|
||||
@@ -427,8 +428,24 @@ function hasProfitRule() {
|
||||
return hasCustomerArea() && !!currentRule.value
|
||||
}
|
||||
|
||||
function hasCompleteDateRange() {
|
||||
return Array.isArray(dateRange.value) && !!dateRange.value[0] && !!dateRange.value[1]
|
||||
}
|
||||
|
||||
function validateRequiredFilters(showMessage = true) {
|
||||
if (!hasCompleteDateRange()) {
|
||||
if (showMessage) ElMessage.warning('请选择完整的计费日期')
|
||||
return false
|
||||
}
|
||||
if (!query.customerCode) {
|
||||
if (showMessage) ElMessage.warning('请选择客户名称')
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
function loadSummary() {
|
||||
if (!hasProfitRule() || !validateMultiValueFilters(false)) return Promise.resolve()
|
||||
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters(false)) return Promise.resolve()
|
||||
const requestVersion = ++summaryRequestVersion
|
||||
summaryLoaded.value = false
|
||||
return listProfitSummary(buildQuery(false)).then(res => {
|
||||
@@ -439,7 +456,7 @@ function loadSummary() {
|
||||
}
|
||||
|
||||
function loadRows() {
|
||||
if (!hasProfitRule() || !validateMultiValueFilters()) return Promise.resolve()
|
||||
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters()) return Promise.resolve()
|
||||
const requestVersion = ++rowsRequestVersion
|
||||
const requestDimension = dimension.value
|
||||
loading.value = true
|
||||
@@ -454,6 +471,7 @@ function loadRows() {
|
||||
}
|
||||
|
||||
function clearReportResults() {
|
||||
hasSearched.value = false
|
||||
summaryRequestVersion++
|
||||
rowsRequestVersion++
|
||||
orderListRequestVersion++
|
||||
@@ -471,7 +489,9 @@ function clearReportResults() {
|
||||
|
||||
function handleSearch() {
|
||||
clearReportResults()
|
||||
if (!validateRequiredFilters()) return
|
||||
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
||||
hasSearched.value = true
|
||||
pageNum.value = 1
|
||||
Promise.all([loadSummary(), loadRows()])
|
||||
}
|
||||
@@ -481,7 +501,8 @@ function handleReset() {
|
||||
query.customerArea = customer_area.value[0]?.value ?? ''
|
||||
arBillStatus.value = ''
|
||||
dateRange.value = [formatLocalDate(-30), formatLocalDate(0)]
|
||||
handleSearch()
|
||||
hasSearched.value = false
|
||||
clearReportResults()
|
||||
}
|
||||
|
||||
function handleDimensionChange() {
|
||||
@@ -489,10 +510,12 @@ function handleDimensionChange() {
|
||||
pageNum.value = 1
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
if (!hasSearched.value || !validateRequiredFilters(false)) return
|
||||
Promise.all([loadSummary(), loadRows()])
|
||||
}
|
||||
|
||||
function openOrderList(row) {
|
||||
if (!hasSearched.value || !validateRequiredFilters()) return
|
||||
if (!validateMultiValueFilters()) return
|
||||
if (!row.orderCount) return
|
||||
orderListTitle.value = '订单列表'
|
||||
@@ -511,7 +534,7 @@ function openOrderList(row) {
|
||||
|
||||
function loadOrderList() {
|
||||
if (!orderListContext.value) return
|
||||
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
||||
if (!hasSearched.value || !validateRequiredFilters(false) || !hasProfitRule() || !validateMultiValueFilters()) return
|
||||
const requestVersion = ++orderListRequestVersion
|
||||
orderListLoading.value = true
|
||||
const params = {
|
||||
@@ -565,6 +588,7 @@ function arBillStatusLabel(value) {
|
||||
}
|
||||
|
||||
async function handleExport() {
|
||||
if (!hasSearched.value || !validateRequiredFilters()) return
|
||||
if (!hasProfitRule() || !validateMultiValueFilters()) return
|
||||
exporting.value = true
|
||||
const exporter = dimension.value === 'product' ? exportProfitProducts : exportProfitOrders
|
||||
@@ -679,7 +703,6 @@ function handleDeleteRate(row) {
|
||||
|
||||
listProfitAreaRules().then(res => {
|
||||
areaRules.value = res.data || {}
|
||||
handleSearch()
|
||||
}).catch(() => {
|
||||
areaRules.value = {}
|
||||
areaRulesFailed.value = true
|
||||
@@ -694,9 +717,20 @@ watch(customer_area, options => {
|
||||
}
|
||||
if (!options.some(area => area.value === query.customerArea)) {
|
||||
query.customerArea = options[0].value
|
||||
handleSearch()
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
watch(() => [
|
||||
query.customerArea,
|
||||
query.orderNo,
|
||||
query.customerCode,
|
||||
query.belongSalerCode,
|
||||
query.productCode,
|
||||
dateRange.value?.[0],
|
||||
dateRange.value?.[1]
|
||||
], () => {
|
||||
if (hasSearched.value) clearReportResults()
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user