This commit is contained in:
jiangfuzhuang
2020-02-11 10:11:08 +08:00
parent ac32df04d7
commit 06506ad5d9
5 changed files with 109 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ import { type } from './tool' // type判断传入值的类型比typeof更详
export default { export default {
install(Vue) { install(Vue) {
Vue.prototype.exportExcel_NPOI = function(param) { Vue.prototype.exportExcel_NPOI = function(param) {
console.log(ExcelDownLoad, param, 1111111111) console.log(param, 1)
download(`${ExcelDownLoad}?param=${param}`) download(`${ExcelDownLoad}?param=${param}`)
} }
Vue.prototype.CreateData = function(type, name, data, pageSize, pageList) { Vue.prototype.CreateData = function(type, name, data, pageSize, pageList) {
@@ -272,6 +272,7 @@ export default {
} }
function download(url) { function download(url) {
getBlob(url, function(blob, filename) { getBlob(url, function(blob, filename) {
console.log(blob, filename, 2)
saveAs(blob, filename) saveAs(blob, filename)
}) })
} }
@@ -283,14 +284,14 @@ function getBlob(url, cb) {
xhr.onload = function() { xhr.onload = function() {
if (xhr.status === 200) { if (xhr.status === 200) {
const name = xhr.getResponseHeader('content-disposition').split('=')[1] const name = xhr.getResponseHeader('content-disposition').split('=')[1]
var filename1 = decodeURIComponent(name) var filename = decodeURIComponent(name)
cb(xhr.response, filename1) cb(xhr.response, filename)
} }
} }
xhr.send() xhr.send()
} }
function saveAs(blob, filename = '下载文件.xls') { function saveAs(blob, filename) {
if (window.navigator.msSaveOrOpenBlob) { if (window.navigator.msSaveOrOpenBlob) {
navigator.msSaveBlob(blob, filename) navigator.msSaveBlob(blob, filename)
} else { } else {

View File

@@ -23,6 +23,7 @@
<!--<el-input v-model="model" placeholder="图号或型号" style="width:150px;margin-left: 10px" clearable size="small" />--> <!--<el-input v-model="model" placeholder="图号或型号" style="width:150px;margin-left: 10px" clearable size="small" />-->
<!--<el-input v-model="spec" placeholder="规格" clearable size="small" style="width:150px;margin: 0px 10px" />--> <!--<el-input v-model="spec" placeholder="规格" clearable size="small" style="width:150px;margin: 0px 10px" />-->
<el-button type="primary" icon="el-icon-search" size="small" style="margin-left: 10px" plain @click="searchRecord()">查询</el-button> <el-button type="primary" icon="el-icon-search" size="small" style="margin-left: 10px" plain @click="searchRecord()">查询</el-button>
<el-button type="success" plain size="small" @click="exportExcel()">导出</el-button>
</el-row> </el-row>
<el-row v-show="false" style="margin-bottom:10px"> <el-row v-show="false" style="margin-bottom:10px">
<el-date-picker <el-date-picker
@@ -112,6 +113,36 @@ export default {
this.searchRecord() this.searchRecord()
}, },
methods: { methods: {
// EXCEL 导出
// 姜福壮
exportExcel() {
let check1, check2, check3, check4, check5, check6, check7
this.projectValue ? check1 = 1 : check1 = 0
this.machineValue ? check2 = 1 : check2 = 0
this.groupValue ? check3 = 1 : check3 = 0
this.name ? check4 = 1 : check4 = 0
this.spec ? check5 = 1 : check5 = 0
this.model ? check6 = 1 : check6 = 0
this.inTime ? check7 = 1 : (check7 = 0, this.inTime = '')
var param = []
param[0] = ['项目流水号_check', check1]
param[1] = ['项目流水号', this.projectValue]
param[2] = ['机床流水号_check', check2]
param[3] = ['机床流水号', this.machineValue]
param[4] = ['组件流水号_check', check3]
param[5] = ['组件流水号', this.groupValue]
param[6] = ['名称_check', check4]
param[7] = ['名称', this.name]
param[8] = ['规格_check', check5]
param[9] = ['规格', this.spec]
param[10] = ['图号或型号_check', check6]
param[11] = ['图号或型号', this.model]
param[12] = ['入库时间_check', check7]
param[13] = ['入库开始时间', this.inTime[0]]
param[14] = ['入库结束时间', this.inTime[1]]
var Data = this.CreateData('00', '报表_采购部仓库_入库记录_查询', param)
this.exportExcel_NPOI(Data)
},
fetchData() { fetchData() {
initMachineProject().then(response => { initMachineProject().then(response => {
for (let i = 0; i < response.data.length; i++) { for (let i = 0; i < response.data.length; i++) {

View File

@@ -23,6 +23,7 @@
<!--<el-input v-model="model" placeholder="图号或型号" clearable size="small" style="width:150px;margin-left: 10px" />--> <!--<el-input v-model="model" placeholder="图号或型号" clearable size="small" style="width:150px;margin-left: 10px" />-->
<!--<el-input v-model="spec" placeholder="规格" clearable size="small" style="width:150px;margin: 0px 10px" />--> <!--<el-input v-model="spec" placeholder="规格" clearable size="small" style="width:150px;margin: 0px 10px" />-->
<el-button type="primary" icon="el-icon-search" size="small" style="margin-left: 10px" plain @click="pageCurrent1=1;pageSize1=100;searchRecord()">查询</el-button> <el-button type="primary" icon="el-icon-search" size="small" style="margin-left: 10px" plain @click="pageCurrent1=1;pageSize1=100;searchRecord()">查询</el-button>
<el-button type="success" plain size="small" @click="exportExcel()">导出</el-button>
</el-row> </el-row>
<el-row v-show="false" style="margin-bottom:10px"> <el-row v-show="false" style="margin-bottom:10px">
<el-date-picker <el-date-picker
@@ -114,6 +115,36 @@ export default {
this.searchRecord() this.searchRecord()
}, },
methods: { methods: {
// EXCEL 导出
// 姜福壮
exportExcel() {
let check1, check2, check3, check4, check5, check6, check7
this.projectValue ? check1 = 1 : check1 = 0
this.machineValue ? check2 = 1 : check2 = 0
this.groupValue ? check3 = 1 : check3 = 0
this.name ? check4 = 1 : check4 = 0
this.spec ? check5 = 1 : check5 = 0
this.model ? check6 = 1 : check6 = 0
this.inTime ? check7 = 1 : (check7 = 0, this.inTime = '')
var param = []
param[0] = ['项目流水号_check', check1]
param[1] = ['项目流水号', this.projectValue]
param[2] = ['机床流水号_check', check2]
param[3] = ['机床流水号', this.machineValue]
param[4] = ['组件流水号_check', check3]
param[5] = ['组件流水号', this.groupValue]
param[6] = ['名称_check', check4]
param[7] = ['名称', this.name]
param[8] = ['规格_check', check5]
param[9] = ['规格', this.spec]
param[10] = ['图号或型号_check', check6]
param[11] = ['图号或型号', this.model]
param[12] = ['入库时间_check', check7]
param[13] = ['入库开始时间', this.inTime[0]]
param[14] = ['入库结束时间', this.inTime[1]]
var Data = this.CreateData('00', '报表_采购部仓库_出库记录_查询', param)
this.exportExcel_NPOI(Data)
},
fetchData() { fetchData() {
initMachineProject().then(response => { initMachineProject().then(response => {
for (let i = 0; i < response.data.length; i++) { for (let i = 0; i < response.data.length; i++) {

View File

@@ -7,6 +7,7 @@
<!-- <el-input v-model="materialSpec" placeholder="物料规格" size="small" style="margin-bottom: 10px; width: 120px;" clearable/>--> <!-- <el-input v-model="materialSpec" placeholder="物料规格" size="small" style="margin-bottom: 10px; width: 120px;" clearable/>-->
<!-- <el-input v-model="materialModel" placeholder="物料型号" size="small" style="margin-bottom: 10px; width: 120px;" clearable/>--> <!-- <el-input v-model="materialModel" placeholder="物料型号" size="small" style="margin-bottom: 10px; width: 120px;" clearable/>-->
<el-button type="primary" icon="el-icon-search" size="small" plain style="margin-left: 10px" @click="pageCurrent=1;pageSize=30;searchMaterial()">查询</el-button> <el-button type="primary" icon="el-icon-search" size="small" plain style="margin-left: 10px" @click="pageCurrent=1;pageSize=30;searchMaterial()">查询</el-button>
<el-button type="success" plain size="small" @click="exportExcel()">导出</el-button>
<!-- <el-button type="primary" icon="el-icon-edit" size="small" @click="addMaterial()">新增</el-button>--> <!-- <el-button type="primary" icon="el-icon-edit" size="small" @click="addMaterial()">新增</el-button>-->
</el-row> </el-row>
</div> </div>
@@ -190,6 +191,23 @@ export default {
this.searchMaterial() this.searchMaterial()
}, },
methods: { methods: {
// EXCEL 导出
// 姜福壮
exportExcel() {
let check1, check2, check3
this.materialName ? check1 = 1 : check1 = 0
this.materialSpec ? check2 = 1 : check2 = 0
this.materialModel ? check3 = 1 : check3 = 0
var param = []
param[0] = ['物料名称_check', check1]
param[1] = ['物料名称', this.materialName]
param[2] = ['物料规格_check', check2]
param[3] = ['物料规格', this.materialSpec]
param[4] = ['物料型号_check', check3]
param[5] = ['物料型号', this.materialModel]
var Data = this.CreateData('00', '报表_采购部仓库_库存_查询', param)
this.exportExcel_NPOI(Data)
},
// 初始化数据 // 初始化数据
initData() { initData() {
const param = { const param = {

View File

@@ -45,6 +45,7 @@
<el-button class="button111" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px" @click="ADD()">新增</el-button> <el-button class="button111" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px" @click="ADD()">新增</el-button>
<!--<el-button type="primary" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px;background: #fdf6ec;border-color: #ff9759;color: #ff9759;" @click="ADD()">新增</el-button>--> <!--<el-button type="primary" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px;background: #fdf6ec;border-color: #ff9759;color: #ff9759;" @click="ADD()">新增</el-button>-->
</el-tooltip> </el-tooltip>
<el-button type="success" plain size="small" @click="exportExcel()">导出</el-button>
</div> </div>
</el-card> </el-card>
<el-row> <el-row>
@@ -231,6 +232,7 @@ export default {
startTime: '', startTime: '',
endTime: '', endTime: '',
date: null, date: null,
time_check: 0,
PageCurrent: 1, PageCurrent: 1,
PageSize: 10, PageSize: 10,
total: null, total: null,
@@ -279,6 +281,28 @@ export default {
// this.fetchTableData1() // this.fetchTableData1()
}, },
methods: { methods: {
// EXCEL 导出
// 姜福壮
exportExcel() {
if (this.contractNumber === '' || this.contractNumber === null) { this.contractNumber_check = 0 } else { this.contractNumber_check = 1 }
if (this.date !== null) {
this.time_check = 1
this.startTime = this.datetoYYMMDD(this.date[0])
this.endTime = this.datetoYYMMDD(this.date[1])
} else {
this.time_check = 0
this.startTime = ''
this.endTime = ''
}
var param = []
param[0] = ['项目流水号_check', this.contractNumber_check]
param[1] = ['项目流水号', this.contractNumber]
param[2] = ['日期_check', this.time_check]
param[3] = ['开始日期', this.startTime]
param[4] = ['结束日期', this.endTime]
var Data = this.CreateData('00', '报表_自家项目报表_查询', param)
this.exportExcel_NPOI(Data)
},
init() { init() {
this.getSelect(initProject, ['项目名称', '项目流水号'], 'entryName') this.getSelect(initProject, ['项目名称', '项目流水号'], 'entryName')
}, },