From a4203d1c0e24a69b3de3a4cf9f3cb1d727602224 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 15 一月 2026 17:24:58 +0800
Subject: [PATCH] 来票登记,开票登记一些计算问题(后端接口未完善)
---
src/views/basicData/product/ProductSelectDialog.vue | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 52 insertions(+), 4 deletions(-)
diff --git a/src/views/basicData/product/ProductSelectDialog.vue b/src/views/basicData/product/ProductSelectDialog.vue
index 246cd88..9f85785 100644
--- a/src/views/basicData/product/ProductSelectDialog.vue
+++ b/src/views/basicData/product/ProductSelectDialog.vue
@@ -33,12 +33,14 @@
<!-- 鍒楄〃 -->
<el-table
+ ref="tableRef"
v-loading="loading"
:data="tableData"
height="420"
highlight-current-row
row-key="id"
@selection-change="handleSelectionChange"
+ @select="handleSelect"
>
<el-table-column type="selection" width="55" />
<el-table-column type="index" label="#" width="60"/>
@@ -70,7 +72,7 @@
</template>
<script setup lang="ts">
-import {computed, onMounted, reactive, ref, watch} from "vue";
+import {computed, onMounted, reactive, ref, watch, nextTick} from "vue";
import {ElMessage} from "element-plus";
import {productModelList} from '@/api/basicData/productModel'
@@ -83,6 +85,7 @@
const props = defineProps<{
modelValue: boolean;
+ single?: boolean; // 鏄惁鍙兘閫夋嫨涓�涓紝榛樿false锛堝彲閫夋嫨澶氫釜锛�
}>();
const emit = defineEmits(['update:modelValue', 'confirm']);
@@ -105,14 +108,48 @@
const loading = ref(false);
const tableData = ref<ProductRow[]>([]);
const total = ref(0);
-const multipleSelection = ref<ProductRow[]>([])
+const multipleSelection = ref<ProductRow[]>([]);
+const tableRef = ref();
function close() {
visible.value = false;
}
const handleSelectionChange = (val: ProductRow[]) => {
- multipleSelection.value = val
+ if (props.single && val.length > 1) {
+ // 濡傛灉闄愬埗涓哄崟涓�夋嫨锛屽彧淇濈暀鏈�鍚庝竴涓�変腑鐨�
+ const lastSelected = val[val.length - 1];
+ multipleSelection.value = [lastSelected];
+ // 娓呯┖琛ㄦ牸閫変腑鐘舵�侊紝鐒跺悗閲嶆柊閫変腑鏈�鍚庝竴涓�
+ nextTick(() => {
+ if (tableRef.value) {
+ tableRef.value.clearSelection();
+ tableRef.value.toggleRowSelection(lastSelected, true);
+ }
+ });
+ } else {
+ multipleSelection.value = val;
+ }
+}
+
+// 澶勭悊鍗曚釜閫夋嫨
+const handleSelect = (selection: ProductRow[], row: ProductRow) => {
+ if (props.single) {
+ // 濡傛灉闄愬埗涓哄崟涓紝娓呯┖鍏朵粬閫夋嫨锛屽彧淇濈暀褰撳墠琛�
+ if (selection.includes(row)) {
+ // 閫変腑褰撳墠琛屾椂锛屾竻绌哄叾浠栭�変腑
+ multipleSelection.value = [row];
+ nextTick(() => {
+ if (tableRef.value) {
+ tableData.value.forEach((item) => {
+ if (item.id !== row.id) {
+ tableRef.value.toggleRowSelection(item, false);
+ }
+ });
+ }
+ });
+ }
+ }
}
function onSearch() {
@@ -136,7 +173,11 @@
ElMessage.warning("璇烽�夋嫨涓�鏉′骇鍝�");
return;
}
- emit("confirm", multipleSelection.value);
+ if (props.single && multipleSelection.value.length > 1) {
+ ElMessage.warning("鍙兘閫夋嫨涓�涓骇鍝�");
+ return;
+ }
+ emit("confirm", props.single ? [multipleSelection.value[0]] : multipleSelection.value);
close();
}
@@ -157,6 +198,13 @@
}
}
+// 鐩戝惉寮圭獥鎵撳紑锛岄噸缃�夋嫨
+watch(() => props.modelValue, (visible) => {
+ if (visible) {
+ multipleSelection.value = [];
+ }
+});
+
onMounted(() => {
loadData()
})
--
Gitblit v1.9.3