From 59dc399361e333ccea50bbe6d8598dcc3cc66eaf Mon Sep 17 00:00:00 2001 From: xiaobai <857694115@qq.com> Date: Thu, 5 Aug 2021 18:26:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 1 + src/api/common.js | 11 + src/api/data.js | 8 +- src/components/Crud/crud.js | 49 ++-- src/utils/index.js | 3 +- src/views/borrow/borrow-history.vue | 18 -- src/views/document/index.vue | 252 ++++++++++-------- .../ysjl/components/manufacture_yb_list.vue | 17 +- .../ysjl/components/original_yb_list.vue | 20 +- 9 files changed, 216 insertions(+), 163 deletions(-) diff --git a/package.json b/package.json index d57a016..3069b25 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "babel-plugin-import": "^1.13.0", "clipboard": "^2.0.4", "core-js": "^2.6.5", + "downloadjs": "^1.4.7", "echarts": "5.1.1", "element-ui": "2.11.1", "file-saver": "2.0.1", diff --git a/src/api/common.js b/src/api/common.js index ce4dd91..61b27ef 100644 --- a/src/api/common.js +++ b/src/api/common.js @@ -198,4 +198,15 @@ export function addBorrowFn(params) { return require('qs').stringify(data, { indices: false }) } }) +} +export function uploadFileFn(params) { + return preview({ + url: '/inspectionSystemFile', + method: 'post', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + }, + data: params, + responseType: 'blob' + }) } diff --git a/src/api/data.js b/src/api/data.js index 87ee29c..530b4d5 100644 --- a/src/api/data.js +++ b/src/api/data.js @@ -1,9 +1,15 @@ import api from '@/utils/api' import qs from 'qs' - +import preview from '@/utils/preview' export function initData(url, params) { return api({ url: url + '?' + qs.stringify(params, { indices: false }), method: 'get' }) +} +export function initData1(url, params) { + return preview({ + url: url + '?' + qs.stringify(params, { indices: false }), + method: 'get' + }) } diff --git a/src/components/Crud/crud.js b/src/components/Crud/crud.js index a4407a3..e739560 100644 --- a/src/components/Crud/crud.js +++ b/src/components/Crud/crud.js @@ -1,4 +1,4 @@ -import { initData } from '@/api/data' +import { initData, initData1 } from '@/api/data' import Vue from 'vue' /** @@ -10,6 +10,8 @@ function CRUD(options) { const defaultOptions = { // 标题 title: '', + // 接口根路由 + rootApi: 0, // 请求数据的url url: '', // 表格数据 @@ -116,20 +118,37 @@ function CRUD(options) { } return new Promise((resolve) => { // 请求数据 - initData(crud.url, crud.getQueryParams()).then(data => { - crud.page.total = data.total - if (data.list) { - crud.data = data.list - } else { - crud.data = data - } - crud.resetDataStatus() - // time 毫秒后显示表格 - setTimeout(() => { - callVmHook(crud, CRUD.HOOK.afterRefresh) - }, crud.time) - resolve(data) - }) + if (crud.rootApi) { + initData1(crud.url, crud.getQueryParams()).then(data => { + crud.page.total = data.total + if (data.list) { + crud.data = data.list + } else { + crud.data = data + } + crud.resetDataStatus() + // time 毫秒后显示表格 + setTimeout(() => { + callVmHook(crud, CRUD.HOOK.afterRefresh) + }, crud.time) + resolve(data) + }) + } else { + initData(crud.url, crud.getQueryParams()).then(data => { + crud.page.total = data.total + if (data.list) { + crud.data = data.list + } else { + crud.data = data + } + crud.resetDataStatus() + // time 毫秒后显示表格 + setTimeout(() => { + callVmHook(crud, CRUD.HOOK.afterRefresh) + }, crud.time) + resolve(data) + }) + } }) }, /** diff --git a/src/utils/index.js b/src/utils/index.js index 2ad4b6c..f6b73c7 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -160,7 +160,7 @@ export function html2Text(val) { export function objectMerge(target, source) { /* Merges two objects, - giving the last one precedence */ + giving the last one precedence */ if (typeof target !== 'object') { target = {} @@ -411,6 +411,7 @@ export function downloadFile(obj, name, suffix) { * @param suffix */ export function downloadFileUrl(url, name, suffix) { + console.log(url) buildClick(url, name, suffix) } diff --git a/src/views/borrow/borrow-history.vue b/src/views/borrow/borrow-history.vue index f758aef..b682892 100644 --- a/src/views/borrow/borrow-history.vue +++ b/src/views/borrow/borrow-history.vue @@ -230,24 +230,6 @@ export default { this.departmentId = 0 this.ifMeasure = false }, - // EXCEL上传方法 - beforeUpload(file) { - const isExcel = - file.type === 'application/vnd.ms-excel' || - file.type === - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' - if (!isExcel) { - this.$notify.error('只能上传xls/xlsx格式的文件') - return false - } - const fd = new FormData() - fd.append('file', file) - fd.append('type', 3) - // uploadInstrumentData(fd).then(() => { - // this.$notify.success('导入数据成功。') - // this.crud.toQuery() - // }) - }, // 关闭所有弹窗 resetChecks() { diff --git a/src/views/document/index.vue b/src/views/document/index.vue index dcdc619..40ed97c 100644 --- a/src/views/document/index.vue +++ b/src/views/document/index.vue @@ -2,85 +2,114 @@