20260724232121

This commit is contained in:
oneao committed 2026-07-24 23:21:21 +08:00
1 parent b33c743236
commit 1b86e0043a
10 files changed
+996 -230

No files matched your search

@@ -1,5 +1,5 @@
<script setup>
import { h, nextTick, ref, watch } from "vue";
import { computed, h, nextTick, ref, watch } from "vue";
import { message, Modal } from "antdv-next";
import { Languages } from "@lucide/vue";
import FmsTable from "@/components/fms-table/FmsTable.vue";
@@ -60,9 +60,43 @@ async function addRow() {
function deleteRow(record) {
localPowers.value = localPowers.value.filter((r) => r.b_id !== record.b_id);
// 同步清理选择状态,避免选中项被删后 keys 残留
const k = String(record.b_id);
if (selectedRowKeys.value.includes(k)) {
selectedRowKeys.value = selectedRowKeys.value.filter((x) => x !== k);
}
emitUpdate();
}
// 行多选:selectedRowKeys 由 FmsTable 的选择列(createSelectionCellRenderers 提供)
// 通过 onChange 回写;FmsTable 在传了 rowSelection 时自动在最前列插入复选框列。
const selectedRowKeys = ref([]);
const rowSelection = computed(() => ({
selectedRowKeys: selectedRowKeys.value,
onChange: (keys) => {
selectedRowKeys.value = keys;
},
}));
// 批量删除选中行
function batchDelete() {
const keys = selectedRowKeys.value;
if (!keys.length) return;
Modal.confirm({
title: `确定删除选中的 ${keys.length} 条记录?`,
okText: "删除",
okType: "danger",
cancelText: "取消",
onOk: () => {
const delSet = new Set(keys);
localPowers.value = localPowers.value.filter((r) => !delSet.has(r.b_id));
selectedRowKeys.value = [];
if (activeKey.value && delSet.has(activeKey.value)) activeKey.value = "";
emitUpdate();
},
});
}
// ── 快速设置多语言 ──
const i18nModalRef = ref(null);
@@ -145,13 +179,14 @@ const CanUseCell = ({ row, cellValue }) => {
);
};
// 操作列单元格:原生 button + Modal.confirm,避免每行一个 Popconfirm 实例的开销
// 操作列单元格:普通文字「删除」按钮(原生 button,避免每行一个组件实例开销)
const ActionsCell = ({ row }) =>
h(
"button",
{
type: "button",
title: "删除",
onMousedown: (e) => e.stopPropagation(),
style: {
border: "none",
background: "transparent",
@@ -190,6 +225,9 @@ const columns = [
<div class="panel-toolbar">
<a-space>
<a-button type="primary" @click="addRow">新增权限</a-button>
<a-button danger :disabled="!selectedRowKeys.length" @click="batchDelete">
批量删除{{ selectedRowKeys.length ? `(${selectedRowKeys.length})` : "" }}
</a-button>
</a-space>
</div>
<div class="panel-body">
@@ -200,6 +238,7 @@ const columns = [
:data-source="localPowers"
row-key="b_id"
:active-row-key="activeKey"
:row-selection="rowSelection"
@row-click="(_, row) => (activeKey = String(row.b_id))"
/>
</div>
@@ -241,8 +280,10 @@ const columns = [
基于 antdv-next Checkbox 源码(checkbox/style/index.js)精确模拟外观。 -->
<style lang="scss">
.pw-checkbox {
display: inline-flex;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
cursor: pointer;
line-height: 1;
margin: 0;