zouyu
6 天以前 aae0b49229d8798a2cc31a8449092e2db62e2407
src/views/performance/class/index.vue
@@ -265,10 +265,26 @@
          <span style="color: red; margin-right: 4px">*</span>人员名称:
        </div>
        <div class="search_input" style="width: calc(100% - 90px)">
          <el-select v-model="schedulingQuery.userId" placeholder="请选择" style="width: 100%" multiple clearable
            collapse-tags>
            <el-option v-for="item in personList" :key="item.id" :label="item.name" :value="item.id">
            </el-option>
          <el-select v-model="schedulingQuery.userId" popper-class="select-with-all" placeholder="请选择" style="width: 100%" multiple collapse-tags clearable>
<!--            <el-option v-for="item in personList" :key="item.id" :label="item.name" :value="item.id">-->
<!--            </el-option>-->
            <template slot="prefix">
              <el-button
                type="text"
                size="mini"
                @click="handleSelectAll"
                style="margin: 4px 0;"
              >
                {{ isAllSelected ? '取消全选' : '全选' }}
              </el-button>
              <el-divider style="margin: 5px 0;" />
            </template>
            <el-option
              v-for="item in personList"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            />
          </el-select>
        </div>
      </div>
@@ -378,7 +394,7 @@
      loading: false,
      schedulingQuery: {
        week: "",
        userId: null,
        userId: [],
        shift: "",
      },
      list: [],
@@ -399,6 +415,11 @@
      menuY: 0,
      selectedTarget: null,
    };
  },
  computed:{
    isAllSelected() {
      return this.schedulingQuery.userId.length === this.personList.length && this.personList.length > 0;
    },
  },
  watch: {
@@ -423,6 +444,14 @@
    document.removeEventListener('click', this.handleClickOutside)
  },
  methods: {
    handleSelectAll() {
      if (this.isAllSelected) {
        this.schedulingQuery.userId = [];
      } else {
        // 只选中可用选项的value
        this.schedulingQuery.userId = this.personList.map(item => item.id);
      }
    },
    handleContextMenu(target,e) {
      // 阻止浏览器默认右键菜单
      e.preventDefault()
@@ -526,40 +555,6 @@
        this.initYear();
      }
    },
    transFromNumber(num) {
      let changeNum = [
        "零",
        "一",
        "二",
        "三",
        "四",
        "五",
        "六",
        "七",
        "八",
        "九",
      ]; //changeNum[0] = "零"
      let unit = ["", "十", "百", "千", "万"];
      num = parseInt(num);
      let getWan = (temp) => {
        let strArr = temp.toString().split("").reverse();
        let newNum = "";
        for (var i = 0; i < strArr.length; i++) {
          newNum =
            (i == 0 && strArr[i] == 0
              ? ""
              : i > 0 && strArr[i] == 0 && strArr[i - 1] == 0
                ? ""
                : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i])) +
            newNum;
        }
        return newNum;
      };
      let overWan = Math.floor(num / 10000);
      let noWan = num % 10000;
      if (noWan.toString().length < 4) noWan = "0" + noWan;
      return overWan ? getWan(overWan) + "万" + getWan(noWan) : getWan(num);
    },
    init() {
      this.pageLoading = true;
      let year = this.query.year.getFullYear();
@@ -574,16 +569,6 @@
      }).then((res) => {
        this.pageLoading = false;
        this.list = res.data.page
        // this.list = res.data.page.map((item) => {
        //   for (let key in item.monthlyAttendance) {
        //     let type = this.getDayByDic(key);
        //     if (type != undefined || type != null) {
        //       item[`day${type}`] = item.monthlyAttendance[key];
        //     }
        //   }
        //   return item;
        // });
        console.log(this.list)
        let headerList = res.data.headerList;
        this.weeks = [];
        headerList.forEach((item) => {
@@ -649,7 +634,7 @@
          this.schedulingVisible = false;
          this.schedulingQuery = {
            week: "",
            userId: null,
            userId: [],
            shift: "",
          };
          this.refresh();