form.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <div>
  3. <div class="description-title">
  4. <span>基本信息</span>
  5. </div>
  6. <el-form :model="form" :rules="rules" ref="ruleForm" label-width="0px">
  7. <div class="description-view">
  8. <table class="description-table">
  9. <tbody>
  10. <tr class="description-tr">
  11. <th class="description-label">姓名</th>
  12. <td class="description-content">
  13. <el-form-item prop="realName">
  14. <el-input v-model="form.realName" size="mini" placeholder="请输入姓名"/>
  15. </el-form-item>
  16. </td>
  17. <th class="description-label">手机号</th>
  18. <td class="description-content">
  19. <el-form-item prop="mobileNo">
  20. <el-input size="mini" v-model="form.mobileNo" placeholder="请输入手机号"/>
  21. </el-form-item>
  22. </td>
  23. <th class="description-label">微信号</th>
  24. <td class="description-content">
  25. <el-form-item prop="wechatNo">
  26. <el-input size="mini" v-model="form.wechatNo" placeholder="请输入微信号"/>
  27. </el-form-item>
  28. </td>
  29. </tr>
  30. <tr class="description-tr" v-for="(item, index) in educations" :key="index">
  31. <th class="description-label desc-item">
  32. <span class="close">
  33. <i v-if="index === 0" @click="addEducation" class="el-icon-circle-plus-outline"/>
  34. <i v-else @click="removeEducation(index)" class="el-icon-remove-outline"/>
  35. </span>学历</th>
  36. <td class="description-content">
  37. <el-form-item prop="level">
  38. <el-input v-model="educations[index].level" size="mini" placeholder="请输入学历"/>
  39. </el-form-item>
  40. </td>
  41. <th class="description-label">学校</th>
  42. <td class="description-content">
  43. <el-form-item prop="school">
  44. <el-input size="mini" v-model="educations[index].school" placeholder="请输入学校"/>
  45. </el-form-item>
  46. </td>
  47. <th class="description-label">毕业时间</th>
  48. <td class="description-content">
  49. <el-form-item prop="year">
  50. <el-date-picker
  51. type="month"
  52. placeholder="请选择毕业时间"
  53. size="mini"
  54. v-model="educations[index].year"
  55. />
  56. </el-form-item>
  57. </td>
  58. </tr>
  59. <tr class="description-tr">
  60. <th class="description-label">所在城市</th>
  61. <td class="description-content">
  62. <el-form-item prop="liveCity">
  63. <el-input size="mini" v-model.trim="form.liveCity" placeholder="请输入所在城市"/>
  64. </el-form-item>
  65. </td>
  66. <th class="description-label">工作意向</th>
  67. <td class="description-content">
  68. <el-form-item prop="intentionCity">
  69. <el-input size="mini" v-model.trim="form.intentionCity" placeholder="请输入工作意向"/>
  70. </el-form-item>
  71. </td>
  72. <th class="description-label">声部</th>
  73. <td class="description-content">
  74. <el-form-item prop="subjectId">
  75. <el-select
  76. v-model.trim="form.subjectId"
  77. clearable
  78. filterable
  79. size="mini"
  80. placeholder='请选择声部'
  81. >
  82. <el-option-group v-for="group in subjectList"
  83. :key="group.label"
  84. :label="group.label">
  85. <el-option v-for="item in group.options"
  86. :key="item.value"
  87. :label="item.label"
  88. :value="item.value">
  89. </el-option>
  90. </el-option-group>
  91. </el-select>
  92. </el-form-item>
  93. </td>
  94. </tr>
  95. <tr class="description-tr">
  96. <th class="description-label">是否经过评估</th>
  97. <td class="description-content">
  98. <el-form-item prop="isInterviewed">
  99. <el-select size="mini" v-model.trim="form.isInterviewed"
  100. clearable
  101. filterable
  102. placeholder="请选择是否经过评估">
  103. <el-option label="是"
  104. :value="true"></el-option>
  105. <el-option label="否"
  106. :value="false"></el-option>
  107. </el-select>
  108. </el-form-item>
  109. </td>
  110. <th class="description-label">其他综合情况</th>
  111. <td class="description-content" colspan="3">
  112. <el-form-item prop="otherComment">
  113. <el-input size="mini" v-model.trim="form.otherComment" placeholder="请输入其他综合情况"/>
  114. </el-form-item>
  115. </td>
  116. </tr>
  117. </tbody>
  118. </table>
  119. </div>
  120. <div class="description-title" style="margin-top: 20px">
  121. <span>在职信息</span>
  122. </div>
  123. <div class="description-view">
  124. <table class="description-table">
  125. <tbody>
  126. <tr class="description-tr">
  127. <th class="description-label">入职日期</th>
  128. <td class="description-content">
  129. <el-form-item prop="entryDate">
  130. <el-date-picker
  131. type="date"
  132. placeholder="选择入职日期"
  133. size="mini"
  134. v-model="form.entryDate"
  135. />
  136. </el-form-item>
  137. </td>
  138. <th class="description-label">职位</th>
  139. <td class="description-content">
  140. <el-form-item prop="position">
  141. <el-select v-model.trim="form.position"
  142. clearable
  143. filterable
  144. size="mini"
  145. placeholder="请选择职位">
  146. <el-option label="指导老师"
  147. value="ADVISER"></el-option>
  148. <el-option label="教务老师"
  149. value="ACADEMIC"></el-option>
  150. <el-option label="乐队指导"
  151. value="TEACHING"></el-option>
  152. </el-select>
  153. </el-form-item>
  154. </td>
  155. <th class="description-label">分部</th>
  156. <td class="description-content">
  157. <el-form-item prop="organId">
  158. <el-select v-model.trim="form.organId"
  159. placeholder='请选择分部'
  160. clearable
  161. filterable
  162. size="mini"
  163. >
  164. <el-option v-for='(item,index) in organList'
  165. :key="index"
  166. :value="item.id"
  167. :label="item.name"
  168. >
  169. </el-option>
  170. </el-select>
  171. </el-form-item>
  172. </td>
  173. </tr>
  174. <tr class="description-tr">
  175. <th class="description-label">员工类型</th>
  176. <td class="description-content">
  177. <el-form-item prop="jobNature">
  178. <el-select size="mini" v-model.trim="form.jobNature"
  179. clearable
  180. filterable
  181. placeholder="请选择员工类型">
  182. <el-option label="全职"
  183. value="FULL_TIME"></el-option>
  184. <el-option label="兼职"
  185. value="PART_TIME"></el-option>
  186. <el-option label="临时"
  187. value="TEMPORARY"></el-option>
  188. </el-select>
  189. </el-form-item>
  190. </td>
  191. <th class="description-label">员工状态</th>
  192. <td class="description-content">
  193. <el-form-item prop="isProbationPeriod">
  194. <el-select size="mini" v-model.trim="form.isProbationPeriod"
  195. clearable
  196. filterable
  197. placeholder="请选择员工状态">
  198. <el-option label="正式"
  199. :value="true"></el-option>
  200. <el-option label="试用"
  201. :value="false"></el-option>
  202. </el-select>
  203. </el-form-item>
  204. </td>
  205. <th class="description-label">离职日期</th>
  206. <td class="description-content">
  207. <el-form-item prop="resignationDate">
  208. <el-date-picker
  209. type="date"
  210. placeholder="选择离职日期"
  211. size="mini"
  212. v-model="form.resignationDate"
  213. />
  214. </el-form-item>
  215. </td>
  216. </tr>
  217. <tr class="description-tr">
  218. <th class="description-label">证件号码</th>
  219. <td class="description-content" colspan="5">
  220. <el-form-item prop="idCard">
  221. <el-input size="mini" v-model="form.idCard" placeholder="请输入证件号码"/>
  222. </el-form-item>
  223. </td>
  224. </tr>
  225. <tr class="description-tr">
  226. <th class="description-label">年龄</th>
  227. <td class="description-content">
  228. <el-form-item prop="age">
  229. <el-input v-model="form.age" size="mini" placeholder="请输入年龄"/>
  230. </el-form-item>
  231. </td>
  232. <th class="description-label">性别</th>
  233. <td class="description-content" colspan="3">
  234. <el-form-item prop="gender">
  235. <el-select size="mini" v-model.trim="form.gender"
  236. clearable
  237. filterable
  238. placeholder="请选择性别">
  239. <el-option label="男"
  240. :value="true"></el-option>
  241. <el-option label="女"
  242. :value="false"></el-option>
  243. </el-select>
  244. </el-form-item>
  245. </td>
  246. </tr>
  247. <tr class="description-tr">
  248. <th class="description-label">开户行</th>
  249. <td class="description-content">
  250. <el-form-item prop="bankAddress">
  251. <el-input size="mini" v-model="form.bankAddress" placeholder="请输入开户行"/>
  252. </el-form-item>
  253. </td>
  254. <th class="description-label">银行卡号</th>
  255. <td class="description-content" colspan="3">
  256. <el-form-item prop="bankCardNo">
  257. <el-input size="mini" v-model="form.bankCardNo" placeholder="请输入银行卡号"/>
  258. </el-form-item>
  259. </td>
  260. </tr>
  261. <tr class="description-tr">
  262. <th class="description-label">紧急联系人姓名</th>
  263. <td class="description-content">
  264. <el-form-item prop="emergencyContactName">
  265. <el-input size="mini" v-model.trim="form.emergencyContactName" placeholder="请输入紧急联系人姓名"/>
  266. </el-form-item>
  267. </td>
  268. <th class="description-label">紧急联系人关系</th>
  269. <td class="description-content">
  270. <el-form-item prop="emergencyContactRelation">
  271. <el-input size="mini" v-model.trim="form.emergencyContactRelation" placeholder="请输入紧急联系人关系"/>
  272. </el-form-item>
  273. </td>
  274. <th class="description-label">紧急联系人电话</th>
  275. <td class="description-content">
  276. <el-form-item prop="emergencyContactPhone">
  277. <el-input size="mini" v-model.trim="form.emergencyContactPhone" placeholder="请输入紧急联系人电话"/>
  278. </el-form-item>
  279. </td>
  280. </tr>
  281. </tbody>
  282. </table>
  283. </div>
  284. </el-form>
  285. <span class="dialog-footer">
  286. <el-button @click="close('ruleForm')">取 消</el-button>
  287. <el-button type="primary" class="main-button" @click="onTypeSubmit('ruleForm')">确 定</el-button>
  288. </span>
  289. </div>
  290. </template>
  291. <script>
  292. // import Vue from 'vue'
  293. import { employeeCreate, employeeUpdate } from '@/api/appTenant'
  294. import Descriptions from '@/components/Descriptions'
  295. // Vue.use(Descriptions)
  296. export default {
  297. name: 'hrform',
  298. props: ['detail', 'subjectList', 'organList', 'close'],
  299. components: {
  300. descriptions: Descriptions
  301. },
  302. data() {
  303. return {
  304. realName: '',
  305. form: {
  306. age: '',
  307. bankAddress: '',
  308. bankCardNo: '',
  309. birthdate: '',
  310. educationalBackground: '',
  311. emergencyContactName: '',
  312. emergencyContactPhone: '',
  313. emergencyContactRelation: '',
  314. entryDate: '',
  315. gender: true,
  316. idCard: '',
  317. intentionCity: '',
  318. isInterviewed: true,
  319. isProbationPeriod: true,
  320. jobNature: '',
  321. liveCity: '',
  322. mobileNo: '',
  323. otherComment: '',
  324. position: '',
  325. realName: '',
  326. resignationDate: '',
  327. subjectId: '',
  328. wechatNo: '',
  329. organId: '',
  330. },
  331. rules: {
  332. age: [
  333. { required: true, message: '请输入年龄', trigger: 'blur' },
  334. ],
  335. bankAddress: [
  336. { required: true, message: '请输入开户行', trigger: 'blur' },
  337. ],
  338. bankCardNo: [
  339. { required: true, message: '请输入卡号', trigger: 'blur' },
  340. ],
  341. birthdate: [
  342. { required: true, message: '请输入生日', trigger: 'blur' },
  343. ],
  344. // bankAddress: [
  345. // { required: true, message: '请输入年龄', trigger: 'blur' },
  346. // ],
  347. emergencyContactName: [
  348. { required: true, message: '请输入紧急联系人姓名', trigger: 'blur' },
  349. ],
  350. emergencyContactPhone: [
  351. { required: true, message: '请输入紧急联系人电话', trigger: 'blur' },
  352. ],
  353. emergencyContactRelation: [
  354. { required: true, message: '请输入紧急联系人关系', trigger: 'blur' },
  355. ],
  356. entryDate: [
  357. { required: true, message: '请输入入职日期', trigger: 'blur' },
  358. ],
  359. gender: [
  360. { required: true, message: '请选择性别', trigger: 'blur' },
  361. ],
  362. idCard: [
  363. { required: true, message: '请输入证件号码', trigger: 'blur' },
  364. ],
  365. intentionCity: [
  366. { required: true, message: '请输入工作意向', trigger: 'blur' },
  367. ],
  368. isInterviewed: [
  369. { required: true, message: '请选择是否经过评估', trigger: 'blur' },
  370. ],
  371. isProbationPeriod: [
  372. { required: true, message: '请选择员工状态', trigger: 'blur' },
  373. ],
  374. jobNature: [
  375. { required: true, message: '请选择员工类型', trigger: 'blur' },
  376. ],
  377. liveCity: [
  378. { required: true, message: '请输入所在城市', trigger: 'blur' },
  379. ],
  380. mobileNo: [
  381. { required: true, message: '请输入手机号', trigger: 'blur' },
  382. ],
  383. otherComment: [
  384. { required: true, message: '请输入其他综合情况', trigger: 'blur' },
  385. ],
  386. position: [
  387. { required: true, message: '请输入职位', trigger: 'blur' },
  388. ],
  389. realName: [
  390. { required: true, message: '请输入姓名', trigger: 'blur' },
  391. ],
  392. resignationDate: [
  393. { required: true, message: '请选择离职日期', trigger: 'blur' },
  394. ],
  395. subjectId: [
  396. { required: true, message: '请选择声部', trigger: 'blur' },
  397. ],
  398. organId: [
  399. { required: true, message: '请选择分部', trigger: 'blur' },
  400. ],
  401. wechatNo: [
  402. { required: true, message: '请输入微信号', trigger: 'blur' },
  403. ],
  404. level: [
  405. { required: true, message: '请输入学历', trigger: 'blur' },
  406. ],
  407. school: [
  408. { required: true, message: '请输入学校', trigger: 'blur' },
  409. ],
  410. year: [
  411. { required: true, message: '请选择毕业时间', trigger: 'blur' },
  412. ],
  413. },
  414. educations: [{level: '', school: '', year: ''}]
  415. }
  416. },
  417. watch: {
  418. detail() {
  419. this.updateData()
  420. },
  421. },
  422. mounted() {
  423. this.updateData()
  424. },
  425. methods: {
  426. updateData() {
  427. if (this.detail) {
  428. this.form = Object.assign({}, this.detail)
  429. try {
  430. this.educations = JSON.parse(this.detail.educationalBackground)
  431. if (!this.educations.length) {
  432. this.educations = [{level: '', school: '', year: ''}]
  433. }
  434. } catch (error) {}
  435. } else {
  436. this.educations = [{level: '', school: '', year: ''}]
  437. }
  438. },
  439. addEducation() {
  440. this.educations = [...this.educations, {level: '', school: '', year: ''}]
  441. },
  442. removeEducation(index) {
  443. this.educations[index] = null
  444. this.educations = this.educations.filter(item => !!item)
  445. },
  446. onTypeSubmit() {
  447. this.$refs['ruleForm'].validate(valid => {
  448. if (valid) {
  449. const { $message } = this
  450. this.form.educationalBackground = JSON.stringify(this.educations)
  451. if (this.detail) {
  452. employeeUpdate(Object.assign({id: this.detail.id}, this.form))
  453. .then(res => {
  454. if (res.code === 200) {
  455. $message.success('修改成功')
  456. this.close('ruleForm')
  457. }
  458. })
  459. } else {
  460. employeeCreate(this.form)
  461. .then(res => {
  462. if (res.code === 200) {
  463. $message.success('创建成功')
  464. this.close('ruleForm')
  465. }
  466. })
  467. }
  468. }
  469. })
  470. }
  471. }
  472. }
  473. </script>
  474. <style lang="less" scoped>
  475. .desc-item{
  476. position: relative;
  477. .close{
  478. position: absolute;
  479. left: 10px;
  480. cursor: pointer;
  481. }
  482. }
  483. .main-button{
  484. background-color: #14928a;
  485. border-color: #14928a;
  486. }
  487. .dialog-footer{
  488. display: block;
  489. text-align: right;
  490. margin-top: 20px;
  491. }
  492. .description-title {
  493. margin-bottom: 20px;
  494. color: rgba(0,0,0,.85);
  495. font-weight: 700;
  496. font-size: 16px;
  497. line-height: 1.5;
  498. }
  499. .description-view {
  500. width: 100%;
  501. border: 1px solid #e8e8e8;
  502. }
  503. .description-view .description-table {
  504. width: 100%;
  505. /* border: 1px solid #e8e8e8; */
  506. border-collapse: collapse;
  507. table-layout: fixed;
  508. }
  509. .description-view .description-tr {
  510. border-bottom: 1px solid #e8e8e8;
  511. width: 100%;
  512. }
  513. .description-view .description-tr:last-child {
  514. border-bottom: none;
  515. }
  516. .description-view .description-label {
  517. border-right: 1px solid #e8e8e8;
  518. background-color: #fafafa;
  519. color: rgba(0, 0, 0, 0.85);
  520. font-weight: 400;
  521. font-size: 14px;
  522. line-height: 22px;
  523. /* margin-right: 8px; */
  524. padding: 12px 16px;
  525. white-space: nowrap;
  526. display: table-cell;
  527. }
  528. .description-view .description-label:after {
  529. content: ""; /** content: ":" */
  530. margin: 0 8px 0 2px;
  531. position: relative;
  532. top: -0.5px;
  533. }
  534. .description-view .description-content {
  535. white-space: nowrap;
  536. overflow: hidden;
  537. text-overflow: ellipsis;
  538. border-right: 1px solid #e8e8e8;
  539. font-size: 14px;
  540. line-height: 1.5;
  541. padding: 12px 16px;
  542. padding-bottom: 0;
  543. color: rgba(0, 0, 0, 0.65);
  544. display: table-cell;
  545. }
  546. .description-tr .description-content:last-child {
  547. border-right: none;
  548. }
  549. </style>