teacherList.vue 19 KB

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