马宇豪
2025-03-04 1b9fea7d4af68d8f933b2dc42bf6084b9646f64c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<template>
    <el-dialog v-model="dialogVisible" :fullscreen="full" title="用户选择" width="60%" draggable>
        <el-button @click="toggleFullscreen" size="small" class="pot" :icon="FullScreen"></el-button>
        <el-row>
            <el-col :span="6">
                <div class="userTree">
                    <el-input v-model="filterText" placeholder="请输入组织机构过滤"></el-input>
                    <div class="tree">
                        <el-tree ref="treeRef" :data="data" :props="propse" @node-click="handleNodeClick" :filter-node-method="filterNode" />
                    </div>
                </div>
            </el-col>
            <el-col :span="14" style="padding: 20px">
                <el-form ref="ruleFormRef" :model="ruleForm" status-icon>
                    <el-row>
                        <el-col :span="10" :offset="1">
                            <el-form-item size="default">
                                <el-input v-model="ruleForm.pass" placeholder="登录名" />
                            </el-form-item>
                        </el-col>
                        <el-col :span="8" :offset="1">
                            <el-form-item>
                                <el-button size="default" type="primary" >查询</el-button>
                                <el-button size="default">重置</el-button>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
                <el-table :data="tableData" style="width: 100%; margin-top: 20px" @cell-click="radio">
                    <el-table-column align="center">
                        <template #default="scope">
                            <el-radio-group v-model="radio1">
                                <el-radio :label="scope.row.uid" size="large">{{ null }}</el-radio>
                            </el-radio-group>
                        </template>
                    </el-table-column>
                    <el-table-column align="center" prop="realName" label="登录名" />
                    <el-table-column align="center" prop="username" label="用户名" />
                    <el-table-column align="center" prop="address" label="所属机构" />
                    <el-table-column align="center" prop="address" label="所属部门" />
                    <el-table-column align="center" prop="type" label="状态" />
                </el-table>
                <el-pagination
                    style="padding: 20px 0; border-bottom: 1px solid #dedede"
                    v-model:currentPage="currentPage4"
                    v-model:page-size="pageSize4"
                    :page-sizes="[100, 200, 300, 400]"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="400"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                />
            </el-col>
            <el-col :span="4">
            <div v-if="dynamicTags[0]==''?false:true">
                <el-tag
                    v-for="tag in dynamicTags"
                    :key="tag"
                    class="mx-1"
                    style="margin: 5px"
                    closable
                    :disable-transitions="false"
                    @close="handleClose(tag)"
                >
                    {{ tag.realName }}
                </el-tag>
                </div>
            </el-col>
        </el-row>
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="dialogVisible = false" size="default">关闭</el-button>
                <el-button type="primary" @click="submitForm" size="default">确定</el-button>
            </span>
        </template>
    </el-dialog>
</template>
<script lang="ts">
import { defineComponent, ref, onMounted, reactive, watch } from 'vue';
import { FullScreen } from '@element-plus/icons-vue';
import { ElMessageBox, ElTree, ElMessage, ElButton, ElInput, TabsPaneContext } from 'element-plus';
import { goalManagementApi } from '/@/api/goalManagement';
interface Tree {
    label: string;
    children?: Tree[];
}
export default defineComponent({
    setup(props, { emit }) {
        //部门树
        const department = () => {
            goalManagementApi()
                .getTreedepartment()
                .then((res) => {
                    if (res.data.code == 200) {
                        data.value = res.data.data;
                    } else {
                        ElMessage.error(res.data.msg);
                    }
                });
        };
        const propse = {
            label: 'depName',
            children: 'children',
            value: 'depId',
        };
        //部门树查询
        const filterText = ref('');
        const treeRef = ref<InstanceType<typeof ElTree>>();
        watch(filterText, (val) => {
            treeRef.value!.filter(val);
        });
        const filterNode = (depName: string, data: Tree) => {
            if (!depName) return true;
            return data.depName.includes(depName);
        };
        onMounted(() => {
            department();
        });
        //左边树形部分点击获取回调
        const names = ref<any>();
        const handleNodeClick = (data: Tree) => {
            goalManagementApi()
                .getManName(data.depId)
                .then((res) => {
                    if (res.data.code == 200) {
                        tableData.value=res.data.data
                    }else{
                        ElMessage.error(res.data.msg);
                    }
                });
        };
 
        const data = ref();
        //中间表格
        // 搜索条件
        const ruleForm = reactive({
            pass: '',
            checkPass: '',
        });
        // 表格
        const tableData = ref();
        const currentPage4 = ref();
        const pageSize4 = ref();
        const handleSizeChange = (val: number) => {
            console.log(`${val} items per page`);
        };
        const handleCurrentChange = (val: number) => {
            console.log(`current page: ${val}`);
        };
        // 右方点击添加后显示标签
        const dynamicTags = ref(['']);
        const handleClose = (tag: any) => {
            dynamicTags.value.splice(dynamicTags.value.indexOf(tag), 1);
            radio1.value = '';
        };
        const radio1 = ref('');
        const radio = (event: any) => {
            dynamicTags.value[0] = event;
        };
        const types=ref()
        // 开启弹窗
        const dialogVisible = ref(false);
        const openDailog = (type:any) => {
            console.log(type)
            types.value=type
            dialogVisible.value = true;
        };
        //全屏
        const full = ref(false);
        const toggleFullscreen = () => {
            if (full.value == false) {
                full.value = true;
            } else {
                full.value = false;
            }
        };
        const submitForm = () => {
            emit('SearchUser', dynamicTags.value);
            dialogVisible.value = false;
        };
        return {
            types,
            filterText,
            treeRef,
            filterNode,
            propse,
            dialogVisible,
            names,
            data,
            handleNodeClick,
            openDailog,
            ruleForm,
            tableData,
            currentPage4,
            pageSize4,
            handleSizeChange,
            handleCurrentChange,
            radio1,
            dynamicTags,
            handleClose,
            FullScreen,
            full,
            toggleFullscreen,
            radio,
            submitForm,
        };
    },
});
</script>
<style scoped>
.userTree {
    border: 1px solid #ebeef5;
}
.userTree .el-input {
    padding: 10px;
    border-bottom: 1px solid #ebeef5;
}
.tree {
    height: 500px;
    overflow: hidden;
    overflow-y: auto;
}
</style>