AI 2 months ago
parent
commit
6be2946ab2
1 changed files with 58 additions and 36 deletions
  1. 58 36
      src/views/news/addJobHunting.vue

+ 58 - 36
src/views/news/addJobHunting.vue

@@ -763,35 +763,40 @@ export default {
       this.$refs.form.validate(valid => {
 
         if (valid) {
-          console.log(this.form)
-          this.form.job_experience = JSON.stringify(this.form.job_experience);
-          this.form.education_experience = JSON.stringify(this.form.education_experience);
-          this.form.skillList = JSON.stringify(this.form.skillList);
-          this.form.city_arr_id = JSON.stringify(this.form.city_arr_id);
-          this.form.cat_arr_id = JSON.stringify(this.form.cat_arr_id);
-          this.form.website_id = this.form.web_site_id == 0 ? this.websiteid : this.form.web_site_id;
-          //去掉this.form.web_site_id
-          delete this.form.web_site_id;
-          if (this.form.website_id == 0) {
+          // 创建 form 对象的深拷贝
+          const formCopy = JSON.parse(JSON.stringify(this.form));
+
+          // 在副本上进行 JSON 转换
+          formCopy.job_experience = JSON.stringify(formCopy.job_experience);
+          formCopy.education_experience = JSON.stringify(formCopy.education_experience);
+          formCopy.skillList = JSON.stringify(formCopy.skillList);
+          formCopy.city_arr_id = JSON.stringify(formCopy.city_arr_id);
+          formCopy.cat_arr_id = JSON.stringify(formCopy.cat_arr_id);
+          formCopy.website_id = formCopy.web_site_id == 0 ? this.websiteid : formCopy.web_site_id;
+          // 去掉 formCopy.web_site_id
+          delete formCopy.web_site_id;
+
+          if (formCopy.website_id == 0) {
             this.$message.error('请选择站点名称');
             return;
           }
 
-          if (this.form.jobtime != '' || this.form.jobtime != null) {
-            this.form.jobtime = formatLocalDate(this.form.jobtime);
+          if (formCopy.jobtime != '' || formCopy.jobtime != null) {
+            formCopy.jobtime = formatLocalDate(formCopy.jobtime);
           } else {
-            this.form.jobtime = null;
+            formCopy.jobtime = null;
           }
-          if (this.form.birth != '' || this.form.birth != null) {
-            this.form.birth = formatLocalDate(this.form.birth);
+          if (formCopy.birth != '' || formCopy.birth != null) {
+            formCopy.birth = formatLocalDate(formCopy.birth);
           } else {
-            this.form.birth = null;
+            formCopy.birth = null;
           }
-          this.form.job_timeList.forEach(item => {
+          formCopy.job_timeList.forEach(item => {
             item = formatLocalDate(item);
           });
+          console.log(new Date().getTime(), '-------------------校验结束------------------');
 
-          this.$store.dispatch('news/addJobHunting', this.form).then(res => {
+          this.$store.dispatch('news/addJobHunting', formCopy).then(res => {
             if (res.code == 200) {
               //汇报结果
               this.$message({
@@ -925,37 +930,54 @@ export default {
       //添加要修改的id
       this.form.id = this.editId;
       //先进行验证
+      let startTime = new Date().getTime();
+      console.log(startTime, '-------------------开始------------------');
       this.$refs.form.validate(valid => {
+        //记录开始时间
+        let startTime1 = new Date().getTime();
+        console.log(startTime1, '-------------------校验开始------------------');
         if (valid) {
           console.log(this.form)
-          this.form.job_experience = JSON.stringify(this.form.job_experience);
-          this.form.education_experience = JSON.stringify(this.form.education_experience);
-          this.form.skillList = JSON.stringify(this.form.skillList);
-          this.form.city_arr_id = JSON.stringify(this.form.city_arr_id);
-          this.form.cat_arr_id = JSON.stringify(this.form.cat_arr_id);
-          this.form.website_id = this.form.web_site_id == 0 ? this.websiteid : this.form.web_site_id;
-          //去掉this.form.web_site_id
-          delete this.form.web_site_id;
-          if (this.form.website_id == 0) {
+          // 创建 form 对象的深拷贝
+          const formCopy = JSON.parse(JSON.stringify(this.form));
+
+          // 在副本上进行 JSON 转换
+          formCopy.job_experience = JSON.stringify(formCopy.job_experience);
+          formCopy.education_experience = JSON.stringify(formCopy.education_experience);
+          formCopy.skillList = JSON.stringify(formCopy.skillList);
+          formCopy.city_arr_id = JSON.stringify(formCopy.city_arr_id);
+          formCopy.cat_arr_id = JSON.stringify(formCopy.cat_arr_id);
+          formCopy.website_id = formCopy.web_site_id == 0 ? this.websiteid : formCopy.web_site_id;
+          // 去掉 formCopy.web_site_id
+          delete formCopy.web_site_id;
+
+          if (formCopy.website_id == 0) {
             this.$message.error('请选择站点名称');
             return;
           }
 
-          if (this.form.jobtime != '' || this.form.jobtime != null) {
-            this.form.jobtime = formatLocalDate(this.form.jobtime);
+          if (formCopy.jobtime != '' || formCopy.jobtime != null) {
+            formCopy.jobtime = formatLocalDate(formCopy.jobtime);
           } else {
-            this.form.jobtime = null;
+            formCopy.jobtime = null;
           }
-          if (this.form.birth != '' || this.form.birth != null) {
-            this.form.birth = formatLocalDate(this.form.birth);
+          if (formCopy.birth != '' || formCopy.birth != null) {
+            formCopy.birth = formatLocalDate(formCopy.birth);
           } else {
-            this.form.birth = null;
+            formCopy.birth = null;
           }
-          this.form.job_timeList.forEach(item => {
+          formCopy.job_timeList.forEach(item => {
             item = formatLocalDate(item);
           });
-
-          this.$store.dispatch('news/updateJobHunting', this.form).then(res => {
+          console.log(new Date().getTime(), '-------------------校验结束------------------');
+
+          this.$store.dispatch('news/updateJobHunting', formCopy).then(res => {
+            //记录结束时间
+            let endTime = new Date().getTime(); //计算时间差
+            console.log(endTime, '-------------------结束------------------');
+            let time = endTime - this.startTime;
+            //记录时间差
+            console.log('时间差'.time, '------------------2--------');
             if (res.code != 200) {
               this.$message.error("修改失败,请稍后再试!");
             } else {