staffPlatManager.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 平台员工管理
  6. </h2>
  7. <div class="m-core">
  8. <save-form
  9. :inline="true"
  10. class="searchForm"
  11. ref="searchForm"
  12. @submit="search"
  13. @reset="reset"
  14. :model="searchForm"
  15. >
  16. <el-form-item prop="search">
  17. <el-input
  18. type="text"
  19. clearable
  20. v-model.trim="searchForm.search"
  21. @keyup.enter.native="search"
  22. placeholder="姓名、编号、手机号"
  23. ></el-input>
  24. </el-form-item>
  25. <el-form-item prop="jobNature">
  26. <el-select
  27. v-model.trim="searchForm.jobNature"
  28. clearable
  29. filterable
  30. placeholder="请选择工作类型"
  31. >
  32. <el-option label="全职" value="FULL_TIME"></el-option>
  33. <el-option label="兼职" value="PART_TIME"></el-option>
  34. <!-- <el-option label="临时"
  35. value="TEMPORARY"></el-option> -->
  36. </el-select>
  37. </el-form-item>
  38. <!-- <el-form-item prop="organId">
  39. <el-select
  40. v-model.trim="searchForm.organId"
  41. clearable
  42. filterable
  43. placeholder="请选择分部"
  44. >
  45. <el-option
  46. v-for="item in selects.branchs"
  47. :key="item.id"
  48. :label="item.name"
  49. :value="item.id"
  50. ></el-option>
  51. </el-select>
  52. </el-form-item> -->
  53. <el-form-item prop="roleId">
  54. <!-- multiple -->
  55. <el-select
  56. v-model.trim="searchForm.roleId"
  57. clearable
  58. filterable
  59. placeholder="请选择角色"
  60. >
  61. <el-option
  62. v-for="item in roleList"
  63. :key="item.value"
  64. :label="item.label"
  65. :value="item.value"
  66. ></el-option>
  67. </el-select>
  68. <!-- collapse-tags -->
  69. </el-form-item>
  70. <el-form-item>
  71. <el-button native-type="submit" type="danger">搜索</el-button>
  72. <el-button native-type="reset" type="primary">重置</el-button>
  73. </el-form-item>
  74. </save-form>
  75. <el-button
  76. type="primary"
  77. style="margin-bottom: 20px"
  78. @click="roleOperation('create')"
  79. v-permission="'employee/add'"
  80. >添加</el-button
  81. >
  82. <!-- 列表 -->
  83. <div class="tableWrap">
  84. <el-table
  85. :data="tableList"
  86. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  87. >
  88. <el-table-column align="center" prop="id" label="员工编号">
  89. <template slot-scope="scope">
  90. <copy-text>{{ scope.row.id }}</copy-text>
  91. </template>
  92. </el-table-column>
  93. <el-table-column align="center" prop="realName" label="姓名">
  94. <template slot-scope="scope">
  95. <copy-text>{{ scope.row.realName }}</copy-text>
  96. </template>
  97. </el-table-column>
  98. <el-table-column align="center" prop="phone" label="手机号">
  99. <template slot-scope="scope">
  100. <copy-text>{{ scope.row.phone }}</copy-text>
  101. </template>
  102. </el-table-column>
  103. <el-table-column align="center" label="角色分类">
  104. <template slot-scope="scope">
  105. <tooltip
  106. :content="scope.row.roleNames | joinArray(',')"
  107. ></tooltip>
  108. </template>
  109. </el-table-column>
  110. <el-table-column align="center" prop="jobNature" label="工作类型">
  111. <template slot-scope="scope">
  112. {{ scope.row.jobNature | jobNature }}
  113. </template>
  114. </el-table-column>
  115. <!-- <el-table-column align="center" label="所属分部">
  116. <template slot-scope="scope">
  117. <tooltip
  118. :content="scope.row.organNameList | joinArray(',')"
  119. ></tooltip>
  120. </template>
  121. </el-table-column> -->
  122. <el-table-column
  123. align="center"
  124. label="状态"
  125. :formatter="formatLockFlag"
  126. >
  127. </el-table-column>
  128. <el-table-column align="center" label="入职时间">
  129. <template slot-scope="scope">
  130. {{ scope.row.entryDate | formatTimer }}
  131. </template>
  132. </el-table-column>
  133. <el-table-column align="center" label="离职时间">
  134. <template slot-scope="scope">
  135. {{ scope.row.demissionDate | formatTimer }}
  136. </template>
  137. </el-table-column>
  138. <el-table-column
  139. align="center"
  140. width="250px"
  141. fixed="right"
  142. label="操作"
  143. >
  144. <template slot-scope="scope">
  145. <el-button
  146. @click="roleOperation('update', scope.row)"
  147. v-if="permission('employee/update')"
  148. type="text"
  149. >修改</el-button
  150. >
  151. <el-button
  152. @click="onStaffOperation('RESET_PASSWORD', scope.row)"
  153. v-if="permission('employee/employeeOperate/RESET_PASSWORD')"
  154. type="text"
  155. >重置密码</el-button
  156. >
  157. <el-button
  158. @click="onStaffOperation('LOCK_UNLOCK', scope.row)"
  159. v-if="
  160. permission(
  161. scope.row.lockFlag == 1
  162. ? 'employee/employeeOperate/unlock'
  163. : 'employee/employeeOperate/lock'
  164. )
  165. "
  166. type="text"
  167. >{{ scope.row.lockFlag == 1 ? "解冻" : "冻结" }}</el-button
  168. >
  169. <el-button
  170. @click="onStaffOperation('REINSTATE', scope.row)"
  171. v-if="
  172. scope.row.demissionDate &&
  173. permission('employee/employeeOperate/REINSTATE')
  174. "
  175. type="text"
  176. >复职</el-button
  177. >
  178. <el-button
  179. @click="handover(scope.row)"
  180. v-if="
  181. !scope.row.demissionDate &&
  182. permission('employee/level') &&
  183. permission('employee/levelDetail')
  184. "
  185. type="text"
  186. >离职</el-button
  187. >
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. <pagination
  192. sync
  193. :total.sync="pageInfo.total"
  194. :page.sync="pageInfo.page"
  195. :limit.sync="pageInfo.limit"
  196. :page-sizes="pageInfo.page_size"
  197. @pagination="getList"
  198. />
  199. </div>
  200. </div>
  201. <el-dialog
  202. :title="formTitle[formActionTitle]"
  203. :visible.sync="roleStatus"
  204. @close="onFormClose('ruleForm')"
  205. width="650px"
  206. >
  207. <el-form :model="form" :rules="rules" ref="ruleForm">
  208. <el-alert
  209. style="margin: 10px 0"
  210. title="基础信息"
  211. :closable="false"
  212. type="info"
  213. >
  214. </el-alert>
  215. <el-row>
  216. <el-col :span="12">
  217. <el-form-item
  218. label="姓名"
  219. prop="realName"
  220. :label-width="formLabelWidth"
  221. >
  222. <el-input
  223. v-model.trim="form.realName"
  224. placeholder="请输入姓名"
  225. autocomplete="off"
  226. ></el-input>
  227. </el-form-item>
  228. </el-col>
  229. <el-col :span="12">
  230. <el-form-item
  231. label="性别"
  232. prop="gender"
  233. :label-width="formLabelWidth"
  234. >
  235. <el-select
  236. v-model.trim="form.gender"
  237. placeholder="请选择性别"
  238. clearable
  239. filterable
  240. >
  241. <el-option label="男" :value="1"></el-option>
  242. <el-option label="女" :value="0"></el-option>
  243. </el-select>
  244. </el-form-item>
  245. </el-col>
  246. </el-row>
  247. <el-row>
  248. <el-col :span="12">
  249. <el-form-item
  250. label="手机号"
  251. prop="phone"
  252. :label-width="formLabelWidth"
  253. >
  254. <el-input
  255. v-model.trim.number="form.phone"
  256. placeholder="请输入手机号"
  257. autocomplete="off"
  258. ></el-input>
  259. </el-form-item>
  260. </el-col>
  261. <el-col :span="12">
  262. <el-form-item
  263. label="工作类型"
  264. prop="jobNature"
  265. :label-width="formLabelWidth"
  266. >
  267. <el-select
  268. v-model.trim="form.jobNature"
  269. clearable
  270. placeholder="请选择工作类型"
  271. filterable
  272. >
  273. <el-option label="全职" value="FULL_TIME"></el-option>
  274. <el-option label="兼职" value="PART_TIME"></el-option>
  275. <!-- <el-option label="临时"
  276. value="TEMPORARY"></el-option> -->
  277. </el-select>
  278. </el-form-item>
  279. </el-col>
  280. </el-row>
  281. <el-row>
  282. <el-col :span="12">
  283. <el-form-item
  284. label="入职时间"
  285. prop="entryDate"
  286. :label-width="formLabelWidth"
  287. >
  288. <el-date-picker
  289. v-model.trim="form.entryDate"
  290. type="date"
  291. :picker-options="{
  292. firstDayOfWeek: 1,
  293. }"
  294. value-format="yyyy-MM-dd HH:mm:ss"
  295. placeholder="选择入职日期"
  296. >
  297. </el-date-picker>
  298. </el-form-item>
  299. </el-col>
  300. <el-col :span="12">
  301. <el-form-item
  302. label="邮政编码"
  303. prop="postalCode"
  304. :label-width="formLabelWidth"
  305. >
  306. <el-input
  307. v-model.trim="form.postalCode"
  308. placeholder="请输入邮政编码"
  309. autocomplete="off"
  310. ></el-input>
  311. </el-form-item>
  312. </el-col>
  313. </el-row>
  314. <el-row>
  315. <el-form-item
  316. label="通讯地址"
  317. prop="contactAddress"
  318. :label-width="formLabelWidth"
  319. >
  320. <el-input
  321. v-model.trim="form.contactAddress"
  322. placeholder="请输入通讯地址"
  323. autocomplete="off"
  324. ></el-input>
  325. </el-form-item>
  326. </el-row>
  327. <el-alert
  328. style="margin: 10px 0"
  329. title="角色权限"
  330. :closable="false"
  331. type="info"
  332. >
  333. </el-alert>
  334. <!-- <el-row>
  335. <el-col :span="24">
  336. <el-form-item
  337. label="所属分部"
  338. prop="organIdLists"
  339. :label-width="formLabelWidth"
  340. >
  341. <select-all
  342. filterable
  343. clearable
  344. placeholder="请选择所属分部"
  345. collapse-tags
  346. v-model.trim="form.organIdLists"
  347. multiple
  348. >
  349. <el-option
  350. v-for="item in organList"
  351. :key="item.id"
  352. :label="item.name"
  353. :value="item.id"
  354. ></el-option>
  355. </select-all>
  356. </el-form-item>
  357. </el-col>
  358. </el-row> -->
  359. <el-row>
  360. <el-col :span="24">
  361. <el-form-item
  362. label="员工角色"
  363. prop="roleIds"
  364. :label-width="formLabelWidth"
  365. >
  366. <select-all
  367. v-model.trim="form.roleIds"
  368. placeholder="请选择员工角色"
  369. clearable
  370. filterable
  371. collapse-tags
  372. multiple
  373. >
  374. <el-option
  375. v-for="item in roleList"
  376. :key="item.value"
  377. :label="item.label"
  378. :value="item.value"
  379. ></el-option>
  380. </select-all>
  381. </el-form-item>
  382. </el-col>
  383. </el-row>
  384. <!-- <el-alert
  385. style="margin: 10px 0"
  386. title="OA信息"
  387. :closable="false"
  388. type="info"
  389. >
  390. </el-alert> -->
  391. <!-- <el-row>
  392. <el-col :span="12">
  393. <el-form-item
  394. label="所属部门"
  395. prop="deptIds"
  396. :label-width="formLabelWidth"
  397. >
  398. <el-cascader
  399. v-model="form.deptIds"
  400. placeholder="请选择所属部门"
  401. clearable
  402. style="width: 100%"
  403. :options="deptList"
  404. :show-all-levels="false"
  405. :collapse-tags="true"
  406. @change="onDeptChange"
  407. :props="{ multiple: true, checkStrictly: false }"
  408. ></el-cascader>
  409. </el-form-item>
  410. </el-col>
  411. <el-col :span="12">
  412. <el-form-item
  413. label="社保分部"
  414. prop="deptId"
  415. :label-width="formLabelWidth"
  416. >
  417. <el-cascader
  418. v-model="form.deptId"
  419. placeholder="请选择社保分部"
  420. clearable
  421. style="width: 100%"
  422. :options="deptSmallList"
  423. :show-all-levels="false"
  424. :collapse-tags="true"
  425. :props="{ checkStrictly: false }"
  426. ></el-cascader>
  427. </el-form-item>
  428. </el-col>
  429. </el-row> -->
  430. <!-- <div v-for="(postDeptIds, index) in form.postDeptIds" :key="index">
  431. <el-form-item
  432. :label="'岗位管理' + (index + 1)"
  433. :label-width="formLabelWidth"
  434. class="setWidth"
  435. :prop="'postDeptIds.' + index + '.postId'"
  436. >
  437. <el-select
  438. filterable
  439. clearable
  440. placeholder="所属岗位"
  441. style="width: 180px !important"
  442. v-model.trim="postDeptIds.postId"
  443. >
  444. <el-option
  445. v-for="item in postList"
  446. :key="item.value"
  447. :label="item.label"
  448. :value="item.value"
  449. ></el-option>
  450. </el-select>
  451. </el-form-item>
  452. <el-form-item
  453. class="setWidth"
  454. style="margin: 0 10px; width: 190px !important"
  455. :prop="'postDeptIds.' + index + '.deptIds'"
  456. >
  457. <el-cascader
  458. v-model="postDeptIds.deptIds"
  459. placeholder="管理部门"
  460. clearable
  461. :options="deptList"
  462. :show-all-levels="false"
  463. :collapse-tags="true"
  464. :props="{ multiple: true, checkStrictly: false }"
  465. ></el-cascader>
  466. </el-form-item>
  467. <el-button
  468. icon="el-icon-minus"
  469. circle
  470. v-if="form.postDeptIds.length > 1"
  471. @click.prevent="removePostDept(postDeptIds)"
  472. ></el-button>
  473. <el-button
  474. icon="el-icon-plus"
  475. @click.prevent="addPostDept"
  476. circle
  477. style="margin-left: 5px"
  478. ></el-button>
  479. </div> -->
  480. </el-form>
  481. <span slot="footer" class="dialog-footer">
  482. <el-button @click="roleStatus = false">取 消</el-button>
  483. <el-button @click="onRoleSubmit('ruleForm')" type="primary"
  484. >确 定</el-button
  485. >
  486. </span>
  487. </el-dialog>
  488. <el-dialog title="工作交接" :visible.sync="handoverVisible" width="500px">
  489. <handover
  490. v-if="handoverVisible"
  491. :detail="detail"
  492. @close="handoverVisible = false"
  493. @submited="getList"
  494. />
  495. </el-dialog>
  496. <el-dialog
  497. title="教务交接"
  498. width="400px"
  499. close-on-click-modal
  500. v-if="educationViseble"
  501. :visible.sync="educationViseble"
  502. >
  503. <el-form :model="educationForm" :inline="true" ref="educationForm">
  504. <el-form-item
  505. label="乐团主管"
  506. :rules="[
  507. {
  508. required: true,
  509. message: '请选择乐团主管',
  510. trigger: 'blur',
  511. },
  512. ]"
  513. >
  514. <el-select
  515. v-model.trim="educationForm.targetUserId"
  516. clearable
  517. filterable
  518. >
  519. <el-option
  520. v-for="item in educationList"
  521. :key="item.userId"
  522. :label="item.userName"
  523. :value="item.userId"
  524. ></el-option>
  525. </el-select>
  526. </el-form-item>
  527. </el-form>
  528. <span slot="footer" class="dialog-footer">
  529. <el-button @click="educationViseble = false">取 消</el-button>
  530. <el-button @click="submitEducation" type="primary">确 定</el-button>
  531. </span>
  532. </el-dialog>
  533. </div>
  534. </template>
  535. <script>
  536. import pagination from "@/components/Pagination/index";
  537. import { permission } from "@/utils/directivePage";
  538. import {
  539. getPlatEmploy,
  540. employeeOperate,
  541. getUserRole,
  542. employeeAdd,
  543. employeeUpdate,
  544. hasCourseGroupRelation,
  545. updateEducationTeacherId,
  546. queryEmployeeOrganByUser,
  547. getDepts,
  548. getPosts,
  549. } from "@/api/systemManage";
  550. // import { userRole } from "./api";
  551. import deepClone from "@/helpers/deep-clone";
  552. // import Treeselect from '@riophae/vue-treeselect'
  553. // import '@riophae/vue-treeselect/dist/vue-treeselect.css'
  554. import Tooltip from "@/components/Tooltip/index";
  555. import { isvalidPhone } from "@/utils/validate";
  556. import handover from "./modals/handover";
  557. let validPhone = (rule, value, callback) => {
  558. if (!value) {
  559. callback(new Error("请输入电话号码"));
  560. } else if (!isvalidPhone(value)) {
  561. callback(new Error("请输入正确的11位手机号码"));
  562. } else {
  563. callback();
  564. }
  565. };
  566. export default {
  567. name: "staffManager",
  568. components: { pagination, Tooltip, handover },
  569. data() {
  570. return {
  571. roleResetList: [],
  572. organList: [],
  573. tableList: [],
  574. educationList: [],
  575. deptList: [],
  576. deptSmallList: [],
  577. postList: [],
  578. educationForm: {
  579. targetUserId: "",
  580. },
  581. educationViseble: false,
  582. activeRow: null,
  583. pageInfo: {
  584. // 分页规则
  585. limit: 10, // 限制显示条数
  586. page: 1, // 当前页
  587. total: 0, // 总条数
  588. page_size: [10, 20, 40, 50], // 选择限制显示条数
  589. },
  590. detail: null,
  591. handoverVisible: false,
  592. roleStatus: false,
  593. formActionTitle: "create",
  594. roleList: [], // 角色列表,
  595. roleBaseList: [], // 登陆人角色
  596. formTitle: {
  597. create: "添加员工",
  598. update: "修改员工",
  599. },
  600. formLabelWidth: "100px",
  601. form: {
  602. realName: null,
  603. gender: null,
  604. phone: null,
  605. roleIds: [],
  606. deptId: null, // 社保分部
  607. // organIdLists: [],
  608. postDeptIds: [
  609. {
  610. postId: null,
  611. deptIds: [],
  612. },
  613. ],
  614. deptIds: [],
  615. // postIds: [],
  616. jobNature: null,
  617. entryDate: null,
  618. contactAddress: null,
  619. postalCode: null,
  620. },
  621. rules: {
  622. realName: [{ required: true, message: "请输入姓名", trigger: "blur" }],
  623. gender: [{ required: true, message: "请选择性别", trigger: "change" }],
  624. phone: [
  625. {
  626. type: "number",
  627. required: true,
  628. validator: validPhone,
  629. trigger: "blur",
  630. },
  631. {
  632. pattern: /^1[3456789]\d{9}$/,
  633. message: "请输入正确的手机号",
  634. trigger: "blur",
  635. },
  636. ],
  637. roleIds: [
  638. {
  639. type: "array",
  640. required: true,
  641. message: "请选择分类",
  642. trigger: "change",
  643. },
  644. ],
  645. // deptId: [{ required: true, message: '请选择社保分部', trigger: 'change' }],
  646. organIdLists: [
  647. {
  648. type: "array",
  649. required: true,
  650. message: "请选择所属分部",
  651. trigger: "change",
  652. },
  653. ],
  654. // deptIds: [{ type: 'array', required: true, message: '请选择所属部门', trigger: 'change' }],
  655. // postIds: [{ type: 'array', required: true, message: '请选择所属岗位', trigger: 'change' }],
  656. jobNature: [
  657. { required: true, message: "请选择工作类型", trigger: "change" },
  658. ],
  659. entryDate: [
  660. { required: true, message: "请选择入职时间", trigger: "blur" },
  661. ],
  662. },
  663. searchForm: {
  664. search: null,
  665. jobNature: null,
  666. organId: null,
  667. roleId: null,
  668. },
  669. };
  670. },
  671. mounted() {
  672. this.getList();
  673. this.getRoleList();
  674. },
  675. methods: {
  676. permission,
  677. handover(row) {
  678. this.detail = row;
  679. this.handoverVisible = true;
  680. },
  681. onBranchCheckAll() {
  682. this.form.organIdLists = [];
  683. this.organList.forEach((item) => {
  684. this.form.organIdLists.push(item.id);
  685. });
  686. },
  687. onRoleSubmit(formName) {
  688. this.$refs[formName].validate((valid) => {
  689. if (valid) {
  690. const { organIdLists, postDeptIds, deptIds, deptId, ...res } =
  691. this.form;
  692. let tempPost = [];
  693. postDeptIds.forEach((post) => {
  694. let tempIds = [];
  695. post.deptIds.forEach((item) => {
  696. tempIds.push(item[item.length - 1]);
  697. });
  698. tempPost.push({
  699. postId: post.postId,
  700. deptIds: tempIds,
  701. });
  702. });
  703. const tempDeptIds = [];
  704. deptIds.forEach((ds) => {
  705. tempDeptIds.push(ds[ds.length - 1]);
  706. });
  707. const tempDeptId = deptId ? deptId[deptId.length - 1] : "";
  708. let tempForm = {
  709. postDeptIds: JSON.stringify(tempPost),
  710. // organIdList: organIdLists.join(","),
  711. deptIds: tempDeptIds,
  712. deptId: tempDeptId,
  713. tenantId:-1,
  714. ...res,
  715. };
  716. if (this.formActionTitle == "create") {
  717. if (this.form.id) {
  718. // 判断有没有Id,如果有则删除
  719. delete this.form.id;
  720. }
  721. employeeAdd(tempForm).then((res) => {
  722. this.messageTips("添加", res);
  723. });
  724. } else if (this.formActionTitle == "update") {
  725. employeeUpdate(tempForm).then((res) => {
  726. this.messageTips("修改", res);
  727. });
  728. }
  729. } else {
  730. return;
  731. }
  732. });
  733. },
  734. messageTips(title, res) {
  735. if (res.code == 200) {
  736. this.$message.success(title + "成功");
  737. this.roleStatus = false;
  738. this.getList();
  739. } else {
  740. this.$message.error(res.msg);
  741. }
  742. },
  743. search() {
  744. this.pageInfo.page = 1;
  745. this.getList();
  746. },
  747. reset() {
  748. this.$refs.searchForm.resetFields();
  749. this.search();
  750. },
  751. getList() {
  752. let searchForm = this.searchForm;
  753. let params = {
  754. search: searchForm.search ? searchForm.search : null,
  755. jobNature: searchForm.jobNature ? searchForm.jobNature : null,
  756. organId: searchForm.organId ? searchForm.organId : null,
  757. roleId: searchForm.roleId ? searchForm.roleId : null,
  758. rows: this.pageInfo.limit,
  759. page: this.pageInfo.page,
  760. };
  761. getPlatEmploy(params).then((res) => {
  762. if (res.code == 200 && res.data) {
  763. this.tableList = res.data.rows;
  764. this.pageInfo.total = res.data.total;
  765. }
  766. });
  767. },
  768. /** 转换菜单数据结构 */
  769. normalizer(node) {
  770. let temp = [];
  771. if (node.children && node.children.length > 0) {
  772. node.children.forEach((item) => {
  773. let child = this.normalizer(item, status);
  774. let obj = {
  775. value: item.deptId,
  776. label: item.deptName,
  777. };
  778. if (child && child.length > 0) {
  779. obj.children = child;
  780. }
  781. temp.push(obj);
  782. });
  783. }
  784. return temp;
  785. },
  786. async getRoleList() {
  787. // 获取角色
  788. getUserRole({ delFlag: 0, rows: 9999,tenantId:-1 }).then((res) => {
  789. let result = res.data;
  790. if (res.code == 200 && result && result.rows.length > 0) {
  791. this.roleList = [];
  792. result.rows.forEach((item) => {
  793. this.roleList.push({
  794. label: item.roleName,
  795. value: item.id,
  796. disabled: false,
  797. });
  798. });
  799. }
  800. });
  801. // 获取可编辑角色
  802. // try {
  803. // const res = await userRole();
  804. // this.roleResetList = [];
  805. // res.data.forEach((item) => {
  806. // this.roleResetList.push({
  807. // label: item.roleName,
  808. // value: item.id,
  809. // disabled: false,
  810. // });
  811. // });
  812. // } catch (e) {
  813. // console.log(e);
  814. // }
  815. // getDepts({ rows: 9999 }).then((res) => {
  816. // if (res.code == 200 && res.data && res.data.length > 0) {
  817. // const depts = res.data || [];
  818. // const formatArr = [];
  819. // depts.forEach((dep) => {
  820. // formatArr.push({
  821. // value: dep.deptId,
  822. // label: dep.deptName,
  823. // children: this.normalizer(dep),
  824. // });
  825. // });
  826. // this.deptList = formatArr;
  827. // }
  828. // });
  829. // 岗位
  830. // getPosts({ rows: 9999 }).then((res) => {
  831. // if (res.code == 200 && res.data && res.data.length > 0) {
  832. // this.postList = [];
  833. // res.data.forEach((item) => {
  834. // this.postList.push({
  835. // label: item.postName,
  836. // value: item.postId,
  837. // });
  838. // });
  839. // }
  840. // });
  841. this.$store.dispatch("setBranchs");
  842. },
  843. onDeptChange(value) {
  844. this.form.deptId = null;
  845. this.deptSmallList = [];
  846. let selectList = value.flat(Infinity);
  847. selectList = [...new Set(selectList)];
  848. const depts = deepClone(this.deptList);
  849. const formatArr = [];
  850. depts.forEach((dep) => {
  851. formatArr.push({
  852. value: dep.value,
  853. label: dep.label,
  854. disabled: !selectList.includes(dep.value),
  855. children: this.normalizer2(dep, selectList),
  856. });
  857. });
  858. this.deptSmallList = formatArr;
  859. },
  860. /** 转换菜单数据结构 */
  861. normalizer2(node, selectList) {
  862. let temp = [];
  863. if (node.children && node.children.length > 0) {
  864. node.children.forEach((item) => {
  865. let child = this.normalizer2(item, selectList);
  866. let obj = {
  867. value: item.value,
  868. label: item.label,
  869. disabled: !selectList.includes(item.value),
  870. };
  871. if (child && child.length > 0) {
  872. obj.children = child;
  873. }
  874. temp.push(obj);
  875. });
  876. }
  877. return temp;
  878. },
  879. async roleOperation(type, data) {
  880. // 获取分部
  881. await queryEmployeeOrganByUser().then((res) => {
  882. if (res.code == 200) {
  883. this.organList = res.data;
  884. }
  885. });
  886. this.formActionTitle = type;
  887. this.roleStatus = true;
  888. // 格式化 可选角色
  889. // 修改的时候
  890. if (type == "update") {
  891. let roleIdList = [...data.roleIds];
  892. // this.roleBaseList.forEach((item) => {
  893. // if (roleIdList.indexOf(item.value) == -1) {
  894. // roleIdList.push(item.value);
  895. // }
  896. // });
  897. // this.roleResetList = [...this.roleList];
  898. // this.roleList.forEach((role) => {
  899. // if (roleIdList.indexOf(role.value) != -1) {
  900. // this.roleResetList.push(role);
  901. // }
  902. // });
  903. // 初始化数据
  904. let postDeptArr = [];
  905. const postDept = data.postDeptIds ? JSON.parse(data.postDeptIds) : [];
  906. if (postDept.length > 0) {
  907. postDept.forEach((dept) => {
  908. let deptIds = dept.deptIds || [];
  909. let deptArr = [];
  910. deptIds.forEach((ds) => {
  911. deptArr.push(this.formatParentId(ds, this.deptList));
  912. });
  913. postDeptArr.push({
  914. postId: dept.postId,
  915. deptIds: deptArr,
  916. });
  917. });
  918. } else {
  919. postDeptArr = [
  920. {
  921. postId: null,
  922. deptIds: [],
  923. },
  924. ];
  925. }
  926. const deptIds = data.deptIds ? eval(data.deptIds) : [];
  927. const tempDeptIds = [];
  928. if (deptIds.length > 0) {
  929. deptIds.forEach((ds) => {
  930. tempDeptIds.push(this.formatParentId(ds, this.deptList));
  931. });
  932. }
  933. this.onDeptChange(tempDeptIds);
  934. this.form = {
  935. id: data.id,
  936. realName: data.realName,
  937. gender: data.gender,
  938. phone: Number(data.phone),
  939. roleIds: data.roleIds,
  940. deptId: data.deptId
  941. ? this.formatParentId(data.deptId, this.deptList)
  942. : null,
  943. organIdLists: data.organIdList ? data.organIdList : [],
  944. jobNature: data.jobNature,
  945. entryDate: data.entryDate,
  946. contactAddress: data.contactAddress,
  947. postalCode: data.postalCode,
  948. postDeptIds: postDeptArr,
  949. deptIds: tempDeptIds,
  950. };
  951. } else {
  952. this.roleResetList = [...this.roleBaseList];
  953. }
  954. },
  955. formatParentId(id, list, ids = []) {
  956. for (const item of list) {
  957. if (item.children) {
  958. const cIds = this.formatParentId(id, item.children, [
  959. ...ids,
  960. item.value,
  961. ]);
  962. if (cIds.includes(id)) {
  963. return cIds;
  964. }
  965. }
  966. if (item.value === id) {
  967. return [...ids, id];
  968. }
  969. }
  970. return ids;
  971. },
  972. onFormClose(formName) {
  973. // 关闭弹窗重置验证
  974. this.form = {
  975. realName: null,
  976. gender: null,
  977. phone: null,
  978. roleName: null,
  979. roleIds: [],
  980. deptId: null,
  981. organIdLists: [],
  982. jobNature: null,
  983. entryDate: null,
  984. contactAddress: null,
  985. postalCode: null,
  986. deptIds: [],
  987. postDeptIds: [
  988. {
  989. postId: null,
  990. deptIds: [],
  991. },
  992. ],
  993. };
  994. this.$refs[formName].resetFields();
  995. },
  996. formatLockFlag(row) {
  997. let reuslt = ["正常", "冻结"];
  998. if (row.demissionDate) {
  999. return "离职";
  1000. } else {
  1001. return reuslt[row.lockFlag];
  1002. }
  1003. },
  1004. async checkStatus(data) {
  1005. let status;
  1006. await hasCourseGroupRelation({ employeeId: data.id }).then(
  1007. async (res) => {
  1008. if (res.code === 200) {
  1009. if (res.data.hasCourseSchedule) {
  1010. this.$message.error("请先交接指导老师课程");
  1011. status = false;
  1012. } else {
  1013. if (res.data.hasCourseGroupRelation) {
  1014. let userId = data.id;
  1015. await this.$store.dispatch("setOrganRole");
  1016. this.educationViseble = true;
  1017. status = false;
  1018. } else {
  1019. // 1 要弹出
  1020. status = true;
  1021. }
  1022. }
  1023. }
  1024. }
  1025. );
  1026. return status;
  1027. },
  1028. onStaffOperation(type, data) {
  1029. const tempStatus = type == "RESET_PASSWORD" ? true : false;
  1030. this.$confirm(
  1031. `您确定${tempStatus ? "重置密码" : "修改员工状态"}?`,
  1032. "提示",
  1033. {
  1034. confirmButtonText: "确定",
  1035. cancelButtonText: "取消",
  1036. type: "warning",
  1037. }
  1038. )
  1039. .then(async () => {
  1040. if (type === "DEMISSION" && !data.demissionDate) {
  1041. this.activeRow = data;
  1042. // 1.点击的是离职按钮
  1043. // 2.判断该考级是否存在乐团主管
  1044. const status = await this.checkStatus(data);
  1045. if (!status) {
  1046. return;
  1047. }
  1048. }
  1049. employeeOperate({
  1050. employeeId: data.id,
  1051. operate: type,
  1052. }).then((res) => {
  1053. if (res.code == 200) {
  1054. this.$message.success(tempStatus ? "重置密码成功" : "更改成功");
  1055. this.roleStatus = false;
  1056. this.getList();
  1057. } else {
  1058. this.$message.error(res.msg);
  1059. }
  1060. });
  1061. })
  1062. .catch((err) => {});
  1063. },
  1064. submitEducation() {
  1065. // 发请求 提交信息
  1066. updateEducationTeacherId({
  1067. currentUserId: this.activeRow.id,
  1068. targetUserId: this.educationForm.targetUserId,
  1069. }).then((res) => {
  1070. if (res.code === 200) {
  1071. const type = "DEMISSION";
  1072. const data = this.activeRow;
  1073. employeeOperate({
  1074. employeeId: data.id,
  1075. operate: type,
  1076. }).then((res) => {
  1077. if (res.code == 200) {
  1078. this.$message.success("更改成功");
  1079. this.roleStatus = false;
  1080. this.educationViseble = false;
  1081. this.getList();
  1082. } else {
  1083. this.$message.error(res.msg);
  1084. }
  1085. });
  1086. }
  1087. });
  1088. },
  1089. removePostDept(item) {
  1090. const index = this.form.postDeptIds.indexOf(item);
  1091. if (index !== -1) {
  1092. this.form.postDeptIds.splice(index, 1);
  1093. }
  1094. },
  1095. addPostDept() {
  1096. this.form.postDeptIds.push({
  1097. postId: null,
  1098. deptIds: [],
  1099. });
  1100. },
  1101. },
  1102. watch: {
  1103. educationViseble(val) {
  1104. if (!val) {
  1105. this.educationForm.targetUserId = "";
  1106. this.$refs["educationForm"].resetFields();
  1107. }
  1108. },
  1109. },
  1110. };
  1111. </script>
  1112. <style lang="scss" scoped>
  1113. /deep/.el-dialog__body {
  1114. // padding: 0 20px;
  1115. }
  1116. /deep/.el-select,
  1117. /deep/.el-date-editor.el-input {
  1118. width: 100% !important;
  1119. }
  1120. .setWidth {
  1121. display: inline-block;
  1122. }
  1123. </style>