This commit is contained in:
zhangdingyu
2019-06-13 10:54:52 +08:00
parent 195fc311ab
commit 2c4709dcde
4 changed files with 1773 additions and 1773 deletions

View File

@@ -219,240 +219,240 @@
</template> </template>
<script> <script>
import { initPickPerson, initMachineProject, searchgroup, searchList, searchListDetail, searchStockNumber1, searchStockNumber2, submitOutStore, errorRecord, searchStockNumber3, initOutType } from '@/api/Inventory/MaterialOut' import { initPickPerson, initMachineProject, searchgroup, searchList, searchListDetail, searchStockNumber1, searchStockNumber2, submitOutStore, errorRecord, searchStockNumber3, initOutType } from '@/api/Inventory/MaterialOut'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
export default { export default {
name: 'MaterialOut', name: 'MaterialOut',
data() { data() {
return { return {
pickingListNum: '', // 领料单流水号 pickingListNum: '', // 领料单流水号
pickingPersonNum: '', // 领料人流水号 pickingPersonNum: '', // 领料人流水号
pickingListNumber: '', pickingListNumber: '',
pickingListNumberShow: '', pickingListNumberShow: '',
pickListTable1: [], pickListTable1: [],
pageCurrent3: 1, pageCurrent3: 1,
pageSize3: 20, pageSize3: 20,
total3: 0, total3: 0,
pickListTable2: [], pickListTable2: [],
StockNumberTable: [], StockNumberTable: [],
dialogFormVisible1: false, dialogFormVisible1: false,
dialogFormVisible2: false, dialogFormVisible2: false,
outType: [], outType: [],
form1: { form1: {
machineValue: '', machineValue: '',
groupNumValue: '', groupNumValue: '',
outNumber: '', outNumber: '',
outNumberMax: '', // 出库最大值 outNumberMax: '', // 出库最大值
personValue: '', personValue: '',
outTypeValue: '' // 出库类别 outTypeValue: '' // 出库类别
}, },
form2: { form2: {
errorNumber: '', errorNumber: '',
reason: '', reason: '',
物料流水号: '', 物料流水号: '',
基本件流水号: '', 基本件流水号: '',
货位流水号: '' 货位流水号: ''
}, },
rules1: { rules1: {
machineValue: [{ required: true, message: '请选择' }], machineValue: [{ required: true, message: '请选择' }],
groupNumValue: [{ required: true, message: '请选择' }], groupNumValue: [{ required: true, message: '请选择' }],
outNumber: [{ required: true, message: '请输入' }], outNumber: [{ required: true, message: '请输入' }],
personValue: [{ required: true, message: '请输入' }], personValue: [{ required: true, message: '请输入' }],
outTypeValue: [{ required: true, message: '请选择' }] // 出库类别 outTypeValue: [{ required: true, message: '请选择' }] // 出库类别
}, },
rules2: { rules2: {
errorNumber: [{ required: true, message: '请输入' }], errorNumber: [{ required: true, message: '请输入' }],
reason: [{ required: true, message: '请输入' }] reason: [{ required: true, message: '请输入' }]
}, },
machine: [], machine: [],
group: [], group: [],
person: [], person: [],
materialNum: '', // 中间变量物料流水号 materialNum: '', // 中间变量物料流水号
machineValue: '', // 中间变量机床流水号 machineValue: '', // 中间变量机床流水号
groupNumValue: '', // 中间变量组件流水号 groupNumValue: '', // 中间变量组件流水号
basePartNum: '', // 中间变量基本件流水号 basePartNum: '', // 中间变量基本件流水号
purchaseBillNum: '', // 中间变量请购单明细流水号 purchaseBillNum: '', // 中间变量请购单明细流水号
parchasePartNum: '', // 中间变量标准件和外购件流水号 parchasePartNum: '', // 中间变量标准件和外购件流水号
inventoryNum: '', // 中间变量仓库流水号 inventoryNum: '', // 中间变量仓库流水号
locationNum: '', // 中间变量货位流水号 locationNum: '', // 中间变量货位流水号
outNumber: 0 // 中间变量出库数量 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].机床流水号
})
}
})
initOutType().then(response => {
for (let i = 0; i < response.data.length; i++) {
this.outType.push({
label: response.data[i].出库类别名称,
value: response.data[i].出库类别流水号
})
}
})
}, },
computed: { // 查询组号
...mapGetters([ searchGroup() {
'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].组件流水号)
})
}
})
}, },
mounted() { // 查询领料单列表
this.fetchData() 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() this.searchList()
}, },
methods: { handleCurrentChange3(val) {
// 初始化数据 this.pageCurrent3 = val
fetchData() { this.searchList()
this.person = [] },
initPickPerson().then(response => { // 查看领料单明细
for (let i = 0; i < response.data.length; i++) { clickList(row) {
this.person.push({ row && row.领料单流水号 ? this.pickingListNum = row.领料单流水号 : this.pickingListNum
label: response.data[i].姓名, row && row.人员编号 ? this.pickingPersonNum = row.人员编号 : this.pickingListNum
value: response.data[i].人员编号 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
}) })
this.machine = [] } else if (this.basePartNum) {
initMachineProject().then(response => { searchStockNumber2(this.basePartNum).then(res => {
for (let i = 0; i < response.data.length; i++) { this.StockNumberTable = res.data
this.machine.push({
label: response.data[i].机床图号,
name: response.data[i].项目名称,
value: response.data[i].机床流水号
})
}
}) })
initOutType().then(response => { } else if (this.purchaseBillNum) {
for (let i = 0; i < response.data.length; i++) { searchStockNumber3(this.purchaseBillNum).then(res => {
this.outType.push({ this.StockNumberTable = res.data
label: response.data[i].出库类别名称,
value: 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
})
}
},
// 出库
outStore(row) {
if (this.$refs['form1'] !== undefined) {
this.$refs['form1'].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
}
}) })
} }
},
// 出库
outStore(row) {
if (this.$refs['form1'] !== undefined) {
this.$refs['form1'].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
}
})
} }
} }
}
</script> </script>
<style scoped> <style scoped>

File diff suppressed because it is too large Load Diff

View File

@@ -184,236 +184,236 @@
</template> </template>
<script> <script>
import Tinymce from '@/components/Tinymce' import Tinymce from '@/components/Tinymce'
import { initSupplier, searchInquirySheet, searchSheetContract, doneContract, searchBaseInfo, savePrice } from '@/api/PurchasingCenter/CreatePurchaseContract' import { initSupplier, searchInquirySheet, searchSheetContract, doneContract, searchBaseInfo, savePrice } from '@/api/PurchasingCenter/CreatePurchaseContract'
import { convertCurrency } from '@/vendor/int2Chinese' import { convertCurrency } from '@/vendor/int2Chinese'
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import { sleep, groupBy } from '@/utils/tool' import { sleep, groupBy } from '@/utils/tool'
import $ from 'jquery' import $ from 'jquery'
export default { export default {
components: { Tinymce }, components: { Tinymce },
inject: ['reload'], inject: ['reload'],
data() { data() {
return { return {
supplier: [], supplier: [],
year: '', year: '',
month: '', month: '',
day: '', day: '',
trustee: '', // 受托人 trustee: '', // 受托人
bank1: '', bank1: '',
account1: '', account1: '',
taxCode1: '', taxCode1: '',
phone1: '', phone1: '',
fax1: '', fax1: '',
postCode1: '', postCode1: '',
bank2: '', bank2: '',
account2: '', account2: '',
taxCode2: '', taxCode2: '',
phone2: '', phone2: '',
fax2: '', fax2: '',
postCode2: '', postCode2: '',
hasTax: '含税', hasTax: '含税',
taxRate: 0.13, taxRate: 0.13,
preview: false, // 预览 preview: false, // 预览
demoRadio: '', // 模板radio demoRadio: '', // 模板radio
content: ``, // 合同格式模板 content: ``, // 合同格式模板
contentNew: ``, // tinymce的 contentNew: ``, // tinymce的
contractName: '采购合同', // 合同名称 contractName: '采购合同', // 合同名称
contractNum: '', // 合同编号 contractNum: '', // 合同编号
contractNums: [], // 合同编号数组 contractNums: [], // 合同编号数组
contractNumValue: '', // 合同流水号 contractNumValue: '', // 合同流水号
supplierName: '', // 供应商名称 supplierName: '', // 供应商名称
supplierValue: '', // 供应商流水号 supplierValue: '', // 供应商流水号
supplierAddress: '', // 供应商地址 supplierAddress: '', // 供应商地址
legalPerson: '', // 法人 legalPerson: '', // 法人
untaxTotal: '', // 未税合计 untaxTotal: '', // 未税合计
tax: '', // 税额 tax: '', // 税额
taxTotal: '', // 含税合计 taxTotal: '', // 含税合计
actualTotal: '', // 实际金额 actualTotal: '', // 实际金额
actualTotal_zh: '', // 实际金额大写 actualTotal_zh: '', // 实际金额大写
payDate: '', // 支付日期 payDate: '', // 支付日期
payMethod: '', // 支付方式 payMethod: '', // 支付方式
deliveryDate: '', // 交货日期 deliveryDate: '', // 交货日期
invoiceInfo: '', // 开票信息 invoiceInfo: '', // 开票信息
otherInfo: '', // 其他说明 otherInfo: '', // 其他说明
tableData1: [], tableData1: [],
单价是否含税: '', 单价是否含税: '',
组件零件流水号组: [], 组件零件流水号组: [],
组件零件基本件流水号组: [], 组件零件基本件流水号组: [],
数量组: [], 数量组: [],
单价组: [], 单价组: [],
交货期组: [] 交货期组: []
} }
}, },
computed: { computed: {
...mapGetters([ ...mapGetters([
'name', 'name',
'id' 'id'
]) ])
}, },
created() { created() {
this.fetchData() this.fetchData()
}, },
methods: { methods: {
// 价格实时保存 // 价格实时保存
priceChange(price, num1, num2, row) { priceChange(price, num1, num2, row) {
this.tableData1.map(v => { this.tableData1.map(v => {
if (Number(v.物料流水号) === Number(row.物料流水号) && Number(v.询价单流水号) === Number(row.询价单流水号)) { if (Number(v.物料流水号) === Number(row.物料流水号) && Number(v.询价单流水号) === Number(row.询价单流水号)) {
v.含税单价 = row.含税单价 v.含税单价 = 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() })
}, const group = this.tableData1
searchContractDetail() { // 查询合同明细 this.tableData1 = []
this.tableData1 = [] this.tableData1 = group
searchSheetContract(this.contractNumValue).then(response => { price = price || 0
for (let i = 0; i < response.data.length; i++) { savePrice(price, num1, num2).then(res => {
this.tableData1.push({ if (res.data[0].result === '1') {
询价单流水号: response.data[i].询价单流水号, console.log('单价实时保存成功')
物料流水号: response.data[i].物料流水号, } else {
询价单明细流水号: response.data[i].询价单明细流水号, console.log('单价实时保存失败')
机床图号: response.data[i].机床图号, }
组号: response.data[i].组号, })
组件零件流水号: response.data[i].组件零件流水号, },
组件零件基本件流水号: response.data[i].组件零件基本件流水号, deleteAllDate() {
交货期: response.data[i].组件零件流水号 ? response.data[i].标准件和外购件交货期 : response.data[i].基本件交货期, this.tableData1.map(v => {
图号: response.data[i].组件零件流水号 ? response.data[i].物料型号 : response.data[i].零件图号, v.交货期 = ''
名称: response.data[i].组件零件流水号 ? response.data[i].物料名称 : response.data[i].零件名称, })
规格: response.data[i].组件零件流水号 ? response.data[i].物料规格 : response.data[i].规格, },
数量: response.data[i].数量, fetchData() {
计量单位: response.data[i].计量单位, initSupplier(this.id).then(res => {
未税单价: response.data[i].单价, this.supplier = []
未税总额: 0, for (let i = 0; i < res.data.length; i++) {
含税单价: response.data[i].单价, this.supplier.push({
含税总额: 0, value: res.data[i].供应商流水号,
备注: response.data[i].备注 label: res.data[i].供应商名称
}) })
} }
}) })
}, searchBaseInfo(this.id).then(res => {
demoChange() { // 模板change this.fax2 = res.data[0] ? res.data[0].传真 : ''
switch (this.demoRadio) { this.postCode2 = '224053'
case '模板1': this.phone2 = res.data[0] ? res.data[0].手机 + '/' + res.data[0].公司电话 : ''
this.demo1() this.taxCode2 = res.data[0] ? res.data[0].税号 : ''
break this.account2 = res.data[0] ? res.data[0].帐号 : ''
case '模板2': this.bank2 = res.data[0] ? res.data[0].开户行 : ''
this.demo2() })
break 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 '自定义': // case '自定义':
// this.customization() // this.customization()
// break // break
} }
}, },
demo1() { // 选择合同模板1 demo1() { // 选择合同模板1
this.content = ` this.content = `
<h2 style="text-align: center;"> <h2 style="text-align: center;">
<strong>采购合同</strong> <strong>采购合同</strong>
</h2> </h2>
@@ -559,161 +559,161 @@
<span>含税总价(税率<span id="taxRate"></span></span><span id="taxTotal"></span><span>元</span><br> <span>含税总价(税率<span id="taxRate"></span></span><span id="taxTotal"></span><span>元</span><br>
<span>优惠后含税总价:</span><span class="actualTotal"></span><span>元</span> <span>优惠后含税总价:</span><span class="actualTotal"></span><span>元</span>
` `
}, },
async editContract() { // 选择一个询价单,整成合同明细 async editContract() { // 选择一个询价单,整成合同明细
const date = new Date() const date = new Date()
this.year = date.getFullYear() this.year = date.getFullYear()
this.month = date.getMonth() + 1 this.month = date.getMonth() + 1
this.day = date.getDate() this.day = date.getDate()
this.demoChange() this.demoChange()
await sleep(0) await sleep(0)
if (this.contractNumValue) { if (this.contractNumValue) {
if (this.demoRadio) { if (this.demoRadio) {
this.$refs.tinymce.destroyTinymce() this.$refs.tinymce.destroyTinymce()
document.getElementById('contractName') ? document.getElementById('contractName').innerHTML = this.contractName : '' document.getElementById('contractName') ? document.getElementById('contractName').innerHTML = this.contractName : ''
document.getElementById('contractNum') ? document.getElementById('contractNum').innerHTML = this.contractNum : '' document.getElementById('contractNum') ? document.getElementById('contractNum').innerHTML = this.contractNum : ''
document.getElementById('supplierName') ? document.getElementById('supplierName').innerHTML = this.supplierName : '' document.getElementById('supplierName') ? document.getElementById('supplierName').innerHTML = this.supplierName : ''
document.getElementById('supplierAddress') ? document.getElementById('supplierAddress').innerHTML = this.supplierAddress : '' document.getElementById('supplierAddress') ? document.getElementById('supplierAddress').innerHTML = this.supplierAddress : ''
document.getElementById('legalPerson') ? document.getElementById('legalPerson').innerHTML = this.legalPerson : '' document.getElementById('legalPerson') ? document.getElementById('legalPerson').innerHTML = this.legalPerson : ''
document.getElementById('payDate') ? document.getElementById('payDate').innerHTML = this.payDate : '' document.getElementById('payDate') ? document.getElementById('payDate').innerHTML = this.payDate : ''
document.getElementById('payMethod') ? document.getElementById('payMethod').innerHTML = this.payMethod : '' document.getElementById('payMethod') ? document.getElementById('payMethod').innerHTML = this.payMethod : ''
document.getElementById('invoiceInfo') ? document.getElementById('invoiceInfo').innerHTML = this.invoiceInfo : '' document.getElementById('invoiceInfo') ? document.getElementById('invoiceInfo').innerHTML = this.invoiceInfo : ''
document.getElementById('deliveryDate') ? document.getElementById('deliveryDate').innerHTML = this.deliveryDate : '' document.getElementById('deliveryDate') ? document.getElementById('deliveryDate').innerHTML = this.deliveryDate : ''
document.getElementById('otherInfo') ? document.getElementById('otherInfo').innerHTML = this.otherInfo : '' document.getElementById('otherInfo') ? document.getElementById('otherInfo').innerHTML = this.otherInfo : ''
document.getElementById('hasTax') ? document.getElementById('hasTax').innerHTML = this.hasTax : '' document.getElementById('hasTax') ? document.getElementById('hasTax').innerHTML = this.hasTax : ''
document.getElementById('taxRate') ? document.getElementById('taxRate').innerHTML = this.taxRate * 100 + '%' : '' document.getElementById('taxRate') ? document.getElementById('taxRate').innerHTML = this.taxRate * 100 + '%' : ''
// 明细表 // 明细表
// 移出旧数据 // 移出旧数据
const children = document.getElementsByClassName('tableData') const children = document.getElementsByClassName('tableData')
const parent = document.getElementById('tbody') const parent = document.getElementById('tbody')
if (children.length !== 0) { if (children.length !== 0) {
for (let i = children.length - 1; i >= 0; i--) { for (let i = children.length - 1; i >= 0; i--) {
parent.removeChild(children[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('请先选择合同模板,再预览')
} }
} else { const merge = []
this.$message.warning('请先选择合同,再预览') this.tableData1.map(v => {
} if ((this.hasTax === '含税' && Number(v.含税单价)) || (this.hasTax === '未税' && Number(v.未税单价))) { // 筛掉未询到价格的物料
}, merge.push({
demo2() { 机床图号: v.机床图号,
this.content = `demo2` 组号: v.组号,
}, 图号: v.图号,
// customization() { // 自定义 名称: v.名称,
// this.content = `自定义` 规格: v.规格,
// }, 数量: Number(v.数量),
generateContract() { // 生成采购合同 计量单位: v.计量单位,
this.content = this.contentNew.replace(/&nbsp;/g, '') 单价: this.hasTax === '含税' ? v.含税单价 : v.未税单价,
this.content = this.content.replace(/\n/g, '') 合计: (Number(v.数量) * (this.hasTax === '含税' ? Number(v.含税单价) : Number(v.未税单价))).toFixed(2),
this.content = this.content.replace(/==/g, '= =') // 更新tinymce中的东西到html中后续会用到 交货期: v.交货期 ? v.交货期.split(' ')[0] : '',
this.组件零件流水号组 = [] 备注: v.备注
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 { } 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
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: '已取消操作'
})
})
} else {
this.$message.warning('请先选择合同进行编辑')
} }
} }
} }
}
</script> </script>
<style scoped> <style scoped>

View File

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