index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. <template>
  2. <div class="h-full flex flex-col teamstyle overflow-hidden">
  3. <!-- 头部 -->
  4. <div class="bg-white flex justify-between team-header">
  5. <div class="flex items-center">
  6. <el-link type="primary" class="text-nowrap mr-20" :icon="CirclePlusFilled"
  7. @click="dialogFromCli('addDeptDialogVisible')">创建部门</el-link>
  8. <el-link class="text-nowrap textFont textFont mr-10" type="primary" :icon="Edit"
  9. @click="updateDepartment('addDeptDialogVisible')">{{ deptListItem.label || '全部人员' }}</el-link>
  10. <span class="textSpan">共 0 人</span>
  11. </div>
  12. <div class="teamForm flex items-center">
  13. <el-input v-model="teamForm.keyword" style="max-width: 650px" size="default" placeholder="请输入姓名搜索" class="mr-6"
  14. clearable @clear="getTableData()" @keyup.enter.native="getTableData()">
  15. <template #prepend>
  16. <el-select v-model="teamForm.matchingType" style="width: 80px">
  17. <el-option label="姓名" :value="0" />
  18. <el-option label="电话" :value="1" />
  19. <el-option label="工号" :value="2" />
  20. </el-select>
  21. </template>
  22. <template #append>
  23. <el-button :icon="Search" @click="getTableData()" />
  24. </template>
  25. </el-input>
  26. <div class="formItem mr-6 flex items-center">
  27. <div class="text-nowrap">状态:</div>
  28. <el-select v-model="teamForm.status" placeholder="请选择" size="default" style="width: 100px"
  29. @change="getTableData()">
  30. <el-option v-for="item in stateOptions" :key="item.value" :label="item.label" :value="item.value" />
  31. </el-select>
  32. </div>
  33. <div class="formItem mr-6 flex items-center">
  34. <div class="text-nowrap">角色:</div>
  35. <el-select v-model="teamForm.roleId" placeholder="请选择" size="default" style="width: 150px" clearable
  36. @change="getTableData()">
  37. <el-option v-for="item in roleList" :key="item.id" :label="item.rolename" :value="item.id" />
  38. </el-select>
  39. </div>
  40. <el-dropdown>
  41. <el-button type="primary">
  42. 更多操作<el-icon class="el-icon--right"><arrow-down /></el-icon>
  43. </el-button>
  44. <template #dropdown>
  45. <el-dropdown-menu>
  46. <el-dropdown-item @click="addPersone(false)" v-permission="['teamAdd']">添加人员</el-dropdown-item>
  47. <el-dropdown-item @click="transitionOperation('exportUser', '')" v-permission="['teamExport']">导出人员</el-dropdown-item>
  48. <el-dropdown-item @click="transitionOperation('importUser', '')" v-permission="['teamImport']">批量导入</el-dropdown-item>
  49. </el-dropdown-menu>
  50. </template>
  51. </el-dropdown>
  52. </div>
  53. </div>
  54. <!-- 内容 -->
  55. <div class="flex-1 flex">
  56. <div class="p-4 w-80 pr-0">
  57. <div class="bg-white w-full h-full shadow-md rounded-md flex flex-col">
  58. <div class="flex-1 overflow-y-auto const-left">
  59. <el-tree style="max-width: 600px" :data="deptList" :props="treeProps" @node-click="treeNode">
  60. <template #default="{ node, data }">
  61. <div class="flex justify-between treeContent">
  62. <div class="custom-tree-node">
  63. <div class="treeLabel">{{ node.label }}</div>
  64. <div class="treeIcon" v-if="data.id > 0">
  65. <el-link type="primary" :icon="CirclePlus" :underline="false"
  66. @click.stop="dialogFromCli('addDeptDialogVisible', data, true)"></el-link>
  67. <el-link type="primary" :icon="Delete" :underline="false" style="margin-left: 6px;"
  68. @click.stop="deteleDept(data)"></el-link>
  69. </div>
  70. </div>
  71. </div>
  72. </template>
  73. </el-tree>
  74. </div>
  75. </div>
  76. </div>
  77. <div class="flex-1 p-4 overflow-auto">
  78. <div class="bg-white w-full h-full shadow-md rounded-md flex flex-col overflow-hidden pt-2 pl-2 pr-2">
  79. <div class="flex-1">
  80. <el-table ref="multipleTableRef" :data="tableData" v-loading="loadingFrom.tableLoading"
  81. @selection-change="changeBatch" style="width: 100%;height: 100%;">
  82. <el-table-column type="selection" width="55" />
  83. <el-table-column label="姓名" property="name" width="150"></el-table-column>
  84. <el-table-column label="手机" property="phone"></el-table-column>
  85. <el-table-column label="工号" property="jobNumber"></el-table-column>
  86. <el-table-column label="部门" property="departmentName"></el-table-column>
  87. <el-table-column label="角色" property="roleName"></el-table-column>
  88. <el-table-column label="创建时间" property="createTime"></el-table-column>
  89. <el-table-column label="操作" width="200" fixed="right">
  90. <template #default="scope">
  91. <el-button :size="'small'" @click="resetPwd(scope.row)">重置</el-button>
  92. <el-button type="primary" :size="'small'" @click="addPersone(scope.row)">编辑</el-button>
  93. <el-button :size="'small'" @click="transitionOperation('disable', scope.row)"
  94. v-if="scope.row.isActive == 1">停用</el-button>
  95. <el-button type="success" :size="'small'" @click="enableUser(scope.row)"
  96. v-if="scope.row.isActive == 0">启用</el-button>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. </div>
  101. <div class="flex justify-between pb-2 pt-2 pl-3 pr-3">
  102. <div class="flex">
  103. <el-button size="default" @click="changeBatch(false)"
  104. :disabled="batchTableData.length == 0">取消</el-button>
  105. <el-dropdown class="ml-3">
  106. <el-button type="primary">
  107. 更多操作<el-icon class="el-icon--right"><arrow-down /></el-icon>
  108. </el-button>
  109. <template #dropdown>
  110. <el-dropdown-menu>
  111. <el-dropdown-item @click="batchItem('批量修改部门', 'dept', deptList)"
  112. :disabled="batchTableData.length == 0">批量修改部门</el-dropdown-item>
  113. <el-dropdown-item @click="batchItem('批量修改角色', 'role', roleList)"
  114. :disabled="batchTableData.length == 0">批量修改角色</el-dropdown-item>
  115. <el-dropdown-item @click="batchEnableItem"
  116. :disabled="batchTableData.length == 0">批量启用员工</el-dropdown-item>
  117. </el-dropdown-menu>
  118. </template>
  119. </el-dropdown>
  120. </div>
  121. <div class="pr-4">
  122. <el-pagination layout="total, prev, pager, next, sizes" :total="totalTable" :page-size="teamForm.pageSize"
  123. @size-change="handleSizeChange" @current-change="handleCurrentChange" />
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. <!-- 新增部门 -->
  130. <el-dialog v-model="dialogFrom.addDeptDialogVisible" width="600" :show-close="false" :before-close="handleClose">
  131. <template #header="{ close, titleId, titleClass }">
  132. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  133. <h4 :id="titleId">{{ deptListItem.label || '创建部门' }}</h4>
  134. <div class="flex">
  135. <el-button @click="dialogFrom.addDeptDialogVisible = false">取消</el-button>
  136. <el-button type="primary" @click="createDepartment(deptRuleFormRef)"
  137. v-bind:loading="loadingFrom.deptDialogVisibleLoading">
  138. 确定
  139. </el-button>
  140. </div>
  141. </div>
  142. </template>
  143. <div class="pt-5">
  144. <el-form ref="deptRuleFormRef" style="max-width: 500px" :model="deptForm" :rules="deptRules" label-width="140px"
  145. size="large" status-icon>
  146. <el-form-item label="部门名称" prop="name">
  147. <el-input v-model="deptForm.name" placeholder="请输入部门名称" clearable />
  148. </el-form-item>
  149. <el-form-item label="主要负责人">
  150. <el-select v-model="deptForm.managerId" placeholder="请选择" style="width: 100%" clearable>
  151. <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id" />
  152. </el-select>
  153. </el-form-item>
  154. <el-form-item label="其他负责人">
  155. <el-select v-model="deptForm.otherManagerIds" placeholder="请选择" style="width: 100%" multiple clearable>
  156. <el-option v-for="item in userList" :key="item.id" :label="item.name" :value="item.id" />
  157. </el-select>
  158. </el-form-item>
  159. </el-form>
  160. </div>
  161. </el-dialog>
  162. <!-- 停用 -->
  163. <el-dialog v-model="dialogFrom.resignationVisible" width="600" :show-close="false" :before-close="handleClose">
  164. <template #header="{ close, titleId, titleClass }">
  165. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  166. <h4 :id="titleId">离职停用员工</h4>
  167. <div class="flex">
  168. <el-button @click="dialogFrom.resignationVisible = false">取消</el-button>
  169. <el-button type="primary" @click="resignation" v-bind:loading="loadingFrom.resignationLoading">
  170. 确定
  171. </el-button>
  172. </div>
  173. </div>
  174. </template>
  175. <div class="pt-4 pb-2">
  176. <div class="flex items-center justify-center">
  177. <div class="pr-2">员工离职日期:</div>
  178. <el-date-picker v-model="resignationDate" type="date" placeholder="请选择日期" value-format="YYYY-MM-DD"
  179. :clearable="false" />
  180. </div>
  181. </div>
  182. </el-dialog>
  183. <!-- 导出人员列表 -->
  184. <el-dialog v-model="dialogFrom.exportUserVisible" width="600" :show-close="false" :before-close="handleClose">
  185. <template #header="{ close, titleId, titleClass }">
  186. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  187. <h4 :id="titleId">导出人员列表</h4>
  188. <div class="flex">
  189. <el-button @click="dialogFrom.exportUserVisible = false">取消</el-button>
  190. <el-button type="primary" @click="exportUser" v-bind:loading="loadingFrom.exportUserLoading">
  191. 导出
  192. </el-button>
  193. </div>
  194. </div>
  195. </template>
  196. <div class="pt-4 pb-2">
  197. <div class="flex items-center justify-center">
  198. <div class="pr-2">导出:</div>
  199. <el-radio-group v-model="exportRadio" class="ml-4">
  200. <el-radio value="1" size="large">全部人员</el-radio>
  201. <el-radio value="0" size="large">仅在职人员</el-radio>
  202. </el-radio-group>
  203. </div>
  204. </div>
  205. </el-dialog>
  206. <!-- 人员导入 -->
  207. <el-dialog v-model="dialogFrom.importVisible" width="680" :show-close="false" top="10vh">
  208. <template #header="{ close, titleId, titleClass }">
  209. <div class="flex justify-between items-center border-b pb-3 dialog-header">
  210. <h4 :id="titleId">人员批量导入</h4>
  211. <div class="flex">
  212. <el-button class="mr-3" @click="dialogFrom.importVisible = false">取消</el-button>
  213. <el-upload ref="importUserRef" class="upload-demo" :limit="1" :show-file-list="false" accept=".xlsx"
  214. :http-request="importUser">
  215. <el-button type="primary" :loading="loadingFrom.importLoading">导入</el-button>
  216. </el-upload>
  217. </div>
  218. </div>
  219. </template>
  220. <div class="p-8">
  221. <div class="ml-4 mr-4">
  222. <div class="flex items-center">1、点击下载 <el-link type="primary"
  223. @click="downloadFile('/upload/人员导入模板.xlsx', '人员导入模板.xlsx')">人员导入模板.xlsx</el-link></div>
  224. <div class="mt-4">2、填写excel模板,并上传</div>
  225. </div>
  226. </div>
  227. </el-dialog>
  228. <!-- 新增人员 -->
  229. <AddPersonnelModal :data="{
  230. addPersonnelDialogVisible: dialogFrom.addPersonnelDialogVisible,
  231. deptList: deptListUntreated,
  232. roleList: roleList,
  233. personnelFromData: personnelFromData
  234. }" @closeModal="closeModal" @personnelModalConfirm="personnelModalConfirm" />
  235. <!-- 批量操作 -->
  236. <BatchOperation :batchData="visibleData" :batchNode="batchTableData" :visibleText="allText.batchText"
  237. :popup="visibleType" :batchOperationVisible="dialogFrom.batchOperationVisible" @close="closeModal" />
  238. </div>
  239. </template>
  240. <script lang="ts" setup>
  241. import { ref, reactive, onMounted, onBeforeMount, inject } from 'vue';
  242. import { UploadRequestOptions, dayjs } from 'element-plus'
  243. import { Search, CirclePlusFilled, Edit, CirclePlus, Delete } from '@element-plus/icons-vue'
  244. import { FormInstance, FormRules, ElMessageBox } from 'element-plus'
  245. import { useStore } from '@/store/index'
  246. import { GET_DATA_LIST, DETELE_DEPT, MOD, GET_USERINFO, GET_ROUTELIST, DEACTIVEUSER, SETACTIVE, GET_DEPTLIST, BACTHSERROLE, GET_USERLIST, GET_ADDDEPT, ADD_USER, SETRESETPWD, EXPOERTUSER } from './api'
  247. import { post, uploadFile } from "@/utils/request";
  248. import { getFromValue, updateDepTreeData, resetFromValue, confirmAction, downloadFile } from '@/utils/tools'
  249. // 导入页面
  250. import AddPersonnelModal from './module/AddPersonnelModal.vue'
  251. import BatchOperation from './module/BatchOperation.vue'
  252. import { formatDate } from '@/utils/times';
  253. import { URL_IMPORTTHREAD } from '../thread/constant';
  254. const { getFunctionList, getUserInfoVal } = useStore()
  255. const globalPopup = inject<GlobalPopup>('globalPopup')
  256. // 定义类型
  257. interface deptRuleForm { // 部门表单类型
  258. name: string,
  259. id: string | number,
  260. parentId: string | number,
  261. managerId: string | number,
  262. otherManagerIds: string[] | number[],
  263. }
  264. // 固定数据
  265. const stateOptions = [{ value: '3', label: '全部' }, { value: '1', label: '在职' }, { value: '0', label: '停用' }]
  266. // ref
  267. const importUserRef = ref<any>()
  268. // 定义变量
  269. const transitiondata = ref<any>() // 过度数据(针对二次弹窗)
  270. const pagePermission: any = ref([]) // 功能权限
  271. const loadingFrom = reactive({ // 所有加载状态
  272. tableLoading: false,
  273. deptDialogVisibleLoading: false,
  274. resignationLoading: false,
  275. exportUserLoading: false,
  276. importLoading: false
  277. })
  278. const dialogFrom: any = reactive({ // 所有弹窗状态
  279. addDeptDialogVisible: false,
  280. addPersonnelDialogVisible: false,
  281. batchOperationVisible: false,
  282. resignationVisible: false,
  283. exportUserVisible: false,
  284. importVisible: false,
  285. });
  286. const allText = reactive({
  287. batchText: '批量操作'
  288. })
  289. const visibleType = ref<batchOperationType>('dept') // 弹窗类型
  290. const visibleData = ref<any>([]) // 批量弹窗数据源
  291. const totalTable = ref(0) // 表格总数
  292. const tableData: any = ref([]) // 表格数据
  293. const roleList: any = ref([]) // 角色列表
  294. const userList: any = ref([]) // 用户列表
  295. const deptList: any = ref([]) // 部门数据
  296. const batchTableData: any = ref([]) // 批量数据
  297. const multipleTableRef: any = ref()
  298. const deptListUntreated: any = ref([]) // 部门数据(未处理)
  299. const deptListItem: any = ref({}) // 选中的部门数据
  300. const personnelFromData = ref({}) // 人员表单数据
  301. const resignationDate = ref(formatDate(new Date())) // 员工离职日期
  302. const exportRadio = ref('1') // 导出人员列表
  303. const teamForm = reactive({ // 筛选条件表单
  304. matchingType: 0,
  305. keyword: '',
  306. status: '3',
  307. pageIndex: 1,
  308. pageSize: 20,
  309. roleId: '',
  310. onlyDirect: '',
  311. departmentId: '-1',
  312. });
  313. const deptRuleFormRef = ref<FormInstance>() // 表单实例
  314. const deptForm = reactive<deptRuleForm>({ // 部门表单
  315. name: '',
  316. id: '',
  317. parentId: '',
  318. managerId: '',
  319. otherManagerIds: [],
  320. })
  321. const treeProps = { // 部门树配置
  322. children: 'children',
  323. label: 'label',
  324. }
  325. // 定义校验规则
  326. const deptRules = reactive<FormRules<typeof deptForm>>({ // 部门表单校验规则
  327. name: [{ required: true, trigger: 'blur', message: '请输入部门名称' }]
  328. })
  329. // 定义方法
  330. async function importUser(param: UploadRequestOptions) {
  331. loadingFrom.importLoading = true
  332. const formData = new FormData();
  333. formData.append('file', param.file)
  334. const res = await uploadFile(URL_IMPORTTHREAD, formData).finally(() => {
  335. importUserRef.value.clearFiles()
  336. loadingFrom.importLoading = false
  337. })
  338. loadingFrom.importLoading = false
  339. if (res.code == 'ok') {
  340. globalPopup?.showSuccess('导入成功' || '')
  341. closeModal('importVisible')
  342. getTableData()
  343. return
  344. }
  345. globalPopup?.showError(res.msg || '')
  346. }
  347. function exportUser() {
  348. loadingFrom.exportUserLoading = true
  349. post(EXPOERTUSER, { containInvalid: exportRadio.value }).then((res) => {
  350. downloadFile(`${res.data}`, '人员列表.xlsx')
  351. globalPopup?.showSuccess('导出成功')
  352. closeModal('exportUserVisible')
  353. }).finally(() => {
  354. loadingFrom.exportUserLoading = false
  355. })
  356. }
  357. function enableUser(row: any) {
  358. const id = row.id
  359. post(SETACTIVE, { id, isActive: 1 }).then(() => {
  360. globalPopup?.showSuccess('启用成功')
  361. getTableData()
  362. })
  363. }
  364. function resignation() {
  365. const id = transitiondata.value.id || ''
  366. loadingFrom.resignationLoading = true
  367. post(DEACTIVEUSER, { id, inactiveDate: resignationDate.value }).then(() => {
  368. globalPopup?.showSuccess('停用成功')
  369. getTableData()
  370. closeModal('resignationVisible')
  371. }).finally(() => {
  372. loadingFrom.resignationLoading = false
  373. })
  374. }
  375. function resetPwd(row: any) {
  376. const userId = row.id
  377. confirmAction(`确定要为${row.name}重置密码吗?`, '重置密码').then(() => {
  378. post(SETRESETPWD, { userId }).then(() => {
  379. globalPopup?.showSuccess('密码已重置为000000,请通知员工及时修改')
  380. }).catch((err) => {
  381. globalPopup?.showError(err.msg)
  382. })
  383. })
  384. }
  385. function batchEnableItem() {
  386. const userIds = batchTableData.value.map((item: any) => item.id)
  387. post(BACTHSERROLE, { ids: JSON.stringify(userIds), isActive: 1 }).then(() => {
  388. globalPopup?.showSuccess('操作成功')
  389. changeBatch(false)
  390. getTableData()
  391. }).catch((err) => {
  392. globalPopup?.showError(err.msg)
  393. })
  394. }
  395. function changeBatch(flag: boolean = true) {
  396. if (flag) {
  397. batchTableData.value = multipleTableRef.value && multipleTableRef.value.getSelectionRows()
  398. } else {
  399. batchTableData.value = []
  400. multipleTableRef.value && multipleTableRef.value.clearSelection()
  401. }
  402. }
  403. function addPersone(item: any) {
  404. console.log(item)
  405. if (!item) {
  406. personnelFromData.value = {}
  407. dialogFrom.addPersonnelDialogVisible = true
  408. return
  409. }
  410. post(GET_USERINFO, { userId: item.id }).then(res => {
  411. const { id, name, phone, jobNumber, roleId, departmentCascade, inductionDate } = res.data
  412. let newData = {
  413. id, name, phone, jobNumber, roleId, departmentId:
  414. departmentCascade && departmentCascade.split(',').map(Number).reverse(),
  415. inductionDate
  416. }
  417. personnelFromData.value = newData
  418. dialogFrom.addPersonnelDialogVisible = true
  419. })
  420. }
  421. async function personnelModalConfirm(data: any, modelType: string) {
  422. post(ADD_USER, { ...data }).then(res => {
  423. if (res.code != 'ok') {
  424. dialogFrom[modelType] = false
  425. globalPopup?.showError(res.msg)
  426. return
  427. }
  428. dialogFrom[modelType] = false
  429. globalPopup?.showSuccess('添加成功')
  430. getTableData()
  431. }).catch(_err => {
  432. dialogFrom[modelType] = false
  433. })
  434. }
  435. function createDepartment(formEl: FormInstance | undefined) {
  436. if (!formEl) return
  437. let data = getFromValue(deptForm)
  438. loadingFrom.deptDialogVisibleLoading = true
  439. post(GET_ADDDEPT, { ...deptForm, otherManagerIds: data.otherManagerIds && data.otherManagerIds.join(',') }).then(res => {
  440. if (res.code != 'ok') {
  441. loadingFrom.deptDialogVisibleLoading = false
  442. globalPopup?.showError(res.msg)
  443. return
  444. }
  445. loadingFrom.deptDialogVisibleLoading = false
  446. globalPopup?.showSuccess('创建成功')
  447. getDeptList()
  448. dialogFrom.addDeptDialogVisible = false
  449. }).catch(_err => {
  450. loadingFrom.deptDialogVisibleLoading = false
  451. })
  452. }
  453. function updateDepartment(type: string) {
  454. if (!deptListItem.value.id || deptListItem.value.id <= 0) return
  455. const { id, label, parentId, managerId, otherManagerIds } = deptListItem.value
  456. console.log(deptListItem.value)
  457. let data = { id, name: label, parentId, managerId, otherManagerIds }
  458. Object.assign(deptForm, data)
  459. dialogFrom[type] = true
  460. }
  461. function treeNode(item: any) {
  462. deptListItem.value = item
  463. teamForm.departmentId = item.id
  464. getTableData()
  465. }
  466. function deteleDept(data: any) {
  467. console.log(data)
  468. ElMessageBox.confirm(
  469. `确定删除【${data.label}】部门吗?`, '',
  470. {
  471. confirmButtonText: '确定',
  472. cancelButtonText: '取消',
  473. type: 'warning',
  474. }
  475. )
  476. .then(() => {
  477. post(DETELE_DEPT, { id: data.id }).then(res => {
  478. if (res.code != 'ok') {
  479. globalPopup?.showError(res.msg)
  480. return
  481. }
  482. globalPopup?.showSuccess('删除成功')
  483. getDeptList()
  484. })
  485. })
  486. }
  487. function getTableData() {
  488. loadingFrom.tableLoading = true
  489. post(GET_DATA_LIST, { ...teamForm }).then(res => {
  490. if (res.code != 'ok') {
  491. loadingFrom.tableLoading = false
  492. globalPopup?.showError(res.msg)
  493. return
  494. }
  495. loadingFrom.tableLoading = false
  496. totalTable.value = res.data.total
  497. tableData.value = res.data.records
  498. }).catch(_err => {
  499. loadingFrom.tableLoading = false
  500. })
  501. }
  502. function getRoleList() {
  503. const companyId = getUserInfoVal('companyId') || ''
  504. post(GET_ROUTELIST, { companyId }).then(res => {
  505. if (res.code != 'ok') {
  506. globalPopup?.showError(res.msg)
  507. return
  508. }
  509. roleList.value = res.data
  510. })
  511. }
  512. function getDeptList() {
  513. post(GET_DEPTLIST, {}).then(res => {
  514. if (res.code != 'ok') {
  515. globalPopup?.showError(res.msg)
  516. return
  517. }
  518. deptListUntreated.value = updateDepTreeData(res.data, false)
  519. deptList.value = updateDepTreeData(res.data, true)
  520. })
  521. }
  522. function getUserList() {
  523. post(GET_USERLIST, {}).then(res => {
  524. if (res.code != 'ok') {
  525. globalPopup?.showError(res.msg)
  526. return
  527. }
  528. userList.value = res.data
  529. })
  530. }
  531. function dialogFromCli(type: string, data: any = {}, flag: boolean = false) {
  532. resetDialog()
  533. if (flag) {
  534. const { id } = data
  535. deptForm.parentId = id
  536. }
  537. dialogFrom[type] = true
  538. }
  539. function handleSizeChange(val: number) {
  540. teamForm.pageIndex = 1
  541. teamForm.pageSize = val
  542. getTableData()
  543. }
  544. function handleCurrentChange(val: number) {
  545. teamForm.pageIndex = val
  546. getTableData()
  547. }
  548. function resetDialog() {
  549. let newDeptForm = resetFromValue(deptForm)
  550. Object.assign(deptForm, newDeptForm)
  551. }
  552. function batchItem(text: string, type: batchOperationType, data: any) {
  553. allText.batchText = text,
  554. visibleType.value = type
  555. visibleData.value = data
  556. dialogFrom.batchOperationVisible = true
  557. }
  558. function handleClose(done: any) {
  559. done()
  560. }
  561. function transitionOperation(type: string, data: any) {
  562. if (type == 'disable') { // 停用
  563. resignationDate.value = formatDate(new Date())
  564. console.log(resignationDate.value, '<==== 离职')
  565. dialogFrom.resignationVisible = true
  566. } else if (type == 'exportUser') { // 导出
  567. exportRadio.value = '1'
  568. dialogFrom.exportUserVisible = true
  569. } else if (type == 'importUser') { // 导入
  570. dialogFrom.importVisible = true
  571. }
  572. transitiondata.value = data
  573. }
  574. function closeModal(modelType: string, flag: boolean = false) {
  575. dialogFrom[modelType] = false
  576. if (flag) {
  577. changeBatch(false)
  578. getTableData()
  579. }
  580. }
  581. onBeforeMount(() => {
  582. pagePermission.value = getFunctionList(MOD)
  583. })
  584. onMounted(() => {
  585. getRoleList()
  586. getUserList()
  587. getTableData()
  588. getDeptList()
  589. });
  590. </script>
  591. <style lang="scss" scoped>
  592. .teamstyle {
  593. .team-header {
  594. padding: 0.75rem 1.25rem;
  595. box-sizing: border-box
  596. }
  597. .textFont {
  598. font-size: 20px;
  599. }
  600. .textSpan {
  601. color: $fontGray;
  602. }
  603. }
  604. .const-left {
  605. padding: 0.75rem 0;
  606. .treeContent {
  607. width: 87%;
  608. .custom-tree-node {
  609. display: flex;
  610. align-items: center;
  611. justify-content: space-between;
  612. width: 100%;
  613. }
  614. .treeLabel {
  615. width: 80%;
  616. white-space: nowrap;
  617. overflow: hidden;
  618. text-overflow: ellipsis;
  619. }
  620. .treeIcon {
  621. display: flex;
  622. align-items: center;
  623. justify-self: flex-end;
  624. }
  625. }
  626. }
  627. .operation {
  628. cursor: pointer;
  629. }
  630. </style>