优化领料任务申请时保存bug

This commit is contained in:
BianLzhaoMin 2024-04-17 13:23:05 +08:00
parent 9deec6f550
commit 75c19d0d51
1 changed files with 254 additions and 258 deletions

View File

@ -3,27 +3,31 @@
<el-form :model="queryParams" ref="queryForm" size="small" :rules="queryRules" :inline="true" v-show="showSearch">
<el-row>
<el-form-item label="领料单位" prop="unitId">
<el-select v-model="queryParams.unitId" filterable clearable @change="GetProData" style="width: 240px" placeholder="请选择">
<el-option
v-for="item in unitList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
<el-select
v-model="queryParams.unitId"
filterable
clearable
@change="GetProData"
style="width: 240px"
placeholder="请选择"
>
<el-option v-for="item in unitList" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="领料工程" prop="proId">
<el-select v-model="queryParams.proId" filterable clearable @change="GetUnitData" style="width: 240px" placeholder="请选择">
<el-option
v-for="item in proList"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
<el-select
v-model="queryParams.proId"
filterable
clearable
@change="GetUnitData"
style="width: 240px"
placeholder="请选择"
>
<el-option v-for="item in proList" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
</el-form-item>
<el-form-item label="协议号" prop="agreementCode">
<el-input maxlength="50" v-model="queryParams.agreementCode" disabled></el-input maxlength="50" >
<el-input maxlength="50" v-model="queryParams.agreementCode" disabled></el-input>
</el-form-item>
<el-form-item label="物品类型" prop="status">
<el-cascader
@ -33,17 +37,20 @@
v-model="deviceType"
@change="deviceTypeChange"
ref="deviceTypeCascader"
filterable></el-cascader>
filterable
></el-cascader>
</el-form-item>
<el-form-item label="领料人" prop="leasePerson">
<el-input maxlength="50"
<el-input
maxlength="50"
v-model="queryParams.leaseApplyInfo.leasePerson"
placeholder="请输入领料人"
clearable
/>
</el-form-item>
<el-form-item label="领料人电话" prop="phone">
<el-input maxlength="11"
<el-input
maxlength="11"
v-model="queryParams.leaseApplyInfo.phone"
placeholder="请输入领料人电话"
clearable
@ -51,7 +58,8 @@
/>
</el-form-item>
<el-form-item label="备注" prop="roleName">
<el-input maxlength="100"
<el-input
maxlength="100"
v-model="queryParams.leaseApplyInfo.remark"
placeholder="请输入备注"
clearable
@ -61,30 +69,17 @@
/>
</el-form-item>
</el-row>
<el-row>
</el-row>
<el-row></el-row>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-back"
size="mini"
@click="handleBack"
>领料申请</el-button>
<el-button type="success" plain icon="el-icon-back" size="mini" @click="handleBack">领料申请</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
v-if="isEdit=='true'"
@click="handleAdd"
>保存</el-button>
<el-button type="primary" plain icon="el-icon-plus" size="mini" v-if="isEdit == 'true'" @click="handleAdd">
保存
</el-button>
</el-col>
<!-- <el-col :span="1.5">
@ -111,7 +106,8 @@
v-model.number="scope.row.preNum"
placeholder="请输入预领数量"
type="number"
min="1" @input="checkNum(scope.row)"
min="1"
@input="checkNum(scope.row)"
clearable
style="width: 100%"
/>
@ -119,15 +115,16 @@
</el-table-column>
<el-table-column label="备注" align="center">
<template slot-scope="scope">
<el-input maxlength="100"
v-model="scope.row.remark"
placeholder="请输入备注"
clearable
style="width: 100%"
/>
<el-input maxlength="100" v-model="scope.row.remark" placeholder="请输入备注" clearable style="width: 100%" />
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" v-if="isEdit=='true'">
<el-table-column
label="操作"
align="center"
fixed="right"
class-name="small-padding fixed-width"
v-if="isEdit == 'true'"
>
<template slot-scope="scope">
<!-- <el-button-->
<!-- size="mini"-->
@ -141,21 +138,18 @@
type="text"
icon="el-icon-delete"
@click="handleDelete({ ...scope.row, index: scope.$index })"
>删除</el-button>
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import { getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role";
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
import { getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from '@/api/system/role'
import { treeselect as menuTreeselect, roleMenuTreeselect } from '@/api/system/menu'
import {
getProData,
getUnitData,
@ -165,23 +159,23 @@ import {
getLeaseListAll,
editLeaseApply,
getLeaseApplyListAll,
getLeaseApplyAuditListAll
getLeaseApplyAuditListAll,
} from '@/api/claimAndRefund/receive'
import { getInfo } from '@/api/login'
export default {
name: "ReceiveApplyAdd",
name: 'ReceiveApplyAdd',
data() {
const validatePhone = (rule, value, callback) => {
if (!value) {
callback(new Error("退料人电话不能为空"));
callback(new Error('退料人电话不能为空'))
// this.$message.error("");
} else if (value.length < 11) {
callback(new Error("电话号码格式不正确"));
callback(new Error('电话号码格式不正确'))
// this.$message.error("");
} else {
callback();
callback()
}
}
};
return {
user: null, //
//
@ -199,7 +193,7 @@ export default {
//
roleList: [],
//
title: "",
title: '',
//
open: false,
//
@ -214,25 +208,25 @@ export default {
//
dataScopeOptions: [
{
value: "1",
label: "全部数据权限"
value: '1',
label: '全部数据权限',
},
{
value: "2",
label: "自定数据权限"
value: '2',
label: '自定数据权限',
},
{
value: "3",
label: "本部门数据权限"
value: '3',
label: '本部门数据权限',
},
{
value: "4",
label: "本部门及以下数据权限"
value: '4',
label: '本部门及以下数据权限',
},
{
value: "5",
label: "仅本人数据权限"
}
value: '5',
label: '仅本人数据权限',
},
],
//
menuOptions: [],
@ -240,7 +234,6 @@ export default {
deptOptions: [],
//
queryParams: {
types: 2,
unitId: null,
@ -255,10 +248,10 @@ export default {
leaseApplyInfo: {
leasePerson: '',
phone: '',
remark: ''
remark: '',
},
//
leaseApplyDetails:[]
leaseApplyDetails: [],
},
leaseApplyDetails: [],
@ -281,13 +274,19 @@ export default {
queryRules: {
unitId: [
{
required:true,message:'请选择来往单位',trigger:'change',type:'number'
}
required: true,
message: '请选择来往单位',
trigger: 'change',
type: 'number',
},
],
proId: [
{
required:true,message:'请选择工程',trigger:'change',type:'number'
}
required: true,
message: '请选择工程',
trigger: 'change',
type: 'number',
},
],
// leasePerson: [
// {
@ -309,7 +308,7 @@ export default {
//
deviceTypeTreeProps: {
multiple: false,
value:'id'
value: 'id',
},
//
deviceType: null,
@ -317,22 +316,16 @@ export default {
//
form: {},
defaultProps: {
children: "children",
label: "label"
children: 'children',
label: 'label',
},
//
rules: {
roleName: [
{ required: true, message: "角色名称不能为空", trigger: "blur" }
],
roleKey: [
{ required: true, message: "权限字符不能为空", trigger: "blur" }
],
roleSort: [
{ required: true, message: "角色顺序不能为空", trigger: "blur" }
]
roleName: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
roleKey: [{ required: true, message: '权限字符不能为空', trigger: 'blur' }],
roleSort: [{ required: true, message: '角色顺序不能为空', trigger: 'blur' }],
},
}
};
},
created() {
this.GetUserInfo()
@ -350,7 +343,7 @@ export default {
this.GetTaskDetail2(this.$route.query.taskId)
}
this.taskId = this.$route.query.taskId
this.isEdit = this.$route.query.isEdit;
this.isEdit = this.$route.query.isEdit
// console.log(typeof(this.isEdit))
// this.$set('isEdit',this.$route.query.isEdit)
},
@ -365,7 +358,7 @@ export default {
//
async GetUnitData() {
const params = {
id:this.queryParams.proId
id: this.queryParams.proId,
}
const res = await getUnitData(params)
this.unitList = res.data
@ -375,7 +368,7 @@ export default {
//
async GetProData() {
const params = {
id:this.queryParams.unitId
id: this.queryParams.unitId,
}
const res = await getProData(params)
this.proList = res.data
@ -386,22 +379,21 @@ export default {
//
async GetDeviceTypeTree() {
const params = {
level:4
level: 4,
}
const res = await getDeviceTypeTree(params)
this.deviceTypeTree = res.data
},
// id
async GetAgreementInfoById() {
if (this.queryParams.unitId && this.queryParams.proId) {
const params = {
unitId: this.queryParams.unitId,
projectId: this.queryParams.proId
projectId: this.queryParams.proId,
}
const res = await getAgreementInfoById(params)
if (!(res.data && res.data.agreementId)) {
this.$message.error('当前单位和工程未上传');
this.$message.error('当前单位和工程未上传')
this.queryParams.unitId = null
this.queryParams.proId = null
@ -439,7 +431,6 @@ export default {
this.leaseApplyDetails = data.leaseApplyDetails.map(item => {
return this.handelEchoData(item)
})
},
//
async GetTaskDetail2(taskId) {
@ -466,7 +457,6 @@ export default {
this.leaseApplyDetails = data.leaseApplyDetails.map(item => {
return this.handelEchoData(item)
})
},
//
handelEchoData(item) {
@ -488,34 +478,34 @@ export default {
//
reset() {
if (this.$refs.menu != undefined) {
this.$refs.menu.setCheckedKeys([]);
this.$refs.menu.setCheckedKeys([])
}
this.menuExpand = false,
this.menuNodeAll = false,
this.deptExpand = true,
this.deptNodeAll = false,
this.form = {
;(this.menuExpand = false),
(this.menuNodeAll = false),
(this.deptExpand = true),
(this.deptNodeAll = false),
(this.form = {
roleId: undefined,
roleName: undefined,
roleKey: undefined,
roleSort: 0,
status: "0",
status: '0',
menuIds: [],
deptIds: [],
menuCheckStrictly: true,
deptCheckStrictly: true,
remark: undefined
};
this.resetForm("form");
remark: undefined,
})
this.resetForm('form')
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.queryParams.pageNum = 1
},
/** 重置按钮操作 */
resetQuery() {
this.dateRange = [];
this.resetForm("queryForm");
this.dateRange = []
this.resetForm('queryForm')
},
//
handleSelectionChange(selection) {
@ -526,41 +516,41 @@ export default {
//
handleCommand(command, row) {
switch (command) {
case "handleDataScope":
this.handleDataScope(row);
break;
case "handleAuthUser":
this.handleAuthUser(row);
break;
case 'handleDataScope':
this.handleDataScope(row)
break
case 'handleAuthUser':
this.handleAuthUser(row)
break
default:
break;
break
}
},
/** 保存按钮操作 */
handleAdd() {
this.$refs.queryForm.validate(async (valid) => {
this.$refs.queryForm.validate(async valid => {
if (!valid) {
return false
} else {
this.queryParams.leaseApplyDetails = this.leaseApplyDetails
if (this.queryParams.leaseApplyDetails.length == 0) {
this.$message.error('请添加数据');
this.$message.error('请添加数据')
return
}
this.queryParams.leaseApplyDetails.forEach(item => {
if(item.num==0){
/* if(item.num==0){
this.$message.error('机具类型库存量为零无法领料');
return
}
} */
if (item.preNum == '') {
this.$message.error('请填写预领数量');
this.$message.error('请填写预领数量')
return
}
})
this.queryParams.createBy = this.user.userName
this.queryParams.companyId = this.user.companyId
let res;
let res
if (this.taskId) {
this.leaseApplyInfoList.forEach(v => {
@ -569,30 +559,35 @@ export default {
})
const params = {
...this.queryParams,taskId:this.taskId,
leaseApplyInfoList:this.leaseApplyInfoList
...this.queryParams,
taskId: this.taskId,
leaseApplyInfoList: this.leaseApplyInfoList,
}
res = await editLeaseApply(params)
} else {
// console.log(this.queryParams)
let isNum = this.queryParams.leaseApplyDetails.every(e => e.num != 0)
if (!isNum) {
this.$message.error('机具类型库存量为零无法领料')
return
}
res = await submitLeaseApply(this.queryParams)
}
if (res.code == 200) {
this.$message({
type: 'success',
message: res.msg
message: res.msg,
})
this.$tab.closeOpenPage({ path: "/claimAndRefund/receive/receiveApply"});
this.$tab.closeOpenPage({ path: '/claimAndRefund/receive/receiveApply' })
}
}
})
},
/** 修改按钮操作 */
handleBack(row) {
this.$tab.closeOpenPage({ path: "/claimAndRefund/receive/receiveApply"});
this.$tab.closeOpenPage({ path: '/claimAndRefund/receive/receiveApply' })
},
/** 删除按钮操作 */
handleDelete(row) {
@ -616,8 +611,11 @@ export default {
///////
deviceTypeChange(val) {
console.log(val)
let nodes = null;
nodes = this.$refs.deviceTypeCascader.getCheckedNodes().length > 0 ? this.$refs.deviceTypeCascader.getCheckedNodes() : [this.$refs.deviceTypeCascader.panel.getNodeByValue(val)]
let nodes = null
nodes =
this.$refs.deviceTypeCascader.getCheckedNodes().length > 0
? this.$refs.deviceTypeCascader.getCheckedNodes()
: [this.$refs.deviceTypeCascader.panel.getNodeByValue(val)]
if (nodes[0].level != 4) {
return
}
@ -626,12 +624,10 @@ export default {
for (let i = 0; i < this.leaseApplyDetails.length; i++) {
if (this.leaseApplyDetails[i].typeId == nodes[0].data.id) {
this.leaseApplyDetails.splice(i, 1)
break;
break
}
}
this.leaseApplyDetails.push(
this.handelTableItemData(nodes[0])
)
this.leaseApplyDetails.push(this.handelTableItemData(nodes[0]))
this.deviceType = {}
},
////
@ -652,7 +648,7 @@ export default {
}
return template
},
},
}
}
};
</script>