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