PersonalInfo.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div class="person-info-title"> 人员信息 </div>
  3. <el-button type="primary" @click="showPositionSetting"> 职位设置 </el-button>
  4. <el-button type="primary" @click="showAddPerson"> 添加人员 </el-button>
  5. <div class="person-info-table">
  6. <el-table :data="tableData" border max-height="700">
  7. <el-table-column prop="date" label="序号">
  8. <template #default="scope">
  9. {{ scope.$index + 1 }}
  10. </template>
  11. </el-table-column>
  12. <el-table-column prop="title" label="岗位职责" />
  13. <el-table-column prop="realname" label="姓名" />
  14. <el-table-column prop="staffNo" label="员工号" />
  15. <el-table-column prop="mobile" label="联系方式" />
  16. <el-table-column prop="department" label="部门" />
  17. <el-table-column prop="jobTitle" label="职务" />
  18. <el-table-column fixed="right" label="操作">
  19. <template #default="scope">
  20. <el-button class="edit-btn" link type="primary" size="small" @click.prevent="editRow(scope.row)">
  21. 编辑
  22. </el-button>
  23. <el-button class="edit-btn" link type="primary" size="small" @click.prevent="deleteRow(scope.row)">
  24. 删除
  25. </el-button>
  26. </template>
  27. </el-table-column>
  28. </el-table>
  29. </div>
  30. <PositionSetting ref="positionSettingRef" />
  31. <AddPerson ref="addPersonRef" :position-options="positionOptions" />
  32. <EditPerson ref="editPersonRef" :position-options="positionOptions" :person-info="editPersonInfo" />
  33. </template>
  34. <script lang="ts" setup>
  35. import { ref, watch } from 'vue';
  36. import { ElMessageBox, ElMessage } from 'element-plus';
  37. import { storeToRefs } from 'pinia';
  38. import { TeamPersonnelInfoType } from '../../type';
  39. import PositionSetting from './PositionSetting.vue';
  40. import useTeamStore from '../../store/userTeam';
  41. import AddPerson from './AddPerson.vue';
  42. import EditPerson from './EditPerson.vue';
  43. import { PositionType, queryTeamPositionList, deleteTeamPersonnel } from '@/api/emergency-organization/teams';
  44. const { teamAndPersonInfo, loadingTeamInfo } = storeToRefs(useTeamStore());
  45. const { refreshCurTeamInfo } = useTeamStore();
  46. const tableData = ref<TeamPersonnelInfoType[]>([]);
  47. const positionSettingRef = ref<InstanceType<typeof PositionSetting>>();
  48. const addPersonRef = ref<InstanceType<typeof AddPerson>>();
  49. const editPersonRef = ref<InstanceType<typeof EditPerson>>();
  50. const positionOptions = ref<PositionType[]>([]);
  51. const editPersonInfo = ref({
  52. id: 0,
  53. userId: 0,
  54. positionId: '',
  55. realname: '',
  56. staffNo: '',
  57. mobile: '',
  58. department: '',
  59. jobTitle: '',
  60. });
  61. async function editRow(row) {
  62. if (!(await positionIsSet())) return;
  63. editPersonInfo.value = {
  64. id: row.id,
  65. userId: row.userId,
  66. positionId: row.positionId,
  67. realname: row.realname,
  68. staffNo: row.staffNo,
  69. mobile: row.mobile,
  70. department: row.department,
  71. jobTitle: row.jobTitle,
  72. };
  73. editPersonRef.value?.dialogShow();
  74. }
  75. function deleteRow(row) {
  76. ElMessageBox.confirm('是否确认删除该人员').then(async () => {
  77. loadingTeamInfo.value = true;
  78. await deleteTeamPersonnel(row.id);
  79. await refreshCurTeamInfo();
  80. loadingTeamInfo.value = false;
  81. });
  82. }
  83. function showPositionSetting() {
  84. positionSettingRef.value?.dialogShow();
  85. }
  86. async function showAddPerson() {
  87. if (!(await positionIsSet())) return;
  88. addPersonRef.value?.dialogShow();
  89. }
  90. async function positionIsSet() {
  91. loadingTeamInfo.value = true;
  92. positionOptions.value = await queryTeamPositionList(teamAndPersonInfo.value!.teamId);
  93. loadingTeamInfo.value = false;
  94. if (positionOptions.value.length === 0) {
  95. ElMessage({
  96. message: '请先设置职位',
  97. type: 'warning',
  98. });
  99. return false;
  100. }
  101. return true;
  102. }
  103. watch(
  104. () => teamAndPersonInfo.value,
  105. () => {
  106. tableData.value = teamAndPersonInfo.value?.personnelList || [];
  107. },
  108. );
  109. </script>
  110. <style scoped lang="scss">
  111. .person-info-title {
  112. margin-bottom: 16px;
  113. }
  114. .person-info-table {
  115. margin-top: 15px;
  116. .edit-btn {
  117. font-size: 14px;
  118. }
  119. }
  120. </style>