马宇豪
2025-03-04 1b9fea7d4af68d8f933b2dc42bf6084b9646f64c
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<template>
    <div>
        <el-dialog :title="batchOutStorageState.title" :close-on-click-modal="false"  v-model="batchOutStorageState.batchOutStorageDialogVisible" width="30%">
            <el-form
                :model="batchOutStorageState.outStorageData"
                :rules="batchOutStorageState.outStorageDataRules"
                ref="outStorageDataRef"
                size="default"
                v-loading="batchOutStorageState.loading"
                element-loading-text="Loading..."
                label-width="150px">
                <el-row>
                    <el-col :span="24" class="mb20">
                        <el-form-item label="当前所选物资/设备:">
                            <el-input v-model="batchOutStorageState.materialName" :readonly="true" class="input-add">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" class="mb20">
                        <el-form-item label="按RFID标记:" prop="rfid">
                            <el-input v-model="batchOutStorageState.outStorageData.rfid" placeholder="选填" class="input-add">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" class="mb20">
                        <el-form-item label="出库数量:" prop="count">
                            <el-input @Output="onVerifiyNumberInteger($event, 'noticeTime')"  v-model="batchOutStorageState.outStorageData.count" placeholder="输入出库数量" 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="batchOutStorageState.outStorageData.receiveUid" placeholder="选择认领人">
                                <el-option
                                v-for="item in batchOutStorageState.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="batchOutStorageState.loading" @click="batchOutStorageState.batchOutStorageDialogVisible = !batchOutStorageState.batchOutStorageDialogVisible" size="default">取 消</el-button>
                    <el-button :disabled="batchOutStorageState.loading" type="primary" @click="submitOutStorageData" v-throttle size="default">确 定</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>
 
<script setup lang="ts">
import {onMounted, reactive, ref} from 'vue'
import {BatchOutStorageStateType, DataType} from "/@/views/facilityManagement/safetyGoodsAndEquipment/index";
import {verifiyNumberInteger} from "/@/utils/toolsValidate";
import {ElMessage} from "element-plus";
import { goodsAndEquipmentApi } from '../../../../api/facilityManagement/safetyGoodsAndEquipment/index'
import {teamManageApi} from "/@/api/systemManage/basicDateManage/personShiftManage/teamManage";
 
const outStorageDataRef = ref()
 
const batchOutStorageState = reactive<BatchOutStorageStateType>({
    title: '批量出库',
    loading: false,
    materialName: '',
    batchOutStorageDialogVisible: false,
    outStorageData:{
        smId: null,
        count: null,
        receiveUid: null,
        rfid: null,
    },
    outStorageDataRules: {
        count: [{ required: true, message: '请填写出库数量', trigger: 'blur' }],
        receiveUid: [{ required: true, message: '请选择认领人', trigger: 'change' }],
    },
    userList: [],
})
 
const openBatchOutStorageDialog = (value: DataType) => {
    batchOutStorageState.batchOutStorageDialogVisible = true
    batchOutStorageState.outStorageData.smId = value.id
    batchOutStorageState.materialName = value.materialName
}
 
const submitOutStorageData = () => {
    batchOutStorageState.loading = true;
    outStorageDataRef.value.validate(async (valid: boolean) => {
        if(valid){
            let res = await goodsAndEquipmentApi().batchOutStorageGoods(batchOutStorageState.outStorageData);
            if(res.data.code === '200'){
                batchOutStorageState.batchOutStorageDialogVisible = false;
                emit('refreshData')
                ElMessage({
                    type: 'success',
                    message: '出库成功',
                    duration: 2000
                });
            }else{
                ElMessage({
                    type: 'warning',
                    message:res.data.msg
                });
            }
        }else{
            ElMessage({
                type: 'warning',
                message: '请完善基本信息'
            });
        }
    });
    batchOutStorageState.loading = false
};
 
const emit = defineEmits(['refreshData',]);
 
defineExpose({
    openBatchOutStorageDialog,
})
 
const onVerifiyNumberInteger = (val: number, title: string) => {
    batchOutStorageState.outStorageData.count = Number(verifiyNumberInteger(val.toString())) === 0 ? null : Number(verifiyNumberInteger(val.toString()));
 
};
 
const getUserByDepartment = async () => {
    let res = await teamManageApi().getAllMember(1);
    if (res.data.code === '200') {
        batchOutStorageState.userList = JSON.parse(JSON.stringify(res.data.data));
    } else {
        ElMessage({
            type: 'warning',
            message: res.data.msg
        });
    }
}
 
onMounted(() => {
    getUserByDepartment()
})
</script>
 
<style scoped>
:deep(.el-dialog__header) {
    paddOutg: var(--el-dialog-padding-primary);
    paddOutg-bottom: 10px;
    margOut-right: 16px;
    word-break: break-all;
    text-align: center !important;
}
</style>