| | |
| | | :close-on-click-modal="false" |
| | | > |
| | | <el-form :model="state.form" size="default" ref="superRef" :rules="state.formRules" label-width="150px" > |
| | | <el-form-item v-if="state.isAdmin" label="企业:" prop="companyId"> |
| | | <el-form-item v-if="state.isAdmin" label="单位:" prop="companyId"> |
| | | <el-select v-model="state.form.companyId" placeholder="请选择" :disabled="state.title =='查看'" clearable @change="getDeptList"> |
| | | <el-option |
| | | v-for="item in state.companyList" |
| | |
| | | <el-form-item label="库存数量:"> |
| | | <el-input v-model.trim="state.originInventory" readonly placeholder="库存数量"></el-input> |
| | | </el-form-item> |
| | | <el-form-item label="材料清单:" prop="warehousingRecordDetails"> |
| | | <el-form-item label="出入库:" prop="warehousingRecordDetails"> |
| | | <el-button |
| | | type="primary" |
| | | plain |
| | |
| | | import {listUser} from "@/api/system/user"; |
| | | import {getWarehousingRecordDetail, updateWarehousingRecord} from "@/api/outsourcingCooperate/outsourcingCooperate"; |
| | | import {getMaterialList} from "@/api/outsourcingCooperate/outsourcingCooperate"; |
| | | import {getEmployeeRecords} from "@/api/onlineEducation/user"; |
| | | import useUserStore from "@/store/modules/user"; |
| | | const emit = defineEmits(["getList"]); |
| | | const dialogVisible = ref(false) |
| | |
| | | const dialogRef = ref(); |
| | | const checkList = (rule, value, callback) => { |
| | | if (state.form.warehousingRecordDetails.length == 0) { |
| | | callback(new Error('材料清单不可为空')) |
| | | callback(new Error('出入库不可为空')) |
| | | } else { |
| | | callback() |
| | | } |
| | |
| | | if(isAdmin){ |
| | | state.companyList = companyList |
| | | } |
| | | await getUserList() |
| | | await getUserList(companyId) |
| | | await getMaterials(companyId) |
| | | state.title = type === 'add' ? '新增' : type ==='edit' ? '编辑' : '查看' |
| | | state.form.companyId = companyId |
| | |
| | | } |
| | | |
| | | const calculateInventoryExcludingCurrent = (currentRow) => { |
| | | if(!state.form.materialId) return 0 |
| | | // if(!state.form.materialId) return 0 |
| | | let inventory = state.materialList.find(i=>i.id == state.form.materialId)?.inventory || 0; |
| | | if(Array.isArray(state.form.warehousingRecordDetails) && state.form.warehousingRecordDetails.length>0){ |
| | | for(let i of state.form.warehousingRecordDetails){ |
| | |
| | | } |
| | | |
| | | const calculateInventory = () => { |
| | | if(state.form.materialId){ |
| | | // if(state.form.materialId){ |
| | | let inventory = state.materialList.find(i=>i.id == state.form.materialId)?.inventory || 0 |
| | | if(Array.isArray(state.form.warehousingRecordDetails) && state.form.warehousingRecordDetails.length>0){ |
| | | for(let i of state.form.warehousingRecordDetails){ |
| | |
| | | if(inventory < 0){ |
| | | ElMessage.warning('库存不足,无法出库') |
| | | } |
| | | }else{ |
| | | state.originInventory = 0 |
| | | } |
| | | // }else{ |
| | | // state.originInventory = 0 |
| | | // } |
| | | } |
| | | |
| | | const checkRemain = (scope) => { |
| | |
| | | } |
| | | |
| | | const getInventory = ()=>{ |
| | | state.form.warehousingRecordDetails = state.form.warehousingRecordDetails.map(i=>{ |
| | | return { |
| | | ...i, |
| | | specification: state.materialList.find(i=>i.id == state.form.materialId)?.specification, |
| | | materialUnit: state.materialList.find(i=>i.id == state.form.materialId)?.materialUnit |
| | | } |
| | | }) |
| | | state.form.warehousingRecordDetails = [] |
| | | // state.form.warehousingRecordDetails = state.form.warehousingRecordDetails.map(i=>{ |
| | | // return { |
| | | // ...i, |
| | | // specification: state.materialList.find(i=>i.id == state.form.materialId)?.specification, |
| | | // materialUnit: state.materialList.find(i=>i.id == state.form.materialId)?.materialUnit |
| | | // } |
| | | // }) |
| | | calculateInventory() |
| | | } |
| | | |
| | |
| | | const getDeptList = async ()=>{ |
| | | state.form.materialId = null |
| | | await getMaterials(state.form.companyId) |
| | | await getUserList(state.form.companyId) |
| | | } |
| | | |
| | | const getUserList = async ()=> { |
| | | const res = await listUser({pageIndex: 1,pageSize: 999}) |
| | | const getUserList = async (companyId)=> { |
| | | const res = await getEmployeeRecords({companyId: companyId}) |
| | | if(res.code == 200){ |
| | | state.userList = res.data.list?res.data.list.map(item=>{ |
| | | const user = item.id |
| | | const {id, ...data} = item |
| | | return { |
| | | ...data, |
| | | userId: user |
| | | } |
| | | }):[] |
| | | state.userList = res.data.list?res.data.list:[] |
| | | }else{ |
| | | ElMessage.warning(res.message) |
| | | } |
| | |
| | | warehousingRecordDetails: [], |
| | | delDetails: [] |
| | | } |
| | | state.originInventory = 0 |
| | | superRef.value.clearValidate(); |
| | | superRef.value.resetFields() |
| | | dialogVisible.value = false; |