staffManager.vue 36 KB

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