Files
JY1.0/src/views/Outsourcing/OutsourcingPartsQuery/index.vue
liushuai cef05b6165 更新
2020-06-03 08:46:28 +08:00

350 lines
11 KiB
Vue

<template>
<div class="app-container">
<el-card>
<div style="margin-top: 7px; margin-bottom: 7px">
<el-input v-model="supplierNameValue" size="small" placeholder="外协厂家零件图号表单号项目名称" style="width: 220px" clearable/>
<el-date-picker v-model="timer" type="daterange" value-format="yyyy-MM-dd" size="small" range-separator="~" start-placeholder="开始日期" end-placeholder="结束日期" style="width: 240px"/>
<el-select v-model="MaterialsValue" placeholder="外协状态" filterable size="small" style="width: 120px" clearable>
<el-option
v-for="item in Materials"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<el-button icon="el-icon-search" type="primary" size="small" plain @click="pageCurrent=1;pageSize=50;getTableData()">查询</el-button>
<el-button v-positive="'loading'" :disabled="false" type="success" class="el-icon-download" size="small" style="margin: 10px 0 0 10px" plain @click="exportExcel">导出</el-button>
</div>
</el-card>
<el-card>
<el-table v-loading="loading" :data="tableData" border stripe size="mini" height="650" style="width: 1480px">
<el-table-column label="序号" align="center" type="index" width="50"/>
<el-table-column label="外协状态" align="center" width="80px">
<template slot-scope="scope">
<el-tag v-if="Number(scope.row.外协状态)==1" type="primary" size="mini">未提交</el-tag>
<el-tag v-if="Number(scope.row.外协状态)===0" type="success" size="mini">未外协</el-tag>
<el-tag v-if="Number(scope.row.外协状态)==2 && Number(scope.row.到货状态)!==1" type="warning" size="mini">未到货</el-tag>
<el-tag v-if="Number(scope.row.外协状态)==3 && Number(scope.row.到货状态)===1" type="success" size="mini">已到货</el-tag>
</template>
</el-table-column>
<el-table-column label="零件图号" align="center" width="140px" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.零件图号 }}
</template>
</el-table-column>
<el-table-column label="零件名称" align="center" width="110px">
<template slot-scope="scope">
{{ scope.row.零件名称 }}
</template>
</el-table-column>
<el-table-column label="数量" align="center" width="55">
<template slot-scope="scope">
{{ scope.row.批次数量 }}
</template>
</el-table-column>
<el-table-column label="外协工序" align="center" width="100">
<template slot-scope="scope">
{{ scope.row.外协工序 }}
</template>
</el-table-column>
<el-table-column label="外协工时(分)" align="center" width="110">
<template slot-scope="scope">
{{ scope.row.外协工时 }}
</template>
</el-table-column>
<el-table-column label="工时费用(元)" align="center" width="110">
<template slot-scope="scope">
{{ scope.row.加工价格_成交 }}
</template>
</el-table-column>
<el-table-column label="外协厂家" align="center" width="140px" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.外协厂家名称 }}
</template>
</el-table-column>
<el-table-column label="外协单号" align="center" width="160">
<template slot-scope="scope">
{{ scope.row.表单号 }}
</template>
</el-table-column>
<el-table-column label="外协日期" align="center" width="100">
<template slot-scope="scope">
{{ scope.row.任务下达日期 ? scope.row.任务下达日期.split(' ')[0]:scope.row.任务下达日期 }}
</template>
</el-table-column>
<el-table-column label="计划到货" align="center" width="120">
<template slot-scope="scope">
{{ scope.row.到货日期 ? (scope.row.到货日期.split(' ')[0] !== '1900-01-01' ? scope.row.到货日期.split(' ')[0] : '') : scope.row.到货日期 }}
</template>
</el-table-column>
<el-table-column label="实际到货" align="center" width="120">
<template slot-scope="scope">
{{ scope.row.到货时间 ? (scope.row.到货时间.split(' ')[0] !== '1900-01-01' ? scope.row.到货时间.split(' ')[0] : '') : scope.row.到货时间 }}
</template>
</el-table-column>
<el-table-column label="外协员" align="center" width="70" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.外协计划员 }}
</template>
</el-table-column>
</el-table>
<div class="block" style="margin-top: 10px;">
<el-pagination
:current-page="pageCurrent"
:page-sizes="[10, 20, 30, 50, 100]"
:page-size="pageSize"
:total="total"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChanges"
@current-change="handleCurrentChanges"/>
</div>
</el-card>
<el-card v-show="false">
<div id="myChart1" :style="{width: '100%', height: '400px', margin: 'auto'}"/>
</el-card>
</div>
</template>
<script>
import { searchTable, getprocedure, search1 } from '@/api/Outsourcing/OutsourcingPartsQuery'
import echarts from 'echarts'
export default {
data() {
return {
timer: '',
supplierNameValue: '',
loading: false,
total: 0,
MaterialsValue: '',
Materials: [{
value: 0,
label: '未到'
}, {
value: 1,
label: '已到'
}, {
value: 2,
label: '未提交'
}, {
value: 3,
label: '未外协'
}],
tableData: [],
procedure: [],
procedureTime: [],
pageCurrent: 1,
pageSize: 50,
tableData1: []
}
},
created() {
this.getTableData()
this.search1()
},
methods: {
formatJson(filterVal, jsonData) {
return jsonData.map(v => filterVal.map(j => {
return v[j]
}))
},
exportExcel() {
let check, check1, check2
this.supplierNameValue ? check = 1 : check = 0
if (this.MaterialsValue !== '' && this.MaterialsValue !== null) {
check1 = 1
} else {
check1 = 0
}
if (this.timer === null) {
this.timer = ''
}
if (this.timer[1] === undefined || this.timer[0] === undefined || this.timer[1] === null || this.timer[0] === null) {
check2 = 0
} else {
check2 = 1
}
var param = []
param[0] = ['外协厂家_check', check]
param[1] = ['外协厂家', this.supplierNameValue]
param[2] = ['外协状态_check', check1]
param[3] = ['外协状态', this.MaterialsValue]
param[4] = ['时间_check', check2]
if (check2 === 0) {
param[5] = ['开始时间', '']
param[6] = ['结束时间', '']
} else {
param[5] = ['开始时间', this.timer[0]]
param[6] = ['结束时间', this.timer[1]]
}
var Data = this.CreateData('2001', '报表_车间生产管理_外协零件_查询数据_新', param)
this.exportExcel_NPOI(Data)
},
getTableData() {
this.tableData = []
this.loading = true
let check, check1, check2
this.supplierNameValue ? check = 1 : check = 0
if (this.MaterialsValue !== '' && this.MaterialsValue !== null) {
check1 = 1
} else {
check1 = 0
}
if (this.timer === null) {
this.timer = ''
}
if (this.timer[1] === undefined || this.timer[0] === undefined || this.timer[1] === null || this.timer[0] === null) {
check2 = 0
} else {
check2 = 1
}
searchTable(check, this.supplierNameValue, check1, this.MaterialsValue, check2, this.timer[0], this.timer[1], this.pageSize, this.pageCurrent).then(response => {
this.tableData = response.data.result
this.total = parseInt(response.data.output[0].ItemCount)
this.loading = false
})
},
getProcedure(row) {
for (let i = 0; i < row.length; i++) {
getprocedure(row[i].工艺计划流水号, row[i].单件是否外协).then(response => {
this.procedure[i] = ''
this.procedureTime[i] = 0
for (let j = 0; j < response.data.length; j++) {
this.procedure[i] = this.procedure[i] + ' ' + response.data[j].工艺名称简称
this.procedureTime[i] = parseInt(this.procedureTime[i]) + parseInt(response.data[j].单件定额工时) * row[i].批次数量 + parseInt(response.data[j].准结定额工时)
}
this.tableData[i].外协工序 = this.procedure[i]
this.tableData[i].外协工时 = this.procedureTime[i]
})
}
},
handleSizeChanges(val) {
this.pageCurrent = 1
this.pageSize = val
this.getTableData()
},
handleCurrentChanges(val) {
this.pageCurrent = val
this.getTableData()
},
// 统计图
search1() {
search1().then(response => {
this.res1 = response.data
}).then(() => {
var myChart1 = echarts.init(document.getElementById('myChart1'))
myChart1.clear()
this.drawLine1(this.res1)
})
},
drawLine1(data) {
var dataX = []
var lineData1 = []
for (let i = 0; i < data.length; i++) {
dataX.push(data[i].外协厂家名称)
lineData1.push(data[i].时间)
}
var myChart1 = echarts.init(document.getElementById('myChart1'))
myChart1.clear()
myChart1.setOption({
grid: {
left: '3%',
right: '8%',
bottom: '3%',
containLabel: true
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
xAxis: {
type: 'category',
name: '外协厂家',
axisLabel: {
interval: 0,
rotate: 0,
margin: 10
},
data: dataX
},
yAxis: {
type: 'value',
name: '天',
min: 0,
scale: 'true'
},
series: [
{
name: '加工时间(天)',
type: 'bar',
color: '#67C23A',
label: {
normal: {
show: true,
position: 'inside'
}
},
data: lineData1
}
]
})
}
}
}
</script>
<style scoped>
span{
margin: 0px;
}
.wrapper{
width: 225px;
height: 50px;
overflow: hidden;
border: 1px solid #b8c7d9;
float: left;
margin: 0px;
}
.content{
position: relative;
padding: 8px 8px 0 8px;
}
.action{
position: absolute;
top: 4px;
right: 8px;
}
.delete{
padding: 0 5px;
border-radius: 3px;
color: #0f84b0;
font-size: 12px;
}
.delete:hover{
background: -webkit-linear-gradient(top,#0ba9e3,#0099d3);
color: #fff;
}
a{
text-decoration: none;
}
.icon{
width: 30px;
height: 30px;
display: inline-block;
margin-right: 7px;
margin-top: 2px;
font-size: 26px;
}
.info{
position: absolute;
left: 44px;
line-height: 30px;
display: inline-block;
color: #999;
}
.el-card {
padding: 0px !important;
margin: 0px !important;
}
</style>