创建采购合同:写入数据库
This commit is contained in:
@@ -24,3 +24,15 @@ export function searchSheetContract(num1) {
|
||||
}
|
||||
})
|
||||
}
|
||||
// 生成采购合同
|
||||
export function doneContract(...params) {
|
||||
return request({
|
||||
url: '',
|
||||
method: 'post',
|
||||
data: {
|
||||
type: '2',
|
||||
name: '采购管理_采购合同_增加数据',
|
||||
param: `采购合同编号=${params[0]}&采购合同名称=${params[1]}&交货日期=${params[2]}&支付日期=${params[3]}&支付方式=${params[4]}&开票信息=${params[5]}&其他说明=${params[6]}&合同总额=${params[7]}&采购员=${params[8]}&供应商流水号=${params[9]}&单价是否含税=${params[10]}&组件零件流水号组=${params[11]}&组件零件基本件流水号组=${params[12]}&数量组=${params[13]}&单价组=${params[14]}&交货期组=${params[15]}`
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="1">
|
||||
<el-tooltip :content="haTtax" placement="top">
|
||||
<el-tooltip :content="hasTax" placement="top">
|
||||
<el-switch
|
||||
v-model="haTtax"
|
||||
v-model="hasTax"
|
||||
active-color="#13ce66"
|
||||
inactive-color="#ff4949"
|
||||
active-value="含税"
|
||||
@@ -41,6 +41,18 @@
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="交货日期:">
|
||||
<el-input v-model="deliveryDate" size="small" type="textarea" rows="1"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开票信息:">
|
||||
<el-input v-model="invoiceInfo" size="small" type="textarea" rows="1"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="支付日期:">
|
||||
@@ -54,12 +66,7 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="开票信息:">
|
||||
<el-input v-model="invoiceInfo" size="small" type="textarea" rows="1"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col :span="24">
|
||||
<el-form-item label="其他说明:">
|
||||
<el-input v-model="otherInfo" size="small" type="textarea" rows="1"/>
|
||||
</el-form-item>
|
||||
@@ -99,26 +106,26 @@
|
||||
{{ scope.row.数量 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-show="haTtax==='未税'" label="单价(未税)" align="center" min-width="100">
|
||||
<el-table-column v-show="hasTax==='未税'" label="单价(未税)" align="center" min-width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-show="haTtax==='未税'" v-model="scope.row.未税单价" size="mini" style="width:70px"/>
|
||||
<span v-show="haTtax!=='未税'">—</span>
|
||||
<el-input v-show="hasTax==='未税'" v-model="scope.row.未税单价" size="mini" style="width:70px"/>
|
||||
<span v-show="hasTax!=='未税'">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-show="haTtax==='含税'" label="单价(含税)" align="center" min-width="100">
|
||||
<el-table-column v-show="hasTax==='含税'" label="单价(含税)" align="center" min-width="100">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-show="haTtax==='含税'" v-model="scope.row.含税单价" size="mini" style="width:70px"/>
|
||||
<span v-show="haTtax!=='含税'">—</span>
|
||||
<el-input v-show="hasTax==='含税'" v-model="scope.row.含税单价" size="mini" style="width:70px"/>
|
||||
<span v-show="hasTax!=='含税'">—</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="总额(未税)" align="center" min-width="100" prop="未税总额">
|
||||
<template slot-scope="scope">
|
||||
{{ haTtax==='未税' ? scope.row.未税总额 = (Number(scope.row.数量) * Number(scope.row.未税单价)).toFixed(2) : scope.row.未税总额 = (scope.row.含税总额 / (1+taxRate)).toFixed(2) }}
|
||||
{{ hasTax==='未税' ? scope.row.未税总额 = (Number(scope.row.数量) * Number(scope.row.未税单价)).toFixed(2) : scope.row.未税总额 = (scope.row.含税总额 / (1+taxRate)).toFixed(2) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="总额(含税)" align="center" min-width="100" prop="含税总额">
|
||||
<template slot-scope="scope">
|
||||
{{ haTtax==='含税' ? scope.row.含税总额 = (Number(scope.row.数量) * Number(scope.row.含税单价)).toFixed(2) : scope.row.含税总额 = (scope.row.未税总额 * (1+taxRate)).toFixed(2) }}
|
||||
{{ hasTax==='含税' ? scope.row.含税总额 = (Number(scope.row.数量) * Number(scope.row.含税单价)).toFixed(2) : scope.row.含税总额 = (scope.row.未税总额 * (1+taxRate)).toFixed(2) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -130,11 +137,11 @@
|
||||
<el-radio-button label="自定义"/>
|
||||
</el-radio-group>
|
||||
<el-button type="primary" plain size="small" style="margin-left:10px;" @click="editContract()">调整合同</el-button>
|
||||
<el-button type="success" size="small" @click="generateContract()">生成合同</el-button>
|
||||
<div style="float: right">
|
||||
<span>合同总额:</span>
|
||||
<el-input v-model="actualTotal" size="small" style="width: 100px"/>
|
||||
<el-button type="primary" size="small" @click="submitTotal()">确定总额</el-button>
|
||||
<el-button type="success" size="small" @click="generateContract()">生成合同</el-button>
|
||||
</div>
|
||||
<hr>
|
||||
<!--html代码-->
|
||||
@@ -152,7 +159,7 @@
|
||||
<script>
|
||||
import Tinymce from '@/components/Tinymce'
|
||||
import QRCode from 'qrcode'
|
||||
import { searchInquirySheet, searchSheetContract } from '@/api/PurchasingCenter/CreatePurchaseContract'
|
||||
import { searchInquirySheet, searchSheetContract, doneContract } from '@/api/PurchasingCenter/CreatePurchaseContract'
|
||||
import { convertCurrency } from '@/vendor/int2Chinese'
|
||||
import { mapGetters } from 'vuex'
|
||||
|
||||
@@ -160,7 +167,7 @@ export default {
|
||||
components: { Tinymce },
|
||||
data() {
|
||||
return {
|
||||
haTtax: '未税',
|
||||
hasTax: '未税',
|
||||
taxRate: 0.16,
|
||||
preview: false, // 预览
|
||||
demoRadio: '自定义', // 模板radio
|
||||
@@ -171,7 +178,10 @@ export default {
|
||||
contractNums: [], // 合同编号数组
|
||||
contractNumValue: '', // 合同流水号
|
||||
supplierName: '', // 供应商名称
|
||||
supplierValue: '', // 供应商流水号
|
||||
supplierAddress: '', // 供应商地址
|
||||
supplierPhone: '', // 供应商电话
|
||||
supplierFax: '', // 供应商传真
|
||||
untaxTotal: '', // 未税合计
|
||||
tax: '', // 税额
|
||||
taxTotal: '', // 含税合计
|
||||
@@ -179,9 +189,16 @@ export default {
|
||||
actualTotal_zh: '', // 实际金额大写
|
||||
payDate: '', // 支付日期
|
||||
payMethod: '', // 支付方式
|
||||
deliveryDate: '', // 交货日期
|
||||
invoiceInfo: '', // 开票信息
|
||||
otherInfo: '', // 其他说明
|
||||
tableData1: []
|
||||
tableData1: [],
|
||||
单价是否含税: '',
|
||||
组件零件流水号组: [],
|
||||
组件零件基本件流水号组: [],
|
||||
数量组: [],
|
||||
单价组: [],
|
||||
交货期组: []
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
@@ -202,7 +219,11 @@ export default {
|
||||
this.contractNums.push({
|
||||
value: response.data[i].询价单流水号,
|
||||
label: response.data[i].询价单编号,
|
||||
supplierName: response.data[i].供应商名称
|
||||
supplierName: response.data[i].供应商名称,
|
||||
supplierValue: response.data[i].供应商流水号,
|
||||
supplierAddress: response.data[i].地址,
|
||||
supplierPhone: response.data[i].电话号码,
|
||||
supplierFax: response.data[i].传真
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -219,6 +240,10 @@ export default {
|
||||
for (let i = 0; i < this.contractNums.length; i++) {
|
||||
if (this.contractNums[i].value === this.contractNumValue) {
|
||||
this.supplierName = this.contractNums[i].supplierName
|
||||
this.supplierValue = this.contractNums[i].supplierValue
|
||||
this.supplierAddress = this.contractNums[i].supplierAddress
|
||||
this.supplierPhone = this.contractNums[i].supplierPhone
|
||||
this.supplierFax = this.contractNums[i].supplierFax
|
||||
this.contractNum = this.contractNums[i].label
|
||||
}
|
||||
}
|
||||
@@ -229,7 +254,9 @@ export default {
|
||||
searchSheetContract(this.contractNumValue).then(response => {
|
||||
console.log(response.data, 111)
|
||||
for (let i = 0; i < response.data.length; i++) {
|
||||
this.tableData1.push({ // 组件零件流水号
|
||||
this.tableData1.push({
|
||||
组件零件流水号: response.data[i].组件零件流水号,
|
||||
组件零件基本件流水号: response.data[i].组件零件基本件流水号,
|
||||
交货期: response.data[i].组件零件流水号 ? response.data[i].标准件和外购件交货期 : response.data[i].基本件交货期,
|
||||
图号: response.data[i].组件零件流水号 ? response.data[i].物料型号 : response.data[i].零件图号,
|
||||
名称: response.data[i].组件零件流水号 ? response.data[i].物料名称 : response.data[i].零件名称,
|
||||
@@ -290,34 +317,34 @@ export default {
|
||||
<table style="border-collapse: collapse; width: 100%;" border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 25%;">买方:</td>
|
||||
<td style="width: 25%;">江苏高精机电装配有限公司</td>
|
||||
<td style="width: 25%;">卖方:</td>
|
||||
<td id="supplierName" style="width: 25%;"> </td>
|
||||
<td style="width: 20%;">买方:</td>
|
||||
<td style="width: 30%;">江苏高精机电装配有限公司</td>
|
||||
<td style="width: 20%;">卖方:</td>
|
||||
<td id="supplierName" style="width: 30%;"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 25%;">地址:</td>
|
||||
<td style="width: 25%;">盐城市开放大道666号</td>
|
||||
<td style="width: 25%;">地址:</td>
|
||||
<td id="supplierAddress" style="width: 25%;"> </td>
|
||||
<td style="width: 20%;">地址:</td>
|
||||
<td style="width: 30%;">盐城市开放大道666号</td>
|
||||
<td style="width: 20%;">地址:</td>
|
||||
<td id="supplierAddress" style="width: 30%;"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 25%;">法定代表人:</td>
|
||||
<td style="width: 25%;">徐秀兵</td>
|
||||
<td style="width: 25%;">法定代表人:</td>
|
||||
<td style="width: 25%;"> </td>
|
||||
<td style="width: 20%;">法定代表人:</td>
|
||||
<td style="width: 30%;">徐秀兵</td>
|
||||
<td style="width: 20%;">法定代表人:</td>
|
||||
<td style="width: 30%;"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 25%;">电话:</td>
|
||||
<td style="width: 25%;"> </td>
|
||||
<td style="width: 25%;">电话:</td>
|
||||
<td style="width: 25%;"> </td>
|
||||
<td style="width: 20%;">电话:</td>
|
||||
<td style="width: 30%;"> </td>
|
||||
<td style="width: 20%;">电话:</td>
|
||||
<td id="supplierPhone" style="width: 30%;"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 25%;">传真:</td>
|
||||
<td style="width: 25%;"> </td>
|
||||
<td style="width: 25%;">传真:</td>
|
||||
<td style="width: 25%;"> </td>
|
||||
<td style="width: 20%;">传真:</td>
|
||||
<td style="width: 30%;"> </td>
|
||||
<td style="width: 20%;">传真:</td>
|
||||
<td id="supplierFax" style="width: 30%;"> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -326,14 +353,16 @@ export default {
|
||||
border="1">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width: 25%;">合同总额(人民币含税):</td>
|
||||
<td style="width: 25%;">合同总额(RMB):</td>
|
||||
<td class="actualTotal" style="width: 25%;"></td>
|
||||
<td style="width: 25%;">大写:</td>
|
||||
<td id="actualTotal_zh" style="width: 25%;"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 25%;">交货日期:</td>
|
||||
<td style="width: 25%;" colspan="3"> </td>
|
||||
<td style="width: 25%;" colspan="3">
|
||||
<p id="deliveryDate"> </p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 25%;" rowspan="3">交货地点:</td>
|
||||
@@ -398,6 +427,7 @@ export default {
|
||||
<hr />
|
||||
<p style="text-align: center;">
|
||||
<strong>明细表</strong>
|
||||
(<strong id="hasTax"></strong>)
|
||||
</p>
|
||||
<table style="border-collapse: collapse; width: 100%;" border="1">
|
||||
<tbody id="tbody">
|
||||
@@ -415,13 +445,14 @@ export default {
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<span>未税合计:</span><span id="untaxTotal"></span><br><br>
|
||||
<span>未税合计:</span><span id="untaxTotal"></span><span>元</span><br><br>
|
||||
<span>税额:</span><span id="tax"></span><br><br>
|
||||
<span>含税总价(税率17%):</span><span id="taxTotal"></span><br><br>
|
||||
<span>优惠后含税总价:</span><span class="actualTotal"></span><br><br>
|
||||
<span>含税总价(税率<span id="taxRate"></span>):</span><span id="taxTotal"></span><span>元</span><br><br>
|
||||
<span>优惠后含税总价:</span><span class="actualTotal"></span><span>元</span><br><br>
|
||||
`
|
||||
},
|
||||
editContract() { // 选择一个询价单,整成合同明细
|
||||
if (this.contractNumValue) {
|
||||
this.$refs.tinymce.destroyTinymce()
|
||||
const opts = {
|
||||
errorCorrectionLevel: 'H',
|
||||
@@ -438,15 +469,19 @@ export default {
|
||||
img.src = url
|
||||
}
|
||||
})
|
||||
this.supplierAddress = '无锡市新区新畅南路3号'
|
||||
document.getElementById('contractName') ? document.getElementById('contractName').innerHTML = this.contractName : ''
|
||||
document.getElementById('contractNum') ? document.getElementById('contractNum').innerHTML = this.contractNum : ''
|
||||
document.getElementById('supplierName') ? document.getElementById('supplierName').innerHTML = this.supplierName : ''
|
||||
document.getElementById('supplierAddress') ? document.getElementById('supplierAddress').innerHTML = this.supplierAddress : ''
|
||||
document.getElementById('supplierPhone') ? document.getElementById('supplierPhone').innerHTML = this.supplierPhone : ''
|
||||
document.getElementById('supplierFax') ? document.getElementById('supplierFax').innerHTML = this.supplierFax : ''
|
||||
document.getElementById('payDate') ? document.getElementById('payDate').innerHTML = this.payDate : ''
|
||||
document.getElementById('payMethod') ? document.getElementById('payMethod').innerHTML = this.payMethod : ''
|
||||
document.getElementById('invoiceInfo') ? document.getElementById('invoiceInfo').innerHTML = this.invoiceInfo : ''
|
||||
document.getElementById('deliveryDate') ? document.getElementById('deliveryDate').innerHTML = this.deliveryDate : ''
|
||||
document.getElementById('otherInfo') ? document.getElementById('otherInfo').innerHTML = this.otherInfo : ''
|
||||
document.getElementById('hasTax') ? document.getElementById('hasTax').innerHTML = this.hasTax : ''
|
||||
document.getElementById('taxRate') ? document.getElementById('taxRate').innerHTML = this.taxRate * 100 + '%' : ''
|
||||
// 明细表
|
||||
// 移出旧数据
|
||||
const children = document.getElementsByClassName('tableData')
|
||||
@@ -477,15 +512,15 @@ export default {
|
||||
document.getElementsByClassName('tableData')[j].children[2].innerHTML = this.tableData1[j].名称
|
||||
document.getElementsByClassName('tableData')[j].children[3].innerHTML = this.tableData1[j].规格
|
||||
document.getElementsByClassName('tableData')[j].children[4].innerHTML = this.tableData1[j].数量
|
||||
this.haTtax === '含税' ? document.getElementsByClassName('tableData')[j].children[5].innerHTML = this.tableData1[j].含税单价 : document.getElementsByClassName('tableData')[j].children[5].innerHTML = this.tableData1[j].未税单价
|
||||
this.hasTax === '含税' ? document.getElementsByClassName('tableData')[j].children[5].innerHTML = this.tableData1[j].含税单价 : document.getElementsByClassName('tableData')[j].children[5].innerHTML = this.tableData1[j].未税单价
|
||||
document.getElementsByClassName('tableData')[j].children[6].innerHTML = Number(document.getElementsByClassName('tableData')[j].children[5].innerHTML) * Number(this.tableData1[j].数量)
|
||||
this.tableData1[j].交货期 ? document.getElementsByClassName('tableData')[j].children[7].innerHTML = this.tableData1[j].交货期.split(' ')[0] : document.getElementsByClassName('tableData')[j].children[7].innerHTML = ''
|
||||
document.getElementsByClassName('tableData')[j].children[8].innerHTML = `备注` + j
|
||||
}
|
||||
}
|
||||
this.actualTotal = this.actualTotal.toFixed(2)
|
||||
this.actualTotal = this.untaxTotal.toFixed(2)
|
||||
this.actualTotal = this.taxTotal.toFixed(2)
|
||||
this.untaxTotal = this.untaxTotal.toFixed(2)
|
||||
this.taxTotal = this.taxTotal.toFixed(2)
|
||||
this.tax = (this.taxTotal - this.untaxTotal).toFixed(2)
|
||||
document.getElementById('untaxTotal') ? document.getElementById('untaxTotal').innerHTML = this.untaxTotal : ''
|
||||
document.getElementById('tax') ? document.getElementById('tax').innerHTML = this.tax : ''
|
||||
@@ -495,6 +530,9 @@ export default {
|
||||
document.getElementById('actualTotal_zh') ? document.getElementById('actualTotal_zh').innerHTML = this.actualTotal_zh : ''
|
||||
this.contentNew = document.getElementsByClassName('editor-content')[0].innerHTML
|
||||
this.$refs.tinymce.initTinymce()
|
||||
} else {
|
||||
this.$message.warning('请先选择合同进行调整')
|
||||
}
|
||||
},
|
||||
demo2() {
|
||||
this.content = `demo2`
|
||||
@@ -507,13 +545,29 @@ export default {
|
||||
},
|
||||
generateContract() { // 生成采购合同
|
||||
this.content = this.contentNew // 更新tinymce中的东西到html中,后续会用到
|
||||
this.组件零件流水号组 = []
|
||||
this.组件零件基本件流水号组 = []
|
||||
this.数量组 = []
|
||||
this.单价组 = []
|
||||
this.交货期组 = []
|
||||
this.hasTax === '含税' ? this.单价是否含税 = 1 : this.单价是否含税 = 0
|
||||
for (let i = 0; i < this.tableData1.length; i++) {
|
||||
this.组件零件流水号组.push(this.tableData1[i].组件零件流水号)
|
||||
this.组件零件基本件流水号组.push(this.tableData1[i].组件零件基本件流水号)
|
||||
this.数量组.push(this.tableData1[i].数量)
|
||||
this.hasTax === '含税' ? this.单价组.push(this.tableData1[i].含税单价) : this.单价组.push(this.tableData1[i].未税单价)
|
||||
this.交货期组.push(this.tableData1[i].交货期)
|
||||
}
|
||||
if (this.contractNumValue) {
|
||||
this.$confirm('此操作将生成采购合同,确认完成编辑?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
|
||||
console.log(this.contractNum, this.contractName, this.deliveryDate, this.payDate, this.payMethod, this.invoiceInfo, this.otherInfo, this.actualTotal, this.id, this.supplierValue, this.单价是否含税, this.组件零件流水号组, this.组件零件基本件流水号组, this.数量组, this.单价组, this.交货期组)
|
||||
doneContract(this.contractNum, this.contractName, this.deliveryDate, this.payDate, this.payMethod, this.invoiceInfo, this.otherInfo, this.actualTotal, this.id, this.supplierValue, this.单价是否含税, this.组件零件流水号组, this.组件零件基本件流水号组, this.数量组, this.单价组, this.交货期组).then(response => {
|
||||
console.log(response.data)
|
||||
})
|
||||
}).catch(() => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
|
||||
Reference in New Issue
Block a user