This commit is contained in:
chenjianan
2018-12-24 14:50:29 +08:00
6 changed files with 69 additions and 19 deletions

View File

@@ -0,0 +1,20 @@
// 导出Excel方法表格id不加扩展名的文件名sheet名
export function exportExcelMethod(tableId, fileName, sheetName) {
tableToExcel(tableId, fileName, sheetName)
return 1
}
const tableToExcel = (function() {
const uri = 'data:application/vnd.ms-excel;base64,'
// 设置导出表格的单元格默认高度/宽度/边框样式/字体颜色/背景颜色/居中网页显示表格宽度建议1240tr/td视情况而定
const template = `<html xmlns:x="urn:schemas-microsoft-com:office:excel"><head><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><meta charset="UTF-8"><style type="text/css">table td {border: 2px solid #000000;height:40px;text-align: center;color: #000000;}</style></head><body><table>{table}</table></body></html>`
const base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
const format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p] }) }
return function(table, filename, sheetname) {
if (!table.nodeType) table = document.getElementById(table)
const ctx = { worksheet: sheetname || 'Worksheet', table: table.innerHTML }
const aTag = document.createElement('a')
aTag.href = uri + base64(format(template, ctx))
aTag.download = filename
aTag.click()
}
})()

View File

@@ -6,7 +6,8 @@
<el-input v-model="partName" placeholder="零件图号" size="small" clearable style="width:200px"/>
<el-button size="small" icon="el-icon-search" type="success" style="margin-left: 10px" @click="pageSize=10; pageCurrent=1;searchTable()">查询</el-button>
<el-checkbox v-model="all" size="mini">查询全部</el-checkbox>
<el-button type="primary" size="small" icon="el-icon-download" style="margin-left:10px" @click="downLoad('BL');edit()">导出备料单</el-button>
<el-button type="primary" size="small" icon="el-icon-download" style="margin-left:10px" @click="downLoad('BL')">导出备料单</el-button>
<el-button type="primary" size="small" icon="el-icon-success" style="margin-left:10px" @click="edit()">导出完成</el-button>
</el-row>
</el-card>
@@ -78,10 +79,11 @@
<script>
import { searchtable, searchtable2, edit } from '@/api/ManufacturingCenter/CreatePreparationBill'
import { getExplorer, method5, Cleanup } from '@/vendor/exportExcel'
import { exportExcelMethod } from './exportExcel'
export default {
data() {
return {
a: 0,
tableData2: [],
partName: '',
all: false,
@@ -118,10 +120,11 @@ export default {
for (let i = 0; i < this.Data.length; i++) {
searchtable2(this.Data[i].工艺计划流水号).then(response => {
this.tableData.push({
工艺计划流水号: this.Data[i].工艺计划流水号,
零件名称: this.Data[i].零件名称,
零件图号: this.Data[i].零件图号,
备料打印: this.Data[i].备料打印,
工艺要求: response.data[i].工艺要求
工艺要求: response.data[0].工艺要求
})
})
this.loading = false
@@ -133,18 +136,24 @@ export default {
this.tableData2 = val
},
edit() {
for (let i = 0; i < this.tableData2.length; i++) {
edit(this.tableData2[i].工艺计划流水号)
if (this.tableData2.length === 0) {
this.$message.warning('暂无数据')
} else {
this.a = 0
for (let i = 0; i < this.tableData2.length; i++) {
edit(this.tableData2[i].工艺计划流水号)
this.a = this.a + 1
}
if (this.a === this.tableData2.length) {
this.searchTable()
}
}
},
downLoad(tableid) {
if (this.tableData2.length === 0) {
this.$message.warning('暂无数据')
} else {
this.searchTable()
getExplorer()
method5(tableid)
Cleanup()
exportExcelMethod(tableid, '123', 'asd')
}
},
// 分页

View File

@@ -298,7 +298,7 @@
<el-button :disabled="disabledmoveInto" round type="primary" size="small" style="margin-top: 200px;margin-left: 45px" @click="moveInto()"></el-button>
</div>
<div>
<el-button round type="danger" size="small" style="margin-top: 50px;margin-left: 45px" @click="remove()"></el-button>
<el-button :disabled="disabledremoveInto" round type="danger" size="small" style="margin-top: 50px;margin-left: 45px" @click="remove()"></el-button>
</div>
</div>
</div>
@@ -314,8 +314,8 @@
:label="item.label"
:value="item.value"/>
</el-select>
<el-button type="primary" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px" @click="addCargoBox()">增加</el-button>
<el-button type="danger" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px;margin-right: 50px" @click="delCargoBox()">删除</el-button>
<el-button :disabled="btnAdd" type="primary" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px" @click="addCargoBox()">增加</el-button>
<el-button :disabled="btnDel" type="danger" icon="el-icon-circle-plus-outline" size="small" style="margin-left: 10px;margin-right: 50px" @click="delCargoBox()">删除</el-button>
<el-popover
placement="right"
width="80"
@@ -406,7 +406,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="运输状态" prop="entryNameValue" label-width="110px">
<el-select v-model="form1.运输状态" clearable filterable placeholder="请选择运输状态" style="width: 200px" size="small">
<el-select v-model="form1.运输状态" clearable filterable placeholder="请选择运输状态" style="width: 200px" size="small" disabled>
<el-option
v-for="item in Transport"
:key="item.value"
@@ -615,6 +615,8 @@ export default {
},
data() {
return {
btnAdd: false,
btnDel: false,
btnLoading: false,
table: [],
canvas: [],
@@ -629,6 +631,7 @@ export default {
委托车辆: '',
发货日期: '',
装箱单名称: '',
运输状态: '',
a: 1, // 嵌套表格交换变量
b: 1, // 嵌套表格交换变量
flag1: '', // 发货单旗帜变量
@@ -647,6 +650,7 @@ export default {
invoiceNum: '', // 发货单编号
detailedAddress: '',
disabledmoveInto: false,
disabledremoveInto: false,
people: '',
phoneNumber: '',
cityValue: '', // 市名
@@ -1001,6 +1005,11 @@ export default {
},
searchCargoBox(row) {
this.invoiceNum = row.发货单编号
this.运输状态 = row.运输状态
this.运输状态 === '已签收' ? this.disabledremoveInto = true : this.disabledremoveInto = false
this.运输状态 === '已签收' ? this.disabledmoveInto = true : this.disabledmoveInto = false
this.运输状态 === '已签收' ? this.btnAdd = true : this.btnAdd = false
this.运输状态 === '已签收' ? this.btnDel = true : this.btnDel = false
this.getFileList()
this.getSelect(searchCargoBox, ['货箱号', '货箱号编号'], 'cargoBox', this.invoiceNum)
},
@@ -1021,6 +1030,10 @@ export default {
}
}).then(() => {
this.getSelect(searchCargoBox, ['货箱号', '货箱号编号'], 'cargoBox', this.invoiceNum)
this.运输状态 === '已签收' ? this.disabledremoveInto = true : this.disabledremoveInto = false
this.运输状态 === '已签收' ? this.disabledmoveInto = true : this.disabledmoveInto = false
this.运输状态 === '已签收' ? this.btnAdd = true : this.btnAdd = false
this.运输状态 === '已签收' ? this.btnDel = true : this.btnDel = false
})
})
},
@@ -1040,6 +1053,10 @@ export default {
}
}).then(() => {
this.getSelect(searchCargoBox, ['货箱号', '货箱号编号'], 'cargoBox', this.invoiceNum)
this.运输状态 === '已签收' ? this.disabledremoveInto = true : this.disabledremoveInto = false
this.运输状态 === '已签收' ? this.disabledmoveInto = true : this.disabledmoveInto = false
this.运输状态 === '已签收' ? this.btnAdd = true : this.btnAdd = false
this.运输状态 === '已签收' ? this.btnDel = true : this.btnDel = false
})
})
},

View File

@@ -416,17 +416,20 @@ export default {
this.tableData1 = data.rows
this.total = data.total
})
this.tableData2 = []
},
// 项目信息表格改变每页显示条数
handleSizeChange(val) {
this.PageCurrent = 1
this.PageSize = val
this.fetchTableData1()
this.tableData2 = []
},
// 项目信息表格翻页
handleCurrentChange(val) {
this.PageCurrent = val
this.fetchTableData1()
this.tableData2 = []
},
// 查询开票记录表格
fetchTableData2(row) {