1515 row-key =" id"
1616 >
1717 <template #toolbar >
18+ <el-select style =" width : 90px " v-model =" activeDate" >
19+ <el-option label =" 账期" value =" billingCycle" ></el-option >
20+ <el-option label =" 日期" value =" deductionDate" ></el-option
21+ ></el-select >
1822 <el-date-picker
23+ v-if =" activeDate === 'billingCycle'"
24+ :key =" 'billingCycle'"
1925 :editable =" false"
2026 v-model =" viewMonth"
2127 type =" month"
22- placeholder =" 请选择月份 "
28+ placeholder =" 请选择账期 "
2329 format =" YYYY-MM"
2430 :clearable =" false"
2531 :disabled-date =" disabledDate"
2632 value-format =" YYYY-MM"
2733 >
28- <template #default =" cell " >
29- <div class =" cell" :class =" { current: cell.isCurrent }" >
30- <span class =" text" >{{ cell.text }}</span >
31- </div >
32- </template >
34+ </el-date-picker >
35+ <el-date-picker
36+ v-else
37+ :editable =" false"
38+ :key =" 'deductionDate'"
39+ v-model =" viewDeductionDate"
40+ type =" date"
41+ placeholder =" 请选择日期"
42+ format =" YYYY-MM-DD"
43+ :clearable =" false"
44+ :disabled-date =" disabledDate"
45+ value-format =" YYYY-MM-DD"
46+ >
3347 </el-date-picker >
3448 </template >
3549 <el-table-column type =" selection" />
242256 </layout-content >
243257</template >
244258<script setup lang="ts">
245- import { ref , watch , onMounted } from " vue" ;
259+ import { ref , watch , onMounted , computed } from " vue" ;
246260import {
247261 PaginationConfig ,
248262 TableConfig ,
@@ -263,6 +277,7 @@ const currentMonth =
263277 ? " 0" + (new Date ().getMonth () + 1 ).toString ()
264278 : (new Date ().getMonth () + 1 ).toString ());
265279const viewMonth = ref <string >(currentMonth );
280+ const viewDeductionDate = ref <string >();
266281/**
267282 * 日志选择框禁用大于当前月份的时间
268283 * @param time 时间
@@ -273,29 +288,43 @@ const disabledDate = (time: Date) => {
273288
274289const cloudAccountList = ref <Array <CloudAccount >>([]);
275290
291+ const activeDate = ref <" billingCycle" | " deductionDate" >(" billingCycle" );
292+
276293/**
277294 * 表格对象
278295 */
279296const table = ref <any >();
280297
281298const clearCondition = () => {
282299 viewMonth .value = " " ;
300+ viewDeductionDate .value = " " ;
283301};
284302
303+ const otherSearchQuery = computed (() => {
304+ const query: any = {};
305+ if (viewMonth .value ) {
306+ query [" month" ] = {
307+ value: viewMonth .value ,
308+ label: " 账期" ,
309+ valueLabel: viewMonth .value ,
310+ field: " month" ,
311+ };
312+ }
313+ if (viewDeductionDate .value ) {
314+ query [" deductionDate" ] = {
315+ value: viewDeductionDate .value ,
316+ label: " 日期" ,
317+ valueLabel: viewDeductionDate .value ,
318+ field: " deductionDate" ,
319+ };
320+ }
321+ return query ;
322+ });
285323onMounted (() => {
286324 /**
287325 * 组件挂载查询数据
288326 */
289- search (
290- table .value ?.getTableSearch ({
291- month: {
292- value: viewMonth .value ,
293- label: " 月份" ,
294- valueLabel: viewMonth .value ,
295- field: " month" ,
296- },
297- })
298- );
327+ search (table .value ?.getTableSearch (otherSearchQuery .value ));
299328 cloudAccountApi .listAll ().then ((ok ) => {
300329 cloudAccountList .value = ok .data ;
301330 });
@@ -304,18 +333,9 @@ onMounted(() => {
304333/**
305334 * 月份发生改变的时候查询数据
306335 */
307- watch (viewMonth , () => {
336+ watch (otherSearchQuery , () => {
308337 const tabSearch: TableSearch = table .value ?.getTableSearch (
309- viewMonth .value
310- ? {
311- month: {
312- value: viewMonth .value ,
313- label: " 月份" ,
314- valueLabel: viewMonth .value ,
315- field: " month" ,
316- },
317- }
318- : undefined
338+ otherSearchQuery .value
319339 );
320340 search (tabSearch );
321341});
0 commit comments