Files
JY1.0/src/views/PurchasingCenter/ReceiveCheck/index.vue
bryan sun 105cce9a94 界面
2019-11-09 17:54:00 +08:00

251 lines
8.3 KiB
Vue

<template>
<div class="app-container receiveCheck">
<el-card>
<div slot="header">
<el-select v-model="machine" filterable clearable size="small" style="margin:0px 10px 0px 10px;width: 180px;" placeholder="机床号" @change="machineChange">
<el-option
v-for="item in machines"
:key="item.value"
:label="item.label"
:value="item.value">
<div style="float: left">{{ item.label }}</div>
<div style="float: right; color: #8492a6; font-size: 13px">{{ item.value2 }}</div>
</el-option>
</el-select>
<!-- <span>项目名称:</span>-->
<!-- <el-select v-model="projectValue" style="width:200px" placeholder="请选择" size="small" clearable filterable @change="projectChange">-->
<!-- <el-option-->
<!-- v-for="item in project"-->
<!-- :key="item.value"-->
<!-- :label="item.label"-->
<!-- :value="item.value"/>-->
<!-- </el-select>-->
<!-- <span>机床图号:</span>-->
<!-- <el-select v-model="machineValue" style="width:190px" placeholder="请选择" size="small" clearable filterable @change="machineChange">-->
<!-- <el-option-->
<!-- v-for="item in machine"-->
<!-- :key="item.value"-->
<!-- :label="item.label"-->
<!-- :value="item.value"/>-->
<!-- </el-select>-->
<span>组号:</span>
<el-select v-model="groupValue" style="width:140px" placeholder="请选择" size="small" clearable filterable>
<el-option
v-for="item in group"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<el-button type="success" icon="el-icon-search" size="small" style="margin-left: 10px" @click="searchProject()">查询</el-button>
</div>
<el-table
:data="tableData1"
:summary-method="getSummaries"
style="width: 100%"
height="650"
size="mini"
show-summary
stripe
border>
<el-table-column align="center" label="序号" type="index"/>
<el-table-column align="center" label="项目名称">
<template slot-scope="scope">
{{ scope.row.项目名称 }}
</template>
</el-table-column>
<el-table-column align="center" label="机床图号" width="100px">
<template slot-scope="scope">
{{ scope.row.机床图号 }}
</template>
</el-table-column>
<el-table-column align="center" label="组号" width="80px">
<template slot-scope="scope">
{{ scope.row.组号 || '—' }}
</template>
</el-table-column>
<el-table-column align="center" label="物料名称" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料名称 }}
</template>
</el-table-column>
<el-table-column align="center" label="物料规格">
<template slot-scope="scope">
{{ scope.row.物料规格 }}
</template>
</el-table-column>
<el-table-column align="center" label="物料型号" min-width="150" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.物料型号 }}
</template>
</el-table-column>
<el-table-column align="center" label="小计(元)" prop="小计">
<template slot-scope="scope">
{{ scope.row.小计 ? scope.row.小计.toFixed(2) : 0 }}
</template>
</el-table-column>
<el-table-column align="center" label="单价">
<template slot-scope="scope">
{{ scope.row.单价 }}
</template>
</el-table-column>
<el-table-column align="center" label="领用数量">
<template slot-scope="scope">
{{ scope.row.出库数量 }}
</template>
</el-table-column>
<el-table-column align="center" label="领用时间" show-overflow-tooltip>
<template slot-scope="scope">
{{ scope.row.出库时间.substr(0,10) }}
</template>
</el-table-column>
</el-table>
</el-card>
</div>
</template>
<script>
import { initProject, searchGroup, searchReceiveCheck, getMachines } from '@/api/PurchasingCenter/ReceiveCheck'
import Cookie from 'js-cookie'
export default {
data() {
return {
projectValue: '', // 项目名称
project: [],
machine: '',
machines: [],
groupValue: '',
group: [],
tableData1: [],
check1: '',
pageCurrent: 1,
pageSize: 10,
total: 0
}
},
created() {
this.fetchData()
this.getMachine()
},
methods: {
getMachine() {
if (Cookie.get('machineValue') !== undefined) {
this.machine = ''
this.machines = []
getMachines().then(response => {
console.log(response, 343434)
for (let i = 0; i < response.data.length; i++) {
this.machines.push({
label: response.data[i].机床图号,
value: response.data[i].机床流水号,
value2: response.data[i].项目名称
})
}
if (Cookie.get('group') !== undefined) {
this.machine = parseInt(Cookie.get('machineValue'))
this.Group = parseInt(Cookie.get('group'))
// this.getTableData()
Cookie.remove('machineValue')
Cookie.remove('group')
} else {
// this.getTableData()
Cookie.remove('machineValue')
Cookie.remove('group')
}
})
} else {
this.Machine = ''
this.Machines = []
getMachines().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.machines.push({
label: response.data[i].机床图号,
value: response.data[i].机床流水号,
value2: response.data[i].项目名称
})
}
})
}
},
fetchData() {
this.getSelect(initProject, ['项目名称', '项目流水号'], 'project')
},
// projectChange() {
// this.machines = []
// this.machine = ''
// this.group = []
// this.groupValue = ''
// searchMachine(this.projectValue).then(response => {
// for (let i = 0; i < response.data.length; i++) {
// this.machines.push({
// value: response.data[i].机床流水号,
// label: response.data[i].机床图号
// })
// }
// })
// },
machineChange() {
this.group = []
this.groupValue = ''
searchGroup(this.machine).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.group.push({
value: response.data[i].组件流水号,
label: response.data[i].组号
})
}
})
},
getSummaries(param) {
const { columns, data } = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '总价'
return
}
const values = data.map(item => Number(item[column.property]))
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return prev + curr
} else {
return prev
}
}, 0)
sums[index] = sums[index].toFixed(2)
sums[index] += ' 元'
} else {
sums[index] = ''
}
})
return sums
},
searchProject() { // 查询
// if (!this.projectValue) {
// this.$message.error('请选择项目')
// } else {
let check2, check3
this.machine ? check2 = 1 : check2 = 0
this.groupValue ? check3 = 1 : check3 = 0
searchReceiveCheck(0, this.projectValue, check2, this.machine, check3, this.groupValue).then(response => {
this.tableData1 = response.data
})
}
}
// }
}
</script>
<style scoped>
.el-select{
width:200px
}
.el-input{
width:200px
}
span{
margin: 10px 0 10px 10px;
}
</style>