兰宝车间质量管理系统-前端
dap
2024-04-30 0b8f48fb610c8a2e3f9fb633241fcf46a78da69d
src/views/system/user/index.vue
@@ -287,10 +287,11 @@
import { UserForm, UserQuery, UserVO } from '@/api/system/user/types';
import { DeptVO } from '@/api/system/dept/types';
import { RoleVO } from '@/api/system/role/types';
import { PostVO } from '@/api/system/post/types';
import { PostQuery, PostVO } from '@/api/system/post/types';
import { treeselect } from '@/api/system/dept';
import { globalHeaders } from '@/utils/request';
import { to } from 'await-to-js';
import { optionselect } from '@/api/system/post';
const router = useRouter();
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -592,6 +593,9 @@
  roleOptions.value = data.roles;
  form.value.password = initPassword.value.toString();
};
/** 是否已经更改过岗位 */
const updatedPost = ref(true);
/** 修改按钮操作 */
const handleUpdate = async (row?: UserForm) => {
  reset();
@@ -606,6 +610,8 @@
  form.value.postIds = data.postIds;
  form.value.roleIds = data.roleIds;
  form.value.password = '';
  /** 编辑 默认未修改过岗位 */
  updatedPost.value = false;
};
/** 提交按钮 */
@@ -645,6 +651,23 @@
    initPassword.value = response.data;
  });
});
// 监测部门变化加载岗位
watch(
  () => form.value.deptId,
  async () => {
    const response = await optionselect(form.value.deptId);
    postOptions.value = response.data;
    /** 判断是否修改过岗位 防止第一次编辑时有岗位信息也被设置为空 */
    if (updatedPost.value) {
      /** 变化后需要重新选择岗位 */
      form.value.postIds = [];
      return;
    }
    /** 执行一次后默认设为已经修改过 */
    updatedPost.value = true;
  }
);
</script>
<style lang="scss" scoped></style>