Explorar o código

关闭浏览器自动保存

yuanyiming hai 1 ano
pai
achega
8bd139b113

+ 278 - 238
src/views/activityManage/newMarkerActivity.vue

@@ -1,253 +1,293 @@
 <template>
-    <!-- 测试上传组件 -->
-    <div v-loading="loading" id="MakerActivityWord">
-      <div class="pAHeader">
-        <div class="pAHeader1">创客活动申请</div>
-      </div>
-      <hr>
-         <!-- 创客专项资金及项目申请表(创客活动) -->
-        <markeractivityWord :wordData="wordData" :total="total"/>
-        <div style="position: fixed;bottom: 5%;right: 2%;">
-          <el-button type="primary" @click="test">提交活动</el-button>
-        </div>
-        <el-dialog
-          title="提示"
-          :visible.sync="submitHint"
-          width="600px"
-          class="pageSubmitData">
-          
-          <div class="deleteContent">确定提交“{{wordData['activityName']}}”创客活动吗?</div>
-          <span slot="footer" class="dialog-footer">
-            <el-button type="primary" @click="applyActivity" class="AllDialogBtn">确认提交</el-button>
-            <el-button @click="submitHint=false" class="AllDialogBtn">取消</el-button>
-          </span>
-        </el-dialog>
+  <!-- 测试上传组件 -->
+  <div v-loading="loading" id="MakerActivityWord">
+    <div class="pAHeader">
+      <div class="pAHeader1">创客活动申请</div>
+    </div>
+    <hr />
+    <!-- 创客专项资金及项目申请表(创客活动) -->
+    <markeractivityWord :wordData="wordData" :total="total" />
+    <div style="position: fixed; bottom: 5%; right: 2%">
+      <el-button type="primary" @click="test">提交活动</el-button>
     </div>
-  </template>
-  
-  <script>
-  import markeractivityWord from './components/markeractivityWord.vue';
-  import {getNowDate} from '@/components/tool/Date.js'
-  import getProjectNo from '@/components/tool/getProjectNo';
-  export default {
-    components: {
-      markeractivityWord
+    <el-dialog
+      title="提示"
+      :visible.sync="submitHint"
+      width="600px"
+      class="pageSubmitData"
+    >
+      <div class="deleteContent">
+        确定提交“{{ wordData["activityName"] }}”创客活动吗?
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="applyActivity" class="AllDialogBtn"
+          >确认提交</el-button
+        >
+        <el-button @click="submitHint = false" class="AllDialogBtn"
+          >取消</el-button
+        >
+      </span>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import markeractivityWord from "./components/markeractivityWord.vue";
+import { getNowDate } from "@/components/tool/Date.js";
+import getProjectNo from "@/components/tool/getProjectNo";
+export default {
+  components: {
+    markeractivityWord,
+  },
+  data() {
+    return {
+      loading: false,
+      submitHint: false,
+      wordData: {
+        applicationDate: getNowDate(1), //申请日期
+        associatedProjects: "", //关联项目
+        activityName: "", //项目名称
+        pro_leader: "", //活动负责人
+        college: "", //所在学院
+        tel: "", //联系电话
+        activityTime: [], //活动时间
+        student: 0, //参与学生人数
+        member: [
+          { name: "", collage: "", work: "" },
+          { name: "", collage: "", work: "" },
+          { name: "", collage: "", work: "" },
+        ],
+        activityPlan: "", //活动计划
+        expectations: "", //预期目标
+        eventAudience: "", //活动受众面
+        fundingPlan: "", //经费支出计划
+        expenditureMothPlan: ["", "", "", "", "", "", "", "", "", "", "", ""],
+        fund: {
+          device: "",
+          Material: "",
+          processing: "",
+          Collaboration: "",
+          APPRAISAL: "",
+          entery: "",
+          activities: "",
+          Transaction: "",
+        }, //预算经费
+      },
+    };
+  },
+  computed: {
+    total() {
+      let num = 0;
+      for (let i in this.wordData["fund"])
+        num += Number(this.wordData["fund"][i]);
+      return num;
     },
-    data() {
-      return {
-        loading:false,
-        submitHint:false,
-        wordData:{
-          applicationDate:getNowDate(1),//申请日期
-          associatedProjects:"",//关联项目
-          activityName:'',//项目名称
-          pro_leader:"",//活动负责人
-          college: '',//所在学院
-          tel:'',//联系电话
-          activityTime:[],//活动时间
-          student:0,//参与学生人数
-          member:[
-            {name:"",collage:"",work:""},
-            {name:"",collage:"",work:""},
-            {name:"",collage:"",work:""},
-          ],
-          activityPlan:"",//活动计划
-          expectations:"",//预期目标
-          eventAudience:"",//活动受众面
-          fundingPlan:"",//经费支出计划
-          expenditureMothPlan:['','','','','','','','','','','',''],
-          fund:{
-            device:"",
-            Material:"",
-            processing:"",
-            Collaboration:"",
-            APPRAISAL:"",
-            entery:"",
-            activities:"",
-            Transaction:"",
-          },//预算经费
+  },
+  methods: {
+    // changeFund(newFund){
+    //   this.wordData['allFund'] = newFund;
+    // },
+    test() {
+      const cEmpty = /^\s*$/g;
+      const checkPhone =
+        /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/; //获取正则表达式 存放到verify变量中
+      for (let i in this.wordData) {
+        switch (i) {
+          // case "associatedProjects":
+          //   if(cEmpty.test(this.wordData[i])){
+          //     this.$message.error("请选择关联项目")
+          //     document.querySelector('#one').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
+          case "activityName":
+            if (cEmpty.test(this.wordData[i])) {
+              this.$message.error("请输入活动名称");
+              document
+                .querySelector("#two")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          case "pro_leader":
+            if (cEmpty.test(this.wordData[i])) {
+              this.$message.error("请输入活动负责人");
+              document
+                .querySelector("#three")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          case "college":
+            if (cEmpty.test(this.wordData[i])) {
+              this.$message.error("请选择所在学院");
+              document
+                .querySelector("#three")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          case "tel":
+            if (cEmpty.test(this.wordData[i])) {
+              this.$message.error("请输入联系电话");
+              document
+                .querySelector("#three")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            } else if (!checkPhone.test(this.wordData[i])) {
+              this.$message.error("请输入正确的手机号");
+              document
+                .querySelector("#three")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          case "activityTime":
+            if (this.wordData[i].length <= 0) {
+              this.$message.error("请选择活动时间");
+              document
+                .querySelector("#four")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          case "allFund":
+            console.log(11111);
+            if (this.total <= 0) {
+              this.$message.error("请输入预算经费");
+              document
+                .querySelector("#fund")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          // case "member":
+          //     let num = 0;
+          //     this.wordData[i].forEach(item=>{
+          //       if(cEmpty.test(item['name']))num++;
+          //       // for(let j in item){
+          //       //   if(cEmpty.test(item[j])){
+          //       //     num++;
+          //       //   }
+          //       // }
+
+          //     })
+          //     if(num>0){
+          //       this.$message.error("指导老师姓名不能为空");
+          //       document.querySelector('#five').scrollIntoView({ behavior: "smooth" });
+          //       return false;
+          //     }
+          //   break;
+          // case "activityPlan":
+          //   if(cEmpty.test(this.wordData[i][0])){
+          //     this.$message.error("请输入活动计划");
+          //     document.querySelector('#six').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
+          // case "expectations":
+          //   if(cEmpty.test(this.wordData[i][0])){
+          //     this.$message.error("预期目标");
+          //     document.querySelector('#seven').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
+          // case "eventAudience":
+          //   if(cEmpty.test(this.wordData[i][0])){
+          //     this.$message.error("活动受众面")
+          //     document.querySelector('#nine').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
+          // case "fundingPlan":
+          //   if(cEmpty.test(this.wordData[i][0])){
+          //     this.$message.error("经费支出计划")
+          //     document.querySelector('#ten').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
         }
-      };
-    },
-    computed:{
-      total() {
-            let num = 0;
-            for(let i in this.wordData['fund'])num += Number(this.wordData['fund'][i]);
-            return num;
-          }
+      }
+      // if()
+      this.submitHint = true;
     },
-    methods: {
-      // changeFund(newFund){
-      //   this.wordData['allFund'] = newFund;
-      // },
-      test(){
-          const cEmpty = /^\s*$/g;
-          const checkPhone = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/; //获取正则表达式 存放到verify变量中
-          for(let i in this.wordData){
-            switch(i){
-              // case "associatedProjects":
-              //   if(cEmpty.test(this.wordData[i])){
-              //     this.$message.error("请选择关联项目")
-              //     document.querySelector('#one').scrollIntoView({ behavior: "smooth" });
-              //     return false;
-              //   }
-              //   break;
-              case "activityName":
-                if(cEmpty.test(this.wordData[i])){
-                  this.$message.error("请输入活动名称")
-                  document.querySelector('#two').scrollIntoView({ behavior: "smooth" });
-                  return false;
-                }
-                break;
-              case "pro_leader":
-                if(cEmpty.test(this.wordData[i])){
-                  this.$message.error("请输入活动负责人")
-                  document.querySelector('#three').scrollIntoView({ behavior: "smooth" });
-                  return false;
-                }
-                break;
-              case "college":
-                if(cEmpty.test(this.wordData[i])){
-                  this.$message.error("请选择所在学院")
-                  document.querySelector('#three').scrollIntoView({ behavior: "smooth" });
-                  return false;;
-                }
-                break;
-              case "tel":
-                if(cEmpty.test(this.wordData[i])){
-                  this.$message.error("请输入联系电话")
-                  document.querySelector('#three').scrollIntoView({ behavior: "smooth" });
-                  return false;
-                }else if(!checkPhone.test(this.wordData[i])){
-                  this.$message.error("请输入正确的手机号");
-                  document.querySelector('#three').scrollIntoView({ behavior: "smooth" });
-                  return false;
-                }
-                break;
-                case "activityTime":
-                  if(this.wordData[i].length<=0){
-                    this.$message.error("请选择活动时间")
-                    document.querySelector('#four').scrollIntoView({ behavior: "smooth" });
-                    return false;;
-                  }
-                  break;
-                case "allFund":
-                  console.log(11111)
-                  if(this.total<=0){
-                    this.$message.error('请输入预算经费')
-                    document.querySelector('#fund').scrollIntoView({ behavior: "smooth" });
-                    return false;
-                  }
-                  break;
-              // case "member":
-              //     let num = 0;
-              //     this.wordData[i].forEach(item=>{
-              //       if(cEmpty.test(item['name']))num++;
-              //       // for(let j in item){
-              //       //   if(cEmpty.test(item[j])){
-              //       //     num++;
-              //       //   }
-              //       // }
-                  
-              //     })
-              //     if(num>0){
-              //       this.$message.error("指导老师姓名不能为空");
-              //       document.querySelector('#five').scrollIntoView({ behavior: "smooth" });
-              //       return false;
-              //     }
-              //   break;
-              // case "activityPlan":
-              //   if(cEmpty.test(this.wordData[i][0])){
-              //     this.$message.error("请输入活动计划");
-              //     document.querySelector('#six').scrollIntoView({ behavior: "smooth" });
-              //     return false;
-              //   }
-              //   break;
-              // case "expectations":
-              //   if(cEmpty.test(this.wordData[i][0])){
-              //     this.$message.error("预期目标");
-              //     document.querySelector('#seven').scrollIntoView({ behavior: "smooth" });
-              //     return false;
-              //   }
-              //   break;
-              // case "eventAudience":
-              //   if(cEmpty.test(this.wordData[i][0])){
-              //     this.$message.error("活动受众面")
-              //     document.querySelector('#nine').scrollIntoView({ behavior: "smooth" });
-              //     return false;
-              //   }
-              //   break;
-              // case "fundingPlan":
-              //   if(cEmpty.test(this.wordData[i][0])){
-              //     this.$message.error("经费支出计划")
-              //     document.querySelector('#ten').scrollIntoView({ behavior: "smooth" });
-              //     return false;
-              //   }
-              //   break;
-            }
-          }
-          // if()
-          this.submitHint = true;
-      },
-      applyActivity(){
-        getProjectNo("HD").then(result=>{
-          let pram = {
-            uid:this.$store.state.userInfo.userid,//用户ID
-            aNo:result,//活动编号
-            tit:this.wordData['activityName'],//活动名称
-            courseId:this.wordData['associatedProjects'],//关联项目ID
-            pLeader:this.wordData['pro_leader'],//活动负责人
-            mon:this.total,//预算经费
-            st:this.wordData['student'],//参与学生人数
-            ct:JSON.stringify(this.wordData['member']),//活动指导老师
-            chp:JSON.stringify({
-              activityPlan:this.wordData['activityName'],//活动计划
-              expectations:this.wordData['expectations'],//预期目标
-              eventAudience:this.wordData['eventAudience'],//活动受众面
-              fundingPlan:this.wordData['fundingPlan'],//经费支出计划
-            }),//活动信息
-            cid:this.wordData['college'],//学院ID,
-            ph:this.wordData['tel'],//联系电话
-            beg:JSON.stringify(this.wordData['activityTime']),//活动时间
-            f:JSON.stringify(this.wordData['fund']),//预算经费明细
-            appltTime:this.wordData['applicationDate'],//申请日期
-            mp:JSON.stringify(this.wordData['expenditureMothPlan']),
-            t:this.wordData['associatedProjects']!=''?0:1,//活动分类 0 创客活动
-          }
-          this.ajax.post(this.$store.state.api+'/ActivityApply',pram).then(result=>{
-            if(result['data']==1){
+    applyActivity() {
+      getProjectNo("HD").then((result) => {
+        let pram = {
+          uid: this.$store.state.userInfo.userid, //用户ID
+          aNo: result, //活动编号
+          tit: this.wordData["activityName"], //活动名称
+          courseId: this.wordData["associatedProjects"], //关联项目ID
+          pLeader: this.wordData["pro_leader"], //活动负责人
+          mon: this.total, //预算经费
+          st: this.wordData["student"], //参与学生人数
+          ct: JSON.stringify(this.wordData["member"]), //活动指导老师
+          chp: JSON.stringify({
+            activityPlan: this.wordData["activityName"], //活动计划
+            expectations: this.wordData["expectations"], //预期目标
+            eventAudience: this.wordData["eventAudience"], //活动受众面
+            fundingPlan: this.wordData["fundingPlan"], //经费支出计划
+          }), //活动信息
+          cid: this.wordData["college"], //学院ID,
+          ph: this.wordData["tel"], //联系电话
+          beg: JSON.stringify(this.wordData["activityTime"]), //活动时间
+          f: JSON.stringify(this.wordData["fund"]), //预算经费明细
+          appltTime: this.wordData["applicationDate"], //申请日期
+          mp: JSON.stringify(this.wordData["expenditureMothPlan"]),
+          t: this.wordData["associatedProjects"] != "" ? 0 : 1, //活动分类 0 创客活动
+        };
+        this.ajax
+          .post(this.$store.state.api + "/ActivityApply", pram)
+          .then((result) => {
+            if (result["data"] == 1) {
               this.$message.success("活动提交成功");
               //提交项目成功,查看sessionStore是否有数据,有则删
-              if(sessionStorage.getItem("makerActivityApplyData"))sessionStorage.removeItem('makerActivityApplyData');
-              this.$router.push('/makerActvity');
-            }else{
-              this.$message.error("活动提交失败")
+              if (localStorage.getItem("makerActivityApplyData"))
+                localStorage.removeItem("makerActivityApplyData");
+              this.$router.push("/makerActvity");
+            } else {
+              this.$message.error("活动提交失败");
             }
-          }).catch(err=>{
-            console.log(err)
           })
-        })
-
-
-      },
+          .catch((err) => {
+            console.log(err);
+          });
+      });
     },
-    mounted(){      //跳转到此页面立刻获取数据
-      //判断,如果sessionStore里有MakerSpaceApplyData这个字段,则存到this.wordData里
-      if(sessionStorage.getItem('makerActivityApplyData'))this.wordData = JSON.parse(sessionStorage.getItem('makerActivityApplyData'))
-      },
-    beforeRouteLeave (to, from, next) {
-      //判断,如果还没提交然后切换页面了,则把数据存到sessionStore里;
-      if(!this.submitHint)sessionStorage.setItem('makerActivityApplyData',JSON.stringify(this.wordData));
-      next();
+    saveData(){
+      localStorage.setItem(
+        "makerActivityApplyData",
+        JSON.stringify(this.wordData)
+      );
     }
-  };
-  </script>
-  
-  <style lang="less" scoped>
-#MakerActivityWord{
-  width:100%;
+  },
+  mounted() {
+    //跳转到此页面立刻获取数据
+    //判断,如果sessionStore里有MakerSpaceApplyData这个字段,则存到this.wordData里
+    if (localStorage.getItem("makerActivityApplyData"))
+      this.wordData = JSON.parse(
+        localStorage.getItem("makerActivityApplyData")
+      );
+    window.addEventListener("beforeunload", () => this.saveData());
+  },
+  destroyed() {
+    window.removeEventListener("beforeunload", (e) => this.saveData());
+  },
+  // beforeDestroy() {},
+  beforeRouteLeave(to, from, next) {
+    //判断,如果还没提交然后切换页面了,则把数据存到sessionStore里;
+    if (!this.submitHint)this.saveData();
+      
+    next();
+  },
+};
+</script>
+
+<style lang="less" scoped>
+#MakerActivityWord {
+  width: 100%;
   display: flex;
   flex-direction: column;
   align-items: center;
 }
-  </style>
+</style>

+ 236 - 202
src/views/activityManage/newNomMarkerActivity.vue

@@ -4,235 +4,269 @@
     <div class="pAHeader">
       <div class="pAHeader1">个人创客申请</div>
     </div>
-    <hr>
-       <!-- 创客专项资金及项目申请表(创客活动) -->
-      <NomMarkerWord :wordData="wordData" :total="total"/>
-      <div style="position: fixed;bottom: 5%;right: 2%;">
-          <el-button type="primary" @click="test">提交活动</el-button>
-        </div>
-      <el-dialog
-        title="提示"
-        :visible.sync="submitHint"
-        width="600px"
-        class="pageSubmitData">
-        
-        <div class="deleteContent">确定提交“{{wordData['activityName']}}”创客项目吗?</div>
-        <span slot="footer" class="dialog-footer">
-          <el-button type="primary" @click="applyActivity" class="AllDialogBtn">确认提交</el-button>
-          <el-button @click="submitHint=false" class="AllDialogBtn">取消</el-button>
-        </span>
-      </el-dialog>
+    <hr />
+    <!-- 创客专项资金及项目申请表(创客活动) -->
+    <NomMarkerWord :wordData="wordData" :total="total" />
+    <div style="position: fixed; bottom: 5%; right: 2%">
+      <el-button type="primary" @click="test">提交活动</el-button>
+    </div>
+    <el-dialog
+      title="提示"
+      :visible.sync="submitHint"
+      width="600px"
+      class="pageSubmitData"
+    >
+      <div class="deleteContent">
+        确定提交“{{ wordData["activityName"] }}”创客项目吗?
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="applyActivity" class="AllDialogBtn"
+          >确认提交</el-button
+        >
+        <el-button @click="submitHint = false" class="AllDialogBtn"
+          >取消</el-button
+        >
+      </span>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-import NomMarkerWord from './components/NomMarkerWord.vue';
-import {getNowDate} from '@/components/tool/Date.js'
-import getProjectNo from '@/components/tool/getProjectNo';
+import NomMarkerWord from "./components/NomMarkerWord.vue";
+import { getNowDate } from "@/components/tool/Date.js";
+import getProjectNo from "@/components/tool/getProjectNo";
 export default {
   components: {
-    NomMarkerWord
+    NomMarkerWord,
   },
   data() {
     return {
-      loading:false,
-      submitHint:false,
-      wordData:{
-        applicationDate:getNowDate(1),//申请日期
+      loading: false,
+      submitHint: false,
+      wordData: {
+        applicationDate: getNowDate(1), //申请日期
         // associatedProjects:"",//关联项目
-        activityName:'',//项目名称
-        pro_leader:"",//活动负责人
-        college: '',//所在学院
-        tel:'',//联系电话
-        activityTime:[],//活动时间
-        student:0,//参与学生人数
-        member:[
-          {name:"",collage:"",work:""},
-          {name:"",collage:"",work:""},
-          {name:"",collage:"",work:""},
+        activityName: "", //项目名称
+        pro_leader: "", //活动负责人
+        college: "", //所在学院
+        tel: "", //联系电话
+        activityTime: [], //活动时间
+        student: 0, //参与学生人数
+        member: [
+          { name: "", collage: "", work: "" },
+          { name: "", collage: "", work: "" },
+          { name: "", collage: "", work: "" },
         ],
-        activityPlan:"",//活动计划
-        expectations:"",//预期目标
-        eventAudience:"",//活动受众面
-        fundingPlan:"",//经费支出计划
-        expenditureMothPlan:['','','','','','','','','','','',''],
-        fund:{
-          device:"",
-          Material:"",
-          processing:"",
-          Collaboration:"",
-          APPRAISAL:"",
-          entery:"",
-          activities:"",
-          Transaction:"",
-        },//预算经费
-      }
+        activityPlan: "", //活动计划
+        expectations: "", //预期目标
+        eventAudience: "", //活动受众面
+        fundingPlan: "", //经费支出计划
+        expenditureMothPlan: ["", "", "", "", "", "", "", "", "", "", "", ""],
+        fund: {
+          device: "",
+          Material: "",
+          processing: "",
+          Collaboration: "",
+          APPRAISAL: "",
+          entery: "",
+          activities: "",
+          Transaction: "",
+        }, //预算经费
+      },
     };
   },
-  computed:{
+  computed: {
     total() {
-          let num = 0;
-          for(let i in this.wordData['fund'])num += Number(this.wordData['fund'][i]);
-          return num;
-          // return (this.wordData.fund.facility*1 + this.wordData.fund.materials*1+this.wordData.fund.process*1+ this.input*1+this.wordData.fund.authenticate*1+ this.wordData.fund.match*1+this.wordData.fund.activity*1+this.wordData.fund.affair*1)/10000
-        }
+      let num = 0;
+      for (let i in this.wordData["fund"])
+        num += Number(this.wordData["fund"][i]);
+      return num;
+      // return (this.wordData.fund.facility*1 + this.wordData.fund.materials*1+this.wordData.fund.process*1+ this.input*1+this.wordData.fund.authenticate*1+ this.wordData.fund.match*1+this.wordData.fund.activity*1+this.wordData.fund.affair*1)/10000
+    },
   },
   methods: {
-    test(){
-        const cEmpty = /^\s*$/g;
-        const checkPhone = /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/; //获取正则表达式 存放到verify变量中
-        for(let i in this.wordData){
-          switch(i){
-            case "activityName":
-              if(cEmpty.test(this.wordData[i])){
-                this.$message.error("请输入活动名称")
-                document.querySelector('#two').scrollIntoView({ behavior: "smooth" });
-                return false;
-              }
-              break;
-            case "pro_leader":
-              if(cEmpty.test(this.wordData[i])){
-                this.$message.error("请输入活动负责人")
-                document.querySelector('#three').scrollIntoView({ behavior: "smooth" });
-                return false;
-              }
-              break;
-            case "college":
-              if(cEmpty.test(this.wordData[i])){
-                this.$message.error("请选择所在学院")
-                document.querySelector('#three').scrollIntoView({ behavior: "smooth" });
-                return false;;
-              }
-              break;
-            case "tel":
-              if(cEmpty.test(this.wordData[i])){
-                this.$message.error("请输入联系电话")
-                document.querySelector('#three').scrollIntoView({ behavior: "smooth" });
-                return false;
-              }else if(!checkPhone.test(this.wordData[i])){
-                this.$message.error("请输入正确的手机号");
-                document.querySelector('#three').scrollIntoView({ behavior: "smooth" });
-                return false;
-              }
-              break;
-              case "activityTime":
-                if(this.wordData[i].length<=0){
-                  this.$message.error("请选择活动时间")
-                  document.querySelector('#four').scrollIntoView({ behavior: "smooth" });
-                  return false;;
-                }
-                break;
-            // case "member":
-            //     let num = 0;
-            //     this.wordData[i].forEach(item=>{
-            //       if(cEmpty.test(item['name']))num++;
-            //       // for(let j in item){
-            //       //   if(cEmpty.test(item[j])){
-            //       //     num++;
-            //       //   }
-            //       // }
-                
-            //     })
-            //     if(num>0){
-            //       this.$message.error("请填完指导老师信息");
-            //       document.querySelector('#five').scrollIntoView({ behavior: "smooth" });
-            //       return false;
-            //     }
-            //   break;
-            // case "activityPlan":
-            //   if(cEmpty.test(this.wordData[i][0])){
-            //     this.$message.error("请输入活动计划");
-            //     document.querySelector('#six').scrollIntoView({ behavior: "smooth" });
-            //     return false;
-            //   }
-            //   break;
-            // case "expectations":
-            //   if(cEmpty.test(this.wordData[i][0])){
-            //     this.$message.error("预期目标");
-            //     document.querySelector('#seven').scrollIntoView({ behavior: "smooth" });
-            //     return false;
-            //   }
-            //   break;
-            // case "eventAudience":
-            //   if(cEmpty.test(this.wordData[i][0])){
-            //     this.$message.error("活动受众面")
-            //     document.querySelector('#nine').scrollIntoView({ behavior: "smooth" });
-            //     return false;
-            //   }
-            //   break;
-            // case "fundingPlan":
-            //   if(cEmpty.test(this.wordData[i][0])){
-            //     this.$message.error("经费支出计划")
-            //     document.querySelector('#ten').scrollIntoView({ behavior: "smooth" });
-            //     return false;
-            //   }
-            //   break;
-          }
-        }
-        if(this.total<=0){
-          this.$message.error("请输入预算经费")
-              document.querySelector('#fund').scrollIntoView({ behavior: "smooth" });
+    test() {
+      const cEmpty = /^\s*$/g;
+      const checkPhone =
+        /^(?:(?:\+|00)86)?1(?:(?:3[\d])|(?:4[5-79])|(?:5[0-35-9])|(?:6[5-7])|(?:7[0-8])|(?:8[\d])|(?:9[189]))\d{8}$/; //获取正则表达式 存放到verify变量中
+      for (let i in this.wordData) {
+        switch (i) {
+          case "activityName":
+            if (cEmpty.test(this.wordData[i])) {
+              this.$message.error("请输入活动名称");
+              document
+                .querySelector("#two")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          case "pro_leader":
+            if (cEmpty.test(this.wordData[i])) {
+              this.$message.error("请输入活动负责人");
+              document
+                .querySelector("#three")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          case "college":
+            if (cEmpty.test(this.wordData[i])) {
+              this.$message.error("请选择所在学院");
+              document
+                .querySelector("#three")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          case "tel":
+            if (cEmpty.test(this.wordData[i])) {
+              this.$message.error("请输入联系电话");
+              document
+                .querySelector("#three")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            } else if (!checkPhone.test(this.wordData[i])) {
+              this.$message.error("请输入正确的手机号");
+              document
+                .querySelector("#three")
+                .scrollIntoView({ behavior: "smooth" });
               return false;
+            }
+            break;
+          case "activityTime":
+            if (this.wordData[i].length <= 0) {
+              this.$message.error("请选择活动时间");
+              document
+                .querySelector("#four")
+                .scrollIntoView({ behavior: "smooth" });
+              return false;
+            }
+            break;
+          // case "member":
+          //     let num = 0;
+          //     this.wordData[i].forEach(item=>{
+          //       if(cEmpty.test(item['name']))num++;
+          //       // for(let j in item){
+          //       //   if(cEmpty.test(item[j])){
+          //       //     num++;
+          //       //   }
+          //       // }
+
+          //     })
+          //     if(num>0){
+          //       this.$message.error("请填完指导老师信息");
+          //       document.querySelector('#five').scrollIntoView({ behavior: "smooth" });
+          //       return false;
+          //     }
+          //   break;
+          // case "activityPlan":
+          //   if(cEmpty.test(this.wordData[i][0])){
+          //     this.$message.error("请输入活动计划");
+          //     document.querySelector('#six').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
+          // case "expectations":
+          //   if(cEmpty.test(this.wordData[i][0])){
+          //     this.$message.error("预期目标");
+          //     document.querySelector('#seven').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
+          // case "eventAudience":
+          //   if(cEmpty.test(this.wordData[i][0])){
+          //     this.$message.error("活动受众面")
+          //     document.querySelector('#nine').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
+          // case "fundingPlan":
+          //   if(cEmpty.test(this.wordData[i][0])){
+          //     this.$message.error("经费支出计划")
+          //     document.querySelector('#ten').scrollIntoView({ behavior: "smooth" });
+          //     return false;
+          //   }
+          //   break;
         }
-        this.submitHint = true;
+      }
+      if (this.total <= 0) {
+        this.$message.error("请输入预算经费");
+        document.querySelector("#fund").scrollIntoView({ behavior: "smooth" });
+        return false;
+      }
+      this.submitHint = true;
     },
-    applyActivity(){
-      getProjectNo("HD").then(result=>{
+    applyActivity() {
+      getProjectNo("HD").then((result) => {
         let pram = {
-          uid:this.$store.state.userInfo.userid,//用户ID
-          aNo:result,//活动编号
-          tit:this.wordData['activityName'],//活动名称
-          courseId:'',//关联项目ID
-          pLeader:this.wordData['pro_leader'],//活动负责人
-          mon:this.total,//预算经费
-          st:this.wordData['student'],//参与学生人数
-          ct:JSON.stringify(this.wordData['member']),//活动指导老师
-          chp:JSON.stringify({
-            activityPlan:this.wordData['activityName'],//活动计划
-            expectations:this.wordData['expectations'],//预期目标
-            eventAudience:this.wordData['eventAudience'],//活动受众面
-            fundingPlan:this.wordData['fundingPlan'],//经费支出计划
-          }),//活动信息
-          cid:this.wordData['college'],//学院ID,
-          ph:this.wordData['tel'],//联系电话
-          beg:JSON.stringify(this.wordData['activityTime']),//活动时间
-          f:JSON.stringify(this.wordData['fund']),//预算经费明细
-          appltTime:this.wordData['applicationDate'],//申请日期
-          mp:JSON.stringify(this.wordData['expenditureMothPlan']),
-          t:1,//活动分类 1 个人创客
-        }
-        this.ajax.post(this.$store.state.api+'/ActivityApply',pram).then(result=>{
-          if(result['data']==1){
-            this.$message.success("活动提交成功");
-            //提交项目成功,查看sessionStore是否有数据,有则删
-            if(sessionStorage.getItem("NomActivityApplyData"))sessionStorage.removeItem('NomActivityApplyData');
-            this.$router.push('/makerActvity');
-          }else{
-            this.$message.error("活动提交失败")
-          }
-        }).catch(err=>{
-          console.log(err)
-        })
-      })
+          uid: this.$store.state.userInfo.userid, //用户ID
+          aNo: result, //活动编号
+          tit: this.wordData["activityName"], //活动名称
+          courseId: "", //关联项目ID
+          pLeader: this.wordData["pro_leader"], //活动负责人
+          mon: this.total, //预算经费
+          st: this.wordData["student"], //参与学生人数
+          ct: JSON.stringify(this.wordData["member"]), //活动指导老师
+          chp: JSON.stringify({
+            activityPlan: this.wordData["activityName"], //活动计划
+            expectations: this.wordData["expectations"], //预期目标
+            eventAudience: this.wordData["eventAudience"], //活动受众面
+            fundingPlan: this.wordData["fundingPlan"], //经费支出计划
+          }), //活动信息
+          cid: this.wordData["college"], //学院ID,
+          ph: this.wordData["tel"], //联系电话
+          beg: JSON.stringify(this.wordData["activityTime"]), //活动时间
+          f: JSON.stringify(this.wordData["fund"]), //预算经费明细
+          appltTime: this.wordData["applicationDate"], //申请日期
+          mp: JSON.stringify(this.wordData["expenditureMothPlan"]),
+          t: 1, //活动分类 1 个人创客
+        };
+        this.ajax
+          .post(this.$store.state.api + "/ActivityApply", pram)
+          .then((result) => {
+            if (result["data"] == 1) {
+              this.$message.success("活动提交成功");
+              //提交项目成功,查看sessionStore是否有数据,有则删
+              if (localStorage.getItem("NomActivityApplyData"))
+                localStorage.removeItem("NomActivityApplyData");
+              this.$router.push("/makerActvity");
+            } else {
+              this.$message.error("活动提交失败");
+            }
+          })
+          .catch((err) => {
+            console.log(err);
+          });
+      });
+    },
+    saveData() {
+      localStorage.setItem(
+        "NomActivityApplyData",
+        JSON.stringify(this.wordData)
+      );
     },
   },
-  mounted(){      //跳转到此页面立刻获取数据
+  mounted() {
+    //跳转到此页面立刻获取数据
     //判断,如果sessionStore里有MakerSpaceApplyData这个字段,则存到this.wordData里
-    if(sessionStorage.getItem('NomActivityApplyData'))this.wordData = JSON.parse(sessionStorage.getItem('NomActivityApplyData'))
-    },
-  beforeRouteLeave (to, from, next) {
+    if (localStorage.getItem("NomActivityApplyData")) {
+      this.wordData = JSON.parse(localStorage.getItem("NomActivityApplyData"));
+    }
+    window.addEventListener("beforeunload", () => this.saveData());
+  },
+  beforeRouteLeave(to, from, next) {
     //判断,如果还没提交然后切换页面了,则把数据存到sessionStore里;
-    if(!this.submitHint)sessionStorage.setItem('NomActivityApplyData',JSON.stringify(this.wordData));
+    if (!this.submitHint) this.saveData();
     next();
-  }
+  },
 };
 </script>
 
 <style lang="less" scoped>
-#MakerActivityWord{
-width:100%;
-display: flex;
-flex-direction: column;
-align-items: center;
+#MakerActivityWord {
+  width: 100%;
+  display: flex;
+  flex-direction: column;
+  align-items: center;
 }
-</style>
+</style>

+ 61 - 55
src/views/projectApply/MakerSpaceApply.vue

@@ -30,8 +30,8 @@
     </el-dialog>
   </div>
 </template>
-  
-  <script>
+
+<script>
 import { getNowDate } from "@/components/tool/Date.js";
 import getProjectNo from "@/components/tool/getProjectNo";
 import MakerSpaceWord from "./components/MakerSpaceWord.vue";
@@ -164,47 +164,47 @@ export default {
             }
             break;
           // case "teacher":
-            // if (this.wordData[i].length < 3) {
-            //   this.$message.error("教师团队应3人以上");
-            //   document
-            //     .querySelector("#five")
-            //     .scrollIntoView({ behavior: "smooth" });
-            //   return false;
-            // } else {
-            // let num = 0;
-            // this.wordData[i].forEach((item) => {
-            //   if (cEmpty.test(item["name"])) num++;
-            // });
-            // if (num > 0) {
-            //   this.$message.error("教师姓名请不要留空");
-            //   document
-            //     .querySelector("#five")
-            //     .scrollIntoView({ behavior: "smooth" });
-            //   return false;
-            // }
-            // // }
-            // break;
+          // if (this.wordData[i].length < 3) {
+          //   this.$message.error("教师团队应3人以上");
+          //   document
+          //     .querySelector("#five")
+          //     .scrollIntoView({ behavior: "smooth" });
+          //   return false;
+          // } else {
+          // let num = 0;
+          // this.wordData[i].forEach((item) => {
+          //   if (cEmpty.test(item["name"])) num++;
+          // });
+          // if (num > 0) {
+          //   this.$message.error("教师姓名请不要留空");
+          //   document
+          //     .querySelector("#five")
+          //     .scrollIntoView({ behavior: "smooth" });
+          //   return false;
+          // }
+          // // }
+          // break;
           // case "student":
-            // if (this.wordData[i].length < 5) {
-            //   this.$message.error("学生团队应5人以上");
-            //   document
-            //     .querySelector("#six")
-            //     .scrollIntoView({ behavior: "smooth" });
-            //   return false;
-            // } else {
-            // let num1 = 0;
-            // this.wordData[i].forEach((item) => {
-            //   if (cEmpty.test(item["name"])) num1++;
-            // });
-            // if (num1 > 0) {
-            //   this.$message.error("学生姓名请不要留空");
-            //   document
-            //     .querySelector("#six")
-            //     .scrollIntoView({ behavior: "smooth" });
-            //   return false;
-            // }
-            // // }
-            // break;
+          // if (this.wordData[i].length < 5) {
+          //   this.$message.error("学生团队应5人以上");
+          //   document
+          //     .querySelector("#six")
+          //     .scrollIntoView({ behavior: "smooth" });
+          //   return false;
+          // } else {
+          // let num1 = 0;
+          // this.wordData[i].forEach((item) => {
+          //   if (cEmpty.test(item["name"])) num1++;
+          // });
+          // if (num1 > 0) {
+          //   this.$message.error("学生姓名请不要留空");
+          //   document
+          //     .querySelector("#six")
+          //     .scrollIntoView({ behavior: "smooth" });
+          //   return false;
+          // }
+          // // }
+          // break;
           case "fund":
             let sum = 0;
             for (let i in this.wordData["fund"]) {
@@ -335,7 +335,7 @@ export default {
             studentActivities: this.wordData["studentActivities"], //学生创客活动组织实施情况
             Transforming: this.wordData["Transforming"], //学生创客团队孵化、转化创业项目情况
             condition: this.wordData["condition"], //立 项基 础及条 件
-          }).replaceAll(/%/g,"%25"), //项目详细
+          }).replaceAll(/%/g, "%25"), //项目详细
           tid: "5f7a66d5-c206-11ed-a4cd-509a4c5b67cf", //特色创客空间建设项目分类ID
           tName: this.wordData["state"], //项目状态
           mon: JSON.stringify(this.wordData["fund"]), //预算经费
@@ -353,8 +353,8 @@ export default {
             if (result["data"] == 1) {
               this.$message.success("项目提交成功");
               //提交项目成功,查看sessionStore是否有数据,有则删
-              if (sessionStorage.getItem("MakerSpaceApplyData"))
-                sessionStorage.removeItem("MakerSpaceApplyData");
+              if (localStorage.getItem("MakerSpaceApplyData"))
+                localStorage.removeItem("MakerSpaceApplyData");
               this.$router.push("/projectApplication");
             } else {
               this.$message.error("项目提交失败");
@@ -365,6 +365,12 @@ export default {
           });
       });
     },
+    saveData() {
+      localStorage.setItem(
+        "MakerSpaceApplyData",
+        JSON.stringify(this.wordData)
+      );
+    },
   },
   computed: {
     reversedMessage: function () {
@@ -385,22 +391,22 @@ export default {
     //   this.getData();     //获取表格数据
     // this.applyProject();
     //判断,如果sessionStore里有MakerSpaceApplyData这个字段,则存到this.wordData里
-    if (sessionStorage.getItem("MakerSpaceApplyData"))
-      this.wordData = JSON.parse(sessionStorage.getItem("MakerSpaceApplyData"));
+    if (localStorage.getItem("MakerSpaceApplyData")) {
+      this.wordData = JSON.parse(localStorage.getItem("MakerSpaceApplyData"));
+    }
+    window.addEventListener("beforeunload", () => this.saveData());
+
   },
+ 
   beforeRouteLeave(to, from, next) {
     //判断,如果还没提交然后切换页面了,则把数据存到sessionStore里;
-    if (!this.submitHint)
-      sessionStorage.setItem(
-        "MakerSpaceApplyData",
-        JSON.stringify(this.wordData)
-      );
+    if (!this.submitHint)this.saveData()
     next();
   },
 };
 </script>
-  
-  <style lang="less">
+
+<style lang="less">
 #MakerSpaceApply {
   display: flex;
   flex-direction: column;
@@ -408,4 +414,4 @@ export default {
   // justify-content: flex-end;
   position: relative;
 }
-</style>
+</style>

+ 51 - 49
src/views/projectApply/newStudentProjectApply.vue

@@ -37,8 +37,8 @@
     </el-dialog>
   </div>
 </template>
-  
-  <script>
+
+<script>
 // import MakerSpaceWord from '../components/MakerSpaceWord.vue'
 import getProjectNo from "@/components/tool/getProjectNo";
 import { getNowDate } from "@/components/tool/Date.js";
@@ -68,12 +68,8 @@ export default {
         tel: "",
         beginTime: "",
         endTime: "",
-        studentS: [
-          { name: "", collage: "", work: "" },
-        ],
-        teacherS: [
-          { name: "", collage: "", work: "" },
-        ],
+        studentS: [{ name: "", collage: "", work: "" }],
+        teacherS: [{ name: "", collage: "", work: "" }],
         brief: "",
         introduce: {
           back: "",
@@ -221,39 +217,39 @@ export default {
           //   let snum = 0;
           //   this.wordData[i].forEach((item) => {
           //     if (cEmpty.test(item["name"])) snum++;
-              // for(let j in item){
-              //   if(cEmpty.test(item[j])){
-              //     snum++;
-              //   }
-              // }
-            // });
-            // if (snum > 0) {
-            //   this.$message.error("学生姓名请不要留空");
-            //   document
-            //     .querySelector("#studentS")
-            //     .scrollIntoView({ behavior: "smooth" });
-            //   return false;
-            // }
-            // }
+          // for(let j in item){
+          //   if(cEmpty.test(item[j])){
+          //     snum++;
+          //   }
+          // }
+          // });
+          // if (snum > 0) {
+          //   this.$message.error("学生姓名请不要留空");
+          //   document
+          //     .querySelector("#studentS")
+          //     .scrollIntoView({ behavior: "smooth" });
+          //   return false;
+          // }
+          // }
           //   break;
           // case "teacherS":
           //   let num = 0;
           //   this.wordData[i].forEach((item) => {
           //     if (cEmpty.test(item["name"])) num++;
-              // for(let j in item){
-              //   if(cEmpty.test(item[j])){
-              //     num++;
-              //   }
-              // }
-            // });
-            // if (num > 0) {
-            //   this.$message.error("老师姓名请不要留空");
-            //   document
-            //     .querySelector("#teacherS")
-            //     .scrollIntoView({ behavior: "smooth" });
-            //   return false;
-            // }
-            // break;
+          // for(let j in item){
+          //   if(cEmpty.test(item[j])){
+          //     num++;
+          //   }
+          // }
+          // });
+          // if (num > 0) {
+          //   this.$message.error("老师姓名请不要留空");
+          //   document
+          //     .querySelector("#teacherS")
+          //     .scrollIntoView({ behavior: "smooth" });
+          //   return false;
+          // }
+          // break;
           // case "brief":
           //   if (this.wordData[i].length > 300 || this.wordData[i].length == 0) {
           //     this.$message.error("请填写项目简介,字数在300字以内");
@@ -321,7 +317,10 @@ export default {
           cs: JSON.stringify(this.wordData["studentS"]), //学生组,
           ct: JSON.stringify(this.wordData["teacherS"]), //教师组,
           bf: this.wordData["brief"], //项目简介
-          introduce: JSON.stringify(this.wordData["introduce"]).replaceAll(/%/g,"%25"), //项目详细
+          introduce: JSON.stringify(this.wordData["introduce"]).replaceAll(
+            /%/g,
+            "%25"
+          ), //项目详细
           mon: JSON.stringify(this.wordData["fund"]), //预算经费
           f: this.wordData["total"], //总经费
           apply: this.wordData["applicationDate"], //申请日期
@@ -337,8 +336,8 @@ export default {
               if (result["data"] == 1) {
                 this.$message.success("项目提交成功");
                 //提交项目成功,查看sessionStore是否有数据,有则删
-                if (sessionStorage.getItem("StudentProjectApplyData"))
-                  sessionStorage.removeItem("StudentProjectApplyData");
+                if (localStorage.getItem("StudentProjectApplyData"))
+                  localStorage.removeItem("StudentProjectApplyData");
                 this.$router.push("/projectApplication");
               } else {
                 this.$message.error("项目提交失败");
@@ -353,24 +352,27 @@ export default {
           });
       });
     },
+    saveData() {
+      localStorage.setItem(
+        "StudentProjectApplyData",
+        JSON.stringify(this.wordData)
+      );
+    },
   },
   mounted() {
-    if (sessionStorage.getItem("StudentProjectApplyData"))
+    if (localStorage.getItem("StudentProjectApplyData"))
       this.wordData = JSON.parse(
-        sessionStorage.getItem("StudentProjectApplyData")
+        localStorage.getItem("StudentProjectApplyData")
       );
+    window.addEventListener("beforeunload", () => this.saveData());
   },
+
   beforeRouteLeave(to, from, next) {
     //判断,如果还没提交然后切换页面了,则把数据存到sessionStore里;
-    if (!this.submitHint)
-      sessionStorage.setItem(
-        "StudentProjectApplyData",
-        JSON.stringify(this.wordData)
-      );
+    if (!this.submitHint) this.saveData();
     next();
   },
 };
 </script>
-  
-  <style lang="less" scoped>
-</style>
+
+<style lang="less" scoped></style>