|
@@ -5,23 +5,53 @@
|
|
|
<span>{{ data.name }}</span>
|
|
|
</el-col>
|
|
|
<el-col class="list" v-if="data.show == 'list'">
|
|
|
- <Table @toAdd="toAdd" :list="list" @toEdit="toAdd"></Table>
|
|
|
+ <el-col :span="24" class="btn">
|
|
|
+ <el-col v-if="data.id">
|
|
|
+ <el-button class="button" type="primary" size="large" @click="toDer()">添加文件夹</el-button>
|
|
|
+ <el-button class="button" type="success" size="large" @click="toAdd()">添加表</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col v-else>
|
|
|
+ <el-button class="button" type="primary" size="large" disabled>添加文件夹</el-button>
|
|
|
+ <el-button class="button" type="success" size="large" disabled>添加表</el-button>
|
|
|
+ </el-col>
|
|
|
+ </el-col>
|
|
|
+ <Table :list="list" @toEdit="toEdit" @toAddDir="toAddDir" @toAddTab="toAddTab"></Table>
|
|
|
</el-col>
|
|
|
<el-col class="form" v-else-if="data.show == 'form'">
|
|
|
- <Form @toBack="toAdd" :form="form"></Form>
|
|
|
+ <Form @toBack="toBack" :form="form"></Form>
|
|
|
</el-col>
|
|
|
</el-col>
|
|
|
+ <el-dialog v-model="data.dialog" title="文件夹" :before-close="handleClose">
|
|
|
+ <el-form ref="ruleFormRef" :model="ruleForm" :rules="rules" label-width="120px" class="demo-ruleForm" :size="formSize" status-icon>
|
|
|
+ <el-form-item label="名称" prop="name">
|
|
|
+ <el-input v-model="ruleForm.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="排序" prop="sort">
|
|
|
+ <el-input v-model="ruleForm.sort" type="number" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="备注" prop="remark">
|
|
|
+ <el-input v-model="ruleForm.remark" type="textarea" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item>
|
|
|
+ <el-button type="primary" @click="submitForm(ruleFormRef)"> 提交 </el-button>
|
|
|
+ <el-button @click="resetForm(ruleFormRef)">重置</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import _ from 'lodash';
|
|
|
-import { reactive } from 'vue';
|
|
|
+import { reactive, ref } from 'vue';
|
|
|
+import type { Ref } from 'vue';
|
|
|
import { useCounterStore as useStore } from '@/stores/counter';
|
|
|
import type { IQueryResult } from '@/util/types.util';
|
|
|
import Form from './parts/form-1.vue';
|
|
|
import Table from './parts/table-1.vue';
|
|
|
-import { $ref } from 'vue/macros';
|
|
|
+import type { FormInstance, FormRules } from 'element-plus';
|
|
|
const store = useStore();
|
|
|
+const formSize = ref('default');
|
|
|
+const ruleFormRef = ref<FormInstance>();
|
|
|
|
|
|
interface dataType {
|
|
|
tableData: Array<any>;
|
|
@@ -29,52 +59,104 @@ interface dataType {
|
|
|
name: string;
|
|
|
show: string;
|
|
|
[prop: string]: any;
|
|
|
+ // dialog: boolean;
|
|
|
}
|
|
|
-
|
|
|
const data: dataType = reactive({
|
|
|
tableData: [] as any[],
|
|
|
id: '',
|
|
|
name: '项目名称',
|
|
|
show: 'list',
|
|
|
test: { t: '1' },
|
|
|
+ dialog: ref(false),
|
|
|
});
|
|
|
-let test = $ref('');
|
|
|
-test = 'abc';
|
|
|
-let list: any = reactive([]);
|
|
|
+
|
|
|
+let list: Ref<any[]> = ref([]);
|
|
|
+// 查询
|
|
|
+const search = async () => {
|
|
|
+ // 详情
|
|
|
+ const aee: IQueryResult = await store.projectFetch(data.id);
|
|
|
+ Object.assign(data, { id: props.id, name: _.get(aee.data, 'name') });
|
|
|
+ // 列表
|
|
|
+ const res: IQueryResult = await store.tableQuery({ project: data.id });
|
|
|
+ list.value = res.data as any[];
|
|
|
+};
|
|
|
let props = defineProps({ id: String });
|
|
|
if (props.id) {
|
|
|
if (data.id && data.id == props.id) {
|
|
|
console.log(data.id);
|
|
|
} else {
|
|
|
- // 项目
|
|
|
- const aee: IQueryResult = await store.projectFetch(props.id);
|
|
|
- Object.assign(data, { id: props.id, name: _.get(aee, 'name') });
|
|
|
- // 列表
|
|
|
- const res: IQueryResult = await store.tabelQuery({ project: props.id });
|
|
|
- list = res.data;
|
|
|
+ data.id = props.id;
|
|
|
+ search();
|
|
|
+ const res: IQueryResult = await store.tableQuery({ project: data.id });
|
|
|
+ list.value = res.data as any[];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// list = props.data.list;
|
|
|
-let form: Object = reactive({
|
|
|
- _id: '',
|
|
|
- name: '',
|
|
|
- columns: [],
|
|
|
- name_zh: '',
|
|
|
- remark: '',
|
|
|
-});
|
|
|
+let form: Ref<{}> = ref({});
|
|
|
// 添加修改
|
|
|
-const toAdd = async (query: { id: string; type: string }) => {
|
|
|
- console.log(query.id);
|
|
|
- if (query.id) {
|
|
|
- const res: IQueryResult = await store.tableFetch(query.id);
|
|
|
- // form = res.data;
|
|
|
- } else {
|
|
|
- // form = { _id: '', name: '', columns: [], name_zh: '', remark: '' };
|
|
|
- }
|
|
|
- data.id = query.id;
|
|
|
- data.show = query.type;
|
|
|
+const toAdd = async () => {
|
|
|
+ form.value = { columns: [], project: data.id };
|
|
|
+ data.show = 'form';
|
|
|
+ search();
|
|
|
+};
|
|
|
+const toAddTab = (query: { id: string }) => {
|
|
|
+ form.value = { project: data.id, dir: query.id, columns: [] };
|
|
|
+ data.show = 'form';
|
|
|
+};
|
|
|
+const toEdit = async (query: { id: string }) => {
|
|
|
+ const res: IQueryResult = await store.tableFetch(query.id);
|
|
|
+ form.value = res.data as {};
|
|
|
+ data.show = 'form';
|
|
|
+ // search();
|
|
|
+};
|
|
|
+const toBack = async () => {
|
|
|
+ data.show = 'list';
|
|
|
+ search();
|
|
|
+};
|
|
|
+// #region 弹窗创建文件夹
|
|
|
+// 表单
|
|
|
+let ruleForm: Ref<{}> = ref({});
|
|
|
+// 验证
|
|
|
+const rules = reactive<FormRules>({
|
|
|
+ name: [{ required: true, message: '请输入项目名称', trigger: 'blur' }],
|
|
|
+});
|
|
|
+const toDer = () => {
|
|
|
+ ruleForm.value.project = data.id;
|
|
|
+ data.dialog = true;
|
|
|
+};
|
|
|
+const toAddDir = (query: { id: string }) => {
|
|
|
+ ruleForm.value.project = data.id;
|
|
|
+ ruleForm.value.super = query.id;
|
|
|
+ data.dialog = true;
|
|
|
+};
|
|
|
+// 提交保存
|
|
|
+const submitForm = async (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return;
|
|
|
+ await formEl.validate(async (valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ console.log(ruleForm.value);
|
|
|
+ if (ruleForm.value._id) {
|
|
|
+ const res: IQueryResult = await store.dirUpdate(ruleForm.value);
|
|
|
+ if (res.errcode == 0) handleClose();
|
|
|
+ } else {
|
|
|
+ const res: IQueryResult = await store.dirCreate(ruleForm.value);
|
|
|
+ if (res.errcode == 0) handleClose();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+// 重置
|
|
|
+const resetForm = (formEl: FormInstance | undefined) => {
|
|
|
+ if (!formEl) return;
|
|
|
+ formEl.resetFields();
|
|
|
+};
|
|
|
+// 关闭弹窗
|
|
|
+const handleClose = () => {
|
|
|
+ ruleForm.value = {};
|
|
|
+ search();
|
|
|
+ data.dialog = false;
|
|
|
};
|
|
|
+// #endregion
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
@@ -83,6 +165,15 @@ const toAdd = async (query: { id: string; type: string }) => {
|
|
|
padding: 24px;
|
|
|
height: 92vh;
|
|
|
}
|
|
|
+.btn {
|
|
|
+ height: 50px;
|
|
|
+ margin: 10px 0;
|
|
|
+ text-align: center;
|
|
|
+ background: #86b2a5;
|
|
|
+}
|
|
|
+.button {
|
|
|
+ margin: 0 10%;
|
|
|
+}
|
|
|
.head {
|
|
|
height: 10vh;
|
|
|
background: #fff;
|