yanghao 1 هفته پیش
والد
کامیت
befe18e9ac
3فایلهای تغییر یافته به همراه94 افزوده شده و 46 حذف شده
  1. 1 1
      .env.local
  2. 91 45
      src/views/report-statistics/device_book/index2.vue
  3. 2 0
      src/views/report-statistics/inspection_order/index.vue

+ 1 - 1
.env.local

@@ -4,7 +4,7 @@ NODE_ENV=development
 VITE_DEV=true
 
 # 请求路径  http://192.168.188.149:48080  https://iot.deepoil.cc
-VITE_BASE_URL='https://iot.deepoil.cc'
+VITE_BASE_URL='http://192.168.188.149:48080'
 
 # 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持 S3 服务
 VITE_UPLOAD_TYPE=server

+ 91 - 45
src/views/report-statistics/device_book/index2.vue

@@ -86,8 +86,19 @@
           </div>
         </el-col>
       </el-row>
+
+      <el-row :gutter="20">
+        <el-col :span="24">
+          <el-radio-group v-model="dateType" size="default" fill="#409eff">
+            <el-radio-button label="年" value="year" />
+            <el-radio-button label="月" value="month" />
+            <el-radio-button label="日" value="day" />
+          </el-radio-group>
+        </el-col>
+      </el-row>
+
       <!-- 列表 -->
-      <ContentWrap style="border: 0; margin-top: 20px">
+      <ContentWrap style="border: 0; margin-top: 10px">
         <el-table
           v-loading="loading"
           :data="list"
@@ -228,34 +239,6 @@
         />
       </ContentWrap>
 
-      <!-- 在 template 中的 el-row 后面添加导出对话框 -->
-      <!-- <el-dialog
-        v-model="exportDialogVisible"
-        title="导出设置"
-        width="500px"
-        :close-on-click-modal="false"
-        :close-on-press-escape="false"
-      >
-        <div class="export-dialog-content">
-          <p class="mb-3">请选择要导出的列:</p>
-          <el-checkbox-group v-model="selectedColumns" class="grid grid-cols-2 gap-2 w-full">
-            <el-checkbox
-              v-for="column in availableColumns"
-              :key="column.prop"
-              :label="column.prop"
-              class="mb-2"
-            >
-              {{ column.label }}
-            </el-checkbox>
-          </el-checkbox-group>
-        </div>
-        <template #footer>
-          <div class="dialog-footer">
-            <el-button @click="exportDialogVisible = false">取消</el-button>
-            <el-button type="primary" @click="confirmExport">确认导出</el-button>
-          </div>
-        </template>
-      </el-dialog> -->
       <el-dialog
         v-model="exportDialogVisible"
         title="导出设置"
@@ -312,7 +295,7 @@ import { useRefreshStore } from '@/store/modules/pms/refreshStore'
 import Echart from '@/components/Echart/src/Echart.vue'
 import echarts from '@/plugins/echarts'
 import { formatDate } from '@/utils/formatTime'
-import { nextTick } from 'vue'
+import { nextTick, watch } from 'vue'
 import download from '@/utils/download'
 
 /** 设备台账 列表 */
@@ -359,7 +342,8 @@ const queryParams = reactive({
   creator: undefined,
   sortingFields: [],
   assetClass: undefined,
-  yfDeviceCode: undefined
+  yfDeviceCode: undefined,
+  createTime: []
 })
 const queryFormRef = ref(null) // 搜索的表单
 const contentSpan = ref(20)
@@ -373,19 +357,19 @@ const availableColumns = ref<any>([]) // 可用的列选项
 const getTableColumns = () => {
   // 根据表格定义动态获取列信息
   availableColumns.value = [
-    { prop: '设备编码', label: '设备编码', visible: true },
-    { prop: '设备名称', label: '设备名称', visible: true },
-    { prop: '公司', label: '公司', visible: true },
-    { prop: '部门名称', label: '部门名称', visible: true },
-    { prop: '设备状态', label: '设备状态', visible: true },
-    { prop: '资产性质', label: '资产性质', visible: true },
-    { prop: '资产类别', label: '资产类别', visible: true },
-    { prop: '生产厂家', label: '生产厂家', visible: true },
-    { prop: '生产日期', label: '生产日期', visible: true },
-    { prop: '投运日期', label: '投运日期', visible: true },
-    { prop: '品牌', label: '品牌', visible: true },
-    { prop: '规格型号', label: '规格型号', visible: true },
-    { prop: '责任人', label: '责任人', visible: true }
+    { prop: 'deviceCode', label: '设备编码', visible: true },
+    { prop: 'deviceName', label: '设备名称', visible: true },
+    { prop: 'company', label: '公司', visible: true },
+    { prop: 'deptName', label: '部门名称', visible: true },
+    { prop: 'deviceStatus', label: '设备状态', visible: true },
+    { prop: 'assetProperty', label: '资产性质', visible: true },
+    { prop: 'assetClassName', label: '资产类别', visible: true },
+    { prop: 'manufacturer', label: '生产厂家', visible: true },
+    { prop: 'manDate', label: '生产日期', visible: true },
+    { prop: 'enableDate', label: '投运日期', visible: true },
+    { prop: 'brandName', label: '品牌', visible: true },
+    { prop: 'model', label: '规格型号', visible: true },
+    { prop: 'chargeName', label: '责任人', visible: true }
   ]
 
   // 默认选中所有列
@@ -500,6 +484,66 @@ const getList = async () => {
   }
 }
 
+let dateType = ref('year')
+
+watch(
+  dateType,
+  () => {
+    const now = new Date()
+    let startTime: Date
+    let endTime: Date
+
+    switch (dateType.value) {
+      case 'year':
+        // 当年:1月1日 00:00:00 到 12月31日 23:59:59
+        startTime = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0)
+        endTime = new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999)
+        break
+
+      case 'month':
+        // 当月:月初 00:00:00 到 月末 23:59:59
+        startTime = new Date(now.getFullYear(), now.getMonth(), 1, 0, 0, 0, 0)
+        // 下个月的第0天就是当月的最后一天
+        endTime = new Date(now.getFullYear(), now.getMonth() + 1, 0, 23, 59, 59, 999)
+        break
+
+      case 'day':
+        // 当日:当天 00:00:00 到 23:59:59
+        const year = now.getFullYear()
+        const month = now.getMonth()
+        const date = now.getDate()
+        startTime = new Date(year, month, date, 0, 0, 0, 0)
+        endTime = new Date(year, month, date, 23, 59, 59, 999)
+        break
+
+      default:
+        startTime = new Date(now.getFullYear(), 0, 1, 0, 0, 0, 0)
+        endTime = new Date(now.getFullYear(), 11, 31, 23, 59, 59, 999)
+    }
+
+    // 使用本地时间格式化函数,避免时区转换问题
+    const formatLocalDateTime = (date: Date): string => {
+      const year = date.getFullYear()
+      const month = String(date.getMonth() + 1).padStart(2, '0')
+      const day = String(date.getDate()).padStart(2, '0')
+      const hours = String(date.getHours()).padStart(2, '0')
+      const minutes = String(date.getMinutes()).padStart(2, '0')
+      const seconds = String(date.getSeconds()).padStart(2, '0')
+
+      return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
+    }
+    // 设置查询参数 - 使用本地时间格式化
+    queryParams.createTime = [formatLocalDateTime(startTime), formatLocalDateTime(endTime)]
+
+    console.log('查询参数>>>>>>>>>>>>>>>>>', typeof queryParams.createTime[0])
+    queryParams.pageNo = 1
+    getList() // 不重置状态
+  },
+  {
+    immediate: true
+  }
+)
+
 const resetQuery = () => {
   queryFormRef.value.resetFields()
   handleQuery()
@@ -509,6 +553,7 @@ const resetQuery = () => {
 const handleDeptNodeClick = async (row) => {
   queryParams.deptId = row.id
   deviceCountQueryParams.deptId = row.id
+  deviceCountQueryParams.createTime = queryParams.createTime
   await getList()
   await getDeviceCount()
 }
@@ -526,7 +571,8 @@ const handleDetail = (id: number) => {
 // 设备数量
 let devicesCount = ref(0)
 const deviceCountQueryParams = reactive({
-  deptId: undefined
+  deptId: undefined,
+  createTime: []
 })
 
 // 设备状态

+ 2 - 0
src/views/report-statistics/inspection_order/index.vue

@@ -561,6 +561,8 @@ watch(
     // 设置查询参数 - 使用本地时间格式化
     queryParams.createTime = [formatLocalDateTime(startTime), formatLocalDateTime(endTime)]
 
+    console.log('查询参数>>>>>>>>>>>>>>>>>', typeof queryParams.createTime[0])
+
     // 重新获取数据,保持当前状态和表格视图
     if (isExceptionPoint.value) {
       // 当前显示异常点表