teacherList.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>
  5. 老师管理
  6. </h2>
  7. <div class="m-core">
  8. <!-- 搜索标题 -->
  9. <save-form
  10. :inline="true"
  11. @submit="search"
  12. @reset="onReSet"
  13. class="searchForm"
  14. :model="searchForm"
  15. ref="searchForm"
  16. >
  17. <el-form-item>
  18. <el-input
  19. v-model.trim="searchForm.search"
  20. clearable
  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>
  32. <el-select
  33. v-model.trim="searchForm.lockFlag"
  34. clearable
  35. filterable
  36. placeholder="老师状态"
  37. >
  38. <el-option
  39. v-for="item in teacherStatus"
  40. :key="item.value"
  41. :label="item.label"
  42. :value="item.value"
  43. ></el-option>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item>
  47. <el-select
  48. style="width: 100% !important"
  49. filterable
  50. clearable
  51. v-model.trim="searchForm.subjectId"
  52. placeholder="专业技能"
  53. >
  54. <el-option
  55. v-for="(item, i) in selects.subjects"
  56. :key="i"
  57. :label="item.name"
  58. :value="item.id"
  59. ></el-option>
  60. </el-select>
  61. <!-- <el-select
  62. v-model.trim="searchForm.subjectId"
  63. filterable
  64. clearable
  65. placeholder="专业技能"
  66. >
  67. <el-option-group
  68. v-for="group in subjectList"
  69. :key="group.label"
  70. :label="group.label"
  71. >
  72. <el-option
  73. v-for="item in group.options"
  74. :key="item.value"
  75. :label="item.label"
  76. :value="item.value"
  77. ></el-option>
  78. </el-option-group>
  79. </el-select> -->
  80. </el-form-item>
  81. <el-form-item>
  82. <el-select
  83. v-model.trim="searchForm.organId"
  84. filterable
  85. clearable
  86. multiple
  87. collapse-tags
  88. placeholder="请选择分部"
  89. >
  90. <el-option
  91. v-for="item in selects.branchs"
  92. :key="item.id"
  93. :label="item.name"
  94. :value="item.id"
  95. >
  96. </el-option>
  97. </el-select>
  98. </el-form-item>
  99. <el-form-item>
  100. <el-select
  101. v-model.trim="searchForm.jobNature"
  102. filterable
  103. clearable
  104. placeholder="工作类型"
  105. >
  106. <el-option
  107. v-for="item in jobNature"
  108. :key="item.value"
  109. :label="item.label"
  110. :value="item.value"
  111. ></el-option>
  112. </el-select>
  113. </el-form-item>
  114. <el-form-item>
  115. <el-select
  116. v-model.trim="searchForm.isProbationPeriod"
  117. clearable
  118. filterable
  119. placeholder="员工状态"
  120. >
  121. <el-option v-for="item in ProbationPeriodList" :key="item.value" :label="item.label" :value="item.value"></el-option>
  122. <!-- <el-option label="正式" value="0"></el-option>
  123. <el-option label="试用" value="1"></el-option>
  124. <el-option label="实习" value="3"></el-option> -->
  125. </el-select>
  126. </el-form-item>
  127. <!-- isSupportExtraPracticeLesson -->
  128. <el-form-item>
  129. <el-select
  130. v-model.trim="searchForm.isSupportExtraPracticeLesson"
  131. clearable
  132. filterable
  133. placeholder="开放陪练"
  134. >
  135. <el-option label="是" value="true"></el-option>
  136. <el-option label="否" value="false"></el-option>
  137. </el-select>
  138. </el-form-item>
  139. <el-form-item>
  140. <el-button native-type="submit" type="danger">搜索</el-button>
  141. <el-button native-type="reset" type="primary">重置</el-button>
  142. <el-button
  143. type="primary"
  144. v-permission="'export/teacherList'"
  145. @click="downLoadTeacher"
  146. >导出</el-button>
  147. </el-form-item>
  148. </save-form>
  149. <el-button
  150. v-permission="'/teacherOperationAdd'"
  151. @click="onTeacher('create')"
  152. type="primary"
  153. style="margin-bottom:20px"
  154. >
  155. 老师新增
  156. </el-button>
  157. <!-- 列表 -->
  158. <div class="tableWrap">
  159. <el-table
  160. :data="tableList"
  161. :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
  162. >
  163. <el-table-column
  164. align="center"
  165. prop="id"
  166. label="老师编号"
  167. ></el-table-column>
  168. <el-table-column align="center" prop="realName" label="老师名称">
  169. <template slot-scope="scope">
  170. <div>
  171. <p>{{ scope.row.realName }}</p>
  172. <p v-if="scope.row.memo">{{ "(" + scope.row.memo + ")" }}</p>
  173. </div>
  174. </template>
  175. </el-table-column>
  176. <el-table-column
  177. align="center"
  178. prop="organName"
  179. label="所属分部"
  180. ></el-table-column>
  181. <el-table-column align="center" width="150px" label="老师状态">
  182. <template slot-scope="scope">{{
  183. scope.row.lockFlag | teacherStatus
  184. }}</template>
  185. </el-table-column>
  186. <el-table-column
  187. align="center"
  188. :show-overflow-tooltip="true"
  189. width="200px"
  190. label="专业技能"
  191. >
  192. <template slot-scope="scope">
  193. <span
  194. style="max-height: 68px; display: block"
  195. :title="scope.row.splitSubjectName"
  196. >{{ scope.row.splitSubjectName }}</span
  197. >
  198. </template>
  199. </el-table-column>
  200. <el-table-column
  201. align="center"
  202. prop="phone"
  203. width="150px"
  204. label="联系电话"
  205. ></el-table-column>
  206. <el-table-column align="center" label="工作类型">
  207. <template slot-scope="scope">{{
  208. scope.row.jobNature | jobNature
  209. }}</template>
  210. </el-table-column>
  211. <el-table-column align="center" label="员工状态">
  212. <template slot-scope="scope">
  213. {{ scope.row.isProbationPeriod | ProbationPeriod }}
  214. </template>
  215. </el-table-column>
  216. <el-table-column
  217. align="center"
  218. prop="vipNum"
  219. label="已开小课"
  220. ></el-table-column>
  221. <el-table-column align="center" width="130px" label="试听课安排">
  222. <template slot-scope="scope">{{
  223. scope.row.demoNum > 0 ? "是" : "否"
  224. }}</template>
  225. </el-table-column>
  226. <el-table-column align="center" width="120px" label="开放网管课">
  227. <template slot-scope="scope">{{
  228. scope.row.isSupportExtraPracticeLesson ? "是" : "否"
  229. }}</template>
  230. </el-table-column>
  231. <!-- <el-table-column align="center" label="运营指标">
  232. <template slot-scope="scope">
  233. <el-button type="text" @click="gotoOperating(scope.row)">{{
  234. scope.row.operatingIndex + "%"
  235. }}</el-button>
  236. </template>
  237. </el-table-column>
  238. <el-table-column align="center" label="服务指标">
  239. <template slot-scope="scope">
  240. <el-button type="text" @click="gotoAfterSchool(scope.row)">{{
  241. scope.row.serviceIndex + "%"
  242. }}</el-button>
  243. </template>
  244. </el-table-column> -->
  245. <el-table-column align="center" label="转正日期">
  246. <template slot-scope="scope">
  247. <div>
  248. {{ scope.row.formalStaffDate | dayjsFormat }}
  249. </div>
  250. </template>
  251. </el-table-column>
  252. <el-table-column align="center" label="离职日期">
  253. <template slot-scope="scope">
  254. <div>
  255. {{ scope.row.demissionDate | dayjsFormat }}
  256. </div>
  257. </template>
  258. </el-table-column>
  259. <el-table-column
  260. align="center"
  261. fixed="right"
  262. width="200"
  263. label="操作"
  264. >
  265. <template slot-scope="scope">
  266. <!-- let search = JSON.stringify(this.searchForm)
  267. let rules = JSON.stringify(this.pageInfo)-->
  268. <auth auths="/teacherDetail">
  269. <router-link
  270. class="el-button--text"
  271. :to="{
  272. path: `/business/teacherDetail?teacherId=${scope.row.id}&teacherName=${scope.row.realName}`,
  273. }"
  274. >查看</router-link>
  275. </auth>
  276. <auth auths="/teacherOperationUpdate">
  277. <el-button
  278. @click="onTeacher('update', scope.row)"
  279. type="text"
  280. >修改</el-button
  281. >
  282. </auth>
  283. <auth :auths="scope.row.lockFlag == 1 ? 'employee/employeeOperate/UNLOCK' : 'employee/employeeOperate/LOCK'">
  284. <el-button
  285. @click="onStaffOperation('LOCK_UNLOCK', scope.row)"
  286. type="text"
  287. >{{ scope.row.lockFlag == 1 ? "解冻" : "冻结" }}</el-button
  288. >
  289. </auth>
  290. <auth auths="user/updatePassword2">
  291. <el-button
  292. @click="resetPassWrod(scope.row)"
  293. type="text"
  294. >修改密码</el-button
  295. >
  296. </auth>
  297. <el-button
  298. v-if="scope.row.contractUrl"
  299. @click="onDownloadProtocol(scope.row)"
  300. type="text"
  301. >下载协议</el-button>
  302. <!-- -->
  303. </template>
  304. </el-table-column>
  305. </el-table>
  306. <pagination
  307. sync
  308. :total.sync="pageInfo.total"
  309. :page.sync="pageInfo.page"
  310. :limit.sync="pageInfo.limit"
  311. :page-sizes="pageInfo.page_size"
  312. @pagination="getList"
  313. />
  314. </div>
  315. </div>
  316. <el-dialog
  317. title="修改密码"
  318. :visible.sync="passwrodVisiable"
  319. :before-close="closePassWord"
  320. width="400px"
  321. >
  322. <el-form :model="passwrodForm" ref="passwrodForm" :inline="true">
  323. <el-form-item
  324. label="手机号"
  325. prop="phone"
  326. label-width="80px"
  327. :rules="[
  328. { required: true, message: '手机号不能为空', trigger: 'blur' },
  329. {
  330. pattern: /^1\d{10}$/,
  331. message: '请输入正确的手机号',
  332. trigger: 'blur',
  333. },
  334. ]"
  335. >
  336. <copy-text>{{ passwrodForm.phone }}</copy-text>
  337. </el-form-item>
  338. <el-form-item
  339. label="输入密码"
  340. prop="password"
  341. label-width="80px"
  342. :rules="[
  343. { required: true, message: '密码不能为空', trigger: 'blur' },
  344. {
  345. pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/,
  346. message: '密码为6-20位数字和字母组合',
  347. trigger: 'blur',
  348. },
  349. ]"
  350. >
  351. <el-input v-model.trim="passwrodForm.password"></el-input>
  352. </el-form-item>
  353. <el-form-item
  354. label="再次输入"
  355. prop="password2"
  356. label-width="80px"
  357. :rules="[
  358. { required: true, message: '密码不能为空', trigger: 'blur' },
  359. {
  360. pattern: /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/,
  361. message: '密码为6-20位数字和字母组合',
  362. trigger: 'blur',
  363. },
  364. ]"
  365. >
  366. <el-input v-model.trim="passwrodForm.password2"></el-input>
  367. </el-form-item>
  368. </el-form>
  369. <span slot="footer" class="dialog-footer">
  370. <el-button @click="passwrodVisiable = false">取 消</el-button>
  371. <el-button type="primary" @click="submitResetPassWord">确 定</el-button>
  372. </span>
  373. </el-dialog>
  374. </div>
  375. </template>
  376. <script>
  377. import pagination from "@/components/Pagination/index";
  378. import { teacherQueryPage } from "@/api/teacherManager";
  379. import { employeeOperate } from "@/api/systemManage";
  380. // import { subjectListTree } from "@/api/specialSetting";
  381. import { resetPassword2 } from "@/api/buildTeam";
  382. import { Export } from "@/utils/downLoadFile";
  383. import cleanDeep from 'clean-deep'
  384. import { jobNature, teacherStatus, ProbationPeriodList } from "@/utils/searchArray";
  385. import store from "@/store";
  386. export default {
  387. name: "teacherList",
  388. components: {
  389. pagination,
  390. },
  391. data() {
  392. return {
  393. searchForm: {
  394. lockFlag: null,
  395. isProbationPeriod: null,
  396. jobNature: null,
  397. subjectId: null,
  398. organId: [],
  399. search: null, // 老师姓名或电话
  400. isSupportExtraPracticeLesson: null,
  401. },
  402. jobNature: jobNature, // 工作类型
  403. teacherStatus: teacherStatus, // 老师状态
  404. ProbationPeriodList: ProbationPeriodList,
  405. subjectList: [], // 声部列表
  406. branchList: [], // 分部列表
  407. tableList: [],
  408. // organId: store.getters.organ,
  409. pageInfo: {
  410. // 分页规则
  411. limit: 10, // 限制显示条数
  412. page: 1, // 当前页
  413. total: 1, // 总条数
  414. page_size: [10, 20, 40, 50], // 选择限制显示条数
  415. },
  416. passwrodVisiable: false,
  417. passwrodForm: {
  418. phone: "",
  419. password: "",
  420. password2: "",
  421. },
  422. activatedRow: null,
  423. lookServer: false,
  424. infoList: [],
  425. };
  426. },
  427. // activated() {
  428. // this.__init();
  429. // this.getList();
  430. // },
  431. mounted() {
  432. if (this.$route.params.search) {
  433. this.searchForm.search = this.$route.params.search;
  434. }
  435. this.__init();
  436. this.getList();
  437. },
  438. methods: {
  439. search() {
  440. this.pageInfo.page = 1;
  441. this.getList();
  442. },
  443. async __init() {
  444. // 获取分部
  445. await this.$store.dispatch("setBranchs");
  446. await this.$store.dispatch("setSubjects");
  447. },
  448. onTeacher(type, row) {
  449. let params = {
  450. type: type,
  451. };
  452. if (row) {
  453. params.teacherId = row.id;
  454. params.teacherName = row.realName;
  455. }
  456. let path = "/business/teacherOperation";
  457. // (params)
  458. // teacherId=${scope.row.id}&teacherName=${scope.row.realName}
  459. this.$router.push(
  460. {
  461. path: path,
  462. query: params,
  463. },
  464. (router) => {
  465. if (type == "update") {
  466. router.meta.title = "老师修改";
  467. } else {
  468. router.meta.title = "老师新增";
  469. }
  470. }
  471. );
  472. },
  473. downLoadTeacher() {
  474. let params = {...this.searchForm};
  475. params.lockFlag ? params.lockFlag : (params.lockFlag = null);
  476. params.isProbationPeriod
  477. ? params.isProbationPeriod
  478. : (params.isProbationPeriod = null);
  479. params.jobNature ? params.jobNature : (params.jobNature = null);
  480. // params.subjectId?params.subjectId:params.subjectId = null
  481. params.subjectId ? params.subjectId : (params.subjectId = null);
  482. params.search ? params.search : (params.search = null);
  483. params.organId = this.searchForm.organId.join(',')
  484. params.isSupportExtraPracticeLesson
  485. ? params.isSupportExtraPracticeLesson
  486. : (params.isSupportExtraPracticeLesson = null);
  487. Export(
  488. this,
  489. {
  490. url: "/api-web/export/teacherList",
  491. fileName:`老师列表导出.xls`,
  492. params:cleanDeep( {
  493. ...params
  494. }),
  495. },
  496. "是否确认导出老师列表?"
  497. );
  498. },
  499. onDownloadProtocol(item) {
  500. window.location.href = item.contractUrl;
  501. },
  502. getList() {
  503. let params = {...this.searchForm};
  504. // params.organId = this.organId
  505. // searchForm: {
  506. // lockFlag: null,
  507. // isProbationPeriod: null,
  508. // jobNature: null,
  509. // subjectId: null,
  510. // organId: null,
  511. // search: null, // 老师姓名或电话
  512. // isSupportExtraPracticeLesson:null
  513. // },
  514. params.lockFlag ? params.lockFlag : (params.lockFlag = null);
  515. params.isProbationPeriod
  516. ? params.isProbationPeriod
  517. : (params.isProbationPeriod = null);
  518. params.jobNature ? params.jobNature : (params.jobNature = null);
  519. // params.subjectId?params.subjectId:params.subjectId = null
  520. params.subjectId ? params.subjectId : (params.subjectId = null);
  521. params.search ? params.search : (params.search = null);
  522. params.isSupportExtraPracticeLesson
  523. ? params.isSupportExtraPracticeLesson
  524. : (params.isSupportExtraPracticeLesson = null);
  525. params.rows = this.pageInfo.limit;
  526. params.page = this.pageInfo.page;
  527. params.organId = this.searchForm.organId.join(',')
  528. teacherQueryPage(params).then((res) => {
  529. if (res.code == 200) {
  530. // (res)
  531. this.tableList = res.data.rows;
  532. this.pageInfo.total = res.data.total;
  533. }
  534. });
  535. },
  536. onStaffOperation(type, data) {
  537. let str = "";
  538. if (data.lockFlag != 1) {
  539. str = `是否冻结${data.realName}老师?`;
  540. } else {
  541. str = `是否解冻${data.realName}老师?`;
  542. }
  543. this.$confirm(str, "提示", {
  544. confirmButtonText: "确定",
  545. cancelButtonText: "取消",
  546. type: "warning",
  547. })
  548. .then(() => {
  549. employeeOperate({
  550. employeeId: data.id,
  551. operate: type,
  552. }).then((res) => {
  553. if (res.code == 200) {
  554. this.$message.success("更改成功");
  555. this.roleStatus = false;
  556. this.getList();
  557. } else {
  558. this.$message.error(res.msg);
  559. }
  560. });
  561. })
  562. .catch(() => {});
  563. },
  564. onReSet() {
  565. this.searchForm = {
  566. lockFlag: null,
  567. isProbationPeriod: null,
  568. jobNature: null,
  569. organId: [],
  570. subjectId: null,
  571. search: null,
  572. };
  573. this.search()
  574. },
  575. resetPassWrod(row) {
  576. this.activatedRow = row;
  577. this.passwrodForm.phone = row.phone;
  578. this.passwrodVisiable = true;
  579. },
  580. closePassWord() {
  581. this.activatedRow = null;
  582. this.passwrodForm = {
  583. phone: "",
  584. password: "",
  585. password2: "",
  586. };
  587. this.$refs["passwrodForm"].resetFields();
  588. this.passwrodVisiable = false;
  589. },
  590. submitResetPassWord() {
  591. if (this.passwrodForm.password !== this.passwrodForm.password2) {
  592. this.$message.error("两次密码必须相同");
  593. return;
  594. }
  595. this.$refs["passwrodForm"].validate((res) => {
  596. if (res) {
  597. // 发请求
  598. resetPassword2({
  599. mobile: this.passwrodForm.phone,
  600. newPassword: this.passwrodForm.password,
  601. userId: this.activatedRow.id,
  602. }).then((res) => {
  603. if (res.code == 200) {
  604. // 修改成功
  605. this.$message.success("修改成功");
  606. this.closePassWord();
  607. }
  608. });
  609. }
  610. });
  611. },
  612. },
  613. };
  614. </script>
  615. <style lang="scss" scoped>
  616. .el-button + .el-button {
  617. margin-left: 0;
  618. }
  619. .hanlderWrap {
  620. display: flex;
  621. flex-direction: row;
  622. justify-content: space-between;
  623. align-items: center;
  624. }
  625. </style>