|
@@ -10,18 +10,21 @@
|
|
|
:header-cell-style="{ 'text-align': 'center' }"
|
|
|
row-key="_id"
|
|
|
default-expand-all
|
|
|
+ v-loading="loading"
|
|
|
>
|
|
|
<el-table-column prop="name_zh" label="表名中文"> </el-table-column>
|
|
|
<el-table-column prop="name" label="表名"> </el-table-column>
|
|
|
<el-table-column prop="remark" label="备注"> </el-table-column>
|
|
|
<el-table-column fixed="right" label="操作">
|
|
|
<template #default="scope">
|
|
|
- <el-button link type="primary" @click.prevent="toEdit(scope.row)">修改</el-button>
|
|
|
- <el-button link type="primary" @click.prevent="toAddDir(scope.row)" v-if="scope.row.type == 'dir'">添加下级文件夹</el-button>
|
|
|
- <el-button link type="primary" @click.prevent="toAddTab(scope.row)" v-if="scope.row.type == 'dir'">添加下级表</el-button>
|
|
|
+ <el-button link type="primary" @click.prevent="toEditDir(scope.row)" v-if="scope.row.type == 'dir'">修改</el-button>
|
|
|
+ <el-button link type="primary" @click.prevent="toEdit(scope.row)" v-if="scope.row.type == 'table'">修改</el-button>
|
|
|
+ <el-button link type="success" @click.prevent="toAddDir(scope.row)" v-if="scope.row.type == 'dir'">添加下级文件夹</el-button>
|
|
|
+ <el-button link type="success" @click.prevent="toAddTab(scope.row)" v-if="scope.row.type == 'dir'">添加下级表</el-button>
|
|
|
<el-button link type="warning">导出</el-button>
|
|
|
<el-button link type="warning">导出ts</el-button>
|
|
|
- <el-button link type="danger" @click.prevent="toDel(scope.row)">删除</el-button>
|
|
|
+ <el-button link type="danger" @click.prevent="toDelDir(scope.row)" v-if="scope.row.type == 'dir'">删除</el-button>
|
|
|
+ <el-button link type="danger" @click.prevent="toDel(scope.row)" v-if="scope.row.type == 'table'">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -29,36 +32,51 @@
|
|
|
</el-col>
|
|
|
</template>
|
|
|
<script setup lang="ts">
|
|
|
-import { reactive, ref } from 'vue';
|
|
|
+import { ref } from 'vue';
|
|
|
import type { Ref } from 'vue';
|
|
|
import { useCounterStore as useStore } from '@/stores/counter';
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus';
|
|
|
const store = useStore();
|
|
|
let list: Ref<any[]> = ref([]);
|
|
|
-const props = defineProps({ list: Array });
|
|
|
-console.log(props.list);
|
|
|
-
|
|
|
-list.value = props.list as any[];
|
|
|
-
|
|
|
-const emit = defineEmits(['toEdit', 'toAddDir', 'toAddTab']);
|
|
|
-// 修改
|
|
|
+// 查询列表
|
|
|
+const search = async () => {
|
|
|
+ const res: IQueryResult = await store.tableQuery({ project: props.id });
|
|
|
+ list.value = res.data as any[];
|
|
|
+};
|
|
|
+const props = defineProps({ list: Array, id: String });
|
|
|
+const loading = ref(false);
|
|
|
+if (props.id) {
|
|
|
+ loading.value = true;
|
|
|
+ search();
|
|
|
+ loading.value = false;
|
|
|
+}
|
|
|
+// 暴露table组件search方法
|
|
|
+defineExpose({ search });
|
|
|
+const emit = defineEmits(['toEdit', 'toEditDir', 'toAddDir', 'toAddTab']);
|
|
|
+// 修改表
|
|
|
const toEdit = (row: { _id: string }) => {
|
|
|
let query: Object = { id: row._id };
|
|
|
emit('toEdit', query);
|
|
|
};
|
|
|
+// 修改文件夹
|
|
|
+const toEditDir = (row: { _id: string }) => {
|
|
|
+ let query: Object = { id: row._id };
|
|
|
+ emit('toEditDir', query);
|
|
|
+};
|
|
|
+// 添加下级文件夹
|
|
|
const toAddDir = (row: { _id: string }) => {
|
|
|
let query: Object = { id: row._id };
|
|
|
emit('toAddDir', query);
|
|
|
};
|
|
|
+// 添加下级表
|
|
|
const toAddTab = (row: { _id: string }) => {
|
|
|
let query: Object = { id: row._id };
|
|
|
emit('toAddTab', query);
|
|
|
};
|
|
|
-// 删除
|
|
|
+// 删除表
|
|
|
const toDel = (row: { _id: string }) => {
|
|
|
- console.log(row._id);
|
|
|
- ElMessageBox.confirm('是否确认删除该表', '提示', {
|
|
|
+ ElMessageBox.confirm('是否确认删除该条数据', '提示', {
|
|
|
confirmButtonText: '确认',
|
|
|
cancelButtonText: '取消',
|
|
|
type: 'warning',
|
|
@@ -66,6 +84,21 @@ const toDel = (row: { _id: string }) => {
|
|
|
const res: IQueryResult = await store.tableDelete(row._id);
|
|
|
if (res.errcode == 0) {
|
|
|
ElMessage({ type: 'success', message: '删除成功' });
|
|
|
+ search();
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+// 删除文件夹
|
|
|
+const toDelDir = (row: { _id: string }) => {
|
|
|
+ ElMessageBox.confirm('是否确认删除该条数据', '提示', {
|
|
|
+ confirmButtonText: '确认',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning',
|
|
|
+ }).then(async () => {
|
|
|
+ const res: IQueryResult = await store.dirDelete(row._id);
|
|
|
+ if (res.errcode == 0) {
|
|
|
+ ElMessage({ type: 'success', message: '删除成功' });
|
|
|
+ search();
|
|
|
}
|
|
|
});
|
|
|
};
|