xujunjie 1 år sedan
förälder
incheckning
8d781e5255
3 ändrade filer med 56 tillägg och 19 borttagningar
  1. 41 18
      pages/daily/projectDaily.vue
  2. 4 0
      services/daily.js
  3. 11 1
      store/index.js

+ 41 - 18
pages/daily/projectDaily.vue

@@ -26,12 +26,14 @@
           <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>
@@ -110,6 +111,7 @@
 <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";
 
@@ -132,13 +134,26 @@ export default {
       return t ? moment(t).format("MM-DD HH:mm") : "-";
     },
   },
+  computed: {
+    ...mapState(["userList"]),
+  },
   methods: {
+    ...mapActions(["queryUserList"]),
     handelSearchConfirm() {
       this.pagination.currentPage = 1;
       this.initData();
     },
     handelChange(e) {
-      this.projectFilter.author = e.target.value
+      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();
@@ -161,6 +176,13 @@ export default {
       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({
@@ -173,6 +195,7 @@ export default {
   },
   onLoad(options) {
     this.project_id = options.project_id;
+    this.queryUserList();
   },
   onShow() {
     this.pagination.currentPage = 1;

+ 4 - 0
services/daily.js

@@ -4,6 +4,10 @@ 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);

+ 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;