研发图纸文件管理系统-前端项目
longyvfengyun
2022-10-14 15da0c3d194b553ebb354a11dbabda53b85f3e43
内容修改
1个文件已修改
172 ■■■■■ 已修改文件
src/pages/resourceManage/product/list.vue 172 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/resourceManage/product/list.vue
@@ -245,6 +245,31 @@
        <a-tab-pane key="2" tab="差异">
          <diff-list :list="diffData"></diff-list>
        </a-tab-pane>
        <a-tab-pane key="3" :tab="abLabel">
          <a-table
            ref="aTable"
            size="small"
            :scroll="{y: 700 }"
            bordered
            :columns="abTbl.columns"
            :data-source="abTbl.dataSource"
            :pagination="false"
            rowKey="subCode"></a-table>
          <div style="text-align: right; padding: 8px;">
            <a-button @click="abTbl.ignore=true" :type="abState?'danger':'primary'" :icon="abState?'question':'check'">{{ abState?"未确认":"已确认" }}</a-button>
          </div>
        </a-tab-pane>
        <a-tab-pane key="4" :tab="errorLabel">
          <a-table
            ref="aTable"
            size="small"
            :scroll="{y: 700 }"
            bordered
            :columns="errorTbl.columns"
            :data-source="errorTbl.dataSource"
            :pagination="false"
            rowKey="subCode"></a-table>
        </a-tab-pane>
      </a-tabs>
      <prod-upload
        class="mt8"
@@ -361,6 +386,46 @@
  name: "",
  mixins: [WSMixin],
  data() {
    const abColumns = [
      {
        title: "子件编码",
        dataIndex: "subCode",
        width: 120,
        align: "center",
      },
      {
        title: "子件名称",
        dataIndex: "subName",
        align: "center",
        ellipsis: true,
      },
      {
        title: "子件型号",
        dataIndex: "subModel",
        align: "center",
        ellipsis: true,
      },
    ];
    const errorColumns = [
      {
        title: "子件编码",
        dataIndex: "subCode",
        width: 120,
        align: "center",
      },
      {
        title: "子件名称",
        dataIndex: "subName",
        align: "center",
        ellipsis: true,
      },
      {
        title: "子件型号",
        dataIndex: "subModel",
        align: "center",
        ellipsis: true,
      },
    ];
    return {
      lockListVisible: false,
      currentObj: null,
@@ -485,6 +550,15 @@
        },
      ],
      dataSource: [],
      abTbl: {
        ignore: false,
        columns: abColumns,
        dataSource: [],
      },
      errorTbl: {
        columns: errorColumns,
        dataSource: [],
      },
      bomLockColumns: [
        {
          title: "子件名称",
@@ -760,6 +834,11 @@
      this.prodUploadShow = false;
    },
    submit(data) {
      if(this.submitState.code) {
        this.$layer.msg(this.submitState.msg);
        return;
      }
      let loading = this.$layer.loading();
      // console.log(data);
      const { parentCode, parentModel, parentName, bomList } = this.resList;
      const param = {
@@ -774,6 +853,7 @@
      };
      addProduct(param).then((res) => {
        const { code, msg } = res.data;
        this.$layer.close(loading);
        if (code) {
          this.$message.success(msg);
          this.prodUploadShow = false;
@@ -826,7 +906,6 @@
        return false;
      }
      let loading = this.$layer.loading();
      debugger;
      const formData = new FormData();
      formData.append("file", this.file);
      if (this.fromProd) {
@@ -844,6 +923,10 @@
          let { code, data, data2, data3, msg } = res.data;
          if (code && data) {
            this.resList = data2;
            let abAndErr = this.getAbAndError(data2.bomList);
            this.abTbl.dataSource = abAndErr.ab;
            this.errorTbl.dataSource = abAndErr.error;
            this.diffData = {
              addList: data3.addList,
              delList: data3.deleteList.map((v) => v.materialObj),
@@ -861,6 +944,44 @@
        });
      })
      this.bomUploadShow = false;
    },
    /**
     * 获取异常和错误的Bom信息
     * @param list
     * @returns {{ab: *[], error: *[]}}
     */
    getAbAndError(list) {
      let ab = ['0101', '0102', '0103', '0105'];
      let error = ['0104', '0106'];
      let result = {
        ab: [],
        error: []
      };
      for(let i=0; i<list.length; i++) {
        let item = list[i];
        let subCode = item.subCode.trim().slice(0,4);
        let dwgExist = item.dwgExist;
        if(!dwgExist) {
          let isInAb = false;
          for(let j=0; j<ab.length; j++) {
            if(ab[j] == subCode) {
              result.ab.push(item);
              isInAb = true;
              break;
            }
          }
          // 是否已经存在ab中
          if(!isInAb) {
            for(let j=0; j<error.length; j++) {
              if(error[j] == subCode) {
                result.error.push(item);
                break;
              }
            }
          }
        }
      }
      return result;
    },
    getAllProducts() {
      getAllProducts().then((res) => {
@@ -928,6 +1049,14 @@
        this.update = Math.random();
      }, 200);
    },
    prodUploadShow(n) {
      // 关闭弹出框清空数据并不能忽视异常数据
      if(!n) {
        this.errorTbl.dataSource = [];
        this.abTbl.dataSource = [];
        this.abTbl.ignore = false;
      }
    }
  },
  computed: {
    ...mapGetters("account", [
@@ -946,6 +1075,47 @@
    canDownloadBom() {
      return checkPermit(PERMITS.downloadBom, this.permits);
    },
    abLabel() {
      let num = this.abTbl.dataSource.length;
      num = num>99?'99+':num;
      return "异常("+num+")";
    },
    errorLabel() {
      let num = this.errorTbl.dataSource.length;
      num = num>99?'99+':num;
      return "错误("+num+")";
    },
    abState() {
      let result = false;
      if(this.abTbl.dataSource.length != 0) {
        if(this.abTbl.ignore) {
          result = false;
        }else {
          result = true;
        }
      }else {
        result = false;
      }
      return result;
    },
    submitState() {
      let result = {
        code: 0,
        msg: "存在异常或错误的数据,请修复后再提交"
      };
      if(this.abState) {
        result.code = 1;
      }else {
        result.code = 0;
      }
      if(this.errorTbl.dataSource.length !=0) {
        result.code = 1;
      }
      return result;
    }
  },
  mounted() {
    this.getUserByRoleId();