staffPlatManager.vue 35 KB

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