staffPlatManager.vue 36 KB

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