|
@@ -32,8 +32,11 @@
|
|
|
<script setup lang="tsx">
|
|
|
import { reactive, ref } from 'vue';
|
|
|
import type { Ref } from 'vue';
|
|
|
-import { NButton, NPopconfirm, NSpace } from 'naive-ui';
|
|
|
+import { NButton, NPopconfirm, NSpace, NTag } from 'naive-ui';
|
|
|
import type { DataTableColumns, PaginationProps } from 'naive-ui';
|
|
|
+import { EventIsShowLabels } from '@/constants';
|
|
|
+import { routeName } from '@/router';
|
|
|
+import { useRouterPush } from '@/composables';
|
|
|
import { useBoolean, useLoading } from '@/hooks';
|
|
|
import { fetchEventDelete, fetchEventList } from '@/service/api/event';
|
|
|
import TableActionModal from './components/table-action-modal.vue';
|
|
@@ -43,6 +46,8 @@ const { loading, startLoading, endLoading } = useLoading(false);
|
|
|
const { bool: visible, setTrue: openModal } = useBoolean();
|
|
|
const eventName = ref('');
|
|
|
const tableData = ref<BackgroundEvent.Event[]>([]);
|
|
|
+const { routerPush } = useRouterPush();
|
|
|
+
|
|
|
function setTableData(data: BackgroundEvent.Event[]) {
|
|
|
tableData.value = data;
|
|
|
}
|
|
@@ -76,7 +81,20 @@ const columns: Ref<DataTableColumns<BackgroundEvent.Event>> = ref([
|
|
|
{
|
|
|
key: 'is_show',
|
|
|
title: '是否启用',
|
|
|
- align: 'center'
|
|
|
+ align: 'center',
|
|
|
+ render: row => {
|
|
|
+ if (row.is_show) {
|
|
|
+ const tagTypes: Record<BackgroundEvent.IsShowKey, NaiveUI.ThemeColor> = {
|
|
|
+ '0': 'error',
|
|
|
+ '1': 'success',
|
|
|
+ '2': 'warning'
|
|
|
+ };
|
|
|
+
|
|
|
+ return <NTag type={tagTypes[row.is_show]}>{EventIsShowLabels[row.is_show]}</NTag>;
|
|
|
+ }
|
|
|
+
|
|
|
+ return <span></span>;
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
key: 'remarks',
|
|
@@ -90,7 +108,7 @@ const columns: Ref<DataTableColumns<BackgroundEvent.Event>> = ref([
|
|
|
render: row => {
|
|
|
return (
|
|
|
<NSpace justify={'center'}>
|
|
|
- <NButton type="info" size={'small'} onClick={() => handleEditTable(row.id)}>
|
|
|
+ <NButton type="info" size={'small'} onClick={() => handleCondition(row.id)}>
|
|
|
设置
|
|
|
</NButton>
|
|
|
</NSpace>
|
|
@@ -107,7 +125,7 @@ const columns: Ref<DataTableColumns<BackgroundEvent.Event>> = ref([
|
|
|
<NButton type="info" size={'small'} onClick={() => handleEditTable(row.id)}>
|
|
|
编辑
|
|
|
</NButton>
|
|
|
- <NButton type="warning" size={'small'} onClick={() => handleEditTable(row.id)}>
|
|
|
+ <NButton type="warning" size={'small'} onClick={() => handleSetting(row.id)}>
|
|
|
影响设置
|
|
|
</NButton>
|
|
|
<NPopconfirm onPositiveClick={() => handleDeleteTable(row.id)}>
|
|
@@ -152,6 +170,26 @@ function handleEditTable(rowId: number) {
|
|
|
openModal();
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * 影响设置
|
|
|
+ */
|
|
|
+function handleSetting(rowId: number) {
|
|
|
+ console.log(rowId);
|
|
|
+}
|
|
|
+
|
|
|
+/*
|
|
|
+ * 执行条件设置
|
|
|
+ */
|
|
|
+function handleCondition(rowId: number) {
|
|
|
+ const findItem = tableData.value.find(item => item.id === rowId);
|
|
|
+ if (findItem) {
|
|
|
+ setEditData(findItem);
|
|
|
+ }
|
|
|
+ routerPush({ name: routeName('function_tab-detail'), query: { name: 'abc' }, hash: '#DEMO_HASH' });
|
|
|
+
|
|
|
+ openModal();
|
|
|
+}
|
|
|
+
|
|
|
function handleDeleteTable(rowId: number) {
|
|
|
const data = fetchEventDelete(rowId);
|
|
|
data.then(res => {
|