省市区全选和电站名称全选

 <el-col :span="6">
              <el-form-item label="省市区">
                <el-cascader
                  :options="options"
                  :props="{ multiple: true }"
                  v-model="form.optionsCity"
                  collapse-tags
                  clearable
                  @change="searchBuilds"
                  placeholder="请选择省市区"
                ></el-cascader>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="电站名称">
                <el-select
                  v-model="form.buildId"
                  placeholder="请选择电站名称"
                  multiple
                  clearable
                  collapse-tags
                  @click.native="searchBuildsClick"
                  @change="changeSelect"
                >
                  <el-checkbox
                    v-model="checked"
                    @change="selectAll"
                    style="text-align: right; width: 100%; padding-right: 10px"
                    >全 选</el-checkbox
                  >
                  <el-option
                    v-for="item in buildData"
                    :key="item.code"
                    :label="item.name"
                    :value="item.id"
                  >
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// 省市区与电站名称联动
searchBuilds() {
  this.form.buildId = "";
  this.buildData = [];
  const [_province = "", _city = "", _area = ""] = this.form.optionsCity;
  this.$post(xxxxxxxx, {
    page: 1,
    size: 3000,
    province: _province || "",
    city: _city || "",
    area: _area || "",
  })
    .then((res) => {
      if (res.status == 1) {
        this.buildData = res.data.rows;
      }
    })
    .catch(() => {
      this.$message.warning("网络异常,稍后请重试");
    });
},
// 获取电站名称
searchBuildsClick() {
  if (!this.form.buildId || this.form.buildId.length <= 0) {
    this.form.buildId = "";
    this.buildData = [];
    const [_province = "", _city = "", _area = ""] = this.form.optionsCity;
    this.$post(SelectUserBuildPowerAndPage, {
      page: 1,
      size: 3000,
      province: _province || "",
      city: _city || "",
      area: _area || "",
    })
      .then((res) => {
        if (res.status == 1) {
          this.buildData = res.data.rows;
        }
      })
      .catch(() => {
        this.$message.warning("网络异常,稍后请重试");
      });
  }
},
//电站选择事件
changeSelect(val) {
  if (val.length === this.buildData.length) {
    this.checked = true;
  } else {
    this.checked = false;
  }
},
// 电站全选
selectAll() {
  this.form.buildId = [];
  if (this.checked) {
    this.buildData.map((item) => {
      this.form.buildId.push(item.id);
    });
    console.log(this.form.buildId, "全选");
  } else {
    this.form.buildId = [];
  }
},

  

posted @   崛起崛起  阅读(40)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示