研发图纸文件管理系统-前端项目
longyvfengyun
2023-12-22 83014a0eed8d21d9299d228b2287293f35a45637
物料中心内容修改
2个文件已修改
123 ■■■■ 已修改文件
src/pages/resourceManage/materialsCenter/apis.js 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/resourceManage/materialsCenter/list.vue 92 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/resourceManage/materialsCenter/apis.js
@@ -2,7 +2,7 @@
/**
 * 图纸查询分类检索
 * @returns
 * @returns
 */
// export const searchCadDrawer = (params, data) => {
//   return axios({
@@ -14,7 +14,7 @@
// }
/**
 * 图纸打包下载
 * @returns
 * @returns
 */
// export const packageDoc = (pictureUrls) => {
//   return axios({
@@ -40,7 +40,7 @@
  })
}
/**
 * 建立关联时查询所有的物料(不分页)
 * 建立关联时查询所有的物料(不分页)
 */
export const getAllMaterialNoLimit = () => {
  return axios({
@@ -50,7 +50,7 @@
}
/**
 * zip解析 新增物料
 * @returns
 * @returns
 */
export const zipParse = (data) => {
  return axios({
@@ -87,6 +87,25 @@
}
/**
 * 获取单个物料的信息
 * @param subCode 编码
 * @param subModel  物料型号
 * @param subName 物料名称
 * @return {AxiosPromise}
 */
export const getMaterialInfoApi = (subCode, subModel, subName)=>{
  return axios({
    method: "GET",
    url: "material/getMaterialDialog",
    params: {
      subCode,
      subModel,
      subName
    }
  })
}
/**
 * 查询物料的历史版本
 * @returns
 */
@@ -111,7 +130,7 @@
}
/**
 *
 *
 * @returns
 */
export const uploadOthers = (data) => {
@@ -175,4 +194,4 @@
    url: "material",
    data
  })
}
}
src/pages/resourceManage/materialsCenter/list.vue
@@ -166,8 +166,8 @@
      <div class="type-grp">
        <a-radio-group v-model="uploadType" button-style="solid">
          <a-radio-button value="normal"> 普通附件 </a-radio-button>
          <a-radio-button value="pic"> 图片 </a-radio-button>
          <a-radio-button value="dwg"> 图纸 </a-radio-button>
          <a-radio-button value="pic" :disabled="isSpecialMater"> 图片 </a-radio-button>
          <a-radio-button value="dwg" :disabled="isSpecialMater"> 图纸 </a-radio-button>
        </a-radio-group>
      </div>
      <a-upload
@@ -178,6 +178,7 @@
        <!-- :showUploadList="false" -->
        <a-button type="primary">选择附件</a-button>
      </a-upload>
        <div v-show="isSpecialMater" class="text-msg">0108,0109开头的物料仅允许上传普通附件(图纸也通过普通附件进行上传)</div>
    </a-modal>
    <a-modal
      :visible="errorVisible"
@@ -219,11 +220,11 @@
import getWebUrl from "@/assets/js/tools/getWebUrl";
import {
  uploadOthers,
  picOrDwg,
  zipParse,
  getFileList,
  addMaterial,
    uploadOthers,
    picOrDwg,
    zipParse,
    getFileList,
    addMaterial, getMaterialInfoApi,
} from "./apis";
import { dwgReview } from "@/pages/workplace/apis";
// import { downloadLog } from "@/pages/system/logs/apis";
@@ -443,6 +444,12 @@
    canUpload() {
      return checkPermit(PERMITS.uploadBom, this.permits);
    },
      isSpecialMater() {
          const { subCode } = this.currentObj;
          const reg = /^(0108\d+)|(0109\d+)/;
            return reg.test(subCode);
      }
  },
  components: {
    AdvanceTable,
@@ -606,8 +613,10 @@
        });
    },
    fileUploadShow() {
            this.uploadType = "normal";
      this.uploadFileList = [];
      this.fileUploadVisible = true;
    },
    fileUploadCancel() {
      this.fileUploadVisible = false;
@@ -633,31 +642,38 @@
      this.uploadFileList.forEach((v, i) => {
        formData.append("file", v.originFileObj);
      });
      if (
        this.uploadType == "normal" &&
        this.uploadFileList.some((v) => v.name.toLowerCase() == dwgFileName)
      ) {
        this.$message.error("所选附件类型不匹配");
        this.$layer.close(loading);
        return false;
      }
      if (
        this.uploadType == "dwg" &&
        this.uploadFileList.some((v) => v.name.toLowerCase() != dwgFileName)
      ) {
        this.$message.error("所选附件类型不匹配");
        this.$layer.close(loading);
        return false;
      }
            // 特殊物料不进行校验名称,统一按普通附件进行上传
            const isSpecial = this.isSpecialMater;
            if(!isSpecial) {
                if (
                    this.uploadType == "normal" &&
                    this.uploadFileList.some((v) => v.name.toLowerCase() == dwgFileName)
                ) {
                    this.$message.error("所选附件类型不匹配");
                    this.$layer.close(loading);
                    return false;
                }
                if (
                    this.uploadType == "dwg" &&
                    this.uploadFileList.some((v) => v.name.toLowerCase() != dwgFileName)
                ) {
                    this.$message.error("所选附件类型不匹配");
                    this.$layer.close(loading);
                    return false;
                }
            }
      let upload = this.uploadType != "normal" ? picOrDwg : uploadOthers;
            upload = isSpecial?uploadOthers:upload;
      upload(formData)
        .then((res) => {
          this.$layer.close(loading);
          const { code, data, msg } = res.data;
          if (code && data) {
            this.$message.success(msg);
            this.panelShow(this.currentObj);
              this.getMaterialInfo(this.currentObj);
            this.fileUploadVisible = false;
          } else {
            this.$message.error(msg);
          }
@@ -667,6 +683,18 @@
          console.log(error);
        });
    },
      async getMaterialInfo(obj) {
            const {subCode, subModel, subName} = obj;
            try{
                const res = await getMaterialInfoApi(subCode, subModel, subName);
                const rs = res.data;
                if(rs.code ===1 && rs.data) {
                    this.panelShow(rs.data2);
                }
            }catch (e) {
                console.log(e);
            }
      },
    resCancel() {
      this.resShow = false;
    },
@@ -725,7 +753,7 @@
            let fileName = v.match(reg2)[2];
            let arr = fileName.split(".");
            let fileType = arr.length ? arr[arr.length - 1].toLowerCase() : "";
            return !(reg.test(fileName) && fileType == "dwg");
            return !(reg.test(fileName) && fileType == "dwg" && !this.isSpecialMater);
          });
        }
        if (dwgUrl) {
@@ -740,14 +768,23 @@
            const {dwgUrl, attachLocks, attachFileList} = obj;
            let isHasNewFile = true;   // 标识是否存有文件,没有锁定和未锁定日志
            if(attachFileList) {
                let boolList =  [];
                for(let i=0; i<attachFileList.length; i++) {
                    const itemI = attachFileList[i];
                    let isHasFile = false;
                    for(let j=0; j<attachLocks.length; j++) {
                        const itemJ = attachLocks[j];
                        if(itemI === itemJ.attachName) {
                            isHasNewFile = false;
                            isHasFile = true;
                            break;
                        }
                    }
                    boolList.push(isHasFile);
                }
                for(let i=0; i<boolList.length; i++) {
                    if(!boolList[i]) {
                        isHasNewFile = true;
                        break;
                    }
                }
            }else {
@@ -880,4 +917,7 @@
a.not-can-use {
    color: #808080;
}
.text-msg {
    color: #FF0000;
}
</style>