quwangxin 2 лет назад
Родитель
Сommit
090f1fbba8

+ 34 - 5
src/api/system/file/index.js

@@ -1,4 +1,5 @@
 import request from '@/utils/request';
+import { download } from '@/utils/file';
 
 /**
  * 上传文件
@@ -14,6 +15,22 @@ export async function uploadFile (data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 上传文件 批量
+ * @param file 文件
+ */
+export async function uploadBatch (data) {
+  const formData = new FormData();
+  formData.append('multiPartFiles', data.multiPartFiles);
+  const res = await request.post(
+    `/main/file/uploadBatch?module=${data.module}`,
+    formData
+  );
+  if (res.data.code === '0') {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}
 
 /**
  * 获取文件
@@ -21,12 +38,14 @@ export async function uploadFile (data) {
 export async function getFile (params) {
   const res = await request.get('/main/file/getFile', {
     params,
-    headers: { requestType: 'blob' }
+    responseType: 'blob'
   });
-  if (res.data.code === '0') {
-    return res.data.data;
-  }
-  return Promise.reject(new Error(res.data.message));
+  const arr = params.objectName.split('/');
+  download(res.data, arr[arr.length - 1]);
+  // if (res.data.code === '0') {
+  //   return res.data.data;
+  // }
+  // return Promise.reject();
 }
 
 /**
@@ -42,3 +61,13 @@ export async function removeFile (data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
+/**
+ * 文件列表
+ */
+export async function getFileList (data) {
+  const res = await request.post(`/main/file/list`, data);
+  if (res.data.code === '0') {
+    return res.data.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 64 - 0
src/components/CommomSelect/category-select.vue

@@ -0,0 +1,64 @@
+<!-- 部门树形选择下拉框 -->
+<template>
+  <ele-tree-select
+    clearable
+    :value="value || ''"
+    :data="treeData"
+    label-key="name"
+    value-key="id"
+    default-expand-all
+    ref="treeSelect"
+    :placeholder="placeholder"
+    @input="updateValue"
+    @change="changeChoose"
+  />
+</template>
+
+<script>
+  import { getTreeByPid } from '@/api/material/manage.js';
+  export default {
+    props: {
+      // 选中的数据(v-model)
+      value: [Number, String],
+      // 提示信息
+      placeholder: {
+        type: String,
+        default: '请选择'
+      },
+      pid: {
+        type: String,
+        default: ''
+      }
+    },
+    data () {
+      return {
+        treeData: []
+      };
+    },
+    created () {
+      this.getData();
+    },
+    methods: {
+      async getData () {
+        const data = await getTreeByPid(this.pid);
+        this.treeData = this.$util.toTreeData({
+          data: data || [],
+          idField: 'id',
+          parentIdField: 'parentId'
+        });
+      },
+      /* 更新选中数据 */
+      updateValue (value) {
+        this.$emit('input', value);
+      },
+
+      changeChoose (val) {
+        this.$emit(
+          'changeGroup',
+          val,
+          this.$refs.treeSelect.getNodeByValue(val)
+        );
+      }
+    }
+  };
+</script>

+ 2 - 1
src/enum/dict.js

@@ -23,5 +23,6 @@ export default {
   排程类型: 'schedule_type',
   提前期单位: 'leadtime_unit',
   价格单位: 'price_unit',
-  检验方案: 'inspection_scheme'
+  检验方案: 'inspection_scheme',
+  文件模块: 'file_module'
 };

+ 1 - 1
src/utils/file.js

@@ -23,7 +23,7 @@ export function getImagePath (url) {
 // 下载方法
 export function download (data, name) {
   const a = document.createElement('a');
-  const url = window.URL.createObjectURL(new Blob([data]));
+  const url = window.URL.createObjectURL(data);
   const filename = name;
   a.href = url;
   a.download = filename;

+ 3 - 1
src/utils/request.js

@@ -9,11 +9,13 @@ import { API_BASE_URL, TOKEN_HEADER_NAME, LAYOUT_PATH } from '@/config/setting';
 import { getToken, setToken } from './token-util';
 import { logout } from './page-tab-util';
 import JSONBIG from 'json-bigint';
-
 const service = axios.create({
   baseURL: API_BASE_URL,
   transformResponse: [
     function (data) {
+      if (data instanceof Blob) {
+        return data;
+      }
       const json = JSONBIG({
         storeAsString: true
       });

+ 0 - 0
src/views/documentManagement/certificateManagement/index.vue


+ 98 - 0
src/views/documentManagement/docManagement/components/doc-search.vue

@@ -0,0 +1,98 @@
+<!-- 搜索表单 -->
+<template>
+  <el-form
+    label-width="77px"
+    class="ele-form-search"
+    @keyup.enter.native="search"
+    @submit.native.prevent
+  >
+    <el-row :gutter="10">
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="文档名称">
+          <el-input clearable v-model="where.name" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="模块名">
+          <el-input clearable v-model="where.module" placeholder="请输入" />
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item label="上传时间">
+          <el-date-picker
+            type="daterange"
+            class="ele-fluid"
+            end-placeholder="结束日期"
+            start-placeholder="开始日期"
+            v-model="where.time"
+            range-separator="至"
+            value-format="yyyy-MM-dd HH:mm:ss"
+          >
+          </el-date-picker>
+        </el-form-item>
+      </el-col>
+      <el-col v-bind="styleResponsive ? { md: 6 } : { span: 6 }">
+        <el-form-item>
+          <el-button
+            type="primary"
+            icon="el-icon-search"
+            class="ele-btn-icon"
+            @click="search"
+          >
+            查询
+          </el-button>
+
+          <el-button
+            @click="reset"
+            icon="el-icon-refresh"
+            class="ele-btn-icon"
+            size="medium"
+            >重置</el-button
+          >
+        </el-form-item>
+      </el-col>
+    </el-row>
+  </el-form>
+</template>
+
+<script>
+  export default {
+    data () {
+      // 默认表单数据
+      const defaultWhere = {
+        module: '',
+        name: '',
+        time: []
+      };
+      return {
+        defaultWhere,
+        // 表单数据
+        where: { ...defaultWhere }
+      };
+    },
+    computed: {
+      // 是否开启响应式布局
+      styleResponsive () {
+        return this.$store.state.theme.styleResponsive;
+      }
+    },
+    methods: {
+      /* 搜索 */
+      search () {
+        const where = { ...this.where };
+        if (where.time?.length) {
+          where.startTime = where.time[0];
+          where.endTime = where.time[1];
+        }
+
+        delete where.time;
+        this.$emit('search', where);
+      },
+      /*  重置 */
+      reset () {
+        this.where = { ...this.defaultWhere };
+        this.search();
+      }
+    }
+  };
+</script>

+ 119 - 0
src/views/documentManagement/docManagement/components/upload-dialog.vue

@@ -0,0 +1,119 @@
+<template>
+  <!-- 上传 -->
+  <el-dialog title="文件上传" :visible.sync="uploadShow" width="40%">
+    <el-form label-width="110px" class="zw-criterion">
+      <el-form-item label="选择文件">
+        <el-upload
+          class="avatar-uploader"
+          action="#"
+          :show-file-list="false"
+          :http-request="handlSuccess"
+          :before-upload="beforeUpload"
+        >
+          <el-button icon="el-icon-plus" size="small" type="primary"
+            >文件上传</el-button
+          >
+        </el-upload>
+      </el-form-item>
+      <el-form-item label="模块名">
+        <DictSelection v-model="module"></DictSelection>
+      </el-form-item>
+      <el-form-item label="">
+        <div class="imgs-box">
+          <p v-for="(item, index) in attaments" :key="index" class="imgs-p">
+            <span> {{ item.name }}</span>
+            <el-link @click="delFileList(index)" type="primary">删除</el-link>
+          </p>
+        </div>
+      </el-form-item>
+    </el-form>
+    <div slot="footer" class="dialog-footer">
+      <el-button size="small" @click="uploadShow = false">关 闭</el-button>
+      <el-button size="small" @click="upload" type="primary">上 传</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import { uploadBatch } from '@/api/system/file/index.js';
+
+  export default {
+    //注册组件
+    data () {
+      return {
+        showViewer: false, // 显示查看器
+        dialogVisible: false,
+        uploadShow: false,
+        attaments: [], //上传文件
+        module: '',
+        file: ''
+      };
+    },
+    created () {},
+    methods: {
+      open () {
+        this.attaments = [];
+        this.module = '';
+        this.dialogVisible = true;
+      },
+      //删除附件
+      delFileList (index) {
+        this.attaments.splice(index, 1);
+      },
+      //上传限制
+      beforeUpload (file) {
+        const isLt10M = file.size / 1024 / 1024 < 10;
+        if (!isLt10M) {
+          this.$message.error('上传文件大小不能超过 10MB!');
+        }
+        return isLt10M;
+      },
+      //图片上传
+      handlSuccess (param) {
+        this.file = param.file;
+        this.attaments.push(param.file);
+      },
+      // 文件上传
+      upload () {
+        if (this.attaments.length == 0) {
+          return this.$message.warning('文件不能为空!');
+        }
+        if (!this.module) {
+          return this.$message.warning('模块名不能为空!');
+        }
+        let res = uploadBatch({
+          module: this.module,
+          multiPartFiles: this.attaments.map((i) => i.file)
+        });
+        if (res.success) {
+          this.$message.success('操作成功!');
+          this.uploadShow = false;
+          this.handleList(this.searchForm);
+        }
+      }
+    }
+  };
+</script>
+
+<style lang="scss">
+  .zw-table-header {
+    float: right;
+  }
+
+  .imgs-box .imgs-p {
+    height: 30px;
+    background: #f0f3f3;
+    line-height: 30px;
+    width: 372px;
+    margin-bottom: 5px;
+    padding: 0 10px;
+    display: flex;
+    justify-content: space-between;
+  }
+  .zw-criterion-normal {
+    padding: 20px 0 0 0;
+  }
+  .el-main {
+    overflow: hidden;
+  }
+</style>

+ 96 - 0
src/views/documentManagement/docManagement/index.vue

@@ -0,0 +1,96 @@
+<template>
+  <div class="ele-body">
+    <el-card shadow="never">
+      <doc-search @search="reload" />
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        height="calc(100vh - 350px)"
+        class="dict-table"
+        tool-class="ele-toolbar-actions"
+      >
+        <!-- 工具栏 -->
+        <template v-slot:toolbar>
+          <el-button type="primary" @click="handleUpload">上传</el-button>
+        </template>
+        <template v-slot:action="{ row }">
+          <el-link type="primary" @click="handleDownload(row)">下载</el-link>
+        </template>
+      </ele-pro-table>
+    </el-card>
+    <uploadDialog ref="uploadDialogRef" />
+  </div>
+</template>
+
+<script>
+  import { getFile, getFileList } from '@/api/system/file/index.js';
+
+  import docSearch from './components/doc-search';
+  import uploadDialog from './components/upload-dialog.vue';
+  export default {
+    components: { docSearch, uploadDialog },
+    data () {
+      return {
+        columns: [
+          {
+            label: '序号',
+            type: 'index',
+            width: 55,
+            align: 'center'
+          },
+          {
+            label: '文档名称',
+            prop: 'name',
+            minWidth: '180',
+            showOverflowTooltip: true
+          },
+          {
+            label: '文档类型',
+            prop: 'type'
+          },
+          {
+            label: '系统'
+          },
+          {
+            label: '储存路径',
+            prop: 'storePath',
+            minWidth: '180',
+            showOverflowTooltip: true
+          },
+          {
+            label: '模块名',
+            prop: 'module'
+          },
+          {
+            label: '上传时间',
+            prop: 'createTime'
+          },
+          {
+            label: '操作',
+            slot: 'action',
+            action: 'action'
+          }
+        ]
+      };
+    },
+    methods: {
+      datasource ({ page, where, limit }) {
+        return getFileList({
+          ...where,
+          pageNum: page,
+          size: limit
+        });
+      },
+      reload (where) {
+        this.$refs.table.reload({ where });
+      },
+      handleUpload () {
+        this.$refs.uploadDialogRef.open();
+      },
+      handleDownload (row) {
+        getFile({ objectName: row.storePath });
+      }
+    }
+  };
+</script>

+ 114 - 39
src/views/material/productLinkMaterial/components/link-material-dialog.vue

@@ -24,23 +24,32 @@
         <el-form label-width="100px">
           <el-row>
             <el-col :span="12">
-              <el-form-item :label="`${catogaryName}分类`">
-                <el-input
+              <el-form-item :label="`分类`">
+                <categorySelect
+                  :pid="type"
+                  :key="type"
+                  v-model="where.categoryLevelGroupId"
+                />
+                <!-- <el-input
                   placeholder="请输入"
-                  v-model="where.categoryLevelRootId"
-                ></el-input> </el-form-item
-            ></el-col>
+                  clearable
+                  v-model="where.categoryLevelGroupId"
+                ></el-input> -->
+              </el-form-item></el-col
+            >
             <el-col :span="12">
-              <el-form-item :label="`${catogaryName}编码`">
+              <el-form-item :label="`编码`">
                 <el-input
                   placeholder="请输入"
+                  clearable
                   v-model="where.code"
                 ></el-input></el-form-item
             ></el-col>
             <el-col :span="12">
-              <el-form-item :label="`${catogaryName}名称`">
+              <el-form-item :label="`名称`">
                 <el-input
                   placeholder="请输入"
+                  clearable
                   v-model="where.name"
                 ></el-input></el-form-item
             ></el-col>
@@ -48,6 +57,7 @@
               <el-form-item label="型号">
                 <el-input
                   placeholder="请输入"
+                  clearable
                   v-model="where.modelType"
                 ></el-input></el-form-item
             ></el-col>
@@ -56,7 +66,7 @@
         <ele-pro-table
           ref="table"
           :columns="columns"
-          :datasource="datasource"
+          :datasource="datasourceShow"
           :selection.sync="selection"
           cache-key="link-material-dialog"
           height="45vh"
@@ -88,22 +98,25 @@
         <el-form label-width="100px">
           <el-row>
             <el-col :span="12">
-              <el-form-item :label="`${catogaryName}分类`">
-                <el-input
-                  placeholder="请输入"
-                  v-model="whereRight.categoryLevelRootId"
-                ></el-input> </el-form-item
+              <el-form-item :label="`分类`">
+                <categorySelect
+                  :pid="type"
+                  :key="type"
+                  v-model="whereRight.categoryLevelGroupId"
+                /> </el-form-item
             ></el-col>
             <el-col :span="12">
-              <el-form-item :label="`${catogaryName}编码`">
+              <el-form-item :label="`编码`">
                 <el-input
+                  clearable
                   placeholder="请输入"
                   v-model="whereRight.code"
                 ></el-input></el-form-item
             ></el-col>
             <el-col :span="12">
-              <el-form-item :label="`${catogaryName}名称`">
+              <el-form-item :label="`名称`">
                 <el-input
+                  clearable
                   placeholder="请输入"
                   v-model="whereRight.name"
                 ></el-input></el-form-item
@@ -111,6 +124,7 @@
             <el-col :span="12">
               <el-form-item label="型号">
                 <el-input
+                  clearable
                   placeholder="请输入"
                   v-model="whereRight.modelType"
                 ></el-input></el-form-item
@@ -120,7 +134,7 @@
         <ele-pro-table
           ref="tableRight"
           :columns="columnsRight"
-          :datasource="datasourceRight"
+          :datasource="datasourceRightShow"
           :selection.sync="selectionRight"
           height="45vh"
           :initLoad="false"
@@ -151,6 +165,10 @@
                 </DictSelection
               ></el-col>
             </el-row>
+          </template>
+          <template v-slot:angle="{ row }">
+            <DictSelection dictName="角度" clearable v-model="row.angle">
+            </DictSelection>
           </template> </ele-pro-table
       ></el-col>
     </el-row>
@@ -169,13 +187,17 @@
     productTieUpMaterial
   } from '@/api/material/product.js';
   import dictMixins from '@/mixins/dictMixins';
+  import categorySelect from '@/components/CommomSelect/category-select.vue';
   export default {
     mixins: [dictMixins],
+    components: { categorySelect },
     data () {
       return {
         visible: false,
         row: {},
         datasource: [],
+        datasourceShow: [],
+        datasourceRightShow: [],
         datasourceRight: [],
         selectionRight: [],
         selection: [],
@@ -243,11 +265,28 @@
             label: '型号',
             prop: 'modelType'
           },
-          {
-            label: '产能',
-            slot: 'capacity',
-            action: 'capacity'
-          }
+          ...(this.type == 8
+            ? [
+                {
+                  label: '槽数',
+                  prop: 'modelType'
+                },
+                {
+                  label: '角度',
+                  slot: 'angle',
+                  action: 'angle'
+                }
+              ]
+            : []),
+          ...(this.type == 4
+            ? [
+                {
+                  label: '产能',
+                  slot: 'capacity',
+                  action: 'capacity'
+                }
+              ]
+            : [])
         ];
       }
     },
@@ -263,18 +302,18 @@
         this.visible = false;
       },
       async save () {
-        if (!this.datasourceRight.length) {
+        if (!this.datasourceRightShow.length) {
           return this.$message.error('请添加关联数据');
         }
         const params = {
           mainCategoryId: this.row.categoryLevelId,
           mainCategoryLevelRootId: this.row.categoryLevelGroupId,
-          materialDetailsPOList: this.datasourceRight.map((i) => ({
+          materialDetailsPOList: this.datasourceRightShow.map((i) => ({
             ...i,
             categoryLevelRootId: this.type
           }))
         };
-        const res = await productTieUpMaterial(params);
+        await productTieUpMaterial(params);
 
         this.$message.success('操作成功!');
         this.$emit('success');
@@ -283,44 +322,80 @@
         if (!this.selection.length) {
           return this.$message.error('请选择关联数据');
         }
+        this.datasource = this.datasource.filter((i) =>
+          this.selection.find((t) => t.categoryId != i.categoryId)
+        );
+        this.datasourceShow = this.datasourceShow.filter((i) =>
+          this.selection.find((t) => t.categoryId != i.categoryId)
+        );
+
+        this.datasourceRightShow.push(...this.selection);
         this.datasourceRight.push(...this.selection);
-        this.selection = [];
 
-        //   this.	"quantity": "",
-        // "quantityUnitId": "",
-        // "timeUnit": 0,
-        // "timeValue": 0
+        this.selection = [];
       },
       handleCancelConect () {
         if (!this.selectionRight.length) {
           return this.$message.error('请选择取消关联数据');
         }
 
-        this.datasourceRight.push(...this.selectionRight);
+        this.datasourceRight = this.datasourceRight.filter((i) =>
+          this.selectionRight.find((t) => t.categoryId != i.categoryId)
+        );
+        this.datasourceRightShow = this.datasourceRightShow.filter((i) =>
+          this.selectionRight.find((t) => t.categoryId != i.categoryId)
+        );
+
+        this.datasourceShow.push(...this.selectionRight);
+        this.datasource.push(...this.selectionRight);
+
         this.selectionRight = [];
       },
       reload () {
-        this.$refs.table.reload();
+        this.datasourceShow = this.datasource.filter((item) => {
+          return (
+            (!this.where.categoryLevelGroupId ||
+              item.categoryLevelGroupId.includes(
+                this.where.categoryLevelGroupId
+              )) &&
+            (!this.where.code || item.code.includes(this.where.code)) &&
+            (!this.where.name || item.name.includes(this.where.name)) &&
+            (!this.where.modelType ||
+              item.modelType.includes(this.where.modelType))
+          );
+        });
       },
       reloadRight () {
-        this.$refs.tableRight.reload();
+        this.datasourceRightShow = this.datasourceRight.filter((item) => {
+          return (
+            (!this.whereRight.categoryLevelGroupId ||
+              item.categoryLevelGroupId.includes(
+                this.whereRight.categoryLevelGroupId
+              )) &&
+            (!this.whereRight.code ||
+              item.code.includes(this.whereRight.code)) &&
+            (!this.whereRight.name ||
+              item.name.includes(this.whereRight.name)) &&
+            (!this.whereRight.modelType ||
+              item.modelType.includes(this.whereRight.modelType))
+          );
+        });
       },
       async getDatasource () {
         const data = await unassociated({
           categoryLevelGroupId: this.idMap[this.type]
         });
-        this.datasource = data;
+        this.datasource = data.slice(0);
+        this.datasourceShow = data.slice(0);
       },
       async getDatasourceRight () {
         const data = await getRelatesInformationList({
           mainCategoryId: this.row.categoryLevelId,
-          categoryLevelGroupId: this.idMap[this.type]
+          // categoryLevelGroupId: this.idMap[this.type],
+          categoryLevelRootId: this.type
         });
-        this.datasourceRight = data;
-      },
-      async _productTieUpMaterial () {
-        const data = await productTieUpMaterial();
-        console.log(data);
+        this.datasourceRight = data.slice(0);
+        this.datasourceRightShow = data.slice(0);
       }
     }
   };

+ 2 - 2
vue.config.js

@@ -33,9 +33,9 @@ module.exports = {
       '/api': {
         // target: 'http://192.168.3.51:18086', // 测试
         // target: 'http://192.168.3.35:8080', // kang杨威
-        target: 'http://192.168.3.25:8080', // 黄峥嵘
+        // target: 'http://192.168.3.25:8080', // 黄峥嵘
         // target: 'http://192.168.3.41:8080', // 何江鹏
-        // target: 'http://192.168.3.33:8080', // 谢一平
+        target: 'http://192.168.3.33:8080', // 谢一平
         // target: 'http://192.168.3.64:8080', // 粟勋
         // target: 'http://192.168.3.34:8080', // 刘毅勋
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域