美文网首页
2022-10-20 avue的column列添加搜索的默认

2022-10-20 avue的column列添加搜索的默认

作者: 半眼鱼 | 来源:发表于2022-10-20 17:20 被阅读0次

在type为select选择框的column列一进入此页面时,设置一个默认值,在点击清空 按钮时,默认查询默认条件的值,类似于如下这种

<template>
  <basic-container>
    <avue-crud ref="crud"
               :data="data"
               :page="page"
               :option="option"
               :search="query"     //设置查询,不要使用:syncSearch,否则会报错
               @search-change="searchChange"
               @search-reset="searchReset"
               @current-change="currentChange"
               @size-change="sizeChange"
               @refresh-change="onRefresh"
               @on-load="onLoad">
    </avue-crud>
  </basic-container>
</template>
 
<script>
import {DICT, tree_stuff} from "@/util/mixins";
import {list, update} from "@/api/report/project";
 
export default {
  data() {
    return {
      query: {isArchived_eq: 0},    //设置查询的默认值
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      option: {
        tip: false,
        border: true,
        index: true,
        selection: false,
        addBtn: false,
        menu: false,
        searchMenuSpan: 4,
        column: [
          {label: "项目状态", prop: "isArchived_eq", type: "select", dicData: DICT.archivedType, search: true, searchSpan: 4, searchPlaceholder: "是否归档", showColumn: false, hide: true},
          {label: "需求来源", prop: "requireBu_like", type: "select", dicData: DICT.requiredBUType, search: true, searchSpan: 4, searchPlaceholder: "需求来源", filterable: true, showColumn: false, hide: true},
          {label: "费用列支", prop: "chargeType_eq", type: "select", dicData: DICT.chargeType, cell: true, search: true, searchSpan: 4, placeholder: "费用列支", showColumn: false, hide: true},
 
          {label: "项目名称", prop: "projectName", minWidth: 260},
          {
            label: "费用列支", prop: "chargeType", type: "select", dicData: DICT.chargeType, cell: true, width: 110, placeholder: "请选择",
            change: ({row, value}) => {
              if (!value) return;
              this.rowUpdate(row);
            }
          },
          {
            label: "项目负责人", prop: "personId", type: "select", dicData: tree_stuff, filterable: true, cell: true, width: 110, placeholder: "可输入",
            change: ({row, value}) => {
              if (!value) return;
              this.rowUpdate(row);
            }
          },
          {label: "需求申请所属事业部", prop: "requireBU", width: 220, overHidden: true},
          {label: "需求总数", prop: "requireNum", width: 90},
          {label: "产品设计", prop: "productNum", width: 90},
          {label: "任务统计", prop: "task", width: 100, slot: true},
          {label: "七日新增", prop: "addNum", width: 90},
          {label: "七日完成", prop: "doneNum", width: 90},
          {label: "投入资源", prop: "resNum", width: 100, slot: true},
          {label: "发生费用", prop: "usedAmount", width: 120},
          {label: "预算总计", prop: "reckonAmount", width: 120},
          {label: "预估剩余预算", prop: "residueDays", width: 120, slot: true}
        ],
      },
      data: []
    };
  },
  methods: {
    rowUpdate(row) {
      update(row);
      row.$cellEdit = false;
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.currentPage = 1;
      this.page.pageSize = pageSize;
    },
    searchReset() {
      this.query = {isArchived_eq: 0};  //清空搜索条件时再查询,直接设置查询得默认值
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    onRefresh() {
      this.onLoad(this.page);   
    },
    onLoad(page, params = {}) {
      list(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
        const data = res.data;
        this.page.total = data.total;
        this.data = data.records;
        this.data.forEach(item => {
          item.residueAmount = item.reckonAmount - item.usedAmount;
          item.residueDays = item.residueAmount / item.daysAmount;
          if (item.chargeType === -1) item.chargeType = null;
        });
      });
    }
  }
};
</script>
 
<style>
</style>

相关文章

  • 2022-10-20 avue的column列添加搜索的默认

    在type为select选择框的column列一进入此页面时,设置一个默认值,在点击清空 按钮时,默认查询默认条件...

  • mysql_数据表的修改操作

    删除列:ALTER TABLE tb1_name DROP[COLUMN] col_name; 添加多列:ALTE...

  • 多列布局

    column-width: 列的宽度 column-count: 列的数量 column-gap: 列与列之间...

  • 多列布局

    column-width: 列的宽度 column-count: 列的数量 column-gap : 列与列的间...

  • 操作数据表

    1、添加列 1、添加单列alter table tbl_name add [column] col_name co...

  • 2017.11.21

    注释:1.行(row)必须包括在contain内。 2.行(row)可以添加列(column),但列不能超过...

  • css多列布局 multi-column(瀑布流布局)

    column-count :指定元素应该分为的列数 column-fill:指定css如何填充列 column-g...

  • PostgreSQL

    现有表中添加一个新的列 ALTER TABLE table_name ADD column_name dataty...

  • 数据表修改

    添加单列 添加多列 删除列 添加主键约束 添加唯一约束 添加外键约束 添加/删除默认约束 删除主键约束 删除唯一约...

  • css3多列,用户界面

    1.css3多列 多列属性 column-count:分割开的列数 column-gap:列与列间的间隙 colu...

网友评论

      本文标题:2022-10-20 avue的column列添加搜索的默认

      本文链接:https://www.haomeiwen.com/subject/gkbuzrtx.html