ZZJ
2022-01-06 fa44bcc2861fe56e8af50fbd8f56065250a2ece3
src/pages/library/components/baseList.vue
@@ -6,14 +6,8 @@
    <el-collapse v-model="activeNames">
      <el-collapse-item name="1" class="el-collapse-item__wrap">
        <template slot="title">
          <span
            :class="
              title === '同步库'
                ? 'iconfont icontongbuku_v'
                : 'iconfont iconbendiku_v'
            "
            style="font-size: 32px"
          ></span>
          <img v-if="title === '同步库'" src="/images/library/同步库2.png" alt="" srcset="">
          <img v-else src="/images/library/本地库2.png" alt="" srcset="">
          <span class="m5">{{ title }}</span>
          <span
            class="iconfont icontianjiaku-09"
@@ -62,6 +56,7 @@
            
              <div
                class="status-dot"
                :class="item.enable == 1 ?'status-dot-active':''"
                :style="item.enable == 1 ? { background: '#4E94FF' } : {}"
              ></div>
            </el-col>
@@ -85,7 +80,7 @@
      </el-collapse-item>
      <el-collapse-item name="2" class="el-collapse-item__wrap">
        <template slot="title">
          <span class="iconfont iconbendiku_v" style="font-size: 32px"></span>
          <img src="/images/library/本地库2.png" alt="" srcset="">
          <span class="m5">{{ titleB }}</span>
          <span
            class="iconfont icontianjiaku-09"
@@ -131,6 +126,7 @@
           
              <div
                class="status-dot"
                :class="item.enable == 1 ?'status-dot-active':''"
                :style="item.enable == 1 ? { background: '#4E94FF' } : {}"
              ></div>
            </el-col>
@@ -148,9 +144,6 @@
              <div class="time-end">
                {{ item.endTime ? item.endTime : "永久有效" }}
              </div>
              <!-- {{ item.startTime }}~{{
                item.endTime ? item.endTime : "永久有效"
              }} -->
            </el-col>
          </el-row>
        </div>
@@ -189,13 +182,9 @@
  },
  methods: {
    isShow(authority) {
      if (this.isAdmin) {
        return true;
      } else if (this.buttonAuthority.indexOf("," + authority + ",") > -1) {
        return true;
      } else {
        return false;
      }
      return (
        this.isAdmin || this.buttonAuthority.indexOf("," + authority + ",") > -1
      );
    },
    async init() {
      await this.BaseManageData.querySyncTables();
@@ -205,85 +194,14 @@
      this.localTableList = this.BaseManageData.localTables;
      this.defaultShow();
    },
    handleChange(val) {},
    async setEnable(item) {
      let res = await updateDbTableStatus({
        id: item.id,
        enable: item.enable,
      });
      if (res.success === true) {
        this.$notify({
          type: "success",
          message: "底库成功变更生效状态!",
        });
      } else {
        this.$notify({
          type: "error",
          message: "底库变更生效状态失败!",
        });
      }
    },
    add(type) {
      this.$emit("changeShow", null, type);
    },
    isDisabled(item) {
      var flag = true;
      if (this.isShow("library:set")) {
        if (item.endTime == "") {
          flag = false;
        } else {
          flag = !this.$moment(new Date()).isBetween(
            item.startTime,
            item.endTime
          );
        }
      }
      return flag;
    },
    clickCategory(index, type, item) {
      this.categoryIndex = type + index;
      // 调用切换右侧面板的函数并且切换父组件中isSelected的值让另一个组件清除被选中状态
      this.clickBase = item;
      this.$emit("getList", item, type);
    },
    edit(item, type) {
      this.$emit("changeShow", item, type);
    },
    deleteBase(id) {
      let token =
        sessionStorage.getItem("loginedInfo") &&
        JSON.parse(sessionStorage.getItem("loginedInfo")).access_token;
      this.$confirm("提示:确定删除底库?", {
        center: true,
        cancelButtonClass: "comfirm-class-cancle",
        confirmButtonClass: "comfirm-class-sure",
      }).then(() => {
        fetch(`/data/api-v/dbtable/deleteDBtablesById?id=${id}`, {
          method: "GET",
          headers: {
            "Content-Type": "application/json",
            Authorization: token,
          },
        })
          .then((res) => {
            return res.json();
          })
          .then((res) => {
            if (res.success) {
              this.$notify({
                type: "success",
                message: "底库删除成功!",
              });
            }
            this.init();
          })
          .catch((err) => {
            this.$notify({
              type: "error",
              message: err,
            });
          });
      });
    },
    // 默认显示第一个库的数据
    defaultShow() {
@@ -317,25 +235,25 @@
        return false;
      }
    },
    dateCompare(dateString, compareDateString) {
      // dateString:当前时间
      // compareDateString:需要比较的时间
      if (this.isEmpty(dateString)) {
        return;
      }
      if (this.isEmpty(compareDateString)) {
        return 1;
      }
      var dateTime = this.dateParse(dateString).getTime();
      var compareDateTime = this.dateParse(compareDateString).getTime();
      if (compareDateTime > dateTime) {
        return 1;
      } else if (compareDateTime === dateTime) {
        return 0;
      } else {
        return -1;
      }
    },
    // dateCompare(dateString, compareDateString) {
    //   // dateString:当前时间
    //   // compareDateString:需要比较的时间
    //   if (this.isEmpty(dateString)) {
    //     return;
    //   }
    //   if (this.isEmpty(compareDateString)) {
    //     return 1;
    //   }
    //   var dateTime = this.dateParse(dateString).getTime();
    //   var compareDateTime = this.dateParse(compareDateString).getTime();
    //   if (compareDateTime > dateTime) {
    //     return 1;
    //   } else if (compareDateTime === dateTime) {
    //     return 0;
    //   } else {
    //     return -1;
    //   }
    // },
  },
  props: {
    listWidth: {
@@ -401,7 +319,7 @@
  font-size: 14px;
}
.out-div {
  max-height: 100%;
  max-height: 100%;    height: 100%;
  .el-collapse-item__wrap {
    will-change: height;
    background-color: #fff;
@@ -435,7 +353,7 @@
    .time-end {
      color: #e9e9e9;
    }
    .status-dot {
    .status-dot-active {
      background: #fff !important;
    }
  }