采购0613

This commit is contained in:
zhangdingyu
2019-06-13 10:53:33 +08:00
parent 58c30a0c88
commit 195fc311ab
7 changed files with 1857 additions and 1775 deletions

View File

@@ -185,6 +185,15 @@
:value="item.value"/>
</el-select>
</el-form-item>
<el-form-item label="出库类别" prop="outTypeValue" label-width="100px">
<el-select v-model="form1.outTypeValue" size="small" placeholder="出库类别" style="width: 200px;margin-right:10px">
<el-option
v-for="item in outType"
:key="item.value"
:label="item.label"
:value="item.value"/>
</el-select>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible1=false">取消</el-button>
@@ -210,225 +219,240 @@
</template>
<script>
import { initPickPerson, initMachineProject, searchgroup, searchList, searchListDetail, searchStockNumber1, searchStockNumber2, submitOutStore, errorRecord, searchStockNumber3 } from '@/api/Inventory/MaterialOut'
import { mapGetters } from 'vuex'
export default {
name: 'MaterialOut',
data() {
return {
pickingListNumber: '',
pickingListNumberShow: '',
pickListTable1: [],
pageCurrent3: 1,
pageSize3: 20,
total3: 0,
pickListTable2: [],
StockNumberTable: [],
dialogFormVisible1: false,
dialogFormVisible2: false,
form1: {
machineValue: '',
groupNumValue: '',
outNumber: '',
outNumberMax: '', // 出库最大值
personValue: ''
},
form2: {
errorNumber: '',
reason: '',
物料流水号: '',
基本件流水号: '',
货位流水号: ''
},
rules1: {
machineValue: [{ required: true, message: '请选择' }],
groupNumValue: [{ required: true, message: '请选择' }],
outNumber: [{ required: true, message: '请输入' }],
personValue: [{ required: true, message: '请输入' }]
},
rules2: {
errorNumber: [{ required: true, message: '请输入' }],
reason: [{ required: true, message: '请输入' }]
},
machine: [],
group: [],
person: [],
materialNum: '', // 中间变量物料流水号
machineValue: '', // 中间变量机床流水号
groupNumValue: '', // 中间变量组件流水号
basePartNum: '', // 中间变量基本件流水号
purchaseBillNum: '', // 中间变量请购单明细流水号
parchasePartNum: '', // 中间变量标准件和外购件流水号
locationNum: '', // 中间变量货位流水号
outNumber: 0 // 中间变量出库数量
}
},
computed: {
...mapGetters([
'id'
])
},
mounted() {
this.fetchData()
this.searchList()
},
methods: {
// 初始化数据
fetchData() {
this.person = []
initPickPerson().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.person.push({
label: response.data[i].姓名,
value: response.data[i].人员编号
})
}
})
this.machine = []
initMachineProject().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.machine.push({
label: response.data[i].机床图号,
name: response.data[i].项目名称,
value: response.data[i].机床流水号
})
}
})
import { initPickPerson, initMachineProject, searchgroup, searchList, searchListDetail, searchStockNumber1, searchStockNumber2, submitOutStore, errorRecord, searchStockNumber3, initOutType } from '@/api/Inventory/MaterialOut'
import { mapGetters } from 'vuex'
export default {
name: 'MaterialOut',
data() {
return {
pickingListNum: '', // 领料单流水号
pickingPersonNum: '', // 领料人流水号
pickingListNumber: '',
pickingListNumberShow: '',
pickListTable1: [],
pageCurrent3: 1,
pageSize3: 20,
total3: 0,
pickListTable2: [],
StockNumberTable: [],
dialogFormVisible1: false,
dialogFormVisible2: false,
outType: [],
form1: {
machineValue: '',
groupNumValue: '',
outNumber: '',
outNumberMax: '', // 出库最大值
personValue: '',
outTypeValue: '' // 出库类别
},
form2: {
errorNumber: '',
reason: '',
物料流水号: '',
基本件流水号: '',
货位流水号: ''
},
rules1: {
machineValue: [{ required: true, message: '请选择' }],
groupNumValue: [{ required: true, message: '请选择' }],
outNumber: [{ required: true, message: '请输入' }],
personValue: [{ required: true, message: '请输入' }],
outTypeValue: [{ required: true, message: '请选择' }] // 出库类别
},
rules2: {
errorNumber: [{ required: true, message: '请输入' }],
reason: [{ required: true, message: '请输入' }]
},
machine: [],
group: [],
person: [],
materialNum: '', // 中间变量物料流水号
machineValue: '', // 中间变量机床流水号
groupNumValue: '', // 中间变量组件流水号
basePartNum: '', // 中间变量基本件流水号
purchaseBillNum: '', // 中间变量请购单明细流水号
parchasePartNum: '', // 中间变量标准件和外购件流水号
inventoryNum: '', // 中间变量仓库流水号
locationNum: '', // 中间变量货位流水号
outNumber: 0 // 中间变量出库数量
}
},
// 查询组号
searchGroup() {
this.group = []
this.form1.groupNumValue = ''
searchgroup(this.form1.machineValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.group.push({
label: response.data[i].组号,
value: Number(response.data[i].组件流水号)
})
}
})
computed: {
...mapGetters([
'id'
])
},
// 查询领料单列表
searchList() {
let check
this.pickingListNumber ? check = 1 : check = 0
searchList(this.pageCurrent3, this.pageSize3, check, this.pickingListNumber).then(response => {
this.pickListTable1 = response.data.rows
this.total3 = response.data.total
})
},
handleSizeChange3(val) {
this.pageSize3 = val
this.pageCurrent3 = 1
mounted() {
this.fetchData()
this.searchList()
},
handleCurrentChange3(val) {
this.pageCurrent3 = val
this.searchList()
},
// 查看领料单明细
clickList(row) {
row && row.领料单流水号 ? this.pickingListNum = row.领料单流水号 : this.pickingListNum
row && row.领料单编号 ? this.pickingListNumberShow = row.领料单编号 : this.pickingListNumberShow
searchListDetail(this.pickingListNum).then(res => {
this.pickListTable2 = res.data
})
},
// 查看领料单明细相关的物料货位数量
clickListDetail(row) {
console.log(row, 111)
row && row.基本件流水号 ? (this.basePartNum = row.基本件流水号, this.materialNum = null, this.parchasePartNum = null, this.purchaseBillNum = null) : this.basePartNum
row && row.物料流水号 ? (this.materialNum = row.物料流水号, this.basePartNum = null, this.purchaseBillNum = null) : this.materialNum
row && row.标准件和外购件流水号 ? (this.parchasePartNum = row.标准件和外购件流水号, this.basePartNum = null, this.purchaseBillNum = null) : this.parchasePartNum
row && row.请购单明细流水号 ? (this.purchaseBillNum = row.请购单明细流水号, this.basePartNum = null, this.materialNum = null, this.parchasePartNum = null) : this.parchasePartNum
row && row.机床流水号 ? this.machineValue = row.机床流水号 : this.machineValue
row && row.组件流水号 ? this.groupNumValue = row.组件流水号 : this.groupNumValue
row && row.总数量 ? this.outNumber = row.总数量 : this.outNumber
if (this.materialNum) {
searchStockNumber1(this.materialNum).then(res => {
this.StockNumberTable = res.data
methods: {
// 初始化数据
fetchData() {
this.person = []
initPickPerson().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.person.push({
label: response.data[i].姓名,
value: response.data[i].人员编号
})
}
})
} else if (this.basePartNum) {
searchStockNumber2(this.basePartNum).then(res => {
this.StockNumberTable = res.data
this.machine = []
initMachineProject().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.machine.push({
label: response.data[i].机床图号,
name: response.data[i].项目名称,
value: response.data[i].机床流水号
})
}
})
} else if (this.purchaseBillNum) {
searchStockNumber3(this.purchaseBillNum).then(res => {
this.StockNumberTable = res.data
initOutType().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.outType.push({
label: response.data[i].出库类别名称,
value: response.data[i].出库类别流水号
})
}
})
}
},
// 出库
outStore(row) {
if (this.$refs['form1'] !== undefined) {
this.$refs['form1'].resetFields()
}
this.form1.machineValue = this.machineValue
this.locationNum = row.货位流水号
this.outNumber > row.货位存量 ? (this.form1.outNumber = row.货位存量, this.form1.outNumberMax = row.货位存量) : (this.form1.outNumber = this.outNumber, this.form1.outNumberMax = this.outNumber) // 货位存量和领料数量对比取小
this.form1.personValue = Number(this.id)
this.group = []
this.form1.groupNumValue = ''
searchgroup(this.form1.machineValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.group.push({
label: response.data[i].组号,
value: Number(response.data[i].组件流水号)
},
// 查询组号
searchGroup() {
this.group = []
this.form1.groupNumValue = ''
searchgroup(this.form1.machineValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.group.push({
label: response.data[i].组号,
value: Number(response.data[i].组件流水号)
})
}
})
},
// 查询领料单列表
searchList() {
let check
this.pickingListNumber ? check = 1 : check = 0
searchList(this.pageCurrent3, this.pageSize3, check, this.pickingListNumber).then(response => {
this.pickListTable1 = response.data.rows
this.total3 = response.data.total
})
},
handleSizeChange3(val) {
this.pageSize3 = val
this.pageCurrent3 = 1
this.searchList()
},
handleCurrentChange3(val) {
this.pageCurrent3 = val
this.searchList()
},
// 查看领料单明细
clickList(row) {
row && row.领料单流水号 ? this.pickingListNum = row.领料单流水号 : this.pickingListNum
row && row.人员编号 ? this.pickingPersonNum = row.人员编号 : this.pickingListNum
row && row.领料单编号 ? this.pickingListNumberShow = row.领料单编号 : this.pickingListNumberShow
searchListDetail(this.pickingListNum).then(res => {
this.pickListTable2 = res.data
})
},
// 查看领料单明细相关的物料货位数量
clickListDetail(row) {
row && row.基本件流水号 ? (this.basePartNum = row.基本件流水号, this.materialNum = null, this.parchasePartNum = null, this.purchaseBillNum = null) : this.basePartNum
row && row.物料流水号 ? (this.materialNum = row.物料流水号, this.basePartNum = null, this.purchaseBillNum = null) : this.materialNum
row && row.标准件和外购件流水号 ? (this.parchasePartNum = row.标准件和外购件流水号, this.basePartNum = null, this.purchaseBillNum = null) : this.parchasePartNum
row && row.请购单明细流水号 ? (this.purchaseBillNum = row.请购单明细流水号, this.basePartNum = null, this.materialNum = null, this.parchasePartNum = null) : this.parchasePartNum
row && row.机床流水号 ? this.machineValue = row.机床流水号 : this.machineValue
row && row.组件流水号 ? this.groupNumValue = row.组件流水号 : this.groupNumValue
row && row.总数量 ? this.outNumber = row.总数量 : this.outNumber
if (this.materialNum) {
searchStockNumber1(this.materialNum).then(res => {
this.StockNumberTable = res.data
})
} else if (this.basePartNum) {
searchStockNumber2(this.basePartNum).then(res => {
this.StockNumberTable = res.data
})
} else if (this.purchaseBillNum) {
searchStockNumber3(this.purchaseBillNum).then(res => {
this.StockNumberTable = res.data
})
}
}).then(() => {
this.form1.groupNumValue = this.groupNumValue
this.dialogFormVisible1 = true
})
},
// 提交出库
submitOutStore() {
this.$refs['form1'].validate((valid) => {
if (valid) {
// 出库数量,出库人,基本件流水号/标准件和外购件流水号 => 记录到一个新表
// 物料流水号,货位流水号,出库数量 => 减掉货位物料数
submitOutStore(this.materialNum, this.locationNum, this.form1.outNumber, this.form1.personValue, this.basePartNum, this.parchasePartNum, this.purchaseBillNum).then(response => {
if (response.data[0].result === '1') {
this.$message.success('出库成功')
this.dialogFormVisible1 = false
this.clickListDetail()
this.clickList()
} else { this.$message.error('操作失败') }
})
} else {
return false
},
// 出库
outStore(row) {
if (this.$refs['form1'] !== undefined) {
this.$refs['form1'].resetFields()
}
})
},
// 异常记录
errorRecord(row) {
if (this.$refs['form2'] !== undefined) {
this.$refs['form2'].resetFields()
this.form1.machineValue = this.machineValue
this.inventoryNum = row.仓库流水号
this.locationNum = row.货位流水号
this.outNumber > row.货位存量 ? (this.form1.outNumber = row.货位存量, this.form1.outNumberMax = row.货位存量) : (this.form1.outNumber = this.outNumber, this.form1.outNumberMax = this.outNumber) // 货位存量和领料数量对比取小
this.form1.personValue = Number(this.id)
this.group = []
this.form1.groupNumValue = ''
searchgroup(this.form1.machineValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.group.push({
label: response.data[i].组号,
value: Number(response.data[i].组件流水号)
})
}
}).then(() => {
this.form1.groupNumValue = this.groupNumValue
this.dialogFormVisible1 = true
})
},
// 提交出库
submitOutStore() {
this.$refs['form1'].validate((valid) => {
if (valid) {
// 出库数量,出库人,基本件流水号/标准件和外购件流水号 => 记录到一个新表
// 物料流水号,货位流水号,出库数量 => 减掉货位物料数
submitOutStore(this.materialNum, this.locationNum, this.form1.outNumber, this.form1.personValue, this.basePartNum, this.parchasePartNum, this.purchaseBillNum, this.pickingListNum, this.pickingPersonNum, this.inventoryNum, this.form1.outTypeValue).then(response => {
if (response.data[0].result === '1') {
this.$message.success('出库成功')
this.dialogFormVisible1 = false
this.clickListDetail()
this.clickList()
} else { this.$message.error('操作失败') }
})
} else {
return false
}
})
},
// 异常记录
errorRecord(row) {
if (this.$refs['form2'] !== undefined) {
this.$refs['form2'].resetFields()
}
this.form2.errorNumber = ''
this.form2.reason = ''
this.form2.物料流水号 = row.物料流水号
this.form2.基本件流水号 = row.基本件流水号
this.form2.货位流水号 = row.货位流水号
this.dialogFormVisible2 = true
},
// 提交异常记录
submitErrorRecord() {
this.$refs['form2'].validate((valid) => {
if (valid) {
errorRecord(this.form2.errorNumber, this.form2.reason, this.form2.物料流水号, this.form2.基本件流水号, this.form2.货位流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('记录成功')
this.dialogFormVisible2 = false
} else { this.$message.error('操作失败') }
})
} else {
return false
}
})
}
this.form2.errorNumber = ''
this.form2.reason = ''
this.form2.物料流水号 = row.物料流水号
this.form2.基本件流水号 = row.基本件流水号
this.form2.货位流水号 = row.货位流水号
this.dialogFormVisible2 = true
},
// 提交异常记录
submitErrorRecord() {
this.$refs['form2'].validate((valid) => {
if (valid) {
errorRecord(this.form2.errorNumber, this.form2.reason, this.form2.物料流水号, this.form2.基本件流水号, this.form2.货位流水号).then(response => {
if (response.data[0].result === '1') {
this.$message.success('记录成功')
this.dialogFormVisible2 = false
} else { this.$message.error('操作失败') }
})
} else {
return false
}
})
}
}
}
</script>
<style scoped>

File diff suppressed because it is too large Load Diff

View File

@@ -129,13 +129,13 @@
</el-table-column>
<el-table-column v-show="hasTax==='未税'" label="单价(未税)" align="center" width="120">
<template slot-scope="scope">
<el-input v-show="hasTax==='未税'" v-model="scope.row.未税单价" size="mini" style="width:100%"/>
<el-input-number v-show="hasTax==='未税'" :min="0" v-model="scope.row.未税单价" controls-position="right" size="mini" style="width:100%" @focus="scope.row.未税单价=''" @change="priceChange(scope.row.未税单价, scope.row.物料流水号, scope.row.询价单流水号, scope.row)"/>
<b v-show="hasTax!=='未税'"></b>
</template>
</el-table-column>
<el-table-column v-show="hasTax==='含税'" label="单价(含税)" align="center" width="120">
<template slot-scope="scope">
<el-input v-show="hasTax==='含税'" v-model="scope.row.含税单价" size="mini" style="width:100%"/>
<el-input-number v-show="hasTax==='含税'" :min="0" v-model="scope.row.含税单价" controls-position="right" size="mini" style="width:100%" @focus="scope.row.含税单价=''" @change="priceChange(scope.row.含税单价, scope.row.物料流水号, scope.row.询价单流水号, scope.row)"/>
<b v-show="hasTax!=='含税'"></b>
</template>
</el-table-column>
@@ -184,213 +184,236 @@
</template>
<script>
import Tinymce from '@/components/Tinymce'
import { initSupplier, searchInquirySheet, searchSheetContract, doneContract, searchBaseInfo } from '@/api/PurchasingCenter/CreatePurchaseContract'
import { convertCurrency } from '@/vendor/int2Chinese'
import { mapGetters } from 'vuex'
import { sleep, groupBy } from '@/utils/tool'
import $ from 'jquery'
import Tinymce from '@/components/Tinymce'
import { initSupplier, searchInquirySheet, searchSheetContract, doneContract, searchBaseInfo, savePrice } from '@/api/PurchasingCenter/CreatePurchaseContract'
import { convertCurrency } from '@/vendor/int2Chinese'
import { mapGetters } from 'vuex'
import { sleep, groupBy } from '@/utils/tool'
import $ from 'jquery'
export default {
components: { Tinymce },
inject: ['reload'],
data() {
return {
supplier: [],
year: '',
month: '',
day: '',
trustee: '', // 受托人
bank1: '',
account1: '',
taxCode1: '',
phone1: '',
fax1: '',
postCode1: '',
bank2: '',
account2: '',
taxCode2: '',
phone2: '',
fax2: '',
postCode2: '',
hasTax: '含税',
taxRate: 0.13,
preview: false, // 预览
demoRadio: '', // 模板radio
content: ``, // 合同格式模板
contentNew: ``, // tinymce的
contractName: '采购合同', // 合同名称
contractNum: '', // 合同编号
contractNums: [], // 合同编号数组
contractNumValue: '', // 合同流水号
supplierName: '', // 供应商名称
supplierValue: '', // 供应商流水号
supplierAddress: '', // 供应商地址
legalPerson: '', // 法人
untaxTotal: '', // 未税合计
tax: '', // 税额
taxTotal: '', // 含税合计
actualTotal: '', // 实际金额
actualTotal_zh: '', // 实际金额大写
payDate: '', // 支付日期
payMethod: '', // 支付方式
deliveryDate: '', // 交货日期
invoiceInfo: '', // 开票信息
otherInfo: '', // 其他说明
tableData1: [],
单价是否含税: '',
组件零件流水号组: [],
组件零件基本件流水号组: [],
数量组: [],
单价组: [],
交货期组: []
}
},
computed: {
...mapGetters([
'name',
'id'
])
},
created() {
this.fetchData()
},
methods: {
deleteAllDate() {
this.tableData1.map(v => {
v.交货期 = ''
})
},
fetchData() {
initSupplier(this.id).then(res => {
this.supplier = []
for (let i = 0; i < res.data.length; i++) {
this.supplier.push({
value: res.data[i].供应商流水号,
label: res.data[i].供应商名称
})
}
})
searchBaseInfo(this.id).then(res => {
this.fax2 = res.data[0] ? res.data[0].传真 : ''
this.postCode2 = '224053'
this.phone2 = res.data[0] ? res.data[0].手机 + '/' + res.data[0].公司电话 : ''
this.taxCode2 = res.data[0] ? res.data[0].税号 : ''
this.account2 = res.data[0] ? res.data[0].帐号 : ''
this.bank2 = res.data[0] ? res.data[0].开户行 : ''
})
searchInquirySheet(0, 0, 0, 0, 1, this.id, 0, 0).then(response => { // 初始化询价单号
this.contractNums = []
for (let i = 0; i < response.data.length; i++) {
this.contractNums.push({
value: response.data[i].询价单流水号,
label: response.data[i].询价单编号,
supplierName: response.data[i].供应商名称,
supplierValue: response.data[i].供应商流水号,
supplierAddress: response.data[i].地址,
legalPerson: response.data[i].企业性质, // 法人
trustee: response.data[i].注册资本 || '', // 受托人
bank1: response.data[i].开户行 || '', // 开户行
account1: response.data[i].帐号 || '', // 帐号
taxCode1: response.data[i].税号 || '', // 税号
phone1: response.data[i].电话号码 || '', // 电话
fax1: response.data[i].传真 || '', // 传真
postCode1: response.data[i].货期 || '' // 邮编
})
}
})
},
submitTotal() { // 确定合同总额
this.$refs.tinymce.destroyTinymce()
document.getElementsByClassName('actualTotal')[0].innerHTML = this.actualTotal
document.getElementsByClassName('actualTotal')[1].innerHTML = this.actualTotal
document.getElementById('actualTotal_zh').innerHTML = convertCurrency(this.actualTotal)
this.contentNew = document.getElementsByClassName('editor-content')[0].innerHTML
this.$refs.tinymce.initTinymce()
},
supplierChange() {
let check
this.supplierValue ? check = 1 : check = 0
searchInquirySheet(0, 0, 0, 0, 1, this.id, check, this.supplierValue).then(response => { // 初始化询价单号
this.contractNums = []
this.contractNumValue = ''
for (let i = 0; i < response.data.length; i++) {
this.contractNums.push({
value: response.data[i].询价单流水号,
label: response.data[i].询价单编号,
supplierName: response.data[i].供应商名称,
supplierValue: response.data[i].供应商流水号,
supplierAddress: response.data[i].地址,
legalPerson: response.data[i].企业性质, // 法人
trustee: response.data[i].注册资本 || '', // 受托人
bank1: response.data[i].开户行 || '', // 开户行
account1: response.data[i].帐号 || '', // 帐号
taxCode1: response.data[i].税号 || '', // 税号
phone1: response.data[i].电话号码 || '', // 电话
fax1: response.data[i].传真 || '', // 传真
postCode1: response.data[i].货期 || '' // 邮编
})
}
})
},
contractChange() { // 选择合同select
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.legalPerson = this.contractNums[i].legalPerson
this.contractNum = this.contractNums[i].label
this.trustee = this.contractNums[i].trustee
this.bank1 = this.contractNums[i].bank1
this.account1 = this.contractNums[i].account1
this.taxCode1 = this.contractNums[i].taxCode1
this.phone1 = this.contractNums[i].phone1
this.fax1 = this.contractNums[i].fax1
this.postCode1 = this.contractNums[i].postCode1
}
}
this.searchContractDetail()
},
searchContractDetail() { // 查询合同明细
this.tableData1 = []
searchSheetContract(this.contractNumValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
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].组件零件流水号 ? response.data[i].物料名称 : response.data[i].零件名称,
规格: response.data[i].组件零件流水号 ? response.data[i].物料规格 : response.data[i].规格,
数量: response.data[i].数量,
计量单位: response.data[i].计量单位,
未税单价: 0,
未税总额: 0,
含税单价: 0,
含税总额: 0,
备注: response.data[i].备注
})
}
})
},
demoChange() { // 模板change
switch (this.demoRadio) {
case '模板1':
this.demo1()
break
case '模板2':
this.demo2()
break
// case '自定义':
// this.customization()
// break
export default {
components: { Tinymce },
inject: ['reload'],
data() {
return {
supplier: [],
year: '',
month: '',
day: '',
trustee: '', // 受托人
bank1: '',
account1: '',
taxCode1: '',
phone1: '',
fax1: '',
postCode1: '',
bank2: '',
account2: '',
taxCode2: '',
phone2: '',
fax2: '',
postCode2: '',
hasTax: '含税',
taxRate: 0.13,
preview: false, // 预览
demoRadio: '', // 模板radio
content: ``, // 合同格式模板
contentNew: ``, // tinymce的
contractName: '采购合同', // 合同名称
contractNum: '', // 合同编号
contractNums: [], // 合同编号数组
contractNumValue: '', // 合同流水号
supplierName: '', // 供应商名称
supplierValue: '', // 供应商流水号
supplierAddress: '', // 供应商地址
legalPerson: '', // 法人
untaxTotal: '', // 未税合计
tax: '', // 税额
taxTotal: '', // 含税合计
actualTotal: '', // 实际金额
actualTotal_zh: '', // 实际金额大写
payDate: '', // 支付日期
payMethod: '', // 支付方式
deliveryDate: '', // 交货日期
invoiceInfo: '', // 开票信息
otherInfo: '', // 其他说明
tableData1: [],
单价是否含税: '',
组件零件流水号组: [],
组件零件基本件流水号组: [],
数量组: [],
单价组: [],
交货期组: []
}
},
demo1() { // 选择合同模板1
this.content = `
computed: {
...mapGetters([
'name',
'id'
])
},
created() {
this.fetchData()
},
methods: {
// 价格实时保存
priceChange(price, num1, num2, row) {
this.tableData1.map(v => {
if (Number(v.物料流水号) === Number(row.物料流水号) && Number(v.询价单流水号) === Number(row.询价单流水号)) {
v.含税单价 = row.含税单价
v.未税单价 = row.未税单价
}
})
const group = this.tableData1
this.tableData1 = []
this.tableData1 = group
price = price || 0
savePrice(price, num1, num2).then(res => {
if (res.data[0].result === '1') {
console.log('单价实时保存成功')
} else {
console.log('单价实时保存失败')
}
})
},
deleteAllDate() {
this.tableData1.map(v => {
v.交货期 = ''
})
},
fetchData() {
initSupplier(this.id).then(res => {
this.supplier = []
for (let i = 0; i < res.data.length; i++) {
this.supplier.push({
value: res.data[i].供应商流水号,
label: res.data[i].供应商名称
})
}
})
searchBaseInfo(this.id).then(res => {
this.fax2 = res.data[0] ? res.data[0].传真 : ''
this.postCode2 = '224053'
this.phone2 = res.data[0] ? res.data[0].手机 + '/' + res.data[0].公司电话 : ''
this.taxCode2 = res.data[0] ? res.data[0].税号 : ''
this.account2 = res.data[0] ? res.data[0].帐号 : ''
this.bank2 = res.data[0] ? res.data[0].开户行 : ''
})
searchInquirySheet(0, 0, 0, 0, 1, this.id, 0, 0).then(response => { // 初始化询价单号
this.contractNums = []
for (let i = 0; i < response.data.length; i++) {
this.contractNums.push({
value: response.data[i].询价单流水号,
label: response.data[i].询价单编号,
supplierName: response.data[i].供应商名称,
supplierValue: response.data[i].供应商流水号,
supplierAddress: response.data[i].地址,
legalPerson: response.data[i].企业性质, // 法人
trustee: response.data[i].注册资本 || '', // 受托人
bank1: response.data[i].开户行 || '', // 开户行
account1: response.data[i].帐号 || '', // 帐号
taxCode1: response.data[i].税号 || '', // 税号
phone1: response.data[i].电话号码 || '', // 电话
fax1: response.data[i].传真 || '', // 传真
postCode1: response.data[i].货期 || '' // 邮编
})
}
})
},
submitTotal() { // 确定合同总额
this.$refs.tinymce.destroyTinymce()
document.getElementsByClassName('actualTotal')[0].innerHTML = this.actualTotal
document.getElementsByClassName('actualTotal')[1].innerHTML = this.actualTotal
document.getElementById('actualTotal_zh').innerHTML = convertCurrency(this.actualTotal)
this.contentNew = document.getElementsByClassName('editor-content')[0].innerHTML
this.$refs.tinymce.initTinymce()
},
supplierChange() {
let check
this.supplierValue ? check = 1 : check = 0
searchInquirySheet(0, 0, 0, 0, 1, this.id, check, this.supplierValue).then(response => { // 初始化询价单号
this.contractNums = []
this.contractNumValue = ''
for (let i = 0; i < response.data.length; i++) {
this.contractNums.push({
value: response.data[i].询价单流水号,
label: response.data[i].询价单编号,
supplierName: response.data[i].供应商名称,
supplierValue: response.data[i].供应商流水号,
supplierAddress: response.data[i].地址,
legalPerson: response.data[i].企业性质, // 法人
trustee: response.data[i].注册资本 || '', // 受托人
bank1: response.data[i].开户行 || '', // 开户行
account1: response.data[i].帐号 || '', // 帐号
taxCode1: response.data[i].税号 || '', // 税号
phone1: response.data[i].电话号码 || '', // 电话
fax1: response.data[i].传真 || '', // 传真
postCode1: response.data[i].货期 || '' // 邮编
})
}
})
},
contractChange() { // 选择合同select
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.legalPerson = this.contractNums[i].legalPerson
this.contractNum = this.contractNums[i].label
this.trustee = this.contractNums[i].trustee
this.bank1 = this.contractNums[i].bank1
this.account1 = this.contractNums[i].account1
this.taxCode1 = this.contractNums[i].taxCode1
this.phone1 = this.contractNums[i].phone1
this.fax1 = this.contractNums[i].fax1
this.postCode1 = this.contractNums[i].postCode1
}
}
this.searchContractDetail()
},
searchContractDetail() { // 查询合同明细
this.tableData1 = []
searchSheetContract(this.contractNumValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
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].组件零件流水号 ? 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].单价,
未税总额: 0,
含税单价: response.data[i].单价,
含税总额: 0,
备注: response.data[i].备注
})
}
})
},
demoChange() { // 模板change
switch (this.demoRadio) {
case '模板1':
this.demo1()
break
case '模板2':
this.demo2()
break
// case '自定义':
// this.customization()
// break
}
},
demo1() { // 选择合同模板1
this.content = `
<h2 style="text-align: center;">
<strong>采购合同</strong>
</h2>
@@ -536,154 +559,161 @@ export default {
<span>含税总价(税率<span id="taxRate"></span></span><span id="taxTotal"></span><span>元</span><br>
<span>优惠后含税总价:</span><span class="actualTotal"></span><span>元</span>
`
},
async editContract() { // 选择一个询价单,整成合同明细
const date = new Date()
this.year = date.getFullYear()
this.month = date.getMonth() + 1
this.day = date.getDate()
this.demoChange()
await sleep(0)
if (this.contractNumValue) {
if (this.demoRadio) {
this.$refs.tinymce.destroyTinymce()
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('legalPerson') ? document.getElementById('legalPerson').innerHTML = this.legalPerson : ''
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')
const parent = document.getElementById('tbody')
if (children.length !== 0) {
for (let i = children.length - 1; i >= 0; i--) {
parent.removeChild(children[i])
},
async editContract() { // 选择一个询价单,整成合同明细
const date = new Date()
this.year = date.getFullYear()
this.month = date.getMonth() + 1
this.day = date.getDate()
this.demoChange()
await sleep(0)
if (this.contractNumValue) {
if (this.demoRadio) {
this.$refs.tinymce.destroyTinymce()
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('legalPerson') ? document.getElementById('legalPerson').innerHTML = this.legalPerson : ''
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')
const parent = document.getElementById('tbody')
if (children.length !== 0) {
for (let i = children.length - 1; i >= 0; i--) {
parent.removeChild(children[i])
}
}
const merge = []
this.tableData1.map(v => {
if ((this.hasTax === '含税' && Number(v.含税单价)) || (this.hasTax === '未税' && Number(v.未税单价))) { // 筛掉未询到价格的物料
merge.push({
机床图号: v.机床图号,
组号: v.组号,
图号: v.图号,
名称: v.名称,
规格: v.规格,
数量: Number(v.数量),
计量单位: v.计量单位,
单价: this.hasTax === '含税' ? v.含税单价 : v.未税单价,
合计: (Number(v.数量) * (this.hasTax === '含税' ? Number(v.含税单价) : Number(v.未税单价))).toFixed(2),
交货期: v.交货期 ? v.交货期.split(' ')[0] : '',
备注: v.备注
})
}
})
let mergeData = []
mergeData = groupBy(merge, ['图号', '名称', '规格', '计量单位', '单价', '交货期', '备注'])
// 放入新数据
const tr = []
for (let i = 0; i < mergeData.length; i++) {
tr[i] = document.createElement('tr')
tr[i].setAttribute('class', 'tableData')
tr[i].innerHTML = '<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>'
const tableHead = $('#tableHead')
tableHead ? tableHead.after(tr[i]) : ''
}
this.actualTotal = 0
this.untaxTotal = 0
this.taxTotal = 0
for (let j = 0; j < this.tableData1.length; j++) {
this.actualTotal += Number(this.tableData1[j].含税总额)
this.untaxTotal += Number(this.tableData1[j].未税总额)
this.taxTotal += Number(this.tableData1[j].含税总额)
}
for (let j = 0; j < mergeData.length; j++) {
if (document.getElementsByClassName('tableData')[j]) {
document.getElementsByClassName('tableData')[j].children[0].innerHTML = j + 1
document.getElementsByClassName('tableData')[j].children[1].innerHTML = mergeData[j].机床图号_组号
document.getElementsByClassName('tableData')[j].children[2].innerHTML = mergeData[j].名称
document.getElementsByClassName('tableData')[j].children[3].innerHTML = mergeData[j].图号
document.getElementsByClassName('tableData')[j].children[4].innerHTML = mergeData[j].规格
document.getElementsByClassName('tableData')[j].children[5].innerHTML = mergeData[j].数量
document.getElementsByClassName('tableData')[j].children[6].innerHTML = mergeData[j].计量单位
document.getElementsByClassName('tableData')[j].children[7].innerHTML = mergeData[j].单价
document.getElementsByClassName('tableData')[j].children[8].innerHTML = (Number(mergeData[j].数量) * Number(mergeData[j].单价)).toFixed(2)
document.getElementsByClassName('tableData')[j].children[9].innerHTML = mergeData[j].交货期
document.getElementsByClassName('tableData')[j].children[10].innerHTML = mergeData[j].备注
}
}
this.actualTotal = this.actualTotal.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 : ''
document.getElementById('taxTotal') ? document.getElementById('taxTotal').innerHTML = this.taxTotal : ''
document.getElementsByClassName('actualTotal')[0] ? document.getElementsByClassName('actualTotal')[0].innerHTML = this.actualTotal : ''
document.getElementsByClassName('actualTotal')[1] ? document.getElementsByClassName('actualTotal')[1].innerHTML = this.actualTotal : ''
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('请先选择合同模板,再预览')
}
const merge = []
this.tableData1.map(v => {
merge.push({
机床图号: v.机床图号,
组号: v.组号,
图号: v.图号,
名称: v.名称,
规格: v.规格,
数量: Number(v.数量),
计量单位: v.计量单位,
单价: this.hasTax === '含税' ? v.含税单价 : v.未税单价,
合计: (Number(v.数量) * (this.hasTax === '含税' ? Number(v.含税单价) : Number(v.未税单价))).toFixed(2),
交货期: v.交货期 ? v.交货期.split(' ')[0] : '',
备注: v.备注
} else {
this.$message.warning('请先选择合同,再预览')
}
},
demo2() {
this.content = `demo2`
},
// customization() { // 自定义
// this.content = `自定义`
// },
generateContract() { // 生成采购合同
this.content = this.contentNew.replace(/&nbsp;/g, '')
this.content = this.content.replace(/\n/g, '')
this.content = this.content.replace(/==/g, '= =') // 更新tinymce中的东西到html中后续会用到
this.组件零件流水号组 = []
this.组件零件基本件流水号组 = []
this.数量组 = []
this.单价组 = []
this.交货期组 = []
this.hasTax === '含税' ? this.单价是否含税 = 1 : this.单价是否含税 = 0
const inquiryDetailNum_old = [] // 需要转移到新询价单的物料的询价单明细流水号
this.tableData1.map(v => {
if ((this.hasTax === '含税' && Number(v.含税单价)) || (this.hasTax === '未税' && Number(v.未税单价))) { // 筛掉未询到价格的物料
this.组件零件流水号组.push(v.组件零件流水号)
this.组件零件基本件流水号组.push(v.组件零件基本件流水号)
this.数量组.push(v.数量)
this.hasTax === '含税' ? this.单价组.push(v.含税单价) : this.单价组.push(v.未税单价)
this.交货期组.push(v.交货期)
} else { // 获取未询到价格的物料的询价单明细流水号们
inquiryDetailNum_old.push(v.询价单明细流水号)
}
})
if (this.contractNumValue) {
this.$confirm('此采购合同将递交审批,递交后该合同不可删除,确认完成编辑?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
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.交货期组, this.content, this.taxRate * 100, inquiryDetailNum_old).then(response => {
if (response.data[0].result === '1') {
this.$message.success('合同生成成功')
this.reload()
} else { this.$message.error('生成合同失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
let mergeData = []
mergeData = groupBy(merge, ['图号', '名称', '规格', '计量单位', '单价', '合计', '交货期', '备注'])
// 放入新数据
const tr = []
for (let i = 0; i < mergeData.length; i++) {
tr[i] = document.createElement('tr')
tr[i].setAttribute('class', 'tableData')
tr[i].innerHTML = '<td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td>'
const tableHead = $('#tableHead')
tableHead ? tableHead.after(tr[i]) : ''
}
this.actualTotal = 0
this.untaxTotal = 0
this.taxTotal = 0
for (let j = 0; j < this.tableData1.length; j++) {
this.actualTotal += Number(this.tableData1[j].含税总额)
this.untaxTotal += Number(this.tableData1[j].未税总额)
this.taxTotal += Number(this.tableData1[j].含税总额)
}
for (let j = 0; j < mergeData.length; j++) {
if (document.getElementsByClassName('tableData')[j]) {
document.getElementsByClassName('tableData')[j].children[0].innerHTML = j + 1
document.getElementsByClassName('tableData')[j].children[1].innerHTML = mergeData[j].机床图号_组号
document.getElementsByClassName('tableData')[j].children[2].innerHTML = mergeData[j].名称
document.getElementsByClassName('tableData')[j].children[3].innerHTML = mergeData[j].图号
document.getElementsByClassName('tableData')[j].children[4].innerHTML = mergeData[j].规格
document.getElementsByClassName('tableData')[j].children[5].innerHTML = mergeData[j].数量
document.getElementsByClassName('tableData')[j].children[6].innerHTML = mergeData[j].计量单位
document.getElementsByClassName('tableData')[j].children[7].innerHTML = mergeData[j].单价
document.getElementsByClassName('tableData')[j].children[8].innerHTML = (Number(mergeData[j].数量) * Number(mergeData[j].单价)).toFixed(2)
document.getElementsByClassName('tableData')[j].children[9].innerHTML = mergeData[j].交货期
document.getElementsByClassName('tableData')[j].children[10].innerHTML = mergeData[j].备注
}
}
this.actualTotal = this.actualTotal.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 : ''
document.getElementById('taxTotal') ? document.getElementById('taxTotal').innerHTML = this.taxTotal : ''
document.getElementsByClassName('actualTotal')[0] ? document.getElementsByClassName('actualTotal')[0].innerHTML = this.actualTotal : ''
document.getElementsByClassName('actualTotal')[1] ? document.getElementsByClassName('actualTotal')[1].innerHTML = this.actualTotal : ''
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('请先选择合同模板,再预览')
this.$message.warning('请先选择合同进行编辑')
}
} else {
this.$message.warning('请先选择合同,再预览')
}
},
demo2() {
this.content = `demo2`
},
// customization() { // 自定义
// this.content = `自定义`
// },
generateContract() { // 生成采购合同
this.content = this.contentNew.replace(/&nbsp;/g, '')
this.content = this.content.replace(/\n/g, '')
this.content = this.content.replace(/==/g, '= =') // 更新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(() => {
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.交货期组, this.content, this.taxRate * 100).then(response => {
if (response.data[0].result === '1') {
this.$message.success('合同生成成功')
this.reload()
} else { this.$message.error('生成合同失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
} else {
this.$message.warning('请先选择合同进行编辑')
}
}
}
}
</script>
<style scoped>

View File

@@ -166,11 +166,11 @@
{{ scope.row.供货商 }}
</template>
</el-table-column>
<el-table-column :filters="source" :filter-method="filterSource" align="center" label="数据来源" min-width="90px" prop="零件类型">
<template slot-scope="scope">
{{ Number(scope.row.零件类型) === 1 ? 'BZ' : 'WG' }}
</template>
</el-table-column>
<!--<el-table-column :filters="source" :filter-method="filterSource" align="center" label="数据来源" min-width="90px" prop="零件类型">-->
<!--<template slot-scope="scope">-->
<!--{{ Number(scope.row.零件类型) === 1 ? 'BZ' : 'WG' }}-->
<!--</template>-->
<!--</el-table-column>-->
<el-table-column align="center" label="计划到货时间" min-width="100px">
<template slot-scope="scope">
{{ scope.row.物料计划到货时间.split(' ')[0] }}
@@ -380,11 +380,11 @@
{{ scope.row.供货商 }}
</template>
</el-table-column>
<el-table-column :filters="source" :filter-method="filterSource" align="center" label="数据来源" min-width="90px" prop="零件类型">
<template slot-scope="scope">
{{ Number(scope.row.零件类型) === 1 ? 'BZ' : 'WG' }}
</template>
</el-table-column>
<!--<el-table-column :filters="source" :filter-method="filterSource" align="center" label="数据来源" min-width="90px" prop="零件类型">-->
<!--<template slot-scope="scope">-->
<!--{{ Number(scope.row.零件类型) === 1 ? 'BZ' : 'WG' }}-->
<!--</template>-->
<!--</el-table-column>-->
<el-table-column align="center" label="计划到货时间" min-width="100px">
<template slot-scope="scope">
{{ scope.row.物料计划到货时间.split(' ')[0] }}
@@ -615,388 +615,388 @@
</template>
<script>
import { initMaterialCategory, initMaterialVariety, initProject, initBuyer, searchMachine, searchGroup, searchTable1, searchTable2, allocateTask1,
allocateTask2, executeReturn1, executeReturn2, retract1, retract2 } from '@/api/PurchasingCenter/PurchaseTaskAllocate'
import { mapGetters } from 'vuex'
import { initMaterialCategory, initMaterialVariety, initProject, initBuyer, searchMachine, searchGroup, searchTable1, searchTable2, allocateTask1,
allocateTask2, executeReturn1, executeReturn2, retract1, retract2 } from '@/api/PurchasingCenter/PurchaseTaskAllocate'
import { mapGetters } from 'vuex'
export default {
name: '', // 采购任务分配
data() {
return {
source: [
{
text: 'BZ',
value: 1
},
{
text: 'WG',
value: 2
}
],
tabName: '标准件',
partNum: '',
partName: '',
partSpec: '',
partMaterial: '',
materialSpec: '',
materialModel: '',
MaterialCategoryValue: '', // 物料类别
MaterialCategory: [], // 物料类别数组
MaterialVarietyValue: '', // 物料品种
MaterialVariety: [], // 物料品种数组
projectValue: '',
project: [],
machineValue: '',
machine: [],
groupValue: '',
group: [],
materialName: '',
materialStatusValue: [0], // 物料状态
materialStatus: [
{
value: 0,
label: '全部'
},
{
value: 1,
label: '未分配'
},
{
value: 2,
label: '已分配',
children: [{
value: 3,
label: '未询价'
}, {
value: 4,
label: '已询价',
export default {
name: '', // 采购任务分配
data() {
return {
source: [
{
text: 'BZ',
value: 1
},
{
text: 'WG',
value: 2
}
],
tabName: '标准件',
partNum: '',
partName: '',
partSpec: '',
partMaterial: '',
materialSpec: '',
materialModel: '',
MaterialCategoryValue: '', // 物料类别
MaterialCategory: [], // 物料类别数组
MaterialVarietyValue: '', // 物料品种
MaterialVariety: [], // 物料品种数组
projectValue: '',
project: [],
machineValue: '',
machine: [],
groupValue: '',
group: [],
materialName: '',
materialStatusValue: [0], // 物料状态
materialStatus: [
{
value: 0,
label: '全部'
},
{
value: 1,
label: '未分配'
},
{
value: 2,
label: '已分配',
children: [{
value: 5,
label: '未采购'
value: 3,
label: '未询价'
}, {
value: 6,
label: '已采购'
value: 4,
label: '已询价',
children: [{
value: 5,
label: '未采购'
}, {
value: 6,
label: '已采购'
}]
}]
}]
}
], // 物料状态
personValue: '',
person: [],
check1: 0,
check2: 0,
check3: 0,
check4: 0,
tableData0: [],
tableData1: [],
tableData2: [],
standardAndPurchase: [],
basic: [],
groupAndPart: [],
groupAndPartBasic: [],
pageCurrent0: 1,
pageSize0: 20,
total0: 0,
pageCurrent1: 1,
pageSize1: 20,
total1: 0,
pageCurrent2: 1,
pageSize2: 20,
total2: 0
}
},
computed: {
...mapGetters([
'name',
'id'
])
},
created() {
this.searchTable0() // 查表1
this.fetchData() // 初始化数据
},
methods: {
filterSource(value, row) {
return Number(row['零件类型']) === Number(value)
}
], // 物料状态
personValue: '',
person: [],
check1: 0,
check2: 0,
check3: 0,
check4: 0,
tableData0: [],
tableData1: [],
tableData2: [],
standardAndPurchase: [],
basic: [],
groupAndPart: [],
groupAndPartBasic: [],
pageCurrent0: 1,
pageSize0: 20,
total0: 0,
pageCurrent1: 1,
pageSize1: 20,
total1: 0,
pageCurrent2: 1,
pageSize2: 20,
total2: 0
}
},
// 撤回
retract(row) {
this.$confirm('是否撤回重新分配?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.tabName === '基本件') {
retract2(row.基本件流水号).then(res => {
if (Number(res.data[0].result) === 1) {
this.$message.success('撤回成功')
this.searchTable2()
} else {
this.$message.error('撤回失败')
}
computed: {
...mapGetters([
'name',
'id'
])
},
created() {
this.searchTable0() // 查表1
this.fetchData() // 初始化数据
},
methods: {
filterSource(value, row) {
return Number(row['零件类型']) === Number(value)
},
// 撤回
retract(row) {
this.$confirm('是否撤回重新分配?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
if (this.tabName === '基本件') {
retract2(row.基本件流水号).then(res => {
if (Number(res.data[0].result) === 1) {
this.$message.success('撤回成功')
this.searchTable2()
} else {
this.$message.error('撤回失败')
}
})
} else {
retract1(row.标准件和外购件流水号).then(res => {
if (Number(res.data[0].result) === 1) {
this.$message.success('撤回成功')
this.searchTable0()
this.searchTable1()
} else {
this.$message.error('撤回失败')
}
})
}
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
},
fetchData() { // 初始化
initProject().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.project.push({
label: response.data[i].项目名称,
value: response.data[i].项目流水号
})
}
})
initBuyer().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.person.push({
text: response.data[i].姓名,
label: response.data[i].姓名,
value: response.data[i].人员编号
})
}
})
this.getSelect(initMaterialCategory, ['物料类别', '物料类别流水号'], 'MaterialCategory', [0, this.DepartmentValue])
},
projectChange() {
this.machine = []
this.machineValue = ''
this.group = []
this.groupValue = ''
searchMachine(this.projectValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.machine.push({
value: response.data[i].机床流水号,
label: response.data[i].机床图号,
name: response.data[i].机床名称
})
}
})
},
machineChange() {
this.group = []
this.groupValue = ''
searchGroup(this.machineValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.group.push({
value: response.data[i].组件流水号,
label: response.data[i].组号
})
}
})
},
searchMaterialVariety() { // 初始化物料品种
this.MaterialVariety = []
this.MaterialVarietyValue = ''
this.getSelect(initMaterialVariety, ['物料品种', '物料品种流水号'], 'MaterialVariety', this.MaterialCategoryValue)
},
searchTable0() { // 查询标准件
this.MaterialCategoryValue ? this.check1 = 1 : this.check1 = 0
this.MaterialVarietyValue ? this.check2 = 1 : this.check2 = 0
this.projectValue ? this.check3 = 1 : this.check3 = 0
let check0, check1, check2, check3
this.machineValue ? check0 = 1 : check0 = 0
this.groupValue ? check1 = 1 : check1 = 0
this.materialName ? this.check4 = 1 : this.check4 = 0
this.materialSpec ? check2 = 1 : check2 = 0
this.materialModel ? check3 = 1 : check3 = 0
searchTable1(this.pageCurrent0, this.pageSize0, this.check1, this.MaterialCategoryValue, this.check2, this.MaterialVarietyValue, this.check3, this.projectValue, check0, this.machineValue, check1, this.groupValue, this.check4, this.materialName, this.materialStatusValue[this.materialStatusValue.length - 1], check2, this.materialSpec, check3, this.materialModel, 1).then(response => {
this.tableData0 = response.data.rows
this.total0 = response.data.total
})
},
searchTable1() { // 查询外购件
this.MaterialCategoryValue ? this.check1 = 1 : this.check1 = 0
this.MaterialVarietyValue ? this.check2 = 1 : this.check2 = 0
this.projectValue ? this.check3 = 1 : this.check3 = 0
let check0, check1, check2, check3
this.machineValue ? check0 = 1 : check0 = 0
this.groupValue ? check1 = 1 : check1 = 0
this.materialName ? this.check4 = 1 : this.check4 = 0
this.materialSpec ? check2 = 1 : check2 = 0
this.materialModel ? check3 = 1 : check3 = 0
searchTable1(this.pageCurrent1, this.pageSize1, this.check1, this.MaterialCategoryValue, this.check2, this.MaterialVarietyValue, this.check3, this.projectValue, check0, this.machineValue, check1, this.groupValue, this.check4, this.materialName, this.materialStatusValue[this.materialStatusValue.length - 1], check2, this.materialSpec, check3, this.materialModel, 2).then(response => {
this.tableData1 = response.data.rows
this.total1 = response.data.total
})
},
searchTable2() { // 查询基本件
this.projectValue ? this.check3 = 1 : this.check3 = 0
let check1, check2, check3, check4, check5, check6
this.partNum ? check1 = 1 : check1 = 0
this.partName ? check2 = 1 : check2 = 0
this.partSpec ? check3 = 1 : check3 = 0
this.partMaterial ? check4 = 1 : check4 = 0
this.machineValue ? check5 = 1 : check5 = 0
this.groupValue ? check6 = 1 : check6 = 0
searchTable2(this.pageCurrent2, this.pageSize2, this.check3, this.projectValue, check5, this.machineValue, check6, this.groupValue, this.materialStatusValue[this.materialStatusValue.length - 1], check1, this.partNum, check2, this.partName, check3, this.partSpec, check4, this.partMaterial).then(response => {
this.tableData2 = response.data.rows
this.total2 = response.data.total
})
},
handleSelectionChange1(val) { // 标准件和外购件多选
this.standardAndPurchase = []
this.groupAndPart = []
for (let i = 0; i < val.length; i++) {
this.standardAndPurchase.push(val[i].标准件和外购件流水号)
this.groupAndPart.push(val[i].组件零件流水号)
}
},
handleSelectionChange2(val) { // 基本件多选
this.basic = []
this.groupAndPartBasic = []
for (let i = 0; i < val.length; i++) {
this.basic.push(val[i].基本件流水号)
this.groupAndPartBasic.push(val[i].组件零件基本件流水号)
}
},
selectable(row) { // 多选禁用
return row.人员编号 === '' || row.人员编号 === null
},
allocateTask1() { // 标准件和外购件分配任务
if (!this.personValue) {
this.$message.error('请选择采购员')
} else if (this.standardAndPurchase.length === 0) {
this.$message.error('请选择需分配的物料')
} else {
retract1(row.标准件和外购件流水号).then(res => {
if (Number(res.data[0].result) === 1) {
this.$message.success('撤回成功')
this.searchTable0()
this.searchTable1()
} else {
this.$message.error('撤回失败')
}
this.$confirm('此操作执行后不可修改,是否确定分配?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
allocateTask1(this.standardAndPurchase, this.personValue).then(response => {
if (response.data[0].result === '1') {
this.$message.success('操作成功')
this.searchTable0()
this.searchTable1()
} else { this.$message.error('操作失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
}
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
},
fetchData() { // 初始化
initProject().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.project.push({
label: response.data[i].项目名称,
value: response.data[i].项目流水号
},
allocateTask2() { // 基本件分配任务
if (!this.personValue) {
this.$message.error('请选择采购员')
} else if (this.basic.length === 0) {
this.$message.error('请选择需分配的零件')
} else {
this.$confirm('此操作执行后不可修改,是否确定分配?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
allocateTask2(this.basic, this.personValue).then(response => {
if (response.data[0].result === '1') {
this.$message.success('操作成功')
this.searchTable2()
} else { this.$message.error('操作失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
}
})
initBuyer().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.person.push({
text: response.data[i].姓名,
label: response.data[i].姓名,
value: response.data[i].人员编号
},
filterHandler(value, row) {
return parseInt(row['人员编号']) === parseInt(value)
},
handleSizeChange0(val) {
this.pageSize0 = val
this.pageCurrent0 = 1
this.searchTable0()
},
handleCurrentChange0(val) {
this.pageCurrent0 = val
this.searchTable0()
},
handleSizeChange1(val) {
this.pageSize1 = val
this.pageCurrent1 = 1
this.searchTable1()
},
handleCurrentChange1(val) {
this.pageCurrent1 = val
this.searchTable1()
},
handleSizeChange2(val) {
this.pageSize2 = val
this.pageCurrent2 = 1
this.searchTable2()
},
handleCurrentChange2(val) {
this.pageCurrent2 = val
this.searchTable2()
},
executeReturn1() { // 退回标准件和外购件
if (this.standardAndPurchase.length === 0) {
this.$message.error('请选择需退回的物料')
} else {
this.$confirm('此操作执行后不可修改,是否确定退回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
executeReturn1(this.standardAndPurchase, this.groupAndPart).then(response => {
if (response.data[0].result === '1') {
this.$message.success('操作成功')
this.searchTable0()
this.searchTable1()
} else { this.$message.error('操作失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
}
})
this.getSelect(initMaterialCategory, ['物料类别', '物料类别流水号'], 'MaterialCategory', [0, this.DepartmentValue])
},
projectChange() {
this.machine = []
this.machineValue = ''
this.group = []
this.groupValue = ''
searchMachine(this.projectValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.machine.push({
value: response.data[i].机床流水号,
label: response.data[i].机床图号,
name: response.data[i].机床名称
},
executeReturn2() { // 退回基本件
if (this.basic.length === 0) {
this.$message.error('请选择需退回的零件')
} else {
this.$confirm('此操作执行后不可修改,是否确定退回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
executeReturn2(this.basic, this.groupAndPartBasic).then(response => {
if (response.data[0].result === '1') {
this.$message.success('操作成功')
this.searchTable2()
} else { this.$message.error('操作失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
}
})
},
machineChange() {
this.group = []
this.groupValue = ''
searchGroup(this.machineValue).then(response => {
for (let i = 0; i < response.data.length; i++) {
this.group.push({
value: response.data[i].组件流水号,
label: response.data[i].组号
})
}
})
},
searchMaterialVariety() { // 初始化物料品种
this.MaterialVariety = []
this.MaterialVarietyValue = ''
this.getSelect(initMaterialVariety, ['物料品种', '物料品种流水号'], 'MaterialVariety', this.MaterialCategoryValue)
},
searchTable0() { // 查询标准件
this.MaterialCategoryValue ? this.check1 = 1 : this.check1 = 0
this.MaterialVarietyValue ? this.check2 = 1 : this.check2 = 0
this.projectValue ? this.check3 = 1 : this.check3 = 0
let check0, check1, check2, check3
this.machineValue ? check0 = 1 : check0 = 0
this.groupValue ? check1 = 1 : check1 = 0
this.materialName ? this.check4 = 1 : this.check4 = 0
this.materialSpec ? check2 = 1 : check2 = 0
this.materialModel ? check3 = 1 : check3 = 0
searchTable1(this.pageCurrent0, this.pageSize0, this.check1, this.MaterialCategoryValue, this.check2, this.MaterialVarietyValue, this.check3, this.projectValue, check0, this.machineValue, check1, this.groupValue, this.check4, this.materialName, this.materialStatusValue[this.materialStatusValue.length - 1], check2, this.materialSpec, check3, this.materialModel, 1).then(response => {
this.tableData0 = response.data.rows
this.total0 = response.data.total
})
},
searchTable1() { // 查询外购件
this.MaterialCategoryValue ? this.check1 = 1 : this.check1 = 0
this.MaterialVarietyValue ? this.check2 = 1 : this.check2 = 0
this.projectValue ? this.check3 = 1 : this.check3 = 0
let check0, check1, check2, check3
this.machineValue ? check0 = 1 : check0 = 0
this.groupValue ? check1 = 1 : check1 = 0
this.materialName ? this.check4 = 1 : this.check4 = 0
this.materialSpec ? check2 = 1 : check2 = 0
this.materialModel ? check3 = 1 : check3 = 0
searchTable1(this.pageCurrent1, this.pageSize1, this.check1, this.MaterialCategoryValue, this.check2, this.MaterialVarietyValue, this.check3, this.projectValue, check0, this.machineValue, check1, this.groupValue, this.check4, this.materialName, this.materialStatusValue[this.materialStatusValue.length - 1], check2, this.materialSpec, check3, this.materialModel, 2).then(response => {
this.tableData1 = response.data.rows
this.total1 = response.data.total
})
},
searchTable2() { // 查询基本件
this.projectValue ? this.check3 = 1 : this.check3 = 0
let check1, check2, check3, check4, check5, check6
this.partNum ? check1 = 1 : check1 = 0
this.partName ? check2 = 1 : check2 = 0
this.partSpec ? check3 = 1 : check3 = 0
this.partMaterial ? check4 = 1 : check4 = 0
this.machineValue ? check5 = 1 : check5 = 0
this.groupValue ? check6 = 1 : check6 = 0
searchTable2(this.pageCurrent2, this.pageSize2, this.check3, this.projectValue, check5, this.machineValue, check6, this.groupValue, this.materialStatusValue[this.materialStatusValue.length - 1], check1, this.partNum, check2, this.partName, check3, this.partSpec, check4, this.partMaterial).then(response => {
this.tableData2 = response.data.rows
this.total2 = response.data.total
})
},
handleSelectionChange1(val) { // 标准件和外购件多选
this.standardAndPurchase = []
this.groupAndPart = []
for (let i = 0; i < val.length; i++) {
this.standardAndPurchase.push(val[i].标准件和外购件流水号)
this.groupAndPart.push(val[i].组件零件流水号)
}
},
handleSelectionChange2(val) { // 基本件多选
this.basic = []
this.groupAndPartBasic = []
for (let i = 0; i < val.length; i++) {
this.basic.push(val[i].基本件流水号)
this.groupAndPartBasic.push(val[i].组件零件基本件流水号)
}
},
selectable(row) { // 多选禁用
return row.人员编号 === '' || row.人员编号 === null
},
allocateTask1() { // 标准件和外购件分配任务
if (!this.personValue) {
this.$message.error('请选择采购员')
} else if (this.standardAndPurchase.length === 0) {
this.$message.error('请选择需分配的物料')
} else {
this.$confirm('此操作执行后不可修改,是否确定分配?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
allocateTask1(this.standardAndPurchase, this.personValue).then(response => {
if (response.data[0].result === '1') {
this.$message.success('操作成功')
this.searchTable0()
this.searchTable1()
} else { this.$message.error('操作失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
}
},
allocateTask2() { // 基本件分配任务
if (!this.personValue) {
this.$message.error('请选择采购员')
} else if (this.basic.length === 0) {
this.$message.error('请选择需分配的零件')
} else {
this.$confirm('此操作执行后不可修改,是否确定分配?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
allocateTask2(this.basic, this.personValue).then(response => {
if (response.data[0].result === '1') {
this.$message.success('操作成功')
this.searchTable2()
} else { this.$message.error('操作失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
}
},
filterHandler(value, row) {
return parseInt(row['人员编号']) === parseInt(value)
},
handleSizeChange0(val) {
this.pageSize0 = val
this.pageCurrent0 = 1
this.searchTable0()
},
handleCurrentChange0(val) {
this.pageCurrent0 = val
this.searchTable0()
},
handleSizeChange1(val) {
this.pageSize1 = val
this.pageCurrent1 = 1
this.searchTable1()
},
handleCurrentChange1(val) {
this.pageCurrent1 = val
this.searchTable1()
},
handleSizeChange2(val) {
this.pageSize2 = val
this.pageCurrent2 = 1
this.searchTable2()
},
handleCurrentChange2(val) {
this.pageCurrent2 = val
this.searchTable2()
},
executeReturn1() { // 退回标准件和外购件
if (this.standardAndPurchase.length === 0) {
this.$message.error('请选择需退回的物料')
} else {
this.$confirm('此操作执行后不可修改,是否确定退回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
executeReturn1(this.standardAndPurchase, this.groupAndPart).then(response => {
if (response.data[0].result === '1') {
this.$message.success('操作成功')
this.searchTable0()
this.searchTable1()
} else { this.$message.error('操作失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
}
},
executeReturn2() { // 退回基本件
if (this.basic.length === 0) {
this.$message.error('请选择需退回的零件')
} else {
this.$confirm('此操作执行后不可修改,是否确定退回?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
executeReturn2(this.basic, this.groupAndPartBasic).then(response => {
if (response.data[0].result === '1') {
this.$message.success('操作成功')
this.searchTable2()
} else { this.$message.error('操作失败') }
})
}).catch(() => {
this.$message({
type: 'info',
message: '已取消操作'
})
})
}
}
}
}
</script>
<style scoped>