schangxiang@126.com
2024-11-21 60735779c303c2dd10feea45d7fd761103b225e0
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<template>
    <div>
        <!-- 单详情 -->
        <el-drawer v-model="drawerVisible" :title="`${detailForm.poId}详情`" direction="rtl" size="80%" @close="handleDrawerClose">
            <template #title>
                <div class="slot_title">
                    <div class="title_orderNo">{{ title }}</div>
                    <div>详情</div>
                </div>
            </template>
 
            <div class="detailBoxWrap">
                <!-- 详情组件 -->
                <open-details ref="propDetailRef"></open-details>
                <div class="msi-form">
                    <el-form :model="detailForm">
                        <el-row>
                            <el-col :span="6">
                                <el-form-item label="物料编号">
                                    <el-input v-model="detailForm.materialCode" clearable placeholder="请输入物料编号" />
                                </el-form-item>
                            </el-col>
                            <el-col :span="4">
                                <el-form-item label-width="20px">
                                    <el-button type="primary" icon="el-icon-search" @click="getDetail">查询</el-button>
                                    <el-button type="primary" style="margin-left: 5px" icon="ele-Download" @click="handleExportExcelWmsStockSnapshot" v-auth="'wmsStockSnapshot:exportExcel'"> 导出 </el-button>
                                </el-form-item>
                            </el-col>
                        </el-row>
                    </el-form>
                </div>
                <div class="msi-content">
                    <el-table :data="drawerList" border striped :max-height="480" ref="tableRefWmsStockSnapshot" :summary-method="getExportTitle" show-summary>
                        <el-table-column type="index" label="序号" width="55" align="center" />
                        <el-table-column prop="materialCode" label="物料编号" show-overflow-tooltip="" />
                        <el-table-column prop="materialName" label="物料名称" show-overflow-tooltip="" />
                        <el-table-column prop="materialUnit" label="单位" show-overflow-tooltip="" />
                        <el-table-column prop="areaCode" label="库区编号" show-overflow-tooltip="" />
                        <el-table-column prop="areaName" label="库区名称" show-overflow-tooltip="" />
                        <el-table-column prop="quantity" label="数量" show-overflow-tooltip="" />
                    </el-table>
                    <Pagination :total="detailCount" v-model:page="detailForm.Page" v-model:limit="detailForm.PageSize" @pagination="getDetail" style="margin-top: 20px; text-align: center"></Pagination>
 
                    <div></div>
                </div>
            </div>
        </el-drawer>
    </div>
</template>
<script lang="ts" setup>
import Pagination from '/@/components/Pagination/index.vue';
import { ElMessage, ElMessageBox } from 'element-plus';
import { ref, nextTick, computed, getCurrentInstance, watch, defineExpose, defineProps, onMounted } from 'vue';
import { exportPageExcel } from '/@/utils/exportPageExcel'; //引入导出方法
import { wmsStockWarning, historialStockPage } from '/@/api/main/inventoryWarning/inventoryWarning';
import OpenDetails from '/@/components/openDetails/openDetails.vue';
import { formatDate, formatDate_T_Date, formatDate_T_Time, defaultTimeRange } from '/@/utils/formatTime';
import commonFunction from '/@/utils/commonFunction';
import { ExcellTableDataExport } from '/@/hooks/exportTableDataExcell';
 
const jsonExcellTableExport = {
    titleName: '', //导出表格名称
    interfaceListName: '', //导出接口名称
};
 
const { getExportTitle, handleExportExcell, formExport, entozhExcell } = ExcellTableDataExport(jsonExcellTableExport);
 
const { proxy }: any = getCurrentInstance(); // 访问实例上下文 proxy同时支持开发 线上环境
const { getEnumDesc } = commonFunction();
const emits = defineEmits(['getTabelData']);
 
const props = defineProps({
    titleAuthor: {
        type: Number,
        required: true,
    },
    hexiao: {
        type: Number,
        default: 1,
        required: true,
    },
});
//控制订单类型
const titleAuthor = computed(() => props.titleAuthor);
// 是否显示核销按钮
const hexiao = computed(() => props.hexiao);
const loading = ref(false);
 
//入库单下物料详情请求
const detailForm = ref({
    materialCode: '',
    begineTime: '',
    snapshotId:'',
    Page: 1,
    PageSize: 10,
});
 
// 物料详情抽屉
const drawerVisible = ref(false);
const drawerType = ref('drawerAll');
// const
//单号
const purchaseNo = ref('');
function convertToDate(number:any) {
    const year = Math.floor(number / 10000);
    const month = Math.floor((number % 10000) / 100);
    const day = number % 100;
 
    const date = new Date(year, month - 1, day); // 月份是从0开始的,所以要减1
    return date.toISOString().split('T')[0]; // 转换为字符串并去掉时间部分
}
let scopetrans = '';
//打开抽屉
const openDrawer = async (type: number, scope: any = {}, entozhExcell?: any) => {
    detailForm.value.Page = 1; //bug:点编辑-再点详情
    detailForm.value.PageSize = 10; //bug:点编辑-再点详情
    if (scope.snapshotNo) {
        title.value = `${scope.snapshotNo}`;
    }
    drawerType.value = 'drawerAll';
    drawerVisible.value = true;
    // detailForm.value.begineTime = convertToDate(scope.snapshotDate) + ' 00:00:00';
    detailForm.value.snapshotId = scope.id;
    debugger
    purchaseNo.value = scope.snapshotNo;
    //------------------获取物料列表物料明细
    getDetail();
    //------------------获取物料列表物料明细
 
    scopetrans = JSON.parse(JSON.stringify(scope));
    nextTick(() => {
        proxy.$refs['propDetailRef'].openADialog(scopetrans, entozhExcell);
    });
};
 
//关闭抽屉
const handleDrawerClose = () => {
    detailForm.value = {
        materialCode: '',
        begineTime: '',
        snapshotId:'',
        Page: 1,
        PageSize: 10,
    };
    deltailList.value = [];
    detailCount.value = 0;
    drawerList.value = [];
};
 
//物料详情类型
interface DetailType {
    id: number;
}
 
//入库单详情列表
const deltailList = ref<DetailType[]>([]);
//弹出层数据
const drawerList = ref<DetailType[]>([]);
 
//入库单详情列表数据条数
const detailCount = ref(0);
 
//弹出层标题
let title = ref('');
//获取入库单下物料详情
const getDetail = async (callback?: any) => {
    loading.value = true;
    var res = await historialStockPage(Object.assign(detailForm.value));
    drawerList.value = res.data.result?.items ?? [];
    detailCount.value = res.data.result?.total;
    loading.value = false;
};
 
const tableRefWmsStockSnapshot = ref(null);
const loadingWmsStockSnapshot = ref(false);
const disabled_btnWmsStockSnapshot = ref(false);
const queryParamsWmsStockSnapshot = ref<any>({});
const tableParamsWmsStockSnapshot = ref({
    page: 1,
    pageSize: 10,
    total: 0,
});
 
//点击导出按钮
const handleExportExcelWmsStockSnapshot = async () => {
    loadingWmsStockSnapshot.value = true;
    disabled_btnWmsStockSnapshot.value = true;
    var new_tableParamsWmsStockSnapshot = JSON.parse(JSON.stringify(tableParamsWmsStockSnapshot.value));
    new_tableParamsWmsStockSnapshot.page = 1;
    new_tableParamsWmsStockSnapshot.pageSize = 100000;
    // new_tableParamsWmsStockSnapshot.begineTime = detailForm.value.begineTime;
    new_tableParamsWmsStockSnapshot.snapshotId = detailForm.value.snapshotId;
    var res = await historialStockPage(Object.assign(queryParamsWmsStockSnapshot.value, new_tableParamsWmsStockSnapshot));
    if (res.data.type == 'success') {
        exportExcelWmsStockSnapshot(res.data.result?.items ?? []);
    }
    loadingWmsStockSnapshot.value = false;
    disabled_btnWmsStockSnapshot.value = false;
};
//导出
const exportExcelWmsStockSnapshot = async (exportDataList: Array) => {
    exportPageExcel(exportDataList, tableRefWmsStockSnapshot, '库存快照', functionMapWmsStockSnapshot);
};
//定义当前页面的方法组
const functionMapWmsStockSnapshot = {
    formatDate_T_Date,
    formatDate_T_Time,
};
// 页面加载时
onMounted(async () => {});
 
// 暴露方法
defineExpose({ openDrawer });
</script>
<style lang="less" scoped>
.detailBoxWrap {
    margin: 10px;
}
 
.msi-form {
    margin-top: 10px;
}
.msi-form {
    margin-bottom: 10px;
}
.slot_title {
    display: flex;
    align-items: center;
    // margin-left: 20px;
    .title_orderNo {
        font-size: 18px;
        color: #f18201;
        font-weight: bold;
        margin-right: 5px;
    }
}
</style>