Jelajahi Sumber

Merge branch 'master' of http://120.55.44.4:10080/xujunjie/WorkloadApp
merge
# Conflicts:
# pages/daily/form.vue

Renxy 1 tahun lalu
induk
melakukan
02099a800d
6 mengubah file dengan 159 tambahan dan 78 penghapusan
  1. 1 5
      pages/daily/daily.vue
  2. 44 38
      pages/daily/form.vue
  3. 92 34
      pages/daily/projectDaily.vue
  4. 8 0
      services/daily.js
  5. 11 1
      store/index.js
  6. 3 0
      utils/listMixin.js

+ 1 - 5
pages/daily/daily.vue

@@ -45,7 +45,6 @@
 import { queryDaily } from "@/services/daily";
 import mixin from "@/utils/listMixin";
 import moment from "moment";
-import { mapActions } from "vuex";
 
 export default {
   mixins: [mixin],
@@ -57,9 +56,7 @@ export default {
       list: [],
     };
   },
-  onLoad() {
-    this.queryProjectList();
-  },
+  
   onShow() {
     this.pagination.currentPage = 1;
     this.initData();
@@ -70,7 +67,6 @@ export default {
     },
   },
   methods: {
-    ...mapActions(["queryProjectList"]),
     handelSearchConfirm() {},
     scrollToLower() {
       if (this.list.length >= this.pagination.total) {

+ 44 - 38
pages/daily/form.vue

@@ -8,13 +8,7 @@
       <view class="forms">
         <view class="title2">张三的金科环境项目日志</view>
         <view class="title-sub">日志详情</view>
-        <uni-forms
-          :modelValue="formData"
-          label-position="left"
-          class="form"
-          ref="form"
-          :rules="rules"
-        >
+        <uni-forms label-position="left" class="form" ref="form" :rules="rules">
           <view class="box" v-for="item in formData" :key="item.key">
             <view
               v-show="formData.length > 1"
@@ -82,7 +76,7 @@ import {
   approvalDelLog,
   approvalEditLog,
 } from "@/services/daily";
-import { mapState } from "vuex";
+import { mapState, mapActions } from "vuex";
 export default {
   data() {
     return {
@@ -111,16 +105,26 @@ export default {
       },
     };
   },
+  onLoad() {},
   onLoad(options) {
+    this.queryProjectList();
     if (options.id) {
       this.initDate(options.id);
     }
+    if (options.project_id) {
+      this.project_id = options.project_id;
+    }
     this.log_id = options.id;
   },
   computed: {
     ...mapState(["projectList"]),
   },
   methods: {
+    ...mapActions(["queryProjectList"]),
+    getProjectName(id) {
+      const item = this.projectList.find((item) => item.ID == id);
+      return item ? item.Name : "-";
+    },
     selectProject(key, e) {
       const select = this.projectList[e.target.value];
       const idx = this.formData.findIndex((item) => item.key == key);
@@ -145,6 +149,10 @@ export default {
       this.formData.splice(index, 1);
     },
     async submit() {
+      // 从项目列表页进入的日志界面无须选择项目
+      if (this.project_id) {
+        this.formData.forEach((item) => (item.code_id = this.project_id));
+      }
       await createDaily(this.formData);
       uni.showToast({
         title: "添加成功",
@@ -156,34 +164,34 @@ export default {
     },
     async initDate(id) {
       //测试代码 详情接口有问题
-      this.formData = [
-        {
-          project_name: "11111",
-          code_id: "11111",
-          title: "11111",
-          content: "11111",
-        },
-        {
-          project_name: "3333",
-          code_id: "22222",
-          title: "22222",
-          content: "22222",
-        },
-        {
-          project_name: "45",
-          code_id: "111511",
-          title: "111161",
-          content: "111811",
-        },
-        {
-          project_name: "110111",
-          code_id: "111911",
-          title: "111119",
-          content: "119111",
-        },
-      ];
-      // const res = await approvalLogDaily({ id });
-      // console.log(res);
+      // this.formData = [
+      //   {
+      //     project_name: "11111",
+      //     code_id: "11111",
+      //     title: "11111",
+      //     content: "11111",
+      //   },
+      //   {
+      //     project_name: "3333",
+      //     code_id: "22222",
+      //     title: "22222",
+      //     content: "22222",
+      //   },
+      //   {
+      //     project_name: "45",
+      //     code_id: "111511",
+      //     title: "111161",
+      //     content: "111811",
+      //   },
+      //   {
+      //     project_name: "110111",
+      //     code_id: "111911",
+      //     title: "111119",
+      //     content: "119111",
+      //   },
+      // ];
+      const res = await approvalLogDaily({ id });
+      console.log(res);
     },
     async deleteLog() {
       await approvalDelLog(this.log_id);
@@ -209,8 +217,6 @@ export default {
 };
 </script>
 
-
-
 <style lang="less" scoped>
 .head {
   width: calc(100% - 60rpx);

+ 92 - 34
pages/daily/projectDaily.vue

@@ -19,19 +19,21 @@
           style="padding: 20rpx 30rpx"
           :radius="20"
           placeholder="请输入日志标题"
-          v-model="filter.searchKeyword"
+          v-model="projectFilter.searchKeyword"
           @confirm="handelSearchConfirm"
         />
         <view class="selectRow">
           <view class="selectCol">
             <picker
               style="max-width: 80%"
-              :range="[]"
-              range-key="label"
+              :range="userList"
+              range-key="CName"
               @change="handelChange"
             >
               <view class="pickerSlot">
-                <view class="itemText"> 提交人 </view>
+                <view class="itemText">
+                  {{ projectFilter.author_name || "提交人" }}
+                </view>
                 <!-- v-if="selectedValues[index] === null" -->
                 <image
                   class="triangle"
@@ -40,12 +42,12 @@
                 />
               </view>
             </picker>
-            <!-- <uni-icons
-              v-if="selectedValues[index] !== null"
+            <uni-icons
+              v-if="projectFilter.author_name"
               type="closeempty"
               size="14"
-              @click="cleanSelect(index)"
-            ></uni-icons> -->
+              @click="cleanSelect()"
+            ></uni-icons>
           </view>
           <view class="selectCol">
             <uniDatetimePicker
@@ -57,12 +59,11 @@
             >
               <view class="pickerSlot">
                 <view class="itemText">
-                  <!-- {{
-                    timerange.length !== 0
-                      ? `${timerange[0]}~${timerange[0]}`
-                      : item.placeholder
-                  }} -->
-                  发布日期
+                  {{
+                    projectFilter.s_time
+                      ? `${projectFilter.s_time}~${projectFilter.e_time}`
+                      : "发布日期"
+                  }}
                 </view>
                 <image
                   class="triangle"
@@ -71,12 +72,12 @@
                 />
               </view>
             </uniDatetimePicker>
-            <!-- <uni-icons
-              v-if="timerange.length === 2"
+            <uni-icons
+              v-if="projectFilter.s_time"
               type="closeempty"
               size="14"
-              @click="cleanSelect(index)"
-            ></uni-icons> -->
+              @click="cleanTime()"
+            ></uni-icons>
           </view>
         </view>
       </view>
@@ -86,21 +87,22 @@
         scroll-y="true"
         @scrolltolower="scrollToLower()"
       >
-        <view class="item">
+        <view class="item" v-for="item in list" :key="item.id">
           <view class="box">
-            <view class="title">张三的金科环境项目日志</view>
+            <view class="title">{{ item.title }}</view>
             <view class="desc">
               <view class="desc-title">日志概述:</view>
               <view class="desc-content">
-                项目进展顺利项目进展顺利项目进项目进展顺利项目进展顺利项目进
+                {{ item.content }}
               </view>
             </view>
             <view class="bottom">
-              <view class="time">07-12 8:50</view>
-              <view class="user">提交人:xxx</view>
+              <view class="time">{{ item.c_time | time }}</view>
+              <view class="user">提交人:{{ item.author_name }}</view>
             </view>
           </view>
         </view>
+        <view class="loadmore">{{ loadMoreText }}</view>
       </scroll-view>
     </view>
   </view>
@@ -109,39 +111,95 @@
 <script>
 import uniDatetimePicker from "@/uni_modules/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue";
 import moment from "moment";
+import { mapState, mapActions } from "vuex";
+import { queryProjectDaily } from "@/services/daily";
+import mixin from "@/utils/listMixin";
+
 export default {
   components: {
     uniDatetimePicker,
   },
+  mixins: [mixin],
   data() {
     return {
       scrollTop: 0,
-      filter: { searchKeyword: "" },
+      projectFilter: { searchKeyword: "", s_time: "", e_time: "" },
       project_id: "",
+      list: [],
+      loadMoreText: "暂无数据",
     };
   },
+  filters: {
+    time(t) {
+      return t ? moment(t).format("MM-DD HH:mm") : "-";
+    },
+  },
+  computed: {
+    ...mapState(["userList"]),
+  },
   methods: {
-    handelSearchConfirm() {},
-    handelChange() {},
+    ...mapActions(["queryUserList"]),
+    handelSearchConfirm() {
+      this.pagination.currentPage = 1;
+      this.initData();
+    },
+    handelChange(e) {
+      let select = this.userList[e.target.value];
+      this.projectFilter.author = select.ID;
+      this.projectFilter.author_name = select.CName;
+
+      this.pagination.currentPage = 1;
+      this.initData();
+    },
+    cleanSelect() {
+      this.projectFilter.author = null;
+      this.projectFilter.author_name = null;
+
+      this.pagination.currentPage = 1;
+      this.initData();
+    },
     scrollToLower() {
-      // if (this.projectList.length >= this.pagination.total) {
-      //   this.loadMoreText = "没有更多数据了";
-      //   return;
-      // }
-      // this.pagination.currentPage++;
-      // this.initData();
+      if (this.list.length >= this.pagination.total) {
+        this.loadMoreText = "没有更多数据了";
+        return;
+      }
+      this.pagination.currentPage++;
+      this.initData();
     },
     handelTimePickerChange(time) {
       if (time.length !== 2) {
         return;
       }
-      this.filter.start = moment(time[0]).format("YYYY-MM-DD 00:00:00");
+      this.projectFilter.s_time = moment(time[0]).format("YYYY-MM-DD 00:00:00");
+      this.projectFilter.e_time = moment(time[1]).format("YYYY-MM-DD 23:59:59");
 
-      this.filter.end = moment(time[1]).format("YYYY-MM-DD 23:59:59");
+      this.pagination.currentPage = 1;
+      this.initData();
+    },
+    cleanTime() {
+      this.projectFilter.s_time = null;
+      this.projectFilter.e_time = null;
+
+      this.pagination.currentPage = 1;
+      this.initData();
+    },
+    async getList(params) {
+      console.log(params);
+      let res = await queryProjectDaily({
+        ...params,
+        project_id: this.project_id,
+      });
+      this.list = res.data.list;
+      return res.data;
     },
   },
   onLoad(options) {
     this.project_id = options.project_id;
+    this.queryUserList();
+  },
+  onShow() {
+    this.pagination.currentPage = 1;
+    this.initData();
   },
 };
 </script>

+ 8 - 0
services/daily.js

@@ -4,6 +4,14 @@ import request from "./request";
 export async function queryDaily() {
   return await request("v2/approval/log-own/list", "GET");
 }
+// 查询用户列表
+export async function queryUserList() {
+  return await request("v2/user", "GET");
+}
+// 请求项目日志列表
+export async function queryProjectDaily(params) {
+  return await request(`v2/approval/log-projects/${params.project_id}`, "GET", params);
+}
 export async function queryProjectList() {
   return await request("v2/workload/project", "GET");
 }

+ 11 - 1
store/index.js

@@ -2,7 +2,7 @@ import Vue from "vue";
 import Vuex from "vuex";
 import { queryAllWorkType } from "@/services/workload";
 import { queryDep } from "@/services/project";
-import { queryProjectList } from "@/services/daily";
+import { queryProjectList, queryUserList } from "@/services/daily";
 
 Vue.use(Vuex);
 const store = new Vuex.Store({
@@ -13,6 +13,7 @@ const store = new Vuex.Store({
     currentProject: {},
     depUserTree: [],
     projectList: [],
+    userList: [],
   },
   mutations: {
     setType(state, values) {
@@ -52,6 +53,9 @@ const store = new Vuex.Store({
     saveProjectList(state, list) {
       state.projectList = list;
     },
+    saveUserList(state, list) {
+      state.userList = list;
+    },
   },
   actions: {
     getType: async function ({ commit, state }, value) {
@@ -66,6 +70,12 @@ const store = new Vuex.Store({
       const res = await queryProjectList();
       commit("saveProjectList", res.data?.list);
     },
+    queryUserList: async function ({ commit, state }, value) {
+      // 防止多次请求数据
+      if (state.userList.length != 0) return;
+      const res = await queryUserList();
+      commit("saveUserList", res.data?.list);
+    },
   },
 });
 export default store;

+ 3 - 0
utils/listMixin.js

@@ -23,6 +23,9 @@ export default {
         if (pagination.currentPage * pagination.pageSize >= pagination.total) {
           this.loadMoreText = "全部加载完毕";
         }
+        if(pagination.total == 0) {
+          this.loadMoreText = '暂无数据'
+        }
       });
     },
   },