From 3baaad59171ded6aca17340fcc907acbeeb45b7b Mon Sep 17 00:00:00 2001
From: zhuguifei <zhuguifei@zhuguifeideiMac.local>
Date: 星期二, 08 四月 2025 08:14:43 +0800
Subject: [PATCH] Merge branch 'main' of http://lanpucloud.cn:1111/r/eims-master

---
 eims-ui/apps/web-antd/src/views/eims/spare-type/index.vue |  170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 170 insertions(+), 0 deletions(-)

diff --git a/eims-ui/apps/web-antd/src/views/eims/spare-type/index.vue b/eims-ui/apps/web-antd/src/views/eims/spare-type/index.vue
new file mode 100644
index 0000000..934c166
--- /dev/null
+++ b/eims-ui/apps/web-antd/src/views/eims/spare-type/index.vue
@@ -0,0 +1,170 @@
+<script setup lang="ts">
+import type { Recordable } from '@vben/types';
+
+import { Page, useVbenDrawer, type VbenFormProps } from '@vben/common-ui';
+import { eachTree, getVxePopupContainer } from '@vben/utils';
+
+import { Popconfirm, Space } from 'ant-design-vue';
+
+import { useVbenVxeGrid, type VxeGridProps } from '#/adapter/vxe-table';
+import { delSpareType, spareTypeExport, listSpareType } from '#/api/eims/spare-type';
+import { $t } from '@vben/locales';
+import { commonDownloadExcel } from '#/utils/file/download';
+
+import { columns, querySchema } from './data';
+import spareTypeDrawer from './spare-type-drawer.vue';
+
+/**
+ * 涓嶈闂负浠�涔堟湁涓や釜鏍硅妭鐐� v-if浼氭帶鍒跺彧浼氭覆鏌撲竴涓�
+ */
+
+const formOptions: VbenFormProps = {
+  commonConfig: {
+    labelWidth: 80,
+    componentProps: {
+      allowClear: true
+    }
+  },
+  schema: querySchema(),
+  wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4'
+};
+
+const gridOptions: VxeGridProps = {
+  columns,
+  height: 'auto',
+  keepSource: true,
+  pagerConfig: {
+    enabled: false
+  },
+  proxyConfig: {
+    ajax: {
+      query: async (_, formValues = {}) => {
+        const resp = await listSpareType({
+          ...formValues
+        });
+        return { rows: resp };
+      }
+    }
+  },
+  rowConfig: {
+    isHover: true,
+    keyField: 'id'
+  },
+  /**
+   * 寮�鍚櫄鎷熸粴鍔�
+   * 鏁版嵁閲忓皬鍙互閫夋嫨鍏抽棴
+   * 濡傛灉閬囧埌鏍峰紡闂(绌虹櫧銆侀敊浣� 婊氬姩绛�)鍙互閫夋嫨鍏抽棴铏氭嫙婊氬姩
+   */
+  scrollY: {
+    enabled: true,
+    gt: 0
+  },
+  treeConfig: {
+    parentField: 'parentId',
+    rowField: 'id',
+    // 鑷姩杞崲涓簍ree 鐢眝xe澶勭悊 鏃犻渶鎵嬪姩杞崲
+    transform: true
+  },
+  id: 'spare-type-index'
+};
+
+const [BasicTable, tableApi] = useVbenVxeGrid({
+  formOptions,
+  gridOptions,
+  gridEvents: {
+    cellDblclick: (e: any) => {
+      const { row = {} } = e;
+      if (!row?.children) {
+        return;
+      }
+      const isExpanded = row?.expand;
+      tableApi.grid.setTreeExpand(row, !isExpanded);
+      row.expand = !isExpanded;
+    },
+    // 闇�瑕佺洃鍚娇鐢ㄧ澶村睍寮�鐨勬儏鍐� 鍚﹀垯灞曞紑/鎶樺彔鐨勬暟鎹笉涓�鑷�
+    toggleTreeExpand: (e: any) => {
+      const { row = {}, expanded } = e;
+      row.expand = expanded;
+    }
+  }
+});
+const [SpareTypeDrawer, drawerApi] = useVbenDrawer({
+  connectedComponent: spareTypeDrawer
+});
+
+function handleAdd() {
+  drawerApi.setData({});
+  drawerApi.open();
+}
+
+function handleSubAdd(row: Recordable<any>) {
+  const { id } = row;
+  drawerApi.setData({ id, update: false });
+  drawerApi.open();
+}
+
+async function handleEdit(record: Recordable<any>) {
+  drawerApi.setData({ id: record.id, update: true });
+  drawerApi.open();
+}
+
+async function handleDelete(row: Recordable<any>) {
+  await delSpareType(row.id);
+  await tableApi.query();
+}
+
+function handleDownloadExcel() {
+  commonDownloadExcel(spareTypeExport, '澶囦欢绫诲瀷', tableApi.formApi.form.values, {
+    fieldMappingTime: formOptions.fieldMappingTime
+  });
+}
+
+/**
+ * 鍏ㄩ儴灞曞紑/鎶樺彔
+ * @param expand 鏄惁灞曞紑
+ */
+function setExpandOrCollapse(expand: boolean) {
+  eachTree(tableApi.grid.getData(), (item) => (item.expand = expand));
+  tableApi.grid?.setAllTreeExpand(expand);
+}
+</script>
+
+<template>
+  <Page :auto-content-height="true">
+    <BasicTable table-title="澶囦欢绫诲瀷鍒楄〃" table-title-help="鍙屽嚮灞曞紑/鏀惰捣瀛愯彍鍗�">
+      <template #toolbar-tools>
+        <Space>
+          <a-button @click="setExpandOrCollapse(false)">
+            {{ $t('pages.common.collapse') }}
+          </a-button>
+          <a-button @click="setExpandOrCollapse(true)">
+            {{ $t('pages.common.expand') }}
+          </a-button>
+          <a-button v-access:code="['eims:spareType:export']" @click="handleDownloadExcel">
+            {{ $t('pages.common.export') }}
+          </a-button>
+          <a-button type="primary" v-access:code="['eims:spareType:add']" @click="handleAdd">
+            {{ $t('pages.common.add') }}
+          </a-button>
+        </Space>
+      </template>
+      <template #action="{ row }">
+        <Space>
+          <ghost-button v-access:code="['eims:spareType:edit']" @click="handleEdit(row)">
+            {{ $t('pages.common.edit') }}
+          </ghost-button>
+          <!-- '鎸夐挳绫诲瀷'鏃犳硶鍐嶆坊鍔犲瓙鑿滃崟 -->
+          <ghost-button v-if="row.menuType !== 'F'" class="btn-success" v-access:code="['eims:spareType:add']" @click="handleSubAdd(row)">
+            {{ $t('pages.common.add') }}
+          </ghost-button>
+          <Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="纭鍒犻櫎锛�" @confirm="handleDelete(row)">
+            <ghost-button danger v-access:code="['eims:spareType:remove']" @click.stop="">
+              {{ $t('pages.common.delete') }}
+            </ghost-button>
+          </Popconfirm>
+        </Space>
+      </template>
+    </BasicTable>
+    <SpareTypeDrawer @reload="tableApi.query()" />
+  </Page>
+</template>

--
Gitblit v1.9.3