6 天以前 053025d1e3952826ec570072d62cf8ed845ce9c7
src/views/basicData/mdm/index.vue
@@ -8,7 +8,7 @@
import { confirm, Page, useVbenModal } from '#/packages/effects/common-ui/src';
import { downloadFileFromBlobPart, isEmpty } from '#/packages/utils/src';
import { message, Tag } from 'ant-design-vue';
import { message, Switch, Tag } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import {
@@ -17,6 +17,7 @@
  // exportItem,
  getItemPage,
  updateItemStatus,
  updateItemSync,
} from '#/api/mdm/item';
import { getItemTypeSimpleList } from '#/api/mes/md/item/type';
import { $t } from '#/locales';
@@ -138,6 +139,23 @@
  }
}
const syncingId = ref<number | null>(null);
/** 切换同步状态:关闭开关会从 MES 删除物料,需确认 */
async function handleSyncChange(row: MdmItemApi.Item, checked: boolean) {
  if (!checked) {
    await confirm('关闭同步将从 MES 删除该物料及关联配置(BOM/SOP/SIP/批次配置),确认继续?');
  }
  syncingId.value = row.id!;
  try {
    await updateItemSync(row.id!, checked);
    message.success(checked ? '已同步到 MES' : '已取消同步');
    handleRefresh();
  } finally {
    syncingId.value = null;
  }
}
const checkedIds = ref<number[]>([]);
function handleRowCheckboxChange({
  records,
@@ -232,8 +250,13 @@
        <Tag v-else>否</Tag>
      </template>
      <template #syncedMes="{ row }">
        <Tag v-if="row.syncedMes" color="success">已同步</Tag>
        <Tag v-else color="default">未同步</Tag>
        <Switch
          :checked="row.syncedMes"
          :loading="syncingId === row.id"
          checkedChildren="已同步"
          unCheckedChildren="未同步"
          @change="handleSyncChange(row, $event)"
        />
      </template>
      <template #actions="{ row }">
        <TableAction