This commit is contained in:
chenjianan
2019-06-14 08:15:57 +08:00
parent 3124baa9d7
commit a374ea5c8d
6 changed files with 364 additions and 9 deletions

View File

@@ -49,3 +49,27 @@ export function searchTable2(...params) {
} }
}) })
} }
// 查询表1标准件和外购件无分页
export function searchTable1Export(...params) {
return request({
url: '',
method: 'post',
data: {
type: '1',
name: '采购管理_采购部采购_查询物料_分配后_加供应商',
param: `机床流水号_check=${params[0]}&机床流水号=${params[1]}&组件流水号_check=${params[2]}&组件流水号=${params[3]}&零件类型=${params[4]}`
}
})
}
// 查询表1基本件无分页
export function searchTable2Export(...params) {
return request({
url: '',
method: 'post',
data: {
type: '1',
name: '采购管理_采购部采购_查询物料_基本件_分配后_加供应商',
param: `机床流水号_check=${params[0]}&机床流水号=${params[1]}&组件流水号_check=${params[2]}&组件流水号=${params[3]}`
}
})
}

View File

@@ -22,7 +22,7 @@ export const ServerIP = `http://192.168.1.231:8411/webpage/file/`
export const uploadFileMachine = `http://192.168.1.231:8411/submit/uploadFileMachine.ashx` // 机床总图 发布时改成0.231 export const uploadFileMachine = `http://192.168.1.231:8411/submit/uploadFileMachine.ashx` // 机床总图 发布时改成0.231
export const downloadFileMachine = `http://192.168.1.231:8411/submit/downloadFileMachine.ashx` // 机床总图 发布时改成0.231 export const downloadFileMachine = `http://192.168.1.231:8411/submit/downloadFileMachine.ashx` // 机床总图 发布时改成0.231
const service = axios.create({ const service = axios.create({
baseURL: `http://192.168.1.231:8411/submit/MESCommonBase.ashx`, baseURL: `http://127.0.0.1:8411/submit/MESCommonBase.ashx`,
timeout: 1500000 // 请求超时时间 timeout: 1500000 // 请求超时时间
}) })

View File

@@ -92,6 +92,11 @@
{{ scope.row.机床图号 }} {{ scope.row.机床图号 }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="机床设计者" align="center" min-width="90">
<template slot-scope="scope">
{{ scope.row.机床设计者 || '—' }}
</template>
</el-table-column>
<el-table-column label="组号" align="center" min-width="80"> <el-table-column label="组号" align="center" min-width="80">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.组号 }} {{ scope.row.组号 }}
@@ -270,6 +275,11 @@
{{ scope.row.机床图号 }} {{ scope.row.机床图号 }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="机床设计者" align="center" min-width="90">
<template slot-scope="scope">
{{ scope.row.机床设计者 || '—' }}
</template>
</el-table-column>
<el-table-column label="组号" align="center" min-width="80"> <el-table-column label="组号" align="center" min-width="80">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.组号 }} {{ scope.row.组号 }}

View File

@@ -50,31 +50,31 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="交货日期:"> <el-form-item label="交货日期:">
<el-input v-model="deliveryDate" size="small" type="textarea" rows="1"/> <el-input v-model="deliveryDate" size="small" type="textarea" rows="1" @change="contractHeaderChange"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="开票信息:"> <el-form-item label="开票信息:">
<el-input v-model="invoiceInfo" size="small" type="textarea" rows="1"/> <el-input v-model="invoiceInfo" size="small" type="textarea" rows="1" @change="contractHeaderChange"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="支付日期:"> <el-form-item label="支付日期:">
<el-input v-model="payDate" size="small" type="textarea" rows="1"/> <el-input v-model="payDate" size="small" type="textarea" rows="1" @change="contractHeaderChange"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="支付方式:"> <el-form-item label="支付方式:">
<el-input v-model="payMethod" size="small" type="textarea" rows="1"/> <el-input v-model="payMethod" size="small" type="textarea" rows="1" @change="contractHeaderChange"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="其他说明:"> <el-form-item label="其他说明:">
<el-input v-model="otherInfo" size="small" type="textarea" rows="1"/> <el-input v-model="otherInfo" size="small" type="textarea" rows="1" @change="contractHeaderChange"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -256,6 +256,12 @@ export default {
this.fetchData() this.fetchData()
}, },
methods: { methods: {
// 合同头实时保存
contractHeaderChange() {
if (this.contractNumValue) {
console.log(this.deliveryDate, this.invoiceInfo, this.payDate, this.payMethod, this.otherInfo)
}
},
// 价格实时保存 // 价格实时保存
priceChange(price, num1, num2, row) { priceChange(price, num1, num2, row) {
this.tableData1.map(v => { this.tableData1.map(v => {
@@ -380,8 +386,8 @@ export default {
询价单流水号: response.data[i].询价单流水号, 询价单流水号: response.data[i].询价单流水号,
物料流水号: response.data[i].物料流水号, 物料流水号: response.data[i].物料流水号,
询价单明细流水号: response.data[i].询价单明细流水号, 询价单明细流水号: response.data[i].询价单明细流水号,
机床图号: response.data[i].机床图号, 机床图号: response.data[i].机床图号 || response.data[i].基本件机床图号,
组号: response.data[i].组号, 组号: response.data[i].组号 || response.data[i].基本件组号,
组件零件流水号: response.data[i].组件零件流水号, 组件零件流水号: response.data[i].组件零件流水号,
组件零件基本件流水号: response.data[i].组件零件基本件流水号, 组件零件基本件流水号: response.data[i].组件零件基本件流水号,
交货期: response.data[i].组件零件流水号 ? response.data[i].标准件和外购件交货期 : response.data[i].基本件交货期, 交货期: response.data[i].组件零件流水号 ? response.data[i].标准件和外购件交货期 : response.data[i].基本件交货期,

View File

@@ -0,0 +1,224 @@
/* eslint-disable */
require('script-loader!file-saver');
// import XLSX from 'xlsx'
import XLSX from 'xlsx-style'
function generateArray(table) {
var out = [];
var rows = table.querySelectorAll('tr');
var ranges = [];
for (var R = 0; R < rows.length; ++R) {
var outRow = [];
var row = rows[R];
var columns = row.querySelectorAll('td');
for (var C = 0; C < columns.length; ++C) {
var cell = columns[C];
var colspan = cell.getAttribute('colspan');
var rowspan = cell.getAttribute('rowspan');
var cellValue = cell.innerText;
if (cellValue !== "" && cellValue == +cellValue) cellValue = +cellValue;
//Skip ranges
ranges.forEach(function (range) {
if (R >= range.s.r && R <= range.e.r && outRow.length >= range.s.c && outRow.length <= range.e.c) {
for (var i = 0; i <= range.e.c - range.s.c; ++i) outRow.push(null);
}
});
//Handle Row Span
if (rowspan || colspan) {
rowspan = rowspan || 1;
colspan = colspan || 1;
ranges.push({
s: {
r: R,
c: outRow.length
},
e: {
r: R + rowspan - 1,
c: outRow.length + colspan - 1
}
});
};
//Handle Value
outRow.push(cellValue !== "" ? cellValue : null);
//Handle Colspan
if (colspan)
for (var k = 0; k < colspan - 1; ++k) outRow.push(null);
}
out.push(outRow);
}
return [out, ranges];
};
function datenum(v, date1904) {
if (date1904) v += 1462;
var epoch = Date.parse(v);
return (epoch - new Date(Date.UTC(1899, 11, 30))) / (24 * 60 * 60 * 1000);
}
function sheet_from_array_of_arrays(data, opts) {
var ws = {};
var range = {
s: {
c: 10000000,
r: 10000000
},
e: {
c: 0,
r: 0
}
};
for (var R = 0; R != data.length; ++R) {
for (var C = 0; C != data[R].length; ++C) {
if (range.s.r > R) range.s.r = R;
if (range.s.c > C) range.s.c = C;
if (range.e.r < R) range.e.r = R;
if (range.e.c < C) range.e.c = C;
var cell = {
v: data[R][C]
};
if (cell.v == null) continue;
var cell_ref = XLSX.utils.encode_cell({
c: C,
r: R
});
if (typeof cell.v === 'number') cell.t = 'n';
else if (typeof cell.v === 'boolean') cell.t = 'b';
else if (cell.v instanceof Date) {
cell.t = 'n';
cell.z = XLSX.SSF._table[14];
cell.v = datenum(cell.v);
} else cell.t = 's';
ws[cell_ref] = cell;
}
}
if (range.s.c < 10000000) ws['!ref'] = XLSX.utils.encode_range(range);
return ws;
}
function Workbook() {
if (!(this instanceof Workbook)) return new Workbook();
this.SheetNames = [];
this.Sheets = {};
}
function s2ab(s) {
var buf = new ArrayBuffer(s.length);
var view = new Uint8Array(buf);
for (var i = 0; i != s.length; ++i) view[i] = s.charCodeAt(i) & 0xFF;
return buf;
}
export function export_table_to_excel(id) {
var theTable = document.getElementById(id);
var oo = generateArray(theTable);
var ranges = oo[1];
/* original data */
var data = oo[0];
var ws_name = "SheetJS";
var wb = new Workbook(),
ws = sheet_from_array_of_arrays(data);
/* add ranges to worksheet */
// ws['!cols'] = ['apple', 'banan'];
ws['!merges'] = ranges;
/* add worksheet to workbook */
wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws;
var wbout = XLSX.write(wb, {
bookType: 'xlsx',
bookSST: false,
type: 'binary'
});
saveAs(new Blob([s2ab(wbout)], {
type: "application/octet-stream"
}), "test.xlsx")
}
export function export_json_to_excel({
headerGroup,
dataGroup,
sheetGroup,
filename,
autoWidth = true,
bookType= 'xlsx'
} = {}) {
var wb = new Workbook()
for (let i = 0; i < dataGroup.length; i++) {
/* original data */
let data = dataGroup[i]
filename = filename || 'excel-list'
data = [...data]
data.unshift(headerGroup[i]);
var ws_name = sheetGroup[i];
var ws = sheet_from_array_of_arrays(data);
if (autoWidth) {
/*设置worksheet每列的最大宽度*/
const colWidth = data.map(row => row.map(val => {
/*先判断是否为null/undefined*/
if (val == null) {
return {
'wch': 10
};
}
/*再判断是否为中文*/
else if (val.toString().charCodeAt(0) > 255) {
return {
'wch': val.toString().length * 2
};
} else {
return {
'wch': val.toString().length
};
}
}))
/*以第一行为初始值*/
let result = colWidth[0];
for (let i = 1; i < colWidth.length; i++) {
for (let j = 0; j < colWidth[i].length; j++) {
if (result[j]['wch'] < colWidth[i][j]['wch']) {
result[j]['wch'] = colWidth[i][j]['wch'];
}
}
}
ws['!cols'] = result;
}
let R = 0;
data.map(item => {
let C = 0;
item.map(itm => {
var cell_ref = XLSX.utils.encode_cell({c:C,r:R});
var cell = {v: itm }
cell.s= {
alignment: {
horizontal: "center"
}
}
ws[cell_ref] = cell;
C++;
})
R++;
})
/* add worksheet to workbook */
wb.SheetNames.push(ws_name);
wb.Sheets[ws_name] = ws;
}
var wbout = XLSX.write(wb, {
bookType: bookType,
bookSST: false,
type: 'binary'
});
saveAs(new Blob([s2ab(wbout)], {
type: "application/octet-stream"
}), `${filename}.${bookType}`);
}

View File

@@ -21,6 +21,7 @@
:value="item.value"/> :value="item.value"/>
</el-select> </el-select>
<el-button type="success" size="small" icon="el-icon-search" style="margin-left: 15px" @click="searchTable()">查询</el-button> <el-button type="success" size="small" icon="el-icon-search" style="margin-left: 15px" @click="searchTable()">查询</el-button>
<el-button type="warning" size="small" icon="el-icon-download" style="margin-left: 15px" @click="exportDetail()">导出</el-button>
</el-card> </el-card>
<el-tabs v-model="PartType" type="border-card" @tab-click="searchTable()"> <el-tabs v-model="PartType" type="border-card" @tab-click="searchTable()">
@@ -268,7 +269,7 @@
</template> </template>
<script> <script>
import { initMachineProject, searchgroup, searchTable1, searchTable2 } from '@/api/PurchasingCenter/PurchaseSituationSearch' import { initMachineProject, searchgroup, searchTable1, searchTable2, searchTable1Export, searchTable2Export } from '@/api/PurchasingCenter/PurchaseSituationSearch'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
name: '', // 采购件采购查询 name: '', // 采购件采购查询
@@ -305,6 +306,96 @@ export default {
this.searchTable() this.searchTable()
}, },
methods: { methods: {
// 导出采购物料执行情况
exportDetail() {
let check1, check2
this.machineNumberValue ? check1 = 1 : check1 = 0
this.groupNumberValue ? check2 = 1 : check2 = 0
searchTable1Export(check1, this.machineNumberValue, check2, this.groupNumberValue, 1).then(res1 => { // 标准件
searchTable1Export(check1, this.machineNumberValue, check2, this.groupNumberValue, 2).then(res2 => { // 外购件
searchTable2Export(check1, this.machineNumberValue, check2, this.groupNumberValue).then(res3 => { // 基本件
import('./Export2Excel').then(excel => {
const dataGroup = []
const filterVal1 = ['机床图号', '组号', '物料名称', '物料型号', '物料规格', '零件数量', ['数量', '离线采购数量'], ['已到货数量', '离线到货数量'], ['供应商名称', '离线合同供应商名称'], ['采购合同编号', '离线合同编号'], '姓名'] // tableData0里的属性名
const filterVal2 = ['机床图号', '组号', '物料名称', '物料型号', '物料规格', '零件数量', ['数量', '离线采购数量'], ['已到货数量', '离线到货数量'], ['供应商名称', '离线合同供应商名称'], ['采购合同编号', '离线合同编号'], '姓名'] // tableData1里的属性名
const filterVal3 = ['机床图号', '组号', '零件名称', '零件图号', '规格', '材料', '零件数量', '数量', '已到货数量', '供应商名称', '采购合同编号', '姓名'] // tableData2里的属性名
const data1 = res1.data.map(v => filterVal1.map(j => {
if (typeof (j) === 'string') {
return v[j] || '—'
} else {
return v[j[0]] || v[j[1]] || '—'
}
}))
data1.map(v => {
v.push('') // 物料状态
if (v[10] === '—') {
v[11] = '未分配'
} else if (v[6] === '—') {
v[11] = '未采购'
} else if (v[6] !== '—' && v[6] !== v[7]) {
v[11] = '未全部到货'
} else if (v[6] !== '—' && v[6] === v[7]) {
v[11] = '全部到货'
}
})
dataGroup.push(data1)
const data2 = res2.data.map(v => filterVal2.map(j => {
if (typeof (j) === 'string') {
return v[j] || '—'
} else {
return v[j[0]] || v[j[1]] || '—'
}
}))
data2.map(v => {
v.push('') // 物料状态
if (v[10] === '—') {
v[11] = '未分配'
} else if (v[6] === '—') {
v[11] = '未采购'
} else if (v[6] !== '—' && v[6] !== v[7]) {
v[11] = '未全部到货'
} else if (v[6] !== '—' && v[6] === v[7]) {
v[11] = '全部到货'
}
})
dataGroup.push(data2)
const data3 = res3.data.map(v => filterVal3.map(j => {
if (typeof (j) === 'string') {
return v[j] || '—'
} else {
return v[j[0]] || v[j[1]] || '—'
}
}))
data3.map(v => {
v.push('') // 物料状态
if (v[11] === '—') {
v[12] = '未分配'
} else if (v[7] === '—') {
v[12] = '未采购'
} else if (v[7] !== '—' && v[7] !== v[8]) {
v[12] = '未全部到货'
} else if (v[7] !== '—' && v[7] === v[8]) {
v[12] = '全部到货'
}
})
dataGroup.push(data3)
const headerGroup = [['机床号', '组号', '名称', '图号或型号', '规格', '技术下达数量', '合同采购数量', '到货数量', '供应商', '合同编号', '采购员', '物料状态'],
['机床号', '组号', '名称', '图号或型号', '规格', '技术下达数量', '合同采购数量', '到货数量', '供应商', '合同编号', '采购员', '物料状态'],
['机床号', '组号', '名称', '图号或型号', '规格', '材料', '技术下达数量', '合同采购数量', '到货数量', '供应商', '合同编号', '采购员', '物料状态']]
const sheetGroup = ['标准件', '外购件', '基本件']
excel.export_json_to_excel({
headerGroup: headerGroup,
dataGroup: dataGroup,
sheetGroup: sheetGroup,
filename: '采购物料执行情况',
autoWidth: true,
bookType: 'xlsx'
})
})
})
})
})
},
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++) {