diff --git a/.env.development b/.env.development
index cebb88f..44a0802 100644
--- a/.env.development
+++ b/.env.development
@@ -8,17 +8,17 @@ VITE_OPEN = true
ENV = 'development'
# ADMIN 服务地址
-VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/ # 测试线上
+# VITE_ADMIN_PROXY_PATH = http://123.156.230.15:8089/api/ # 测试线上
# VITE_ADMIN_PROXY_PATH = http://pjcloud.center.takin.cc/
# VITE_ADMIN_PROXY_PATH = http://localhost:9999/
-# VITE_ADMIN_PROXY_PATH = http://192.168.101.125:9999/ # 邓-本地
+VITE_ADMIN_PROXY_PATH = http://192.168.101.132:9999/ # 邓-本地
# VITE_ADMIN_PROXY_PATH = http://59.202.170.152:81/api # 正式环境线上
# 图片访问基础地址
-VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api/ # 测试线上
+# VITE_IMAGE_BASE_PATH = http://123.156.230.15:8089/api/ # 测试线上
# VITE_IMAGE_BASE_PATH = http://pjcloud.center.takin.cc
# VITE_IMAGE_BASE_PATH = http://localhost:9999
-# VITE_IMAGE_BASE_PATH = http://192.168.101.125:9999 # 邓-本地
+VITE_IMAGE_BASE_PATH = http://192.168.101.132:9999 # 邓-本地
# VITE_IMAGE_BASE_PATH = http://59.202.170.152:81/api/ # 正式环境线上
# 代码生成服务地址
diff --git a/src/components/Select/SelectSupermarketSupplier.vue b/src/components/Select/SelectSupermarketSupplier.vue
index d267f95..dba3e01 100644
--- a/src/components/Select/SelectSupermarketSupplier.vue
+++ b/src/components/Select/SelectSupermarketSupplier.vue
@@ -10,13 +10,30 @@
:loading="state.loading"
@visible-change="handleVisibleChange"
@change="handleChange"
+ popper-class="supplier-select-dropdown"
>
+
+ 加载中...
+
+
+ 没有更多数据了
+
+
+
diff --git a/src/views/supermarketerp/components/select-dialog.vue b/src/views/supermarketerp/components/select-dialog.vue
index 999621e..70baa71 100644
--- a/src/views/supermarketerp/components/select-dialog.vue
+++ b/src/views/supermarketerp/components/select-dialog.vue
@@ -1,5 +1,5 @@
-
+
@@ -24,8 +24,7 @@
v-loading="loading"
:row-key="(row:any) => row.id"
:reserve-selection="true"
- @row-click="rowClick"
- :row-style="{ cursor: 'pointer' }"
+ @selection-change="handleSelectionChange"
>
@@ -35,20 +34,30 @@
-
-
-
@@ -75,6 +84,7 @@ import { ref } from "vue"
import { getErpSpuPage } from "/@/api/supermarketerp/common"
import { getSupermarketCategory, getSupermarketBrand } from "/@/api/supermarketerp/supermarketSpu"
import { useDict } from "/@/hooks/dict"
+import { displayPrice } from "/@/utils/formatMoney"
const emit = defineEmits(["getSelectedRows"])
const props = withDefaults(
@@ -100,10 +110,29 @@ const total = ref(0)
const dataList = ref([]) // 对话框多选表格数据
const supermarketCategory = ref([]) // 商品分类
const supermarketBrand = ref([]) // 商品品牌
+const selectedRowsWithUnit = ref([]) // 记录选中行及其包装单位
+const currentSelectedRows = ref([]) // 当前选中的商品行
+
+// 格式化价格显示
+const formatPrice = (price: number) => {
+ return displayPrice(price, "")
+}
+
+// 判断行是否被选中
+const isRowSelected = (row: any) => {
+ return currentSelectedRows.value.some((selectedRow: any) => selectedRow.id === row.id)
+}
+
+// 处理商品选择变化
+const handleSelectionChange = (selection: any[]) => {
+ currentSelectedRows.value = selection
+}
// 打开弹窗
const openDialog = async () => {
dialogVisible.value = true
+ selectedRowsWithUnit.value = []
+ currentSelectedRows.value = []
getDataListAndSelect()
}
@@ -113,21 +142,24 @@ const getDataListAndSelect = async () => {
try {
const { code, data } = await getErpSpuPage(queryForm)
if (code === 0) {
- dataList.value = data.records.map((item: any) => ({ ...item, erpSpuId: item.id }))
+ dataList.value = data.records.map((item: any) => {
+ return {
+ ...item,
+ erpSpuId: item.id
+ }
+ })
total.value = data.total
- // 保存当前已选中的行
- // const currentSelectedRows = tableRef.value?.getSelectionRows() || []
- // 清空表格数据后重新设置
+ // 恢复之前的选择状态
nextTick(() => {
- // 合并当前页面数据中的已选行和之前保存的已选行
- const rowsToSelect = [...props.selectedRows.filter((row) => dataList.value.some((item) => item.erpSpuId === row.erpSpuId))]
- // 去重
- // const uniqueRowsToSelect = Array.from(new Map(rowsToSelect.map((row) => [row.erpSpuId, row])).values())
- // 为匹配的行设置选中状态
- rowsToSelect.forEach((row) => {
+ const rowsToRestore = props.selectedRows.filter((row) => dataList.value.some((item) => item.erpSpuId === row.erpSpuId))
+
+ // 恢复商品选择状态
+ rowsToRestore.forEach((row) => {
const targetRow = dataList.value.find((item) => item.erpSpuId === row.erpSpuId)
- targetRow && tableRef.value?.toggleRowSelection(targetRow, true)
+ if (targetRow) {
+ tableRef.value?.toggleRowSelection(targetRow, true)
+ }
})
})
}
@@ -153,24 +185,22 @@ const resetQuery = () => {
getDataListAndSelect()
}
-// 点击商品列表表格行
-const rowClick = (row: any) => {
- console.log("clicked-row", row)
- tableRef.value.toggleRowSelection(row)
-}
-
// 商品选择对话框确认
const dialogConfirm = () => {
const $table = tableRef.value
if ($table) {
- // 获取所有选中的行,包括其他页面的选择
+ // 获取当前选中的商品
const currentSelectedRows = $table.getSelectionRows()
+
// 合并当前选中的行和之前已选的行(排除当前页面的行)
const allSelectedRows = [
...currentSelectedRows,
...props.selectedRows.filter((row) => !dataList.value.some((item) => item.erpSpuId === row.erpSpuId)),
]
+
dialogVisible.value = false
+ selectedRowsWithUnit.value = []
+ currentSelectedRows.value = []
emit("getSelectedRows", allSelectedRows)
}
}