teacherOperation.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <div class='m-container'>
  3. <!-- <h2>
  4. <el-page-header @back="onCancel" :content="'老师' + (pageType == 'create' ? '新增' : '修改')"></el-page-header>
  5. </h2> -->
  6. <div class="infoWrap">
  7. <div class="left">
  8. <h4>基本信息</h4>
  9. <el-form :model="topForm"
  10. :rules="rules"
  11. ref="form">
  12. <el-row>
  13. <el-col :span="12">
  14. <el-form-item label="姓名"
  15. prop="realName"
  16. :label-width="formLabelWidth">
  17. <el-input v-model="topForm.realName"></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="12">
  21. <el-form-item label="性别"
  22. prop="gender"
  23. :label-width="formLabelWidth">
  24. <el-select v-model="topForm.gender">
  25. <el-option label='男'
  26. :value='1'></el-option>
  27. <el-option label='女'
  28. :value='0'></el-option>
  29. </el-select>
  30. </el-form-item>
  31. </el-col>
  32. </el-row>
  33. <el-row>
  34. <el-col :span="12">
  35. <el-form-item label="出生日期"
  36. :label-width="formLabelWidth">
  37. <el-date-picker v-model="topForm.birthdate"
  38. type="date"
  39. value-format="yyyy-MM-dd"
  40. placeholder="出生日期">
  41. </el-date-picker>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="12">
  45. <el-form-item label="入职日期"
  46. prop="entryDate"
  47. :label-width="formLabelWidth">
  48. <el-date-picker v-model="topForm.entryDate"
  49. type="date"
  50. value-format="yyyy-MM-dd"
  51. placeholder="入职日期">
  52. </el-date-picker>
  53. </el-form-item>
  54. </el-col>
  55. </el-row>
  56. <el-row>
  57. <el-col :span="12">
  58. <el-form-item label="工作类别"
  59. prop="jobNature"
  60. :label-width="formLabelWidth">
  61. <el-select v-model="topForm.jobNature"
  62. placeholder="工作类型">
  63. <el-option v-for="item in jobNature"
  64. :key="item.value"
  65. :label="item.label"
  66. :value="item.value"></el-option>
  67. </el-select>
  68. </el-form-item>
  69. </el-col>
  70. <el-col :span="12">
  71. <el-form-item label="所属分部"
  72. prop="organId"
  73. :label-width="formLabelWidth">
  74. <el-select v-model="topForm.organId"
  75. placeholder="所属分部">
  76. <el-option v-for="item in branchList"
  77. :key="item.value"
  78. :label="item.label"
  79. :value="item.value"></el-option>
  80. </el-select>
  81. </el-form-item>
  82. </el-col>
  83. </el-row>
  84. <el-row>
  85. <el-col :span="12">
  86. <el-form-item label="流动范围"
  87. :label-width="formLabelWidth">
  88. <el-select v-model="topForm.flowOrganRange"
  89. multiple
  90. placeholder="流动范围">
  91. <el-option v-for="item in branchList"
  92. :key="item.value"
  93. :label="item.label"
  94. :value="item.value.toString()"></el-option>
  95. </el-select>
  96. </el-form-item>
  97. </el-col>
  98. <el-col :span="12">
  99. <el-form-item label="人事状态"
  100. prop="isProbationPeriod"
  101. :label-width="formLabelWidth">
  102. <el-select v-model="topForm.isProbationPeriod"
  103. placeholder="人事状态">
  104. <el-option label="正式"
  105. :value="1"></el-option>
  106. <el-option label="临时"
  107. :value="0"></el-option>
  108. </el-select>
  109. </el-form-item>
  110. </el-col>
  111. </el-row>
  112. <el-row>
  113. <el-col :span="12">
  114. <el-form-item label="老师简介"
  115. :label-width="formLabelWidth">
  116. <el-input type='textarea'
  117. v-model="topForm.introduction"></el-input>
  118. </el-form-item>
  119. </el-col>
  120. <el-col :span="12"
  121. v-if="pageType == 'update'">
  122. <el-form-item label="教学点"
  123. :label-width="formLabelWidth">
  124. <el-input disabled
  125. v-model="teacherSchools"></el-input>
  126. </el-form-item>
  127. </el-col>
  128. </el-row>
  129. <h4>资料学历</h4>
  130. <el-row>
  131. <el-col :span="12">
  132. <el-form-item label="手机号"
  133. prop="phone"
  134. :label-width="formLabelWidth">
  135. <el-input v-model.number="topForm.phone"></el-input>
  136. </el-form-item>
  137. </el-col>
  138. <el-col :span="12">
  139. <el-form-item label="毕业学校"
  140. :label-width="formLabelWidth">
  141. <el-input v-model="topForm.graduateSchool"></el-input>
  142. </el-form-item>
  143. </el-col>
  144. </el-row>
  145. <el-row>
  146. <el-col :span="12">
  147. <el-form-item label="电子邮箱"
  148. :label-width="formLabelWidth">
  149. <el-input v-model="topForm.email"></el-input>
  150. </el-form-item>
  151. </el-col>
  152. <el-col :span="12">
  153. <el-form-item label="最高学历"
  154. :label-width="formLabelWidth">
  155. <!-- <el-input v-model="topForm.educationBackground"></el-input> -->
  156. <el-select v-model="topForm.educationBackground"
  157. placeholder="最高学历">
  158. <el-option label="初中"
  159. value="初中"></el-option>
  160. <el-option label="高中"
  161. value="高中"></el-option>
  162. <el-option label="大专"
  163. value="大专"></el-option>
  164. <el-option label="本科"
  165. value="本科"></el-option>
  166. <el-option label="硕士"
  167. value="硕士"></el-option>
  168. <el-option label="博士"
  169. value="博士"></el-option>
  170. </el-select>
  171. </el-form-item>
  172. </el-col>
  173. </el-row>
  174. <el-row>
  175. <el-col :span="12">
  176. <el-form-item label="专业技能"
  177. prop="subjectIds"
  178. :label-width="formLabelWidth">
  179. <el-select multiple
  180. v-model="topForm.subjectIds"
  181. placeholder="专业技能">
  182. <el-option-group v-for="group in subjectList"
  183. :key="group.label"
  184. :label="group.label">
  185. <el-option v-for="item in group.options"
  186. :key="item.value"
  187. :label="item.label"
  188. :value="item.value.toString()">
  189. </el-option>
  190. </el-option-group>
  191. </el-select>
  192. </el-form-item>
  193. </el-col>
  194. <el-col :span="12">
  195. <el-form-item label="职称"
  196. :label-width="formLabelWidth">
  197. <el-input v-model="topForm.technicalTitles"></el-input>
  198. </el-form-item>
  199. </el-col>
  200. </el-row>
  201. <el-row>
  202. <el-col :span="12">
  203. <el-form-item label="证件类型"
  204. :label-width="formLabelWidth">
  205. <el-input v-model="topForm.certificateType"></el-input>
  206. <!-- <el-select v-model="topForm.certificateType" placeholder="证件类型">
  207. <el-option label="身份证" value="身份证"></el-option>
  208. <el-option label="护照" value="护照"></el-option>
  209. <el-option label="港澳通行证" value="港澳通行证"></el-option>
  210. </el-select> -->
  211. </el-form-item>
  212. </el-col>
  213. <el-col :span="12">
  214. <el-form-item label="证件号码"
  215. :label-width="formLabelWidth">
  216. <el-input v-model="topForm.certificateNum"></el-input>
  217. </el-form-item>
  218. </el-col>
  219. </el-row>
  220. <el-row>
  221. <el-col :span="12">
  222. <el-form-item label=""
  223. :label-width="formLabelWidth">
  224. <!-- <el-input v-model="topForm.certificateType"></el-input> -->
  225. <el-checkbox v-model="topForm.isSupportCourseScheduleRewardsRules">适用VIP分部活动</el-checkbox>
  226. </el-form-item>
  227. </el-col>
  228. </el-row>
  229. <el-form-item>
  230. <el-button @click="onSubmit('form')"
  231. type="primary">立即{{ pageType == "create" ? '创建' : '修改' }}</el-button>
  232. <el-button @click="onReSet('form')">重置</el-button>
  233. </el-form-item>
  234. </el-form>
  235. </div>
  236. <div class="right">
  237. <div class="teacherIcon">
  238. <img v-if="topForm.avatar"
  239. key="avatar"
  240. :src="topForm.avatar"
  241. alt="">
  242. <img v-else
  243. key="avatar"
  244. src="@/assets/images/base/woman.png"
  245. alt="">
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </template>
  251. <script>
  252. // import { queryByOrganId } from '@/api/systemManage'
  253. import { branchQueryPage, subjectListTree } from '@/api/specialSetting'
  254. import { teacherAdd, teacherUpdate, teacherGet } from '@/api/teacherManager'
  255. import store from '@/store'
  256. import { permission } from '@/utils/directivePage'
  257. import { jobNature } from '@/utils/searchArray'
  258. import { isvalidPhone } from '@/utils/validate'
  259. let validPhone = (rule, value, callback) => {
  260. if (!value) {
  261. callback(new Error('请输入电话号码'))
  262. } else if (!isvalidPhone(value)) {
  263. callback(new Error('请输入正确的11位手机号码'))
  264. } else {
  265. callback()
  266. }
  267. }
  268. export default {
  269. name: 'adminManager',
  270. data () {
  271. return {
  272. jobNature: jobNature,
  273. organId: store.getters.organ,
  274. pageType: this.$route.query.type,
  275. teacherId: this.$route.query.teacherId,
  276. formLabelWidth: '80px',
  277. branchList: [], // 分部列表
  278. subjectList: [], //声部列表
  279. teacherSchools: null,
  280. topForm: {
  281. realName: null,
  282. gender: null,
  283. birthdate: null,
  284. entryDate: null,
  285. jobNature: null,
  286. organId: store.getters.organ,
  287. flowOrganRange: null,
  288. introduction: null,
  289. phone: null,
  290. avatar: null,
  291. graduateSchool: null,
  292. email: null,
  293. educationBackground: null,
  294. subjectIds: [],
  295. isProbationPeriod: null,
  296. technicalTitles: null,
  297. certificateType: null,
  298. certificateNum: null,
  299. isSupportCourseScheduleRewardsRules: true
  300. },
  301. rules: {
  302. realName: [{ required: true, message: '请输入姓名', trigger: 'blur' },
  303. { min: 2, max: 10, message: '请输入 2 到 10 个字符', trigger: 'blur' }],
  304. gender: [{ required: true, message: '请选择性别', trigger: 'change' }],
  305. entryDate: [{ required: true, message: '请选择入职日期', trigger: 'change' }],
  306. jobNature: [{ required: true, message: '请选择工作类别', trigger: 'change' }],
  307. isProbationPeriod: [{ required: true, message: '请选择人事状态', trigger: 'change' }],
  308. organId: [{ required: true, message: '请选择所属分部', trigger: 'change' }],
  309. phone: [{ required: true, validator: validPhone, trigger: 'blur' }],
  310. subjectIds: [{ required: true, type: 'array', message: '请选择专业技能', trigger: 'change' }]
  311. }
  312. }
  313. },
  314. mounted () {
  315. this.__init()
  316. },
  317. methods: {
  318. __init () {
  319. branchQueryPage({ // 获取分部
  320. delFlag: 0,
  321. rows: 9999
  322. }).then(res => {
  323. if (res.code == 200 && res.data && res.data.rows) {
  324. res.data.rows.forEach(item => {
  325. this.branchList.push({
  326. label: item.name,
  327. value: item.id
  328. })
  329. })
  330. }
  331. })
  332. subjectListTree({ // 声部
  333. delFlag: 0,
  334. rows: 9999
  335. }).then(res => {
  336. let result = res.data
  337. if (res.code == 200) {
  338. let tempArray = []
  339. result.rows.forEach((item, index) => {
  340. let subject = []
  341. item.subjects.forEach(s => {
  342. subject.push({
  343. value: s.id,
  344. label: s.name
  345. })
  346. })
  347. tempArray[index] = {
  348. label: item.name,
  349. options: subject
  350. }
  351. })
  352. this.subjectList = tempArray
  353. }
  354. })
  355. if (this.pageType == 'update') {
  356. teacherGet({ teacherId: this.teacherId }).then(res => {
  357. let result = res.data
  358. this.topForm = {
  359. realName: result.realName,
  360. gender: result.gender,
  361. birthdate: result.birthdate,
  362. entryDate: result.entryDate,
  363. jobNature: result.jobNature,
  364. organId: result.organId,
  365. flowOrganRange: result.flowOrganRangeId ? result.flowOrganRangeId.split(',') : null,
  366. introduction: result.introduction,
  367. phone: result.phone,
  368. avatar: result.avatar,
  369. graduateSchool: result.graduateSchool,
  370. email: result.email,
  371. educationBackground: result.educationBackground,
  372. subjectIds: result.subjectId ? result.subjectId.split(',') : null,
  373. technicalTitles: result.technicalTitles,
  374. certificateType: result.certificateType,
  375. certificateNum: result.certificateNum,
  376. isProbationPeriod: result.isProbationPeriod,
  377. isSupportCourseScheduleRewardsRules: result.isSupportCourseScheduleRewardsRules
  378. }
  379. this.teacherSchools = result.teacherSchools.length > 0 ? result.teacherSchools.join(',') : ''
  380. })
  381. }
  382. },
  383. onSubmit (formName) {
  384. this.$refs[formName].validate(valid => {
  385. if (valid) {
  386. this.topForm.flowOrganRange = this.topForm.flowOrganRange.join(',')
  387. this.topForm.subjectId = this.topForm.subjectIds.join(',')
  388. if (this.pageType == 'update') {
  389. this.topForm.id = this.teacherId
  390. teacherUpdate(this.topForm).then(res => {
  391. if (res.code == 200) {
  392. // this.$emit('onTeacher')
  393. this.$router.push('/business/teacherList')
  394. }
  395. this.messageTips('修改', res)
  396. })
  397. } else if (this.pageType == 'create') {
  398. if (this.topForm.id) {
  399. delete this.topForm.id
  400. }
  401. teacherAdd(this.topForm).then(res => {
  402. if (res.code == 200) {
  403. // 权限判断,是否有课酬设置
  404. if(permission('/teacherAdd/salarySeting')) {
  405. this.$router.push('/business/teacherList')
  406. } else {
  407. this.$emit('onTeacher', res.data)
  408. }
  409. }
  410. this.messageTips('添加', res)
  411. })
  412. }
  413. } else {
  414. return false
  415. }
  416. })
  417. },
  418. messageTips (title, res) {
  419. if (res.code == 200) {
  420. this.$message.success(title + '成功')
  421. } else {
  422. this.topForm.subjectIds = this.topForm.subjectIds.split(',')
  423. this.$message.error(res.msg)
  424. }
  425. },
  426. onReSet (formName) {
  427. this.topForm = {
  428. realName: null,
  429. gender: null,
  430. birthdate: null,
  431. entryDate: null,
  432. jobNature: null,
  433. organId: store.getters.organ,
  434. flowOrganRange: null,
  435. introduction: null,
  436. phone: null,
  437. avatar: null,
  438. graduateSchool: null,
  439. email: null,
  440. educationBackground: null,
  441. subjectIds: [],
  442. technicalTitles: null,
  443. certificateType: null,
  444. certificateNum: null,
  445. jobType: 'ADVISER'
  446. }
  447. this.$refs[formName].resetFields()
  448. },
  449. onCancel () {
  450. this.$router.push('/business/teacherList')
  451. }
  452. }
  453. }
  454. </script>
  455. <style lang="scss" scoped>
  456. .el-button--primary {
  457. background: #14928a;
  458. border-color: #14928a;
  459. color: #fff;
  460. &:hover,
  461. &:active,
  462. &:focus {
  463. background: #14928a;
  464. border-color: #14928a;
  465. color: #fff;
  466. }
  467. }
  468. /deep/.el-date-editor.el-input,
  469. /deep/.el-select {
  470. width: 100% !important;
  471. }
  472. // .el-row {
  473. // margin-top: 40px;
  474. // }
  475. // .el-col {
  476. // display: flex;
  477. // align-items: center;
  478. // margin-bottom: 20px;
  479. // justify-content: flex-end;
  480. // margin-right: 50%;
  481. // }
  482. // .el-input-group {
  483. // width: 200px;
  484. // margin: 0 20px;
  485. // }
  486. // /deep/.el-tree-node__content {
  487. // height: 40px !important;
  488. // }
  489. /deep/.el-form-item__content {
  490. font-size: 14px !important;
  491. margin-right: 5%;
  492. }
  493. .infoWrap {
  494. margin-top: 20px;
  495. display: flex;
  496. flex-direction: row;
  497. justify-content: flex-start;
  498. .left {
  499. max-width: 1000px;
  500. width: 100%;
  501. h4 {
  502. margin-bottom: 20px;
  503. }
  504. }
  505. .right {
  506. margin-left: 100px;
  507. .teacherIcon {
  508. width: 150px;
  509. height: 150px;
  510. // border: 1px solid #444;
  511. border-radius: 50%;
  512. overflow: hidden;
  513. img {
  514. width: 150px;
  515. height: 150px;
  516. }
  517. }
  518. }
  519. }
  520. </style>