|
@@ -1,5 +1,5 @@
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, onMounted } from "vue";
|
|
|
|
|
|
|
+import { ref, reactive, onMounted } from "vue";
|
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
import { ElMessage, ElMessageBox } from "element-plus";
|
|
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
|
import { useRenderIcon } from "@/components/ReIcon/src/hooks";
|
|
|
import Refresh from "~icons/ep/refresh";
|
|
import Refresh from "~icons/ep/refresh";
|
|
@@ -22,6 +22,8 @@ const loading = ref(false);
|
|
|
const syncing = ref(false);
|
|
const syncing = ref(false);
|
|
|
const keyword = ref("");
|
|
const keyword = ref("");
|
|
|
const dataList = ref<any[]>([]);
|
|
const dataList = ref<any[]>([]);
|
|
|
|
|
+const total = ref(0);
|
|
|
|
|
+const pagination = reactive({ currentPage: 1, pageSize: 10 });
|
|
|
const productOptions = ref<any[]>([]);
|
|
const productOptions = ref<any[]>([]);
|
|
|
const bindDialogVisible = ref(false);
|
|
const bindDialogVisible = ref(false);
|
|
|
const currentErpGoods = ref<any>(null);
|
|
const currentErpGoods = ref<any>(null);
|
|
@@ -31,10 +33,14 @@ const bindLoading = ref(false);
|
|
|
async function fetchList() {
|
|
async function fetchList() {
|
|
|
loading.value = true;
|
|
loading.value = true;
|
|
|
try {
|
|
try {
|
|
|
- const res = await getErpGoodsList(keyword.value || undefined);
|
|
|
|
|
|
|
+ const res = await getErpGoodsList({
|
|
|
|
|
+ keyword: keyword.value || undefined,
|
|
|
|
|
+ page: pagination.currentPage,
|
|
|
|
|
+ pageSize: pagination.pageSize
|
|
|
|
|
+ });
|
|
|
if (res.code === 200) {
|
|
if (res.code === 200) {
|
|
|
- dataList.value = res.data || [];
|
|
|
|
|
- // 检查各 ERP 商品的关联状态
|
|
|
|
|
|
|
+ dataList.value = res.data?.list || [];
|
|
|
|
|
+ total.value = res.data?.total || 0;
|
|
|
await fetchBoundStatus();
|
|
await fetchBoundStatus();
|
|
|
}
|
|
}
|
|
|
} finally {
|
|
} finally {
|
|
@@ -42,6 +48,22 @@ async function fetchList() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function handlePageChange(page: number) {
|
|
|
|
|
+ pagination.currentPage = page;
|
|
|
|
|
+ fetchList();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function handleSizeChange(size: number) {
|
|
|
|
|
+ pagination.currentPage = 1;
|
|
|
|
|
+ pagination.pageSize = size;
|
|
|
|
|
+ fetchList();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function handleSearch() {
|
|
|
|
|
+ pagination.currentPage = 1;
|
|
|
|
|
+ fetchList();
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
async function fetchBoundStatus() {
|
|
async function fetchBoundStatus() {
|
|
|
try {
|
|
try {
|
|
|
const res = await getProductList({ page: 1, pageSize: 1000 });
|
|
const res = await getProductList({ page: 1, pageSize: 1000 });
|
|
@@ -146,13 +168,13 @@ onMounted(() => {
|
|
|
placeholder="搜索商品名称或编码"
|
|
placeholder="搜索商品名称或编码"
|
|
|
clearable
|
|
clearable
|
|
|
class="w-[240px]!"
|
|
class="w-[240px]!"
|
|
|
- @keyup.enter="fetchList"
|
|
|
|
|
|
|
+ @keyup.enter="handleSearch"
|
|
|
>
|
|
>
|
|
|
<template #prefix>
|
|
<template #prefix>
|
|
|
<el-icon><component :is="useRenderIcon(Search)" /></el-icon>
|
|
<el-icon><component :is="useRenderIcon(Search)" /></el-icon>
|
|
|
</template>
|
|
</template>
|
|
|
</el-input>
|
|
</el-input>
|
|
|
- <el-button @click="fetchList">搜索</el-button>
|
|
|
|
|
|
|
+ <el-button @click="handleSearch">搜索</el-button>
|
|
|
<el-button
|
|
<el-button
|
|
|
type="primary"
|
|
type="primary"
|
|
|
:icon="useRenderIcon(Refresh)"
|
|
:icon="useRenderIcon(Refresh)"
|
|
@@ -226,40 +248,88 @@ onMounted(() => {
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="flex justify-end mt-4">
|
|
|
|
|
+ <el-pagination
|
|
|
|
|
+ v-model:current-page="pagination.currentPage"
|
|
|
|
|
+ v-model:page-size="pagination.pageSize"
|
|
|
|
|
+ :total="total"
|
|
|
|
|
+ :page-sizes="[10, 20, 50]"
|
|
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
|
+ background
|
|
|
|
|
+ @current-change="handlePageChange"
|
|
|
|
|
+ @size-change="handleSizeChange"
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<!-- 关联对话框 -->
|
|
<!-- 关联对话框 -->
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
v-model="bindDialogVisible"
|
|
v-model="bindDialogVisible"
|
|
|
title="关联本地商品"
|
|
title="关联本地商品"
|
|
|
- width="520px"
|
|
|
|
|
|
|
+ width="680px"
|
|
|
:close-on-click-modal="false"
|
|
:close-on-click-modal="false"
|
|
|
>
|
|
>
|
|
|
|
|
+ <!-- ERP 商品信息卡片 -->
|
|
|
|
|
+ <div class="flex items-center gap-4 mb-5 p-4 bg-gray-50 rounded-lg">
|
|
|
|
|
+ <el-image
|
|
|
|
|
+ v-if="currentErpGoods?.picPath"
|
|
|
|
|
+ :src="currentErpGoods.picPath"
|
|
|
|
|
+ :preview-src-list="[currentErpGoods.picPath]"
|
|
|
|
|
+ fit="cover"
|
|
|
|
|
+ preview-teleported
|
|
|
|
|
+ style="width:72px;height:72px;border-radius:6px;flex-shrink:0"
|
|
|
|
|
+ />
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-else
|
|
|
|
|
+ class="w-[72px] h-[72px] rounded-md flex items-center justify-center bg-gray-200 text-gray-400 text-xs flex-shrink-0"
|
|
|
|
|
+ >
|
|
|
|
|
+ 无图
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="min-w-0">
|
|
|
|
|
+ <div class="text-sm text-gray-500">{{ currentErpGoods?.goodsCode }}</div>
|
|
|
|
|
+ <div class="text-base font-medium mt-1 truncate">{{ currentErpGoods?.goodsName }}</div>
|
|
|
|
|
+ <div class="text-xs text-gray-400 mt-1">
|
|
|
|
|
+ 规格: {{ currentErpGoods?.specs || '-' }} | 售价: ¥{{ currentErpGoods?.salePrice || '-' }}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
<el-form label-width="100px">
|
|
<el-form label-width="100px">
|
|
|
- <el-form-item label="ERP 商品">
|
|
|
|
|
- <el-input
|
|
|
|
|
- :model-value="
|
|
|
|
|
- currentErpGoods?.goodsCode +
|
|
|
|
|
- ' - ' +
|
|
|
|
|
- currentErpGoods?.goodsName
|
|
|
|
|
- "
|
|
|
|
|
- disabled
|
|
|
|
|
- />
|
|
|
|
|
- </el-form-item>
|
|
|
|
|
<el-form-item label="选择本地商品">
|
|
<el-form-item label="选择本地商品">
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="selectedProductId"
|
|
v-model="selectedProductId"
|
|
|
- placeholder="请选择要关联的本地商品"
|
|
|
|
|
|
|
+ placeholder="请搜索并选择要关联的本地商品"
|
|
|
clearable
|
|
clearable
|
|
|
filterable
|
|
filterable
|
|
|
class="w-full!"
|
|
class="w-full!"
|
|
|
|
|
+ popper-class="erp-bind-select-popper"
|
|
|
>
|
|
>
|
|
|
<el-option
|
|
<el-option
|
|
|
v-for="p in productOptions"
|
|
v-for="p in productOptions"
|
|
|
:key="p.id"
|
|
:key="p.id"
|
|
|
:label="`[${p.code || '无编码'}] ${p.name}`"
|
|
:label="`[${p.code || '无编码'}] ${p.name}`"
|
|
|
:value="p.id"
|
|
:value="p.id"
|
|
|
- />
|
|
|
|
|
|
|
+ >
|
|
|
|
|
+ <div class="flex items-center gap-3 py-0.5">
|
|
|
|
|
+ <el-image
|
|
|
|
|
+ v-if="p.pic"
|
|
|
|
|
+ :src="p.pic"
|
|
|
|
|
+ fit="cover"
|
|
|
|
|
+ style="width:40px;height:40px;border-radius:4px;flex-shrink:0"
|
|
|
|
|
+ />
|
|
|
|
|
+ <div
|
|
|
|
|
+ v-else
|
|
|
|
|
+ class="w-[40px] h-[40px] rounded flex items-center justify-center bg-gray-100 text-gray-300 flex-shrink-0"
|
|
|
|
|
+ >
|
|
|
|
|
+ <el-icon size="16"><component :is="useRenderIcon(Search)" /></el-icon>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="min-w-0">
|
|
|
|
|
+ <div class="text-sm truncate">{{ p.name }}</div>
|
|
|
|
|
+ <div class="text-xs text-gray-400">{{ p.code || '无编码' }}</div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
</el-form>
|
|
</el-form>
|
|
@@ -272,3 +342,9 @@ onMounted(() => {
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+
|
|
|
|
|
+<style lang="scss">
|
|
|
|
|
+.erp-bind-select-popper {
|
|
|
|
|
+ max-width: 600px !important;
|
|
|
|
|
+}
|
|
|
|
|
+</style>
|