staffPlatManager.vue 35 KB

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