Ver código fonte

Merge branch 'feature/master' into feature/develop

rainwer 7 meses atrás
pai
commit
76fe5dba23

+ 421 - 0
src/views/business/production/fileUpload/detail.vue

@@ -0,0 +1,421 @@
+<template>
+  <div class="page-container list-container">
+    <!-- 功能按钮区 -->
+    <div class="list-btns-container">
+      <el-row style="font-size: 13px; padding: 2px 10px;">客户名称:{{ companyName }}</el-row>
+    </div>
+    <!-- 搜索区 -->
+    <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
+      <el-form-item label="文件名称:">
+        <el-input v-model.trim="queryParams.fileName" size="small" type="text" placeholder="文件名称" :clearable="true"
+          style="width: 130px" />
+      </el-form-item>
+      <!-- <el-form-item label="客户名称:">
+        <el-input v-model.trim="queryParams.companyName" size="small" type="text" placeholder="客户名称" :clearable="true"
+          style="width: 130px" />
+      </el-form-item> -->
+      <el-form-item label="文件类型:">
+        <el-select v-model="queryParams.type" clearable>
+                  <el-option v-for="item in fileTypes" :key="item.value" :label="item.label"
+                    :value="item.value" />
+                </el-select>
+      </el-form-item>
+      <el-form-item label="文件状态:">
+        <el-select v-model="queryParams.deleted" clearable>
+          <el-option label="正常" :value="0" />
+          <el-option label="作废" :value="1" />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="来源:" v-if="tenant.versionId === '4'">
+        <el-select v-model="queryParams.fromTenantId" clearable>
+          <el-option v-for="tenant in tenantList" :label="tenant.contactCompany" :value="tenant.fromTenantId" :key="tenant.id"/>
+        </el-select>
+      </el-form-item>
+      <el-form-item label="上传人:" prop="userName">
+        <el-input size="small" v-model="queryParams.userName" placeholder="请输入上传人" clearable style="width: 130px"
+          @keyup.enter="handleQuery" />
+      </el-form-item>
+
+      <el-form-item prop="dateFilter" label="上传时间:">
+        <el-date-picker size="small" v-model="queryParams.dateFilterFinish" type="daterange" clearable
+          format="YYYY - MM - DD " value-format="YYYY-MM-DD" range-separator="至" start-placeholder="业务日期"
+          end-placeholder="业务日期" style="width: 70%;"></el-date-picker>
+      </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="Search" @click="handleQuery" size="small">搜索</el-button>
+        <el-button type="primary" icon="Upload" @click="uploadHandle" size="small" v-hasPermi="['business:upload:add']">上传</el-button>
+        <el-button type="danger" :disabled="!ids.length" icon="Delete" @click="handleDelete" size="small" v-hasPermi="['business:upload:del']">作废</el-button>
+      </el-form-item>
+    </el-form>
+    <!-- <div v-if="flag && flag2 && tenant.versionId !== '4'">
+      <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
+        <el-tab-pane label="全部" name="first">
+
+        </el-tab-pane>
+        <el-tab-pane label="我的" name="second">
+
+        </el-tab-pane>
+      </el-tabs>
+    </div> -->
+
+    <!-- 列表区 -->
+    <el-table v-loading="loading" :data="list" size="small" border height="100%"
+      @selection-change="handleSelectionChange">
+      <el-table-column type="selection" :selectable="selectable" width="55" align="center" />
+      <el-table-column label="文件名称" prop="fileName" min-width="110" align="left" />
+      <!-- <el-table-column label="客户名称" align="center" prop="companyName">
+        <template #default="scope">
+          <div style="display: flex; align-items: center; ">
+            <template v-if="scope.row.customerLabelName ">
+              <el-tooltip :content="scope.row.customerLabelName" placement="top">
+                <el-icon :size="15">
+                  <CollectionTag />
+                </el-icon>
+              </el-tooltip>
+              <span style="padding-left:5px;">{{ scope.row.companyName }}</span>
+            </template>
+            <template v-else>
+              <div style="width: 20px; height: 15px;"></div>
+              <span>{{ scope.row.companyName }}</span>
+            </template>
+          </div>
+        </template>
+      </el-table-column> -->
+      <el-table-column label="受委托方" align="center" prop="accountName" min-width="100"
+        v-if="tenant.versionId === '4'" />
+      <el-table-column label="文件类型" align="center" prop="type" width="120">
+        <template #default="scope">
+            {{ fileTypes.find(f => f.value == scope.row.type).label }}
+        </template>
+      </el-table-column>
+      <el-table-column label="上传人" align="center" prop="userName" width="120" />
+      <el-table-column label="上传时间" align="center" prop="createTime" width="180" />
+      <el-table-column label="文件状态" align="center" prop="deleted" width="80">
+        <template #default="scope">
+          <template v-if="scope.row.deleted">
+            <el-tag type="danger">作废</el-tag>
+          </template>
+          <template v-else>
+            <el-tag type="success">正常</el-tag>
+          </template>
+        </template>
+      </el-table-column>
+      <el-table-column label="操作" width="130" align="center" class-name="small-padding fixed-width">
+        <template #default="scope">
+          <el-button link size="small" type="primary" circle
+            @click="viewHandle(scope.row)">查看</el-button>
+          <el-button size="small" link type="primary" circle
+            @click="downloadHandle(scope.row)">下载</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页 -->
+    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
+      v-model:limit="queryParams.pageSize" @pagination="getList" />
+    <el-image-viewer v-if="showViewer" :url-list="currentFileList" @close="closeImages" :initial-index="showIndex" />
+    <form-dialog ref="formDialogRef" :getList="getList" :fileTypes="fileTypes" />
+    <view-dialog ref="viewDialogRef" :getList="getList" />
+  </div>
+</template>
+
+<script setup name="ResouceUpload">
+  import { listLableNoPage } from "@/api/business/lable"
+  import { listFile, delFile } from "@/api/business/fileUpload";
+  import { uploadFile, downloadFile } from "@/api/tool/file";
+  import useUserStore from "@/store/modules/user";
+  import { ref } from "vue";
+  import formDialog from "./form.vue";
+  import viewDialog from "./view.vue";
+  import {
+    listEntrustOrder,
+  } from "@/api/business/entrust/entrustOrder";
+  import {
+    listProductionCompany,
+  } from "@/api/business/production/productionCompany";
+
+  const { proxy } = getCurrentInstance();
+  /** 字典数组区 */
+  /** 查询 对象 */
+  const tenant = useUserStore().tenant
+  const list = ref([]);
+  const loading = ref(true);
+  const ids = ref([]);
+  const single = ref(true);
+  const multiple = ref(true);
+  const oneself = ref(false);
+  const total = ref(0);
+  const baseUrl = ref(import.meta.env.VITE_APP_BASE_API);
+  const showViewer = ref(false);
+  const currentFileList = ref([]);
+  const showIndex = ref(0);
+  const tenantList = ref([]);
+
+  const permissions = useUserStore().permissions;
+
+  const fileTypes = ref([
+    {value: 1, label: '票据'},
+    {value: 2, label: '银行'},
+    {value: 3, label: '社保及公积金'},
+    {value: 4, label: '库存表'},
+  ])
+  const formOpen = ref(false);
+  const formDialogRef = ref(null);
+  const viewDialogRef = ref(null);
+  const flag = ref(checkPermission(['business:upload:person']))
+  const flag2 = ref(checkPermission(['business:upload:myself']))
+  const activeName = flag.value ? ref('first') : ref('second');
+  const options = ref([]);
+  const form = ref({
+    id: null,
+    companyName: "",
+    companyId: null,
+    remark: "",
+    type: 1,
+    files: [],
+  });
+
+  const emptyForm = {
+    id: null,
+    companyName: "",
+    companyId: null,
+    type: 1,
+    remark: "",
+    files: [],
+  };
+
+  /** 查询对象 */
+  const queryParams = ref({
+    pageNum: 1,
+    pageSize: 20,
+    orderByColumn: "create_time",
+    year: proxy.moment().subtract(1, "month").format("yyyy"),
+    month: proxy.moment().subtract(1, "month").format("MM"),
+    principal: tenant.versionId !== '4' && !flag.value ? useUserStore().user.userId : null,
+    tenantVersionId: tenant.versionId,
+    companyId: proxy.$route.query.companyId
+  });
+
+  const companyName = ref(proxy.$route.query.companyName)
+
+  /***********************  方法区  ****************************/
+    /** 查询company列表 */
+  // function getList() {
+  //   loading.value = true;
+  //   listProductionCompany(queryParams.value).then((response) => {
+  //     list.value = response.rows;
+  //     total.value = response.total;
+  //     loading.value = false;
+  //   });
+  // }
+
+  function selectable(row) {
+    return !row.deleted
+  }
+
+  function getEntrustOrderList() {
+    if(tenant.versionId != '4') {
+      return
+    }
+    listEntrustOrder({
+    pageNum: 1,
+    pageSize: 20,
+    orderByColumn: "create_time", status: 1}).then(res => {
+      tenantList.value = res.rows
+    })
+  }
+
+  onActivated(() => {
+    // 你的逻辑
+    // getList();
+    getEntrustOrderList()
+  });
+  /** 查询文件列表 */
+  function getList() {
+    loading.value = true;
+    listFile(queryParams.value).then((response) => {
+      list.value = response.rows.map((l) => ({ ...l }));
+      // prev.value = proxy.deepClone(response.rows);
+      total.value = response.total;
+      loading.value = false;
+    });
+  }
+
+  /** 是否为自己负责 */
+  function handleOneself() {
+    if (oneself.value) {
+      queryParams.value.principal = useUserStore().user.userId;
+    } else {
+      queryParams.value.principal = null;
+    }
+    getList();
+  }
+
+  /** 搜索按钮操作 */
+  function handleQuery() {
+    queryParams.value.pageNum = 1;
+    getList();
+  }
+  function checkPermission(templatePermission) {
+    const all_permission = "*:*:*";
+    const permissions = useUserStore().permissions;
+    const hasPermissions = permissions.some((permission) => {
+      return (
+        all_permission === permission || templatePermission.includes(permission)
+      );
+    });
+    return hasPermissions;
+  }
+  /** 重置按钮操作 */
+  function resetQuery() {
+    queryParams.value = {
+      pageNum: 1,
+      pageSize: 20,
+      year: proxy.moment().format("YYYY"),
+      month: proxy.moment().format("MM"),
+      orderByColumn: "create_time",
+      tenantVersionId: tenant.versionId
+    };
+    if (activeName.value != null && activeName.value === 'second') {
+      queryParams.value.principal = useUserStore().user.userId;
+    }
+    handleQuery();
+  }
+
+  // 多选框选中数据
+  function handleSelectionChange(selection) {
+    ids.value = selection.map((item) => item.id);
+    single.value = selection.length != 1;
+    multiple.value = !selection.length;
+  }
+  function getOption() {
+    listLableNoPage().then(res => {
+      options.value = res.data
+    })
+  }
+  /** 新增按钮操作 */
+  function handleAdd() {
+    // proxy.$refs.DepositRef.open();
+    formOpen.value = true;
+  }
+
+  function formCancel() {
+    formOpen.value = false;
+    reset();
+  }
+
+  function reset() {
+    form.value = proxy.deepClone(emptyForm);
+  }
+
+  /** 删除按钮操作 */
+  function handleDelete(row) {
+    const _ids = row.id || ids.value;
+    proxy.$modal
+      .confirm("是否确认作废选中的数据项?")
+      .then(function () {
+        return delFile(_ids);
+      })
+      .then(() => {
+        getList();
+        proxy.$modal.msgSuccess("作废成功!");
+      })
+      .catch(() => { });
+  }
+
+  function upload(param) {
+    const formData = new FormData();
+    formData.append("file", param.file);
+    uploadFile(formData).then((res) => {
+      if (res.code === 200) {
+        const file = {};
+        file.fileName = res.newFileName;
+        file.url = res.url;
+        file.originalFileName = res.originalFilename;
+        file.fileUrl = res.fileName;
+        file.masterId = form.value.id;
+        file.masterTableName = "biz_deduction";
+        form.value.files.push(file);
+      }
+    });
+  }
+
+  function showFileList(row) {
+    currentFileList.value = row.files.map((l) => `${baseUrl.value}${l.fileUrl}`);
+    showViewer.value = true;
+  }
+
+  function closeImages() {
+    showViewer.value = false;
+  }
+
+
+  function getForm(id) {
+    getDeposit(id).then((res) => {
+      form.value = res.data;
+      if (form.value == null) {
+        reset();
+      }
+    });
+  }
+
+  function handleDelFile(index) {
+    form.value.files.splice(index, 1);
+  }
+
+  function showFeedbackDialog(row) {
+    const value = proxy.deepClone(row);
+    value.status = 4;
+    proxy.$refs.feedbackDialogRef.open(value);
+  }
+
+  function verifyDeduction(value) {
+    saveDeduction(value).then((res) => {
+      getList();
+    });
+  }
+
+  function currentMonthChange(arg) {
+    const year = proxy.moment(arg).format("YYYY");
+    const month = proxy.moment(arg).format("MM");
+    queryParams.value.year = year;
+    queryParams.value.month = month;
+    handleQuery();
+  }
+
+  function disabledDateHandler(date) {
+    if (date <= proxy.moment().subtract(1, "month")) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
+  function uploadHandle(row) {
+    formDialogRef.value.open({companyId: proxy.$route.query.companyId});
+  }
+  function viewHandle(row) {
+    const fileExtension = row.fileName.match(/\.([^.]+)$/)[1];
+    if(!['xlsx', 'xls', 'doc', 'docx', 'txt', 'pdf', 'jpg', 'png'].includes(fileExtension)) {
+      proxy.$modal.msgError(`该文件格式不支持预览!`);
+      return false
+    }
+    viewDialogRef.value.open(row);
+  }
+  function downloadHandle(row) {
+    downloadFile({fileName: row.fileUrl, delete: false})
+      .then((blob) => {
+        const link = document.createElement('a');
+        link.href = URL.createObjectURL(blob);
+        // 下载文件的名称及文件类型后缀
+        link.download = row.fileName;
+        document.body.appendChild(link);
+        link.click();
+        //在资源下载完成后 清除 占用的缓存资源
+        window.URL.revokeObjectURL(link.href);
+        document.body.removeChild(link);
+      });
+  }
+  getList();
+  // getOption();
+  // getEntrustOrderList()
+</script>

+ 356 - 0
src/views/business/production/fileUpload/form.vue

@@ -0,0 +1,356 @@
+<template>
+  <el-dialog v-model="visible" :width="width" append-to-body draggable show-close :close-on-click-modal="false">
+    <template #header>
+      <div class="dialog-title-container">
+        <span class="title-label" style="color: #fff">
+          <el-icon>
+            <Document />
+          </el-icon>
+          文件</span>
+      </div>
+    </template>
+    <div class="form-btns-container">
+      <el-button type="primary" size="small" icon="Finished" @click="handleSave">
+        保存</el-button>
+    </div>
+    <div v-loading="loading">
+      <div style="padding: 8px 24px 16px 24px">
+        <el-form size="small" label-width="80px" :model="form" :rules="formRules" ref="uploadForm">
+          <el-row :gutter="30">
+            <el-col :span="12">
+              <el-form-item label="文件类型" prop="type">
+                <el-select v-model="form.type" style="width: 100%">
+                  <el-option v-for="item in fileTypes" :key="item.value" :label="item.label"
+                    :value="item.value" />
+                </el-select>
+              </el-form-item>
+            </el-col>
+            <el-col :span="24">
+              <el-form-item label="选择文件" prop="files">
+                <el-upload v-if="visible" action="#" :http-request="upload" :before-upload="handleBeforeUpload" :with-credentials="true"
+                  :before-remove="removeFile" v-model:file-list="fileList" :on-exceed="onExceed" :on-error="onUploadError" :accept="acceptType"
+                  :show-file-list="true" multiple :limit="5" drag style="width: 100%;">
+                  <!-- <el-button size="small" type="primary" icon="Upload">上传文件</el-button> -->
+                  <el-icon class="el-icon--upload"><upload-filled /></el-icon>
+                  <div class="el-upload__text">
+                    上传文件
+                  </div>
+                  <template #tip>
+                    <div class="el-upload__tip">
+                      单次最多上传5个文件,每个文件最大15M
+                    </div>
+                  </template>
+                </el-upload>
+              </el-form-item>
+            </el-col>
+          </el-row>
+        </el-form>
+      </div>
+    </div>
+    <el-dialog v-model="visibleCompany" width="660px" append-to-body draggable show-close :close-on-click-modal="false">
+      <template #header>
+        <div class="dialog-title-container">
+          <span class="title-label" style="color: #fff">
+            <el-icon>
+              <Document />
+            </el-icon>
+            企业</span>
+        </div>
+      </template>
+      <!-- <div class="form-btns-container">
+        <el-button type="primary" size="small" icon="Finished" @click="handleSave">
+          保存</el-button>
+      </div> -->
+      <div v-loading="loadingCompany">
+        <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
+          <el-form-item label="客户名称:">
+            <el-input v-model.trim="queryParams.name" size="small" type="text" placeholder="客户名称" :clearable="true"
+              style="width: 130px" />
+          </el-form-item>
+          <el-form-item>
+          <el-button type="primary" icon="Search" @click="handleQuery" size="small">搜索</el-button>
+        </el-form-item>
+        </el-form>
+        <el-table :data="list" style="width: 100%">
+          <el-table-column prop="name" label="名称" />
+          <el-table-column fixed="right" label="操作" width="120">
+            <template #default="scope">
+              <el-button link type="primary" size="small" @click="handleSelect(scope.row)">
+                选择
+              </el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+        <!-- 分页 -->
+        <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
+          v-model:limit="queryParams.pageSize" @pagination="getCompanyList" />
+      </div>
+    </el-dialog>
+  </el-dialog>
+</template>
+<script setup>
+  import { reactive } from "vue";
+  import { UploadFilled } from '@element-plus/icons-vue'
+
+  import {
+    addFileInfos,
+  } from "@/api/business/fileUpload";
+  import { uploadFile } from "@/api/tool/file";
+  import { listCompany } from "@/api/business/crm/company";
+  const { proxy } = getCurrentInstance();
+  const loading = ref(false);
+  const props = defineProps({
+    getList: {
+      type: Function,
+      default: () => { },
+    },
+    width: {
+      type: String,
+      default: "800px",
+    },
+    fileTypes: {
+      type: Array,
+      default: () => []
+    }
+  });
+  const { getList, width, fileTypes } = toRefs(props);
+  const srcList = ref([]);
+  const visibleCompany = ref(false);
+  const loadingCompany = ref(false);
+    /** 查询对象 */
+  const queryParams = ref({
+    pageNum: 1,
+    pageSize: 20,
+    orderByColumn: "create_time",
+    // principal: tenant.versionId !== '4' && !flag.value ? useUserStore().user.userId : null,
+    name: ''
+  });
+  const companyList = ref([])
+  const data = reactive({
+    visible: false,
+    list: [],
+    total: 0,
+    query: {
+      name: "",
+      total: 0,
+      pageSize: 15,
+      pageNum: 1,
+    },
+    // files: [],
+    months: [],
+    form: {
+      files: []
+    },
+    selection: [],
+    baseUrl: import.meta.env.VITE_APP_BASE_API,
+    options: {},
+    formRules: {
+      type: [
+        { required: true, message: '请选择文件类型', trigger: 'change' }
+      ],
+      companyId: [
+        { required: true, message: '请选择公司', trigger: 'change' }
+      ],
+      files: [
+        { required: true, message: '请上传文件', validator: validateFiles }
+      ],
+    },
+    fileMap: {},
+    fileList: [],
+    acceptType: ".bmp,.gif,.jpg,.jpeg,.png,.doc,.docx,.xls,.xlsx,.ppt,.pptx,.html,.htm,.txt,.rar,.zip,.gz,.bz2,.mp4,.avi,.rmvb,.pdf"
+  });
+  const {
+    visible,
+    list,
+    query,
+    selection,
+    baseUrl,
+    options,
+    total,
+    // files,
+    form,
+    months,
+    formRules,
+    fileMap,
+    fileList,
+    acceptType
+  } = toRefs(data);
+
+  function onUploadError(err) {
+    console.log('onUploadError', err)
+  }
+
+  function onExceed(files) {
+    console.log( fileList.value)
+    if(files.length + fileList.value.length> 5) {
+      proxy.$modal.msgError("单次最多上传5个文件")
+      return  false
+    }
+    return true
+  }
+
+  function validateFiles(rule, value, callback) {
+    if (!form.value.files || form.value.files.length == 0) {
+      callback(new Error('请上传文件'))
+    } else {
+      callback()
+    }
+  } 
+
+  function handleSelect(row) {
+    form.value.companyId = row.id
+    companyList.value.push(row)
+    visibleCompany.value = false
+  }
+
+  function open(arg) {
+    visible.value = true;
+    form.value = {
+      files: [],
+      companyId: arg.companyId
+    }
+    fileMap.value = {}
+    fileList.value = []
+    // getCompanyList()
+  }
+    /** 查询company列表 */
+  function getCompanyList() {
+    loadingCompany.value = true;
+    listCompany(queryParams.value).then((response) => {
+      list.value = response.rows.map((l) => ({ ...l }));
+      // prev.value = proxy.deepClone(response.rows);
+      total.value = response.total;
+      loadingCompany.value = false;
+    });
+  }
+  /** 搜索按钮操作 */
+  function handleQuery() {
+    queryParams.value.pageNum = 1;
+    // getCompanyList();
+  }
+  /**
+   * 对话框关闭 事件
+   */
+  function close() {
+    visible.value = false;
+  }
+  function handleImageView(fileUrl) {
+    window.open(`${baseUrl.value}${fileUrl}`);
+  }
+  /**
+   * 加载数据
+   */
+  const loadData = async () => {
+    // getCompanyList()
+    const res = await listFiles(form.value);
+    // files.value = res.data.files;
+    months.value = res.data.months;
+    form.value.isFinished = res.data.finished.isFinished;
+    srcList.value = files.value.map((v) => baseUrl.value + v.fileUrl);
+    loading.value = false;
+ 
+  };
+  /**
+   * 列表checkbox列选择 事件
+   */
+  function handleSelectionChange(selection) {
+    selection.value = selection;
+  }
+  /**
+   * 搜索 事件
+   */
+  function handleSearch() {
+    loadData();
+  }
+  function openFile(attach) {
+    window.open(`${baseUrl.value}/${attach.fileUrl}`, attach.fileName);
+  }
+
+  function upload(param) {
+    const formData = new FormData();
+    formData.append("file", param.file);
+    uploadFile(formData).then((res) => {
+      if (res.code === 200) {
+        const file = {};
+        file.fileName = res.originalFilename;
+        file.url = res.url;
+        file.originalFileName = res.originalFilename;
+        file.fileUrl = res.fileName;
+
+        form.value.files.push(file)
+        fileMap.value[param.file.uid] = file.fileUrl
+        if(fileList.value.findIndex(f => f.uid == param.file.uid) < 0) {
+          console.log('fileList', fileList)
+          console.log('param.file.uid', param.file.uid)
+          fileList.value.push(param.file)
+        }
+      } else {
+        const index = fileList.value.findIndex(f => f.uid == param.file.uid)
+        fileList.value.splice(index, 1);
+      }
+    }).catch(e => {
+      const index = fileList.value.findIndex(f => f.uid == param.file.uid)
+      fileList.value.splice(index, 1);
+    });
+  }
+
+  const types = acceptType.value.split(',')
+  function handleBeforeUpload(file) {
+    const fileExtension = file.name.split('.').pop().toLowerCase();
+    if(!types.includes('.'+fileExtension)) {
+      proxy.$modal.msgError("文件格式不正确");
+      return false;
+    }
+    
+    console.log('handleBeforeUpload',file)
+    if(file.size > 15 * 1024 * 1024) {
+      proxy.$modal.msgError("文件大小不能超过15M");
+      return false;
+    }
+    return true;
+  }
+
+  function removeFile(file) {
+    const fileUrl = fileMap.value[file.uid]
+    form.value.files = form.value.files.filter(f => f.fileUrl != fileUrl)
+    // fileMap.value.value.delete(file.uid)
+    delete fileMap[file.uid]
+    return true
+  }
+
+  function deleteHandle(index) {
+    proxy.$modal
+      .confirm("确定删除?")
+      .then(() => {
+        files.value.splice(index, 1);
+        srcList.value = files.value.map((v) => baseUrl.value + v.fileUrl);
+      })
+      .catch(() => {
+        proxy.$modal.msg("已取消删除");
+      });
+  }
+
+  function handleSave() {
+    proxy.$refs["uploadForm"].validate((valid) => {
+      if (valid) {
+        const file = {
+          companyId: form.value.companyId,
+          type: form.value.type,
+          files: form.value.files,
+        };
+        addFileInfos(file).then((res) => {
+          getList.value();
+          close();
+        });
+      }
+    });
+    
+  }
+  function focusCompanySelect() {
+    visibleCompany.value = true
+  }
+
+  defineExpose({
+    open,
+  });
+</script>

+ 328 - 0
src/views/business/production/fileUpload/index.vue

@@ -0,0 +1,328 @@
+<template>
+  <div class="page-container list-container">
+    <!-- 功能按钮区 -->
+    <div class="list-btns-container">
+    </div>
+    <!-- 搜索区 -->
+    <el-form class="list-search-container" :model="queryParams" ref="queryRef" :inline="true" label-width="68px">
+      <el-form-item label="客户名称:" prop="name">
+          <el-input v-model="queryParams.name" placeholder="请输入客户名称" style="width: 150px" clearable
+            @keyup.enter="handleQuery" />
+        </el-form-item>
+        <el-form-item label="税号:" prop="socialCreditCode">
+          <el-input v-model="queryParams.socialCreditCode" style="width: 150px" placeholder="请输入税号" clearable
+            @keyup.enter="handleQuery" />
+        </el-form-item>
+        <el-form-item label="客户负责人:" prop="leaderName">
+          <el-input v-model="queryParams.leaderName" placeholder="请输入客户负责人" style="width: 150px" clearable
+            @keyup.enter="handleQuery" />
+        </el-form-item>
+      <el-form-item>
+        <el-button type="primary" icon="Search" @click="handleQuery" size="small">搜索</el-button>
+        <!-- <el-button type="primary" icon="Upload" @click="uploadHandle" size="small" v-hasPermi="['business:upload:add']">上传</el-button>
+        <el-button type="danger" :disabled="!ids.length" icon="Delete" @click="handleDelete" size="small" v-hasPermi="['business:upload:del']">作废</el-button> -->
+      </el-form-item>
+    </el-form>
+    <!-- <div v-if="flag && flag2 && tenant.versionId !== '4'">
+      <el-tabs v-model="activeName" class="demo-tabs" @tab-click="handleClick">
+        <el-tab-pane label="全部" name="first">
+
+        </el-tab-pane>
+        <el-tab-pane label="我的" name="second">
+
+        </el-tab-pane>
+      </el-tabs>
+    </div> -->
+
+    <!-- 列表区 -->
+    <el-table v-loading="loading" :data="list" size="small" border height="100%"
+      @selection-change="handleSelectionChange">
+      <el-table-column type="selection" :selectable="selectable" width="55" align="center" />
+      <el-table-column label="客户名称" prop="name" min-width="110" align="left" />
+      <el-table-column label="税号" min-width="200" align="center" prop="socialCreditCode" />
+      <el-table-column label="纳税类型" align="center" min-width="120" prop="taxType" />
+      <el-table-column label="客服" align="center" min-width="110" prop="adviserName" />
+      <el-table-column label="负责人" align="center" min-width="110" prop="leaderName" />
+      <el-table-column label="操作" width="130" align="center" class-name="small-padding fixed-width">
+        <template #default="scope">
+          <el-button link size="small" type="primary" circle
+            @click="viewHandle(scope.row)">查看</el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+    <!-- 分页 -->
+    <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
+      v-model:limit="queryParams.pageSize" @pagination="getList" />
+    <el-image-viewer v-if="showViewer" :url-list="currentFileList" @close="closeImages" :initial-index="showIndex" />
+    <form-dialog ref="formDialogRef" :getList="getList" :fileTypes="fileTypes" />
+    <view-dialog ref="viewDialogRef" :getList="getList" />
+  </div>
+</template>
+
+<script setup name="ResouceUpload">
+  import { listLableNoPage } from "@/api/business/lable"
+  import { listFile, delFile } from "@/api/business/fileUpload";
+  import { uploadFile, downloadFile } from "@/api/tool/file";
+  import useUserStore from "@/store/modules/user";
+  import { ref } from "vue";
+  import formDialog from "./form.vue";
+  import viewDialog from "./view.vue";
+  import {
+    listEntrustOrder,
+  } from "@/api/business/entrust/entrustOrder";
+  import {
+    listProductionCompany,
+  } from "@/api/business/production/productionCompany";
+
+  const { proxy } = getCurrentInstance();
+  /** 字典数组区 */
+  /** 查询 对象 */
+  const tenant = useUserStore().tenant
+  const list = ref([]);
+  const loading = ref(true);
+  const ids = ref([]);
+  const single = ref(true);
+  const multiple = ref(true);
+  const oneself = ref(false);
+  const total = ref(0);
+  const baseUrl = ref(import.meta.env.VITE_APP_BASE_API);
+  const showViewer = ref(false);
+  const currentFileList = ref([]);
+  const showIndex = ref(0);
+  const tenantList = ref([]);
+
+  const permissions = useUserStore().permissions;
+
+  const fileTypes = ref([
+    {value: 1, label: '票据'},
+    {value: 2, label: '银行'},
+    {value: 3, label: '社保及公积金'},
+    {value: 4, label: '库存表'},
+  ])
+  const formOpen = ref(false);
+  const formDialogRef = ref(null);
+  const viewDialogRef = ref(null);
+  const flag = ref(checkPermission(['business:upload:person']))
+  const flag2 = ref(checkPermission(['business:upload:myself']))
+  const activeName = flag.value ? ref('first') : ref('second');
+  const options = ref([]);
+  const form = ref({
+    id: null,
+    companyName: "",
+    companyId: null,
+    remark: "",
+    type: 1,
+    files: [],
+  });
+
+  const emptyForm = {
+    id: null,
+    companyName: "",
+    companyId: null,
+    type: 1,
+    remark: "",
+    files: [],
+  };
+
+  /** 查询对象 */
+  const queryParams = ref({
+    pageNum: 1,
+    pageSize: 20,
+    orderByColumn: "create_time",
+    year: proxy.moment().subtract(1, "month").format("yyyy"),
+    month: proxy.moment().subtract(1, "month").format("MM"),
+    principal: tenant.versionId !== '4' && !flag.value ? useUserStore().user.userId : null,
+    tenantVersionId: tenant.versionId,
+    isZero: 0
+  });
+
+  /***********************  方法区  ****************************/
+    /** 查询company列表 */
+  function getList() {
+    loading.value = true;
+    listProductionCompany(queryParams.value).then((response) => {
+      list.value = response.rows;
+      total.value = response.total;
+      loading.value = false;
+    });
+  }
+
+  function selectable(row) {
+    return !row.deleted
+  }
+
+  function getEntrustOrderList() {
+    if(tenant.versionId != '4') {
+      return
+    }
+    listEntrustOrder({
+    pageNum: 1,
+    pageSize: 20,
+    orderByColumn: "create_time", status: 1}).then(res => {
+      tenantList.value = res.rows
+    })
+  }
+
+  onActivated(() => {
+    // 你的逻辑
+    // getList();
+    getEntrustOrderList()
+  });
+  /** 查询company列表 */
+  // function getList() {
+  //   loading.value = true;
+  //   listFile(queryParams.value).then((response) => {
+  //     list.value = response.rows.map((l) => ({ ...l }));
+  //     // prev.value = proxy.deepClone(response.rows);
+  //     total.value = response.total;
+  //     loading.value = false;
+  //   });
+  // }
+
+  /** 是否为自己负责 */
+  function handleOneself() {
+    if (oneself.value) {
+      queryParams.value.principal = useUserStore().user.userId;
+    } else {
+      queryParams.value.principal = null;
+    }
+    getList();
+  }
+
+  /** 搜索按钮操作 */
+  function handleQuery() {
+    queryParams.value.pageNum = 1;
+    getList();
+  }
+  function checkPermission(templatePermission) {
+    const all_permission = "*:*:*";
+    const permissions = useUserStore().permissions;
+    const hasPermissions = permissions.some((permission) => {
+      return (
+        all_permission === permission || templatePermission.includes(permission)
+      );
+    });
+    return hasPermissions;
+  }
+  /** 重置按钮操作 */
+  function resetQuery() {
+    queryParams.value = {
+      pageNum: 1,
+      pageSize: 20,
+      year: proxy.moment().format("YYYY"),
+      month: proxy.moment().format("MM"),
+      orderByColumn: "create_time",
+      tenantVersionId: tenant.versionId
+    };
+    if (activeName.value != null && activeName.value === 'second') {
+      queryParams.value.principal = useUserStore().user.userId;
+    }
+    handleQuery();
+  }
+
+  // 多选框选中数据
+  function handleSelectionChange(selection) {
+    ids.value = selection.map((item) => item.id);
+    single.value = selection.length != 1;
+    multiple.value = !selection.length;
+  }
+  /** 新增按钮操作 */
+  function handleAdd() {
+    // proxy.$refs.DepositRef.open();
+    formOpen.value = true;
+  }
+
+  function reset() {
+    form.value = proxy.deepClone(emptyForm);
+  }
+
+  /** 删除按钮操作 */
+  function handleDelete(row) {
+    const _ids = row.id || ids.value;
+    proxy.$modal
+      .confirm("是否确认作废选中的数据项?")
+      .then(function () {
+        return delFile(_ids);
+      })
+      .then(() => {
+        getList();
+        proxy.$modal.msgSuccess("作废成功!");
+      })
+      .catch(() => { });
+  }
+
+  function showFileList(row) {
+    currentFileList.value = row.files.map((l) => `${baseUrl.value}${l.fileUrl}`);
+    showViewer.value = true;
+  }
+
+  function closeImages() {
+    showViewer.value = false;
+  }
+
+
+  function getForm(id) {
+    getDeposit(id).then((res) => {
+      form.value = res.data;
+      if (form.value == null) {
+        reset();
+      }
+    });
+  }
+
+  function handleDelFile(index) {
+    form.value.files.splice(index, 1);
+  }
+
+  function showFeedbackDialog(row) {
+    const value = proxy.deepClone(row);
+    value.status = 4;
+    proxy.$refs.feedbackDialogRef.open(value);
+  }
+
+  function verifyDeduction(value) {
+    saveDeduction(value).then((res) => {
+      getList();
+    });
+  }
+
+  function currentMonthChange(arg) {
+    const year = proxy.moment(arg).format("YYYY");
+    const month = proxy.moment(arg).format("MM");
+    queryParams.value.year = year;
+    queryParams.value.month = month;
+    handleQuery();
+  }
+
+  function disabledDateHandler(date) {
+    if (date <= proxy.moment().subtract(1, "month")) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
+  function uploadHandle(row) {
+    formDialogRef.value.open();
+  }
+  function viewHandle(row) {
+    proxy.$router.push({path: '/Production/detail', query: {companyId: row.id, companyName: row.name}})
+  }
+  function downloadHandle(row) {
+    downloadFile({fileName: row.fileUrl, delete: false})
+      .then((blob) => {
+        const link = document.createElement('a');
+        link.href = URL.createObjectURL(blob);
+        // 下载文件的名称及文件类型后缀
+        link.download = row.fileName;
+        document.body.appendChild(link);
+        link.click();
+        //在资源下载完成后 清除 占用的缓存资源
+        window.URL.revokeObjectURL(link.href);
+        document.body.removeChild(link);
+      });
+  }
+  getList();
+  // getOption();
+  // getEntrustOrderList()
+</script>

+ 84 - 0
src/views/business/production/fileUpload/view.vue

@@ -0,0 +1,84 @@
+<template>
+  <el-dialog v-model="visible" :width="width" append-to-body show-close :close-on-click-modal="false">
+    <template #header>
+      <div class="dialog-title-container">
+        <span class="title-label" style="color: #fff; display: flex; flex-direction: row; justify-content: flex-start; align-items: center; line-height: 26px;"> <el-icon> <Document /> </el-icon>预览</span>
+      </div>
+    </template>
+    <div>
+      <div style="padding: 8px 24px 16px 24px">
+        <vue-office-excel v-if="['xlsx', 'xls'].includes(fileExtension)" :src="`${baseUrl}${form.fileUrl}`" style="width: 100%; min-height: 800px;"></vue-office-excel>
+        <vue-office-docx v-else-if="['doc', 'docx'].includes(fileExtension)" :src="`${baseUrl}${form.fileUrl}`" style="width: 100%; min-height: 800px;"></vue-office-docx>
+        <vue-office-pdf v-else-if="['pdf'].includes(fileExtension)" :src="`${baseUrl}${form.fileUrl}`" style="width: 100%; min-height: 800px;"></vue-office-pdf>
+        <iframe v-else-if="['txt',].includes(fileExtension)" :src="`${baseUrl}${form.fileUrl}`" style="width: 100%; min-height: 800px;"></iframe>
+        <el-image v-else-if="['jpg', 'png'].includes(fileExtension)" style="width: 100%; min-height: 800px" :src="`${baseUrl}${form.fileUrl}`" 
+        :zoom-rate="1.2"
+        :max-scale="7"
+        :min-scale="0.2"
+        :preview-src-list="[`${baseUrl}${form.fileUrl}`]"/>
+      </div>
+    </div>
+  </el-dialog>
+</template>
+<script setup>
+  import { reactive } from "vue";
+  import VueOfficeDocx from '@vue-office/docx';
+  import '@vue-office/docx/lib/index.css'; 
+  import VueOfficeExcel from '@vue-office/excel';
+  import '@vue-office/excel/lib/index.css'; 
+  import VueOfficePdf from '@vue-office/pdf';
+  import '@vue-office/pdf/lib/index.js'; 
+  const { proxy } = getCurrentInstance();
+
+  const props = defineProps({
+    getList: {
+      type: Function,
+      default: () => { },
+    },
+    width: {
+      type: String,
+      default: "1200px",
+    },
+  });
+
+  const fileExtension = ref('')
+  // import api from '@/api/biz/fileStorage'
+  const data = reactive({
+    visible: false,
+    list: [],
+    total: 0,
+    query: {
+      name: "",
+      total: 0,
+      pageSize: 15,
+      pageNum: 1,
+    },
+    files: [],
+    months: [],
+    form: {},
+    selection: [],
+    baseUrl: import.meta.env.VITE_APP_BASE_API,
+    options: {},
+  });
+  const {
+    visible,
+    baseUrl,
+    form,
+  } = toRefs(data);
+  function open(arg) {
+    visible.value = true;
+    form.value = arg;
+    // loading.value = true
+    fileExtension.value = arg.fileName.match(/\.([^.]+)$/)[1];
+  }
+  /**
+   * 对话框关闭 事件
+   */
+  function close() {
+    visible.value = false;
+  }
+ 
+  defineExpose({
+    open,
+  });
+</script>

+ 3 - 0
src/views/business/production/receiveResource/index.vue

@@ -195,6 +195,9 @@
   }
 
   function getEntrustOrderList() {
+    if(tenant.versionId != '4') {
+      return
+    }
     listEntrustOrder({
     pageNum: 1,
     pageSize: 20,