spring
5 小时以前 3ea1ff641e1c680a5a1727fb4034797bfe65d93e
src/pages/consumablesLogistics/stockManagement/index.vue
@@ -2,18 +2,6 @@
  <view class="stock-mgmt-page">
    <PageHeader title="库存管理" @back="goBack" />
    <view class="tabs-wrap">
      <view
        v-for="tab in tabs"
        :key="tab.name"
        class="tab-item"
        :class="{ active: activeTab === tab.name }"
        @click="activeTab = tab.name"
      >
        <text>{{ tab.label }}</text>
      </view>
    </view>
    <view class="search-section">
      <view class="search-row">
        <view class="search-input-wrap">
@@ -102,17 +90,11 @@
</template>
<script setup>
import { computed, reactive, ref, toRefs, watch } from "vue";
import { computed, reactive, ref, toRefs } from "vue";
import { onReachBottom, onShow } from "@dcloudio/uni-app";
import PageHeader from "@/components/PageHeader.vue";
import { frozenConsumablesIn, getConsumablesInListPage, thawConsumablesIn } from "@/api/consumablesLogistics/consumablesIn.js";
import { frozenConsumablesUninventory, getConsumablesUninventoryListPage, thawConsumablesUninventory } from "@/api/consumablesLogistics/consumablesUninventory.js";
const activeTab = ref("qualified");
const tabs = [
  { label: "合格库存", name: "qualified" },
  { label: "不合格库存", name: "unqualified" },
];
const tableData = ref([]);
const total = ref(0);
const loadStatus = ref("loadmore");
@@ -126,15 +108,13 @@
});
const { searchForm, quantityForm } = toRefs(data);
const isQualified = () => activeTab.value === "qualified";
const getList = () => {
  const isFirstPage = page.current === 1;
  if (isFirstPage) {
    uni.showLoading({ title: "加载中...", mask: true });
  }
  const params = { ...page, productName: searchForm.value.productName };
  const api = isQualified() ? getConsumablesInListPage : getConsumablesUninventoryListPage;
  api(params)
  getConsumablesInListPage(params)
    .then((res) => {
      uni.hideLoading();
      const records = res.data?.records || [];
@@ -163,12 +143,6 @@
  getList();
};
watch(activeTab, () => {
  page.current = 1;
  loadStatus.value = "loadmore";
  getList();
});
const handleQuery = () => {
  page.current = 1;
  loadStatus.value = "loadmore";
@@ -176,9 +150,8 @@
};
const goAdd = () => {
  const type = isQualified() ? "0" : "1";
  uni.navigateTo({
    url: `/pages/consumablesLogistics/stockManagement/add?type=${type}`,
    url: `/pages/consumablesLogistics/stockManagement/add?type=0`,
  });
};
@@ -202,13 +175,12 @@
      "stockSubtractRecord",
      JSON.stringify({
        item: row,
        type: isQualified() ? "0" : "1",
        type: "0",
      })
    );
  } catch (e) {}
  const typeParam = isQualified() ? "0" : "1";
  uni.navigateTo({
    url: `/pages/consumablesLogistics/stockManagement/subtract?type=${typeParam}&id=${row.id}`,
    url: `/pages/consumablesLogistics/stockManagement/subtract?type=0&id=${row.id}`,
  });
};
@@ -243,9 +215,9 @@
  const base = { id, lockedQuantity: num };
  let promise;
  if (quantityOp.value === "frozen") {
    promise = isQualified() ? frozenConsumablesIn(base) : frozenConsumablesUninventory(base);
    promise = frozenConsumablesIn(base);
  } else {
    promise = isQualified() ? thawConsumablesIn(base) : thawConsumablesUninventory(base);
    promise = thawConsumablesIn(base);
  }
  promise
    .then(() => {
@@ -283,9 +255,6 @@
<style lang="scss" scoped>
.stock-mgmt-page { min-height: 100vh; background: #f5f5f5; padding-bottom: 120rpx; }
.tabs-wrap { display: flex; background: #fff; padding: 24rpx; gap: 24rpx; }
.tab-item { flex: 1; text-align: center; padding: 20rpx; border-radius: 12rpx; background: #f0f0f0; font-size: 28rpx; color: #666; }
.tab-item.active { background: #2979ff; color: #fff; }
.search-section { background: #fff; margin: 24rpx; padding: 24rpx; border-radius: 16rpx; }
.search-row { display: flex; align-items: center; }
.search-input-wrap { flex: 1; margin-right: 20rpx; min-width: 0; }