From a1d7e81859f554f3a53680cc35f0f49bf1f77098 Mon Sep 17 00:00:00 2001
From: wwf <1971391498@qq.com>
Date: 星期四, 14 五月 2026 14:37:02 +0800
Subject: [PATCH] 导入项目

---
 src/views/erp/stock/stock/index.vue |  186 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 186 insertions(+), 0 deletions(-)

diff --git a/src/views/erp/stock/stock/index.vue b/src/views/erp/stock/stock/index.vue
new file mode 100644
index 0000000..4d80117
--- /dev/null
+++ b/src/views/erp/stock/stock/index.vue
@@ -0,0 +1,186 @@
+<!-- ERP 浜у搧搴撳瓨鍒楄〃 -->
+<template>
+  <doc-alert title="銆愬簱瀛樸�戜骇鍝佸簱瀛樸�佸簱瀛樻槑缁�" url="https://doc.iocoder.cn/erp/stock/" />
+
+  <ContentWrap>
+    <!-- 鎼滅储宸ヤ綔鏍� -->
+    <el-form
+      class="-mb-15px"
+      :model="queryParams"
+      ref="queryFormRef"
+      :inline="true"
+      label-width="68px"
+    >
+      <el-form-item label="浜у搧" prop="productId">
+        <el-select
+          v-model="queryParams.productId"
+          clearable
+          filterable
+          placeholder="璇烽�夋嫨浜у搧"
+          class="!w-240px"
+        >
+          <el-option
+            v-for="item in productList"
+            :key="item.id"
+            :label="item.name"
+            :value="item.id"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item label="浠撳簱" prop="warehouseId">
+        <el-select
+          v-model="queryParams.warehouseId"
+          clearable
+          filterable
+          placeholder="璇烽�夋嫨浠撳簱"
+          class="!w-240px"
+        >
+          <el-option
+            v-for="item in warehouseList"
+            :key="item.id"
+            :label="item.name"
+            :value="item.id"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 鎼滅储</el-button>
+        <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 閲嶇疆</el-button>
+        <el-button
+          type="primary"
+          plain
+          @click="openForm('create')"
+          v-hasPermi="['erp:stock:create']"
+        >
+          <Icon icon="ep:plus" class="mr-5px" /> 鏂板
+        </el-button>
+        <el-button
+          type="success"
+          plain
+          @click="handleExport"
+          :loading="exportLoading"
+          v-hasPermi="['erp:stock:export']"
+        >
+          <Icon icon="ep:download" class="mr-5px" /> 瀵煎嚭
+        </el-button>
+      </el-form-item>
+    </el-form>
+  </ContentWrap>
+
+  <!-- 鍒楄〃 -->
+  <ContentWrap>
+    <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
+      <el-table-column label="浜у搧鍚嶇О" align="center" prop="productName" />
+      <el-table-column label="浜у搧鍗曚綅" align="center" prop="unitName" />
+      <el-table-column label="浜у搧鍒嗙被" align="center" prop="categoryName" />
+      <el-table-column
+        label="搴撳瓨閲�"
+        align="center"
+        prop="count"
+        :formatter="erpCountTableColumnFormatter"
+      />
+      <el-table-column label="浠撳簱" align="center" prop="warehouseName" />
+    </el-table>
+    <!-- 鍒嗛〉 -->
+    <Pagination
+      :total="total"
+      v-model:page="queryParams.pageNo"
+      v-model:limit="queryParams.pageSize"
+      @pagination="getList"
+    />
+  </ContentWrap>
+</template>
+
+<script setup lang="ts">
+import download from '@/utils/download'
+import { StockApi, StockVO } from '@/api/erp/stock/stock'
+import { ProductApi, ProductVO } from '@/api/erp/product/product'
+import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
+import { erpCountTableColumnFormatter } from '@/utils'
+
+/** ERP 浜у搧搴撳瓨鍒楄〃 */
+defineOptions({ name: 'ErpStock' })
+
+const message = useMessage() // 娑堟伅寮圭獥
+const { t } = useI18n() // 鍥介檯鍖�
+
+const loading = ref(true) // 鍒楄〃鐨勫姞杞戒腑
+const list = ref<StockVO[]>([]) // 鍒楄〃鐨勬暟鎹�
+const total = ref(0) // 鍒楄〃鐨勬�婚〉鏁�
+const queryParams = reactive({
+  pageNo: 1,
+  pageSize: 10,
+  productId: undefined,
+  warehouseId: undefined
+})
+const queryFormRef = ref() // 鎼滅储鐨勮〃鍗�
+const exportLoading = ref(false) // 瀵煎嚭鐨勫姞杞戒腑
+const productList = ref<ProductVO[]>([]) // 浜у搧鍒楄〃
+const warehouseList = ref<WarehouseVO[]>([]) // 浠撳簱鍒楄〃
+
+/** 鏌ヨ鍒楄〃 */
+const getList = async () => {
+  loading.value = true
+  try {
+    const data = await StockApi.getStockPage(queryParams)
+    list.value = data.list
+    total.value = data.total
+  } finally {
+    loading.value = false
+  }
+}
+
+/** 鎼滅储鎸夐挳鎿嶄綔 */
+const handleQuery = () => {
+  queryParams.pageNo = 1
+  getList()
+}
+
+/** 閲嶇疆鎸夐挳鎿嶄綔 */
+const resetQuery = () => {
+  queryFormRef.value.resetFields()
+  handleQuery()
+}
+
+/** 娣诲姞/淇敼鎿嶄綔 */
+const formRef = ref()
+const openForm = (type: string, id?: number) => {
+  formRef.value.open(type, id)
+}
+
+/** 鍒犻櫎鎸夐挳鎿嶄綔 */
+const handleDelete = async (id: number) => {
+  try {
+    // 鍒犻櫎鐨勪簩娆$‘璁�
+    await message.delConfirm()
+    // 鍙戣捣鍒犻櫎
+    await StockApi.deleteStock(id)
+    message.success(t('common.delSuccess'))
+    // 鍒锋柊鍒楄〃
+    await getList()
+  } catch {}
+}
+
+/** 瀵煎嚭鎸夐挳鎿嶄綔 */
+const handleExport = async () => {
+  try {
+    // 瀵煎嚭鐨勪簩娆$‘璁�
+    await message.exportConfirm()
+    // 鍙戣捣瀵煎嚭
+    exportLoading.value = true
+    const data = await StockApi.exportStock(queryParams)
+    download.excel(data, '浜у搧搴撳瓨.xls')
+  } catch {
+  } finally {
+    exportLoading.value = false
+  }
+}
+
+/** 鍒濆鍖� **/
+onMounted(async () => {
+  await getList()
+  // 鍔犺浇浜у搧銆佷粨搴撳垪琛�
+  productList.value = await ProductApi.getProductSimpleList()
+  warehouseList.value = await WarehouseApi.getWarehouseSimpleList()
+})
+</script>

--
Gitblit v1.8.0