form.vue 23 KB

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