Browse Source

3.1.4-sfc.12 定时开关机增加选择区间内的所有日期

liuyanpeng 11 tháng trước cách đây
mục cha
commit
434c2a5298
2 tập tin đã thay đổi với 60 bổ sung3 xóa
  1. 1 1
      package.json
  2. 59 2
      src/shelf/DeviceTimingSwitcher.vue

+ 1 - 1
package.json

@@ -1,7 +1,7 @@
 {
   "name": "client-wms-v3",
   "description": "Leanwo Prodog Client",
-  "version": "3.1.4-sfc.9",
+  "version": "3.1.4-sfc.12",
   "author": "yangzhijie1488 <yangzhijie1488@163.com>",
   "scripts": {
     "dev": "cross-env webpack serve --config ./webpack.dev.js",

+ 59 - 2
src/shelf/DeviceTimingSwitcher.vue

@@ -44,6 +44,9 @@
               <a-button :disabled="!dateRange" class="action-btn" @click="selectWorkdays">
                 选择区间内的工作日
               </a-button>
+              <a-button :disabled="!dateRange" class="action-btn" @click="selectAllDates">
+                选择区间内的所有日期
+              </a-button>
               <a-button type="primary" :disabled="isCalendarDisabled" class="action-btn" @click="selectWorkdaysOfYear">
                 选择年度剩余工作日
               </a-button>
@@ -665,6 +668,60 @@ const selectWorkdays = async () => {
   message.success(`本次共选择了 ${currentDates.value.length} 个工作日`);
 };
 
+// 选择区间内的所有日期
+const selectAllDates = async () => {
+  if (!dateRange.value || !dateRange.value[0] || !dateRange.value[1]) {
+    return;
+  }
+
+  const startDate = dateRange.value[0];
+  const endDate = dateRange.value[1];
+
+  // 生成日期范围内的所有日期
+  const allDates = [];
+  let currentDate = startDate.clone();
+  console.log('currentDate',startDate, currentDate, endDate);
+
+  while (currentDate <= endDate) {
+    allDates.push(currentDate.format('YYYY-MM-DD'));
+    currentDate = currentDate.add(1, 'day');
+  }
+
+  // 将选中的日期添加到当前日期列表(避免重复)
+  allDates.forEach(dateStr => {
+    if (
+      !currentDates.value.includes(dateStr) &&
+      !preDates.value.includes(dateStr)
+    ) {
+      currentDates.value.push(dateStr);
+    } else if (
+      preDates.value.includes(dateStr) &&
+      canceledDates.value.includes(dateStr)
+    ) {
+      // 如果日期在历史数据中且被取消了,从取消列表中移除
+      canceledDates.value = canceledDates.value.filter(d => d !== dateStr);
+    }
+  });
+
+  // 对当前日期列表排序
+  currentDates.value.sort();
+
+  // 重新构建总选中列表
+  const filteredPreDates = preDates.value.filter(
+    d => !canceledDates.value.includes(d),
+  );
+  selectedDates.value = [
+    ...new Set([...filteredPreDates, ...currentDates.value]),
+  ];
+  selectedDates.value.sort();
+
+  // 更新日历视图为开始日期所在的月份
+  currentMonth.value = startDate.month();
+  currentYear.value = startDate.year();
+
+  message.success(`本次共选择了 ${currentDates.value.length} 个日期`);
+};
+
 // 保存选择
 const saveSelections = () => {
   if (isCalendarDisabled.value) {
@@ -957,7 +1014,7 @@ const fetchAllDeviceIds = async () => {
     };
 
     const url =
-      'DeviceManagementResource/queryDeviceManagementDtoByScreenAndRfid';
+      'DeviceManagementResource/queryDeviceManagementDtoByScreen';
 
     await ajaxApi(url, params).then(
       success => {
@@ -1004,7 +1061,7 @@ const fetchDevices = async (search = '', reset = false) => {
     };
 
     const url =
-      'DeviceManagementResource/queryDeviceManagementDtoByScreenAndRfid';
+      'DeviceManagementResource/queryDeviceManagementDtoByScreen';
 
     await ajaxApi(url, params).then(
       success => {