wanshenmean
6 小时以前 f288ccc545f8cc32bc922c96dfb3cab9a1f92ec6
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
<template>
  <div class="inbound-detail-page">
    <el-card shadow="never">
      <template #header>
        <span>入库单明细 - {{ route.query.inboundOrderNo || '' }}</span>
      </template>
 
      <el-form :inline="true" :model="queryForm" class="search-form">
        <el-form-item label="物料编号">
          <el-input v-model="queryForm.materielCode" placeholder="请输入物料编号" clearable />
        </el-form-item>
        <el-form-item label="物料名称">
          <el-input v-model="queryForm.materielName" placeholder="请输入物料名称" clearable />
        </el-form-item>
        <el-form-item label="批次号">
          <el-input v-model="queryForm.batchNo" placeholder="请输入批次号" clearable />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="handleSearch">查询</el-button>
          <el-button @click="handleReset">重置</el-button>
        </el-form-item>
      </el-form>
 
      <el-table v-loading="loading" :data="tableData" border stripe>
        <el-table-column prop="materielCode" label="物料编号" min-width="150" show-overflow-tooltip />
        <el-table-column prop="materielName" label="物料名称" min-width="160" show-overflow-tooltip />
        <el-table-column prop="batchNo" label="批次号" min-width="120" align="center" />
        <el-table-column prop="orderQuantity" label="单据数量" min-width="100" align="center" />
        <el-table-column prop="receiptQuantity" label="组盘数量" min-width="120" align="center" />
        <el-table-column prop="overInQuantity" label="上架数量" min-width="120" align="center" />
        <el-table-column prop="orderDetailStatus" label="明细状态" min-width="110" align="center">
          <template #default="{ row }">
            {{ getDetailStatusText(row.orderDetailStatus) }}
          </template>
        </el-table-column>
        <el-table-column prop="creater" label="创建人" min-width="90" align="center" />
        <el-table-column prop="createDate" label="创建时间" min-width="160" align="center" />
      </el-table>
 
      <el-pagination
        v-model:current-page="pagination.page"
        v-model:page-size="pagination.pageSize"
        :total="pagination.total"
        :page-sizes="[10, 20, 50, 100]"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handlePageChange"
        style="margin-top: 16px; justify-content: flex-end"
      />
    </el-card>
  </div>
</template>
 
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { ElMessage } from 'element-plus';
import { client } from '@/api/client';
 
const route = useRoute();
const loading = ref(false);
const tableData = ref([]);
const detailStatusOptions = ref([]);
 
const queryForm = reactive({ materielCode: '', materielName: '', batchNo: '' });
const pagination = reactive({ page: 1, pageSize: 20, total: 0 });
 
async function loadData() {
  loading.value = true;
  try {
    const orderId = route.query.id;
    const wheres = [{ name: 'orderId', value: String(orderId), displayType: 'int' }];
    if (queryForm.materielCode) wheres.push({ name: 'materielCode', value: queryForm.materielCode, displayType: 'like' });
    if (queryForm.materielName) wheres.push({ name: 'materielName', value: queryForm.materielName, displayType: 'like' });
    if (queryForm.batchNo) wheres.push({ name: 'batchNo', value: queryForm.batchNo, displayType: 'like' });
    const res = await client.post('/api/InboundOrderDetail/getPageList', {
      page: pagination.page, rows: pagination.pageSize, sort: 'id', order: 'asc',
      wheres: JSON.stringify(wheres),
    });
    tableData.value = res?.rows || [];
    pagination.total = res?.total || 0;
  } catch { ElMessage.error('加载数据失败'); }
  finally { loading.value = false; }
}
 
async function loadDictionary() {
  try {
    const res = await client.post('/api/Sys_Dictionary/GetVueDictionary', ['orderDetailStatusEnum']);
    detailStatusOptions.value = res?.find(item => item.dicNo === 'orderDetailStatusEnum')?.data || [];
  } catch { detailStatusOptions.value = []; }
}
 
function handleSearch() { pagination.page = 1; loadData(); }
function handleReset() { queryForm.materielCode = ''; queryForm.materielName = ''; queryForm.batchNo = ''; handleSearch(); }
function handleSizeChange() { loadData(); }
function handlePageChange() { loadData(); }
const getDetailStatusText = (val) => detailStatusOptions.value.find(o => `${o.key}` === `${val}`)?.value || val || '-';
 
onMounted(() => { loadDictionary(); loadData(); });
</script>
 
<style scoped>
.inbound-detail-page { padding: 16px; }
.search-form { margin-bottom: 12px; }
</style>