退料优化
This commit is contained in:
parent
bb962793fd
commit
82a72adb84
|
|
@ -260,4 +260,13 @@ export function endBackOver(data) {
|
|||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
// 获取退料列表
|
||||
export function getUseInfoListApi(data) {
|
||||
return request({
|
||||
url: '/material/backApply/getUseInfoList',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
style="width: 240px"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="设备类型" prop="selDeviceTypeChangeValue">
|
||||
<!-- <el-form-item label="设备类型" prop="selDeviceTypeChangeValue">
|
||||
<el-select
|
||||
@change="selDeviceTypeChange"
|
||||
style="width: 240px"
|
||||
|
|
@ -76,14 +76,13 @@
|
|||
filterable
|
||||
style="width: 240px"
|
||||
></el-cascader>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="退料人" prop="backPerson">
|
||||
<el-input
|
||||
v-model="queryParams.backPerson"
|
||||
placeholder="请输入退料人"
|
||||
clearable
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="退料时间" prop="backTime">
|
||||
|
|
@ -100,6 +99,7 @@
|
|||
v-model="queryParams.phone"
|
||||
placeholder="请输入退料人电话"
|
||||
clearable
|
||||
maxlength="11"
|
||||
style="width: 240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
|
@ -111,7 +111,6 @@
|
|||
rows="1"
|
||||
type="textarea"
|
||||
style="width: 240px"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
|
@ -150,10 +149,36 @@
|
|||
</el-col>
|
||||
</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
|
||||
ref="tableRef"
|
||||
v-loading="loading"
|
||||
:data="leaseApplyDetails"
|
||||
@selection-change="handleSelectionChange"
|
||||
:max-height="500"
|
||||
>
|
||||
<el-table-column
|
||||
type="selection"
|
||||
|
|
@ -183,7 +208,7 @@
|
|||
<el-table-column
|
||||
label="当前在用量"
|
||||
align="center"
|
||||
prop="useNum"
|
||||
prop="totalUseNum"
|
||||
min-width="180"
|
||||
></el-table-column>
|
||||
<el-table-column
|
||||
|
|
@ -216,7 +241,6 @@
|
|||
placeholder="请输入备注"
|
||||
clearable
|
||||
style="width: 100%"
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -278,6 +302,7 @@ import {
|
|||
submitBackApplyApi,
|
||||
materialReturnNoteByApply,
|
||||
submitRefuseBackApply,
|
||||
getUseInfoListApi,
|
||||
} from '@/api/claimAndRefund/return.js'
|
||||
import { mapState } from 'vuex'
|
||||
import { getInfo, h } from '@/api/login'
|
||||
|
|
@ -377,6 +402,9 @@ export default {
|
|||
leaseApplyDetails: [],
|
||||
},
|
||||
leaseApplyDetails: [],
|
||||
displayedList: [],
|
||||
isRestoringSelection: false,
|
||||
keyword: '',
|
||||
//退料详情单条模板
|
||||
leaseApplyDetailsItem: {
|
||||
createBy: null,
|
||||
|
|
@ -516,6 +544,69 @@ export default {
|
|||
...mapState(['user']),
|
||||
},
|
||||
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() {
|
||||
this.selDeviceTypeChangeValue = ''
|
||||
|
|
@ -577,7 +668,8 @@ export default {
|
|||
} else {
|
||||
this.queryParams.agreementId = res.data.agreementId
|
||||
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
|
||||
},
|
||||
|
||||
/** 查询角色列表 */
|
||||
async getList() {},
|
||||
/** 查询菜单树结构 */
|
||||
getMenuTreeselect() {
|
||||
menuTreeselect().then((response) => {
|
||||
|
|
@ -694,20 +784,9 @@ export default {
|
|||
})
|
||||
this.resetForm('form')
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageNum = 1
|
||||
this.getList()
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = []
|
||||
this.resetForm('queryForm')
|
||||
this.handleQuery()
|
||||
},
|
||||
//是否可用勾选框
|
||||
selectable(row) {
|
||||
console.log(row)
|
||||
// console.log(row)
|
||||
if (row.num != 0) {
|
||||
return true
|
||||
} else {
|
||||
|
|
@ -716,6 +795,7 @@ export default {
|
|||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
if (this.isRestoringSelection) return
|
||||
this.queryParams.leaseApplyDetails = selection
|
||||
},
|
||||
// 更多操作触发
|
||||
|
|
@ -734,84 +814,97 @@ export default {
|
|||
|
||||
/** 保存按钮操作 */
|
||||
handleAdd() {
|
||||
this.$refs.queryForm.validate(async (valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
} else {
|
||||
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,
|
||||
}
|
||||
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
|
||||
// 二次确认
|
||||
this.$confirm('是否确定保存?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
this.$refs.queryForm.validate(async (valid) => {
|
||||
if (!valid) {
|
||||
return false
|
||||
} 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,
|
||||
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.closeOpenPage({
|
||||
// path: '/claimAndRefund/return/returnApply',
|
||||
// })
|
||||
// }, 1000)
|
||||
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.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) => {
|
||||
this.$modal.msgSuccess('修改成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
} else {
|
||||
this.form.menuIds = this.getMenuAllCheckedKeys()
|
||||
addRole(this.form).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功')
|
||||
this.open = false
|
||||
this.getList()
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
@ -880,7 +971,7 @@ export default {
|
|||
},
|
||||
|
||||
checkNum(row) {
|
||||
let maxNum = row.useNum
|
||||
let maxNum = row.totalUseNum
|
||||
if (row.num <= 1) {
|
||||
row.num = 1
|
||||
} else if (row.num >= maxNum) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue