| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502 |
- <template>
- <div class="info">
- <header>
- <h5>基本信息</h5>
- <div class="opts">
- <el-button type="info" @click="onCancel">取消</el-button>
- <el-button type="primary" @click="onSubmit">保存</el-button>
- </div>
- </header>
- <div class="edit">
- <el-form ref="form" :rules="rules" :model="form" label-width="147px">
- <el-form-item label="昵称" prop="nickname">
- <el-input v-model="form.nickname" maxlength="50"></el-input>
- </el-form-item>
- <el-form-item label="工作状态" prop="type">
- <el-select v-model="form.type" placeholder="请选择">
- <el-option
- v-for="type in types"
- :key="type.value"
- :label="type.label"
- :value="type.value"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="职业方向" prop="direction_op">
- <el-select v-model="form.occupation_op" placeholder="请选择">
- <el-option
- v-for="item in directions"
- :key="item.occupation_id"
- :label="item.occupation_name"
- :value="item.occupation_id"
- ></el-option>
- </el-select>
- <el-select v-model="form.direction_op" placeholder="请选择">
- <el-option
- v-for="item in subDirections"
- :key="item.direction_id"
- :label="item.direction_name"
- :value="item.direction_id"
- ></el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="所在地区" prop="city_op_id">
- <el-select v-model="form.province_op_id" placeholder="请选择" @change="getCities">
- <el-option v-for="item in provinces" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- <!-- <el-date-picker
- type="date"
- placeholder="选择日期"
- v-model="form.date1"
- style="width: 100%;"
- ></el-date-picker>-->
- <el-select v-model="form.city_op_id" placeholder="请选择">
- <el-option v-for="item in cities" :key="item.id" :label="item.name" :value="item.id"></el-option>
- </el-select>
- <!-- <el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker> -->
- </el-form-item>
- <el-form-item label="日薪" prop="work_price">
- <el-input-number
- :min="300"
- :max="2000"
- controls-position="right"
- v-model="form.work_price"
- :style="{width: '150px', marginRight: '10px'}"
- ></el-input-number>元/天(8小时)
- </el-form-item>
- <el-form-item label="可工作时间" prop="workday">
- <div class="times">
- <el-checkbox v-model="form.workday" label="工作日"></el-checkbox>
- <el-time-select
- v-model="form.workdayStart"
- :picker-options="{
- start: '00:00',
- step: '00:30',
- end: '24:00'
- }"
- placeholder="开始时间"
- ></el-time-select>
- <span class="to">至</span>
- <el-time-select
- v-model="form.workdayEnd"
- :picker-options="{
- start: '00:00',
- step: '00:30',
- end: '24:00'
- }"
- placeholder="结束时间"
- ></el-time-select>
- </div>
- <div class="times">
- <el-checkbox v-model="form.weekend" label="周末"></el-checkbox>
- <el-time-select
- v-model="form.weekendStart"
- :picker-options="{
- start: '00:00',
- step: '00:30',
- end: '24:00'
- }"
- placeholder="开始时间"
- ></el-time-select>
- <span class="to">至</span>
- <el-time-select
- v-model="form.weekendEnd"
- :picker-options="{
- start: '00:00',
- step: '00:30',
- end: '24:00'
- }"
- placeholder="结束时间"
- ></el-time-select>
- </div>
- </el-form-item>
- </el-form>
- </div>
- </div>
- </template>
- <script>
- import { mapState } from "vuex";
- const types = [
- {
- value: "2",
- label: "求职"
- },
- {
- value: "4",
- label: "自由职业"
- },
- {
- value: "5",
- label: "正常工作"
- }
- ];
- export default {
- data() {
- return {
- rules: {
- nickname: [
- {
- required: true,
- message: "请完善昵称信息",
- trigger: "blur"
- },
- { max: 50, message: "昵称不得超过50字符", trigger: "blur" },
- {
- validator: (rule, value, callback) => {
- console.log(this.regPhone);
- if (this.regPhone.test(value)) {
- callback(new Error("请不要使用手机号作为昵称"));
- } else {
- callback();
- }
- },
- trigger: "blur"
- },
- {
- validator: (rule, value, callback) => {
- if (this.regSpecialChar.test(value)) {
- callback(new Error("昵称不得使用特殊字符"));
- } else {
- callback();
- }
- },
- trigger: "blur"
- }
- ],
- type: [
- {
- required: true,
- message: "请设置当前工作状态",
- trigger: "change"
- }
- ],
- direction_op: [
- {
- required: true,
- validator: (rule, value, callback) => {
- if (!this.form.direction_op || !this.form.occupation_op) {
- callback(new Error("请设置职业方向信息"));
- } else {
- callback();
- }
- },
- trigger: "change"
- }
- ],
- city_op_id: [
- {
- required: true,
- validator: (rule, value, callback) => {
- if (!this.form.city_op_id || !this.form.occupation_op) {
- callback(new Error("请设置所在地区信息"));
- } else {
- callback();
- }
- },
- trigger: "change"
- }
- ],
- work_price: [
- {
- required: true,
- message: "请设置日薪",
- trigger: "blur"
- },
- {
- validator: (rule, value, callback) => {
- if (value < 300 || value > 2000) {
- callback(new Error("日薪只允许设置300--2000范围内的正整数"));
- } else {
- callback();
- }
- },
- trigger: "blur"
- }
- ],
- workday: [
- {
- required: true,
- validator: (rule, value, callback) => {
- console.log(value);
- if (!this.form.workday && !this.form.weekend) {
- callback(new Error("请完善可工作时间"));
- } else if (
- (this.form.workday &&
- (!this.form.workdayStart || !this.form.workdayEnd)) ||
- (this.form.weekend &&
- (!this.form.weekendStart || !this.form.weekendEnd))
- ) {
- callback(new Error("请完善可工作时间"));
- } else {
- console.log(this.$refs.form);
- callback();
- }
- },
- trigger: "change"
- }
- ],
- weekend: [
- {
- validator: (rule, value, callback) => {
- if (!value && !this.form.workday) {
- callback(new Error("请完善可工作时间"));
- } else if (
- value &&
- (!this.form.weekendStart || !this.form.weekendEnd)
- ) {
- callback(new Error("请完善周末可工作时间"));
- } else {
- callback();
- }
- },
- trigger: "change"
- }
- ]
- },
- userInfo: {},
- form: {
- nickname: "",
- type: "",
- work_price: 300,
- occupation_op: "",
- direction_op: "",
- address: ["", ""],
- region: "",
- workday: true,
- weekend: false,
- workdayStart: "",
- workdayEnd: "",
- weekendStart: "",
- weekendEnd: "",
- dailyRate: "",
- workdayTime: "",
- province_op_id: "",
- city_op_id: ""
- },
- editing: false,
- types,
- directions: [],
- regions: [],
- provinces: [],
- cities: []
- };
- },
- computed: {
- ...mapState(["regPhone", "regSpecialChar"]),
- subDirections: function() {
- let direction = this.form.occupation_op;
- let current = null;
- this.directions.map(dir => {
- if (dir.occupation_id === direction) {
- current = dir;
- }
- });
- if (!current) {
- return [];
- }
- return current.children;
- },
- typeShow: function() {
- const types = this.types;
- const type = this.form.type;
- let show = "-";
- for (let i = 0, len = types.length; i < len; i++) {
- if (types[i].value == type) {
- show = `${types[i].label}`;
- }
- }
- return show;
- },
- occupationShow: function() {
- const directions = this.directions;
- let show = "-";
- for (let i = 0, len = directions.length; i < len; i++) {
- if (directions[i].occupation_id == this.form.occupation_op) {
- const subs = directions[i].children;
- for (let j = 0, len = subs.length; j < len; j++) {
- if (subs[j].direction_id == this.form.direction_op) {
- show = `${directions[i].occupation_name} - ${subs[j].direction_name}`;
- }
- }
- }
- }
- return show;
- },
- provinceShow: function() {
- const directions = this.directions;
- let show = "-";
- for (let i = 0, len = directions.length; i < len; i++) {
- if (directions[i].occupation_id == this.type) {
- show = `${directions[i].occupation_name}`;
- }
- }
- return show;
- }
- },
- watch: {
- "form.occupation_op": function() {
- if (this.form.occupation_op !== this.userInfo.occupation_op) {
- this.userInfo.occupation_op=this.form.occupation_op;
- this.form.direction_op = "";
- }
- }
- },
- async mounted() {
- this.userInfo = await this.getUserInfo();
- const user = this.userInfo;
- console.log(user);
- this.form.nickname = user.nickname;
- this.form.type = user.type && user.type !== "0" ? user.type : "";
- this.form.occupation_op =
- user.occupation_op && user.occupation_op !== "0"
- ? user.occupation_op
- : "";
- this.form.direction_op =
- user.direction_op && user.direction_op !== "0" ? user.direction_op : "";
- this.form.work_price = user.work_price;
- this.form.province_op_id =
- user.province_op_id && user.province_op_id !== "0"
- ? user.province_op_id
- : "";
- this.form.city_op_id =
- user.city_op_id && user.city_op_id !== "0" ? user.city_op_id : "";
- const work_time_op = user.work_time_op;
- if (work_time_op) {
- if (work_time_op.weekend) {
- this.form.weekend = true;
- this.form.weekendStart = work_time_op.weekend[0];
- this.form.weekendEnd = work_time_op.weekend[1];
- } else {
- this.form.weekend = false;
- }
- if (work_time_op.workday) {
- this.form.workday = true;
- this.form.workdayStart = work_time_op.workday[0];
- this.form.workdayEnd = work_time_op.workday[1];
- } else {
- this.form.workday = false;
- }
- }
- this.getDirection();
- this.getProvinces();
- this.form.province_op_id = this.form.province_op_id
- ? this.form.province_op_id
- : "";
- if (this.form.province_op_id) {
- this.getCities(this.form.province_op_id, true);
- }
- },
- methods: {
- async onSubmit() {
- this.cnzz("签约","签约页面+基本信息保存","");
- //console.log("submit!");
- this.$refs["form"].validate(async valid => {
- if (!valid) {
- // this.$message.error("填写有误");
- return false;
- }
- const form = this.form;
- const work_time_op = {};
- if (form.weekend) {
- work_time_op.weekend = [form.weekendStart, form.weekendEnd];
- }
- if (form.workday) {
- work_time_op.workday = [form.workdayStart, form.workdayEnd];
- }
- const data = {
- work_time_op: JSON.stringify(work_time_op),
- province_op_id: this.form.province_op_id,
- city_op_id: this.form.city_op_id,
- // district_op_name: '',
- // work_time_per_work: '',
- // work_remote: '',
- // work_area: '',
- // province_op: '', // 远程工作
- work_price: form.work_price,
- nickname: form.nickname,
- type: form.type,
- occupation_op: form.occupation_op,
- direction_op: form.direction_op
- };
- const res = await this.$axios.$post("/api/user/update_info", data);
- if (res.status === 1) {
- this.$message.success("保存成功!");
- this.editing = false;
- } else {
- // this.$message.error(res.info);
- }
- });
- },
- async getDirection() {
- const res = await this.$axios.$post("/api/direction/get_all_data");
- this.directions = res.data || [];
- },
- async getProvinces() {
- const res = await this.$axios.$post("/api/geo/get_province_list");
- this.provinces = res.data || [];
- },
- async getCities(id, flag) {
- if (!flag) {
- this.form.city_op_id = "";
- }
- const res = await this.$axios.$post(
- "/api/geo/get_city_list_by_province",
- { prov_id: id }
- );
- this.cities = res.data || [];
- this.form.city_op = res.data[0].id;
- },
- async onCancel() {
- this.form.nickname = this.userInfo.nickname;
- this.form.type = this.userInfo.type;
- this.form.occupation_op = this.userInfo.occupation_op;
- this.form.direction_op = this.userInfo.direction_op;
- this.form.work_price = this.userInfo.work_price;
- let work_time_op = this.userInfo.work_time_op;
- if (work_time_op.weekend) {
- this.form.weekend = true;
- this.form.weekendStart = work_time_op.weekend[0];
- this.form.weekendEnd = work_time_op.weekend[1];
- } else {
- this.form.weekend = false;
- }
- if (work_time_op.workday) {
- this.form.workday = true;
- this.form.workdayStart = work_time_op.workday[0];
- this.form.workdayEnd = work_time_op.workday[1];
- } else {
- this.form.workday = false;
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .info {
- .edit {
- > form {
- margin-top: 44px;
- .el-select,
- .el-input {
- width: 217px;
- margin-right: 10px;
- }
- .times {
- margin-bottom: 20px;
- .el-checkbox {
- width: 88px;
- }
- .to {
- margin-right: 10px;
- }
- .el-input {
- width: 136px;
- }
- }
- }
- }
- }
- </style>
|