沈丘营商办后台前端项目
wjt
2024-06-24 cace6971fbdb31ade5c5ae2cdca781ff50f9510c
添加分管机构
2个文件已修改
82 ■■■■■ 已修改文件
src/api/system/company/company.ts 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/user/index.vue 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/system/company/company.ts
@@ -292,3 +292,30 @@
    data: data
  })
}
// 多机构回显 /system/user/batchUserDeptView
export function batchUserDeptView(data) {
  return request({
    url: `/system/user/batchUserDeptView`,
    method: 'get',
    params: data
  })
}
// 机构树 /system/user/batchUserDeptTree
export function batchUserDeptTree(data) {
  return request({
    url: `/system/user/batchUserDeptTree`,
    method: 'get',
    params: data
  })
}
// 机构数保存 /system/user/batchUserDeptSave
export function batchUserDeptSave(data) {
  return request({
    url: `/system/user/batchUserDeptSave`,
    method: 'post',
    data: data
  })
}
src/views/system/user/index.vue
@@ -86,7 +86,7 @@
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" align="center" width="280" class-name="small-padding fixed-width">
          <el-table-column label="操作" align="center" width="380" class-name="small-padding fixed-width">
            <template #default="scope">
              <!-- <el-tooltip content="修改" placement="top" v-if="scope.row.userId !== 1"> -->
                <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']">修改</el-button>
@@ -103,6 +103,7 @@
              <!-- <el-tooltip content="重置支付密码" placement="top" v-if="scope.row.userId !== 1">
                <el-button link type="danger" icon="Key" @click="handlePayPwd(scope.row)" v-hasPermi="['system:user:resetPwd']"></el-button>
              </el-tooltip> -->
              <el-button link type="success" icon="Key" @click="handlerDept(scope.row)" v-hasPermi="['system:user:resetPwd']">分管机构</el-button>
            </template>
          </el-table-column>
        </el-table>
@@ -235,13 +236,25 @@
        </div>
      </template>
    </el-dialog>
    <!-- 多机构绑定 -->
     <el-dialog title="分管机构"  v-model="openDialog" width="400px" append-to-body>
        <el-tree :data="treeData" ref="depttree" :default-expanded-keys="defaultKeys" :props="{label: 'deptName', value: 'deptId', children: 'child' }" node-key="deptId" :default-checked-keys="defaultKeys" show-checkbox>
        </el-tree>
        <template #footer>
          <div class="dialog-footer">
            <el-button type="primary" @click="submitFileFormSave">确 定</el-button>
            <el-button @click="openDialog = false">取 消</el-button>
          </div>
        </template>
     </el-dialog>
  </div>
</template>
<script setup name="User">
import { getToken } from "@/utils/auth";
import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect, resetPayPwd,updateUserProfile } from "@/api/system/user";
import { batchUserDeptView,batchUserDeptTree,batchUserDeptSave  } from '@/api/system/company/company'
const router = useRouter();
const { proxy } = getCurrentInstance();
const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex");
@@ -570,4 +583,42 @@
getDeptTree();
// getList();
const openDialog = ref(false)
const userInfo = reactive({
  userId: "",
})
const treeData = ref([])
const defaultKeys = ref([])
const depttree = ref()
function handlerDept(item) {
  userInfo.userId = item.userId
  openDialog.value = true
  batchUserDeptTreeHttp(item.deptId)
  batchUserDeptViewHttp(userInfo.userId)
}
function batchUserDeptViewHttp(userId) {
  batchUserDeptView({userId}).then(val => {
    defaultKeys.value = val.data.deptIds
  })
}
function batchUserDeptTreeHttp(deptId) {
  batchUserDeptTree({deptId}).then(val => {
    val.data.child.forEach(item => {
      // item.disabled = true
      if(item.deptId == deptId) {
        item.disabled = true
      }
    })
    treeData.value = [val.data]
  })
}
function submitFileFormSave() {
  userInfo.deptIds = depttree.value.getCheckedKeys()
  batchUserDeptSave(userInfo).then(val => {
    if(val.code == 200){
      openDialog.value = false
    }
  })
}
</script>