step-education.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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="(keyword)=> fetchUniversity(keyword, idx)"
  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="(keyword)=> fetchMajor(keyword, idx)"
  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 {
  207. ...it,
  208. ...item1
  209. };
  210. });
  211. const res = await this.$axios.$post("/api/user_education/save_all", {
  212. data: JSON.stringify(data)
  213. });
  214. if (res.status === 1) {
  215. this.$message.success("保存成功!");
  216. this.getData();
  217. return true;
  218. } else {
  219. return false;
  220. }
  221. },
  222. async getData() {
  223. const res = await this.$axios.$post("/api/user_education/list");
  224. const data = res.data || [];
  225. const education = data.map(it => ({
  226. ...it,
  227. date: [it.start_time || "", it.end_time || ""]
  228. }));
  229. console.log("education", education);
  230. this.education = education;
  231. },
  232. async getEducationBackground() {
  233. const res = await this.$axios.$post(
  234. "/api/simple_data/select_education_background"
  235. );
  236. const data = res.data || [];
  237. this.educationBackgrounds = data.map(it => ({
  238. value: it.id,
  239. label: it.name
  240. }));
  241. },
  242. async fetchUniversity(keyword,index) {
  243. this.education[index].university=keyword;
  244. this.loadingUniversity = true;
  245. const res = await this.$axios.$post(
  246. "/api/simple_data/select_university",
  247. { keyword }
  248. );
  249. this.loadingUniversity = false;
  250. const data = res.data || [];
  251. this.universities = data.map(it => ({ value: it.id, label: it.name }));
  252. },
  253. async fetchMajor(keyword,index) {
  254. this.education[index].major=keyword;
  255. this.loadingMajor = true;
  256. const res = await this.$axios.$post("/api/simple_data/select_major", {
  257. keyword
  258. });
  259. this.loadingMajor = false;
  260. const data2 = res.data || [];
  261. this.majors = data2.map(it => ({ value: it.id, label: it.name }));
  262. },
  263. handleRankClose() {
  264. this.rankForm = {
  265. first: ""
  266. };
  267. },
  268. handleRank() {
  269. this.rankDialog = false;
  270. },
  271. handleAdd() {
  272. if (this.userinfo && this.userinfo.realname_verify_status === "0") {
  273. this.$message.error("请先进行实名认证");
  274. return;
  275. }
  276. if (
  277. this.editingItem.length > 0 &&
  278. !this.education[this.editingItem[0]].id
  279. ) {
  280. this.$message.error("请先保存现有修改");
  281. return;
  282. }
  283. const _init = JSON.parse(JSON.stringify(this.init));
  284. this.education.push(_init);
  285. this.editingModel = _init;
  286. this.editingItem = [this.education.length - 1];
  287. },
  288. handleImageUrl(idx, url) {
  289. this.education[idx].diploma_photo = url;
  290. },
  291. async handleDelete(idx) {
  292. this.editingItem = [];
  293. this.education.splice(idx, 1);
  294. this.editingModel = null;
  295. await this.onSubmit();
  296. },
  297. handleCancel(idx, item) {
  298. if (!item.id) {
  299. this.education.splice(idx, 1);
  300. } else {
  301. this.education.splice(idx, 1, this.editingModel);
  302. }
  303. this.editingItem = [];
  304. this.editingModel = null;
  305. },
  306. handleConfirm(idx, item) {
  307. this.cnzz("签约", "签约页面+教育经历保存", "");
  308. // const item = this.education.slice(idx, idx + 1)[0];
  309. if (!item.date) {
  310. this.$message.error("请设置开始时间/结束时间!");
  311. return;
  312. } else if (
  313. item.date &&
  314. item.date[0] &&
  315. item.date[1] &&
  316. item.date[0] > item.date[1]
  317. ) {
  318. this.$message.error("请设置开始时间小于结束时间!");
  319. return;
  320. }
  321. if (!item.university || !item.major || !item.education_background) {
  322. this.$message.error("请设置学校名称/专业/学历!");
  323. return;
  324. }
  325. // if (item.description !== "" && item.description.length < 15) {
  326. // this.$message.error("教育经历不得低于15个字符");
  327. // return;
  328. // }
  329. if (item.description.length > 140) {
  330. this.$message.error("教育经历不得多于140个字符");
  331. return;
  332. }
  333. // if (!item.diploma_url && !item.diploma_photo) {
  334. // this.$message.error("请提供学历证明!");
  335. // return;
  336. // }
  337. // const submitItem = {
  338. // ...item,
  339. // start_time: item.date[0],
  340. // end_time: item.date[1]
  341. // };
  342. let bool=this.onSubmit();
  343. if(bool)
  344. {
  345. this.editingItem = [];
  346. }
  347. },
  348. editItem(idx) {
  349. if (this.userinfo && this.userinfo.realname_verify_status === "0") {
  350. this.$message.error("请先进行实名认证");
  351. return;
  352. }
  353. this.editingItem = [idx];
  354. const origin = this.education.slice(idx, idx + 1)[0];
  355. this.editingModel = JSON.parse(JSON.stringify(origin));
  356. }
  357. }
  358. };
  359. </script>
  360. <style lang="scss" scoped>
  361. .education {
  362. .sign-edit-icon {
  363. margin-right: 20px;
  364. }
  365. .header .el-icon-plus {
  366. font-size: 18px;
  367. }
  368. .edit {
  369. padding: 20px 0;
  370. > form {
  371. .header {
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. margin-bottom: 10px;
  376. }
  377. .range {
  378. margin-right: 10px;
  379. }
  380. .opts {
  381. display: flex;
  382. align-items: center;
  383. .el-button {
  384. margin-left: 5px;
  385. }
  386. }
  387. .el-select,
  388. .el-input {
  389. width: 136px;
  390. margin-right: 10px;
  391. .el-input--suffix .el-input__inner {
  392. padding-right: 0;
  393. }
  394. }
  395. .small {
  396. width: 140px;
  397. }
  398. .big {
  399. width: 100%;
  400. }
  401. .times {
  402. .el-checkbox {
  403. width: 88px;
  404. }
  405. .el-input {
  406. width: 160px;
  407. }
  408. }
  409. .content {
  410. display: flex;
  411. justify-content: space-between;
  412. align-items: flex-start;
  413. margin-top: 10px;
  414. .el-textarea {
  415. display: flex;
  416. // width: 620px;
  417. // height: 162px;
  418. height: 80px;
  419. }
  420. }
  421. }
  422. }
  423. .show {
  424. // padding: 18px 0;
  425. border-bottom: 1px solid #ebeef5;
  426. h4 {
  427. display: flex;
  428. justify-content: space-between;
  429. align-items: center;
  430. height: 60px;
  431. line-height: 60px;
  432. font-size: 15px;
  433. font-family: PingFangSC-Regular, PingFang SC;
  434. font-weight: 400;
  435. color: #0b121a;
  436. }
  437. p {
  438. word-break: break-all;
  439. margin-top: 8px;
  440. font-size: 14px;
  441. font-family: PingFangSC-Regular;
  442. font-weight: 400;
  443. color: rgba(102, 102, 102, 1);
  444. line-height: 24px;
  445. }
  446. }
  447. .empty {
  448. margin: 112px auto 104px;
  449. font-size: 27px;
  450. font-family: PingFangSC-Regular;
  451. font-weight: 400;
  452. text-align: center;
  453. color: rgba(205, 205, 205, 1);
  454. line-height: 38px;
  455. }
  456. footer p {
  457. margin-top: 15px;
  458. font-size: 12px;
  459. font-family: PingFangSC-Regular;
  460. font-weight: 400;
  461. color: rgba(145, 154, 167, 1);
  462. line-height: 17px;
  463. }
  464. }
  465. </style>