step-info.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  1. <template>
  2. <div class="sign-new-info">
  3. <div class="sign-new-tips">
  4. 基本信息能让客栈和客户迅速了解你!信息完善将会优先派单!
  5. </div>
  6. <div class="edit">
  7. <el-form
  8. ref="form"
  9. :rules="rules"
  10. :model="form"
  11. label-width="100px"
  12. label-position="left"
  13. >
  14. <el-form-item label="昵称" prop="nickname">
  15. <el-input
  16. v-model="form.nickname"
  17. maxlength="50"
  18. style="width:340px"
  19. ></el-input>
  20. </el-form-item>
  21. <el-form-item label="工作状态" prop="type">
  22. <el-select
  23. v-model="form.type"
  24. placeholder="请选择"
  25. style="width:340px"
  26. >
  27. <el-option
  28. v-for="typeItem in types"
  29. :key="typeItem.value"
  30. :label="typeItem.label"
  31. :value="typeItem.value"
  32. ></el-option>
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="职业方向" prop="direction_op">
  36. <el-select
  37. v-model="form.occupation_op"
  38. placeholder="请选择"
  39. style="width:340px"
  40. >
  41. <el-option
  42. v-for="item in directions"
  43. :key="item.occupation_id"
  44. :label="item.occupation_name"
  45. :value="item.occupation_id"
  46. ></el-option>
  47. </el-select>
  48. <el-select
  49. v-model="form.direction_op"
  50. placeholder="请选择"
  51. style="width:340px"
  52. >
  53. <el-option
  54. v-for="item in subDirections"
  55. :key="item.direction_id"
  56. :label="item.direction_name"
  57. :value="item.direction_id"
  58. ></el-option>
  59. </el-select>
  60. </el-form-item>
  61. <el-form-item label="所在地区" prop="city_op_id">
  62. <el-select
  63. v-model="form.province_op_id"
  64. placeholder="请选择"
  65. @change="getCities"
  66. style="width:340px"
  67. >
  68. <el-option
  69. v-for="item in provinces"
  70. :key="item.id"
  71. :label="item.name"
  72. :value="item.id"
  73. ></el-option>
  74. </el-select>
  75. <el-select
  76. v-model="form.city_op_id"
  77. placeholder="请选择"
  78. style="width:340px"
  79. >
  80. <el-option
  81. v-for="item in cities"
  82. :key="item.id"
  83. :label="item.name"
  84. :value="item.id"
  85. ></el-option>
  86. </el-select>
  87. </el-form-item>
  88. <el-form-item label="可接受日薪" prop="work_price">
  89. <el-input-number
  90. :min="300"
  91. :max="2000"
  92. controls-position="right"
  93. v-model="form.work_price"
  94. :style="{ width: '340px', marginRight: '10px' }"
  95. ></el-input-number
  96. >元/天(8小时-远程)
  97. </el-form-item>
  98. <el-form-item label="可工作时间" prop="workday">
  99. <div class="times">
  100. <el-checkbox v-model="form.workday" label="工作日"></el-checkbox>
  101. <el-time-select
  102. v-model="form.workdayStart"
  103. :picker-options="{
  104. start: '00:00',
  105. step: '00:30',
  106. end: '24:00'
  107. }"
  108. placeholder="开始时间"
  109. ></el-time-select>
  110. <span class="to">至</span>
  111. <el-time-select
  112. v-model="form.workdayEnd"
  113. :picker-options="{
  114. start: '00:00',
  115. step: '00:30',
  116. end: '24:00'
  117. }"
  118. placeholder="结束时间"
  119. ></el-time-select>
  120. </div>
  121. <div class="times">
  122. <el-checkbox v-model="form.weekend" label="周末"></el-checkbox>
  123. <el-time-select
  124. v-model="form.weekendStart"
  125. :picker-options="{
  126. start: '00:00',
  127. step: '00:30',
  128. end: '24:00'
  129. }"
  130. placeholder="开始时间"
  131. ></el-time-select>
  132. <span class="to">至</span>
  133. <el-time-select
  134. v-model="form.weekendEnd"
  135. :picker-options="{
  136. start: '00:00',
  137. step: '00:30',
  138. end: '24:00'
  139. }"
  140. placeholder="结束时间"
  141. ></el-time-select>
  142. </div>
  143. </el-form-item>
  144. </el-form>
  145. </div>
  146. <div class="sign-new-next">
  147. <div
  148. class="sign-new-next-btn"
  149. :class="{
  150. disable: !canNext
  151. }"
  152. @click="nextStep"
  153. >
  154. 下一步
  155. </div>
  156. </div>
  157. </div>
  158. </template>
  159. <script>
  160. import { mapState } from "vuex";
  161. const types = [
  162. {
  163. value: "2",
  164. label: "求职"
  165. },
  166. {
  167. value: "4",
  168. label: "自由职业"
  169. },
  170. {
  171. value: "5",
  172. label: "正常工作"
  173. }
  174. ];
  175. export default {
  176. data() {
  177. return {
  178. rules: {
  179. nickname: [
  180. {
  181. required: true,
  182. message: "请完善昵称信息",
  183. trigger: "blur"
  184. },
  185. { max: 50, message: "昵称不得超过50字符", trigger: "blur" },
  186. {
  187. validator: (rule, value, callback) => {
  188. console.log(this.regPhone);
  189. if (this.regPhone.test(value)) {
  190. callback(new Error("请不要使用手机号作为昵称"));
  191. } else {
  192. callback();
  193. }
  194. },
  195. trigger: "blur"
  196. },
  197. {
  198. validator: (rule, value, callback) => {
  199. if (this.regSpecialChar.test(value)) {
  200. callback(new Error("昵称不得使用特殊字符"));
  201. } else {
  202. callback();
  203. }
  204. },
  205. trigger: "blur"
  206. }
  207. ],
  208. type: [
  209. {
  210. required: true,
  211. message: "请设置当前工作状态",
  212. trigger: "change"
  213. }
  214. ],
  215. direction_op: [
  216. {
  217. required: true,
  218. validator: (rule, value, callback) => {
  219. if (!this.form.direction_op || !this.form.occupation_op) {
  220. callback(new Error("请设置职业方向信息"));
  221. } else {
  222. callback();
  223. }
  224. },
  225. trigger: "change"
  226. }
  227. ],
  228. city_op_id: [
  229. {
  230. required: true,
  231. validator: (rule, value, callback) => {
  232. if (!this.form.city_op_id || !this.form.occupation_op) {
  233. callback(new Error("请设置所在地区信息"));
  234. } else {
  235. callback();
  236. }
  237. },
  238. trigger: "change"
  239. }
  240. ],
  241. work_price: [
  242. {
  243. required: true,
  244. message: "请设置日薪",
  245. trigger: "blur"
  246. },
  247. {
  248. validator: (rule, value, callback) => {
  249. if (value < 300 || value > 2000) {
  250. callback(new Error("日薪只允许设置300--2000范围内的正整数"));
  251. } else {
  252. callback();
  253. }
  254. },
  255. trigger: "blur"
  256. }
  257. ],
  258. workday: [
  259. {
  260. required: true,
  261. validator: (rule, value, callback) => {
  262. console.log(value);
  263. if (!this.form.workday && !this.form.weekend) {
  264. callback(new Error("请完善可工作时间"));
  265. } else if (
  266. (this.form.workday &&
  267. (!this.form.workdayStart || !this.form.workdayEnd)) ||
  268. (this.form.weekend &&
  269. (!this.form.weekendStart || !this.form.weekendEnd))
  270. ) {
  271. callback(new Error("请完善可工作时间"));
  272. } else {
  273. console.log(this.$refs.form);
  274. callback();
  275. }
  276. },
  277. trigger: "change"
  278. }
  279. ],
  280. weekend: [
  281. {
  282. validator: (rule, value, callback) => {
  283. if (!value && !this.form.workday) {
  284. callback(new Error("请完善可工作时间"));
  285. } else if (
  286. value &&
  287. (!this.form.weekendStart || !this.form.weekendEnd)
  288. ) {
  289. callback(new Error("请完善周末可工作时间"));
  290. } else {
  291. callback();
  292. }
  293. },
  294. trigger: "change"
  295. }
  296. ]
  297. },
  298. userInfo: {},
  299. form: {
  300. nickname: "",
  301. type: "",
  302. work_price: 300,
  303. occupation_op: "",
  304. direction_op: "",
  305. address: ["", ""],
  306. region: "",
  307. workday: true,
  308. weekend: false,
  309. workdayStart: "",
  310. workdayEnd: "",
  311. weekendStart: "",
  312. weekendEnd: "",
  313. dailyRate: "",
  314. workdayTime: "",
  315. province_op_id: "",
  316. city_op_id: ""
  317. },
  318. editing: false,
  319. types,
  320. directions: [],
  321. regions: [],
  322. provinces: [],
  323. cities: []
  324. };
  325. },
  326. computed: {
  327. ...mapState(["regPhone", "regSpecialChar"]),
  328. subDirections: function() {
  329. let direction = this.form.occupation_op;
  330. let current = null;
  331. this.directions.map(dir => {
  332. if (dir.occupation_id === direction) {
  333. current = dir;
  334. }
  335. });
  336. if (!current) {
  337. return [];
  338. }
  339. return current.children;
  340. },
  341. typeShow: function() {
  342. const types = this.types;
  343. const type = this.form.type;
  344. let show = "-";
  345. for (let i = 0, len = types.length; i < len; i++) {
  346. if (types[i].value == type) {
  347. show = `${types[i].label}`;
  348. }
  349. }
  350. return show;
  351. },
  352. occupationShow: function() {
  353. const directions = this.directions;
  354. let show = "-";
  355. for (let i = 0, len = directions.length; i < len; i++) {
  356. if (directions[i].occupation_id == this.form.occupation_op) {
  357. const subs = directions[i].children;
  358. for (let j = 0, len = subs.length; j < len; j++) {
  359. if (subs[j].direction_id == this.form.direction_op) {
  360. show = `${directions[i].occupation_name} - ${subs[j].direction_name}`;
  361. }
  362. }
  363. }
  364. }
  365. return show;
  366. },
  367. provinceShow: function() {
  368. const directions = this.directions;
  369. let show = "-";
  370. for (let i = 0, len = directions.length; i < len; i++) {
  371. if (directions[i].occupation_id == this.type) {
  372. show = `${directions[i].occupation_name}`;
  373. }
  374. }
  375. return show;
  376. },
  377. canNext() {
  378. let {
  379. nickname,
  380. occupation_op,
  381. direction_op,
  382. city_op_id,
  383. city_op,
  384. work_price,
  385. workdayEnd,
  386. workdayStart,
  387. weekendEnd,
  388. weekendStart
  389. } = this.form;
  390. let condition =
  391. nickname !== "" &&
  392. occupation_op !== "" &&
  393. direction_op !== "" &&
  394. work_price !== "" &&
  395. workdayEnd !== "" &&
  396. workdayStart !== "" &&
  397. weekendEnd !== "" &&
  398. weekendStart !== "" &&
  399. city_op_id !== "" &&
  400. city_op !== "";
  401. return condition;
  402. }
  403. },
  404. watch: {
  405. "form.occupation_op": function() {
  406. if (this.form.occupation_op !== this.userInfo.occupation_op) {
  407. this.form.direction_op = "";
  408. }
  409. }
  410. },
  411. async mounted() {
  412. this.userInfo = await this.getUserInfo();
  413. const user = this.userInfo;
  414. console.log(user);
  415. this.form.nickname = user.nickname;
  416. this.form.type = user.type && user.type !== "0" ? user.type : "";
  417. this.form.occupation_op =
  418. user.occupation_op && user.occupation_op !== "0"
  419. ? user.occupation_op
  420. : "";
  421. this.form.direction_op =
  422. user.direction_op && user.direction_op !== "0" ? user.direction_op : "";
  423. this.form.work_price = user.work_price;
  424. this.form.province_op_id =
  425. user.province_op_id && user.province_op_id !== "0"
  426. ? user.province_op_id
  427. : "";
  428. this.form.city_op_id =
  429. user.city_op_id && user.city_op_id !== "0" ? user.city_op_id : "";
  430. const work_time_op = user.work_time_op;
  431. if (work_time_op) {
  432. if (work_time_op.weekend) {
  433. this.form.weekend = true;
  434. this.form.weekendStart = work_time_op.weekend[0];
  435. this.form.weekendEnd = work_time_op.weekend[1];
  436. } else {
  437. this.form.weekend = false;
  438. }
  439. if (work_time_op.workday) {
  440. this.form.workday = true;
  441. this.form.workdayStart = work_time_op.workday[0];
  442. this.form.workdayEnd = work_time_op.workday[1];
  443. } else {
  444. this.form.workday = false;
  445. }
  446. }
  447. this.getDirection();
  448. this.getProvinces();
  449. this.form.province_op_id = this.form.province_op_id
  450. ? this.form.province_op_id
  451. : "";
  452. if (this.form.province_op_id) {
  453. this.getCities(this.form.province_op_id, true);
  454. }
  455. },
  456. created() {
  457. this.cnzz("签约流程", "基本信息", "访问");
  458. },
  459. methods: {
  460. async nextStep() {
  461. if (!this.canNext) {
  462. this.cnzz("签约流程", "基本信息(下一步)", "失败");
  463. return;
  464. }
  465. this.cnzz("签约流程", "基本信息(下一步)", "成功");
  466. await this.onSubmit();
  467. this.$emit("next");
  468. },
  469. async onSubmit() {
  470. this.$refs["form"].validate(async valid => {
  471. if (!valid) {
  472. // this.$message.error("填写有误");
  473. return false;
  474. }
  475. const form = this.form;
  476. const work_time_op = {};
  477. if (form.weekend) {
  478. work_time_op.weekend = [form.weekendStart, form.weekendEnd];
  479. }
  480. if (form.workday) {
  481. work_time_op.workday = [form.workdayStart, form.workdayEnd];
  482. }
  483. const data = {
  484. work_time_op: JSON.stringify(work_time_op),
  485. province_op_id: this.form.province_op_id,
  486. city_op_id: this.form.city_op_id,
  487. // district_op_name: '',
  488. // work_time_per_work: '',
  489. // work_remote: '',
  490. // work_area: '',
  491. // province_op: '', // 远程工作
  492. work_price: form.work_price,
  493. nickname: form.nickname,
  494. type: form.type,
  495. occupation_op: form.occupation_op,
  496. direction_op: form.direction_op
  497. };
  498. const res = await this.$axios.$post("/api/user/update_info", data);
  499. if (res.status === 1) {
  500. this.$message.success("保存成功!");
  501. this.editing = false;
  502. this.cnzz("签约流程", "基本信息(下一步)", "服务器OK");
  503. } else {
  504. this.cnzz("签约流程", "基本信息(下一步)", "服务器FAIL");
  505. // this.$message.error(res.info);
  506. }
  507. });
  508. },
  509. async getDirection() {
  510. const res = await this.$axios.$post("/api/direction/get_all_data");
  511. this.directions = res.data || [];
  512. },
  513. async getProvinces() {
  514. const res = await this.$axios.$post("/api/geo/get_province_list");
  515. this.provinces = res.data || [];
  516. },
  517. async getCities(id, flag) {
  518. if (!flag) {
  519. this.form.city_op_id = "";
  520. }
  521. const res = await this.$axios.$post(
  522. "/api/geo/get_city_list_by_province",
  523. { prov_id: id }
  524. );
  525. this.cities = res.data || [];
  526. this.form.city_op = res.data[0].id;
  527. },
  528. async onCancel() {
  529. this.form.nickname = this.userInfo.nickname;
  530. this.form.type = this.userInfo.type;
  531. this.form.occupation_op = this.userInfo.occupation_op;
  532. this.form.direction_op = this.userInfo.direction_op;
  533. this.form.work_price = this.userInfo.work_price;
  534. let work_time_op = this.userInfo.work_time_op;
  535. if (work_time_op.weekend) {
  536. this.form.weekend = true;
  537. this.form.weekendStart = work_time_op.weekend[0];
  538. this.form.weekendEnd = work_time_op.weekend[1];
  539. } else {
  540. this.form.weekend = false;
  541. }
  542. if (work_time_op.workday) {
  543. this.form.workday = true;
  544. this.form.workdayStart = work_time_op.workday[0];
  545. this.form.workdayEnd = work_time_op.workday[1];
  546. } else {
  547. this.form.workday = false;
  548. }
  549. }
  550. }
  551. };
  552. </script>
  553. <style lang="scss" scoped>
  554. .sign-new-info {
  555. .edit {
  556. margin-top: 60px;
  557. & > form {
  558. margin-top: 44px;
  559. .el-select,
  560. .el-input {
  561. width: 217px;
  562. margin-right: 10px;
  563. }
  564. .times {
  565. margin-bottom: 20px;
  566. .el-checkbox {
  567. width: 88px;
  568. }
  569. .to {
  570. margin-right: 10px;
  571. }
  572. .el-input {
  573. width: 136px;
  574. }
  575. }
  576. }
  577. }
  578. }
  579. </style>