退料优化

This commit is contained in:
bb_pan 2025-10-31 14:08:49 +08:00
parent bb962793fd
commit 82a72adb84
2 changed files with 197 additions and 97 deletions

View File

@ -261,3 +261,12 @@ export function endBackOver(data) {
data data
}) })
} }
// 获取退料列表
export function getUseInfoListApi(data) {
return request({
url: '/material/backApply/getUseInfoList',
method: 'post',
data: data
})
}

View File

@ -51,7 +51,7 @@
style="width: 240px" style="width: 240px"
></el-input> ></el-input>
</el-form-item> </el-form-item>
<el-form-item label="设备类型" prop="selDeviceTypeChangeValue"> <!-- <el-form-item label="设备类型" prop="selDeviceTypeChangeValue">
<el-select <el-select
@change="selDeviceTypeChange" @change="selDeviceTypeChange"
style="width: 240px" style="width: 240px"
@ -76,14 +76,13 @@
filterable filterable
style="width: 240px" style="width: 240px"
></el-cascader> ></el-cascader>
</el-form-item> </el-form-item> -->
<el-form-item label="退料人" prop="backPerson"> <el-form-item label="退料人" prop="backPerson">
<el-input <el-input
v-model="queryParams.backPerson" v-model="queryParams.backPerson"
placeholder="请输入退料人" placeholder="请输入退料人"
clearable clearable
style="width: 240px" style="width: 240px"
@keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
<el-form-item label="退料时间" prop="backTime"> <el-form-item label="退料时间" prop="backTime">
@ -100,6 +99,7 @@
v-model="queryParams.phone" v-model="queryParams.phone"
placeholder="请输入退料人电话" placeholder="请输入退料人电话"
clearable clearable
maxlength="11"
style="width: 240px" style="width: 240px"
/> />
</el-form-item> </el-form-item>
@ -111,7 +111,6 @@
rows="1" rows="1"
type="textarea" type="textarea"
style="width: 240px" style="width: 240px"
@keyup.enter.native="handleQuery"
/> />
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -150,10 +149,36 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row :gutter="20">
<el-col :span="24" :offset="0">
<div
style="
margin-bottom: 12px;
display: flex;
align-items: center;
gap: 8px;
"
>
<el-input
v-model="keyword"
placeholder="请输入关键字搜索"
clearable
style="width: 260px"
size="small"
/>
<el-button size="small" type="primary" @click="handleSearch"
>搜索</el-button
>
</div>
</el-col>
</el-row>
<el-table <el-table
ref="tableRef"
v-loading="loading" v-loading="loading"
:data="leaseApplyDetails" :data="leaseApplyDetails"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
:max-height="500"
> >
<el-table-column <el-table-column
type="selection" type="selection"
@ -183,7 +208,7 @@
<el-table-column <el-table-column
label="当前在用量" label="当前在用量"
align="center" align="center"
prop="useNum" prop="totalUseNum"
min-width="180" min-width="180"
></el-table-column> ></el-table-column>
<el-table-column <el-table-column
@ -216,7 +241,6 @@
placeholder="请输入备注" placeholder="请输入备注"
clearable clearable
style="width: 100%" style="width: 100%"
@keyup.enter.native="handleQuery"
/> />
</template> </template>
</el-table-column> </el-table-column>
@ -278,6 +302,7 @@ import {
submitBackApplyApi, submitBackApplyApi,
materialReturnNoteByApply, materialReturnNoteByApply,
submitRefuseBackApply, submitRefuseBackApply,
getUseInfoListApi,
} from '@/api/claimAndRefund/return.js' } from '@/api/claimAndRefund/return.js'
import { mapState } from 'vuex' import { mapState } from 'vuex'
import { getInfo, h } from '@/api/login' import { getInfo, h } from '@/api/login'
@ -377,6 +402,9 @@ export default {
leaseApplyDetails: [], leaseApplyDetails: [],
}, },
leaseApplyDetails: [], leaseApplyDetails: [],
displayedList: [],
isRestoringSelection: false,
keyword: '',
//退 //退
leaseApplyDetailsItem: { leaseApplyDetailsItem: {
createBy: null, createBy: null,
@ -516,6 +544,69 @@ export default {
...mapState(['user']), ...mapState(['user']),
}, },
methods: { methods: {
//
async getList(agreementId) {
try {
const res = await getUseInfoListApi({ agreementId })
if (!res.data) return
this.displayedList = res.data || []
this.displayedList.forEach((item) => {
item.num = 0
item.remark = ''
})
this.leaseApplyDetails = [...this.displayedList]
} catch (error) {
console.log('🚀 ~ error:', error)
}
},
handleSearch() {
const keyword = this.keyword.trim()
// 1. typeName typeCode
const matched = this.displayedList.filter(
(item) =>
item.typeName?.includes(keyword) ||
item.typeCode?.includes(keyword),
)
// 2.
const others = this.displayedList.filter(
(item) => !matched.includes(item),
)
this.isRestoringSelection = true
// 3.
this.leaseApplyDetails = [...matched, ...others]
// 5.
this.$nextTick(() => {
this.restoreSelections()
})
},
//
restoreSelections() {
this.$refs.tableRef.clearSelection()
// 1.
this.$refs.tableRef.clearSelection()
// 2. queryParams.leaseApplyDetails
this.leaseApplyDetails.forEach((row) => {
const isSelected = this.queryParams.leaseApplyDetails.find(
(sel) => sel.typeId === row.typeId,
)
console.log('🚀 ~ isSelected:', isSelected)
if (isSelected) {
this.$refs.tableRef.toggleRowSelection(row, true)
}
})
// 3. ElementUI toggleRowSelection
this.$nextTick(() => {
this.isRestoringSelection = false
})
},
// //
async GetUnitData() { async GetUnitData() {
this.selDeviceTypeChangeValue = '' this.selDeviceTypeChangeValue = ''
@ -577,7 +668,8 @@ export default {
} else { } else {
this.queryParams.agreementId = res.data.agreementId this.queryParams.agreementId = res.data.agreementId
this.queryParams.agreementCode = res.data.agreementCode this.queryParams.agreementCode = res.data.agreementCode
this.GetDeviceTypeTreeFn(res.data.agreementId) // this.GetDeviceTypeTreeFn(res.data.agreementId)
this.getList(res.data.agreementId)
} }
} }
}, },
@ -619,8 +711,6 @@ export default {
return template return template
}, },
/** 查询角色列表 */
async getList() {},
/** 查询菜单树结构 */ /** 查询菜单树结构 */
getMenuTreeselect() { getMenuTreeselect() {
menuTreeselect().then((response) => { menuTreeselect().then((response) => {
@ -694,20 +784,9 @@ export default {
}) })
this.resetForm('form') this.resetForm('form')
}, },
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = []
this.resetForm('queryForm')
this.handleQuery()
},
// //
selectable(row) { selectable(row) {
console.log(row) // console.log(row)
if (row.num != 0) { if (row.num != 0) {
return true return true
} else { } else {
@ -716,6 +795,7 @@ export default {
}, },
// //
handleSelectionChange(selection) { handleSelectionChange(selection) {
if (this.isRestoringSelection) return
this.queryParams.leaseApplyDetails = selection this.queryParams.leaseApplyDetails = selection
}, },
// //
@ -734,84 +814,97 @@ export default {
/** 保存按钮操作 */ /** 保存按钮操作 */
handleAdd() { handleAdd() {
this.$refs.queryForm.validate(async (valid) => { //
if (!valid) { this.$confirm('是否确定保存?', '提示', {
return false confirmButtonText: '确定',
} else { cancelButtonText: '取消',
let backApplyInfo = [] type: 'warning',
if (this.queryParams.leaseApplyDetails.length == 0) { }).then(() => {
this.$message.error('请添加数据') this.$refs.queryForm.validate(async (valid) => {
return if (!valid) {
} return false
// const isRemark = this.queryParams.leaseApplyDetails.some(
// (item) => item.remark == '' || item.remark == undefined
// );
const isNum = this.queryParams.leaseApplyDetails.some(
(item) => item.num == '' || item.num == undefined,
)
if (isNum) {
this.$message.error('退料数量不能为空!')
return
}
this.queryParams.createBy = this.user.name
this.queryParams.companyId = this.companyId
this.queryParams.userId = this.userId
this.queryParams.backApplyInfo = {
backPerson: this.queryParams.backPerson,
phone: this.queryParams.phone,
remark: this.queryParams.remark,
backTime: this.queryParams.backTime,
companyId: this.companyId,
}
if (this.rowId != '') {
let params = {
companyId: this.companyId,
createBy: this.createBy,
userId: this.userId,
id: this.rowId,
agreementId: this.queryParams.agreementId,
backApplyInfo: this.queryParams.backApplyInfo,
backApplyDetails:
this.queryParams.leaseApplyDetails,
}
this.submitLoading = true
const res = await submitRefuseBackApply(params)
if (res.code == 200) {
this.$message({ type: 'success', message: res.msg })
this.$emit('goBackPage')
// setTimeout(() => {
// this.$tab.closeOpenPage({
// path: '/claimAndRefund/return/returnApply',
// })
// }, 1000)
}
this.submitLoading = false
} else { } else {
let params = { let backApplyInfo = []
if (this.queryParams.leaseApplyDetails.length == 0) {
this.$message.error('请添加数据')
return
}
// const isRemark = this.queryParams.leaseApplyDetails.some(
// (item) => item.remark == '' || item.remark == undefined
// );
const isNum = this.queryParams.leaseApplyDetails.some(
(item) => item.num == '' || item.num == undefined,
)
if (isNum) {
this.$message.error('退料数量不能为空!')
return
}
this.queryParams.createBy = this.user.name
this.queryParams.companyId = this.companyId
this.queryParams.userId = this.userId
this.queryParams.backApplyInfo = {
backPerson: this.queryParams.backPerson,
phone: this.queryParams.phone,
remark: this.queryParams.remark,
backTime: this.queryParams.backTime,
companyId: this.companyId, companyId: this.companyId,
createBy: this.createBy,
userId: this.userId,
agreementId: this.queryParams.agreementId,
backApplyInfo: this.queryParams.backApplyInfo,
backApplyDetails:
this.queryParams.leaseApplyDetails,
} }
this.submitLoading = true if (this.rowId != '') {
const res = await submitBackApplyApi(params) let params = {
if (res.code == 200) { companyId: this.companyId,
this.$message({ type: 'success', message: res.msg }) createBy: this.createBy,
this.$emit('goBackPage') userId: this.userId,
// setTimeout(() => { id: this.rowId,
// this.$tab.closeOpenPage({ agreementId: this.queryParams.agreementId,
// path: '/claimAndRefund/return/returnApply', backApplyInfo: this.queryParams.backApplyInfo,
// }) backApplyDetails:
// }, 1000) this.queryParams.leaseApplyDetails,
}
this.submitLoading = true
const res = await submitRefuseBackApply(params)
if (res.code == 200) {
this.$message({
type: 'success',
message: res.msg,
})
this.$emit('goBackPage')
setTimeout(() => {
this.$tab.refreshPage({
path: '/claimAndRefund/return/apply',
})
}, 300)
}
this.submitLoading = false
} else {
let params = {
companyId: this.companyId,
createBy: this.createBy,
userId: this.userId,
agreementId: this.queryParams.agreementId,
backApplyInfo: this.queryParams.backApplyInfo,
backApplyDetails:
this.queryParams.leaseApplyDetails,
}
this.submitLoading = true
const res = await submitBackApplyApi(params)
if (res.code == 200) {
this.$message({
type: 'success',
message: res.msg,
})
this.$emit('goBackPage')
setTimeout(() => {
this.$tab.refreshPage({
path: '/claimAndRefund/return/apply',
})
}, 300)
}
this.submitLoading = false
} }
this.submitLoading = false
} }
} })
}) })
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
@ -850,14 +943,12 @@ export default {
updateRole(this.form).then((response) => { updateRole(this.form).then((response) => {
this.$modal.msgSuccess('修改成功') this.$modal.msgSuccess('修改成功')
this.open = false this.open = false
this.getList()
}) })
} else { } else {
this.form.menuIds = this.getMenuAllCheckedKeys() this.form.menuIds = this.getMenuAllCheckedKeys()
addRole(this.form).then((response) => { addRole(this.form).then((response) => {
this.$modal.msgSuccess('新增成功') this.$modal.msgSuccess('新增成功')
this.open = false this.open = false
this.getList()
}) })
} }
} }
@ -880,7 +971,7 @@ export default {
}, },
checkNum(row) { checkNum(row) {
let maxNum = row.useNum let maxNum = row.totalUseNum
if (row.num <= 1) { if (row.num <= 1) {
row.num = 1 row.num = 1
} else if (row.num >= maxNum) { } else if (row.num >= maxNum) {