维修导入功能
This commit is contained in:
parent
c18977b826
commit
32b343b1cb
|
|
@ -129,6 +129,16 @@ export function exportLeaseAll(data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//新增维修导入信息
|
||||||
|
export function addRepairInputInfoApi(data) {
|
||||||
|
return request({
|
||||||
|
url: '/material/purchaseCheckInfo/addRepairInputInfo',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,10 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="协议号" prop="agreementCode">
|
||||||
|
<el-input maxlength="50" v-model="repairParams.agreementCode" disabled style="width: 240px"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="规格型号" prop="equipmentId">
|
<el-form-item label="规格型号" prop="equipmentId">
|
||||||
<el-cascader
|
<el-cascader
|
||||||
:key="propsKey"
|
:key="propsKey"
|
||||||
|
|
@ -58,8 +62,7 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<el-table v-loading="loading" :data="equipmentList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="equipmentList" >>
|
||||||
<el-table-column type="selection" width="55" align="center" />
|
|
||||||
<el-table-column align="center" label="序号" type="index" width="55" />
|
<el-table-column align="center" label="序号" type="index" width="55" />
|
||||||
<el-table-column
|
<el-table-column
|
||||||
align="center"
|
align="center"
|
||||||
|
|
@ -68,8 +71,19 @@
|
||||||
show-overflow-tooltip
|
show-overflow-tooltip
|
||||||
></el-table-column>
|
></el-table-column>
|
||||||
<el-table-column align="center" label="规格型号" prop="specificationType" show-overflow-tooltip />
|
<el-table-column align="center" label="规格型号" prop="specificationType" show-overflow-tooltip />
|
||||||
<el-table-column align="center" label="单位" prop="unitName" />
|
<el-table-column align="center" label="计量单位" prop="unitName" />
|
||||||
<el-table-column align="center" label="维修配件名称" prop="partModelName" width="180">
|
<el-table-column align="center" label="维修配件名称" prop="partName" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-input
|
||||||
|
maxlength="100"
|
||||||
|
v-model="scope.row.partName"
|
||||||
|
placeholder="请输入"
|
||||||
|
clearable
|
||||||
|
style="width: 100%"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="维修配件型号" align="center" prop="partModelName" width="180">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input
|
<el-input
|
||||||
maxlength="100"
|
maxlength="100"
|
||||||
|
|
@ -80,24 +94,14 @@
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="维修配件型号" align="center" prop="partTypeName" width="180">
|
<el-table-column label="使用数量" align="center" prop="partNum">
|
||||||
<template slot-scope="scope">
|
|
||||||
<el-input
|
|
||||||
maxlength="100"
|
|
||||||
v-model="scope.row.partTypeName"
|
|
||||||
placeholder="请输入"
|
|
||||||
clearable
|
|
||||||
style="width: 100%"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="使用数量" align="center" prop="useNum">
|
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input-number
|
<el-input-number
|
||||||
type="number"
|
type="number"
|
||||||
:min="1"
|
:min="1"
|
||||||
clearable
|
:precision="0"
|
||||||
v-model.number="scope.row.useNum"
|
v-model.number="scope.row.partNum"
|
||||||
|
@change="calculateTotalPrice(scope.row)"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
></el-input-number>
|
></el-input-number>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -105,21 +109,21 @@
|
||||||
<el-table-column label="配件单价" align="center" prop="partPrice" >
|
<el-table-column label="配件单价" align="center" prop="partPrice" >
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input
|
<el-input
|
||||||
|
type="number"
|
||||||
maxlength="100"
|
maxlength="100"
|
||||||
v-model="scope.row.partPrice"
|
v-model.number="scope.row.partPrice"
|
||||||
placeholder="请输入"
|
placeholder="请输入"
|
||||||
clearable
|
@input="calculateTotalPrice(scope.row)"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="配件总价" align="center" prop="partCost">
|
<el-table-column label="配件总价" align="center" prop="partAllCosts">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-input
|
<el-input
|
||||||
maxlength="100"
|
:value="scope.row.partAllCosts || '0.00'"
|
||||||
v-model="scope.row.partCost"
|
placeholder="自动计算"
|
||||||
placeholder="请输入"
|
readonly
|
||||||
clearable
|
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -166,9 +170,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { addPurchaseCheckInfo, getPurchaseCheckInfo, updatePurchaseCheckInfo } from '@/api/store/newBuy'
|
import { getUnitList, getAgreementInfoById, } from '@/api/claimAndRefund/receive'
|
||||||
|
import { getProjectListByUnitIds,addRepairInputInfoApi } from '@/api/cost/cost'
|
||||||
import { getUserByRoleList } from '@/api/system/user'
|
import { getUserByRoleList } from '@/api/system/user'
|
||||||
import { equipmentTypeTree, supplierInfoList, listSupplierInfo } from '@/api/store/tools'
|
import { equipmentTypeTree, } from '@/api/store/tools'
|
||||||
import Treeselect from '@riophae/vue-treeselect'
|
import Treeselect from '@riophae/vue-treeselect'
|
||||||
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
||||||
import HoldingpoleDialog from '@/components/HoldingpoleDialog/index.vue'
|
import HoldingpoleDialog from '@/components/HoldingpoleDialog/index.vue'
|
||||||
|
|
@ -180,24 +185,10 @@ export default {
|
||||||
name: 'RepairCostList',
|
name: 'RepairCostList',
|
||||||
dicts: ['sys_normal_disable'],
|
dicts: ['sys_normal_disable'],
|
||||||
components: { Treeselect, HoldingpoleDialog },
|
components: { Treeselect, HoldingpoleDialog },
|
||||||
props: {
|
|
||||||
isEdit: {
|
|
||||||
type: Boolean,
|
|
||||||
default: () => {
|
|
||||||
return false
|
|
||||||
},
|
|
||||||
},
|
|
||||||
editTaskId: {
|
|
||||||
type: [String, Number],
|
|
||||||
default: () => {
|
|
||||||
return ''
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
actionUrlPic: process.env.VUE_APP_BASE_API + '/system/sys/file/upload',
|
actionUrlPic: process.env.VUE_APP_BASE_API + '/system/sys/file/upload',
|
||||||
actionUrl: process.env.VUE_APP_BASE_API + '/material/purchaseCheckInfo/importData',
|
actionUrl: process.env.VUE_APP_BASE_API + '/material/purchaseCheckInfo/importRepairData',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: 'Bearer ' + localStorage.getItem('token'),
|
Authorization: 'Bearer ' + localStorage.getItem('token'),
|
||||||
},
|
},
|
||||||
|
|
@ -333,6 +324,7 @@ export default {
|
||||||
repairParams: {
|
repairParams: {
|
||||||
unitId: '',
|
unitId: '',
|
||||||
projectId: '',
|
projectId: '',
|
||||||
|
agreementCode: '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -350,7 +342,7 @@ export default {
|
||||||
created() {
|
created() {
|
||||||
|
|
||||||
this.getUnitList()
|
this.getUnitList()
|
||||||
this.getProjectList()
|
this.GetProData()
|
||||||
|
|
||||||
this.getUserList()
|
this.getUserList()
|
||||||
this.equipmentType()
|
this.equipmentType()
|
||||||
|
|
@ -358,35 +350,52 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
//获取结算单位下的结算工程
|
//获取结算单位下的结算工程
|
||||||
unitChange(val){
|
unitChange(val){
|
||||||
console.log("xxxxxxxxxx",val)
|
console.log("yyyyyyyyyyyyyyyyy",val)
|
||||||
if(!val){
|
this.repairParams.projectId = null;
|
||||||
console.log("yyyyyyyy")
|
|
||||||
this.queryParams.projectId = null;
|
|
||||||
this.queryParams.unitId = null
|
|
||||||
this.getUnitList()
|
|
||||||
this.getProjectList()
|
|
||||||
// this.GetProData()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setTimeout(()=>{
|
|
||||||
|
|
||||||
this.GetProData()
|
this.GetProData()
|
||||||
},500)
|
|
||||||
},
|
},
|
||||||
//获取结算工程下的结算单位
|
//获取结算工程下的结算单位
|
||||||
proChange(val){
|
proChange(val){
|
||||||
console.log("xxxxxxxxxx",val)
|
this.GetAgreementInfoById()
|
||||||
if(val.length==0){
|
|
||||||
setTimeout(()=>{
|
|
||||||
this.getUnitList()
|
|
||||||
},500)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setTimeout(()=>{
|
|
||||||
this.GetUnitData()
|
|
||||||
},500)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getUnitList() {
|
||||||
|
getUnitList().then((response) => {
|
||||||
|
this.unitList = response.data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async GetProData() {
|
||||||
|
const params = {
|
||||||
|
unitId: this.repairParams.unitId,
|
||||||
|
}
|
||||||
|
const res = await getProjectListByUnitIds(params)
|
||||||
|
this.projectList = res.data;
|
||||||
|
},
|
||||||
|
|
||||||
|
async GetAgreementInfoById() {
|
||||||
|
console.log("zzzzzzzzzzz",this.repairParams.unitId,this.repairParams.projectId)
|
||||||
|
if (this.repairParams.unitId && this.repairParams.projectId) {
|
||||||
|
const params = {
|
||||||
|
unitId: this.repairParams.unitId,
|
||||||
|
projectId: this.repairParams.projectId,
|
||||||
|
}
|
||||||
|
const res = await getAgreementInfoById(params)
|
||||||
|
if(res.data.agreementCode == null || res.data.agreementCode == '' || res.data.agreementCode == undefined){
|
||||||
|
this.$message({
|
||||||
|
message: '暂无协议',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
this.repairParams.agreementId = res.data.agreementId
|
||||||
|
this.repairParams.agreementCode = res.data.agreementCode
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/** 查询用户列表--采购员 */
|
/** 查询用户列表--采购员 */
|
||||||
getUserList() {
|
getUserList() {
|
||||||
getUserByRoleList({ roleIds: [152] }).then((response) => {
|
getUserByRoleList({ roleIds: [152] }).then((response) => {
|
||||||
|
|
@ -406,8 +415,7 @@ export default {
|
||||||
item3.children.forEach((item4) => {
|
item3.children.forEach((item4) => {
|
||||||
item4.machineTypeName = item3.typeName
|
item4.machineTypeName = item3.typeName
|
||||||
item4.specificationType = item4.typeName
|
item4.specificationType = item4.typeName
|
||||||
this.$set(item4, 'purchasePrice', 0)
|
this.$set(item4, 'partNum', 1)
|
||||||
this.$set(item4, 'purchaseNum', 1)
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -451,25 +459,6 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
//获取任务详情--- 编辑回显数据
|
|
||||||
getTaskInfo() {
|
|
||||||
// this.loading = true;
|
|
||||||
getPurchaseCheckInfo({
|
|
||||||
taskId: this.taskId,
|
|
||||||
keyWord: this.queryParams.keyWord,
|
|
||||||
}).then((response) => {
|
|
||||||
// this.taskInfo = response.data
|
|
||||||
this.maForm.purchaseTime = response.data.purchaseTime
|
|
||||||
this.maForm.arrivalTime = response.data.arrivalTime
|
|
||||||
this.maForm.purchaser = response.data.purchaser
|
|
||||||
this.maForm.remark = response.data.remark
|
|
||||||
this.maForm.purchaseNumber = response.data.purchaseNumber
|
|
||||||
this.equipmentList = response.data.checkDetailsList
|
|
||||||
|
|
||||||
// this.loading = false;
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
getParentsById(list, id) {
|
getParentsById(list, id) {
|
||||||
for (let i in list) {
|
for (let i in list) {
|
||||||
if (list[i].typeId == id) {
|
if (list[i].typeId == id) {
|
||||||
|
|
@ -489,13 +478,6 @@ export default {
|
||||||
|
|
||||||
/** 查询右侧列表 */
|
/** 查询右侧列表 */
|
||||||
getList() {
|
getList() {
|
||||||
// this.loading = true;
|
|
||||||
// listRole().then(response => {
|
|
||||||
// this.equipmentList = response.rows;
|
|
||||||
// this.total = response.total;
|
|
||||||
// this.loading = false;
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
},
|
},
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
|
|
@ -530,78 +512,62 @@ export default {
|
||||||
})
|
})
|
||||||
this.resetForm('form')
|
this.resetForm('form')
|
||||||
},
|
},
|
||||||
// 多选框选中数据
|
|
||||||
handleSelectionChange(selection) {
|
|
||||||
this.ids = selection.map((item) => item.roleId)
|
|
||||||
this.single = selection.length != 1
|
|
||||||
this.multiple = !selection.length
|
|
||||||
},
|
|
||||||
|
|
||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
handleSave() {
|
handleSave() {
|
||||||
|
if(this.repairParams.agreementId == null || this.repairParams.agreementId == '' || this.repairParams.agreementId == undefined){
|
||||||
|
this.$message({
|
||||||
|
message: '请选择协议号',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.equipmentList.length > 0) {
|
if (this.equipmentList.length > 0) {
|
||||||
this.$refs['maForm'].validate((valid) => {
|
|
||||||
if (valid) {
|
|
||||||
// console.log(this.maForm,'maForm')
|
|
||||||
// console.log(this.equipmentList,'equipmentList')
|
|
||||||
let isEmpty = true
|
|
||||||
this.equipmentList.forEach((item) => {
|
this.equipmentList.forEach((item) => {
|
||||||
if (item.purchaseNum == '' || !item.purchaseNum) {
|
if(!item.partName || !item.partModelName){
|
||||||
isEmpty = false
|
this.$message({
|
||||||
|
message: '请填写配件名称和配件型号',
|
||||||
|
type: 'error',
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const params = this.equipmentList.map((item) => {
|
||||||
|
return {
|
||||||
|
agreementId: this.repairParams.agreementId,
|
||||||
|
typeId: item.typeId,
|
||||||
|
partNum: item.partNum,
|
||||||
|
partPrice: item.partPrice,
|
||||||
|
partName: item.partName,
|
||||||
|
partModelName: item.partModelName,
|
||||||
|
partAllCosts: item.partAllCosts,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
// console.log(this.taskId)
|
|
||||||
|
|
||||||
this.maForm.taskId = this.taskId
|
|
||||||
this.maForm.checkDetailsList = this.equipmentList
|
|
||||||
// console.log(this.maForm)
|
|
||||||
if (isEmpty) {
|
|
||||||
if (this.equipmentList.length > 0) {
|
|
||||||
this.$modal
|
this.$modal
|
||||||
.confirm('是否确认保存当前页面')
|
.confirm('是否确认保存当前页面')
|
||||||
.then(function () {})
|
.then(function () {})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (this.isEdit) {
|
|
||||||
console.log('编辑')
|
|
||||||
this.loading = true
|
|
||||||
updatePurchaseCheckInfo(this.maForm).then((response) => {
|
|
||||||
if (response.code == 200) {
|
|
||||||
this.$modal.msgSuccess('编辑成功')
|
|
||||||
// this.$tab.closeOpenPage({
|
|
||||||
// path: '/store/newBuy/newDevicesList',
|
|
||||||
// })
|
|
||||||
|
|
||||||
this.$emit('addToolsSuccess')
|
this.loading = true
|
||||||
|
addRepairInputInfoApi(params).then((response) => {
|
||||||
|
if (response.code == 200) {
|
||||||
|
this.$modal.msgSuccess('保存成功')
|
||||||
|
// 保存成功后清除页面数据
|
||||||
|
this.clearPageData();
|
||||||
}
|
}
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
} else if (!this.isEdit) {
|
|
||||||
console.log('新增')
|
|
||||||
this.loading = true
|
|
||||||
addPurchaseCheckInfo(this.maForm).then((response) => {
|
|
||||||
if (response.code == 200) {
|
|
||||||
this.$modal.msgSuccess('新增成功')
|
|
||||||
// this.$tab.closeOpenPage({
|
|
||||||
// path: '/store/newBuy/newDevicesList',
|
|
||||||
// })
|
|
||||||
|
|
||||||
this.$emit('addToolsSuccess')
|
|
||||||
}
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.$modal.msgError('请先选择并添加机具类型!!!')
|
this.$modal.msgError('请先添加维修信息')
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.$modal.msgError('请填写采购数量!!!')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.$modal.msgError('请先添加机具类型')
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
|
|
@ -624,6 +590,21 @@ export default {
|
||||||
})
|
})
|
||||||
.catch(() => {})
|
.catch(() => {})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearPageData() {
|
||||||
|
// 清除设备列表
|
||||||
|
this.equipmentList = [];
|
||||||
|
// 重置协议号
|
||||||
|
this.repairParams.agreementId = '';
|
||||||
|
// 重置规格型号选择
|
||||||
|
this.deviceType = [];
|
||||||
|
this.repairParams.unitId = '';
|
||||||
|
this.repairParams.projectId = '';
|
||||||
|
this.repairParams.agreementCode = '';
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
deviceTypeChange(val) {
|
deviceTypeChange(val) {
|
||||||
const deviceTypeList = this.$refs.deviceTypeCascader.getCheckedNodes()
|
const deviceTypeList = this.$refs.deviceTypeCascader.getCheckedNodes()
|
||||||
let tempList = []
|
let tempList = []
|
||||||
|
|
@ -633,17 +614,14 @@ export default {
|
||||||
})
|
})
|
||||||
for (let i of items) {
|
for (let i of items) {
|
||||||
for (let z of deviceTypeList) {
|
for (let z of deviceTypeList) {
|
||||||
if (z.data.typeId === i) {
|
if (z.data.typeId == i) {
|
||||||
const obj = JSON.parse(JSON.stringify(z.data))
|
const obj = JSON.parse(JSON.stringify(z.data))
|
||||||
obj.supplierId = this.queryParams.supplierId
|
// 初始化配件相关字段
|
||||||
obj.createTime = null
|
obj.partNum = obj.partNum || 1
|
||||||
obj.productionTime = this.queryParams.productionTime
|
obj.partPrice = obj.partPrice || 0
|
||||||
obj.purchasePrice = 0
|
obj.partName = obj.partName || ''
|
||||||
obj.purchaseNum = ''
|
obj.partModelName = obj.partModelName || ''
|
||||||
obj.purveyorId = this.queryParams.purveyorId
|
obj.partAllCosts = 0
|
||||||
obj.checkUrl = ''
|
|
||||||
obj.checkUrlName = ''
|
|
||||||
obj.fileList = []
|
|
||||||
tempList.push(obj)
|
tempList.push(obj)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
@ -662,6 +640,15 @@ export default {
|
||||||
items.forEach((e) => {
|
items.forEach((e) => {
|
||||||
newArray.forEach((j) => {
|
newArray.forEach((j) => {
|
||||||
if (e == j.typeId) {
|
if (e == j.typeId) {
|
||||||
|
// 确保数量至少为1
|
||||||
|
if (!j.partNum || j.partNum < 1) {
|
||||||
|
j.partNum = 1
|
||||||
|
}
|
||||||
|
// 确保有配件相关字段
|
||||||
|
j.partPrice = j.partPrice || 0
|
||||||
|
j.partName = j.partName || ''
|
||||||
|
j.partModelName = j.partModelName || ''
|
||||||
|
j.partAllCosts = (j.partNum * (j.partPrice || 0)).toFixed(2)
|
||||||
newArray_array.push(j)
|
newArray_array.push(j)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -674,11 +661,11 @@ export default {
|
||||||
|
|
||||||
/** 模板下载 */
|
/** 模板下载 */
|
||||||
downloadModel() {
|
downloadModel() {
|
||||||
const params = {params:JSON.stringify(this.queryParams)}
|
const params = {params:JSON.stringify(this.repairParams)}
|
||||||
this.download(
|
this.download(
|
||||||
'material/purchaseCheckInfo/downLoadTypeModel',
|
'material/purchaseCheckInfo/downLoadRepairModel',
|
||||||
{...params,},
|
{...params,},
|
||||||
`模板下载_${new Date().getTime()}.xlsx`,
|
`维修导入模板下载_${new Date().getTime()}.xlsx`,
|
||||||
)
|
)
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
@ -698,33 +685,84 @@ export default {
|
||||||
this.$message.success('文件上传成功');
|
this.$message.success('文件上传成功');
|
||||||
this.dialogUpload = false; // 上传成功后关闭弹窗
|
this.dialogUpload = false; // 上传成功后关闭弹窗
|
||||||
response.data.forEach((item) => {
|
response.data.forEach((item) => {
|
||||||
this.equipmentList.push({
|
const partNum = item.partNum && item.partNum >= 1 ? item.partNum : 1
|
||||||
|
const partPrice = item.partPrice || 0
|
||||||
|
// 创建新项数据
|
||||||
|
const newItem = {
|
||||||
machineTypeName: item.typeName,
|
machineTypeName: item.typeName,
|
||||||
specificationType: item.modelName,
|
specificationType: item.modelName,
|
||||||
typeId: item.typeId,
|
typeId: item.typeId,
|
||||||
unitName: item.unitName,
|
unitName: item.unitName,
|
||||||
supplierId: this.queryParams.supplierId? this.queryParams.supplierId : '',
|
partName: item.partName,
|
||||||
createTime: null,
|
partModelName: item.partModelName,
|
||||||
productionTime: this.queryParams.productionTime? this.queryParams.productionTime : '',
|
partPrice: partPrice,
|
||||||
purchasePrice: 0,
|
partNum: partNum,
|
||||||
purchaseNum: '',
|
partAllCosts: (partNum * partPrice).toFixed(2),
|
||||||
purveyorId: this.queryParams.purveyorId? this.queryParams.purveyorId : '',
|
}
|
||||||
checkUrl: '',
|
|
||||||
checkUrlName: '',
|
// 获取该项的层级路径
|
||||||
fileList: [],
|
|
||||||
})
|
|
||||||
// 获取新增项的层级路径
|
|
||||||
const path = this.getParentsById(this.equipmentTypeList, item.typeId);
|
const path = this.getParentsById(this.equipmentTypeList, item.typeId);
|
||||||
if (path) {
|
|
||||||
|
// 检查是否已存在相同typeId的项
|
||||||
|
let exists = false;
|
||||||
|
let typeIdExistsInDeviceType = false;
|
||||||
|
|
||||||
|
// 检查设备列表中是否存在相同typeId
|
||||||
|
for (let i = 0; i < this.equipmentList.length; i++) {
|
||||||
|
if (this.equipmentList[i].typeId == item.typeId) {
|
||||||
|
// 替换已存在的项
|
||||||
|
this.equipmentList[i] = newItem;
|
||||||
|
exists = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查deviceType中是否已包含该typeId
|
||||||
|
if (path && path.length > 0) {
|
||||||
|
const targetTypeId = path[path.length - 1]; // 最底层typeId
|
||||||
|
for (let i = 0; i < this.deviceType.length; i++) {
|
||||||
|
if (this.deviceType[i][this.deviceType[i].length - 1] === targetTypeId) {
|
||||||
|
typeIdExistsInDeviceType = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果不存在,则添加新项
|
||||||
|
if (!exists) {
|
||||||
|
this.equipmentList.push(newItem);
|
||||||
|
// 获取新增项的层级路径并添加到deviceType
|
||||||
|
if (path && !typeIdExistsInDeviceType) {
|
||||||
this.deviceType.push(path);
|
this.deviceType.push(path);
|
||||||
}
|
}
|
||||||
|
} else if (path && !typeIdExistsInDeviceType) {
|
||||||
|
// 如果是替换已有项,但deviceType中没有对应的typeId,则添加
|
||||||
|
this.deviceType.push(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 强制更新propsKey以触发级联选择器重新渲染
|
||||||
|
this.propsKey++;
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error('文件上传失败');
|
this.$message.error('文件上传失败');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
// 计算配件总价
|
||||||
|
calculateTotalPrice(row) {
|
||||||
|
// 确保数量至少为1
|
||||||
|
if (!row.partNum || row.partNum < 1) {
|
||||||
|
this.$set(row, 'partNum', 1)
|
||||||
|
}
|
||||||
|
// 确保单价为数字
|
||||||
|
const price = parseFloat(row.partPrice) || 0
|
||||||
|
const num = parseFloat(row.partNum) || 1
|
||||||
|
// 计算总价,使用 $set 确保响应式更新
|
||||||
|
const total = (price * num).toFixed(2)
|
||||||
|
this.$set(row, 'partAllCosts', total)
|
||||||
},
|
},
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue