离线税率

This commit is contained in:
chenjianan
2019-06-05 09:41:08 +08:00
parent 054352fb3c
commit c9a53c6049
2 changed files with 72 additions and 14 deletions

View File

@@ -135,26 +135,26 @@ export function deleteMateriel(num) {
}) })
} }
// 保存离线合同 // 保存离线合同
export function saveOfflineContact(contractNum, total, partGroup, numGroup, priceGroup, dateGroup, remarkGroup) { export function saveOfflineContact(contractNum, total, partGroup, numGroup, priceGroup, dateGroup, remarkGroup, taxRate) {
return request({ return request({
url: '', url: '',
method: 'post', method: 'post',
data: { data: {
type: '2', type: '2',
name: '采购管理_离线合同_保存合同', name: '采购管理_离线合同_保存合同',
param: `离线合同流水号=${contractNum}&合同总额=${total}&离线合同明细流水号组=${partGroup}&数量组=${numGroup}&单价组=${priceGroup}&交货期要求组=${dateGroup}&备注组=${remarkGroup}` param: `离线合同流水号=${contractNum}&合同总额=${total}&离线合同明细流水号组=${partGroup}&数量组=${numGroup}&单价组=${priceGroup}&交货期要求组=${dateGroup}&备注组=${remarkGroup}&税率=${taxRate}`
} }
}) })
} }
// 生成离线合同 // 生成离线合同
export function doneOfflineContact(contractNum, total, partGroup, numGroup, priceGroup, dateGroup, remarkGroup) { export function doneOfflineContact(contractNum, total, partGroup, numGroup, priceGroup, dateGroup, remarkGroup, taxRate) {
return request({ return request({
url: '', url: '',
method: 'post', method: 'post',
data: { data: {
type: '2', type: '2',
name: '采购管理_离线合同_生成合同', name: '采购管理_离线合同_生成合同',
param: `离线合同流水号=${contractNum}&合同总额=${total}&离线合同明细流水号组=${partGroup}&数量组=${numGroup}&单价组=${priceGroup}&交货期要求组=${dateGroup}&备注组=${remarkGroup}` param: `离线合同流水号=${contractNum}&合同总额=${total}&离线合同明细流水号组=${partGroup}&数量组=${numGroup}&单价组=${priceGroup}&交货期要求组=${dateGroup}&备注组=${remarkGroup}&税率=${taxRate}`
} }
}) })
} }

View File

@@ -344,6 +344,17 @@
@current-change="handleCurrentChange2"/> @current-change="handleCurrentChange2"/>
<el-button :disabled="disable" type="success" size="mini" style="float:right;margin-left:10px" @click="doneOfflineContact">生成</el-button> <el-button :disabled="disable" type="success" size="mini" style="float:right;margin-left:10px" @click="doneOfflineContact">生成</el-button>
<el-button :disabled="disable" type="info" size="mini" style="float:right" @click="saveContract">保存</el-button> <el-button :disabled="disable" type="info" size="mini" style="float:right" @click="saveContract">保存</el-button>
<el-tooltip :content="hasTax" placement="top">
<el-switch
v-model="hasTax"
active-color="#13ce66"
inactive-color="#ff4949"
active-value="含税"
inactive-value="未税"
style="margin: 3px;float:right"/>
</el-tooltip>
<el-input v-model="taxRate" style="float:right;width:100px" placeholder="税率" size="mini"/>
<h4 style="float:right;width: 40px;margin: 5px">税率:</h4>
</div> </div>
<el-table v-loading="" :data="tableData3" :summary-method="getSummaries" border style="max-height: 500px;" height="500px" size="mini" show-summary> <el-table v-loading="" :data="tableData3" :summary-method="getSummaries" border style="max-height: 500px;" height="500px" size="mini" show-summary>
<el-table-column label="离线合同编号" align="center" min-width="150"> <el-table-column label="离线合同编号" align="center" min-width="150">
@@ -381,14 +392,26 @@
{{ scope.row.参考价格 }} {{ scope.row.参考价格 }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="单价" align="center" min-width="100" prop="单价"> <el-table-column label="单价(未税)" align="center" min-width="100" prop="单价">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-model="scope.row.单价" :disabled="disable" size="mini" style="width:70px"/> <el-input v-show="hasTax==='未税'" v-model="scope.row.未税单价" :disabled="disable" size="mini" style="width:70px"/>
<b v-show="hasTax!=='未税'">{{ (scope.row.单价 / (1 + taxRate)).toFixed(2) }}</b>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="合计" align="center" min-width="100" prop="合计"> <el-table-column label="单价(含税)" align="center" min-width="100" prop="单价">
<template slot-scope="scope"> <template slot-scope="scope">
{{ (Number(scope.row.单价||0) * Number(scope.row.数量||0)).toFixed(2) }} <el-input v-show="hasTax==='含税'" v-model="scope.row.单价" :disabled="disable" size="mini" style="width:70px"/>
<b v-show="hasTax!=='含税'">{{ (scope.row.未税单价 * (1 + taxRate)).toFixed(2) }}</b>
</template>
</el-table-column>
<el-table-column label="总额(未税)" align="center" min-width="100" prop="合计">
<template slot-scope="scope">
{{ 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">
{{ hasTax==='含税' ? scope.row.含税总额 = (Number(scope.row.数量) * Number(scope.row.单价)).toFixed(2) : scope.row.含税总额 = (scope.row.未税总额 * (1+taxRate)).toFixed(2) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="交货期要求" align="center" min-width="100" prop="交货期要求"> <el-table-column label="交货期要求" align="center" min-width="100" prop="交货期要求">
@@ -669,6 +692,8 @@ export default {
name: '', // 离线合同 name: '', // 离线合同
data() { data() {
return { return {
hasTax: '含税',
taxRate: 0.13,
source: [ source: [
{ {
text: 'BZ', text: 'BZ',
@@ -1052,7 +1077,10 @@ export default {
searchMateriel(this.offlineContractNum).then(response => { searchMateriel(this.offlineContractNum).then(response => {
this.tableData3 = response.data this.tableData3 = response.data
this.tableData3.map(v => { this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价 !v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
}) })
}) })
} else { this.$message.error('数据占用,删除失败') } } else { this.$message.error('数据占用,删除失败') }
@@ -1124,7 +1152,10 @@ export default {
console.log(response.data) console.log(response.data)
this.tableData3 = response.data this.tableData3 = response.data
this.tableData3.map(v => { this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价 !v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
}) })
}) })
Number(row.离线合同状态) !== 1 ? this.disable = true : this.disable = false // 是否为编辑模式 Number(row.离线合同状态) !== 1 ? this.disable = true : this.disable = false // 是否为编辑模式
@@ -1135,8 +1166,23 @@ export default {
columns.forEach((column, index) => { columns.forEach((column, index) => {
if (index === 0) { if (index === 0) {
sums[index] = '总价' sums[index] = '总价'
} else if (index === 7) { } else if (index === 9) {
const values = data.map(item => Number(Number(item['单价']) * Number(item['数量']))) const values = data.map(item => Number(item['未税总额']))
if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr)
if (!isNaN(value)) {
return Number((prev + curr).toFixed(2))
} else {
return Number((prev).toFixed(2))
}
}, 0)
sums[index] += ' 元'
} else {
sums[index] = 'N/A'
}
} else if (index === 10) {
const values = data.map(item => Number(item['含税总额']))
if (!values.every(value => isNaN(value))) { if (!values.every(value => isNaN(value))) {
sums[index] = values.reduce((prev, curr) => { sums[index] = values.reduce((prev, curr) => {
const value = Number(curr) const value = Number(curr)
@@ -1168,7 +1214,10 @@ export default {
searchMateriel(this.offlineContractNum).then(response => { searchMateriel(this.offlineContractNum).then(response => {
this.tableData3 = response.data this.tableData3 = response.data
this.tableData3.map(v => { this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价 !v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
}) })
}) })
} else { this.$message.error('选入失败') } } else { this.$message.error('选入失败') }
@@ -1187,7 +1236,10 @@ export default {
searchMateriel(this.offlineContractNum).then(response => { searchMateriel(this.offlineContractNum).then(response => {
this.tableData3 = response.data this.tableData3 = response.data
this.tableData3.map(v => { this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价 !v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
}) })
}) })
} else { this.$message.error('移除失败') } } else { this.$message.error('移除失败') }
@@ -1215,18 +1267,21 @@ export default {
this.totalPrice += this.tableData3[i].数量 * this.tableData3[i].单价 this.totalPrice += this.tableData3[i].数量 * this.tableData3[i].单价
this.partGroup.push(this.tableData3[i].离线合同明细流水号) this.partGroup.push(this.tableData3[i].离线合同明细流水号)
this.numGroup.push(this.tableData3[i].数量) this.numGroup.push(this.tableData3[i].数量)
this.priceGroup.push(this.tableData3[i].单价) this.hasTax === '含税' ? this.priceGroup.push(this.tableData3[i].单价) : this.priceGroup.push(this.tableData3[i].未税单价 * (1 + this.taxRate))
dateGroup.push(this.tableData3[i].交货期要求) dateGroup.push(this.tableData3[i].交货期要求)
remarkGroup.push(this.tableData3[i].备注) remarkGroup.push(this.tableData3[i].备注)
} }
saveOfflineContact(this.offlineContractNum, this.totalPrice, this.partGroup, this.numGroup, this.priceGroup, dateGroup, remarkGroup).then(response => { saveOfflineContact(this.offlineContractNum, this.totalPrice, this.partGroup, this.numGroup, this.priceGroup, dateGroup, remarkGroup, this.taxRate * 100).then(response => {
if (response.data[0].result === '1') { if (response.data[0].result === '1') {
this.$message.success('离线合同保存成功') this.$message.success('离线合同保存成功')
this.searchTable2() this.searchTable2()
searchMateriel(this.offlineContractNum).then(response => { searchMateriel(this.offlineContractNum).then(response => {
this.tableData3 = response.data this.tableData3 = response.data
this.tableData3.map(v => { this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价 !v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
}) })
}) })
} else { this.$message.error('离线合同保存失败') } } else { this.$message.error('离线合同保存失败') }
@@ -1254,18 +1309,21 @@ export default {
this.totalPrice += this.tableData3[i].数量 * this.tableData3[i].单价 this.totalPrice += this.tableData3[i].数量 * this.tableData3[i].单价
this.partGroup.push(this.tableData3[i].离线合同明细流水号) this.partGroup.push(this.tableData3[i].离线合同明细流水号)
this.numGroup.push(this.tableData3[i].数量) this.numGroup.push(this.tableData3[i].数量)
this.priceGroup.push(this.tableData3[i].单价) this.hasTax === '含税' ? this.priceGroup.push(this.tableData3[i].单价) : this.priceGroup.push(this.tableData3[i].未税单价 * (1 + this.taxRate))
dateGroup.push(this.tableData3[i].交货期要求) dateGroup.push(this.tableData3[i].交货期要求)
remarkGroup.push(this.tableData3[i].备注) remarkGroup.push(this.tableData3[i].备注)
} }
doneOfflineContact(this.offlineContractNum, this.totalPrice, this.partGroup, this.numGroup, this.priceGroup, dateGroup, remarkGroup).then(response => { doneOfflineContact(this.offlineContractNum, this.totalPrice, this.partGroup, this.numGroup, this.priceGroup, dateGroup, remarkGroup, this.taxRate * 100).then(response => {
if (response.data[0].result === '1') { if (response.data[0].result === '1') {
this.$message.success('离线合同生成成功') this.$message.success('离线合同生成成功')
this.searchTable2() this.searchTable2()
searchMateriel(this.offlineContractNum).then(response => { searchMateriel(this.offlineContractNum).then(response => {
this.tableData3 = response.data this.tableData3 = response.data
this.tableData3.map(v => { this.tableData3.map(v => {
this.$set(v, '未税总额', 0)
this.$set(v, '含税总额', 0)
!v.单价 ? v.单价 = v.参考价格 : v.单价 !v.单价 ? v.单价 = v.参考价格 : v.单价
this.$set(v, '未税单价', v.单价 / (1 + this.taxRate))
}) })
this.disable = true // 是否为编辑模式 this.disable = true // 是否为编辑模式
}) })