Files
JY1.0/src/views/WorkshopProcurement/CreatingProcurementContracts/index.vue
2019-11-18 19:51:48 +08:00

692 lines
26 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="app-container">
<el-card class="searchContract">
<el-row>
<el-select v-model="contractNumValue" placeholder="请购单号/合同编号" size="small" @change="searchData">
<el-option
v-for="item in contractNum"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<el-input v-model="contractName" placeholder="合同名称" size="small"/>
<el-input v-model="supplierName" size="small" placeholder="请双击选择供应商" readonly clearable @dblclick.native="dialogVisible1=true;submitDisable=true" @clear="emptySupplierDetail"/>
<el-input v-model="AdvanceCharge" size="small" placeholder="预付款"/>
<el-select v-model="currencyValue" placeholder="币种" size="small" clearable>
<el-option
v-for="item in currency"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<el-date-picker
v-model="stipulateArrivalTime"
size="small"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
placeholder="规定到货时间"/>
<el-input v-model="name" placeholder="采购员" size="small" readonly/>
<el-input v-model="taxRate" placeholder="税率" size="small"/>
<el-button v-show="contractNumType===0" type="success" size="small" @click="linkGroup">成组采购</el-button>
<el-button v-show="contractNumType===1" type="danger" size="small" @click="unLinkGroup">取消成组采购</el-button>
</el-row>
</el-card>
<el-card>
<el-table v-show="contractNumType===1" :data="tableData5" border style="width: 100%" height="100px" size="mini">
<el-table-column label="组件名称" align="center" width="150">
<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="120">
<template slot-scope="scope">
<el-input v-model="scope.row.数量" size="mini" style="width:100%" @change="update1(scope.row)"/>
</template>
</el-table-column>
<el-table-column label="单价" align="center" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.单价" size="mini" style="width:100%" @change="update1(scope.row)"/>
</template>
</el-table-column>
<el-table-column label="金额" align="center" width="150">
<template slot-scope="scope">
{{ parseInt(scope.row.数量) * parseFloat(scope.row.单价) }}
</template>
</el-table-column>
<el-table-column label="交货期" align="center" width="150">
<template slot-scope="scope">
<el-date-picker
v-model="scope.row.物料计划到货时间"
size="small"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
style="width:100%"
@change="update1(scope.row)"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" width="250">
<template slot-scope="scope">
<el-input v-model="scope.row.备注" size="mini" style="width:100%" @change="update1(scope.row)"/>
</template>
</el-table-column>
</el-table>
</el-card>
<el-card>
<el-table v-show="contractNumType===0" :data="tableData4" border style="width: 100%;max-height: 400px;" height="300px" size="mini">
<el-table-column label="物料名称" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.物料名称 }}
</template>
</el-table-column>
<el-table-column label="图号或型号" align="center" min-width="100">
<template slot-scope="scope">
{{ scope.row.图号或型号 }}
</template>
</el-table-column>
<el-table-column label="材料或规格" align="center" width="200">
<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="150">
<template slot-scope="scope">
<el-input v-model="scope.row.单价" size="mini" style="width:70px"/>
</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="150">
<template slot-scope="scope">
<el-date-picker
v-model="scope.row.物料计划到货时间"
size="small"
type="date"
format="yyyy-MM-dd"
value-format="yyyy-MM-dd"
style="width: 133px"
@change="update(scope.row)"/>
</template>
</el-table-column>
<el-table-column label="备注" align="center" width="150">
<template slot-scope="scope">
<el-input v-model="scope.row.备注" size="mini" style="width: 120px" @change="update(scope.row)"/>
</template>
</el-table-column>
</el-table>
<el-button
type="shengcheng"
size="small"
style="margin-top:10px"
@click="calculateContractSum">计算合同总额</el-button>
<span>合同总额(未税):</span>
<el-input v-model="contractSum" size="small"/>
<span>合同总额(含税):</span>
<el-input v-model="contractSum2" size="small"/>
</el-card>
<el-card>
<el-input :rows="20" v-model="textArea" type="textarea" style="width:calc(99% - 250px);float:right;margin-bottom: 20px" resize="none"/>
<el-select v-model="contractValue" size="small" style="width: 110px;margin-left: 7.5%;margin-top: 10px" @change="changeContract">
<el-option
v-for="item in contract"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
<el-button
type="shengcheng"
size="small"
style="margin-left: 7.5%; margin-top: 10px"
@click="doneContract">生成采购合同</el-button>
</el-card>
<el-dialog v-el-drag-dialog :visible.sync="dialogVisible1" title="供应商选择" center style="min-height: 300px">
<el-form ref="form1" :model="form1" label-position="left" label-width="90px" class="searchForm">
<el-row>
<el-col :span="12">
<el-form-item label="供应商名称">
<el-input v-model="supplierName" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="企业性质">
<el-input v-model="enterpriseNature" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="货期">
<el-input v-model="goodTime" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="注册资本">
<el-input v-model="registeredCapital" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="税号">
<el-input v-model="taxNum" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电子邮箱">
<el-input v-model="EMail" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="地址">
<el-input v-model="address" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="账号">
<el-input v-model="account" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="开户行">
<el-input v-model="openingBank" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="电话号码">
<el-input v-model="phone" size="small"/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="传真">
<el-input v-model="fax" size="small"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-button
type="success"
size="small"
icon="el-icon-search"
@click="searchSupplier">查询</el-button>
<el-button
:disabled="submitDisable"
type="primary"
size="small"
icon="el-icon-check"
@click="submitSelectSupplier">确定</el-button>
<el-button
type="danger"
size="small"
icon="el-icon-delete"
@click="emptySupplierDetail">清空</el-button>
</el-col>
</el-row>
<el-table :data="tableData01" size="mini" style="width: 97%;max-height: 300px;margin-top:15px" height="200px" border @row-click="showSupplierDetail">
<el-table-column align="center" label="供应商名称" width="200">
<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="创立日期">
<template slot-scope="scope">
{{ scope.row.创立日期&&scope.row.创立日期!=='1900-01-01' ? scope.row.创立日期 : '-' }}
</template>
</el-table-column>
<el-table-column align="center" label="注册资本">
<template slot-scope="scope">
{{ scope.row.注册资本 }}
</template>
</el-table-column>
</el-table>
</el-form>
</el-dialog>
<el-dialog v-el-drag-dialog :visible.sync="dialogVisible2" title="成组采购" center style="min-height: 200px" width="430px">
<el-form ref="form3" :model="form3" :rules="rules1" label-position="right" label-width="120px">
<el-row>
<el-form-item label="机床" prop="机床">
<el-input v-model="form3.机床" size="small"/>
</el-form-item>
</el-row>
<el-row>
<el-form-item label="组号" prop="groupNumValue">
<el-select v-model="form3.groupNumValue" placeholder="组号" size="small" filterable>
<el-option
v-for="item in groupNum"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
</el-form-item>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button
type="primary"
size="small"
icon="el-icon-check"
@click="submitGroup">转为成组采购</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { searchSupplier, update, doneContract, initPurchaseOrder, searchData2, searchContractDemo, initGroupNum, submitGroup, update1, unLinkGroup, searchData1, doneContract1 } from '@/api/WorkshopProcurement/CreatingProcurementContracts'
import { mapGetters } from 'vuex'
export default {
inject: ['reload'],
data() {
return {
submitDisable: true, // 不点击表格中的行不让确定
AdvanceCharge: '',
loading: false,
groupNum: [],
groupNumValue: '',
dialogVisible1: false,
dialogVisible2: false,
disable2: true,
disable3: true,
disable4: true,
disable5: true,
disable6: true,
tableData01: [],
tableData2: [], // 合同模板表
form1: {},
form2: {},
form3: {
groupNumValue: '',
机床: ''
},
machineValue: '',
rules1: {
groupNumValue: [{ required: true, message: '请选择组号' }]
},
textArea: '',
paramRow: '', // 参数row
contractSum: 0,
contractSum1: 0,
contractSum2: 0,
deliveryDay: [],
deliveryDay1: [],
contractNumValue: '',
contractNumType: 0,
RequisitionNumber: '',
contract: [{
label: '合同模板1',
value: 1
}, {
label: '合同模板2',
value: 2
}, {
label: '采购计划',
value: 3
}, {
label: '成组采购',
value: 4
}],
contractValue: 1,
contractNum: [], // 合同号
contractName: '产品采购合同', // 合同名称
supplierName: '', // 供应商
supplier: [],
supplierValue: '', // 供应商流水号
enterpriseNature: '', // 企业性质
createDate: '', // 创立日期
registeredCapital: '', // 注册资本
taxNum: '', // 税号
EMail: '', // 电子邮箱
address: '', // 地址
account: '', // 账户
openingBank: '', // 开户行
phone: '', // 电话号码
fax: '', // 传真
goodTime: '', // 货期
supplierCheck1: 0,
supplierCheck2: 0,
supplierCheck3: 0,
supplierCheck4: 0,
supplierCheck5: 0,
supplierCheck6: 0,
supplierCheck7: 0,
supplierCheck8: 0,
supplierCheck9: 0,
supplierCheck10: 0,
supplierCheck11: 0,
supplierCheck12: 0,
payMethod: [], // 付款方式
payMethodValue: 1,
payMethodName: '货到付款',
currency: [{
label: '人民币',
value: 1
}, {
label: '美元',
value: 2
}, {
label: '英镑',
value: 3
}, {
label: '欧元',
value: 4
}], // 币种
currencyValue: 1,
payTime1: [],
payTime1Value: 1,
payTime2: [],
payTime2Value: 1,
payTime3: [],
payTime3Value: 1,
payTime4: [],
payTime4Value: 1,
payTime5: [],
payTime5Value: 1,
payTime6: [],
payTime6Value: 1,
planArrivalTime: '', // 计划到货时间
stipulateArrivalTime: '', // 规定到货时间
freight: '', // 运费
taxRate: '0.13', // 税率
tableData4: [],
tableData5: [],
groupNum2: [],
groupNum5: [],
group1: '',
group2: '',
group3: '',
group5: '',
group6: '',
group7: '',
group8: '',
group9: '',
group10: '',
group11: '',
group12: ''
}
},
computed: {
...mapGetters([
'sidebar',
'avatar',
'name',
'id'
])
},
created() {
this.fetchData()
},
methods: {
linkGroup() {
console.log(this.form3, 111)
this.dialogVisible2 = true
},
submitGroup() {
submitGroup(this.contractNumValue, this.form3.groupNumValue).then(response => {
if (response.data[0].result === '1') {
this.contractNumType = 1
this.dialogVisible2 = false
this.searchData()
this.$message.success('转换成功')
} else {
this.$message.success('转换失败')
}
})
},
update1(row) {
update1(row.组件流水号, row.数量, row.单价, row.物料计划到货时间, row.备注).then(response => {
})
},
unLinkGroup() {
unLinkGroup(this.contractNumValue).then(response => {
if (response.data[0].result === '1') {
this.contractNumType = 0
this.$message.success('转换成功')
} else {
this.$message.success('转换失败')
}
})
},
searchData() {
for (let i = 0; i < this.contractNum.length; i++) {
if (this.contractNum[i].value === this.contractNumValue) {
this.contractNumType = this.contractNum[i].id
}
}
console.log(this.contractNumType, 1111)
searchData1(this.contractNumValue).then(response => {
console.log(response.datas)
this.tableData5 = response.data
}).then(() => {
this.groupNum5 = this.tableData5 // 给中间变量需要时重新push
console.log(this.tableData5)
})
searchData2(this.contractNumValue).then(response => {
this.tableData4 = response.data
this.machineValue = response.data[0].机床流水号
this.form3.机床 = response.data[0].机床图号
this.form3.groupNumValue = response.data[0].组件流水号
console.log(this.machineValue, 111)
initGroupNum(this.machineValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.groupNum.push({
label: response.data[i].组号,
value: response.data[i].组件流水号
})
}
})
for (let i = 0; i < response.data.length; i++) {
this.tableData4[i].金额 = parseFloat(this.tableData4[i].单价) * parseFloat(this.tableData4[i].零件数量)
}
}).then(() => {
this.groupNum2 = this.tableData4 // 给中间变量需要时重新push
console.log(this.tableData4)
})
},
update(row) {
update(row.请购单明细流水号, row.物料计划到货时间, row.备注).then(response => {
})
},
calculateContractSum() { // 计算合同总额
this.contractSum = 0
this.contractSum1 = 0
this.costAccount = 0
this.riseFallPoint = 0
this.tableData4 = []
for (let i = 0; i < this.groupNum2.length; i++) {
this.groupNum2[i].金额 = parseFloat(this.groupNum2[i].单价) * parseFloat(this.groupNum2[i].零件数量)
this.contractSum1 += parseFloat(this.groupNum2[i].金额)
this.tableData4.push(this.groupNum2[i])
}
this.contractSum = (this.contractSum1).toFixed(2)
this.contractSum2 = parseInt(this.contractSum * (1 + parseFloat(this.taxRate)) * 100) / 100
this.costAccount = this.contractSum
if (parseInt(this.costAccount) === 0) {
this.$message.error('成本核算不可为0')
} else {
this.riseFallPoint = (this.contractSum - this.costAccount) / this.costAccount
this.riseFallPoint = this.riseFallPoint.toFixed(2)
}
},
fetchData() {
searchContractDemo(1).then(response => {
this.textArea = response.data[0].合同模板内容
})
initPurchaseOrder().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.contractNum.push({
label: response.data[i].请购单编号,
value: response.data[i].请购单流水号,
id: response.data[i].请购类型
})
}
})
},
changeContract() {
searchContractDemo(this.contractValue).then(response => {
this.textArea = response.data[0].合同模板内容
})
},
searchSupplier() { // 查询创立日期和注册资本大于符合条件的数据
this.supplierName ? this.supplierCheck1 = 1 : (this.supplierCheck1 = 0, this.supplierName = '')
this.enterpriseNature ? this.supplierCheck2 = 1 : (this.supplierCheck2 = 0, this.enterpriseNature = '')
this.createDate ? this.supplierCheck3 = 1 : (this.supplierCheck3 = 0, this.createDate = '')
this.registeredCapital ? this.supplierCheck4 = 1 : (this.supplierCheck4 = 0, this.registeredCapital = '')
this.taxNum ? this.supplierCheck5 = 1 : (this.supplierCheck5 = 0, this.taxNum = '')
this.EMail ? this.supplierCheck6 = 1 : (this.supplierCheck6 = 0, this.EMail = '')
this.address ? this.supplierCheck7 = 1 : (this.supplierCheck7 = 0, this.address = '')
this.account ? this.supplierCheck8 = 1 : (this.supplierCheck8 = 0, this.account = '')
this.openingBank ? this.supplierCheck9 = 1 : (this.supplierCheck9 = 0, this.openingBank = '')
this.phone ? this.supplierCheck10 = 1 : (this.supplierCheck10 = 0, this.phone = '')
this.fax ? this.supplierCheck11 = 1 : (this.supplierCheck11 = 0, this.fax = '')
this.goodTime ? this.supplierCheck12 = 1 : (this.supplierCheck12 = 0, this.goodTime = '')
searchSupplier(this.supplierCheck1, this.supplierName, this.supplierCheck2, this.enterpriseNature, this.supplierCheck3, this.createDate, this.supplierCheck4, this.registeredCapital, this.supplierCheck5, this.taxNum, this.supplierCheck6, this.EMail, this.supplierCheck7, this.address, this.supplierCheck8, this.account, this.supplierCheck9, this.openingBank, this.supplierCheck10, this.phone, this.supplierCheck11, this.fax, this.supplierCheck12, this.goodTime).then(response => {
for (let i = 0; i < response.data.length; i++) {
if (response.data[i].创立日期 !== '' && response.data[i].创立日期 !== null) {
response.data[i].创立日期 = response.data[i].创立日期.split(' ')[0]
}
}
this.tableData01 = response.data
})
},
submitSelectSupplier() { // 确定选择供应商
this.dialogVisible1 = false
},
emptySupplierDetail() { // 清空
this.submitDisable = true
this.supplierValue = ''
this.supplierName = ''
this.enterpriseNature = ''
this.createDate = ''
this.registeredCapital = ''
this.taxNum = ''
this.EMail = ''
this.address = ''
this.account = ''
this.openingBank = ''
this.phone = ''
this.fax = ''
this.goodTime = ''
},
showSupplierDetail(row) {
this.submitDisable = false
this.form2.supplierValue = row.供应商流水号
this.form2.supplierName = row.供应商名称
this.supplierValue = row.供应商流水号
this.supplierName = row.供应商名称
this.enterpriseNature = row.企业性质
this.createDate = row.创立日期
this.registeredCapital = row.注册资本
this.taxNum = row.税号
this.EMail = row.电子信箱
this.address = row.地址
this.account = row.帐号
this.openingBank = row.开户行
this.phone = row.电话号码
this.fax = row.传真
this.goodTime = row.货期
},
doneContract() { // 生成采购合同
if (this.contractNumValue === '') {
this.$message.error('请选择生成合同的请购单')
} else if (this.stipulateArrivalTime === '' || this.stipulateArrivalTime === null) {
this.$message.error('请选择规定到货时间!')
} else {
if (this.contractNumType === 0) {
this.group1 = ''
this.group2 = ''
this.group3 = ''
this.group7 = ''
this.group8 = ''
this.group9 = ''
this.group10 = ''
this.group11 = ''
this.group12 = ''
for (let i = 0; i < this.tableData4.length; i++) {
this.group1 += this.tableData4[i].物料流水号 + ','
this.group2 += this.tableData4[i].零件数量 + ','
this.group3 += this.tableData4[i].单价 + ','
this.group7 += this.taxRate + ','
this.group8 += this.currencyValue + ','
this.group9 += this.tableData4[i].请购单明细流水号 + ','
this.group11 += this.tableData4[i].单件定额工时 + ','
this.group12 += this.tableData4[i].准结定额工时 + ','
}
for (let i = 0; i < this.contractNum.length; i++) {
if (this.contractNum[i].value === this.contractNumValue) {
this.RequisitionNumber = this.contractNum[i].label
}
}
this.group1 = this.group1.substr(0, this.group1.length - 1)
this.group2 = this.group2.substr(0, this.group2.length - 1)
this.group3 = this.group3.substr(0, this.group3.length - 1)
doneContract(this.contractNumValue, this.RequisitionNumber, this.contractName, this.planArrivalTime, this.stipulateArrivalTime, this.supplierValue, this.textArea, this.contractValue, this.freight, this.group1, this.group2, this.group3, this.group7, this.group8, this.group9, this.id, this.group11, this.group12, this.AdvanceCharge).then(response => {
if (response.data[0].result === '1') {
this.$message.success('生成合同成功')
this.reload()
} else { this.$message.error('生成合同失败') }
})
} else {
for (let i = 0; i < this.contractNum.length; i++) {
if (this.contractNum[i].value === this.contractNumValue) {
this.RequisitionNumber = this.contractNum[i].label
}
}
doneContract1(this.contractNumValue, this.RequisitionNumber, this.contractName, this.stipulateArrivalTime, this.form3.groupNumValue, this.id, this.supplierValue, this.textArea, this.contractValue, this.freight, this.AdvanceCharge, this.tableData5[0].数量, this.tableData5[0].单价, this.taxRate, this.currencyValue, this.tableData5[0].备注).then(response => {
if (response.data[0].result === '1') {
this.$message.success('生成合同成功')
this.reload()
} else { this.$message.error('生成合同失败') }
})
}
}
},
exportExcel() {}
}
}
</script>
<style scoped>
.el-date-editor{
width:200px
}
.el-select{
width:150px;
margin-right: 10px;
}
.el-input{
width:150px;
margin-right: 10px;
}
span{
margin: 10px 0 10px 10px;
}
.searchForm .el-form-item{
margin-bottom: 5px;
}
</style>