|
|
@@ -9,10 +9,10 @@
|
|
|
</header>
|
|
|
<div class="edit">
|
|
|
<el-form ref="form" :rules="rules" :model="form" label-width="147px">
|
|
|
- <el-form-item label="昵称">
|
|
|
- <el-input v-model="form.nickname" maxLength="50"></el-input>
|
|
|
+ <el-form-item label="昵称" prop="nickname">
|
|
|
+ <el-input v-model="form.nickname" maxlength="50"></el-input>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="工作状态">
|
|
|
+ <el-form-item label="工作状态" prop="type">
|
|
|
<el-select v-model="form.type" placeholder="请选择">
|
|
|
<el-option
|
|
|
v-for="type in types"
|
|
|
@@ -22,7 +22,7 @@
|
|
|
></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="职业方向">
|
|
|
+ <el-form-item label="职业方向" prop="direction_op">
|
|
|
<el-select v-model="form.occupation_op" placeholder="请选择">
|
|
|
<el-option
|
|
|
v-for="item in directions"
|
|
|
@@ -40,14 +40,9 @@
|
|
|
></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="所在地区">
|
|
|
+ <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-option v-for="item in provinces" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
|
|
</el-select>
|
|
|
<!-- <el-date-picker
|
|
|
type="date"
|
|
|
@@ -56,16 +51,11 @@
|
|
|
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-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="日薪">
|
|
|
+ <el-form-item label="日薪" prop="work_price">
|
|
|
<el-input-number
|
|
|
:min="300"
|
|
|
:max="2000"
|
|
|
@@ -74,7 +64,7 @@
|
|
|
:style="{width: '150px', marginRight: '10px'}"
|
|
|
></el-input-number>元/天(8小时)
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="可工作时间">
|
|
|
+ <el-form-item label="可工作时间" prop="workday">
|
|
|
<div class="times">
|
|
|
<el-checkbox v-model="form.workday" label="工作日"></el-checkbox>
|
|
|
<el-time-select
|
|
|
@@ -97,6 +87,8 @@
|
|
|
placeholder="结束时间"
|
|
|
></el-time-select>
|
|
|
</div>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="weekend">
|
|
|
<div class="times">
|
|
|
<el-checkbox v-model="form.weekend" label="周末"></el-checkbox>
|
|
|
<el-time-select
|
|
|
@@ -126,6 +118,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import { mapState } from "vuex";
|
|
|
const types = [
|
|
|
{
|
|
|
value: "2",
|
|
|
@@ -144,9 +137,103 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
rules: {
|
|
|
- nickname: ""
|
|
|
+ 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: "blur"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ address: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请设置所在地区信息",
|
|
|
+ trigger: "blur"
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ 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: [
|
|
|
+ {
|
|
|
+ validator: (rule, value, callback) => {
|
|
|
+ console.log(value);
|
|
|
+ if (!value && !this.form.weekend) {
|
|
|
+ callback(new Error("请完善可工作时间"));
|
|
|
+ } else if (
|
|
|
+ value &&
|
|
|
+ (!this.form.workdayStart || !this.form.workdayEnd)
|
|
|
+ ) {
|
|
|
+ callback(new Error("请完善工作日可工作时间"));
|
|
|
+ } else {
|
|
|
+ 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:{},
|
|
|
+ userInfo: {},
|
|
|
form: {
|
|
|
nickname: "",
|
|
|
type: "",
|
|
|
@@ -163,18 +250,19 @@ export default {
|
|
|
weekendEnd: "",
|
|
|
dailyRate: "",
|
|
|
workdayTime: "",
|
|
|
- province_op_id:'',
|
|
|
- city_op_id:''
|
|
|
+ province_op_id: "",
|
|
|
+ city_op_id: ""
|
|
|
},
|
|
|
editing: false,
|
|
|
types,
|
|
|
directions: [],
|
|
|
regions: [],
|
|
|
- provinces:[],
|
|
|
- cities:[]
|
|
|
+ provinces: [],
|
|
|
+ cities: []
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
+ ...mapState(["regPhone", "regSpecialChar"]),
|
|
|
subDirections: function() {
|
|
|
let direction = this.form.occupation_op;
|
|
|
let current = null;
|
|
|
@@ -239,100 +327,114 @@ export default {
|
|
|
this.form.occupation_op = this.userInfo.occupation_op;
|
|
|
this.form.direction_op = this.userInfo.direction_op;
|
|
|
this.form.work_price = this.userInfo.work_price;
|
|
|
- this.form.province_op_id=this.userInfo.province_op_id;
|
|
|
- this.form.city_op_id=this.userInfo.city_op_id;
|
|
|
+ this.form.province_op_id = this.userInfo.province_op_id;
|
|
|
+ this.form.city_op_id = this.userInfo.city_op_id;
|
|
|
const work_time_op = this.userInfo.work_time_op;
|
|
|
- if (work_time_op){
|
|
|
+ if (work_time_op) {
|
|
|
if (work_time_op.weekend) {
|
|
|
- this.form.weekend=true;
|
|
|
+ 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;
|
|
|
+ } else {
|
|
|
+ this.form.weekend = false;
|
|
|
}
|
|
|
- if (work_time_op.workday){
|
|
|
- this.form.workday=true;
|
|
|
+ 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;
|
|
|
+ } else {
|
|
|
+ this.form.workday = false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
this.getDirection();
|
|
|
this.getProvinces();
|
|
|
- this.form.province_op_id=this.form.province_op_id?this.form.province_op_id:10;
|
|
|
- this.getCities(this.form.province_op_id);
|
|
|
+ this.form.province_op_id = this.form.province_op_id
|
|
|
+ ? this.form.province_op_id
|
|
|
+ : 10;
|
|
|
+ this.getCities(this.form.province_op_id, true);
|
|
|
},
|
|
|
methods: {
|
|
|
async onSubmit() {
|
|
|
//console.log("submit!");
|
|
|
- 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);
|
|
|
- }
|
|
|
+ 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(){
|
|
|
+ async getProvinces() {
|
|
|
const res = await this.$axios.$post("/api/geo/get_province_list");
|
|
|
this.provinces = res.data || [];
|
|
|
},
|
|
|
- async getCities(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 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(){
|
|
|
- console.log(this.userInfo);
|
|
|
- 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;
|
|
|
- }
|
|
|
+ async onCancel() {
|
|
|
+ console.log(this.userInfo);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
};
|