step-education.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <div class="education" id="education">
  3. <header class="sign-new-header">
  4. <div class="sign-new-header-title">教育经历</div>
  5. <span>
  6. <el-button @click="handleAdd" type="text" icon="el-icon-plus"
  7. >添加</el-button
  8. >
  9. </span>
  10. </header>
  11. <div v-if="education.length > 0">
  12. <template v-for="(item, idx) in education">
  13. <div
  14. v-if="editingItem.indexOf(idx) < 0"
  15. :key="item.university"
  16. class="show"
  17. >
  18. <h4>
  19. <span>{{
  20. `${item.start_time} - ${item.end_time || "至今"} ${
  21. item.university
  22. } ${item.major}`
  23. }}</span>
  24. <img
  25. @click="editItem(idx)"
  26. src="~/assets/img/svg/edit.svg"
  27. class="sign-edit-icon"
  28. />
  29. <!-- <el-button @click="editItem(idx)" type="text">编辑</el-button> -->
  30. </h4>
  31. <!-- <p>{{ item.description }}</p> -->
  32. </div>
  33. <div v-else :key="'education' + idx" class="edit">
  34. <el-form ref="form" :rules="rules" :model="item" label-width="147px">
  35. <div class="header">
  36. <date-range class="range" v-model="item.date"></date-range>
  37. <el-select
  38. v-model="item.university"
  39. allow-create
  40. filterable
  41. remote
  42. default-first-option
  43. placeholder="学校名称"
  44. :remote-method="fetchUniversity"
  45. :loading="loadingUniversity"
  46. >
  47. <el-option
  48. v-for="item in universities"
  49. :key="item.label"
  50. :label="item.label"
  51. :value="item.label"
  52. ></el-option>
  53. </el-select>
  54. <!-- reserve-keyword -->
  55. <el-select
  56. class="small"
  57. v-model="item.major"
  58. allow-create
  59. filterable
  60. remote
  61. default-first-option
  62. placeholder="选择专业"
  63. :remote-method="fetchMajor"
  64. :loading="loadingMajor"
  65. >
  66. <el-option
  67. v-for="item in majors"
  68. :key="item.label"
  69. :label="item.label"
  70. :value="item.label"
  71. ></el-option>
  72. </el-select>
  73. <el-select
  74. class="small"
  75. v-model="item.education_background"
  76. placeholder="学历"
  77. >
  78. <el-option
  79. v-for="educationBackground in educationBackgrounds"
  80. :key="educationBackground.value"
  81. :label="educationBackground.label"
  82. :value="educationBackground.label"
  83. ></el-option>
  84. </el-select>
  85. </div>
  86. <!-- <div>
  87. <el-input
  88. class="big"
  89. v-model="item.diploma_url"
  90. placeholder="请输入学信网在线验证报告地址"
  91. ></el-input>
  92. </div> -->
  93. <div class="content">
  94. <el-input
  95. type="textarea"
  96. :rows="7"
  97. maxlength="140"
  98. show-word-limit
  99. placeholder="经历简介(选填)"
  100. v-model="item.description"
  101. ></el-input>
  102. <!-- <uploader
  103. :imageUrl="item.diploma_photo"
  104. title="毕业证图片"
  105. @change="val => handleImageUrl(idx, val)"
  106. ></uploader> -->
  107. </div>
  108. <footer class="sign-new-form-footer">
  109. <div class="sign-new-form-tips">
  110. <!-- <p>学信网在线验证报告, 例如:https://www.proginn.com</p>
  111. <p>
  112. 注:学历证明可以是毕业证图片或学信网在线验证报告(二选一即可)
  113. </p> -->
  114. </div>
  115. <div class="sign-new-btn-area">
  116. <span class="opts">
  117. <el-button type="danger" @click="handleDelete(idx, item)"
  118. >删除</el-button
  119. >
  120. <el-button type="info" @click="handleCancel(idx, item)"
  121. >取消</el-button
  122. >
  123. <el-button type="primary" @click="handleConfirm(idx, item)"
  124. >保存</el-button
  125. >
  126. </span>
  127. </div>
  128. </footer>
  129. </el-form>
  130. </div>
  131. </template>
  132. </div>
  133. <div v-else class="empty">点击右上角“添加”按钮添加教育经历</div>
  134. </div>
  135. </template>
  136. <script>
  137. import uploader from "@/components/uploader";
  138. import dateRange from "@/components/date-range";
  139. import { mapState } from "vuex";
  140. export default {
  141. data() {
  142. return {
  143. // editing: true,
  144. editingModel: null,
  145. editingItem: [],
  146. rules: {
  147. name: ""
  148. },
  149. education: [],
  150. current: null,
  151. originEducation: [],
  152. universities: [],
  153. loadingUniversity: false,
  154. majors: [],
  155. loadingMajor: false,
  156. educationBackgrounds: [],
  157. init: {
  158. diploma_photo: "",
  159. diploma_url: "",
  160. start_time: "",
  161. end_time: "",
  162. date: [],
  163. university: "",
  164. major: "",
  165. education_background: "",
  166. description: ""
  167. }
  168. };
  169. },
  170. components: {
  171. uploader,
  172. dateRange
  173. },
  174. computed: {
  175. ...mapState(["userinfo"])
  176. },
  177. watch: {
  178. education: function(val) {
  179. this.$emit("educationChange", val);
  180. }
  181. },
  182. async mounted() {
  183. this.getData();
  184. this.getEducationBackground();
  185. },
  186. methods: {
  187. async onSubmit(idx) {
  188. console.log("submit!", this.education);
  189. if (this.education.length > 10) {
  190. this.$message.error("最多可添加10项工作经历!");
  191. }
  192. const data = this.education.map(it => {
  193. let item1 = {
  194. diploma_photo: it.diploma_photo,
  195. diploma_url: it.diploma_url,
  196. start_time: it.date[0],
  197. end_time: it.date[1],
  198. university: it.university,
  199. major: it.major,
  200. education_background: it.education_background,
  201. description: it.description
  202. };
  203. if (it.id) {
  204. item1.id = it.id;
  205. }
  206. return item1;
  207. });
  208. const res = await this.$axios.$post("/api/user_education/save_all", {
  209. data: JSON.stringify(data)
  210. });
  211. if (res.status === 1) {
  212. this.$message.success("保存成功!");
  213. this.getData();
  214. return true;
  215. } else {
  216. this.$message.error(res.info);
  217. return false;
  218. }
  219. },
  220. async getData() {
  221. const res = await this.$axios.$post("/api/user_education/list");
  222. const data = res.data || [];
  223. const education = data.map(it => ({
  224. ...it,
  225. date: [it.start_time || "", it.end_time || ""]
  226. }));
  227. console.log("education", education);
  228. this.education = education;
  229. },
  230. async getEducationBackground() {
  231. const res = await this.$axios.$post(
  232. "/api/simple_data/select_education_background"
  233. );
  234. const data = res.data || [];
  235. this.educationBackgrounds = data.map(it => ({
  236. value: it.id,
  237. label: it.name
  238. }));
  239. },
  240. async fetchUniversity(keyword) {
  241. console.log(keyword);
  242. this.loadingUniversity = true;
  243. const res = await this.$axios.$post(
  244. "/api/simple_data/select_university",
  245. { keyword }
  246. );
  247. this.loadingUniversity = false;
  248. const data = res.data || [];
  249. this.universities = data.map(it => ({ value: it.id, label: it.name }));
  250. },
  251. async fetchMajor(keyword) {
  252. console.log(keyword);
  253. this.loadingMajor = true;
  254. const res = await this.$axios.$post("/api/simple_data/select_major", {
  255. keyword
  256. });
  257. this.loadingMajor = false;
  258. const data = res.data || [];
  259. this.majors = data.map(it => ({ value: it.id, label: it.name }));
  260. },
  261. handleRankClose() {
  262. this.rankForm = {
  263. first: ""
  264. };
  265. },
  266. handleRank() {
  267. this.rankDialog = false;
  268. },
  269. handleAdd() {
  270. if (this.userinfo && this.userinfo.realname_verify_status === "0") {
  271. this.$message.error("请先进行实名认证");
  272. return;
  273. }
  274. if (
  275. this.editingItem.length > 0 &&
  276. !this.education[this.editingItem[0]].id
  277. ) {
  278. this.$message.error("请先保存现有修改");
  279. return;
  280. }
  281. const _init = JSON.parse(JSON.stringify(this.init));
  282. this.education.push(_init);
  283. this.editingModel = _init;
  284. this.editingItem = [this.education.length - 1];
  285. },
  286. handleImageUrl(idx, url) {
  287. this.education[idx].diploma_photo = url;
  288. },
  289. async handleDelete(idx) {
  290. this.editingItem = [];
  291. this.education.splice(idx, 1);
  292. this.editingModel = null;
  293. await this.onSubmit();
  294. },
  295. handleCancel(idx, item) {
  296. if (!item.id) {
  297. this.education.splice(idx, 1);
  298. } else {
  299. this.education.splice(idx, 1, this.editingModel);
  300. }
  301. this.editingItem = [];
  302. this.editingModel = null;
  303. },
  304. handleConfirm(idx, item) {
  305. this.cnzz("签约", "签约页面+教育经历保存", "");
  306. // const item = this.education.slice(idx, idx + 1)[0];
  307. if (!item.date) {
  308. this.$message.error("请设置开始时间/结束时间!");
  309. return;
  310. } else if (
  311. item.date &&
  312. item.date[0] &&
  313. item.date[1] &&
  314. item.date[0] > item.date[1]
  315. ) {
  316. this.$message.error("请设置开始时间小于结束时间!");
  317. return;
  318. }
  319. if (!item.university || !item.major || !item.education_background) {
  320. this.$message.error("请设置学校名称/专业/学历!");
  321. return;
  322. }
  323. // if (item.description !== "" && item.description.length < 15) {
  324. // this.$message.error("教育经历不得低于15个字符");
  325. // return;
  326. // }
  327. if (item.description.length > 140) {
  328. this.$message.error("教育经历不得多于140个字符");
  329. return;
  330. }
  331. // if (!item.diploma_url && !item.diploma_photo) {
  332. // this.$message.error("请提供学历证明!");
  333. // return;
  334. // }
  335. this.editingItem = [];
  336. // const submitItem = {
  337. // ...item,
  338. // start_time: item.date[0],
  339. // end_time: item.date[1]
  340. // };
  341. this.onSubmit();
  342. },
  343. editItem(idx) {
  344. if (this.userinfo && this.userinfo.realname_verify_status === "0") {
  345. this.$message.error("请先进行实名认证");
  346. return;
  347. }
  348. this.editingItem = [idx];
  349. const origin = this.education.slice(idx, idx + 1)[0];
  350. this.editingModel = JSON.parse(JSON.stringify(origin));
  351. }
  352. }
  353. };
  354. </script>
  355. <style lang="scss" scoped>
  356. .education {
  357. .sign-edit-icon {
  358. margin-right: 20px;
  359. }
  360. .header .el-icon-plus {
  361. font-size: 18px;
  362. }
  363. .edit {
  364. padding: 20px 0;
  365. > form {
  366. .header {
  367. display: flex;
  368. align-items: center;
  369. justify-content: space-between;
  370. margin-bottom: 10px;
  371. }
  372. .range {
  373. margin-right: 10px;
  374. }
  375. .opts {
  376. display: flex;
  377. align-items: center;
  378. .el-button {
  379. margin-left: 5px;
  380. }
  381. }
  382. .el-select,
  383. .el-input {
  384. width: 136px;
  385. margin-right: 10px;
  386. .el-input--suffix .el-input__inner {
  387. padding-right: 0;
  388. }
  389. }
  390. .small {
  391. width: 140px;
  392. }
  393. .big {
  394. width: 100%;
  395. }
  396. .times {
  397. .el-checkbox {
  398. width: 88px;
  399. }
  400. .el-input {
  401. width: 160px;
  402. }
  403. }
  404. .content {
  405. display: flex;
  406. justify-content: space-between;
  407. align-items: flex-start;
  408. margin-top: 10px;
  409. .el-textarea {
  410. display: flex;
  411. // width: 620px;
  412. // height: 162px;
  413. height: 80px;
  414. }
  415. }
  416. }
  417. }
  418. .show {
  419. // padding: 18px 0;
  420. border-bottom: 1px solid #ebeef5;
  421. h4 {
  422. display: flex;
  423. justify-content: space-between;
  424. align-items: center;
  425. height: 60px;
  426. line-height: 60px;
  427. font-size: 15px;
  428. font-family: PingFangSC-Regular, PingFang SC;
  429. font-weight: 400;
  430. color: #0b121a;
  431. }
  432. p {
  433. word-break: break-all;
  434. margin-top: 8px;
  435. font-size: 14px;
  436. font-family: PingFangSC-Regular;
  437. font-weight: 400;
  438. color: rgba(102, 102, 102, 1);
  439. line-height: 24px;
  440. }
  441. }
  442. .empty {
  443. margin: 112px auto 104px;
  444. font-size: 27px;
  445. font-family: PingFangSC-Regular;
  446. font-weight: 400;
  447. text-align: center;
  448. color: rgba(205, 205, 205, 1);
  449. line-height: 38px;
  450. }
  451. footer p {
  452. margin-top: 15px;
  453. font-size: 12px;
  454. font-family: PingFangSC-Regular;
  455. font-weight: 400;
  456. color: rgba(145, 154, 167, 1);
  457. line-height: 17px;
  458. }
  459. }
  460. </style>