Your Name
2023-01-06 e3d63f84a43db07fa5992de2937ee23fc67bad38
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
<template>
    <div>
        <el-dialog :title="batchInStorageState.title" :close-on-click-modal="false"  v-model="batchInStorageState.batchInStorageDialogVisible" width="30%">
            <el-form
                :model="batchInStorageState.inStorageData"
                :rules="batchInStorageState.inStorageDataRules"
                ref="inStorageDataRef"
                size="default"
                v-loading="batchInStorageState.loading"
                element-loading-text="Loading..."
                label-width="150px">
                <el-row>
                    <el-col :span="24" class="mb20">
                        <el-form-item label="当前所选物资/设备:">
                            <el-input v-model="batchInStorageState.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="batchInStorageState.inStorageData.rfid" placeholder="选填" class="input-add">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" class="mb20">
                        <el-form-item label="入库数量:" prop="wareHousingCount">
                            <el-input @input="onVerifiyNumberInteger($event, 'noticeTime')"  v-model="batchInStorageState.inStorageData.wareHousingCount" placeholder="输入入库数量" class="input-add">
                            </el-input>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" class="mb20">
                        <el-form-item label="有效期类型:" prop="validType">
                            <el-radio-group v-model="batchInStorageState.inStorageData.validType">
                                <el-radio :label="0">长期</el-radio>
                                <el-radio :label="1">非长期</el-radio>
                            </el-radio-group>
                        </el-form-item>
                    </el-col>
                    <el-col :span="24" class="mb20" v-if="batchInStorageState.inStorageData.validType === 1">
                        <el-form-item label="有效期至:" prop="validTime">
                            <el-date-picker
                                v-model="batchInStorageState.inStorageData.validTime"
                                type="datetime"
                                format="YYYY-MM-DD HH:mm:ss"
                                value-format="YYYY-MM-DD HH:mm:ss"
                                placeholder="选择日期时间"
                                style="width: 90%" />
                        </el-form-item>
                    </el-col>
 
                </el-row>
            </el-form>
            <template #footer>
                <span class="dialog-footer">
                    <el-button :disabled="batchInStorageState.loading" @click="batchInStorageState.batchInStorageDialogVisible = !batchInStorageState.batchInStorageDialogVisible" size="default">取 消</el-button>
                    <el-button :disabled="batchInStorageState.loading" type="primary" @click="submitInStorageData" v-throttle size="default">确 定</el-button>
                </span>
            </template>
        </el-dialog>
    </div>
</template>
 
<script setup lang="ts">
import { reactive, ref} from 'vue'
import {BatchInStorageStateType, DataType} from "/@/views/facilityManagement/safetyGoodsAndEquipment/index";
import {verifiyNumberInteger} from "/@/utils/toolsValidate";
import {ElMessage} from "element-plus";
import { goodsAndEquipmentApi } from '../../../../api/facilityManagement/safetyGoodsAndEquipment/index'
 
const inStorageDataRef = ref()
 
const batchInStorageState = reactive<BatchInStorageStateType>({
    title: '批量入库',
    loading: false,
    materialName: '',
    batchInStorageDialogVisible: false,
    inStorageData:{
        smId: null,
        wareHousingCount: null,
        validType: null,
        validTime: null,
        rfid: null,
    },
    inStorageDataRules: {
        wareHousingCount: [{ required: true, message: '请填写物资数量', trigger: 'blur' }],
        validType: [{ required: true, message: '请选择有效期类型', trigger: 'change' }],
        validTime: [{ required: true, message: '请选择有效期至', trigger: 'change' }],
    },
})
 
const openBatchInStorageDialog = (value: DataType) => {
    batchInStorageState.batchInStorageDialogVisible = true
    batchInStorageState.inStorageData.smId = value.id
    batchInStorageState.materialName = value.materialName
}
 
const submitInStorageData = () => {
    batchInStorageState.loading = true;
    inStorageDataRef.value.validate(async (valid: boolean) => {
        if(valid){
            let res = await goodsAndEquipmentApi().batchInStorageGoods(batchInStorageState.inStorageData);
            if(res.data.code === '200'){
                batchInStorageState.batchInStorageDialogVisible = false;
                emit('refreshData')
                ElMessage({
                    type: 'success',
                    message: '入库成功',
                    duration: 2000
                });
            }else{
                ElMessage({
                    type: 'warning',
                    message:res.data.msg
                });
            }
        }else{
            ElMessage({
                type: 'warning',
                message: '请完善基本信息'
            });
        }
    });
    batchInStorageState.loading = false;
};
 
const emit = defineEmits(['refreshData',]);
 
defineExpose({
    openBatchInStorageDialog,
})
 
const onVerifiyNumberInteger = (val: number, title: string) => {
    batchInStorageState.inStorageData.wareHousingCount = Number(verifiyNumberInteger(val.toString())) === 0 ? null : Number(verifiyNumberInteger(val.toString()));
};
</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>