研发图纸文件管理系统-前端项目
he wei
2022-07-23 63362865fb820b1145fde269c706fb17e93e0c1e
UA 图纸历史
3个文件已添加
3个文件已修改
496 ■■■■ 已修改文件
src/pages/drawManage/details/apis.js 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/drawManage/details/details.vue 266 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/drawManage/details/index.js 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/drawManage/drawCenter/DrawCenter.vue 176 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/drawManage/drawCenter/apis.js 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/config.js 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/drawManage/details/apis.js
New file
@@ -0,0 +1,30 @@
import axios from "@/assets/axios";
/**
 * 根据子件code获取最终的信息
 * @returns
 */
export const getInfo = (scode) => {
  return axios({
    method: "GET",
    url: "productBom/getBomBySubcode",
    params: {
      scode
    }
  })
}
/**
 * 根据子件名称和母料型号查询历史版本记录
 * @returns
 */
export const getHistory = (pmodel, sname) => {
  return axios({
    method: "GET",
    url: "productBomHistory/getBomHistoryByPModelAndSName",
    params: {
      pmodel,
      sname
    }
  })
}
src/pages/drawManage/details/details.vue
New file
@@ -0,0 +1,266 @@
<template>
  <a-spin :spinning="spinning" tip="拼命加载中...">
    <a-card>
      <a-descriptions title="图纸信息">
        <a-descriptions-item label="母料型号">{{
          info.parentModel
        }}</a-descriptions-item>
        <a-descriptions-item label="母料名称">{{
          info.parentName
        }}</a-descriptions-item>
        <a-descriptions-item v-if="info.parentCode" label="母料编号">{{
          info.parentCode
        }}</a-descriptions-item>
        <a-descriptions-item label="类别">{{
          info.category
        }}</a-descriptions-item>
        <a-descriptions-item label="子件型号">{{
          info.subModel
        }}</a-descriptions-item>
        <a-descriptions-item label="子件名称">{{
          info.subName
        }}</a-descriptions-item>
      </a-descriptions>
      <advance-table
        :data-source="dataSource"
        :columns="columns"
        :loading="loading"
        title=""
        row-key="subCode"
        @search="onSearch"
        @refresh="onRefresh"
        @reset="onReset"
        :format-conditions="true"
        :scroll="{ x: 2700 }"
      >
        <template slot="title">
          <span class="title">图纸历史版本</span>
        </template>
        <template slot="pictureUrl" slot-scope="{ record }">
          <image-view
            v-if="record"
            :url="webUrl + record.pictureUrl"
            @load="imageLoad"
          ></image-view>
        </template>
        <template slot="action" slot-scope="{ record }">
          <div v-if="record.dwgUrl">
            <a @click="dwgReview(record.dwgUrl)">预览</a>
            <a-divider type="vertical"></a-divider>
            <a :href="webUrl + record.dwgUrl" download>下载</a>
          </div>
        </template>
      </advance-table>
    </a-card>
  </a-spin>
</template>
<script>
import AdvanceTable from "@/components/table/advance/AdvanceTable";
import ImageView from "@/pages/components/ImageView";
import getWebUrl from "@/assets/js/tools/getWebUrl";
import { dwgReview } from "@/pages/workplace/apis";
import { getInfo, getHistory } from "./apis";
export default {
  name: "",
  data() {
    return {
      scode: this.$route.params.subCode,
      info: {},
      webUrl: getWebUrl(),
      loading: false,
      spinning: false,
      y: 500,
      conditions: {},
      columns: [
        {
          title: "子件编码",
          dataIndex: "subCode",
          key: "subCode",
          align: "center",
          width: 130,
        },
        {
          title: "子件型号",
          dataIndex: "subModel",
          key: "subModel",
          width: 180,
          align: "center",
          noSearch: true,
        },
        {
          title: "子件名称",
          dataIndex: "subName",
          key: "subName",
          align: "center",
          width: 180,
          noSearch: true,
        },
        {
          title: "单位",
          dataIndex: "unit",
          key: "unit",
          align: "center",
          width: 80,
          noSearch: true,
        },
        {
          title: "子件数量",
          dataIndex: "quantity",
          key: "quantity",
          align: "center",
          width: 120,
          noSearch: true,
        },
        {
          title: "生产商",
          dataIndex: "producer",
          key: "producer",
          align: "center",
          width: 80,
        },
        {
          title: "封装类型/材质",
          dataIndex: "material",
          key: "material",
          align: "center",
          width: 180,
        },
        {
          title: "元件编号/料厚",
          dataIndex: "thickness",
          key: "thickness",
          align: "center",
          noSearch: true,
          width: 180,
        },
        {
          title: "表面处理/物料详情",
          dataIndex: "surfaceDetail",
          key: "surfaceDetail",
          align: "center",
          noSearch: true,
          width: 180,
        },
        {
          title: "备注",
          dataIndex: "notes",
          key: "notes",
          align: "center",
        },
        {
          title: "图片",
          dataIndex: "pictureUrl",
          key: "pictureUrl",
          align: "center",
          noSearch: true,
          width: 120,
          scopedSlots: { customRender: "pictureUrl" },
        },
        {
          title: "上传人",
          dataIndex: "upUser",
          key: "upUser",
          align: "center",
        },
        {
          title: "创建日期",
          dataIndex: "createDate",
          key: "createDate",
          align: "center",
          noSearch: true,
          width: 120,
        },
        {
          title: "更新日期",
          dataIndex: "updateDate",
          key: "updateDate",
          align: "center",
          noSearch: true,
          width: 120,
        },
        {
          title: "版本",
          dataIndex: "version",
          key: "version",
          align: "center",
          width: 120,
        },
        {
          title: "操作",
          dataIndex: "operation",
          key: "operation",
          align: "center",
          width: 140,
          fixed: "right",
          scopedSlots: { customRender: "action" },
        },
      ],
      dataSource: [],
    };
  },
  components: {
    AdvanceTable,
    ImageView,
  },
  methods: {
    getInfo() {
      getInfo(this.scode).then((res) => {
        res = res.data;
        if (res.code && res.data) {
          this.info = res.data2;
          this.searchData();
        }
      });
    },
    searchData() {
      const { subName, parentModel } = this.info;
      getHistory(parentModel, subName).then((res) => {
        res = res.data;
        console.log(res);
        let data = [];
        if (res.code && res.data) {
          data = res.data2;
        }
        this.dataSource = data;
      });
    },
    dwgReview(url) {
      this.spinning = true;
      dwgReview(url)
        .then((res) => {
          this.spinning = false;
          let rs = res.data;
          if (rs.code == 1 && rs.data) {
            window.open(this.webUrl + rs.data);
          } else {
            this.$message.error(rs.msg);
          }
        })
        .catch((error) => {
          this.spinning = false;
          console.log(error);
        });
    },
    onSearch(conditions, searchOptions) {
      this.conditions = conditions;
      this.searchData();
    },
    onRefresh(conditions) {
      this.conditions = conditions;
      this.searchData();
    },
    onReset(conditions) {
      this.conditions = conditions;
      this.searchData();
    },
  },
  mounted() {
    this.getInfo();
  },
};
</script>
<style scoped>
</style>
src/pages/drawManage/details/index.js
New file
@@ -0,0 +1,2 @@
import details from './details';
export default details;
src/pages/drawManage/drawCenter/DrawCenter.vue
@@ -1,68 +1,89 @@
<template>
  <a-card>
    <advance-table
      :data-source="dataSource"
      :row-selection="{
        selectedRowKeys,
        onChange: onSelectChange,
        fixed: true,
        selections: true,
        columnWidth: 60
      }"
      :columns="columns"
      :loading="loading"
      title=""
      row-key="subCode"
      @search="onSearch"
      @refresh="onRefresh"
      @reset="onReset"
      :format-conditions="true"
      :scroll="{ x: 2700 }"
      :pagination="{
        current: pageCurr,
        pageSize: pageSize,
        total: total,
        showSizeChanger: true,
        showLessItems: true,
        showQuickJumper: true,
        pageSizeOptions: ['10', '20', '50', '100', '1000'],
        showTotal: (total, range) =>
          `第 ${range[0]}-${range[1]} 条,总计 ${total} 条`,
        onChange: onPageChange,
        onShowSizeChange: onSizeChange,
      }"
    >
      <template slot="title">
        <span class="title">图纸中心</span>
        <a-space class="operator" style="margin-left: 1em;">
          <a-button>打包</a-button>
        </a-space>
      </template>
      <template slot="action" slot-scope="scope">
        <a @click="scope.record">下载</a>
        <a-divider type="vertical"></a-divider>
        <a @click="scope.record">详情</a>
      </template>
    </advance-table>
  </a-card>
  <a-spin :spinning="spinning" tip="拼命加载中...">
    <a-card>
      <advance-table
        :data-source="dataSource"
        :row-selection="{
          selectedRowKeys,
          onChange: onSelectChange,
          fixed: true,
          selections: true,
          columnWidth: 60,
        }"
        :columns="columns"
        :loading="loading"
        title=""
        row-key="subCode"
        @search="onSearch"
        @refresh="onRefresh"
        @reset="onReset"
        :format-conditions="true"
        :scroll="{ x: 2700 }"
        :pagination="{
          current: pageCurr,
          pageSize: pageSize,
          total: total,
          showSizeChanger: true,
          showLessItems: true,
          showQuickJumper: true,
          pageSizeOptions: ['10', '20', '50', '100', '1000'],
          showTotal: (total, range) =>
            `第 ${range[0]}-${range[1]} 条,总计 ${total} 条`,
          onChange: onPageChange,
          onShowSizeChange: onSizeChange,
        }"
      >
        <template slot="title">
          <span class="title">图纸中心</span>
          <a-space class="operator" style="margin-left: 1em">
            <a-button @click="packageDoc">打包</a-button>
          </a-space>
        </template>
        <template slot="pictureUrl" slot-scope="{ record }">
          <image-view
            v-if="record"
            :url="webUrl + record.pictureUrl"
            @load="imageLoad"
          ></image-view>
        </template>
        <template slot="action" slot-scope="{ record }">
          <div v-if="record.dwgUrl">
            <a @click="dwgReview(record.dwgUrl)">预览</a>
            <a-divider type="vertical"></a-divider>
            <a :href="webUrl + record.dwgUrl" download>下载</a>
            <a-divider type="vertical"></a-divider>
          </div>
          <a @click="goDetails(record)">详情</a>
        </template>
      </advance-table>
    </a-card>
  </a-spin>
</template>
<script>
import AdvanceTable from "@/components/table/advance/AdvanceTable";
import { searchCadDrawer } from "./apis";
import ImageView from "@/pages/components/ImageView";
import getWebUrl from "@/assets/js/tools/getWebUrl";
import { dwgReview } from "@/pages/workplace/apis";
import { searchCadDrawer, packageDoc } from "./apis";
export default {
  name: "DrawCenter",
  components: {
    AdvanceTable,
    ImageView,
  },
  data() {
    return {
      selectedRowKeys: [],
      selectedRows: [],
      spinning: false,
      loading: false,
      pageCurr: 1,
      pageSize: 10,
      total: 0,
      webUrl: getWebUrl(),
      y: 500,
      conditions: {},
      columns: [
        {
@@ -178,7 +199,8 @@
          key: "pictureUrl",
          align: "center",
          noSearch: true,
          width: 80,
          width: 120,
          scopedSlots: { customRender: "pictureUrl" },
        },
        {
          title: "上传人",
@@ -270,9 +292,63 @@
        this.total = total;
      });
    },
    onSelectChange(selectedRowKeys) {
      console.log('selectedRowKeys changed: ', selectedRowKeys);
    onSelectChange(selectedRowKeys, selectedRows) {
      // console.log("selectedRowKeys changed: ", selectedRowKeys, selectedRows);
      this.selectedRowKeys = selectedRowKeys;
      this.selectedRows = selectedRows;
    },
    imageLoad() {
      this.y++;
      this.$nextTick(() => {
        this.y--;
      });
    },
    dwgReview(url) {
      this.spinning = true;
      dwgReview(url)
        .then((res) => {
          this.spinning = false;
          let rs = res.data;
          if (rs.code == 1 && rs.data) {
            window.open(this.webUrl + rs.data);
          } else {
            this.$message.error(rs.msg);
          }
        })
        .catch((error) => {
          this.spinning = false;
          console.log(error);
        });
    },
    goDetails(recode) {
      console.log(recode);
      const { subCode } = recode;
      this.$router.push(`/draw/details/${subCode}`);
    },
    packageDoc() {
      if (!this.selectedRowKeys.length) {
        this.$message.info("请选择要打包的子件");
        return false;
      }
      // TODO
      const params = {
        list: this.selectedRows.map((v) => v.fileUrl),
      };
      packageDoc(params).then((res) => {
        // console.log(res, "===========");
        let { headers, data } = res;
        let url = window.URL.createObjectURL(data);
        const matchRes = /filename=(.*)/.exec(headers["content-disposition"]);
        const fileName = matchRes ? matchRes[1].trim() : "未知文件名.zip";
        let link = document.createElement("a");
        link.style.display = "none";
        link.href = url;
        link.download = fileName;
        document.body.appendChild(link);
        link.click();
        document.body.removeChild(link);
        window.URL.revokeObjectURL(url);
      });
    },
  },
  computed: {},
src/pages/drawManage/drawCenter/apis.js
@@ -13,16 +13,13 @@
  })
}
/**
 * 新增用户
 * 图纸打包下载
 * @returns 
 */
export const addUser = (data) => {
export const packageDoc = () => {
  return axios({
    method: "POST",
    url: "docUser/addUser",
    headers: {
      "Content-Type": "multipart/form-data"
    },
    data
    method: "GET",
    url: "productBom/downloadCadDrawer",
    responseType: "blob"
  })
}
src/router/config.js
@@ -50,6 +50,15 @@
              name: '图纸中心',
              component: () => import('@/pages/drawManage/drawCenter'),
            },
            {
              path: 'details/:subCode',
              name: '图纸详情',
              meta: {
                invisible: true,
                highlight: '/draw/center'
              },
              component: () => import('@/pages/drawManage/details'),
            },
            // {
            //   path: 'analysis',
            //   name: '图纸审批',