This commit is contained in:
zhangdingyu
2019-09-18 10:15:45 +08:00
61 changed files with 7778 additions and 24 deletions

View File

@@ -1,25 +1,41 @@
<template>
<div class="app-container">
<el-card>
<<<<<<< HEAD
<span style="margin-left: 0">项目名称:</span>
<el-select v-model="projectValue" placeholder="请选择项目名称" filterable size="small" style="margin-top: 3px">
=======
<span>项目名称</span>
<el-select v-model="projectValue" placeholder="请选择项目名称" filterable size="small">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-option
v-for="item in project"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<<<<<<< HEAD
<el-button type="primary" size="small" style="margin-left: 10px" icon="el-icon-circle-plus-outline" @click="addReceipt">增加</el-button>
<el-button type="warning" size="small" style="margin-left: 10px" icon="el-icon-download" @click="exportTable()">导出</el-button>
=======
<el-button type="primary" size="small" icon="el-icon-circle-plus-outline" @click="addReceipt">增加</el-button>
<el-button type="warning" size="small" icon="el-icon-download" @click="exportTable()">导出</el-button>
<div class="title">总装箱单</div>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-table
v-loading="loading"
:data="receiptData"
border
<<<<<<< HEAD
stripe
size="mini"
highlight-current-row
style="margin-top:3px;margin-bottom: 0"
height="170px"
=======
size="mini"
style="margin-top:20px"
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
@row-click="searchTable">
<el-table-column
label="装箱单号"
@@ -54,6 +70,7 @@
align="center">
<template slot-scope="scope">{{ scope.row.联系方式 }}</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column label="操作" fixed="right" align="center" width="150">
<template slot-scope="scope">
<el-tooltip effect="dark" content="编辑" placement="top">
@@ -75,28 +92,56 @@
@click="handleDeleteReceipt(scope.row)"/>
</div>
</el-tooltip>
=======
<el-table-column label="操作" fixed="right" align="center" width="200">
<template slot-scope="scope">
<el-button
size="mini"
type="primary"
icon="el-icon-edit"
@click="handleEditReceipt(scope.row)">编辑</el-button>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="handleDeleteReceipt(scope.row)">删除</el-button>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
</template>
</el-table-column>
</el-table>
</el-card>
<<<<<<< HEAD
<el-card >
<el-button :disabled="!disabled" plain type="primary" style="margin-top: 3px" size="small" icon="el-icon-circle-plus-outline" @click="addMachine">添加主机</el-button>
=======
<el-card style="margin-top: 10px">
<el-button :disabled="!disabled" type="primary" size="small" icon="el-icon-circle-plus-outline" @click="addMachine">添加主机</el-button>
<div class="title">主机</div>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-table
v-loading="loading"
:data="machineTableData"
border
<<<<<<< HEAD
stripe
highlight-current-row
size="mini"
height="170px"
style="margin-top:3px;margin-bottom: 0">
=======
size="mini"
style="margin-top:20px">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-table-column type="expand">
<template slot-scope="props">
<el-table
:data="groupData"
border
<<<<<<< HEAD
stripe
=======
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
size="mini"
style="width: 90%">
<el-table-column
@@ -168,6 +213,7 @@
align="center">
<template slot-scope="scope">{{ scope.row.备注 }}</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column label="操作" fixed="right" align="center" width="150">
<template slot-scope="scope">
<el-tooltip effect="dark" content="编辑" placement="top">
@@ -189,22 +235,47 @@
@click="deleteMachine(scope.row)"/>
</div>
</el-tooltip>
=======
<el-table-column label="操作" fixed="right" align="center" width="200">
<template slot-scope="scope">
<el-button
size="mini"
type="primary"
icon="el-icon-edit"
@click="editMachine(scope.row)">编辑</el-button>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="deleteMachine(scope.row)">删除</el-button>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
</template>
</el-table-column>
</el-table>
</el-card>
<<<<<<< HEAD
<el-card >
<el-button :disabled="!disabled" type="primary" style="margin-top: 3px" plain size="small" icon="el-icon-circle-plus-outline" @click="addSpare">添加备件</el-button>
=======
<el-card style="margin-top: 10px">
<el-button :disabled="!disabled" type="primary" size="small" icon="el-icon-circle-plus-outline" @click="addSpare">添加备件</el-button>
<div class="title">随机供应的备件</div>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-table
v-loading="loading"
:data="spareData"
border
<<<<<<< HEAD
stripe
highlight-current-row
height="170px"
size="mini"
style="margin-top:3px;margin-bottom: 0">
=======
size="mini"
style="margin-top:20px">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-table-column
label="序号"
type="index"
@@ -237,6 +308,7 @@
align="center">
<template slot-scope="scope">{{ scope.row.备注 }}</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column label="操作" fixed="right" align="center" width="150">
<template slot-scope="scope">
<el-tooltip class="item" effect="dark" content="编辑" placement="top">
@@ -258,17 +330,38 @@
@click="deleteSpare(scope.row)"/>
</div>
</el-tooltip>
=======
<el-table-column label="操作" fixed="right" align="center" width="200">
<template slot-scope="scope">
<el-button
size="mini"
type="primary"
icon="el-icon-edit"
@click="editSpare(scope.row)">编辑</el-button>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="deleteSpare(scope.row)">删除</el-button>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
</template>
</el-table-column>
</el-table>
</el-card>
<<<<<<< HEAD
<el-card >
<el-button :disabled="!disabled" plain type="primary" size="small" style="margin-top: 3px" icon="el-icon-circle-plus-outline" @click="addFile">添加文件</el-button>
=======
<el-card style="margin-top: 10px">
<el-button :disabled="!disabled" type="primary" size="small" icon="el-icon-circle-plus-outline" @click="addFile">添加文件</el-button>
<div class="title">随机技术文件</div>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-table
v-loading="fileLoading"
:data="fileData"
border
<<<<<<< HEAD
highlight-current-row
stripe
height="170px"
@@ -281,15 +374,34 @@
<el-table-column
label="名称"
align="center">
=======
size="mini"
style="margin-top:20px">
<el-table-column
label="序号"
align="center"
type="index"
min-width="150px"/>
<el-table-column
label="名称"
align="center"
min-width="200px">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">{{ scope.row.名称 }}</template>
</el-table-column>
<el-table-column
label="数量"
<<<<<<< HEAD
align="center">
=======
align="center"
min-width="100px">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">{{ scope.row.数量 }}</template>
</el-table-column>
<el-table-column
label="备注"
<<<<<<< HEAD
align="center">
<template slot-scope="scope">{{ scope.row.备注 }}</template>
</el-table-column>
@@ -314,6 +426,24 @@
@click="deleteFile(scope.row)"/>
</div>
</el-tooltip>
=======
align="center"
min-width="500px">
<template slot-scope="scope">{{ scope.row.备注 }}</template>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="200">
<template slot-scope="scope">
<el-button
size="mini"
type="primary"
icon="el-icon-edit"
@click="editFile(scope.row)">编辑</el-button>
<el-button
size="mini"
type="danger"
icon="el-icon-delete"
@click="deleteFile(scope.row)">删除</el-button>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
</template>
</el-table-column>
</el-table>

View File

@@ -5,7 +5,11 @@
<div style="overflow: hidden">
<div style="margin-bottom: 10px;">
<span>项目</span>
<<<<<<< HEAD
<el-select v-model="projectValue" filterable size="small" style="margin-top: 3px" placeholder="项目名称">
=======
<el-select v-model="projectValue" filterable size="small" placeholder="项目名称">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-option
v-for="item in project"
:key="item.value"

View File

@@ -1,7 +1,11 @@
<template>
<div>
<el-card>
<<<<<<< HEAD
<div style="width: 900px;margin: 3px auto">
=======
<div style="width: 900px;margin: 0 auto">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<span>机床名称</span>
<el-select v-model="machineValue" filterable clearable size="small" placeholder="机床名称" @change="getGroups">
<el-option
@@ -10,7 +14,11 @@
:label="item.label"
:value="item.value"/>
</el-select>
<<<<<<< HEAD
<span style="margin-left: 10px">分组名称</span>
=======
<span>分组名称</span>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-select v-model="groupValue" filterable clearable size="small" placeholder="分组名称">
<el-option
v-for="item in groupsNames"
@@ -18,9 +26,15 @@
:label="item.label"
:value="item.value"/>
</el-select>
<<<<<<< HEAD
<el-button :loading="listLoading" :disabled="disabled" type="primary" plain icon="el-icon-d-caret" size="small" style="margin-left: 10px" @click="transferData">传递</el-button>
<el-button type="danger" plain icon="el-icon-delete" size="small" style="margin-left: 10px" @click="allDelete">一键删除</el-button>
<el-row style="margin-top: 10px">
=======
<el-button :loading="listLoading" :disabled="disabled" type="primary" icon="el-icon-d-caret" size="small" style="margin-left: 10px" @click="transferData">传递</el-button>
<el-button type="danger" icon="el-icon-delete" size="small" @click="allDelete">一键删除</el-button>
<el-row style="margin-top: 20px">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<span>机床名称</span>
<el-input v-model="machineName" readonly size="small" placeholder="机床名称" style="width: 200px;"/>
<span>机床数量</span>
@@ -34,33 +48,53 @@
:data="tableData"
:row-class-name="tableRowClassName"
size="mini"
<<<<<<< HEAD
height="300"
highlight-current-row
border
stripe
=======
border
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
@row-click="searchMaterial1">
<el-table-column
label="序号"
align="center"
type="index"
width="50"/>
<<<<<<< HEAD
<el-table-column align="center" label="物料状态" min-width="90">
=======
<el-table-column align="center" label="物料状态" min-width="100">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
<el-tag v-if="scope.row.物料流水号===null" type="warning" size="small">不存在</el-tag>
<el-tag v-if="scope.row.物料流水号!==null" type="primary" size="small">存在</el-tag>
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="图号" min-width="120">
=======
<el-table-column align="center" label="图号" min-width="150">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.图号或者型号 }}
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="名称" min-width="80">
=======
<el-table-column align="center" label="名称" min-width="100">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.名称 }}
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="材料" width="100">
=======
<el-table-column align="center" label="材料" width="150">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.材料或者规格 }}
</template>
@@ -85,31 +119,53 @@
{{ scope.row.部件数量 }}
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="制造商" min-width="80">
=======
<el-table-column align="center" label="制造商" min-width="100">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.制造商 }}
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="备注" width="80">
=======
<el-table-column align="center" label="备注" width="100">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.备注 }}
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="分类码" width="60">
=======
<el-table-column align="center" label="分类码" width="80">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.分类码 }}
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="整改类型" width="300">
<template slot-scope="scope">
<el-radio-group v-model="scope.row.整改类型" @change="submitChangeType(scope.row)" >
=======
<el-table-column align="center" label="整改类型" width="250">
<template slot-scope="scope">
<el-radio-group v-model="scope.row.整改类型" @change="submitChangeType(scope.row)">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-radio :label="1" class="radio">新增</el-radio>
<el-radio :label="2" class="radio">替换</el-radio>
<el-radio :label="3" class="radio">补充加工</el-radio>
</el-radio-group>
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="旧图号" >
=======
<el-table-column align="center" label="旧图号" width="150">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.前图号或者型号 }}
</template>
@@ -133,9 +189,13 @@
style="width: 100%"
size="mini"
highlight-current-row
<<<<<<< HEAD
height="150"
border
stripe>
=======
border>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-table-column
label="序号"
align="center"
@@ -762,9 +822,16 @@ export default {
<style scoped>
span{
<<<<<<< HEAD
margin: 3px;
}
radio {
margin-left: 3px;
=======
margin: 10px;
}
.radio {
margin-left: 10px;
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
}
</style>

View File

@@ -1,11 +1,19 @@
<template>
<div class="app-container">
<el-card v-loading="loading">
<<<<<<< HEAD
<div style="width: 650px;margin: 0 auto">
<div style="overflow: hidden">
<div style="margin-bottom: 10px;">
<span>项目</span>
<el-select v-model="projectValue" filterable size="small" placeholder="项目名称" style="margin-top: 3px">
=======
<div style="width: 620px;margin: 0 auto">
<div style="overflow: hidden">
<div style="margin-bottom: 10px;">
<span>项目</span>
<el-select v-model="projectValue" filterable size="small" placeholder="项目名称">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-option
v-for="item in project"
:key="item.value"
@@ -20,7 +28,11 @@
:label="item.label"
:value="item.value"/>
</el-select>
<<<<<<< HEAD
<el-button type="primary" size="small" icon="el-icon-upload2" style="margin-left: 10px" @click="opendialogVisibleMachine()">上传总图</el-button>
=======
<el-button type="primary" size="small" @click="opendialogVisibleMachine()">上传总图</el-button>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
</div>
<upload-excel-component @on-selected-file="selected"/>
</div>
@@ -30,7 +42,11 @@
</el-tooltip>
<el-upload :on-remove="handleRemove" :file-list="itemFile" action=""/>
</div>
<<<<<<< HEAD
<div v-if="worksheet.length !== 0" style="float: right;margin: 3px 0">
=======
<div v-if="worksheet.length !== 0" style="float: right;margin: 20px 0">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-button :disabled="disabled" icon="el-icon-upload2" type="primary" size="small" @click="basicPartsToSQL">导入到数据库</el-button>
</div>
</div>

View File

@@ -3,7 +3,11 @@
<el-card>
<div style="width: 900px;margin: 0 auto">
<span>机床名称</span>
<<<<<<< HEAD
<el-select v-model="machineValue" filterable clearable size="small" placeholder="机床名称" style="margin-top: 3px" @change="getGroups">
=======
<el-select v-model="machineValue" filterable clearable size="small" placeholder="机床名称" @change="getGroups">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-option
v-for="item in machineNames"
:key="item.value"
@@ -18,9 +22,15 @@
:label="item.label"
:value="item.value"/>
</el-select>
<<<<<<< HEAD
<el-button :loading="listLoading" :disabled="disabled" type="primary" plain icon="el-icon-d-caret" size="small" style="margin-left: 10px" @click="transferData">传递</el-button>
<el-button type="danger" icon="el-icon-delete" plain size="small" @click="allDelete">一键删除</el-button>
<el-row style="margin-top: 5px;margin-bottom: 3px">
=======
<el-button :loading="listLoading" :disabled="disabled" type="primary" icon="el-icon-d-caret" size="small" style="margin-left: 10px" @click="transferData">传递</el-button>
<el-button type="danger" icon="el-icon-delete" size="small" @click="allDelete">一键删除</el-button>
<el-row style="margin-top: 20px">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<span>机床名称</span>
<el-input v-model="machineName" readonly size="small" placeholder="机床名称" style="width: 200px;"/>
<span>机床数量</span>
@@ -35,8 +45,11 @@
:row-class-name="tableRowClassName"
size="mini"
border
<<<<<<< HEAD
stripe
height="280px"
=======
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
highlight-current-row
@row-click="searchMaterial1">
<el-table-column
@@ -44,6 +57,7 @@
align="center"
type="index"
width="50"/>
<<<<<<< HEAD
<el-table-column align="center" label="物料状态" min-width="50">
<template slot-scope="scope">
<el-tag v-if="scope.row.物料流水号===null" type="warning" size="small" style="margin: 0px">不存在</el-tag>
@@ -51,11 +65,24 @@
</template>
</el-table-column>
<el-table-column align="center" label="图号" min-width="150">
=======
<el-table-column align="center" label="物料状态" min-width="100">
<template slot-scope="scope">
<el-tag v-if="scope.row.物料流水号===null" type="warning" size="small">不存在</el-tag>
<el-tag v-if="scope.row.物料流水号!==null" type="primary" size="small">存在</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="图号" min-width="200">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.图号或者型号 }}
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="名称" min-width="200" show-overflow-tooltip>
=======
<el-table-column align="center" label="名称" min-width="100">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.名称 }}
</template>
@@ -65,7 +92,11 @@
{{ scope.row.材料或者规格 }}
</template>
</el-table-column>
<<<<<<< HEAD
<el-table-column align="center" label="规格" width="150">
=======
<el-table-column align="center" label="规格" width="100">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<template slot-scope="scope">
{{ scope.row.规格 }}
</template>
@@ -115,7 +146,11 @@
<!--</template>-->
<!--</el-table-column>-->
</el-table>
<<<<<<< HEAD
<div class="block">
=======
<div class="block" style="margin-top: 10px;">
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-pagination
:current-page="pageCurrent"
:page-sizes="[10, 20, 40, 100]"
@@ -132,10 +167,15 @@
:cell-class-name="cell"
style="width: 100%"
size="mini"
<<<<<<< HEAD
height="200px"
highlight-current-row
border
stripe>
=======
highlight-current-row
border>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
<el-table-column
label="序号"
align="center"

View File

@@ -0,0 +1,220 @@
/* eslint-disable */
require('script-loader!file-saver');
import XLSX from 'xlsx'
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({
multiHeader = [],
header,
data,
filename,
merges = [],
autoWidth = true,
bookType= 'xlsx'
} = {}) {
/* original data */
filename = filename || 'excel-list'
data = [...data]
data.unshift(header);
for (let i = multiHeader.length-1; i > -1; i--) {
data.unshift(multiHeader[i])
}
var ws_name = "SheetJS";
var wb = new Workbook(),
ws = sheet_from_array_of_arrays(data);
if (merges.length > 0) {
if (!ws['!merges']) ws['!merges'] = [];
merges.forEach(item => {
ws['!merges'].push(XLSX.utils.decode_range(item))
})
}
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;
}
/* 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

@@ -29,6 +29,10 @@
</el-select>
<el-button icon="el-icon-search" type="success" size="small" @click="pageCurrentWB = 1;pageSizeWB = 10;pageCurrent = 1;pageSize = 10;getTableData()">查询</el-button>
<<<<<<< HEAD
=======
<el-button :loading="downloadLoading" type="success" icon="el-icon-download" size="small" style="margin-left: 15px" @click="handleDownload()">导出EXCEL</el-button>
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
</el-card>
<el-card>
<div v-for="(file, key) in hadFile" :key="key">
@@ -259,10 +263,19 @@
import { projectSelect, machineSelect, groupSelect, basicPartsData, deleteBasicParts, purchasePartsData, deletePurchaseData, getFileData } from '@/api/TechnologyCenter/QueryParts'
import { mapGetters } from 'vuex'
import { ServerIP } from '@/utils/request'
<<<<<<< HEAD
=======
import request from '@/utils/request'
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
export default {
name: 'Index',
data() {
return {
<<<<<<< HEAD
=======
downloadLoading: false,
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
projectValue: '',
project: [],
machineValue: '',
@@ -342,6 +355,86 @@ export default {
this.fetchData()
},
methods: {
<<<<<<< HEAD
=======
async handleDownload() {
this.downloadLoading = true
await request({
url: '',
method: 'post',
data: {
type: '3',
name: `declare @项目流水号 int =${this.projectValue}
create table #临时表1
(
id int IDENTITY (1,1) not null,
物料名称 nvarchar(50),
物料规格 nvarchar(50),
物料型号 nvarchar(50),
primary key (id)
);
create table #临时表2
(
id int IDENTITY (1,1) not null,
物料名称 nvarchar(50),
物料规格 nvarchar(50),
物料型号 nvarchar(50),
总数量 int,
primary key (id)
);
insert into #临时表1 select distinct 物料名称,物料规格,物料型号 from dbo.零件查询_物料规格型号_统计查询_视图
where 项目流水号=@项目流水号
declare @id int =1
declare @id2 int
declare @物料名称 nvarchar(50)
declare @物料规格 nvarchar(50)
declare @物料型号 nvarchar(50)
declare @总数量 int
while (@id<=(select COUNT (id) from #临时表1 ))
begin
select @物料名称=物料名称,@物料规格=物料规格,@物料型号=物料型号 from #临时表1
where id=@id
insert into #临时表2 (物料名称,物料规格,物料型号) values (@物料名称,@物料规格,@物料型号)
set @id2 = @@IDENTITY
select @总数量 = COUNT(物料流水号) from 零件查询_物料规格型号_统计查询_视图
where 物料名称=@物料名称 and 物料规格=@物料规格 and 物料型号=@物料型号 and 项目流水号=@项目流水号
update #临时表2 set 总数量 = @总数量
where id=@id2
set @id = @id + 1
end
select * from #临时表2
drop table #临时表1
drop table #临时表2`
}
}).then(res => {
if (res.data.length === 0) {
this.$message.error('暂无数据')
this.downloadLoading = false
} else {
import('./Export2Excel').then(excel => {
const tHeader = ['物料名称', '物料型号', '物料规格', '总数量']
const filterVal = ['物料名称', '物料型号', '物料规格', '总数量']
const list = res.data
const data = this.formatJson(filterVal, list)
excel.export_json_to_excel({
header: tHeader,
data,
filename: 'EXCEL',
autoWidth: true,
bookType: 'xlsx'
})
this.downloadLoading = false
})
}
})
},
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
return v[j]
}))
},
// ///////////////////////////////////////////////////↑0910zdy
>>>>>>> 4a39ba8190d04cdcdea962794e7d7df3408bfd2d
// 在什么情况下需要查询上传的附件调用this.getFileData()即可根据
getFileData(machineValue) {
this.hadFile = []