Ver código fonte

项目列表页 初稿

XuZinan 3 anos atrás
pai
commit
da3f436c21

+ 73 - 7
pages/Project/list.vue

@@ -1,14 +1,80 @@
 <template>
-    
+  <view class="content">
+    <view class="head">
+      <span class="title">项目列表</span>
+      <span class="self">只看自己</span>
+    </view>
+    <view class="list">
+      <view
+        class="project"
+        v-for="project in projectList"
+        :key="project.id"
+        @click="onClickProject(project)"
+      >
+        {{ `${project.project_name}(${project.project_full_code})` }}
+      </view>
+    </view>
+  </view>
 </template>
 
-
 <script>
+import { queryProject } from "@/services/project";
+import { mapState } from "vuex";
 export default {
-}
+  computed: {
+    ...mapState(["currentProject"]),
+  },
+  data() {
+    return { projectList: [] };
+  },
+  onShow() {
+    this.getProject();
+  },
+  methods: {
+    async getProject() {
+      let res = {};
+      res = await queryProject();
+      this.projectList = res.data.list;
+    },
+    async onClickProject(project) {
+      await this.$store.commit("setCurrentProject", project);
+      console.log(this.currentProject);
+      uni.navigateTo({
+        url: `./detail?id=${project.id}`,
+      });
+    },
+  },
+};
 </script>
 
-
-<style scoped>
-
-</style>
+<style lang="less" scoped>
+.content {
+  display: flex;
+  justify-content: center;
+  flex-wrap: wrap;
+}
+.head {
+  width: 100%;
+  padding: 0 20px 20px 20px;
+  position: fixed;
+  background: #f8f8f8;
+  display: flex;
+  justify-content: space-between;
+  align-items: center;
+  .title {
+    font: 24px bold;
+  }
+  .self {
+    font: 16px;
+  }
+}
+.list {
+  width: 90%;
+  margin-top: 60px;
+}
+.project {
+  border-top: 2px solid gray;
+  padding: 20px 0px;
+  font-size: 20px;
+}
+</style>

+ 2 - 2
pages/WorkingHours/index.vue

@@ -88,13 +88,13 @@
       ></uni-popup-dialog>
     </uni-popup>
     <view class="group">
-      <button
+      <!-- <button
         class="approval"
         v-if="permission['func-05-mobile-works-approval']"
         @click="onHandleApproval()"
       >
         审批工时
-      </button>
+      </button> -->
       <button
         v-if="permission['func-05-mobile-works-commit']"
         @click="onHandleAudit({}, 2)"

+ 4 - 4
pages/index/index.vue

@@ -2,19 +2,19 @@
   <view class="content">
     <view class="group">
       <button class="page" v-if="true" @click="onHandleClick(0)">
-        <uni-icons type="list" size="40"></uni-icons>
+        <uni-icons type="list" size="40" />
         <view>项目列表</view>
       </button>
       <button class="page" v-if="true" @click="onHandleClick(1)">
-        <uni-icons type="checkmarkempty" size="40"></uni-icons>
+        <uni-icons type="checkmarkempty" size="40" />
         <view>项目审核</view>
       </button>
       <button class="page" v-if="true" @click="onHandleClick(2)">
-        <uni-icons type="calendar" size="40"></uni-icons>
+        <uni-icons type="calendar" size="40" />
         <view>工时上报</view>
       </button>
       <button class="page" v-if="true" @click="onHandleClick(3)">
-        <uni-icons type="auth" size="40"></uni-icons>
+        <uni-icons type="auth" size="40" />
         <view>工时审批</view>
       </button>
     </view>

+ 8 - 0
services/project.js

@@ -0,0 +1,8 @@
+import request from "./request";
+
+export async function queryProject(params) {
+  return await request("/v2/approval/record", "GET", {
+    ...params,
+    pageSize: 99999,
+  });
+}

+ 4 - 0
store/index.js

@@ -7,12 +7,16 @@ const store = new Vuex.Store({
   state: {
     typeList: [],
     allType: {},
+    currentProject: {},
   },
   mutations: {
     setType(state, values) {
       state.typeList = values.typeList;
       state.allType = values.allType;
     },
+    setCurrentProject(state, project) {
+      state.currentProject = project;
+    },
   },
   actions: {
     getType: async function ({ commit, state }, value) {