teacherList.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. <template>
  2. <div class="m-container">
  3. <h2>
  4. <div class="squrt"></div>老师列表
  5. </h2>
  6. <div class="m-core">
  7. <div class="newBand"
  8. v-permission="'/teacherOperationAdd'"
  9. @click="onTeacher('create')">老师新增</div>
  10. <!-- 搜索标题 -->
  11. <el-form :inline="true"
  12. class="searchForm"
  13. v-model="searchForm">
  14. <el-form-item>
  15. <el-input v-model="searchForm.search"
  16. @keyup.enter.native='getList'
  17. placeholder="老师姓名或电话"></el-input>
  18. </el-form-item>
  19. <el-form-item>
  20. <el-select v-model="searchForm.lockFlag"
  21. clearable
  22. filterable
  23. placeholder="老师状态">
  24. <el-option v-for="item in teacherStatus"
  25. :key="item.value"
  26. :label="item.label"
  27. :value="item.value"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. <el-form-item>
  31. <el-select v-model="searchForm.subjectId"
  32. filterable
  33. clearable
  34. placeholder="专业技能">
  35. <el-option-group v-for="group in subjectList"
  36. :key="group.label"
  37. :label="group.label">
  38. <el-option v-for="item in group.options"
  39. :key="item.value"
  40. :label="item.label"
  41. :value="item.value">
  42. </el-option>
  43. </el-option-group>
  44. </el-select>
  45. </el-form-item>
  46. <el-form-item>
  47. <el-select v-model="searchForm.organId"
  48. filterable
  49. clearable
  50. placeholder="请选择分部">
  51. <el-option v-for="item in branchList"
  52. :key="item.id"
  53. :label="item.label"
  54. :value="item.value"></el-option>
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item>
  58. <el-select v-model="searchForm.jobNature"
  59. filterable
  60. clearable
  61. placeholder="工作类型">
  62. <el-option v-for="item in jobNature"
  63. :key="item.value"
  64. :label="item.label"
  65. :value="item.value"></el-option>
  66. </el-select>
  67. </el-form-item>
  68. <el-form-item>
  69. <el-select v-model="searchForm.isProbationPeriod"
  70. clearable
  71. filterable
  72. placeholder="人事状态">
  73. <el-option label="试用"
  74. value="0"></el-option>
  75. <el-option label="正式"
  76. value="1"></el-option>
  77. </el-select>
  78. </el-form-item>
  79. <el-form-item>
  80. <el-button @click="search"
  81. type="danger">搜索</el-button>
  82. <el-button @click="onReSet"
  83. type="primary">重置</el-button>
  84. </el-form-item>
  85. </el-form>
  86. <!-- 列表 -->
  87. <div class="tableWrap">
  88. <el-table :data='tableList'
  89. :header-cell-style="{background:'#EDEEF0',color:'#444'}">
  90. <el-table-column align='center'
  91. prop="id"
  92. label="老师编号">
  93. </el-table-column>
  94. <el-table-column align='center'
  95. prop="realName"
  96. label="老师名称">
  97. </el-table-column>
  98. <el-table-column align='center'
  99. prop="organName"
  100. label="所属分部">
  101. </el-table-column>
  102. <el-table-column align='center'
  103. label="老师状态">
  104. <template slot-scope="scope">
  105. {{ scope.row.lockFlag | teacherStatus }}
  106. </template>
  107. </el-table-column>
  108. <el-table-column align='center'
  109. label="专业技能">
  110. <template slot-scope="scope">
  111. <span style="max-height: 68px;display: block;"
  112. :title="scope.row.splitSubjectName">{{ scope.row.splitSubjectName }}</span>
  113. </template>
  114. </el-table-column>
  115. <el-table-column align='center'
  116. prop="phone"
  117. label="联系电话">
  118. </el-table-column>
  119. <el-table-column align='center'
  120. label="工作类型">
  121. <template slot-scope="scope">
  122. {{ scope.row.jobNature | jobNature }}
  123. </template>
  124. </el-table-column>
  125. <el-table-column align='center'
  126. label="人事状态">
  127. <template slot-scope="scope">
  128. {{ scope.row.isProbationPeriod ? '正式' : '试用' }}
  129. </template>
  130. </el-table-column>
  131. <el-table-column align='center'
  132. prop="vipNum"
  133. label="已开小课">
  134. </el-table-column>
  135. <el-table-column align='center'
  136. label="试听课安排">
  137. <template slot-scope="scope">
  138. {{ scope.row.demoNum > 0 ? '是' : '否' }}
  139. </template>
  140. </el-table-column>
  141. <el-table-column align='center'
  142. label="操作">
  143. <template slot-scope="scope">
  144. <!-- let search = JSON.stringify(this.searchForm)
  145. let rules = JSON.stringify(this.pageInfo) -->
  146. <router-link style="color:#409EFF"
  147. v-permission="'/teacherDetail'"
  148. :to="{path:`/business/teacherDetail?teacherId=${scope.row.id}&teacherName=${scope.row.realName}`,query:{search:JSON.stringify(searchForm),rules:JSON.stringify(pageInfo)}}">查看</router-link>
  149. <el-button v-permission="'/teacherIperationUpdate'"
  150. @click="onTeacher('update', scope.row)"
  151. type="text">修改</el-button>
  152. <el-button v-permission="'employee/employeeOperate'"
  153. @click="onStaffOperation('LOCK_UNLOCK', scope.row)"
  154. type="text">{{ scope.row.lockFlag == 1 ? '解冻' : '冻结' }}</el-button>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. <pagination :total="pageInfo.total"
  159. :page.sync="pageInfo.page"
  160. :limit.sync="pageInfo.limit"
  161. :page-sizes="pageInfo.page_size"
  162. @pagination="getList" />
  163. </div>
  164. </div>
  165. </div>
  166. </template>
  167. <script>
  168. import pagination from '@/components/Pagination/index'
  169. import { teacherQueryPage } from '@/api/teacherManager'
  170. import { employeeOperate } from '@/api/systemManage'
  171. import { subjectListTree } from '@/api/specialSetting'
  172. import { getEmployeeOrgan } from '@/api/buildTeam'
  173. import { jobNature, teacherStatus } from '@/utils/searchArray'
  174. import store from '@/store'
  175. export default {
  176. name: 'teacherList',
  177. components: {
  178. pagination
  179. },
  180. data () {
  181. return {
  182. searchForm: {
  183. lockFlag: null,
  184. isProbationPeriod: null,
  185. jobNature: null,
  186. subjectId: null,
  187. organId: null,
  188. search: null // 老师姓名或电话
  189. },
  190. jobNature: jobNature, // 工作类型
  191. teacherStatus: teacherStatus, // 老师状态
  192. subjectList: [], // 声部列表
  193. branchList: [], // 分部列表
  194. tableList: [],
  195. // organId: store.getters.organ,
  196. pageInfo: {
  197. // 分页规则
  198. limit: 10, // 限制显示条数
  199. page: 1, // 当前页
  200. total: 1, // 总条数
  201. page_size: [10, 20, 40, 50] // 选择限制显示条数
  202. },
  203. }
  204. },
  205. activated () {
  206. this.__init();
  207. this.getList();
  208. },
  209. mounted () {
  210. this.__init()
  211. this.getList()
  212. },
  213. methods: {
  214. search () {
  215. this.pageInfo.page = 1;
  216. this.getList();
  217. },
  218. __init () {
  219. if (this.$route.query.search) {
  220. this.$route.query.search instanceof Object ? this.searchForm = this.$route.query.search : this.searchForm = JSON.parse(this.$route.query.search);
  221. }
  222. if (this.$route.query.rules) {
  223. this.$route.query.rules instanceof Object ? this.pageInfo = this.$route.query.rules : this.pageInfo = JSON.parse(this.$route.query.rules);
  224. }
  225. getEmployeeOrgan().then(res => {
  226. if (res.code == 200) {
  227. res.data.forEach(item => {
  228. this.branchList.push({
  229. label: item.name,
  230. value: item.id
  231. })
  232. })
  233. }
  234. })
  235. subjectListTree({
  236. delFlag: 0,
  237. rows: 9999
  238. }).then(res => {
  239. let result = res.data
  240. if (res.code == 200) {
  241. let tempArray = []
  242. result.rows.forEach((item, index) => {
  243. let subject = []
  244. item.subjects.forEach(s => {
  245. subject.push({
  246. value: s.id,
  247. label: s.name
  248. })
  249. })
  250. tempArray[index] = {
  251. label: item.name,
  252. options: subject
  253. }
  254. })
  255. this.subjectList = tempArray
  256. }
  257. })
  258. // this.getList();
  259. },
  260. onTeacher (type, row) {
  261. let search = JSON.stringify(this.searchForm)
  262. let rules = JSON.stringify(this.pageInfo)
  263. let params = {
  264. type: type,
  265. search,
  266. rules
  267. }
  268. if (row) {
  269. params.teacherId = row.id
  270. }
  271. let path = '/business/teacherOperation'
  272. if (type == 'update') {
  273. path = '/business/teacherOperationUpdate'
  274. }
  275. this.$router.push({
  276. path: path,
  277. query: params
  278. })
  279. },
  280. getList () {
  281. let params = this.searchForm
  282. // params.organId = this.organId
  283. params.rows = this.pageInfo.limit
  284. params.page = this.pageInfo.page
  285. teacherQueryPage(params).then(res => {
  286. if (res.code == 200) {
  287. // console.log(res)
  288. this.tableList = res.data.rows
  289. this.pageInfo.total = res.data.total
  290. }
  291. })
  292. },
  293. onStaffOperation (type, data) {
  294. let str = ''
  295. if (data.lockFlag != 1) {
  296. str = `是否冻结${data.realName}老师?`
  297. } else {
  298. str = `是否解冻${data.realName}老师?`
  299. }
  300. this.$confirm(str, '提示', {
  301. confirmButtonText: '确定',
  302. cancelButtonText: '取消',
  303. type: 'warning'
  304. }).then(() => {
  305. employeeOperate({
  306. employeeId: data.id,
  307. operate: type
  308. }).then(res => {
  309. if (res.code == 200) {
  310. this.$message.success('更改成功')
  311. this.roleStatus = false
  312. this.getList()
  313. } else {
  314. this.$message.error(res.msg)
  315. }
  316. })
  317. }).catch(() => { })
  318. },
  319. onReSet () {
  320. this.searchForm = {
  321. lockFlag: null,
  322. isProbationPeriod: null,
  323. jobNature: null,
  324. organId: null,
  325. subjectId: null,
  326. search: null
  327. }
  328. }
  329. }
  330. }
  331. </script>
  332. <style lang="scss">
  333. .el-button + .el-button {
  334. margin-left: 0;
  335. }
  336. </style>