Browse Source

跳转选择项目

Lijy 3 years ago
parent
commit
cc6f03803e

+ 2 - 2
fhKeeper/formulahousekeeper/timesheet_h5/src/main.js

@@ -13,12 +13,12 @@ import "@/components/Vant";
 
 
 import { Form , Toast , Grid, GridItem , DatetimePicker ,
 import { Form , Toast , Grid, GridItem , DatetimePicker ,
 Picker , Dialog , NumberKeyboard , Sticky , Skeleton ,
 Picker , Dialog , NumberKeyboard , Sticky , Skeleton ,
-Panel , Divider , List , pullRefresh , SwipeCell, Checkbox, Search, Slider,Stepper,Tag, Calendar, Row, Col } from 'vant';
+Panel , Divider , List , pullRefresh , SwipeCell, Checkbox, Search, Slider,Stepper,Tag, Calendar, Row, Col, RadioGroup, Radio } from 'vant';
 
 
 Vue.use(Form).use(Toast).use(Grid).use(GridItem).use(DatetimePicker)
 Vue.use(Form).use(Toast).use(Grid).use(GridItem).use(DatetimePicker)
 .use(Picker).use(Dialog).use(NumberKeyboard).use(Sticky).use(Skeleton)
 .use(Picker).use(Dialog).use(NumberKeyboard).use(Sticky).use(Skeleton)
 .use(Panel).use(Divider).use(List).use(pullRefresh).use(SwipeCell)
 .use(Panel).use(Divider).use(List).use(pullRefresh).use(SwipeCell)
-.use(Checkbox).use(Search).use(Slider).use(Stepper).use(Tag).use(Calendar)
+.use(Checkbox).use(Search).use(Slider).use(Stepper).use(Tag).use(Calendar).use(RadioGroup).use(Radio)
 .use(Row).use(Col);
 .use(Row).use(Col);
 
 
 // rem
 // rem

+ 7 - 0
fhKeeper/formulahousekeeper/timesheet_h5/src/router/index.js

@@ -60,6 +60,13 @@ const router = new Router({
         },
         },
         component: () => import("@/views/edit/index")
         component: () => import("@/views/edit/index")
     },
     },
+    {
+        path: "/search",
+        meta: {
+            title: "选择项目"
+        },
+        component: () => import("@/views/edit/search")
+    },
     {
     {
         path: "/review",
         path: "/review",
         meta: {
         meta: {

+ 39 - 8
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/index.vue

@@ -29,11 +29,12 @@
                 <!-- <van-icon v-if="index>0&&canEdit" class="form_del" name="delete" @click="delPro(index)" /> -->
                 <!-- <van-icon v-if="index>0&&canEdit" class="form_del" name="delete" @click="delPro(index)" /> -->
 
 
                 <van-cell-group :title="'项目' + (index+1)">
                 <van-cell-group :title="'项目' + (index+1)">
-                    <van-field  readonly  name="projectId" clickable :value="item.projectName" label="投入项目" placeholder="请选择投入项目" @click="clickPicker(index)"
-                    :rules="[{ required: true, message: '请选择投入项目' }]"/>
+                    <!-- <div>请选择投入项目</div> -->
+                    <van-field  readonly  name="projectId" clickable :value="item.projectName" label="投入项目" placeholder="请选择投入项目" @click="clickPicker(index, item)"
+                    :rules="[{ required: true, message: '请选择项目' }]" /><!-- 
                     <van-popup v-model="showPickerProject" position="bottom">
                     <van-popup v-model="showPickerProject" position="bottom">
                         <van-picker show-toolbar :columns="project" value-key="projectName" @confirm="choseProject" @cancel="showPickerProject = false" />
                         <van-picker show-toolbar :columns="project" value-key="projectName" @confirm="choseProject" @cancel="showPickerProject = false" />
-                    </van-popup>
+                    </van-popup> -->
                     <!-- 相关维度 -->
                     <!-- 相关维度 -->
                     <van-field :value="item.weiduName" v-if="item.projectId && user.timeType.customDegreeActive == 1"  readonly  name="id" clickable :label="user.timeType.customDegreeName" placeholder="请选择" @click="clickPickers(index)"/>
                     <van-field :value="item.weiduName" v-if="item.projectId && user.timeType.customDegreeActive == 1"  readonly  name="id" clickable :label="user.timeType.customDegreeName" placeholder="请选择" @click="clickPickers(index)"/>
                     <van-popup v-model="showPickerProjects" position="bottom">
                     <van-popup v-model="showPickerProjects" position="bottom">
@@ -681,6 +682,12 @@
                         toast.clear();
                         toast.clear();
                         this.$toast.fail('获取失败:'+res.msg);
                         this.$toast.fail('获取失败:'+res.msg);
                     }
                     }
+                    if(localStorage.getItem("formVal")) {
+                        console.log('触发了')
+                        var obj = localStorage.getItem("formVal")
+                        this.form = JSON.parse(obj)
+                        localStorage.removeItem('formVal')
+                    }
                 }).catch(err=> {toast.clear();});
                 }).catch(err=> {toast.clear();});
             },
             },
 
 
@@ -693,20 +700,35 @@
             },
             },
 
 
             // 选择项目
             // 选择项目
-            clickPicker(i) {
-                if (!this.canEdit) return;
-                this.clickIndex = i;
-                this.showPickerProject = true;
+            clickPicker(i, item) {
+                // if (!this.canEdit) return;
+                // this.clickIndex = i;
+                // this.showPickerProject = true;
+                console.log(i, item, this.form)
+                this.$router.push({
+                    path: '/search',
+                    query: {
+                        // from: JSON.stringify(this.form)
+                        from: this.form,
+                        idx: i
+                    }
+                });
             },
             },
             clickPickers(i) {
             clickPickers(i) {
                 if (!this.canEdit) return;
                 if (!this.canEdit) return;
                 this.clickIndex = i;
                 this.clickIndex = i;
                 this.showPickerProjects = true;
                 this.showPickerProjects = true;
+                var proId = this.form.domains[this.clickIndex].projectId
+                console.log(proId, 990990)
+                this.dimension(proId)
             },
             },
             //选择任务
             //选择任务
             clickPickerTask(i) {
             clickPickerTask(i) {
+                console.log(1234567)
                 if (!this.canEdit) return;
                 if (!this.canEdit) return;
                 this.clickIndex = i;
                 this.clickIndex = i;
+                var proId = this.form.domains[this.clickIndex].projectId
+                this.getTaskList(proId)
                 this.showPickerTask = true;
                 this.showPickerTask = true;
             },
             },
             choseTask(value, index) {
             choseTask(value, index) {
@@ -740,7 +762,6 @@
                         .then(res => {
                         .then(res => {
                             if(res.code == "ok") {
                             if(res.code == "ok") {
                                 this.form.domains[this.clickIndex].professionProgress = res.data;
                                 this.form.domains[this.clickIndex].professionProgress = res.data;
-                                
                                 this.$forceUpdate();
                                 this.$forceUpdate();
                             } else {
                             } else {
                                 this.$toast.fail('获取失败');
                                 this.$toast.fail('获取失败');
@@ -1067,6 +1088,7 @@
         },
         },
         
         
         mounted() {
         mounted() {
+            console.log(localStorage.getItem("formVal"))
             var ua = navigator.userAgent.toLowerCase();
             var ua = navigator.userAgent.toLowerCase();
             this.isIOSystem = this.isIOS();
             this.isIOSystem = this.isIOS();
             if (ua.indexOf("wxwork") > 0) {
             if (ua.indexOf("wxwork") > 0) {
@@ -1087,6 +1109,15 @@
             if (this.isCorpWX) {
             if (this.isCorpWX) {
                 this.initWxConfig();
                 this.initWxConfig();
             }
             }
+
+            // if(localStorage.getItem("formVal")) {
+            //     var obj = localStorage.getItem("formVal")
+            //     this.form = JSON.parse(obj)
+            //     localStorage.removeItem('formVal')
+            // }
+        },
+        beforeDestroy() {
+            localStorage.removeItem('formVal')
         }
         }
     };
     };
 </script>
 </script>

+ 120 - 0
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/search.vue

@@ -0,0 +1,120 @@
+<template>
+  <div style="background: #fff;">
+      <van-nav-bar title="选择项目" left-text="返回" @click-left="back()" fixed left-arrow/>
+      <van-search v-model="value" placeholder="请输入项目名称" @clear="sea()" @blur="sea()" @search="sea()" style="margin-top: 45px;"/>
+      <van-radio-group v-model="checkeds">
+          <div v-for="item in project" :key="item.id" class="prejectList">
+            <van-radio :name="item">{{item.projectName}}</van-radio>
+          </div>
+      </van-radio-group>
+      <div v-if="project.length == 0" class="adds">暂无数据</div>
+      <div style="width: 100%;height: 44px;"></div>
+      <div class="qued" @click="qued()">确定</div>
+  </div>
+</template>
+
+<script>
+export default {
+  props: {},
+  components: {},
+  data() {
+    return {
+        value: '',
+        project: '',
+        checkeds: '',
+        pro: '',
+        from: '',
+        idx: 0
+    };
+  },
+  computed: {},
+  watch: {
+      '$route': 'getParams'
+  },
+  created() {
+      this.getParams()
+  },
+  mounted() {
+      this.getPeoject()
+  },
+  methods: {
+      // 接收传过来的参数
+      getParams() {
+          const routerParams = this.$route.query.from
+          const idx = this.$route.query.idx
+          this.from = routerParams
+          this.idx = idx
+      },
+      // 获取项目
+      getPeoject() {
+          this.$axios.post("/project/getProjectList", {})
+          .then(res => {
+              if(res.code == "ok") {
+                  this.project = res.data;
+                  this.pro = res.data
+                  console.log(res.data)
+              } else {
+                  this.$toast.fail('获取失败:'+res.msg);
+              }
+          }).catch(err=> {toast.clear();});
+      },
+      back() {
+          this.$router.go(-1);
+      },
+      qued() {
+          console.log(this.checkeds)
+          if(this.checkeds == '') {
+              this.$toast('请选择项目');
+          } else {
+              this.from.domains[this.idx].projectId = this.checkeds.id
+              this.from.domains[this.idx].projectName = this.checkeds.projectName
+              localStorage.setItem('formVal', JSON.stringify(this.from))
+              this.$router.go(-1);
+          }
+      },
+      sea() {
+          if(this.value.length > 0) {
+              let text = this.value
+              let reg = new RegExp(text)
+              let data = this.project.filter(item => reg.test(item.projectName)) //返回
+              this.project = data
+          } else {
+              this.project = this.pro
+          }
+          
+      },
+  },
+};
+</script>
+
+<style>
+    .prejectList {
+        padding: 10px 20px;
+        background: #fff;
+        border-bottom: 1px solid #f6f6f6;
+    }
+    .van-search {
+        background: #fff !important;
+        border-bottom: 1px solid #f6f6f6;
+    }
+    .van-search__content {
+        border-radius: 20px !important;
+    }
+    .qued {
+        width: 100%;
+        height: 44px;
+        background: #1989fa;
+        text-align: center;
+        line-height: 44px;
+        color: #fff;
+        position: fixed;
+        left: 0;
+        bottom: 0;
+    }
+    .adds {
+        width: 100%;
+        text-align: center;
+        line-height: 85px;
+        color: #b6b6b6;
+    }
+</style>