| | |
| | |
|
| | | <script setup name="User">
|
| | | import { getToken } from "@/utils/auth";
|
| | | import { treeselect } from "@/api/system/dept";
|
| | | import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser } from "@/api/system/user";
|
| | | import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user";
|
| | |
|
| | | const router = useRouter();
|
| | | const { proxy } = getCurrentInstance();
|
| | |
| | | proxy.$refs["deptTreeRef"].filter(val);
|
| | | });
|
| | | /** 查询部门下拉树结构 */
|
| | | function getTreeselect() {
|
| | | treeselect().then(response => {
|
| | | function getDeptTree() {
|
| | | deptTreeSelect().then(response => {
|
| | | deptOptions.value = response.data;
|
| | | });
|
| | | };
|
| | |
| | | function submitFileForm() {
|
| | | proxy.$refs["uploadRef"].submit();
|
| | | };
|
| | | /** 初始化部门数据 */
|
| | | function initTreeData() {
|
| | | // 判断部门的数据是否存在,存在不获取,不存在则获取
|
| | | if (deptOptions.value === undefined) {
|
| | | treeselect().then(response => {
|
| | | deptOptions.value = response.data;
|
| | | });
|
| | | }
|
| | | };
|
| | | /** 重置操作表单 */
|
| | | function reset() {
|
| | | form.value = {
|
| | |
| | | /** 新增按钮操作 */
|
| | | function handleAdd() {
|
| | | reset();
|
| | | initTreeData();
|
| | | getUser().then(response => {
|
| | | postOptions.value = response.posts;
|
| | | roleOptions.value = response.roles;
|
| | |
| | | /** 修改按钮操作 */
|
| | | function handleUpdate(row) {
|
| | | reset();
|
| | | initTreeData();
|
| | | const userId = row.userId || ids.value;
|
| | | getUser(userId).then(response => {
|
| | | form.value = response.data;
|
| | |
| | | });
|
| | | };
|
| | |
|
| | | getTreeselect();
|
| | | getDeptTree();
|
| | | getList();
|
| | | </script>
|