employees.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. <div class="employees-container">
  2. <div class="page-header">
  3. <div>
  4. <h1>员工管理</h1>
  5. <p class="subtitle">根据身份管理企业员工 (数据从企业微信同步)</p>
  6. </div>
  7. <button class="btn btn-secondary" (click)="exportEmployees()">导出</button>
  8. </div>
  9. <!-- 统计卡片 - 按身份统计 -->
  10. <div class="stats-cards">
  11. <div class="stat-card" (click)="setRoleFilter('all')" [class.active]="roleFilter() === 'all'">
  12. <div class="stat-value">{{ stats.total() }}</div>
  13. <div class="stat-label">全部员工</div>
  14. </div>
  15. <div class="stat-card" (click)="setRoleFilter('客服')" [class.active]="roleFilter() === '客服'">
  16. <div class="stat-value">{{ stats.service() }}</div>
  17. <div class="stat-label">客服</div>
  18. </div>
  19. <div class="stat-card" (click)="setRoleFilter('组员')" [class.active]="roleFilter() === '组员'">
  20. <div class="stat-value">{{ stats.designer() }}</div>
  21. <div class="stat-label">设计师(组员)</div>
  22. </div>
  23. <div class="stat-card" (click)="setRoleFilter('组长')" [class.active]="roleFilter() === '组长'">
  24. <div class="stat-value">{{ stats.leader() }}</div>
  25. <div class="stat-label">组长</div>
  26. </div>
  27. <div class="stat-card" (click)="setRoleFilter('人事')" [class.active]="roleFilter() === '人事'">
  28. <div class="stat-value">{{ stats.hr() }}</div>
  29. <div class="stat-label">人事</div>
  30. </div>
  31. <div class="stat-card" (click)="setRoleFilter('财务')" [class.active]="roleFilter() === '财务'">
  32. <div class="stat-value">{{ stats.finance() }}</div>
  33. <div class="stat-label">财务</div>
  34. </div>
  35. </div>
  36. <!-- 筛选栏 -->
  37. <div class="filter-bar">
  38. <input
  39. type="text"
  40. class="search-input"
  41. placeholder="搜索姓名、手机号或企微ID..."
  42. [ngModel]="keyword()"
  43. (ngModelChange)="keyword.set($event)"
  44. />
  45. <button class="btn btn-text" (click)="resetFilters()">重置</button>
  46. </div>
  47. <!-- 数据表格 -->
  48. <div *ngIf="loading()" class="loading-state">加载中...</div>
  49. <div *ngIf="!loading()" class="data-table">
  50. <table>
  51. <thead>
  52. <tr>
  53. <th>姓名</th>
  54. <th>手机号</th>
  55. <th>企微ID</th>
  56. <th>身份</th>
  57. <th>部门</th>
  58. <th>状态</th>
  59. <th width="120">操作</th>
  60. </tr>
  61. </thead>
  62. <tbody>
  63. <tr *ngFor="let emp of filtered" [class.disabled]="emp.isDisabled">
  64. <td>
  65. <div style="display:flex;align-items:center;gap:8px;">
  66. <img [src]="emp.avatar || '/assets/images/default-avatar.svg'" alt="" style="width:32px;height:32px;border-radius:50%;object-fit:cover;"/>
  67. <div>
  68. <div style="font-weight:600;">
  69. {{ emp.realname || emp.name }}
  70. <span style="font-size:12px;color:#999;font-weight:400;" *ngIf="emp.realname && emp.name">
  71. ({{ emp.name }})
  72. </span>
  73. </div>
  74. <div style="font-size:12px;color:#888;" *ngIf="emp.position">{{ emp.position }}</div>
  75. </div>
  76. </div>
  77. </td>
  78. <td>{{ emp.mobile }}</td>
  79. <td>{{ emp.userid }}</td>
  80. <td><span class="badge">{{ emp.roleName }}</span></td>
  81. <td>
  82. @if(emp.roleName=="客服"){
  83. 客服部
  84. } @else if(emp.roleName=="管理员") {
  85. 总部
  86. } @else {
  87. {{ emp.department }}
  88. }
  89. </td>
  90. <td><span [class]="'status ' + (emp.isDisabled ? 'disabled' : 'active')">{{ emp.isDisabled ? '已禁用' : '正常' }}</span></td>
  91. <td>
  92. <button class="btn-icon" (click)="viewEmployee(emp)" title="查看">👁</button>
  93. <button class="btn-icon" (click)="editEmployee(emp)" title="编辑">✏️</button>
  94. <button class="btn-icon" (click)="toggleEmployee(emp)" [title]="emp.isDisabled ? '启用' : '禁用'">
  95. {{ emp.isDisabled ? '✓' : '🚫' }}
  96. </button>
  97. </td>
  98. </tr>
  99. <tr *ngIf="filtered.length === 0">
  100. <td colspan="7" class="empty-state">暂无数据</td>
  101. </tr>
  102. </tbody>
  103. </table>
  104. </div>
  105. <!-- 侧边面板 -->
  106. <div class="side-panel" [class.open]="showPanel">
  107. <div class="panel-overlay" (click)="closePanel()"></div>
  108. <div class="panel-content">
  109. <div class="panel-header">
  110. <h2>{{ panelMode === 'edit' ? '编辑员工' : '员工详情' }}</h2>
  111. <button class="btn-close" (click)="closePanel()">×</button>
  112. </div>
  113. <div class="panel-body" *ngIf="currentEmployee">
  114. <div *ngIf="panelMode === 'detail'" class="detail-view">
  115. <!-- 员工头像与基本信息 -->
  116. <div class="detail-header">
  117. <div class="detail-avatar-section">
  118. <img [src]="currentEmployee.avatar || '/assets/images/default-avatar.svg'" class="detail-avatar" alt="员工头像"/>
  119. <div class="detail-badge-container">
  120. <span class="detail-role-badge">{{ currentEmployee.roleName }}</span>
  121. <span [class]="'detail-status-badge ' + (currentEmployee.isDisabled ? 'disabled' : 'active')">
  122. {{ currentEmployee.isDisabled ? '已禁用' : '在职' }}
  123. </span>
  124. </div>
  125. </div>
  126. <div class="detail-info-section">
  127. <div class="detail-name-block">
  128. <h3 class="detail-realname">{{ currentEmployee.realname || currentEmployee.name }}</h3>
  129. <span class="detail-nickname" *ngIf="currentEmployee.realname && currentEmployee.name">昵称: {{ currentEmployee.name }}</span>
  130. </div>
  131. <div class="detail-position" *ngIf="currentEmployee.position">
  132. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  133. <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
  134. <line x1="9" y1="9" x2="15" y2="9"></line>
  135. </svg>
  136. {{ currentEmployee.position }}
  137. </div>
  138. <div class="detail-meta">
  139. <div class="detail-meta-item" *ngIf="currentEmployee.gender">
  140. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  141. <circle cx="12" cy="12" r="10"></circle>
  142. </svg>
  143. {{ currentEmployee.gender === '1' ? '男' : currentEmployee.gender === '2' ? '女' : currentEmployee.gender }}
  144. </div>
  145. <div class="detail-meta-item" *ngIf="currentEmployee.joinDate">
  146. <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  147. <rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect>
  148. <line x1="16" y1="2" x2="16" y2="6"></line>
  149. <line x1="8" y1="2" x2="8" y2="6"></line>
  150. <line x1="3" y1="10" x2="21" y2="10"></line>
  151. </svg>
  152. 入职 {{ currentEmployee.joinDate }}
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. <!-- 联系方式 -->
  158. <div class="detail-section">
  159. <div class="detail-section-title">
  160. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  161. <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"></path>
  162. </svg>
  163. 联系方式
  164. </div>
  165. <div class="detail-grid">
  166. <div class="detail-item">
  167. <label>手机号</label>
  168. <div class="detail-value">{{ currentEmployee.mobile || '-' }}</div>
  169. </div>
  170. <div class="detail-item">
  171. <label>邮箱</label>
  172. <div class="detail-value">{{ currentEmployee.email || '-' }}</div>
  173. </div>
  174. <div class="detail-item">
  175. <label>企微ID</label>
  176. <div class="detail-value">{{ currentEmployee.userid || '-' }}</div>
  177. </div>
  178. </div>
  179. </div>
  180. <!-- 组织信息 -->
  181. <div class="detail-section">
  182. <div class="detail-section-title">
  183. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  184. <path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"></path>
  185. <circle cx="9" cy="7" r="4"></circle>
  186. <path d="M23 21v-2a4 4 0 0 0-3-3.87"></path>
  187. <path d="M16 3.13a4 4 0 0 1 0 7.75"></path>
  188. </svg>
  189. 组织信息
  190. </div>
  191. <div class="detail-grid">
  192. <div class="detail-item">
  193. <label>身份</label>
  194. <div class="detail-value">
  195. <span class="badge">{{ currentEmployee.roleName }}</span>
  196. </div>
  197. </div>
  198. <div class="detail-item">
  199. <label>部门</label>
  200. <div class="detail-value">
  201. @if(currentEmployee.roleName=="客服") {
  202. 客服部
  203. } @else if(currentEmployee.roleName=="管理员") {
  204. 总部
  205. } @else {
  206. {{ currentEmployee.department }}
  207. }
  208. </div>
  209. </div>
  210. <div class="detail-item" *ngIf="currentEmployee.level">
  211. <label>职级</label>
  212. <div class="detail-value">{{ currentEmployee.level }}</div>
  213. </div>
  214. </div>
  215. </div>
  216. <div class="skills" *ngIf="currentEmployee.skills?.length">
  217. <label>技能</label>
  218. <div class="tags">
  219. <span class="tag" *ngFor="let s of currentEmployee.skills">{{ s }}</span>
  220. </div>
  221. </div>
  222. <div class="workload" *ngIf="currentEmployee.workload">
  223. <label>工作量</label>
  224. <div class="grid">
  225. <div class="detail-item"><label>当前项目</label><div>{{ currentEmployee.workload?.currentProjects || 0 }}</div></div>
  226. <div class="detail-item"><label>已完成</label><div>{{ currentEmployee.workload?.completedProjects || 0 }}</div></div>
  227. <div class="detail-item"><label>平均质量</label><div>{{ currentEmployee.workload?.averageQuality || 0 }}</div></div>
  228. </div>
  229. </div>
  230. </div>
  231. <div *ngIf="panelMode === 'edit'" class="form-view">
  232. <!-- 员工头像 -->
  233. <div class="form-avatar-section">
  234. <img [src]="currentEmployee.avatar || '/assets/images/default-avatar.svg'" class="form-avatar" alt="员工头像"/>
  235. <div class="form-avatar-info">
  236. <div class="form-avatar-name">{{ currentEmployee.name }}</div>
  237. <div class="form-avatar-id">ID: {{ currentEmployee.userid || '-' }}</div>
  238. </div>
  239. </div>
  240. <!-- 基本信息 -->
  241. <div class="form-section">
  242. <div class="form-section-title">
  243. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  244. <path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
  245. <circle cx="12" cy="7" r="4"></circle>
  246. </svg>
  247. 基本信息
  248. </div>
  249. <div class="form-group">
  250. <label class="form-label required">真实姓名</label>
  251. <input
  252. type="text"
  253. class="form-input"
  254. [(ngModel)]="formModel.realname"
  255. placeholder="请输入真实姓名(用于正式场合)"
  256. required
  257. />
  258. <div class="form-hint">用于正式文档、合同签署等场合</div>
  259. </div>
  260. <div class="form-group">
  261. <label class="form-label required">昵称</label>
  262. <input
  263. type="text"
  264. class="form-input"
  265. [(ngModel)]="formModel.name"
  266. placeholder="请输入昵称(内部沟通用)"
  267. required
  268. />
  269. <div class="form-hint">用于日常沟通,可以是昵称、花名等</div>
  270. </div>
  271. <div class="form-group">
  272. <label class="form-label required">手机号</label>
  273. <input
  274. type="tel"
  275. class="form-input"
  276. [(ngModel)]="formModel.mobile"
  277. placeholder="请输入手机号"
  278. maxlength="11"
  279. required
  280. />
  281. </div>
  282. <div class="form-group">
  283. <label class="form-label required">企微ID</label>
  284. <input
  285. type="text"
  286. class="form-input"
  287. [(ngModel)]="formModel.userid"
  288. placeholder="企业微信用户ID"
  289. readonly
  290. disabled
  291. />
  292. <div class="form-hint">企微ID由系统同步,不可修改</div>
  293. </div>
  294. </div>
  295. <!-- 职位信息 -->
  296. <div class="form-section">
  297. <div class="form-section-title">
  298. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  299. <rect x="3" y="3" width="18" height="18" rx="2" ry="2"></rect>
  300. <line x1="9" y1="9" x2="15" y2="9"></line>
  301. </svg>
  302. 职位信息
  303. </div>
  304. <div class="form-group">
  305. <label class="form-label required">身份</label>
  306. <select class="form-select" [(ngModel)]="formModel.roleName" required>
  307. <option value="">请选择身份</option>
  308. <option *ngFor="let role of roles" [value]="role">{{ role }}</option>
  309. </select>
  310. </div>
  311. <div class="form-group">
  312. <label class="form-label required">部门</label>
  313. <select class="form-select" [(ngModel)]="formModel.departmentId">
  314. <option [value]="undefined">未分配</option>
  315. <option *ngFor="let dept of departments()" [value]="dept.id">{{ dept.name }}</option>
  316. </select>
  317. <div class="form-hint">客服和管理员无需分配项目组</div>
  318. </div>
  319. </div>
  320. <!-- 状态管理 -->
  321. <div class="form-section">
  322. <div class="form-section-title">
  323. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  324. <path d="M12 2a10 10 0 1 0 0 20 10 10 0 1 0 0-20z"></path>
  325. <path d="M12 6v6l4 2"></path>
  326. </svg>
  327. 状态管理
  328. </div>
  329. <div class="form-group">
  330. <label class="form-label">员工状态</label>
  331. <div class="status-toggle">
  332. <label class="status-option" [class.active]="!formModel.isDisabled">
  333. <input
  334. type="radio"
  335. name="status"
  336. [value]="false"
  337. [(ngModel)]="formModel.isDisabled"
  338. />
  339. <span class="status-dot active"></span>
  340. <span>正常</span>
  341. </label>
  342. <label class="status-option" [class.active]="formModel.isDisabled">
  343. <input
  344. type="radio"
  345. name="status"
  346. [value]="true"
  347. [(ngModel)]="formModel.isDisabled"
  348. />
  349. <span class="status-dot disabled"></span>
  350. <span>已禁用</span>
  351. </label>
  352. </div>
  353. <div class="form-hint">禁用后该员工将无法登录系统</div>
  354. </div>
  355. </div>
  356. <!-- 提示信息 -->
  357. <div class="form-notice">
  358. <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
  359. <circle cx="12" cy="12" r="10"></circle>
  360. <line x1="12" y1="16" x2="12" y2="12"></line>
  361. <line x1="12" y1="8" x2="12.01" y2="8"></line>
  362. </svg>
  363. <div>
  364. <div class="form-notice-title">修改说明</div>
  365. <div class="form-notice-text">员工数据主要从企业微信同步,姓名和手机号可以在此修改,修改后将保存到后端数据库。</div>
  366. </div>
  367. </div>
  368. </div>
  369. </div>
  370. <div class="panel-footer" *ngIf="panelMode === 'edit'">
  371. <button class="btn btn-default" (click)="closePanel()">取消</button>
  372. <button class="btn btn-primary" (click)="updateEmployee()">更新</button>
  373. </div>
  374. </div>
  375. </div>
  376. </div>