<template>
|
<!-- 仓库信息 -->
|
<div id="quotation"
|
class="global-content">
|
<!-- 筛选 -->
|
<inbound-inuqer ref="inref"
|
byfilter="计划单号"
|
:filterList="filterList"
|
:add="true"
|
:tolead="true"
|
:derive="true"
|
:imexcel="true"
|
:datetimeshow="true"
|
@refresh="refresh"
|
@addmodal="addmodal"
|
@inquer="inquer"
|
@derive="derive"
|
@importfile="importfile" />
|
<!-- <input type="file" accept=".xls,.xlsx" @change="readExcel($event)" /> -->
|
|
<!-- table -->
|
<div class="table">
|
<table-container :tableHead="tableHead"
|
:tableData="tableData"
|
:editShow="true"
|
:delShow="true"
|
:pageSize="pageSize"
|
:totle="totle"
|
@edit="edit"
|
@del="del"
|
@SizeChange="SizeChange"
|
@CurrentChange="CurrentChange" />
|
</div>
|
|
<transition name="modal">
|
<modal v-if="addmodalShow"
|
:modabg="true"
|
:modalStyle="modalStyle"
|
@cancel="addmodalShow = false">
|
<p slot="title">冲压生产计划单-{{ title }}</p>
|
<div class="height"
|
slot="centent">
|
<quotaion-edit @partclick="partShow = true"
|
@cancel="
|
addmodalShow = false;
|
refresh();
|
"
|
:chooselist="chooselist"
|
:rowitem="rowitem"
|
@addsubmit="addsubmit" />
|
</div>
|
</modal>
|
</transition>
|
<transition name="modal">
|
<modal v-if="partShow"
|
:modabg="true"
|
@cancel="partShow = false">
|
<p slot="title">零件选择</p>
|
<div class="height"
|
slot="centent">
|
<choose ref="partChoose"
|
:wipelist="wipelist"
|
@chooseClick="chooseClick"
|
@cancel="partShow = false"
|
@addchoose="addchooseShow = true" />
|
</div>
|
</modal>
|
</transition>
|
</div>
|
</template>
|
|
<script>
|
import { TableContainer, Modal, Choose, AddChoose } from '@/components/index';
|
import inboundInuqer from '../../components/inboundinuqer';
|
import quotaionEdit from '../../components/quotaionEdit';
|
import { getimestampDate, getymdhms } from '@/utils/date';
|
import { exportTableList } from '@/utils/excel';
|
const { quotation } = require('@/components/tableContainer/tableHead');
|
import { getCache, setCache, removeToken } from '@/utils/sessionStorage';
|
import { InOrderSearch, InOrderDelete, ImportInOrder } from '@/api/quotation';
|
import XLSX from 'xlsx';
|
export default {
|
name: 'quotation',
|
data () {
|
return {
|
modalStyle: {
|
width: '50%'
|
},
|
title: '',
|
tableData: [],
|
modalShow: false,
|
addmodalShow: false,
|
partShow: false,
|
addchooseShow: false,
|
|
chooselist: [],
|
rowitem: {},
|
totle: 0,
|
page: 1,
|
pageSize: 20,
|
wipelist: ['inOrderCode'],
|
inuqerobg: {},
|
filterList: [
|
{
|
value: '计划单号',
|
label: '计划单号'
|
}
|
]
|
};
|
},
|
components: { TableContainer, inboundInuqer, Modal, quotaionEdit, Choose, AddChoose },
|
computed: {
|
tableHead () {
|
return quotation;
|
}
|
},
|
created () { },
|
mounted () {
|
this.InOrderSearch();
|
console.log(getymdhms());
|
},
|
methods: {
|
//刷新
|
refresh () {
|
this.inuqerobg = {};
|
this.$refs.inref.inrefclear();
|
this.InOrderSearch();
|
},
|
//查询
|
inquer (e) {
|
this.page = 1;
|
this.inuqerobg = e;
|
this.InOrderSearch();
|
},
|
//导出
|
derive () {
|
let tHeader = [];
|
let filterVal = [];
|
this.tableHead.forEach(item => {
|
tHeader.push(item.columnDescription);
|
filterVal.push(item.columnName);
|
});
|
this.$Loading(true);
|
const { 计划单号: inOrderCode } = this.inuqerobg;
|
//console('inOrderCode' + inOrderCode)
|
const OrderStatusId = this.inuqerobg.OrderStatusId;
|
const orderType = this.inuqerobg.orderType;
|
InOrderSearch('1&onePageNum=99999999', {
|
inOrderCode, orderType, OrderStatusId,
|
createTimeStart: this.inuqerobg.timepick ? this.inuqerobg.timepick[0] : '',
|
createTimeEnd: this.inuqerobg.timepick ? this.inuqerobg.timepick[1] : ''
|
}).then(res => {
|
if (res.code == 0) {
|
let data = res.data;
|
data.forEach(item => {
|
item.doTime = item.doTime ? getimestampDate(item.doTime) : '';
|
item.updateTime = item.updateTime ? getimestampDate(item.updateTime) : '';
|
});
|
exportTableList(tHeader, filterVal, data, '冲压计划' + getymdhms());
|
}
|
this.$Loading(false);
|
});
|
},
|
//导入
|
importfile (e) {
|
this.readExcel(e);
|
},
|
|
//获取生产计划列表
|
InOrderSearch () {
|
this.$Loading(true);
|
const { 计划单号: inOrderCode } = this.inuqerobg;
|
//console('inOrderCode' + inOrderCode)
|
const OrderStatusId = this.inuqerobg.OrderStatusId;
|
const orderType = this.inuqerobg.orderType;
|
InOrderSearch(this.page + '&onePageNum=' + this.pageSize, {
|
inOrderCode, orderType, OrderStatusId,
|
createTimeStart: this.inuqerobg.timepick ? this.inuqerobg.timepick[0] : '',
|
createTimeEnd: this.inuqerobg.timepick ? this.inuqerobg.timepick[1] : ''
|
}).then(res => {
|
if (res.code == 0) {
|
this.tableData = res.data.filter(item => (item.doTime = getimestampDate(item.doTime)));
|
this.totle = res.num;
|
}
|
this.$Loading();
|
});
|
},
|
//分页
|
CurrentChange (e) {
|
console.log(e);
|
this.page = e;
|
this.InOrderSearch();
|
},
|
//页数
|
SizeChange (e) {
|
this.pageSize = e;
|
this.InOrderSearch();
|
},
|
//编辑
|
edit (row) {
|
this.addmodalShow = true;
|
this.rowitem = { ...row };
|
this.title = '编辑';
|
},
|
//删除
|
del (row) {
|
console.log(row);
|
const { inOrderCode } = { ...row };
|
this.$confirm('此操作将永久删除该生产计划信息, 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(() => {
|
InOrderDelete({ inOrderCode }).then(res => {
|
if (res.code == 0) {
|
this.$message({
|
type: 'success',
|
message: '删除成功'
|
});
|
this.InOrderSearch();
|
} else {
|
this.$message({
|
type: 'warning',
|
message: '删除失败'
|
});
|
}
|
});
|
})
|
.catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
},
|
//新建
|
addmodal () {
|
this.rowitem = {};
|
this.addmodalShow = true;
|
this.title = '新建';
|
},
|
//新增修改后
|
addsubmit () {
|
this.addmodalShow = false;
|
this.modalShow = false;
|
this.UserSearch();
|
},
|
//零件勾选数据
|
chooseClick (e) {
|
if (e.length > 0) {
|
this.chooselist = [...e];
|
this.partShow = false;
|
} else {
|
this.$message({
|
type: 'info',
|
message: '请勾选'
|
});
|
}
|
},
|
//新增零件后
|
addchooseclick () {
|
this.addchooseShow = false;
|
this.$refs.partChoose.itemSearch();
|
},
|
readExcel (e) {
|
// 读取表格文件
|
let _this = this;
|
const files = e.file;
|
// debugger;
|
if (files.length <= 0) {
|
return false;
|
} else if (!/\.(xls|xlsx)$/.test(files.name.toLowerCase())) {
|
this.$message({
|
message: '上传格式不正确,请上传xls或者xlsx格式',
|
type: 'warning'
|
});
|
return false;
|
} else {
|
// 更新获取文件名
|
console.log(files);
|
}
|
|
const fileReader = new FileReader();
|
fileReader.onload = ev => {
|
try {
|
const data = ev.target.result;
|
const workbook = XLSX.read(data, {
|
type: 'binary'
|
});
|
const wsname = workbook.SheetNames[0]; //取第一张表
|
const ws = XLSX.utils.sheet_to_json(workbook.Sheets[wsname]); //生成json表格内容
|
console.log(ws);
|
let list = [];
|
|
ws.forEach(item => {
|
list.push({
|
itemCode: item['零件编号'],
|
inType: item['生产类型'],
|
Desc: item['生产班线'],
|
createTime: item['生产日期'],
|
itemNum: item['生产数量']
|
});
|
});
|
_this.ImportInOrder(JSON.stringify(list));
|
} catch (e) {
|
return false;
|
}
|
};
|
fileReader.readAsBinaryString(files);
|
},
|
//导入接口
|
ImportInOrder (list) {
|
ImportInOrder({ userName: getCache('userInfo').userName, items: list }).then(res => {
|
if (res.code == 0) {
|
this.$message({
|
type: 'success',
|
message: '导入成功'
|
});
|
} else {
|
this.$message({
|
type: 'warning',
|
message: '导入失败!请按照模板填入内容'
|
});
|
}
|
});
|
this.InOrderSearch();
|
}
|
}
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
#quotation {
|
.table {
|
width: 100%;
|
margin-top: 10px;
|
height: calc(100% - 40px);
|
overflow: hidden;
|
}
|
}
|
</style>
|