|
@@ -0,0 +1,279 @@
|
|
|
+<script setup lang="ts">
|
|
|
+defineOptions({
|
|
|
+ // name 作为一种规范最好必须写上并且和路由的name保持一致
|
|
|
+ name: "prosonDepartment"
|
|
|
+});
|
|
|
+import { ref, reactive } from "vue";
|
|
|
+import { ElMessageBox, ElMessage } from "element-plus";
|
|
|
+const dialogVisibleAdd = ref(false);
|
|
|
+const handleNodeClick = data => {
|
|
|
+ console.log(data);
|
|
|
+};
|
|
|
+
|
|
|
+const data = [
|
|
|
+ {
|
|
|
+ label: "Level one 1",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: "Level two 1-1",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: "Level three 1-1-1"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "Level one 2",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: "Level two 2-1",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: "Level three 2-1-1"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "Level two 2-2",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: "Level three 2-2-1"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "Level one 3",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: "Level two 3-1",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: "Level three 3-1-1"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "Level two 3-2",
|
|
|
+ children: [
|
|
|
+ {
|
|
|
+ label: "Level three 3-2-1"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+];
|
|
|
+
|
|
|
+const defaultProps = {
|
|
|
+ children: "children",
|
|
|
+ label: "label"
|
|
|
+};
|
|
|
+const tableData = [
|
|
|
+ {
|
|
|
+ date: "2016-05-03",
|
|
|
+ name: "Tom",
|
|
|
+ address: "No. 189, Grove St, Los Angeles"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ date: "2016-05-02",
|
|
|
+ name: "Tom",
|
|
|
+ address: "No. 189, Grove St, Los Angeles"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ date: "2016-05-04",
|
|
|
+ name: "Tom",
|
|
|
+ address: "No. 189, Grove St, Los Angeles"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ date: "2016-05-01",
|
|
|
+ name: "Tom",
|
|
|
+ address: "No. 189, Grove St, Los Angeles"
|
|
|
+ }
|
|
|
+];
|
|
|
+// 添加部门弹窗
|
|
|
+const addDepartment = () => {
|
|
|
+ dialogVisibleAdd.value = !dialogVisibleAdd.value;
|
|
|
+};
|
|
|
+const handleClose = () => {
|
|
|
+ ElMessageBox.confirm("确认关闭弹窗吗?")
|
|
|
+ .then(() => {
|
|
|
+ dialogVisibleAdd.value = !dialogVisibleAdd.value;
|
|
|
+ ElMessage({
|
|
|
+ message: "已关闭",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ // catch error
|
|
|
+ });
|
|
|
+};
|
|
|
+// 添加部门保存
|
|
|
+const saveDepartment = () => {
|
|
|
+ dialogVisibleAdd.value = false;
|
|
|
+ ElMessage({
|
|
|
+ message: "添加成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+};
|
|
|
+const form = reactive({
|
|
|
+ name: "",
|
|
|
+ region: "",
|
|
|
+ date1: "",
|
|
|
+ date2: "",
|
|
|
+ delivery: false,
|
|
|
+ type: [],
|
|
|
+ resource: "",
|
|
|
+ desc: ""
|
|
|
+});
|
|
|
+const deleteRow = row => {
|
|
|
+ console.log(row);
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<template>
|
|
|
+ <div class="flex w-full h-full">
|
|
|
+ <div class="box-left">
|
|
|
+ <el-input placeholder="搜索" class="mb-2" />
|
|
|
+ <el-tree
|
|
|
+ class="m-2 mr-8"
|
|
|
+ style="max-width: 600px"
|
|
|
+ :data="data"
|
|
|
+ node-key="id"
|
|
|
+ default-expand-all
|
|
|
+ :expand-on-click-node="false"
|
|
|
+ >
|
|
|
+ <template #default="{ node }">
|
|
|
+ <span>{{ node.label }}</span>
|
|
|
+ <el-dropdown trigger="click">
|
|
|
+ <span>
|
|
|
+ <el-icon><Operation /></el-icon>
|
|
|
+ </span>
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu class="setting">
|
|
|
+ <el-dropdown-item> 编辑部门 </el-dropdown-item>
|
|
|
+ <el-dropdown-item> 添加子部门 </el-dropdown-item>
|
|
|
+ <el-dropdown-item> 配置角色 </el-dropdown-item>
|
|
|
+ <el-dropdown-item>
|
|
|
+ <el-link type="danger">删除</el-link>
|
|
|
+ </el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </el-dropdown>
|
|
|
+ </template>
|
|
|
+ </el-tree>
|
|
|
+ <el-button type="primary" plain @click="addDepartment"
|
|
|
+ >添加部门</el-button
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <div class="box-right">
|
|
|
+ <div class="flex justify-between mb-3">
|
|
|
+ <el-input placeholder="搜索" class="mb-2" style="max-width: 300px" />
|
|
|
+ <el-button type="primary">添加成员</el-button>
|
|
|
+ </div>
|
|
|
+ <el-table :data="tableData" style="width: 100%">
|
|
|
+ <el-table-column prop="date" label="姓名" />
|
|
|
+ <el-table-column prop="name" label="工号" />
|
|
|
+ <el-table-column prop="address" label="性别" />
|
|
|
+ <el-table-column prop="address" label="年龄" />
|
|
|
+ <el-table-column prop="address" label="职称" />
|
|
|
+ <el-table-column prop="address" label="部门" />
|
|
|
+ <el-table-column label="操作">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-dropdown trigger="click" class="mr-2">
|
|
|
+ <el-icon><View /></el-icon>
|
|
|
+ </el-dropdown>
|
|
|
+ <el-dropdown trigger="click">
|
|
|
+ <el-icon><Operation /></el-icon>
|
|
|
+ <template #dropdown>
|
|
|
+ <el-dropdown-menu class="setting">
|
|
|
+ <el-dropdown-item>
|
|
|
+ <el-link type="danger" @click="deleteRow(row)"
|
|
|
+ >删除</el-link
|
|
|
+ >
|
|
|
+ </el-dropdown-item>
|
|
|
+ <el-dropdown-item> 配置角色 </el-dropdown-item>
|
|
|
+ </el-dropdown-menu>
|
|
|
+ </template>
|
|
|
+ </el-dropdown>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <!-- 添加部门 -->
|
|
|
+ <el-dialog
|
|
|
+ v-model="dialogVisibleAdd"
|
|
|
+ title="新建部门"
|
|
|
+ width="500"
|
|
|
+ :before-close="handleClose"
|
|
|
+ >
|
|
|
+ <el-form :model="form" label-width="auto" style="max-width: 600px">
|
|
|
+ <el-form-item
|
|
|
+ prop="name"
|
|
|
+ label="部门名称"
|
|
|
+ :rules="[
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: '请填写部门名称',
|
|
|
+ trigger: 'blur'
|
|
|
+ }
|
|
|
+ ]"
|
|
|
+ >
|
|
|
+ <el-input v-model="form.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="部门编号">
|
|
|
+ <el-input v-model="form.name" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="上级部门">
|
|
|
+ <el-select
|
|
|
+ v-model="form.region"
|
|
|
+ placeholder="please select your zone"
|
|
|
+ >
|
|
|
+ <el-option label="Zone one" value="shanghai" />
|
|
|
+ <el-option label="Zone two" value="beijing" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="部门负责人">
|
|
|
+ <el-select
|
|
|
+ v-model="form.region"
|
|
|
+ placeholder="please select your zone"
|
|
|
+ >
|
|
|
+ <el-option label="Zone one" value="shanghai" />
|
|
|
+ <el-option label="Zone two" value="beijing" />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button @click="handleClose">取消</el-button>
|
|
|
+ <el-button type="primary" @click="saveDepartment"> 确认 </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.box-left {
|
|
|
+ width: 25%;
|
|
|
+ // border: 1px solid red;
|
|
|
+ height: 100%;
|
|
|
+ padding: 10px 20px;
|
|
|
+ border-right: 1px solid #999;
|
|
|
+}
|
|
|
+
|
|
|
+.box-right {
|
|
|
+ width: 70%;
|
|
|
+ height: 100%;
|
|
|
+ padding: 10px 20px;
|
|
|
+}
|
|
|
+// ::v-deep .el-dropdown {
|
|
|
+// line-height: 1;
|
|
|
+// }
|
|
|
+// ::v-deep .el-tree-node__expand-icon {
|
|
|
+// line-height: 10px;
|
|
|
+// border: 1px solid red;
|
|
|
+// }
|
|
|
+</style>
|