<template>
|
<div>
|
<el-dialog :title="checkOutState.title" :close-on-click-modal="false" v-model="checkOutState.checkOutDialogVisible" width="30%">
|
<el-form
|
:model="checkOutState.checkOutForm"
|
ref="checkOutFormRef"
|
size="default"
|
v-loading="checkOutState.loading"
|
element-loading-text="Loading..."
|
label-width="150px">
|
<el-row>
|
<el-col :span="24" class="mb20">
|
<el-form-item label="当前所选物资:">
|
<el-input v-model="checkOutState.materialName" :readonly="true" class="input-add">
|
</el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24" class="mb20">
|
<el-form-item label="认领人:" prop="receiveUid">
|
<el-select class="input-add" v-model="checkOutState.checkOutForm.receiveUid" placeholder="选择认领人">
|
<el-option
|
v-for="item in checkOutState.userList"
|
:key="item.uid"
|
:value="item.uid"
|
:label="item.realName"
|
></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button :disabled="checkOutState.loading" @click="checkOutState.batchOutStorageDialogVisible = !checkOutState.batchOutStorageDialogVisible" size="default">取 消</el-button>
|
<el-button :disabled="checkOutState.loading" type="primary" @click="submitCheckOutForm" v-throttle size="default">确 定</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
|
import { reactive} from "vue";
|
import {checkOutStateType, GoodsDetailDataType} from "/@/views/facilityManagement/goodsDetailManage/index";
|
import {teamManageApi} from "/@/api/systemManage/basicDateManage/personShiftManage/teamManage";
|
import {ElMessage} from "element-plus/es";
|
import {goodsDetailApi} from "/@/api/facilityManagement/goodsDetailManage";
|
import {useUserInfo} from "/@/stores/userInfo";
|
|
const checkOutState = reactive<checkOutStateType>({
|
title: '',
|
loading: false,
|
checkOutDialogVisible: false,
|
materialName: '',
|
checkOutForm: {
|
id: null,
|
receiveUid: null,
|
ids: [],
|
},
|
userList: [],
|
})
|
|
const openCheckOutDialog = (title: string, value: GoodsDetailDataType, ids:Array<number>, checkOutName: null | string) => {
|
checkOutState.title = title;
|
checkOutState.checkOutDialogVisible = true;
|
checkOutState.checkOutForm.receiveUid = null;
|
getUserByDepartment(useUserInfo().userInfos.depId as number)
|
if(title === '单独出库'){
|
checkOutState.materialName = value.name as string
|
checkOutState.checkOutForm.id = value.id;
|
delete checkOutState.checkOutForm.ids;
|
}else{
|
checkOutState.materialName = checkOutName as string
|
checkOutState.checkOutForm.ids = ids
|
delete checkOutState.checkOutForm.id;
|
}
|
|
|
}
|
|
const submitCheckOutForm = async () => {
|
if(checkOutState.checkOutForm.receiveUid === null){
|
ElMessage({
|
type: 'warning',
|
message: '请选择认领人'
|
})
|
}else{
|
checkOutState.loading = true
|
let res = await (checkOutState.title === '单独出库' ? goodsDetailApi().checkOutBySingle(checkOutState.checkOutForm) : goodsDetailApi().checkOutByMore(checkOutState.checkOutForm))
|
if(res.data.code === '200'){
|
checkOutState.checkOutDialogVisible = false
|
emit('refreshGoodsDetail')
|
ElMessage({
|
type: 'success',
|
message:'认领成功'
|
})
|
}else{
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
})
|
}
|
checkOutState.loading = false
|
}
|
}
|
|
const getUserByDepartment = async (value: number) => {
|
let res = await teamManageApi().getAllMember(value);
|
if (res.data.code === '200') {
|
checkOutState.userList = JSON.parse(JSON.stringify(res.data.data));
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
}
|
|
const emit = defineEmits(['refreshGoodsDetail'])
|
|
defineExpose({
|
openCheckOutDialog
|
})
|
|
</script>
|
|
<style scoped>
|
:deep(.el-dialog__header) {
|
padding: var(--el-dialog-padding-primary);
|
padding-bottom: 10px;
|
margin-right: 16px;
|
word-break: break-all;
|
text-align: center !important;
|
}
|
</style>
|