Your Name
2023-01-30 d8afe78f6a31bf0cf6743f85fb05a121f541c6aa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<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>