step-education.vue 13 KB

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