研发图纸文件管理系统-前端项目
he wei
2024-01-17 752d135e7d0d229002aed8f558a244ff58e949ca
src/pages/resourceManage/software/list.vue
@@ -28,6 +28,7 @@
              onChange: onPageChange,
              onShowSizeChange: onSizeChange,
            }"
            :rowClassName="rowClassFn"
          >
            <template slot="dataIndex" slot-scope="{ index }">
              {{ index + 1 }}
@@ -62,7 +63,9 @@
              </a-popover>
              <template v-if="canDownloadSoftware">
                <a-divider type="vertical"></a-divider>
                <a :disabled="!!record.soft.lockFlag" @click="download(record)"
                <a
                  :disabled="!!record.soft.lockFlag && !isTester"
                  @click="download(record)"
                  >下载</a
                >
                <a-divider type="vertical"></a-divider>
@@ -77,11 +80,7 @@
                    >更新说明</a-button
                  >
                  <a-button
                    v-if="
                      record.soft.lockFlag !== -1
                        ? canLock
                        : tester.some((v) => v == user.name)
                    "
                    v-if="record.soft.lockFlag !== -1 ? canLock : isTester"
                    type="primary"
                    @click="lock(record)"
                    >{{ record.soft.lockFlag ? "解锁" : "锁定" }}</a-button
@@ -91,6 +90,12 @@
                    type="primary"
                    @click="handleEmailShow(record)"
                    >邮件通知</a-button
                  >
                  <a-button
                    type="primary"
                    :disabled="!isTester"
                    @click="handleConfirmDelete(record)"
                    >删除</a-button
                  >
                </a-space>
                <a>更多</a>
@@ -222,6 +227,8 @@
import moment from "moment";
import { getUserList } from "../../permission/apis";
import { message, Modal } from "ant-design-vue";
import {
  getList,
  downLoadSoftware,
@@ -229,18 +236,25 @@
  productSoftwareSubmit,
  applyModel,
  updateSoftwareLock,
  deleteSoftwareApi,
} from "./apis";
import { mapGetters } from "vuex";
import EmailCard from "../../components/emailCard";
import {
  searchDefaultMailUser,
  sendMail,
} from "../../components/emailCard/apis";
import { getRoleUser } from "@/pages/user/apis";
// TODO
const tester = ["李桂华"];
// const tester = ["李桂华"];
export default {
  name: "",
  data() {
    return {
      tester,
      mailList: [],
      tester: [],
      versionTime: moment().format("YYYY-MM-DD HH:mm:ss"),
      reasonVisible: false,
      reason: "",
@@ -286,6 +300,7 @@
          searchAble: true,
          noSearch: true,
          search: {
            default: 0,
            selectOptions: [
              {
                title: "全部",
@@ -414,13 +429,20 @@
  },
  methods: {
    moment,
    rowClassFn(record) {
      let classList = [];
      if (record.soft.lockFlag == -1) {
        classList.push("locked");
      }
      return classList;
    },
    disabledDate(current) {
      // Can not select days before today and today
      return current > moment().endOf("day");
    },
    onSearch(conditions, searchOptions) {
      console.log(conditions);
      console.log(searchOptions, "options");
      // console.log(conditions);
      // console.log(searchOptions, "options");
      this.pageCurr = 1;
      this.conditions = conditions;
      this.searchData();
@@ -440,7 +462,7 @@
      this.searchData();
    },
    onReset(conditions) {
      console.log(conditions, "reset");
      // console.log(conditions, "reset");
      this.conditions = conditions;
      this.searchData();
    },
@@ -662,7 +684,7 @@
        });
    },
    cellMouseenter(e, obj) {
      console.log("enter", e, obj);
      // console.log("enter", e, obj);
      const wraper = this.$refs.wraper;
      const { clientHeight, clientWidth } = wraper;
      const { target, clientX, clientY } = e;
@@ -735,18 +757,27 @@
        if (code && data) {
          this.$message.success("操作成功");
          this.reasonVisible = false;
          // 如果是测试人员解锁确认 则自动发送邮件
          if (lockFlagNow == -1 && this.isTester) {
            this.sendEmail();
          }
          this.searchData();
        } else {
          this.$message.error("操作失败");
        }
      });
    },
    sendEmail() {
      let { title, content } = this.handleEmailShow(this.currentObj, true);
      let params = { mailList: this.mailList, title, content };
      sendMail(params);
    },
    lock(record) {
      this.reason = "";
      this.currentObj = record;
      this.reasonVisible = true;
    },
    handleEmailShow(record) {
    handleEmailShow(record, get) {
      this.emailInfo.title =
        "[软件发布记录]" +
        record.soft.fileName +
@@ -771,6 +802,12 @@
      });
      content.push("发布说明: " + soft.releaseNotes);
      this.emailInfo.content = content.join("\n");
      if (get) {
        return {
          title: this.emailInfo.title,
          content: content.join("\n"),
        };
      }
      this.emailShow = true;
    },
    emailCancel() {
@@ -782,11 +819,68 @@
          let rs = res.data;
          if (rs.code && rs.data) {
            this.userList = rs.data2;
            this.searchDefaultMailUser();
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    searchDefaultMailUser() {
      // 软件 type为1
      let type = 1;
      searchDefaultMailUser(type).then((res) => {
        let rs = res.data;
        let data = [];
        if (rs.code === 1) {
          data = rs.data.map((item) => {
            return item.user;
          });
        }
        this.mailList = this.userList
          .filter((o) => data.includes(o.name) && o.mail)
          .map((item) => {
            return item.mail;
          });
      });
    },
    getRoleUser() {
      getRoleUser(0)
        .then((res) => {
          let { code, data, data2 } = res.data;
          let list = [];
          if (code && data) {
            // console.log(data);
            list = data2.map((v) => v.name);
          }
          this.tester = list;
        })
        .catch((err) => {
          console.log(err);
        });
    },
    handleConfirmDelete(obj) {
      Modal.confirm({
        content: () => "删除当前软件,删除后无法恢复,请注意!!!",
        onOk: async () => {
          try {
            const res = await deleteSoftwareApi(
              obj.soft.fileName,
              obj.soft.version
            );
            const rs = res.data;
            if (rs.code === 1 && rs.data) {
              this.$message.success("删除成功。");
            } else {
              this.$message.error("删除失败!!!");
            }
            this.searchData();
          } catch (e) {
            this.$message.error("删除失败,请联系开发人员!!!");
            console.log(e);
          }
        },
      });
    },
  },
  watch: {
@@ -835,8 +929,12 @@
    canLock() {
      return checkPermit(PERMITS.lockOther, this.permits);
    },
    isTester() {
      return this.tester.some((v) => v == this.user.name);
    },
  },
  mounted() {
    this.getRoleUser();
    this.searchData();
    this.searchAllUserList();
    window.addEventListener("resize", this.resize);
@@ -906,4 +1004,11 @@
.btn-grp button {
  width: 6.4em;
}
/deep/.locked > td {
  background: #fec54b;
}
/deep/.locked.locked.locked.ant-table-row-hover > td,
/deep/.locked.locked.locked:hover > td {
  background: #fcd583;
}
</style>