Bläddra i källkod

新增项目导入上一篇功能/根据反馈修复问题

fanghuisheng 7 månader sedan
förälder
incheckning
d8da7d5b30

+ 8 - 1
src/api/business/project.js

@@ -34,7 +34,7 @@ export function projectApi() {
         ProjectsList(data) {
             return request({
                 url: '/service-iot/pmProject/projects',
-                method: 'get',
+                method: 'GET',
                 data: data
             })
         },
@@ -44,6 +44,13 @@ export function projectApi() {
                 method: 'POST',
                 data: data
             })
+        },
+        ProjectsWeekList(data) {
+            return request({
+                url: '/service-iot/pmWorkReport/week',
+                method: 'GET',
+                data: data
+            })
         }
     };
 }

+ 9 - 0
src/api/system/user.js

@@ -65,6 +65,15 @@ export function deptUserTreeSelect(query) {
   })
 }
 
+// 用户列表
+export function UserList(query) {
+  return request({
+    url: '/system//user/list',
+    method: 'GET',
+    params: query
+  })
+}
+
 // 微信用户验证
 export function getPageAuthorization(data) {
   return request({

+ 2 - 2
src/pages/business/common/projectMange/record/index.vue

@@ -44,7 +44,7 @@
     <template #default>
       <u-loading-page :loading="state.loading" fontSize="16" style="z-index: 99"></u-loading-page>
       <view class="content-area" v-for="(group, date) in proxy.$common.groupedItems(state.dataList, 'createTime')" :key="date">
-        <view class="content-area-time font14">{{ proxy.$common.jktTimes(date, "否") }}</view>
+        <view class="content-area-time font14">{{ proxy.$time.jktTimes(date, "否") }}</view>
         <view class="content-area-center bg-white" v-for="(el, ind) in group" :key="ind" @click="goContentDetails(el)">
           <view class="flex mb10">
             <u-avatar
@@ -58,7 +58,7 @@
             ></u-avatar>
             <view>
               <view class="content-area-center-title font14 mb5">{{ el.createBy }}的日报</view>
-              <view class="content-area-center-time font12">{{ proxy.$common.jktTimes(el.createTime.replace("T", " ")) }}</view>
+              <view class="content-area-center-time font12">{{ proxy.$time.jktTimes(el.createTime.replace("T", " ")) }}</view>
             </view>
           </view>
           <view class="mb5">

+ 54 - 10
src/pages/business/common/projectMange/write/components/template1.vue

@@ -170,15 +170,22 @@
 <script setup>
 /*----------------------------------依赖引入-----------------------------------*/
 import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
-import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
+import { ref, reactive, computed, getCurrentInstance, toRefs, inject, watchEffect } from "vue";
 /*----------------------------------接口引入-----------------------------------*/
 import { projectApi } from "@/api/business/project.js";
+import { UserList } from "@/api/system/user.js";
 /*----------------------------------组件引入-----------------------------------*/
 /*----------------------------------store引入-----------------------------------*/
 /*----------------------------------公共方法引入-----------------------------------*/
 import { storageSystem } from "@/utils/storage"; // 公共方法引用
 /*----------------------------------公共变量-----------------------------------*/
 const { proxy } = getCurrentInstance();
+const props = defineProps({
+  projectList: {
+    type: Object,
+    default: {},
+  },
+});
 /*----------------------------------变量声明-----------------------------------*/
 const state = reactive({
   timeShow: false,
@@ -198,14 +205,19 @@ const state = reactive({
   projectsCheck: [],
   projectsList: [],
   userList: [],
+  userDate: [],
   saveTime: "",
 });
-const { timeShow, timeValue, modalShow, form, projectsCheck, projectsList, userList, saveTime } = toRefs(state);
+const { timeShow, timeValue, modalShow, form, projectsCheck, projectsList, userList, userDate, saveTime } = toRefs(state);
 
 /**
  * @初始化
  */
 function init() {
+  UserList({ pageNum: "1", pageSize: "10000" }).then((res) => {
+    state.userDate = res.data.rows;
+  });
+
   projectApi()
     .ProjectsList()
     .then((requset) => {
@@ -220,7 +232,7 @@ function timeInputClick() {
 
 /** 时间选择器确定按钮点击事件 */
 function timeConfirm() {
-  state.form.timingTime = proxy.$common.formatterDateTime(state.timeValue);
+  state.form.timingTime = proxy.$time.getFormatterDate(state.timeValue);
   state.timeShow = false;
 }
 
@@ -251,7 +263,7 @@ function insertProjects() {
 
 /** 实时保存填写数据 */
 function realTimeSaving() {
-  state.saveTime = proxy.$common.formatterDate(new Date(), "hh:mm");
+  state.saveTime = proxy.$time.formatterDate(new Date(), "hh:mm");
   storageSystem.set("project", state);
 }
 
@@ -289,7 +301,7 @@ function handleSubmit() {
   }
 
   state.form.ccTo = state.userList.map((obj) => `${obj.id}`).join(",");
-  state.form.reportDate = proxy.$common.formatterDate(new Date(), "yyyy-MM-dd");
+  state.form.reportDate = proxy.$time.formatterDate(new Date(), "yyyy-MM-dd");
   state.form.workContents.forEach((e) => {
     e.workTime = parseInt(e.workTime);
   });
@@ -298,15 +310,47 @@ function handleSubmit() {
     .Insert(state.form)
     .then((requset) => {
       proxy.$tab.redirectTo("/pages/business/common/projectMange/record/index"); //返回到需要执行方法的页面
-      state.form = {
-        workContents: [],
-        tomorrowPlan: "",
-        coordinateWork: null,
-      };
+      state.form.workContents = [];
+      state.form.tomorrowPlan = "";
+      state.form.coordinateWork = null;
+      state.form.isRegularlySend = 0;
+      state.form.timingTime = null;
       storageSystem.set("project", state);
     });
 }
 
+watchEffect(() => {
+  if (JSON.stringify(props.projectList) != "{}") {
+    state.userList = [];
+
+    Object.keys(props.projectList).forEach((key) => {
+      state.form[key] = props.projectList[key];
+    });
+
+    var ccTo = state.form.ccTo.length > 0 ? state.form.ccTo.split(",").map((num) => Number(num)) : [];
+    state.userDate.forEach((e) => {
+      if (ccTo.includes(e.userId)) {
+        state.userList.push({
+          address: e.address,
+          avatar: e.avatar,
+          deptId: e.deptId,
+          email: e.email,
+          id: e.userId,
+          label: e.nickName,
+          nickName: e.nickName,
+          phonenumber: e.phonenumber,
+          post: e.post,
+          sex: e.sex,
+          userId: e.userId,
+          userName: e.userName,
+        });
+      }
+    });
+
+    storageSystem.set("project", state);
+  }
+});
+
 onReady(() => {});
 
 onShow(() => {

+ 45 - 3
src/pages/business/common/projectMange/write/insert.vue

@@ -8,7 +8,7 @@
       </template>
       <template #right>
         <view class="u-navbar__content__right__item">
-          <u-icon name="more-dot-fill" size="20" color="#000"></u-icon>
+          <u-icon name="more-dot-fill" size="20" color="#000" @click="moreClick()"></u-icon>
         </view>
       </template>
     </u-navbar>
@@ -31,9 +31,15 @@
     :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
   >
     <template #default>
-      <template1 v-if="templateId == 1" />
+      <template1 v-if="templateId == 1" :projectList="newProjectList" />
     </template>
   </oa-scroll>
+
+  <u-modal :show="modalShow" title="" :cancelText="'取消'" :zoom="false" :showConfirmButton="false" :showCancelButton="true" @cancel="modalShow = false">
+    <view class="slot-content">
+      <view @click="handleSubmit('importPrevious')">导入上一篇</view>
+    </view>
+  </u-modal>
 </template>
 
 <script setup>
@@ -41,6 +47,7 @@
 import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
 import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
 /*----------------------------------接口引入-----------------------------------*/
+import { projectApi } from "@/api/business/project.js";
 /*----------------------------------组件引入-----------------------------------*/
 import template1 from "./components/template1.vue";
 /*----------------------------------store引入-----------------------------------*/
@@ -50,8 +57,37 @@ const { proxy } = getCurrentInstance();
 /*----------------------------------变量声明-----------------------------------*/
 const state = reactive({
   templateId: 1,
+  modalShow: false,
+  newProjectList: {},
 });
-const { templateId } = toRefs(state);
+const { templateId, modalShow, newProjectList } = toRefs(state);
+
+function moreClick() {
+  state.modalShow = true;
+}
+
+function handleSubmit(type) {
+  if (type === "importPrevious") {
+    projectApi()
+      .ProjectsWeekList({
+        startDate: proxy.$time.getCurrentWeekDate().startDate,
+        endDate: proxy.$time.getCurrentWeekDate().endDate,
+      })
+      .then((requset) => {
+        var newData = requset.data[0].newData[0];
+
+        state.newProjectList = {
+          tomorrowPlan: newData.tomorrowPlan,
+          coordinateWork: newData.coordinateWork,
+          workContents: newData.workContents,
+          sendDingTalk: newData.sendDingTalk,
+          ccTo: newData.ccTo,
+        };
+
+        state.modalShow = false;
+      });
+  }
+}
 
 onReady(() => {});
 
@@ -66,3 +102,9 @@ onLoad((options) => {
 
 onUnload(() => {});
 </script>
+<style lang="scss" scoped>
+:deep(.u-modal__content) {
+  font-size: 14px;
+  justify-content: left;
+}
+</style>

+ 2 - 2
src/pages/business/fireIot/customManage/index.vue

@@ -113,8 +113,8 @@ function selectListApi() {
     projectName: projectName.value,
     current: current.value,
     size: pageSize.value,
-    endTime: radioValue.value ? proxy.$common.getDays(-radioValue.value)[0] + " 00:00:00" : "",
-    startTime: radioValue.value ? proxy.$common.getDays(-radioValue.value)[1] + " 00:00:00" : "",
+    endTime: radioValue.value ? proxy.$time.getDays(-radioValue.value)[0] + " 00:00:00" : "",
+    startTime: radioValue.value ? proxy.$time.getDays(-radioValue.value)[1] + " 00:00:00" : "",
   }).then((requset) => {
     if (requset.status === "SUCCESS") {
       dataList.value = requset.data.records;

+ 2 - 2
src/pages/business/mhxf/informationSelect/index.vue

@@ -73,7 +73,7 @@ const state = reactive({
   classifyUrl: "",
   placeholderText: "",
   classifyData: undefined, //警情查询数据存储
-  operateDate: proxy.$common.formatterDateTime(new Date()), //操作时间
+  operateDate: proxy.$time.getFormatterDate(new Date()), //操作时间
 });
 
 const inter = reactive({
@@ -510,7 +510,7 @@ watchEffect(() => {
 
 onLoad((options) => {
   inter.interOperateDate = setInterval(() => {
-    state.operateDate = proxy.$common.formatterDateTime(new Date());
+    state.operateDate = proxy.$time.getFormatterDate(new Date());
   }, 1000);
 });
 

+ 1 - 1
src/pages/business/mhxf/unitInfoCollection/index.vue

@@ -963,7 +963,7 @@ function handleDateTime(value, index, time) {
  * @确定按钮事件
  */
 function timeSubmit(data) {
-  let time = proxy.$common.formatterDateTime(data.value);
+  let time = proxy.$time.getFormatterDate(data.value);
   let timeData = time.split(" ")[0];
   if (timeTitle.value == "成立时间") {
     form.value.foundTime = timeData;

+ 2 - 2
src/pages/business/zhaf/signIn/index.vue

@@ -44,7 +44,7 @@ const state = reactive({
   address: "", //准确位置信息
   deviceCode: uni.getSystemInfoSync().deviceId, //设备编号
   signInType: 1, //签到类型(0:已签到 1:已签退)
-  operateDate: proxy.$common.formatterDateTime(new Date()), //操作时间
+  operateDate: proxy.$time.getFormatterDate(new Date()), //操作时间
   operateCode: 0, //操作类型
   longitude: "", //经度
   latitude: "", //纬度
@@ -107,7 +107,7 @@ onLoad(() => {
   inter.interLocation = setInterval(getLocation(), 1000 * 10);
   //#endif
   inter.interOperateDate = setInterval(() => {
-    state.operateDate = proxy.$common.formatterDateTime(new Date());
+    state.operateDate = proxy.$time.getFormatterDate(new Date());
   }, 1000);
 });
 

+ 1 - 1
src/pages/business/zhaf/xunJian/collect/components/collectDetail.vue

@@ -69,7 +69,7 @@ function handleInsert() {
     .validate()
     .then((res) => {
       let endTime = new Date();
-      model.siteTime = proxy.$common.formatterDate(endTime, "yyyy-MM-dd hh:mm:ss");
+      model.siteTime = proxy.$time.formatterDate(endTime, "yyyy-MM-dd hh:mm:ss");
 
       xunJianStore.collectDataList.push(model);
       proxy.$tab.navigateBack(1); //返回到需要执行方法的页面

+ 1 - 1
src/pages/business/zhaf/xunJian/plan/index.vue

@@ -321,7 +321,7 @@ function activitiesApi() {
  * @统计
  * @api接口请求
  */
-const currentDate = ref(proxy.$common.getDate().year + "-" + proxy.$common.getDate().month + "-" + proxy.$common.getDate().dates); //统计时间数据存储
+const currentDate = ref(proxy.$time.getDate().year + "-" + proxy.$time.getDate().month + "-" + proxy.$time.getDate().dates); //统计时间数据存储
 const currentDatevalue = ref(new Date());
 const currentDateList = ref({}); //统计list数据存储
 function currentApi() {

+ 1 - 1
src/pages/business/zhaf/xunJian/xunJian.vue

@@ -53,7 +53,7 @@ const xunJianStore = xunJianStores(); //全局变量值Store
 /*----------------------------------变量声明-----------------------------------*/
 const inspectList = proxy.$constData.xunJianList; //九宫格json数据
 
-const currentDate = proxy.$common.getDate().year + "-" + proxy.$common.getDate().month + "-" + proxy.$common.getDate().dates;
+const currentDate = proxy.$time.getDate().year + "-" + proxy.$time.getDate().month + "-" + proxy.$time.getDate().dates;
 const currentDateList = ref([]);
 
 function navItemClick(url, id) {

+ 1 - 1
src/pages/common/alarmMessage/index.vue

@@ -83,7 +83,7 @@ function init() {
         requset.data.records.forEach((el) => {
           state.allInfoList.push({
             sitePhoto: el.sitePhoto,
-            time: proxy.$common.jktTimes(el.alarmTime),
+            time: proxy.$time.jktTimes(el.alarmTime),
             deviceId: el.deviceId,
             deviceName: el.deviceName,
             alarmType: el.alarmType,

+ 2 - 2
src/pages/common/appMessage/index.vue

@@ -17,7 +17,7 @@
       <u-loading-page :loading="state.loading" fontSize="16" style="z-index: 99"></u-loading-page>
 
       <view class="content-area" v-for="(group, date) in proxy.$common.groupedItems(state.noticeList, 'createTime')" :key="date">
-        <view class="content-area-time font14">{{ proxy.$common.jktTimes(date, "否") }}</view>
+        <view class="content-area-time font14">{{ proxy.$time.jktTimes(date, "否") }}</view>
         <view
           class="content-area-center flex bg-white list-cell list-cell-arrow"
           :id="ind == noticeList.length - 1 ? 'bottomInfo' : ''"
@@ -31,7 +31,7 @@
             <view class="content-area-center-cont font14">{{ el.infoContent }}</view>
           </view>
           <view class="content-area-center-badge"><u-badge :isDot="el.readFlag == 0 ? true : false" type="error"></u-badge></view>
-          <view class="content-area-center-time font14">{{ proxy.$common.jktTimes(el.createTime.replace("T", " ")) }}</view>
+          <view class="content-area-center-time font14">{{ proxy.$time.jktTimes(el.createTime.replace("T", " ")) }}</view>
         </view>
       </view>
     </template>

+ 2 - 2
src/pages/common/invoicing/index.vue

@@ -247,8 +247,8 @@ function handleSubmit(value) {
         current: 1,
         size: 10,
         invoiceTitle: form.value.invoiceTitle,
-        startTime: proxy.$common.getYearLast(new Date()),
-        endTime: proxy.$common.formatterDateTime(new Date()),
+        startTime: proxy.$time.getYearLast(new Date()),
+        endTime: proxy.$time.getFormatterDate(new Date()),
       }).then((requset) => {
         if (requset.status === "SUCCESS") {
           proxy.$modal.closeLoading();

+ 1 - 1
src/pages/mine.vue

@@ -40,7 +40,7 @@
                 <view>我的信息</view>
               </view>
             </view>
-            <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToSecure()" v-if="proxy.$common.isVisible()">
+            <view class="list-cell list-cell-arrow" @click="proxy.$settingStore.handleToSecure()">
               <view class="menu-item">
                 <view class="iconfont oaIcon-yanzheng menu-item-icon"></view>
                 <view>账号与安全</view>

+ 5 - 5
src/pages/mine/secure/index.vue

@@ -23,19 +23,19 @@
 
       <view class="menu-list mt0 mlr0">
         <!-- #ifdef APP-PLUS || MP-WEIXIN -->
-        <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
+        <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')" v-if="proxy.$common.isVisible()">
           <!-- <view class="list-cell list-cell-arrow" @click="proxy.$tab.navigateTo(`/pages/mine/secure/fingerprint/index`)"> -->
           <view class="menu-item">
             <view class="title">指纹登录</view>
           </view>
         </view>
         <!-- #endif -->
-        <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
+        <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')" v-if="proxy.$common.isVisible()">
           <view class="menu-item">
             <view class="title">人脸</view>
           </view>
         </view>
-        <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
+        <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')" v-if="proxy.$common.isVisible()">
           <view class="menu-item">
             <view class="title">手势密码</view>
           </view>
@@ -48,14 +48,14 @@
             <view class="title">登录日志</view>
           </view>
         </view>
-        <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')">
+        <view class="list-cell list-cell-arrow" @click="proxy.$modal.showToast('模块建设中~')" v-if="proxy.$common.isVisible()">
           <view class="menu-item">
             <view class="title">常用设备管理</view>
           </view>
         </view>
       </view>
 
-      <view class="menu-list mt0 mlr0" @click="handleUserModal('手机号验证')">
+      <view class="menu-list mt0 mlr0" @click="handleUserModal('手机号验证')" v-if="proxy.$common.isVisible()">
         <view class="list-cell">
           <view class="menu-item">
             <view class="button error">注 销 账 号</view>

+ 0 - 151
src/plugins/common.plugins.js

@@ -100,45 +100,6 @@ export default {
     textarea.remove()
     // #endif
   },
-  /**
-   * @param {时间处理(今日,昨日)} 
-   * @param {传入值} time 
-   * @param {是否携带时分秒} isTime
-   * @returns 
-   */
-  jktTimes(time, isTime) {
-    if (time == undefined) return "";
-    var today = new Date().getDate();//当前时间-日
-    var day = new Date(time).getDate();//传入时间-日
-
-    var newday = today - day
-    if (newday == 0) {
-      if (isTime == "否") {
-        return "今天";
-      } else {
-        var newTime = time.split(" ")[1]
-        var newTime2 = newTime.split(":")
-        return newTime2[0] + ":" + newTime2[1];
-      }
-    } else if (newday == 1) {
-      if (isTime == "否") {
-        return "昨天";
-      } else {
-        var newTime = time.split(" ")[1]
-        var newTime2 = newTime.split(":")
-        return newTime2[0] + ":" + newTime2[1];
-      }
-    } else {
-      var newTime = time.split(" ")
-
-      if (isTime == "否") {
-        return newTime[0]
-      } else {
-        var newTime2 = newTime[1].split(":")
-        return newTime2[0] + ":" + newTime2[1];
-      }
-    }
-  },
   /**
    * @根据时间分类数据
    * @param {数据集} data 
@@ -154,40 +115,6 @@ export default {
     });
     return grouped;
   },
-  /**
-   * @指定获取开始时间结束时间
-   */
-  getDays(value) {
-    let oneDay = 24 * 60 * 60 * 1000;
-    let endTime = new Date(Date.now());
-    endTime = this.formatterDate(endTime, "yyyy-MM-dd");
-    let startTime = new Date(Date.now() - value * oneDay);
-    startTime = this.formatterDate(startTime, "yyyy-MM-dd");
-    const days = [startTime, endTime,]
-    return days;
-  },
-  /**
-   * @处理公共日期格式
-   */
-  formatterDate(date, fmt) {
-    let nowDate = {
-      yyyy: date.getFullYear(), // 年
-      MM: date.getMonth() + 1, // 月份
-      dd: date.getDate(), //日
-      hh: date.getHours(),
-      mm: date.getMinutes(),
-      ss: date.getSeconds(),
-    };
-    if (/(y+)/.test(fmt)) {
-      fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
-    }
-    for (var k in nowDate) {
-      if (new RegExp("(" + k + ")").test(fmt)) {
-        fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? nowDate[k] : ("00" + nowDate[k]).substr(("" + nowDate[k]).length));
-      }
-    }
-    return fmt;
-  },
   /**
    * @公共获取URL中的参数
    */
@@ -204,84 +131,6 @@ export default {
     }
     return theRequest;
   },
-  /**
-   * @获取当前日期前一年的日期
-   */
-  getYearLast(dateStr) {
-    // 假设要获取的日期为dateStr,格式为"YYYY-MM-DD"
-    let date = new Date(dateStr);
-    let Y = date.getFullYear() - 1; // 获取前一年的年份
-    let M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; // 月
-    let D; // 日
-
-    var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
-    var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
-    var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
-
-    // 判断原日期的月份是否为2月份
-    if (date.getMonth() === 1) { // 2月份
-      // 判断前一年是否为闰年
-      if (Y % 4 === 0 && Y % 100 !== 0 || Y % 400 === 0) { // 闰年
-        D = Math.min(date.getDate(), 29); // 新日期的日期最大为29
-      } else { // 平年
-        D = Math.min(date.getDate(), 28); // 新日期的日期最大为28
-      }
-    } else { // 非2月份
-      D = date.getDate(); // 新日期的日期为原日期的日期
-    }
-
-    let newDateStr = Y + "-" + M + "-" + (D < 10 ? "0" + D : D) + " " + h + m + s; // 格式化日期字符串
-
-    return newDateStr
-  },
-  /**
-   * @获取年月日时分秒
-   * @returns
-   */
-  formatterDateTime(time3) {
-    var date = new Date(time3);
-    var Y = date.getFullYear() + "-";
-    var M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
-    var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
-
-    var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
-    var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
-    var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
-    var strDate = Y + M + D + h + m + s;
-
-    return strDate;
-  },
-  /**
-   * @统计两个日期之间的月份
-   */
-  getMonths(date1, date2) {
-    //用-分成数组
-    date1 = date1.split("-");
-    date2 = date2.split("-");
-    //获取年,月数
-    var year1 = parseInt(date1[0]),
-      month1 = parseInt(date1[1]),
-      year2 = parseInt(date2[0]),
-      month2 = parseInt(date2[1]),
-      //通过年,月差计算月份差
-      months = (year2 - year1) * 12 + (month2 - month1) + 1;
-    return months;
-  },
-  getDate() {
-    var date = new Date();
-    var year = date.getFullYear(); //  返回的是年份
-    var month = date.getMonth() + 1; //  返回的月份上个月的月份,记得+1才是当月
-    if (month < 10) {
-      month = "0" + month;
-    }
-    var dates = date.getDate(); //  返回的是几号
-    if (dates < 10) {
-      dates = "0" + dates;
-    }
-    var day = date.getDay(); //  周一返回的是1,周六是6,但是周日是0
-    var arr = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
-    return { year, month, dates, day, arr, };
-  },
   /**
    * @数组对象排序
    * @return

+ 4 - 0
src/plugins/index.js

@@ -3,6 +3,7 @@ import auth from "./auth.plugins";
 import modal from "./modal.plugins";
 import common from "./common.plugins";
 import setting from "./setting.plugins";
+import time from "./time.plugins.js";
 import constData from "./constData.plugins.js";
 import nfc from "./nfc.plugins.js";
 
@@ -33,6 +34,9 @@ export default {
     // 公共设置方法
     app.provide("$setting", setting);
     app.config.globalProperties.$setting = setting;
+    // 公共时间处理方法
+    app.provide("$time", time);
+    app.config.globalProperties.$time = time;
     // 公共默认数据存储
     app.provide("$constData", constData);
     app.config.globalProperties.$constData = constData;

+ 171 - 0
src/plugins/time.plugins.js

@@ -0,0 +1,171 @@
+export default {
+    /**
+     * @param {时间处理(今日,昨日)} 
+     * @param {传入值} time 
+     * @param {是否携带时分秒} isTime
+     * @returns 
+     */
+    jktTimes(time, isTime) {
+        if (time == undefined) return "";
+        var today = new Date().getDate();//当前时间-日
+        var day = new Date(time).getDate();//传入时间-日
+
+        var newday = today - day
+        if (newday == 0) {
+            if (isTime == "否") {
+                return "今天";
+            } else {
+                var newTime = time.split(" ")[1]
+                var newTime2 = newTime.split(":")
+                return newTime2[0] + ":" + newTime2[1];
+            }
+        } else if (newday == 1) {
+            if (isTime == "否") {
+                return "昨天";
+            } else {
+                var newTime = time.split(" ")[1]
+                var newTime2 = newTime.split(":")
+                return newTime2[0] + ":" + newTime2[1];
+            }
+        } else {
+            var newTime = time.split(" ")
+
+            if (isTime == "否") {
+                return newTime[0]
+            } else {
+                var newTime2 = newTime[1].split(":")
+                return newTime2[0] + ":" + newTime2[1];
+            }
+        }
+    },
+    /**
+     * @指定获取开始时间结束时间
+     */
+    getDays(value) {
+        let oneDay = 24 * 60 * 60 * 1000;
+        let endTime = new Date(Date.now());
+        endTime = this.formatterDate(endTime, "yyyy-MM-dd");
+        let startTime = new Date(Date.now() - value * oneDay);
+        startTime = this.formatterDate(startTime, "yyyy-MM-dd");
+        const days = [startTime, endTime]
+        return days;
+    },
+    /**
+     * @处理公共日期格式
+     */
+    formatterDate(date, fmt) {
+        let nowDate = {
+            yyyy: date.getFullYear(), // 年
+            MM: date.getMonth() + 1, // 月份
+            dd: date.getDate(), //日
+            hh: date.getHours(),
+            mm: date.getMinutes(),
+            ss: date.getSeconds(),
+        };
+        if (/(y+)/.test(fmt)) {
+            fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
+        }
+        for (var k in nowDate) {
+            if (new RegExp("(" + k + ")").test(fmt)) {
+                fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? nowDate[k] : ("00" + nowDate[k]).substr(("" + nowDate[k]).length));
+            }
+        }
+        return fmt;
+    },
+    /**
+     * @获取年月日时分秒
+     * @returns
+     */
+    getFormatterDate(time3) {
+        var date = new Date(time3);
+        var Y = date.getFullYear() + "-";
+        var M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
+        var D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
+
+        var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
+        var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
+        var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
+        var strDate = Y + M + D + h + m + s;
+
+        return strDate;
+    },
+    /**
+     * @获取当前日期前一年的日期
+     */
+    getYearLast(dateStr) {
+        // 假设要获取的日期为dateStr,格式为"YYYY-MM-DD"
+        let date = new Date(dateStr);
+        let Y = date.getFullYear() - 1; // 获取前一年的年份
+        let M = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; // 月
+        let D; // 日
+
+        var h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
+        var m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":";
+        var s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
+
+        // 判断原日期的月份是否为2月份
+        if (date.getMonth() === 1) { // 2月份
+            // 判断前一年是否为闰年
+            if (Y % 4 === 0 && Y % 100 !== 0 || Y % 400 === 0) { // 闰年
+                D = Math.min(date.getDate(), 29); // 新日期的日期最大为29
+            } else { // 平年
+                D = Math.min(date.getDate(), 28); // 新日期的日期最大为28
+            }
+        } else { // 非2月份
+            D = date.getDate(); // 新日期的日期为原日期的日期
+        }
+        let newDateStr = Y + "-" + M + "-" + (D < 10 ? "0" + D : D) + " " + h + m + s; // 格式化日期字符串
+        return newDateStr
+    },
+    /**
+     * @统计两个日期之间的月份
+     */
+    getMonths(date1, date2) {
+        //用-分成数组
+        date1 = date1.split("-");
+        date2 = date2.split("-");
+        //获取年,月数
+        var year1 = parseInt(date1[0]),
+            month1 = parseInt(date1[1]),
+            year2 = parseInt(date2[0]),
+            month2 = parseInt(date2[1]),
+            //通过年,月差计算月份差
+            months = (year2 - year1) * 12 + (month2 - month1) + 1;
+        return months;
+    },
+    /**
+     * @获取年月日星期几
+     */
+    getDate() {
+        var date = new Date();
+        var year = date.getFullYear(); //  返回的是年份
+        var month = date.getMonth() + 1; //  返回的月份上个月的月份,记得+1才是当月
+        if (month < 10) {
+            month = "0" + month;
+        }
+        var dates = date.getDate(); //  返回的是几号
+        if (dates < 10) {
+            dates = "0" + dates;
+        }
+        var day = date.getDay(); //  周一返回的是1,周六是6,但是周日是0
+        var arr = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
+        return { year, month, dates, day, arr, };
+    },
+    /**
+     * @获取当前周开始结束日期
+     */
+    getCurrentWeekDate() {
+        const now = new Date();
+        const startOfWeek = new Date(now.getFullYear(), now.getMonth(), now.getDate() - now.getDay() + 1); // 本周开始日期
+        const endOfWeek = new Date(startOfWeek);
+        endOfWeek.setDate(endOfWeek.getDate() + 6); // 本周结束日期
+
+        const startDate = this.getFormatterDate(startOfWeek).split(' ')[0];
+        const endDate = this.getFormatterDate(endOfWeek).split(' ')[0];
+
+        return {
+            startDate: startDate,
+            endDate: endDate
+        }
+    }
+}