zhongrj
2024-03-27 cc1c0a396698648256c350f6f0fe2cb2f0b02c7e
src/views/securityUnitOperation/operationAnalysis.vue
@@ -4,63 +4,79 @@
      <el-col :span="24">
        <div class="rowContent first-menu">
          <div class="rowTitle">
            <img src="../../../public/img/bajgxt/u1618.png" />
            <span>数据概览</span>
            <el-button>进入数据统计表</el-button>
            <el-select class="select1" v-model="value1" placeholder="请选择">
              <el-option
                v-for="item in options1"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
            <el-select class="select2" v-model="value2" placeholder="请选择">
            <avue-input-tree
              class="select1"
              default-expand-all
              v-model="value1"
              placeholder="请选择内容"
              type="tree"
              :dic="options1"
              :props="props"
              @change="handleNodeClick"
            ></avue-input-tree>
            <avue-input-tree
              class="select2"
              default-expand-all
              v-model="value2"
              placeholder="请选择公司"
              type="tree"
              :dic="options2"
              :props="props2"
              @change="changeCompanys"
            ></avue-input-tree>
            <!-- <el-select
              class="select2"
              v-model="value2"
              placeholder="请选择"
              @change="changeCompanys"
            >
              <el-option
                v-for="item in options2"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
                :key="item.departmentid"
                :label="item.enterpriseName"
                :value="item.departmentid"
              ></el-option>
            </el-select> -->
            <el-button @click="toOperationTable">进入数据统计表</el-button>
          </div>
          <div style="display: flex ;margin-top: 15px;">
          <div class="col-content">
            <div class="box-card">
              <span>总保安数</span>
              <span>500</span>
              <span>较上月上涨2%</span>
              <span>{{ card.baoanTotal }}</span>
              <span>较上月增加{{ card.addbaoanTotal }}人</span>
            </div>
            <div class="box-card">
              <span>正常保安员</span>
              <span>500</span>
              <span>较上月上涨2%</span>
              <span>{{ card.zcBaoan }}</span>
              <span>较上月增加{{ card.addzcBaoan }}人</span>
            </div>
            <div class="box-card">
              <span>持证保安员</span>
              <span>500</span>
              <span>较上月上涨2%</span>
              <span>{{ card.czBaoan }}</span>
              <span>较上月增加{{ card.addczBaoan }}人</span>
            </div>
            <div class="box-card">
            <!-- <div class="box-card">
              <span>过考保安员</span>
              <span>500</span>
              <span>较上月上涨2%</span>
            </div>
              <span>{{ card.gkBaoan }}</span>
              <span>较上月增加{{ card.addgkBaoan }}人</span>
            </div> -->
            <div class="box-card">
              <span>服务客户</span>
              <span>500</span>
              <span>较上月上涨2%</span>
              <span>{{ card.kh }}</span>
              <span>较上月增加{{ card.addkh }}家</span>
            </div>
            <div class="box-card">
              <span>缴纳社保</span>
              <span>500</span>
              <span>较上月上涨2%</span>
              <span>{{ card.sheb }}</span>
              <span>较上月增加{{ card.addsheb }}人</span>
            </div>
            <div class="box-card">
              <span>保安派遣</span>
              <span>500</span>
              <span>较上月上涨2%</span>
              <span>{{ card.baoanPq }}</span>
              <span>较上月增加{{ card.addbaoanPq }}人</span>
            </div>
          </div>
        </div>
@@ -68,16 +84,47 @@
    </el-row>
    <el-row :gutter="20">
      <el-col :span="16">
        <div class="rowContent" id="middleEchart1"></div>
        <div class="rowContent" v-loading="loading1">
          <span class="span-title">保安类数据统计</span>
          <div id="middleEchart1"></div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="rowContent" id="middleEchart2"></div>
        <div class="rowContent" v-loading="loading2">
          <span class="span-title">服务客户</span>
          <div id="middleEchart2"></div>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <div class="rowContent">
    <el-row :gutter="20">
      <el-col :span="16">
        <div class="rowContent" v-loading="loading3">
          <span class="span-title">公司运营趋势</span>
          <div id="bottomEchart"></div>
        </div>
      </el-col>
      <el-col :span="8">
        <div class="rowContent" v-loading="loading4">
          <span class="span-title">年龄结构</span>
          <div class="leftEchartTitle qing">
            <div class="block1"></div>
            <span>青年</span>
            <span>{{ ageData.qing }}</span>
            <span>人</span>
          </div>
          <div class="leftEchartTitle zhong">
            <div class="block1"></div>
            <span>中年</span>
            <span>{{ ageData.zhong }}</span>
            <span>人</span>
          </div>
          <div class="leftEchartTitle lao">
            <div class="block1"></div>
            <span>老年</span>
            <span>{{ ageData.lao }}</span>
            <span>人</span>
          </div>
          <div id="bottomEchart1"></div>
        </div>
      </el-col>
    </el-row>
@@ -87,65 +134,558 @@
<script>
import * as echarts from "echarts";
import echartJs from "./securityEchart.js";
import { lazyTreeJu, lazyTrees } from "../../api/index/index";
import {
  queryCounts,
  getCompanys,
  queryYearKh,
  queryYearG,
  selectAge,
} from "../../api/securityUnitOperation/securityUnitOperation";
export default {
  data() {
    return {
      value1: "1",
      value2: "1",
      options1: [
      value1: "",
      value2: "",
      value0: "2012",
      card: {
        baoanTotal: 0,
        addbaoanTotal: 0,
        zcBaoan: 0,
        addzcBaoan: 0,
        czBaoan: 0,
        addczBaoan: 0,
        gkBaoan: 0,
        addgkBaoan: 0,
        kh: 0,
        addkh: 0,
        sheb: 0,
        addsheb: 0,
        baoanPq: 0,
        addbaoanPq: 0,
      },
      options0: [
        {
          value: "1",
          label: "南昌市"
        }
          value: "2012",
          label: "2012年",
        },
        {
          value: "2011",
          label: "2011年",
        },
        {
          value: "2010",
          label: "2010年",
        },
        {
          value: "2009",
          label: "2009年",
        },
        {
          value: "2008",
          label: "2008年",
        },
        {
          value: "2007",
          label: "2007年",
        },
      ],
      options2: [
        {
          value: "1",
          label: "保安公司"
        }
      ]
      options1: [],
      options2: [],
      enterpriseName: "",
      loading1: true,
      loading2: true,
      loading3: true,
      loading4: false,
      echartDom: {
        middleEchart1: null,
        middleEchart2: null,
        bottomEchart: null,
        bottomEchart1: null,
      },
      ageData: {
        qing: 0,
        zhong: 0,
        lao: 0,
      },
      props: {
        children: "children",
        label: "title",
        value: "id",
      },
      props2: {
        children: "children",
        label: "enterpriseName",
        value: "departmentid",
      },
      node: {}, //选中的记录
    };
  },
  methods: {
    setEchart() {
      let data = [];
      let bottomEchart = echarts.init(document.getElementById("bottomEchart"));
      bottomEchart.setOption(echartJs.bottomOption(data));
      let middleEchart1 = echarts.init(
        document.getElementById("middleEchart1")
      );
      middleEchart1.setOption(echartJs.middleOption1(data));
      let middleEchart2 = echarts.init(
        document.getElementById("middleEchart2")
      );
      middleEchart2.setOption(echartJs.middleOption2(data));
    }
    //点击节点
    handleNodeClick(id) {
      this.value1 = id;
      this.getCompanys();
    },
    setAgeEchart() {
      this.loading4 = true;
      let params = {
        jurisdiction: this.value1,
        deptid: this.value2,
      };
      selectAge(params).then((res) => {
        if (res.data.code === 200) {
          if (!this.echartDom.bottomEchart1) {
            this.echartDom.bottomEchart1 = echarts.init(
              document.getElementById("bottomEchart1")
            );
          }
          this.echartDom.bottomEchart1.setOption(
            echartJs.bottomOption2(res.data.data)
          );
          this.ageData.qing = res.data.data.qcount;
          this.ageData.zhong = res.data.data.zcount;
          this.ageData.lao = res.data.data.lcount;
        } else {
          this.$message.error(res.data.msg);
        }
        this.loading4 = false;
      });
    },
    toOperationTable() {
      this.$router.push({
        path:
          "/securityUnitOperation/operationTable?jurisdiction=" +
          this.value2 +
          "&enterpriseName=" +
          this.enterpriseName +
          "&jurisdiction1=" +
          this.value1,
      });
    },
    getFenju() {
      this.options1 = [];
      this.value1 = "";
      this.node = {};
      lazyTrees().then((res) => {
        if (res.data.code === 200) {
          this.options1 = res.data.data;
          this.value1 = this.options1[0] ? this.options1[0].id : "";
          this.node = this.options1[0];
          this.getCompanys();
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    getCompanys() {
      getCompanys({ jurisdiction: this.value1 }).then((res) => {
        if (res.data.code === 200) {
          this.options2 = res.data.data;
          // this.value2 = this.options2[0] ? this.options2[0].departmentid : "";
          this.enterpriseName = this.options2[0]
            ? this.options2[0].enterpriseName
            : "";
          this.changeCompanys();
        }
      });
    },
    getQueryCounts() {
      let params = {
        jurisdiction: this.value1,
        deptid: this.value2,
      };
      queryCounts(params).then((res) => {
        if (res.data.code === 200) {
          let data = res.data.data[0];
          this.card = {
            baoanTotal: data.baoan.num,
            addbaoanTotal: data.baoan.thisnum,
            zcBaoan: data.zcbaoan.num,
            addzcBaoan: data.zcbaoan.thisnum,
            czBaoan: data.czbaoan.num,
            addczBaoan: data.czbaoan.thisnum,
            gkBaoan: 0,
            addgkBaoan: 0,
            kh: data.kh.num,
            addkh: data.kh.thisnum,
            sheb: data.sheb.num,
            addsheb: data.sheb.thisnum,
            baoanPq: data.paiq.num,
            addbaoanPq: data.paiq.thisnum,
          };
        }
      });
    },
    getQueryYearKh() {
      this.loading2 = true;
      let params = {
        jurisdiction: this.value1,
        deptid: this.value2,
      };
      queryYearKh(params).then((res) => {
        if (res.data.code === 200) {
          if (!this.echartDom.middleEchart2) {
            this.echartDom.middleEchart2 = echarts.init(
              document.getElementById("middleEchart2")
            );
          }
          this.echartDom.middleEchart2.setOption(
            echartJs.middleOption2(res.data.data)
          );
        }
        this.loading2 = false;
      });
    },
    getQueryYearG() {
      this.loading1 = true;
      this.loading3 = true;
      let params = {
        jurisdiction: this.value1,
        deptid: this.value2,
      };
      queryYearG(params).then((res) => {
        if (res.data.code === 200) {
          if (!this.echartDom.middleEchart1) {
            this.echartDom.middleEchart1 = echarts.init(
              document.getElementById("middleEchart1")
            );
          }
          this.echartDom.middleEchart1.setOption(
            echartJs.middleOption1(res.data.data)
          );
          if (!this.echartDom.bottomEchart) {
            this.echartDom.bottomEchart = echarts.init(
              document.getElementById("bottomEchart")
            );
          }
          this.echartDom.bottomEchart.setOption(
            echartJs.bottomOption1(res.data.data)
          );
        }
        this.loading3 = false;
        this.loading1 = false;
      });
    },
    // 清空之前的查询结果
    clear() {
      this.card = {
        baoanTotal: 0,
        addbaoanTotal: 0,
        zcBaoan: 0,
        addzcBaoan: 0,
        czBaoan: 0,
        addczBaoan: 0,
        gkBaoan: 0,
        addgkBaoan: 0,
        kh: 0,
        addkh: 0,
        sheb: 0,
        addsheb: 0,
        baoanPq: 0,
        addbaoanPq: 0,
      };
      this.ageData = {
        qing: 0,
        zhong: 0,
        lao: 0,
      };
    },
    changeCompanys() {
      this.options2.forEach((item) => {
        if (item.departmentid === this.value2) {
          this.enterpriseName = item.enterpriseName;
        }
      });
      this.clear();
      this.getQueryCounts();
      this.getQueryYearKh();
      this.getQueryYearG();
      this.setAgeEchart();
    },
  },
  mounted() {
    this.setEchart();
  }
    this.getFenju();
  },
};
</script>
<style lang="scss" scoped>
@media screen and (max-width: 1280px) {
  .box-card {
    font-size: 15px;
    width: 128px;
    background: #00aaf1;
    height: 117px;
    text-align: center;
    margin-right: 28px;
    box-shadow: 5px 5px 5px rgba($color: #000, $alpha: 0.35);
    line-height: 36px;
    span:nth-child(2) {
      color: #06ffff;
      font-size: 31px;
    }
  }
  .col-content {
    margin-top: 39px !important;
  }
  .leftEchartTitle.qing {
    right: 10px;
    margin-top: 42px;
    .block1 {
      background: #73c0de;
      margin-top: 11px;
      width: 10px;
      height: 10px;
      border-radius: 100%;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 12px;
      margin: 0px 3px 0px 3px;
    }
    span:nth-child(3) {
      color: #73c0de;
      font-size: 15px;
      width: 45px;
    }
    span:nth-child(4) {
      font-size: 12px;
      color: #73c0de;
    }
  }
  .leftEchartTitle.zhong {
    right: 10px;
    margin-top: 83px;
    .block1 {
      width: 10px;
      height: 10px;
      border-radius: 100%;
      background: #fac858;
      margin-top: 11px;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 12px;
      margin: 0px 3px 0px 3px;
    }
    span:nth-child(3) {
      color: #fac858;
      font-size: 15px;
      width: 45px;
    }
    span:nth-child(4) {
      font-size: 12px;
      color: #fac858;
    }
  }
  .leftEchartTitle.lao {
    right: 10px;
    margin-top: 125px;
    .block1 {
      width: 10px;
      height: 10px;
      border-radius: 100%;
      background: #91cc75;
      margin-top: 11px;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 12px;
      margin: 0px 3px 0px 3px;
    }
    span:nth-child(3) {
      color: #91cc75;
      font-size: 15px;
      width: 45px;
    }
    span:nth-child(4) {
      font-size: 12px;
      color: #91cc75;
    }
  }
}
// 适配分辨率1600*900
@media screen and (min-width: 1281px) and (max-width: 1600px) {
  .box-card {
    font-size: 15px;
    width: 128px;
    background: #00aaf1;
    height: 117px;
    text-align: center;
    margin-right: 66px;
    box-shadow: 5px 5px 5px rgba($color: #000, $alpha: 0.35);
    line-height: 36px;
    span:nth-child(2) {
      color: #06ffff;
      font-size: 31px;
    }
  }
  .leftEchartTitle.qing {
    right: 37px;
    margin-top: 42px;
    .block1 {
      width: 10px;
      height: 10px;
      background: #73c0de;
      margin-top: 10px;
      border-radius: 100%;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 13px;
    }
    span:nth-child(3) {
      color: #73c0de;
      font-size: 17px;
    }
    span:nth-child(4) {
      font-size: 13px;
      color: #73c0de;
    }
  }
  .leftEchartTitle.zhong {
    right: 37px;
    margin-top: 83px;
    .block1 {
      width: 10px;
      height: 10px;
      background: #fac858;
      margin-top: 10px;
      border-radius: 100%;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 13px;
    }
    span:nth-child(3) {
      color: #fac858;
      font-size: 17px;
    }
    span:nth-child(4) {
      font-size: 13px;
      color: #fac858;
    }
  }
  .leftEchartTitle.lao {
    right: 37px;
    margin-top: 125px;
    .block1 {
      width: 10px;
      height: 10px;
      background: #91cc75;
      margin-top: 10px;
      border-radius: 100%;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 13px;
    }
    span:nth-child(3) {
      color: #91cc75;
      font-size: 17px;
    }
    span:nth-child(4) {
      font-size: 13px;
      color: #91cc75;
    }
  }
}
@media screen and (min-width: 1601px) and (max-width: 1920px) {
  .box-card {
    width: 150px;
    background: #00aaf1;
    height: 135px;
    text-align: center;
    margin-right: 66px;
    box-shadow: 5px 5px 5px rgba($color: #000, $alpha: 0.35);
    line-height: 40px;
    span:nth-child(2) {
      color: #06ffff;
      font-size: 34px;
    }
  }
  .leftEchartTitle.qing {
    right: 37px;
    margin-top: 42px;
    .block1 {
      width: 10px;
      height: 10px;
      background: #73c0de;
      margin-top: 10px;
      border-radius: 100%;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 13px;
    }
    span:nth-child(3) {
      color: #73c0de;
      font-size: 17px;
    }
    span:nth-child(4) {
      font-size: 13px;
      color: #73c0de;
    }
  }
  .leftEchartTitle.zhong {
    right: 37px;
    margin-top: 83px;
    .block1 {
      width: 10px;
      height: 10px;
      background: #fac858;
      margin-top: 10px;
      border-radius: 100%;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 13px;
    }
    span:nth-child(3) {
      color: #fac858;
      font-size: 17px;
    }
    span:nth-child(4) {
      font-size: 13px;
      color: #fac858;
    }
  }
  .leftEchartTitle.lao {
    right: 37px;
    margin-top: 125px;
    .block1 {
      width: 10px;
      height: 10px;
      background: #91cc75;
      margin-top: 10px;
      border-radius: 100%;
    }
    span:nth-child(2) {
      color: #fff;
      font-size: 13px;
    }
    span:nth-child(3) {
      color: #91cc75;
      font-size: 17px;
    }
    span:nth-child(4) {
      font-size: 13px;
      color: #91cc75;
    }
  }
}
.page1 {
  height: 100%;
  width: 100%;
  /* background: #003688; */
}
#bottomEchart,
#middleEchart1,
#middleEchart2 {
  height: 100%;
#middleEchart2,
#bottomEchart1 {
  height: calc(100% - 25px);
  width: 100%;
}
.rowContent {
  height: 20%;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0px 0px 1px #fff;
}
.first-menu {
  padding: 5px 20px 20px 20px;
  height: calc(100% - 25px) !important;
}
.el-row:first-child {
  height: calc(40% - 80px);
@@ -158,51 +698,98 @@
.el-row:nth-child(3) {
  height: 30%;
}
.el-col,
.rowContent {
.el-col {
  height: 100%;
}
.box-card {
  width: 150px;
  background: #00aaf1;
  height: 135px;
  text-align: center;
  margin-right: 66px;
  box-shadow: 5px 5px 5px rgba($color: #000, $alpha: 0.35);
  line-height: 40px;
.rowContent {
  padding: 5px 20px 0px 10px;
  height: calc(100% - 5px);
  width: calc(100% - 30px);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0px 0px 1px #fff;
  .span-title {
    color: #fff;
    font-size: 17px;
    margin-left: 35px;
    font-weight: 600;
  }
}
.box-card span {
  display: block;
  width: 100%;
  color: #fff;
}
.box-card span:nth-child(2) {
  color: #06ffff;
  font-size: 34px;
}
.rowTitle {
  height: 40px;
  display: flex;
  line-height: 40px;
  img {
    width: 30px;
    height: 30px;
    margin-top: 5px;
  }
  span {
    color: #fff;
    font-size: 25px;
    font-size: 17px;
    font-weight: 600;
    margin-right: 20px;
    margin-left: 11px;
  }
  .select0 {
    position: absolute;
    right: 443px;
  }
  .select1 {
    position: absolute;
    right: 140px;
    right: 360px;
  }
  .select2 {
    position: absolute;
    right: 0px;
    right: 159px;
  }
  .el-button {
    position: absolute;
    right: 300px;
    right: 0px;
  }
  /deep/ .el-input__inner {
    width: 120px;
    width: 180px;
  }
}
.col-content {
  display: flex;
  margin-top: 15px;
  margin-left: 36px;
}
.leftEchartTitle {
  height: 30px;
  display: flex;
  line-height: 30px;
  margin-top: 10px;
  margin-left: 28px;
  position: absolute;
  .block1 {
    width: 23px;
    height: 13px;
    background: #2ec7c9;
    border-radius: 3px;
    margin-top: 9px;
  }
  span:nth-child(2) {
    color: #fff;
    font-size: 13px;
    margin: 0px 10px 0px 3px;
  }
  span:nth-child(3) {
    color: #2ec7c9;
    font-size: 17px;
    font-weight: 700;
    display: block;
    width: 65px;
    text-align: center;
  }
  span:nth-child(4) {
    font-size: 13px;
    color: #2ec7c9;
  }
}
</style>