Commit 34a0f2c8 by Tianqing Liu

feat: 联动清空数据

1 parent 7d966b5d
...@@ -2,12 +2,23 @@ ...@@ -2,12 +2,23 @@
<div class="containter"> <div class="containter">
<a-form :model="queryForm" layout="inline" :label-col="{ style: { width: '70px' } }"> <a-form :model="queryForm" layout="inline" :label-col="{ style: { width: '70px' } }">
<a-form-item label="集团:" style="padding: 5px 0"> <a-form-item label="集团:" style="padding: 5px 0">
<a-select v-model:value="queryForm.account_id" style="width: 240px" mode="multiple" :maxTagCount="1" <a-select v-model:value="queryForm.account_id" style="width: 240px" :maxTagCount="1"
@change="onAccountChange" :options="accountList" optionFilterProp="label" show-search> @change="onAccountChange" :options="accountList" optionFilterProp="label" show-search>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label="广场:" style="padding: 5px 0"> <a-form-item label="广场:" style="padding: 5px 0">
<a-select v-model:value="queryForm.plaza_id" style="width: 240px" :maxTagCount="1" :options="plazaList" optionFilterProp="label" show-search> <a-select v-model:value="queryForm.plaza_id" style="width: 240px" :maxTagCount="1" :options="plazaList" optionFilterProp="label" show-search @change="onPlazaChange">
</a-select>
</a-form-item>
<a-form-item label="店铺:" style="padding: 5px 0">
<a-select v-model:value="queryForm.zone_id"
style="width: 240px"
mode="multiple"
:maxTagCount="1"
:options="zoneList"
optionFilterProp="label"
show-search
>
</a-select> </a-select>
</a-form-item> </a-form-item>
...@@ -92,6 +103,7 @@ ...@@ -92,6 +103,7 @@
getPagedList getPagedList
} from '@/PublicUtil/PublicUtil' } from '@/PublicUtil/PublicUtil'
import {ElMessage,ElMessageBox} from 'element-plus' import {ElMessage,ElMessageBox} from 'element-plus'
import snapshotRecordApi from '@/views/SnapshotCluster/SnapshotRecord/SnapshotRecordApi';
export default { export default {
components: { components: {
}, },
...@@ -105,10 +117,11 @@ ...@@ -105,10 +117,11 @@
const dataList = ref([]) const dataList = ref([])
const accountList = ref([]) const accountList = ref([])
const plazaList = ref([]) const plazaList = ref([])
const zoneList = ref([])
const currobj = ref({}) const currobj = ref({})
const currentItem = ref({}) const currentItem = ref({})
const queryForm = reactive({ const queryForm = reactive({
account_id: [], account_id: '',
plaza_id: '', plaza_id: '',
date: moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'), date: moment(moment().format('YYYY-MM-DD'), 'YYYY-MM-DD'),
startTime: '00:00:00', startTime: '00:00:00',
...@@ -139,11 +152,19 @@ ...@@ -139,11 +152,19 @@
const onAccountChange = function() { const onAccountChange = function() {
getPlazaList(1) getPlazaList(1)
} }
const onPlazaChange = function() {
queryForm.zone_id = []
zoneList.value = []
// 1 表示不从localStorage中读取数据
getZoneList(1)
}
const getPlazaList = function(val) { const getPlazaList = function(val) {
queryForm.plaza_id = '' queryForm.plaza_id = ''
queryForm.zone_id = []
plazaList.value = [] plazaList.value = []
zoneList.value = []
batchesResultApi.getPlazaList({ batchesResultApi.getPlazaList({
account_id: queryForm.account_id.toString() account_id: Array.isArray(queryForm.account_id) ? queryForm.account_id[0] : queryForm.account_id,
}).then( }).then(
(r) => { (r) => {
if (isArray(r)) { if (isArray(r)) {
...@@ -159,7 +180,44 @@ ...@@ -159,7 +180,44 @@
} else { } else {
queryForm.plaza_id = plazaList.value[0].value queryForm.plaza_id = plazaList.value[0].value
} }
confirmSearch() // 1 表示不从localStorage中读取数据,若则读取
getZoneList(val)
}
}
}
)
}
const getZoneList = function(val) {
console.log('getZoneList', val, searchCondition.value)
// queryForm.zone_id = []
zoneList.value = []
snapshotRecordApi.getZoneList(
{
account_id: Array.isArray(queryForm.account_id) ? queryForm.account_id[0] : queryForm.account_id,
plaza_id: queryForm.plaza_id,
}
).then(
(r) => {
if (isArray(r))
{
for (const item of r)
{
zoneList.value.push(
{
value: item.id,
label: item.name,
}
)
}
if(zoneList.value.length){
if(!val&&searchCondition.value.zone_id && searchCondition.value.zone_id.length>0){
queryForm.zone_id = searchCondition.value.zone_id
}else{
queryForm.zone_id = []
}
}else{
queryForm.zone_id = []
} }
} }
} }
...@@ -167,7 +225,7 @@ ...@@ -167,7 +225,7 @@
} }
const getAccountList = function() { const getAccountList = function() {
queryForm.account_id = [] queryForm.account_id = ''
accountList.value = [] accountList.value = []
batchesResultApi.getAccountList().then( batchesResultApi.getAccountList().then(
(r) => { (r) => {
...@@ -179,10 +237,10 @@ ...@@ -179,10 +237,10 @@
}) })
} }
if (accountList.value.length) { if (accountList.value.length) {
if (searchCondition.value.account_id && searchCondition.value.account_id.length > 0) { if (searchCondition.value.account_id) {
queryForm.account_id = searchCondition.value.account_id queryForm.account_id = searchCondition.value.account_id
} else { } else {
queryForm.account_id.push(accountList.value[0].value) queryForm.account_id = accountList.value[0].value
} }
getPlazaList() getPlazaList()
} }
...@@ -199,6 +257,7 @@ ...@@ -199,6 +257,7 @@
const rawData = toRaw(queryForm) const rawData = toRaw(queryForm)
const data = filterEmptyValueInObject({ const data = filterEmptyValueInObject({
mallId: rawData.plaza_id, mallId: rawData.plaza_id,
zoneId: rawData.zone_id.toString(),
countDate: formatDate(rawData.date), countDate: formatDate(rawData.date),
startTime: formatDate(rawData.date) + ' ' + rawData.startTime, startTime: formatDate(rawData.date) + ' ' + rawData.startTime,
endTime: formatDate(rawData.date) + ' ' + rawData.endTime, endTime: formatDate(rawData.date) + ' ' + rawData.endTime,
...@@ -210,6 +269,7 @@ ...@@ -210,6 +269,7 @@
const storageData = filterEmptyValueInObject({ const storageData = filterEmptyValueInObject({
account_id: rawData.account_id, account_id: rawData.account_id,
plaza_id: [rawData.plaza_id], plaza_id: [rawData.plaza_id],
zone_id: rawData.zone_id,
date: rawData.date, date: rawData.date,
minNum: rawData.minNum, minNum: rawData.minNum,
maxNum: rawData.maxNum, maxNum: rawData.maxNum,
...@@ -219,7 +279,7 @@ ...@@ -219,7 +279,7 @@
let searchCondition = JSON.parse(window.localStorage.getItem('searchCondition')); let searchCondition = JSON.parse(window.localStorage.getItem('searchCondition'));
let newSearchCondition = { let newSearchCondition = {
...searchCondition, ...searchCondition,
...storageData ...storageData,
} }
window.localStorage.setItem('searchCondition', JSON.stringify(newSearchCondition)) window.localStorage.setItem('searchCondition', JSON.stringify(newSearchCondition))
batchesResultApi.getBatchesResultList(data).then( batchesResultApi.getBatchesResultList(data).then(
...@@ -426,6 +486,8 @@ ...@@ -426,6 +486,8 @@
clickSearch, clickSearch,
concatBatches, concatBatches,
deleteBatches, deleteBatches,
onPlazaChange,
zoneList,
} }
} }
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!