研发图纸文件管理系统-前端项目
he wei
2024-12-03 98ff6711d7fb3d4b37846d62a20bcd5c09e25d07
src/pages/resourceManage/product/list.vue
@@ -29,6 +29,7 @@
              onChange: onPageChange,
              onShowSizeChange: onSizeChange,
            }"
            :rowClassName="rowClassFn"
          >
            <template slot="dataIndex" slot-scope="{ index }">
              {{ index + 1 }}
@@ -40,7 +41,16 @@
                  >新增</a-button
                >
                <a-button type="primary" @click="prodDiff">产品比较</a-button>
                <a-button type="primary" @click="ownerDownloadLog"
                  >我的锁定记录</a-button
                >
              </a-space>
            </template>
            <template slot="enabled" slot-scope="{ record }">
              {{ record.enabled == -1 ? "是" : "否" }}
            </template>
            <template slot="enabled1" slot-scope="{ record }">
              {{ record.enabled == 1 ? "可用" : "不可用" }}
            </template>
            <template slot="isNormal" slot-scope="{ record }">
              {{ record.customCode == "" ? "是" : "否" }}
@@ -50,21 +60,31 @@
                <a @click="upload(record)">上传软件</a>
                <a-divider type="vertical"></a-divider>
              </template> -->
              <a @click="viewLog(record)">日志</a>
              <a @click="viewLog(record)">状态日志</a>
              <a-divider type="vertical"></a-divider>
              <a @click="goDetails(record)">详情</a>
              <a-divider type="vertical"></a-divider>
              <a-popover title="" trigger="hover">
                <a-space class="btn-grp" direction="vertical" slot="content">
                  <!-- TODO -->
                  <a-button
                    :disabled="record.version == -1"
                    v-if="isTester && record.enabled != 1"
                    type="primary"
                    @click="unLock(record)"
                    >解锁</a-button
                  >
                  <a-button type="primary" @click="downloadLog(record)"
                    >下载日志</a-button
                  >
                  <a-button
                    :disabled="record.version != 1"
                    type="primary"
                    @click="edit(record)"
                    >编辑</a-button
                  >
                  <a-button
                    v-if="canDownloadBom"
                    :disabled="record.version == -1"
                    :disabled="record.version == -1 && !isTester"
                    type="primary"
                    @click="checkLock(record)"
                    >下载</a-button
@@ -79,16 +99,22 @@
                  <a-button
                    type="primary"
                    v-if="canFeedback"
                    :disabled="record.version == -1"
                    @click="showFeedback(record)"
                    >反馈</a-button
                  >
                  <a-button
                    type="primary"
                    v-if="record.ecrList.length > 0"
                    @click="showEcrlist(record)"
                    >ecr记录</a-button
                  <a-badge
                    :count="record.ecrList.length"
                    showZero
                    :number-style="{
                      backgroundColor: record.ecrList.length > 0 ? '#090' : '#900',
                    }"
                  >
                    <a-button
                      type="primary"
                      @click="showEcrlist(record)"
                      >ecr记录</a-button
                      >
                  </a-badge>
                </a-space>
                <a>更多</a>
              </a-popover>
@@ -337,7 +363,9 @@
            <div>
              <span class="user">{{ item.owner }}</span> 在
              <span class="time">{{ item.createTime }}</span>
              {{ item.lockFlag ? "锁定" : "激活" }}了版本
              {{
                { "-1": "上传", "0": "激活", "1": "锁定" }[item.lockFlag]
              }}了版本
              <span class="version">{{ item.versionTime }}</span>
            </div>
            <div>操作原因: {{ item.reason ? item.reason : "无" }}</div>
@@ -451,6 +479,48 @@
        rowKey="num"
      ></a-table>
    </a-modal>
    <!-- 操作原因 -->
    <a-modal
      :visible="reasonVisible"
      :width="460"
      title="操作原因"
      :destroyOnClose="true"
      :maskClosable="false"
      @cancel="reasonCancel"
      @ok="reasonOk"
    >
      <a-form-model-item ref="name" label="操作原因">
        <a-input
          type="textarea"
          v-model="reason"
          placeHolder="请输入操作原因"
        />
      </a-form-model-item>
    </a-modal>
    <download-reason
      :reason-visible.sync="downloadReasonVisible"
      v-if="downloadReasonVisible"
      @ok="downloadReasonOk"
    ></download-reason>
    <download-logs
      :visible.sync="downloadlogVisible"
      v-if="downloadlogVisible"
      :type="12"
      :oprate-info="oprateInfo"
    ></download-logs>
    <a-modal
      :visible="ownerLogVisible"
      title="我的下载记录"
      width="100%"
      :destroyOnClose="true"
      @cancel="ownerLogClose"
      wrapClassName="full-modal"
    >
      <owner-download></owner-download>
      <template v-slot:footer>
        <a-button @click="ownerLogClose">关闭</a-button>
      </template>
    </a-modal>
  </div>
</template>
@@ -459,6 +529,8 @@
import ChangeParts from "./changeParts";
import ProdUpload from "./prodUpload";
import DrawUpload from "@/pages/components/drawUpload";
import DownloadReason from "@/pages/components/downloadReason";
import DownloadLogs from "@/pages/components/downloadLogs";
import getWebUrl from "@/assets/js/tools/getWebUrl";
import {
@@ -467,7 +539,16 @@
  getAllProducts,
  getLogList,
  getLockedList,
  setpHistoryEnable,
} from "./apis";
import {
  searchDefaultMailUser,
  sendMail,
} from "../../components/emailCard/apis";
import { getUserList } from "../../permission/apis";
import { getRoleUser } from "@/pages/user/apis";
import { submitFeedback } from "@/pages/workplace/apis";
import { productSoftwareSubmit } from "../software/apis";
import { zipParse } from "@/pages/workplace/myDraw/apis";
@@ -478,6 +559,7 @@
import createWs from "@/assets/js/websocket";
import DiffList from "@/pages/components/diffList";
import FeedbackForm from "../components/feedbackForm.vue";
import OwnerDownload from "../components/ownerDownload";
const WSMixin = createWs("product");
export default {
@@ -564,6 +646,14 @@
      },
    ];
    return {
      ownerLogVisible: false,
      reason: "",
      reasonVisible: false,
      oprateInfo: "",
      downloadlogVisible: false,
      tester: [],
      downloadReasonVisible: false,
      curObj: null,
      errorVisible: false,
      ecrColumns,
      feedbackShow: false,
@@ -595,6 +685,8 @@
      },
      prodData: {},
      userList: [],
      userListAll: [],
      mailList: [],
      file: null,
      // title: "",
      fileUrl: "",
@@ -667,6 +759,24 @@
          width: 100,
          scopedSlots: { customRender: "isNormal" },
        },
        {
          title: "待复核",
          dataIndex: "enabled",
          dataType: "boolean",
          align: "center",
          searchAble: true,
          width: 100,
          scopedSlots: { customRender: "enabled" },
        },
        {
          title: "是否可用",
          dataIndex: "enabled1",
          dataType: "boolean",
          align: "center",
          searchAble: false,
          width: 100,
          scopedSlots: { customRender: "enabled1" },
        },
        // {
        //   title: "创建时间",
        //   dataIndex: "createTime",
@@ -732,7 +842,7 @@
            title: "问题描述",
            dataIndex: "irregularDesc",
            align: "center",
          }
          },
        ],
        dataSource: [],
      },
@@ -774,8 +884,115 @@
    DrawUpload,
    DiffList,
    FeedbackForm,
    DownloadReason,
    DownloadLogs,
    OwnerDownload,
  },
  methods: {
    rowClassFn(record) {
      let classList = [];
      if (record.enabled == -1) {
        classList.push("locked");
      }
      if (record.enabled == 0) {
        classList.push("unable");
      }
      return classList;
    },
    unLock(obj) {
      this.curObj = obj;
      this.reasonVisible = true;
    },
    reasonCancel() {
      this.reasonVisible = false;
    },
    reasonOk() {
      let {
        curObj: {
          customCode,
          parentCode,
          version,
          versionTime,
          enabled: lockFlagNow,
        },
        reason,
      } = this;
      let enabled = 1;
      setpHistoryEnable({
        customCode,
        parentCode,
        enabled,
        version,
        reason,
        versionTime,
      }).then((res) => {
        let { code, data } = res.data;
        if (code && data) {
          this.$message.success("操作成功");
          this.sendMessage();
          this.reasonVisible = false;
          // 如果是测试人员解锁确认 则自动发送邮件
          if (lockFlagNow == -1 && this.isTester) {
            this.sendEmail();
          }
        } else {
          this.$message.error("操作失败");
        }
      });
    },
    sendEmail() {
      let { title, content } = this.handleEmailShow(this.curObj, true);
      let params = { mailList: this.mailList, title, content };
      sendMail(params);
    },
    searchAllUserList() {
      getUserList()
        .then((res) => {
          let rs = res.data;
          if (rs.code && rs.data) {
            this.userListAll = rs.data2;
            this.searchDefaultMailUser();
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    searchDefaultMailUser() {
      //  type为3
      let type = 3;
      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.userListAll
          .filter((o) => data.includes(o.name) && o.mail)
          .map((item) => {
            return item.mail;
          });
      });
    },
    handleEmailShow(record, get) {
      let title =
        "[产品发布记录]" + record.parentModel + " 版本:" + record.versionTime;
      let content = [];
      content.push("物料编码: " + record.parentCode);
      content.push("物料名称: " + record.parentName);
      content.push("规格型号: " + record.parentModel);
      content.push("标准机型: " + (!record.customCode ? "是" : "否"));
      content.push("定制单号: " + (record.customCode || "无"));
      content.push("版本时间: " + record.versionTime);
      if (get) {
        return {
          title,
          content: content.join("\n"),
        };
      }
    },
    onSearch(conditions, searchOptions) {
      // console.log(conditions);
      // console.log(searchOptions);
@@ -835,7 +1052,7 @@
      }
    },
    edit(obj) {
      console.log(obj, 99);
      // console.log(obj, 99);
      this.editObj = obj;
      this.editShow = true;
    },
@@ -853,7 +1070,7 @@
            this.lockListVisible = true;
          } else {
            // 没有锁定
            this.download(obj);
            this.showReason(obj);
          }
        } else {
          this.$message.error("查询锁定清单出错");
@@ -865,19 +1082,29 @@
    },
    lockListOk() {
      this.lockListVisible = false;
      this.download(this.currentObj);
      this.showReason(this.currentObj);
    },
    download(obj) {
      const { id, version } = obj;
    showReason(obj) {
      this.curObj = obj;
      this.downloadReasonVisible = true;
    },
    downloadReasonOk(reason) {
      this.download(reason);
    },
    download(reason) {
      const { id, version, parentCode, customCode } = this.curObj;
      let oprateInfo = parentCode + "_" + customCode;
      let loading = this.$layer.loading({ shade: true });
      downloadBom(id, version).then((res) => {
      downloadBom(id, version, reason, oprateInfo).then((res) => {
        // console.log(res, "===========");
        this.$layer.close(loading);
        let { headers, data, status } = res;
        if (200 == status && data) {
          let url = window.URL.createObjectURL(data);
          const matchRes = /filename=(.*)/.exec(headers["content-disposition"]);
          const fileName = matchRes ? matchRes[1].trim() : "未知文件名.zip";
          const fileName = matchRes
            ? decodeURI(matchRes[1].trim())
            : "未知文件名.zip";
          let link = document.createElement("a");
          link.style.display = "none";
          link.href = url;
@@ -980,21 +1207,29 @@
      }
      const { pageCurr, pageSize, conditions, columns } = this;
      let params = {};
      let col, index;
      Object.keys(conditions).forEach((v) => {
        switch (v) {
          case "isNormal":
            if (conditions[v]) {
              params["customCode"] = "";
              columns.forEach((val) => {
              columns.forEach((val, idx) => {
                if (val.dataIndex == "customCode") {
                  val.search.value = "";
                  col = { ...val, search: { value: "", backup: "" } };
                  index = idx;
                }
              });
              this.$set(this.columns, index, col);
            }
            break;
          case "customCode":
            if (params["customCode"] == undefined) {
              params[v] = conditions[v];
            }
            break;
          case "enabled":
            if (conditions[v]) {
              params[v] = -1;
            }
            break;
          default:
@@ -1044,9 +1279,9 @@
        parentName,
      };
      addProduct(param).then((res) => {
        const { code, msg } = res.data;
        const { code, data, msg } = res.data;
        this.$layer.close(loading);
        if (code) {
        if (code && data) {
          this.$message.success(msg);
          this.prodUploadShow = false;
        } else {
@@ -1251,7 +1486,7 @@
      return reg.test(txt);
    },
    viewLog(obj) {
      console.log(obj);
      // console.log(obj);
      const { parentCode, customCode } = obj;
      getLogList({ parentCode, customCode }).then((res) => {
        const { code, data } = res.data;
@@ -1275,6 +1510,33 @@
    },
    ecrListCancel() {
      this.ecrListVisible = false;
    },
    getRoleUser() {
      getRoleUser(1)
        .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);
        });
    },
    downloadLog(record) {
      // console.log(record);
      let { customCode, parentCode } = record;
      this.oprateInfo = parentCode + "_" + customCode;
      this.downloadlogVisible = true;
    },
    ownerDownloadLog() {
      this.ownerLogVisible = true;
    },
    ownerLogClose() {
      this.ownerLogVisible = false;
    },
  },
  watch: {
@@ -1325,6 +1587,7 @@
      "projectManagerList",
      "generalManagerList",
      "permits",
      "user",
    ]),
    ...mapGetters("setting", ["affixed"]),
    canUploadBom() {
@@ -1380,8 +1643,13 @@
      return result;
    },
    isTester() {
      return this.tester.some((v) => v == this.user.name);
    },
  },
  mounted() {
    this.searchAllUserList();
    this.getRoleUser();
    this.getUserByRoleId();
    this.sendMessage();
    this.getAllProducts();
@@ -1500,6 +1768,43 @@
}
.btn-grp .ant-btn {
  min-width: 6em;
  min-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;
}
/deep/.unable > td {
  background: #f0637b;
}
/deep/.unable.unable.unable.ant-table-row-hover > td,
/deep/.unable.unable.unable:hover > td {
  background: #ff869a;
}
</style>
<style lang="less">
.full-modal {
  height: 100%;
  .ant-modal {
    max-width: 100%;
    height: 100%;
    top: 0;
    padding-bottom: 0;
    margin: 0;
  }
  .ant-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    // height: calc(100vh);
  }
  .ant-modal-body {
    flex: 1;
  }
}
</style>