Parcourir la source

0306xx系统管理

XiaXxxxxx il y a 1 an
Parent
commit
9735615910

+ 2 - 2
src/components/Table/src/hooks/useTable.ts

@@ -143,8 +143,8 @@ export function useTable(tableProps?: Props): [
     getShowPagination: () => {
       return toRaw(getTableInstance().getShowPagination());
     },
-    expandAll: () => {
-      getTableInstance().expandAll();
+    expandAll: (isTreeTable) => {
+      getTableInstance().expandAll(isTreeTable);
     },
     collapseAll: () => {
       getTableInstance().collapseAll();

+ 23 - 2
src/components/Table/src/hooks/useTableExpand.ts

@@ -32,8 +32,8 @@ export function useTableExpand(
     };
   });
 
-  function expandAll() {
-    const keys = getAllKeys();
+  function expandAll(isTreeTable) {
+    const keys = isTreeTable ? getSecondsKeys() : getAllKeys();
     expandedRowKeys.value = keys;
   }
 
@@ -49,6 +49,27 @@ export function useTableExpand(
     });
     return keys;
   }
+  // 专门给树形表格用的,展开二级
+  function getSecondsKeys(data?: Recordable[]) {
+    const keys: string[] = [];
+    const { childrenColumnName } = unref(propsRef);
+    toRaw(data || unref(tableData)).forEach((item) => {
+      keys.push(item[unref(getRowKey) as string]);
+      const children = item[childrenColumnName || 'children'];
+      if (children?.length) {
+        children.forEach((child) => {
+          keys.push(child[unref(getRowKey) as string]);
+          // const children1 = child[childrenColumnName || 'children'];
+          // if (children1?.length) {
+          //   children1.forEach((child1) => {
+          //     keys.push(child1[unref(getRowKey) as string]);
+          //   })
+          // }
+        })
+      }
+    });
+    return keys;
+  }
 
   function collapseAll() {
     expandedRowKeys.value = [];

+ 1 - 1
src/components/Table/src/types/table.ts

@@ -88,7 +88,7 @@ export interface TableActionType {
   reload: (opt?: FetchParams) => Promise<void>;
   getSelectRows: <T = Recordable>() => T[];
   clearSelectedRowKeys: () => void;
-  expandAll: () => void;
+  expandAll: (isTreeTable: boolean) => void;
   collapseAll: () => void;
   getSelectRowKeys: () => string[];
   deleteSelectRowByKey: (key: string) => void;

+ 2 - 2
src/views/systemAdmin/system/account/index.vue

@@ -75,12 +75,12 @@ export default defineComponent({
     }
     const columns = [
       {
-        title: '用户名',
+        title: '用户名',
         dataIndex: 'NAME',
         align: 'center'
       },
       {
-        title: '登录名',
+        title: '登录名',
         dataIndex: 'LOGIN_NAME',
         align: 'center'
       },

+ 90 - 0
src/views/systemAdmin/system/position/PositionManageModal.vue

@@ -0,0 +1,90 @@
+<template>
+    <BasicModal :maskClosable="false" :width="440" @register="registerModal" v-bind="$attrs" :title="getTitle" centered
+        @ok="handleSubmit">
+        <BasicForm @register="registerForm" />
+    </BasicModal>
+</template>
+
+<script>
+import { defineComponent, reactive, ref, onMounted, watch, computed } from 'vue';
+import { BasicModal, useModalInner } from '/@/components/Modal';
+import { BasicForm, useForm } from '/@/components/Form/index';
+import { message } from 'ant-design-vue';
+import { formSchema } from './position.data';
+import { v4 as uuidv4 } from 'uuid';
+import { savePosition } from '/@/api/sys/position';
+
+export default defineComponent({
+    name: 'PositionModal',
+    components: { BasicModal, BasicForm },
+    setup(_, { emit }) {
+        const modalStatus = ref('add');
+        const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
+            resetForm();
+            if (data.status === 'add') {
+                const { orgid, oabaseid, sort } = data.form;
+                setFieldsValue({
+                    orgid: orgid,
+                    oabaseid: oabaseid,
+                    sort: sort,
+                    id: uuidv4()
+                })
+            } else if (data.status === 'edit') {
+                const { id, orgid, oabaseid, name, duty, sort } = data.form;
+                setFieldsValue({
+                    id: id,
+                    orgid: orgid,
+                    oabaseid: oabaseid,
+                    name: name,
+                    duty: duty,
+                    sort: sort
+                })
+            }
+            modalStatus.value = data.status;
+        });
+        const [registerForm, { setFieldsValue, resetFields, validate, getFieldsValue }] = useForm({
+            schemas: formSchema,
+            labelCol: { span: 6 },
+            wrapperCol: { span: 16 },
+            showActionButtonGroup: false
+        });
+        const getTitle = computed(() => {
+            if (modalStatus.value === 'add') {
+                return '新增岗位';
+            }
+            if (modalStatus.value === 'edit') {
+                return '编辑岗位';
+            }
+        });
+        const resetForm = () => {
+            resetFields();
+        }
+        // 提交信息
+        const handleSubmit = () => {
+            validate().then(async (res) => {
+                if (res) {
+                    let params = { ...getFieldsValue() }
+                    savePosition(params).then(res => {
+                        if (res.datas === 1) {
+                            message.success('操作成功')
+                        } else {
+                            message.error('操作失败')
+                        }
+                        // 关闭弹窗
+                        closeModal();
+                        // 触发父组件事件
+                        emit('success', res);
+                    })
+                }
+            });
+
+        };
+        return {
+            registerModal,
+            registerForm,
+            getTitle,
+            handleSubmit,
+        };
+    },
+});
+</script>

+ 0 - 105
src/views/systemAdmin/system/position/PositionModal copy.vue

@@ -1,105 +0,0 @@
-<template>
-    <a-modal 
-        :visible="true" 
-        :maskClosable="false" 
-        :destroyOnClose="true"
-        :title="title" 
-        :footer="null"
-        :wrapClassName="wrapClassName"
-        @cancel="onClose" 
-    >
-        <div class="content">
-            <div class="items">
-                <div class="label">名称:</div>
-                <div class="data">{{ positionDetail.name }}</div>
-            </div>
-            <div class="items">
-                <div class="label">职责:</div>
-                <div class="data">{{ positionDetail.duty }}</div>
-            </div>
-            <div class="items">
-                <div class="label">id:</div>
-                <div class="data">{{ positionDetail.id }}</div>
-            </div>
-            <div class="items">
-                <div class="label">机构id:</div>
-                <div class="data">{{ positionDetail.orgid }}</div>
-            </div>
-            <div class="items">
-                <div class="label">排序:</div>
-                <div class="data">{{ positionDetail.sort }}</div>
-            </div>
-        </div>
-    </a-modal>
-</template>
-<script>
-import { defineComponent, reactive, ref, onMounted, watch, toRefs } from 'vue';
-import { message } from 'ant-design-vue';
-import moment from 'moment';
-
-const props = {
-    positionDetail:{
-        type:Object,
-        default:{
-            name:'',
-            duty:'',
-            id:'',
-            orgid:'',
-            sort:0
-        }
-    }
-}
-export default defineComponent({
-    name: 'modal',
-    components: {},
-    props,
-    setup(props, { emit }) {
-        const data = reactive({
-            // width: '1000px',
-            title: '岗位详情',
-            wrapClassName:'modal-wrap',
-            positionDetail:props.positionDetail
-        })
-        watch(
-            () => props.positionDetail,
-            (val) => {
-                data.positionDetail = val
-            }
-        )
-        // 关闭请求弹窗
-        const onClose = (e) => {
-            emit('closeModal')
-        }
-        return {
-            ...toRefs(data),
-            //func
-            onClose
-        };
-    },
-});
-</script>
-<style lang="less" scoped>
-.modal-wrap{
-    .content{
-        padding: 10px 10px 10px 20px;
-        margin-top: 10px;
-        .items{
-            margin: 10px 0;
-            display: flex;
-            &:first-child{
-                margin-top: 0;
-            }
-
-            .label{
-                font-size: 16px;
-                font-weight: 500;
-                width: 60px;
-            }
-            .data{
-                margin-left: 10px;
-                font-size: 16px;
-            }
-        }
-    }
-}
-</style>

+ 0 - 336
src/views/systemAdmin/system/position/index copy.vue

@@ -1,336 +0,0 @@
-<template>
-    <div class="p-4">
-        <div class="position-header">
-            <div class="position-title">岗位管理</div>
-            <div class="handle-btns">
-                <a-button class="btn" type="primary" @click="addHandle">新增</a-button>
-                <a-button class="btn" @click="editHandle">修改</a-button>
-                <a-button class="btn" danger @click="delHandle">删除</a-button>
-            </div>
-        </div>
-        <div class="position-body">
-            <div class="structure-tree list-items">
-                <div class="item-title">部门列表</div>
-                <a-tree :replaceFields="replaceFields" :treeData="treeData" v-if="treeData" @select="nodeSelect"></a-tree>
-            </div>
-            <div class="posts-list list-items">
-                <div class="item-title">职位列表</div>
-                <div class="posts-box item-box">
-                    <div class="posts item" v-for="(item, index) in posts.data" :key="index"
-                        @click="chooseHandle(item, 'posts')">
-                        <span :class="{ 'chosed': item.departid === posts.currentId }">{{ item.departName }}</span>
-                    </div>
-                </div>
-            </div>
-            <div class="position-list list-items">
-                <div class="item-title">岗位列表</div>
-                <div class="position-box item-box">
-                    <div class="position item" v-for="(item, index) in position.data" :key="index">
-                        <span :class="{ 'chosed': item.id === position.currentId }" @click="chooseHandle(item, 'position')">{{ item.name }}</span>
-                        <span v-if="item.id === position.currentId" style="color: red;" @click="openDetailModal(item)">查看</span>
-                    </div>
-                </div>
-            </div>
-        </div>
-        <PositionDrawer :formData="formData" :drawerTitle="drawerTitle" @onSubmit="onSubmit" ref="drawerRef">
-        </PositionDrawer>
-        <PositionModal v-if="showModal" @closeModal="showModal = false" :positionDetail="positionDetail"/>
-    </div>
-</template>
-
-<script>
-import { defineComponent, reactive, ref, toRefs, computed, onMounted, watch, createVNode } from 'vue';
-import PositionDrawer from './PositionDrawer.vue';
-import PositionModal from './PositionModal.vue';
-import { structureList, getPostsList, getPositionList, delPosition } from '/@/api/sys/position';
-import { message, Modal } from 'ant-design-vue';
-import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
-
-export default defineComponent({
-    name: 'position',
-    components: { PositionDrawer, PositionModal, ExclamationCircleOutlined },
-    setup(props, { emit }) {
-        const drawerRef = ref(null)
-        const data = reactive({
-            replaceFields: {
-                children: 'children',
-                title: 'name',
-                key: 'id'
-            },
-            treeData: [],//单位列表树
-            currentNode: "",//当前选中的树节点
-            posts: {
-                currentId: "",
-                data: []
-            },//职位数据
-            position: {
-                currentId: "",
-                data: []
-            },//岗位数据
-            formData: {
-                id: "",
-                orgid: "",
-                oabaseid: "",
-                name: '',
-                duty: '',
-                sort: 0,
-            },
-            drawerTitle: '新增岗位',
-            showModal:false,
-            positionDetail:{}
-        });
-        /**
-         * 点击树节点触发
-         */
-        const nodeSelect = (selectkey, { selectedNodes, node }) => {
-            if (node.dataRef.departid === data.currentNode) {
-                return;
-            } else {
-                data.currentNode = node.dataRef.departid
-            }
-            resetTwoDatas()
-            let params = {
-                departmentId: node.dataRef.departid
-            }
-            getPostsList(params).then(res => {
-                if (res.datas) {
-                    data.posts.data = res.datas
-                }
-            })
-        };
-        const resetTwoDatas = () => {
-            data.posts.data = []
-            data.posts.currentId = ""
-            data.position.data = []
-            data.position.currentId = ""
-        }
-        const chooseHandle = (item, type) => {
-            if (type === 'posts') {
-                if (data.posts.currentId === item.departid) {
-                    return;
-                }
-                data.posts.currentId = item.departid
-                data.position.data = []
-                data.position.currentId = ""
-                //此处查询岗位数据
-                let params = {
-                    zwId: data.posts.currentId
-                }
-                getPositionList(params).then(res => {
-                    if (res.datas && res.datas.length) {
-                        data.position.data = res.datas
-                    } else {
-                        message.info('该职位下无岗位数据')
-                    }
-                })
-            } else {
-                data.position.currentId = item.id
-            }
-        }
-        onMounted(() => {
-            structureList().then(res => {
-                res.length && (data.treeData = res)
-            })
-        });
-        /**
-         * 对岗位的操作
-         */
-        const addHandle = () => {
-            if (data.currentNode === "") {
-                message.error('请先选择机构!')
-            } else if (data.posts.currentId === "") {
-                message.error('请先选择职位!')
-            } else {
-                data.formData = {
-                    id: "",
-                    orgid: data.currentNode,
-                    oabaseid: data.posts.currentId,
-                    name: "",
-                    duty: "",
-                    sort: data.position.data.length + 1,
-                }
-                data.drawerTitle = '新增岗位'
-                drawerRef.value.showDrawer()
-            }
-        }
-        const editHandle = () => {
-            if (data.currentNode === "") {
-                message.error('请先选择机构!')
-            } else if (data.posts.currentId === "") {
-                message.error('请先选择职位!')
-            } else if (data.position.currentId === "") {
-                message.error('请先选择岗位!')
-            } else {
-                data.position.data.forEach(item => {
-                    if (item.id === data.position.currentId) {
-                        data.formData = {
-                            id: data.position.currentId,
-                            orgid: data.currentNode,
-                            oabaseid: data.posts.currentId,
-                            name: item.name,
-                            duty: item.duty,
-                            sort: parseInt(item.sort),
-                        }
-                        data.drawerTitle = '修改岗位'
-                        drawerRef.value.showDrawer()
-                    }
-                })
-            }
-        }
-        const delHandle = () => {
-            if (data.currentNode === "") {
-                message.error('请先选择机构!')
-            } else if (data.posts.currentId === "") {
-                message.error('请先选择职位!')
-            } else if (data.position.currentId === "") {
-                message.error('请先选择岗位!')
-            } else {
-                Modal.confirm({
-                    title: '删除提示',
-                    icon: createVNode(ExclamationCircleOutlined),
-                    content: '确定删除岗位?',
-                    centered: true,
-                    okText: '确定',
-                    okType: 'danger',
-                    cancelText: '取消',
-                    onOk: (() => {
-                        let params = {
-                            oabaseid: data.posts.currentId,
-                            id: data.position.currentId
-                        }
-                        delPosition(params).then(res => {
-                            if (res.datas === 1) {
-                                message.success('操作成功')
-                                onSubmit(true)
-                            } else {
-                                message.error('操作失败')
-                            }
-                        })
-                    })
-                });
-            }
-        }
-        const openDetailModal = (item) => {
-            data.positionDetail = item
-            data.showModal = true
-        }
-        const onSubmit = (e) => {
-            if (e) {
-                data.position.data = []
-                data.position.currentId = ""
-                let params = {
-                    zwId: data.posts.currentId
-                }
-                getPositionList(params).then(res => {
-                    if (res.datas && res.datas.length) {
-                        data.position.data = res.datas
-                    }
-                })
-            }
-        }
-        return {
-            drawerRef,
-            ...toRefs(data),
-            nodeSelect,
-            chooseHandle,
-            addHandle,
-            editHandle,
-            delHandle,
-            openDetailModal,
-            onSubmit
-        };
-    },
-});
-</script>
-
-<style lang="less" scoped>
-.p-4 {
-    height: 100%;
-
-    .position-header {
-        padding: 10px;
-        width: 100%;
-        height: 70px;
-        background-color: #fff;
-        display: flex;
-        justify-content: space-between;
-        align-items: center;
-
-        .position-title {
-            font-size: 16px;
-            font-weight: 500;
-            margin-left: 20px;
-            user-select: none;
-        }
-
-        .handle-btns {
-            margin-right: 20px;
-            display: flex;
-
-            .btn {
-                margin-right: 10px;
-
-                &:last-child {
-                    margin-right: 0;
-                }
-            }
-        }
-    }
-
-    .position-body {
-        margin-top: 20px;
-        width: 100%;
-        // height: 800px;
-        height: calc(100% - 90px);
-        display: flex;
-
-        .list-items {
-            margin-right: 20px;
-            padding: 10px;
-            height: 100%;
-            overflow: auto;
-            flex: 1;
-            background-color: #fff;
-
-            &:last-child {
-                margin-right: 0;
-            }
-
-            .item-title {
-                padding-left: 10px;
-                height: 40px;
-                line-height: 40px;
-                font-size: 16px;
-                background-color: #9eafe7;
-            }
-
-            .item-box {
-                margin-top: 7px;
-
-                .item {
-                    width: fit-content;
-                    height: 32px;
-                    display: flex;
-                    align-items: center;
-
-                    span {
-                        padding: 4px;
-                        cursor: pointer;
-                        user-select: none;
-
-                        &:hover {
-                            background-color: #f5f5f5;
-                        }
-
-                        margin-right: 30px;
-                    }
-
-                    .chosed {
-                        background-color: #dbedff;
-                    }
-                }
-            }
-        }
-    }
-}
-</style>

+ 56 - 46
src/views/systemAdmin/system/position/index.vue

@@ -1,18 +1,20 @@
 <template>
     <div class="position p-4">
         <div class="left-tree-box">
-            <div class="tree-title">部门列表</div>
+            <div class="tree-title">机构列表</div>
             <div class="tree-box">
                 <div class="search-input">
-                    <a-input-search v-model:value="treeSearchValue" placeholder="搜索关键字" style="width: 100%;height:100%;" />
+                    <a-input-search v-model:value="treeSearchValue" placeholder="搜索关键字"
+                        style="width: 100%;height:100%;" />
                 </div>
                 <div class="tree-container">
-                    <a-directory-tree :tree-data="treeData" :expandedKeys="expandedKeys" class="tree-list" :showIcon="false"
-                        :auto-expand-parent="autoExpandParent" @expand="onExpand" :replaceFields="replaceFields"
-                        @select="nodeSelect">
+                    <a-directory-tree :tree-data="treeData" :expandedKeys="expandedKeys" class="tree-list"
+                        :showIcon="false" :auto-expand-parent="autoExpandParent" @expand="onExpand"
+                        :replaceFields="replaceFields" @select="nodeSelect">
                         <template #switcherIcon>
                             <div class="self-switcher-icon"></div>
                         </template>
+
                         <template #title="{ name, selected, dataRef }">
                             <span v-if="name.indexOf(treeSearchValue) > -1">
                                 {{ name.substr(0, name.indexOf(treeSearchValue)) }}
@@ -29,7 +31,8 @@
             <div class="tree-title">职位列表</div>
             <div class="tree-box">
                 <div class="tree-container">
-                    <a-directory-tree :tree-data="departTreeData" class="depart-tree-list" :showIcon="false" :replaceFields="{
+                    <a-directory-tree :tree-data="departTreeData" class="depart-tree-list" :showIcon="false"
+                        :replaceFields="{
                         children: 'children',
                         title: 'departName',
                         key: 'departid'
@@ -40,11 +43,13 @@
         </div>
         <div class="right-table-box">
             <BasicTable @register="registerTable" class="basic-table">
+
                 <template #toolbar>
                     <Button type="primary" @click="handleAdd">
                         新增
                     </Button>
                 </template>
+
                 <template #action="{ record }">
                     <TableAction :actions="[
                         {
@@ -62,8 +67,7 @@
                 </template>
             </BasicTable>
         </div>
-        <PositionModal v-if="ifShowModal" :title="modalTitle" :formData="formData" @closeModal="ifShowModal = false"
-            @onSubmit="onSubmit" />
+        <PositionManageModal @register="registerModal" @success="onSubmit"></PositionManageModal>
     </div>
 </template>
 
@@ -76,13 +80,15 @@ import { BasicTable, useTable, TableAction } from '/@/components/Table';
 import { Button } from 'ant-design-vue';
 import { message, Modal } from 'ant-design-vue';
 import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
-
-import PositionModal from './PositionModal.vue';
+import { useModal } from '/@/components/Modal';
+// import PositionModal from './PositionModal.vue';
+import PositionManageModal from './PositionManageModal.vue';
 
 export default defineComponent({
     name: 'position',
-    components: { BasicTable, TableAction, Button, PositionModal, ExclamationCircleOutlined },
+    components: { BasicTable, TableAction, Button, PositionManageModal, ExclamationCircleOutlined },
     setup(props, { emit }) {
+        const [registerModal, { openModal }] = useModal();
         // 机构树所用的数据
         const data = reactive({
             replaceFields: {
@@ -267,9 +273,6 @@ export default defineComponent({
                 slots: { customRender: 'action' },
             }
         });
-        const formData = ref(null)
-        const modalTitle = ref('新增岗位')
-        const ifShowModal = ref(false)
         //新增岗位
         const handleAdd = () => {
             if (!departmentId.value) {
@@ -281,30 +284,28 @@ export default defineComponent({
                 return;
             }
             let tempData = getDataSource();
-            formData.value = {
-                id: "",
-                orgid: departmentId.value,
-                oabaseid: zwId.value,
-                name: "",
-                duty: "",
-                sort: tempData.length + 1,
-            }
-            modalTitle.value = '新增岗位'
-            ifShowModal.value = true
+            openModal(true, {
+                status: 'add',
+                form: {
+                    orgid: departmentId.value,
+                    oabaseid: zwId.value,
+                    sort: tempData.length + 1,
+                }
+            });
         }
         //编辑岗位
         const handleEdit = (item) => {
-            console.log(item);
-            formData.value = {
-                id: item.id,
-                orgid: departmentId.value,
-                oabaseid: zwId.value,
-                name: item.name,
-                duty: item.duty,
-                sort: parseInt(item.sort),
-            }
-            modalTitle.value = '编辑岗位'
-            ifShowModal.value = true
+            openModal(true, {
+                status: 'edit',
+                form: {
+                    id: item.id,
+                    orgid: departmentId.value,
+                    oabaseid: zwId.value,
+                    name: item.name,
+                    duty: item.duty,
+                    sort: item.sort
+                }
+            });
         }
         //删除岗位
         const handleDelete = (id) => {
@@ -324,42 +325,51 @@ export default defineComponent({
                     delPosition(params).then(res => {
                         if (res.resp_code === 0) {
                             message.success('操作成功')
-                            onSubmit(true)
-                        } else if(res.resp_code === 1) {
+                            onSubmit()
+                        } else if (res.resp_code === 1) {
                             message.info(res.resp_msg)
-                        } else{
+                        } else {
                             message.error('操作失败')
                         }
                     })
                 })
             });
         }
-        const onSubmit = (e) => {
-            if (e) {
-                reload();
-            }
+        const onSubmit = () => {
+            reload();
+        }
+        const getKeys = (treeData) => {
+            let keys = [];
+            treeData.forEach(element => {
+                keys.push(element.id)
+                if (element.children?.length) {
+                    element.children.forEach(item => {
+                        keys.push(item.id)
+                    })
+                }
+            });
+            return keys
         }
         onMounted(() => {
             //初始化时获取所有机构
             structureList().then(res => {
                 if (res.length) {
-                    console.log(res)
                     data.treeData = res
                     data.dataList = []
                     generateList(data.treeData)
+                    const keys = getKeys(data.treeData)
+                    data.expandedKeys = keys;
                 }
             })
         });
         return {
-            formData,
-            modalTitle,
-            ifShowModal,
             ...toRefs(data),
             //func
             onExpand,
             nodeSelect,
             departNodeSelect,
             registerTable,
+            registerModal,
             reload,
             handleAdd,
             handleEdit,

+ 68 - 0
src/views/systemAdmin/system/position/position.data.ts

@@ -0,0 +1,68 @@
+import { FormSchema } from '/@/components/Table';
+
+export const formSchema: FormSchema[] = [
+    {
+        field: 'id',
+        label: 'id',
+        component: 'Input',
+        show: false
+    },
+    {
+        field: 'orgid',
+        label: '机构id',
+        component: 'Input',
+        show: false
+    },
+    {
+        field: 'oabaseid',
+        label: '职位id',
+        component: 'Input',
+        show: false
+    },
+    {
+        field: 'name',
+        label: '岗位名称',
+        component: 'Input',
+        required: true,
+        componentProps: {
+            maxLength: 255,
+            placeholder: '请输入名称',
+        },
+    },
+    {
+        field: 'duty',
+        label: '岗位职责',
+        component: 'Input',
+        required: true,
+        componentProps: {
+            maxLength: 255,
+            placeholder: '请输入职责',
+        },
+    },
+    {
+        field: 'sort',
+        label: '岗位排序',
+        component: 'Input',
+        componentProps: {
+            maxLength: 255,
+            placeholder: '请输入排序'
+        },
+        dynamicRules: () => {
+            return [
+                {
+                    required: true,
+                    validator: (_, value) => {
+                        if (!String(value).length) {
+                            return Promise.reject('请输入序号');
+                        }
+                        let test = /^[0-9]\d*$/
+                        if (!test.test(value)) {
+                            return Promise.reject('请输入正确的序号');
+                        }
+                        return Promise.resolve();
+                    },
+                },
+            ];
+        }
+    }
+];

+ 24 - 12
src/views/systemAdmin/system/role/index.vue

@@ -19,18 +19,18 @@
         <BasicTable @register="registerTable" class="basic-table">
           <template #action="{ record }">
             <TableAction :actions="[
-              {
-                label: '修改',
-                tooltip: '修改',
-                onClick: handleEdit.bind(null, record),
-              },
-              {
-                label: '删除',
-                tooltip: '删除',
-                color: 'error',
-                onClick: handleDelete.bind(null, record),
-              },
-            ]" />
+            // {
+            //   label: '修改',
+            //   tooltip: '修改',
+            //   onClick: handleEdit.bind(null, record),
+            // },
+            {
+              label: '删除',
+              tooltip: '删除',
+              color: 'error',
+              onClick: handleDelete.bind(null, record),
+            },
+          ]" />
           </template>
         </BasicTable>
       </div>
@@ -56,6 +56,7 @@
     <RoleModal v-if="ifShowModal" @closeModal="ifShowModal = false" @onSubmit="onSubmit" />
   </div>
 </template>
+
 <script>
 import { defineComponent, nextTick, reactive, ref, toRefs, watch, onMounted, createVNode, computed } from 'vue';
 import { BasicTable, useTable, TableAction } from '/@/components/Table';
@@ -187,6 +188,13 @@ export default defineComponent({
         },
       ];
     });
+    const rowClick = (record, index) => {
+      return {
+        onClick: () => {
+          handleEdit(record)
+        }
+      }
+    }
     const [registerTable, { reload }] = useTable({
       title: '',
       api: roleList,		 //数据
@@ -198,6 +206,7 @@ export default defineComponent({
       pagination: {
         hideOnSinglePage: false
       },
+      customRow: rowClick,
       canResize: true,
       showTableSetting: false,  // 显示表格设置
       showIndexColumn: true,
@@ -216,6 +225,7 @@ export default defineComponent({
         trigger: 'blur'
       }]
     };
+    
     const menuTreeData = ref([])
     onMounted(() => {
       //此处请求菜单树
@@ -236,6 +246,7 @@ export default defineComponent({
       return node.name;
     }
     return {
+      rowClick,
       customTitle,
       ifShowModal,
       formRef,
@@ -255,6 +266,7 @@ export default defineComponent({
   },
 });
 </script>
+
 <style lang="less" scoped>
 .p-4 {
   height: 100%;

+ 13 - 8
src/views/systemAdmin/system/structure/index.vue

@@ -57,20 +57,24 @@ export default defineComponent({
     const ifShowModal = ref(false)
     const modalTitle = ref('新增机构')
     const formData = ref(null)
-    
+    const expandedRowKeys = ref([])
     const onFetchSuccess= () => {
       // 演示默认展开所有表项
       // nextTick(()=>{
       //   expandAll()
       // })
-      // setTimeout(()=>{
-      //   let tableData = getRawDataSource();
-      //   if(tableData?.length){
-      //     expandAll()
-      //   }
-      // },100)
+      setTimeout(()=>{
+        // let tableData = getRawDataSource();
+        // console.log(tableData)
+        // expandedRowKeys.value = getKeys(tableData)
+        // if(tableData.length){
+          expandAll(true)
+        // }
+      },100)
     }
 
+    
+
     const [
       registerTable,
       { reload, expandAll, collapseAll, getRawDataSource },
@@ -86,7 +90,7 @@ export default defineComponent({
       showIndexColumn: false,
       canResize: true,
       // rowKey: (record) => record.id,
-      autoCreateKey:true,
+      autoCreateKey: true,
       afterFetch:onFetchSuccess,
       actionColumn: {
         width: 100,
@@ -167,6 +171,7 @@ export default defineComponent({
 
     return {
       ifShowModal,
+      expandedRowKeys,
       modalTitle,
       formData,
       onSubmit,

+ 6 - 5
src/views/systemAdmin/system/structure/structure.data.ts

@@ -16,11 +16,11 @@ export const columns: BasicColumn[] = [
     // width: 180,
     align: 'left',
   },
-  {
-    title: '机构ID',
-    dataIndex: 'id',
-    width: 320,
-  },
+  // {
+  //   title: '机构ID',
+  //   dataIndex: 'id',
+  //   width: 320,
+  // },
   // {
   //   title: '父级ID',
   //   dataIndex: 'parentId',
@@ -96,6 +96,7 @@ export const formSchema: FormSchema[] = [
     field: 'orderId',
     component: 'Input',
     componentProps: {
+      type: 'number',
       maxLength: 255,
       placeholder: '请输入排序',
     },

+ 94 - 0
src/views/systemAdmin/system/zhiwei/ZhiweiManageModal.vue

@@ -0,0 +1,94 @@
+<template>
+    <BasicModal :maskClosable="false" :width="440" @register="registerModal" v-bind="$attrs" :title="getTitle" centered
+        @ok="handleSubmit">
+        <BasicForm @register="registerForm" />
+    </BasicModal>
+</template>
+
+<script>
+import { defineComponent, reactive, ref, onMounted, watch, computed } from 'vue';
+import { BasicModal, useModalInner } from '/@/components/Modal';
+import { BasicForm, useForm } from '/@/components/Form/index';
+import { message } from 'ant-design-vue';
+import { formSchema } from './zhiwei.data';
+import { v4 as uuidv4 } from 'uuid';
+import { savePosts } from '/@/api/sys/zhiwei';
+
+export default defineComponent({
+    name: 'ZhiweiModal',
+    components: { BasicModal, BasicForm },
+    setup(_, { emit }) {
+        const modalStatus = ref('add');
+        const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
+            resetForm();
+            if (data.status === 'add') {
+                //传入机构id
+                const { orgId, orderId } = data.form;
+                setFieldsValue({
+                    orgId: orgId,
+                    orderId: orderId,
+                    departid: uuidv4(),
+                    parentId: ''
+                })
+            } else if (data.status === 'edit') {
+                const { departid, orderId, departName, parentId } = data.form;
+                setFieldsValue({
+                    orderId: orderId,
+                    departid: departid,
+                    departName: departName,
+                    parentId: parentId
+                })
+            }
+            modalStatus.value = data.status;
+        });
+        const [registerForm, { setFieldsValue, resetFields, validate, getFieldsValue }] = useForm({
+            // labelWidth: 100,
+            schemas: formSchema,
+            labelCol: { span: 6 },
+            wrapperCol: { span: 16 },
+            showActionButtonGroup: false
+        });
+        const getTitle = computed(() => {
+            if (modalStatus.value === 'add') {
+                return '新增职位';
+            }
+            if (modalStatus.value === 'edit') {
+                return '编辑职位';
+            }
+        });
+        const resetForm = () => {
+            resetFields();
+        }
+        // 提交信息
+        const handleSubmit = () => {
+            validate().then(async (res) => {
+                if (res) {
+                    // let { departName, departid, orderId, orgId, parentId } = getFieldsValue();
+                    let params = { ...getFieldsValue() }
+                    if (modalStatus.value === 'edit') {
+                        delete params.orgId
+                    }
+                    savePosts(params).then(res => {
+                        if (res.datas === 1) {
+                            message.success('操作成功')
+                        } else {
+                            message.error('操作失败')
+                        }
+                        // 关闭弹窗
+                        closeModal();
+                        // 触发父组件事件
+                        emit('success', res);
+                    })
+                }
+            });
+
+        };
+        return {
+            registerModal,
+            registerForm,
+            getTitle,
+            handleSubmit,
+        };
+    },
+});
+</script>

+ 0 - 155
src/views/systemAdmin/system/zhiwei/ZhiweiModal.vue

@@ -1,155 +0,0 @@
-<template>
-    <a-modal :visible="true" :maskClosable="false" centered :destroyOnClose="true" :title="title"
-        :wrapClassName="wrapClassName" :width="width" @cancel="onClose" @ok="onSubmit">
-        <div class="content">
-            <a-form ref="formRef" :model="form" :rules="rules" :label-col="labelCol" :wrapper-col="wrapperCol">
-                <!-- 名称 -->
-                <a-form-item label="职位名称" name="departName">
-                    <a-input v-model:value="form.departName" style="width: 100%" placeholder="请输入名称" />
-                </a-form-item>
-                <!-- 排序 -->
-                <a-form-item label="排序" name="orderId">
-                    <a-input v-model:value="form.orderId" style="width: 100%" placeholder="请输入序号" />
-                </a-form-item>
-            </a-form>
-        </div>
-        <template #footer>
-            <div class="btns" style="display: flex;justify-content: center;">
-                <a-button class="btn" @click="onClose" style="width: 64px;height: 34px;margin-right: 25px;color: #333333;">取消</a-button>
-                <a-button class="btn" @click="onSubmit" style="width: 64px;height: 34px;background: #0671DD;color: #ffffff;">确定</a-button>
-            </div>
-        </template>
-    </a-modal>
-</template>
-<script>
-import { defineComponent, reactive, ref, onMounted, watch, toRefs } from 'vue';
-import { message } from 'ant-design-vue';
-import moment from 'moment';
-import { v4 as uuidv4 } from 'uuid';
-import { savePosts } from '/@/api/sys/zhiwei';
-
-const props = {
-    formData: {
-        type: Object,
-        default: {}
-    },
-    title: {
-        type: String,
-        default: "新增职位"
-    }
-}
-export default defineComponent({
-    name: 'modal',
-    components: {},
-    props,
-    setup(props, { emit }) {
-        const data = reactive({
-            width: '440px',
-            wrapClassName: 'modal-wrap',
-        })
-        const form = reactive({
-            departid: "",
-            parentId: "",
-            departName: "",
-            orderId: '',
-            orgId: ""
-        });
-        const rules = {
-            departName: [{
-                required: true,
-                message: '请输入职位名称',
-                trigger: 'blur'
-            }],
-            orderId: [{
-                required: true,
-                message: '请输入序号',
-                trigger: 'change'
-            }]
-        };
-        const title = ref(props.title)
-        const formRef = ref()
-
-        onMounted(() => {
-            if (Object.keys(props.formData).length) {
-                for (let key in form) {
-                    form[key] = props.formData[key]
-                }
-            }
-            form.orderId += ''
-        })
-        watch(
-            () => [props.formData, props.title],
-            ([newF, newD]) => {
-                for (let key in form) {
-                    form[key] = props.formData[key]
-                }
-                form.orderId += ''
-                title.value = newD
-            },
-            {
-                immediate: true,
-                deep: true
-            }
-        )
-        // 关闭请求弹窗
-        const onClose = () => {
-            emit('closeModal')
-            resetForm()
-        };
-        const onSubmit = () => {
-            formRef.value.validate().then(() => {
-                //此处调用新增
-                if (title.value === '新增职位') {
-                    form.departid = uuidv4()
-                } else {
-                    form.orgId = null
-                }
-                form.orderId = parseInt(form.orderId)
-                savePosts(form).then(res => {
-                    if (res.datas === 1) {
-                        message.success('操作成功')
-                        emit('onSubmit', true)
-                    } else {
-                        message.error('操作失败')
-                        emit('onSubmit', false)
-                    }
-                    onClose()
-                })
-            }).catch((error) => {
-                console.log('error', error);
-            });
-        };
-        const resetForm = () => {
-            formRef.value.resetFields();
-        };
-        return {
-            form,
-            rules,
-            title,
-            formRef,
-            labelCol: { span: 6 },
-            wrapperCol: { span: 16 },
-            ...toRefs(data),
-            //func
-            onClose,
-            onSubmit
-        };
-    },
-});
-</script>
-<style lang="less" scoped>
-.modal-wrap {
-    .content {
-        padding: 20px 10px 10px 20px;
-        margin-top: 10px;
-    }
-
-    ::v-deep .ant-modal-footer {
-        .btn {
-            width: 64px;
-            height: 34px;
-            background-color: red;
-        }
-    }
-}
-</style>

+ 0 - 296
src/views/systemAdmin/system/zhiwei/index copy.vue

@@ -1,296 +0,0 @@
-<template>
-    <div class="p-4">
-        <div class="zhiwei-header">
-            <div class="zhiwei-title">职位管理</div>
-            <div class="handle-btns">
-                <a-button class="btn" type="primary" @click="addHandle">新增</a-button>
-                <a-button class="btn" @click="editHandle">修改</a-button>
-                <a-button class="btn" danger @click="delHandle">删除</a-button>
-            </div>
-        </div>
-        <div class="zhiwei-body">
-            <div class="structure-tree list-items">
-                <div class="item-title">部门列表</div>
-                <a-tree :replaceFields="replaceFields" :treeData="treeData" v-if="treeData" @select="nodeSelect"></a-tree>
-            </div>
-            <div class="posts-list list-items">
-                <div class="item-title">职位列表</div>
-                <div class="posts-box item-box">
-                    <div class="posts item" v-for="(item, index) in posts.data" :key="index">
-                        <span :class="{ 'chosed': item.departid === posts.currentId }" @click="chooseHandle(item, 'posts')">{{ item.departName }}</span>
-                        <span v-if="item.departid === posts.currentId" style="color: red;" @click="openDetailModal(item)">查看</span>
-                    </div>
-                </div>
-            </div>
-        </div>
-        <ZhiweiDrawer :formData="formData" :drawerTitle="drawerTitle" @onSubmit="onSubmit" ref="drawerRef"></ZhiweiDrawer>
-        <ZhiweiModal v-if="showModal" @closeModal="showModal = false" :positionDetail="positionDetail"/>
-    </div>
-</template>
-
-<script>
-import { defineComponent, reactive, ref, toRefs, computed, onMounted, watch, createVNode } from 'vue';
-import ZhiweiDrawer from './ZhiweiDrawer.vue';
-import ZhiweiModal from './ZhiweiModal.vue';
-import { structureList, getPostsList, delPosts } from '/@/api/sys/zhiwei';
-import { message, Modal } from 'ant-design-vue';
-import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
-
-export default defineComponent({
-    name: 'zhiwei',
-    components: { ZhiweiDrawer, ZhiweiModal, ExclamationCircleOutlined },
-    setup(props, { emit }) {
-        const drawerRef = ref(null)
-        const data = reactive({
-            replaceFields: {
-                children: 'children',
-                title: 'name',
-                key: 'id'
-            },
-            treeData: [],//单位列表树
-            currentNode: "",//当前选中的树节点
-            posts: {
-                currentId: "",
-                data: []
-            },//职位数据
-            formData: {
-                departid: "",
-                parentId: "",
-                departName: "",
-                orderId: 0,
-                orgId: ""
-            },
-            drawerTitle: '新增职位',
-            showModal:false,
-            positionDetail:{}
-        });
-        /**
-         * 点击树节点触发
-         */
-        const nodeSelect = (selectkey, { selectedNodes, node }) => {
-            if (node.dataRef.departid === data.currentNode) {
-                return;
-            } else {
-                data.currentNode = node.dataRef.departid
-            }
-            resetDatas()
-            let params = {
-                departmentId: node.dataRef.departid
-            }
-            getPostsList(params).then(res => {
-                if (res.datas) {
-                    data.posts.data = res.datas
-                    !res.datas.length && message.info('该部门下无职位数据')
-                }else{
-                    message.info('该部门下无职位数据')
-                }
-            })
-        };
-        const resetDatas = () => {
-            data.posts.data = []
-            data.posts.currentId = ""
-        }
-        const chooseHandle = (item) => {
-            if (data.posts.currentId === item.departid) {
-                return;
-            }
-            data.posts.currentId = item.departid
-        }
-        const openDetailModal = (item) => {
-            data.positionDetail = item
-            data.showModal = true
-        }
-        onMounted(() => {
-            structureList().then(res => {
-                res.length && (data.treeData = res)
-            })
-        });
-        /**
-         * 对职位的操作
-         */
-        const addHandle = () => {
-            if (data.currentNode === "") {
-                message.error('请先选择机构!')
-            } else {
-                data.formData = {
-                    departid: "",
-                    parentId: "",
-                    departName: "",
-                    orderId: data.posts.data.length + 1,
-                    orgId: data.currentNode
-                }
-                data.drawerTitle = '新增职位'
-                drawerRef.value.showDrawer()
-            }
-        }
-        const editHandle = () => {
-            if (data.currentNode === "") {
-                message.error('请先选择机构!')
-            } else if (data.posts.currentId === "") {
-                message.error('请先选择职位!')
-            } else {
-                data.posts.data.forEach(item => {
-                    if (item.departid === data.posts.currentId) {
-                        data.formData = {
-                            departid: data.posts.currentId,
-                            parentId: item.parentId,
-                            departName: item.departName,
-                            orderId: item.orderId
-                        }
-                        data.drawerTitle = '修改职位'
-                        drawerRef.value.showDrawer()
-                    }
-                })
-            }
-        }
-        const delHandle = () => {
-            if (data.currentNode === "") {
-                message.error('请先选择机构!')
-            } else if (data.posts.currentId === "") {
-                message.error('请先选择职位!')
-            } else {
-                Modal.confirm({
-                    title: '删除提示',
-                    icon: createVNode(ExclamationCircleOutlined),
-                    content: '确定删除岗位?',
-                    centered: true,
-                    okText: '确定',
-                    okType: 'danger',
-                    cancelText: '取消',
-                    onOk: (() => {
-                        let params = {
-                            orgId: data.currentNode,
-                            departid: data.posts.currentId
-                        }
-                        delPosts(params).then(res => {
-                            if (res.datas === 1) {
-                                message.success('操作成功')
-                                onSubmit(true)
-                            } else {
-                                message.error('操作失败')
-                            }
-                        })
-                    })
-                });
-
-            }
-        }
-        const onSubmit = (e) => {
-            if (e) {
-                data.posts.data = []
-                data.posts.currentId = ""
-                let params = {
-                    departmentId: data.currentNode
-                }
-                getPostsList(params).then(res => {
-                    if (res.datas) {
-                        data.posts.data = res.datas
-                    }
-                })
-            }
-        }
-        return {
-            drawerRef,
-            ...toRefs(data),
-            nodeSelect,
-            chooseHandle,
-            addHandle,
-            editHandle,
-            delHandle,
-            openDetailModal,
-            onSubmit
-        };
-    },
-});
-</script>
-
-<style lang="less" scoped>
-.p-4 {
-    height: 100%;
-
-    .zhiwei-header {
-        padding: 10px;
-        width: 100%;
-        height: 70px;
-        background-color: #fff;
-        display: flex;
-        justify-content: space-between;
-        align-items: center;
-
-        .zhiwei-title {
-            font-size: 16px;
-            font-weight: 500;
-            margin-left: 20px;
-            user-select: none;
-        }
-
-        .handle-btns {
-            margin-right: 20px;
-            display: flex;
-
-            .btn {
-                margin-right: 10px;
-
-                &:last-child {
-                    margin-right: 0;
-                }
-            }
-        }
-    }
-
-    .zhiwei-body {
-        margin-top: 20px;
-        width: 100%;
-        // height: 800px;
-        height: calc(100% - 90px);
-        display: flex;
-
-        .list-items {
-            margin-right: 20px;
-            padding: 10px;
-            height: 100%;
-            overflow: auto;
-            flex: 1;
-            background-color: #fff;
-
-            &:last-child {
-                margin-right: 0;
-            }
-
-            .item-title {
-                padding-left: 10px;
-                height: 40px;
-                line-height: 40px;
-                font-size: 16px;
-                background-color: #9eafe7;
-            }
-
-            .item-box {
-                margin-top: 7px;
-
-                .item {
-                    width: fit-content;
-                    height: 32px;
-                    display: flex;
-                    align-items: center;
-
-                    span {
-                        padding: 4px;
-                        cursor: pointer;
-                        user-select: none;
-
-                        &:hover {
-                            background-color: #f5f5f5;
-                        }
-                        margin-right: 30px;
-                    }
-
-                    .chosed {
-                        background-color: #dbedff;
-                    }
-                }
-            }
-        }
-    }
-}
-</style>

+ 51 - 30
src/views/systemAdmin/system/zhiwei/index.vue

@@ -1,18 +1,20 @@
 <template>
     <div class="zhiwei p-4">
         <div class="left-tree-box">
-            <div class="tree-title">部门列表</div>
+            <div class="tree-title">机构列表</div>
             <div class="tree-box">
                 <div class="search-input">
-                    <a-input-search v-model:value="treeSearchValue" placeholder="搜索关键字" style="width: 100%;height:100%;" />
+                    <a-input-search v-model:value="treeSearchValue" placeholder="搜索关键字"
+                        style="width: 100%;height:100%;" />
                 </div>
                 <div class="tree-container">
-                    <a-directory-tree :tree-data="treeData" :expandedKeys="expandedKeys" class="tree-list" :showIcon="false"
-                        :auto-expand-parent="autoExpandParent" @expand="onExpand" :replaceFields="replaceFields"
-                        @select="nodeSelect">
+                    <a-directory-tree :tree-data="treeData" :expandedKeys="expandedKeys" class="tree-list"
+                        :showIcon="false" :auto-expand-parent="autoExpandParent" @expand="onExpand"
+                        :replaceFields="replaceFields" @select="nodeSelect">
                         <template #switcherIcon>
                             <div class="self-switcher-icon"></div>
                         </template>
+
                         <template #title="{ name, selected, dataRef }">
                             <span v-if="name.indexOf(treeSearchValue) > -1">
                                 {{ name.substr(0, name.indexOf(treeSearchValue)) }}
@@ -27,11 +29,13 @@
         </div>
         <div class="right-table-box">
             <BasicTable @register="registerTable" class="basic-table">
+
                 <template #toolbar>
                     <Button type="primary" @click="handleAdd">
                         新增
                     </Button>
                 </template>
+
                 <template #action="{ record }">
                     <TableAction :actions="[
                         {
@@ -49,8 +53,7 @@
                 </template>
             </BasicTable>
         </div>
-        <ZhiweiModalVue v-if="ifShowModal" :title="modalTitle" :formData="formData" @closeModal="ifShowModal = false"
-            @onSubmit="onSubmit" />
+        <ZhiweiManageModal @register="registerModal" @success="onSubmit"></ZhiweiManageModal>
     </div>
 </template>
 
@@ -60,16 +63,18 @@ import { defineComponent, reactive, ref, toRefs, computed, onMounted, watch, cre
 import { structureList, getPostsList, delPosts } from '/@/api/sys/zhiwei';
 // 导入表格组件,表格事件
 import { BasicTable, useTable, TableAction } from '/@/components/Table';
+import { useModal } from '/@/components/Modal';
 import { Button } from 'ant-design-vue';
 import { message, Modal } from 'ant-design-vue';
 import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
 
-import ZhiweiModalVue from './ZhiweiModal.vue';
+import ZhiweiManageModal from './ZhiweiManageModal.vue';
 
 export default defineComponent({
     name: 'zhiwei',
-    components: { BasicTable, TableAction, Button, ZhiweiModalVue, ExclamationCircleOutlined },
+    components: { BasicTable, TableAction, Button, ZhiweiManageModal, ExclamationCircleOutlined },
     setup(props, { emit }) {
+        const [registerModal, { openModal }] = useModal();
         // 机构树所用的数据
         const data = reactive({
             replaceFields: {
@@ -174,12 +179,6 @@ export default defineComponent({
                 key: 'departName',
                 align: 'center'
             },
-            // {
-            //     title: '职位id',
-            //     dataIndex: 'departid',
-            //     key: 'departid',
-            //     align: 'center'
-            // },
             {
                 title: '排序',
                 dataIndex: 'orderId',
@@ -218,8 +217,6 @@ export default defineComponent({
             }
         });
         const formData = ref(null)
-        const modalTitle = ref('新增职位')
-        const ifShowModal = ref(false)
         //新增职位
         const handleAdd = () => {
             if (!departmentId.value) {
@@ -234,8 +231,13 @@ export default defineComponent({
                 orderId: tempData.length + 1,
                 orgId: departmentId.value
             }
-            modalTitle.value = '新增职位'
-            ifShowModal.value = true
+            openModal(true, {
+                status: 'add',
+                form: {
+                    orderId: tempData.length + 1,
+                    orgId: departmentId.value
+                }
+            });
         }
         //修改职位
         const handleEdit = (item) => {
@@ -245,8 +247,15 @@ export default defineComponent({
                 departName: item.departName,
                 orderId: item.orderId
             }
-            modalTitle.value = '编辑职位'
-            ifShowModal.value = true
+            openModal(true, {
+                status: 'edit',
+                form: {
+                    departid: item.departid,
+                    parentId: item.parentId,
+                    departName: item.departName,
+                    orderId: item.orderId
+                }
+            });
         }
         //删除职位
         const handleDelete = (id) => {
@@ -266,20 +275,30 @@ export default defineComponent({
                     delPosts(params).then(res => {
                         if (res.resp_code === 0) {
                             message.success('操作成功')
-                            onSubmit(true)
-                        } else if(res.resp_code === 1) {
+                            onSubmit()
+                        } else if (res.resp_code === 1) {
                             message.info(res.resp_msg)
-                        } else{
+                        } else {
                             message.error('操作失败')
                         }
                     })
                 })
             });
         }
-        const onSubmit = (e) => {
-            if (e) {
-                reload();
-            }
+        const onSubmit = () => {
+            reload();
+        }
+        const getKeys = (treeData) => {
+            let keys = [];
+            treeData.forEach(element => {
+                keys.push(element.id)
+                if (element.children?.length) {
+                    element.children.forEach(item => {
+                        keys.push(item.id)
+                    })
+                }
+            });
+            return keys
         }
         onMounted(() => {
             //初始化时获取所有机构
@@ -288,18 +307,19 @@ export default defineComponent({
                     data.treeData = res
                     data.dataList = []
                     generateList(data.treeData)
+                    const keys = getKeys(data.treeData)
+                    data.expandedKeys = keys;
                 }
             })
         });
         return {
             formData,
-            modalTitle,
-            ifShowModal,
             ...toRefs(data),
             //func
             onExpand,
             nodeSelect,
             registerTable,
+            registerModal,
             reload,
             handleAdd,
             handleEdit,
@@ -427,6 +447,7 @@ export default defineComponent({
 
             ::v-deep .ant-table-title {
                 padding: 0 !important;
+
                 .vben-basic-title {
                     font-family: '阿里巴巴普惠体 2.0';
                     font-size: 16px;

+ 59 - 0
src/views/systemAdmin/system/zhiwei/zhiwei.data.ts

@@ -0,0 +1,59 @@
+import { FormSchema } from '/@/components/Table';
+
+export const formSchema: FormSchema[] = [
+    {
+        field: 'departid',
+        label: '职位id',
+        component: 'Input',
+        show: false
+    },
+    {
+        field: 'orgId',
+        label: '机构id',
+        component: 'Input',
+        show: false
+    },
+    {
+        field: 'parentId',
+        label: '父级id',
+        component: 'Input',
+        show: false
+    },
+    {
+        field: 'departName',
+        label: '职位名称',
+        component: 'Input',
+        required: true,
+        componentProps: {
+            maxLength: 255,
+            placeholder: '请输入名称',
+        },
+    },
+    {
+        field: 'orderId',
+        label: '职位排序',
+        component: 'Input',
+        componentProps: {
+            // type: 'number',
+            maxLength: 255,
+            placeholder: '请输入排序'
+        },
+        dynamicRules: () => {
+            return [
+                {
+                    required: true,
+                    validator: (_, value) => {
+                        if (!String(value).length) {
+                            return Promise.reject('请输入序号');
+                        }
+                        let test = /^[0-9]\d*$/
+                        if (!test.test(value)) {
+                            return Promise.reject('请输入正确的序号');
+                        }
+                        return Promise.resolve();
+                    },
+                },
+            ];
+        }
+    }
+];