配件新购优化

This commit is contained in:
bb_pan 2025-08-30 15:15:45 +08:00
parent c870b2e079
commit ae32826796
2 changed files with 109 additions and 31 deletions

View File

@ -71,3 +71,12 @@ export function getInBoundForm(query) {
params: query
})
}
// 根据id查3级树
export function getSelectPartListApi(query) {
return request({
url: '/material/part_lease/selectPartList',
method: 'get',
params: query
})
}

View File

@ -56,23 +56,40 @@
<span>%</span>
</el-form-item>
<el-form-item label="类型规格" prop="deviceType">
<el-form-item label="类型名称" prop="deviceType">
<el-cascader
:key="propsKey"
v-model="deviceType"
:show-all-levels="false"
:options="equipmentTypeList"
:props="deviceTypeTreeProps"
filterable
clearable
collapse-tags
style="width: 240px"
placeholder="请选择规格型号"
placeholder="请选择类型名称"
ref="deviceTypeCascader"
popper-class="popper-select"
@change="deviceTypeChange"
@change="deviceTypeChange2"
></el-cascader>
</el-form-item>
<el-form-item label="规格型号" prop="maType">
<el-select
v-model="maForm.maType"
placeholder="请选择规格型号"
filterable
style="width: 240px"
@change="maTypeChange"
>
<el-option
v-for="item in maTypeList"
:key="item.id"
:label="item.paName"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input
v-model="maForm.remark"
@ -124,7 +141,7 @@
<el-input
v-model.number="scope.row.purchaseNum"
controls-position="right" type="number"
style="width: 100%" :disabled="scope.row.status!=0"
style="width: 100%"
:min="0"
></el-input>
</template>
@ -139,7 +156,7 @@
v-model="scope.row.purchaseTaxPrice"
controls-position="right"
style="width: 100%" @blur="scope.row.purchaseTaxPrice = scope.row.purchaseTaxPrice>0? scope.row.purchaseTaxPrice:0"
:min="0" :step="1" :disabled="scope.row.status!=0"
:min="0" :step="1"
@change="purchaseTaxPriceChange(scope.row,scope.$index)"
></el-input-number>
</template>
@ -170,7 +187,7 @@
v-model="scope.row.productionTime"
style="width: 100%"
value-format="yyyy-MM-dd"
type="date" :disabled="scope.row.status!=0"
type="date"
placeholder="出厂日期"
clearable
></el-date-picker>
@ -281,7 +298,7 @@
</template>
<script>
import { getTypeTree,addPartInfo,getPartTypeCheckInfo,updatePartInfo,getPartTypeFileList } from '@/api/part/partArrived';
import { getTypeTree,addPartInfo,getPartTypeCheckInfo,updatePartInfo,getPartTypeFileList, getSelectPartListApi } from '@/api/part/partArrived';
import { getListFacturer } from '@/api/ma/supplier';
import { getToken } from '@/utils/auth'
@ -371,7 +388,9 @@ export default {
purchaser: '',
remark: '',
purchaseNumber: '',
maType: null
},
maTypeList: [],
//
form: {},
defaultProps: {
@ -403,7 +422,7 @@ export default {
label: 'partName',
// multiple: false,
value: 'partId',
multiple: true,
multiple: false,
},
deviceType: [],
propsKey: 1000,
@ -478,16 +497,17 @@ export default {
this.equipmentTypeList.forEach((item, index) => {
if (item.children && item.children.length > 0) {
item.children.forEach((item2, index2) => {
if (item2.children && item2.children.length > 0) {
item2.children.forEach((item3) => {
item2.children.forEach((item3) => {
item3.maTypeName = item2.partName
item3.specificationType = item3.partName
this.$set(item3, 'purchaseTaxPrice', 0)
this.$set(item3, 'purchasePrice', 0)
})
})
}
delete item2.children
// if (item2.children && item2.children.length > 0) {
// item2.children.forEach((item3) => {
// item2.children.forEach((item3) => {
// item3.maTypeName = item2.partName
// item3.specificationType = item3.partName
// this.$set(item3, 'purchaseTaxPrice', 0)
// this.$set(item3, 'purchasePrice', 0)
// })
// })
// }
})
}
})
@ -572,6 +592,55 @@ export default {
this.equipmentList = []
}
},
deviceTypeChange2(val) {
console.log('🚀 ~ deviceTypeChange2 ~ val:', val)
this.maTypeList = []
this.maForm.maType = ''
if (val.length > 0) {
this.getMaTypeList(val[1])
}
},
async getMaTypeList(id) {
try {
const res = await getSelectPartListApi({ id: id })
console.log('🚀 ~ getMaTypeList ~ res:', res)
this.maTypeList = res.data
} catch (error) {
console.log('🚀 ~ getMaTypeList ~ error:', error)
}
},
maTypeChange (val) {
console.log('🚀 ~ maTypeChange ~ val:', this.maForm.maType)
if (val) {
const obj = this.maTypeList.find(item => item.id === val)
console.log('🚀 ~ maTypeChange ~ obj:', obj)
// id this.equipmentList
const isExist = this.equipmentList.find(item => item.id === obj.id || item.partId == obj.id)
console.log('🚀 ~ maTypeChange ~ isExist:', isExist)
if (isExist) {
this.$message({
message: `当前配件 ${obj.paName} 已添加`,
type: 'warning'
})
return
} else {
this.equipmentList.push({
...obj,
maTypeName: obj.partName,
partId: obj.id,
partName: obj.paName,
createTime: null,
productionTime: this.maForm.productionTime,
purchaseTaxPrice: 0,
purchaseNum: 0,
status: 0,
isExitFile: '1',
bmFileInfo:[]
})
}
}
},
//
productionTimeChange(val){
this.equipmentList.forEach(item=>{
@ -613,12 +682,12 @@ export default {
this.$refs['maForm'].validate((valid) => {
if (valid) {
this.maForm.taskId = this.taskId;
let index =this.equipmentList.findIndex(item=>item.purchaseNum==0)
let index2 =this.equipmentList.findIndex(item=>item.purchaseTaxPrice==0)
let index =this.equipmentList.findIndex(item=>item.purchaseNum == 0 || !item.purchaseNum)
let index2 =this.equipmentList.findIndex(item=>item.purchaseTaxPrice == 0 || !item.purchaseTaxPrice)
if(index>-1){
this.$modal.msgError('采购数量不能为0')
this.$modal.msgError(`${index + 1}行采购数量不能为0`)
}else if(index2>-1){
this.$modal.msgError('含税单价不能为0')
this.$modal.msgError(`${index2 + 1}行采购含税价格不能为0`)
}else {
this.$modal.confirm('是否确认保存当前页面').then(function () {})
.then(() => {
@ -635,7 +704,7 @@ export default {
)
}
this.loading = false
})
}).catch(() => { this.loading = false })
} else if (!this.isEdit) {
console.log('新增')
// console.log(this.equipmentList)
@ -650,7 +719,7 @@ export default {
)
}
this.loading = false
})
}).catch(() => { this.loading = false })
}
}).catch(() => {})
}
@ -913,12 +982,12 @@ export default {
this.$modal
.confirm('是否确认删除所选择的数据项?')
.then(() => {
this.deviceType.forEach((e, index) => {
if (e[2] === row.partId) {
this.deviceType.splice(index, 1)
this.propsKey++
}
})
// this.deviceType.forEach((e, index) => {
// if (e[2] === row.partId) {
// this.deviceType.splice(index, 1)
// this.propsKey++
// }
// })
this.equipmentList.forEach((item, index) => {
if (item.partId == row.partId) {
this.equipmentList.splice(index, 1)