zhangwencui
2026-06-09 f4c73e3d36ff577aed91bed9bcd635c9eb6dcaa6
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
<template>
  <el-dialog v-model="isShow"
             title="库存详情"
             width="90%"
             top="3vh"
             class="batch-no-qty-detail-dialog"
             @close="closeModal">
    <div class="detail-content">
      <div class="detail-table-wrapper">
        <el-table :data="tableData"
                  border
                  v-loading="tableLoading"
                  style="width: 100%"
                  height="100%">
          <el-table-column label="产品名称"
                           prop="productName"
                           show-overflow-tooltip />
          <el-table-column label="规格型号"
                           prop="model"
                           show-overflow-tooltip />
          <el-table-column label="厂家"
                           prop="manufacturerId"
                           show-overflow-tooltip>
            <template #default="scope">
              {{ getManufacturerName(scope.row.manufacturerId) }}
            </template>
          </el-table-column>
          <el-table-column label="来源"
                           show-overflow-tooltip>
            <template #default="scope">
              {{ scope.row.sourceText || "--" }}
            </template>
          </el-table-column>
          <el-table-column label="单位"
                           prop="unit"
                           show-overflow-tooltip />
          <el-table-column label="批号"
                           prop="batchNo"
                           show-overflow-tooltip />
          <el-table-column label="库存数量"
                           prop="qualitity"
                           show-overflow-tooltip />
          <el-table-column label="备注"
                           prop="remark"
                           show-overflow-tooltip />
          <el-table-column label="最近更新时间"
                           prop="updateTime"
                           show-overflow-tooltip />
        </el-table>
      </div>
      <pagination v-show="total > 0"
                  :total="total"
                  layout="total, sizes, prev, pager, next, jumper"
                  :page="page.current"
                  :limit="page.size"
                  @pagination="paginationChange" />
    </div>
  </el-dialog>
</template>
 
<script setup>
  import pagination from "@/components/PIMTable/Pagination.vue";
  import { computed, reactive, ref, watch, onMounted } from "vue";
  import { getWasteBatchNoQty } from "@/api/inventoryManagement/stockUninventory.js";
  import { getManufacturerOptions } from "@/api/inspectionManagement/manufacturerManageFile.js";
 
  const props = defineProps({
    visible: {
      type: Boolean,
      required: true,
    },
    record: {
      type: Object,
      default: () => ({}),
    },
  });
 
  const emit = defineEmits(["update:visible"]);
 
  const isShow = computed({
    get() {
      return props.visible;
    },
    set(val) {
      emit("update:visible", val);
    },
  });
 
  const tableData = ref([]);
  const tableLoading = ref(false);
  const manufacturerOptions = ref([]);
  const total = ref(0);
  const page = reactive({
    current: 1,
    size: 20,
  });
 
  const getManufacturerName = manufacturerId => {
    return (
      manufacturerOptions.value.find(item => item.id === manufacturerId)?.name ||
      "--"
    );
  };
 
  const fetchManufacturerOptions = () => {
    getManufacturerOptions().then(res => {
      manufacturerOptions.value = res.data || [];
    });
  };
 
  onMounted(() => {
    fetchManufacturerOptions();
  });
 
  const getList = () => {
    if (!props.record?.productId || !props.record?.productModelId) {
      tableData.value = [];
      total.value = 0;
      return;
    }
 
    tableLoading.value = true;
    getWasteBatchNoQty({
      current: page.current,
      size: page.size,
      productId: props.record.productId,
      productModelId: props.record.productModelId,
      type: "waste",
    })
      .then(res => {
        tableData.value = res.data?.records || [];
        total.value = res.data?.total || 0;
      })
      .finally(() => {
        tableLoading.value = false;
      });
  };
 
  const paginationChange = obj => {
    page.current = obj.page;
    page.size = obj.limit;
    getList();
  };
 
  const closeModal = () => {
    isShow.value = false;
    page.current = 1;
    page.size = 20;
    tableData.value = [];
    total.value = 0;
  };
 
  watch(
    () => props.visible,
    visible => {
      if (!visible) {
        return;
      }
      page.current = 1;
      getList();
    },
    { immediate: true }
  );
</script>
 
<style scoped lang="scss">
  .detail-content {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 170px);
    min-height: 520px;
  }
 
  .detail-table-wrapper {
    flex: 1;
    min-height: 0;
  }
 
  :deep(.batch-no-qty-detail-dialog .el-dialog) {
    max-width: calc(100vw - 48px);
  }
 
  :deep(.batch-no-qty-detail-dialog .el-dialog__body) {
    padding-top: 12px;
  }
</style>