| | |
| | | <div style="padding: 20px;"> |
| | | <!-- 页面标题和筛选条件 --> |
| | | <div class="w-full md:w-auto flex items-center gap-3" style="margin-bottom: 20px;"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | type="daterange" |
| | | format="YYYY-MM-DD" |
| | | value-format="YYYY-MM-DD" |
| | | range-separator="至" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | clearable |
| | | @change="handleDateChange" |
| | | class="w-full md:w-auto" |
| | | style="margin-right: 30px;" |
| | | /> |
| | | |
| | | <!-- 设备类型筛选 --> |
| | | <el-select |
| | | v-model="equipmentType" |
| | | placeholder="设备类型" |
| | | clearable |
| | | @change="handleFilterChange" |
| | | style="margin-right: 20px; width: 150px;" |
| | | > |
| | | <el-option |
| | | v-for="item in equipmentTypeOptions" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | |
| | | <el-button |
| | | type="primary" |
| | | icon="Refresh" |
| | | @click="resetFilters" |
| | | size="default" |
| | | > |
| | | 重置 |
| | | 查询 |
| | | </el-button> |
| | | </div> |
| | | |
| | |
| | | :header-cell-style="{ background: '#f5f7fa', color: '#606266' }" |
| | | > |
| | | <el-table-column prop="id" label="资产编号" width="120" /> |
| | | <el-table-column prop="deviceName" label="设备名称" width="150" /> |
| | | <el-table-column prop="deviceModel" label="型号规格" width="150" /> |
| | | <el-table-column prop="supplierName" label="供应商" width="120" /> |
| | | <el-table-column prop="deviceName" label="设备名称" width="250" /> |
| | | <el-table-column prop="deviceModel" label="型号规格" min-width="150" /> |
| | | <el-table-column prop="supplierName" label="供应商" min-width="120" /> |
| | | <el-table-column prop="unit" label="单位" width="120" /> |
| | | <el-table-column prop="number" label="数量" width="120" /> |
| | | <el-table-column prop="originalValue" label="原值(元)" width="120"> |
| | |
| | | if (equipmentListRes.code === 200) { |
| | | equipmentList.value = equipmentListRes.data.records; |
| | | pagination.value.total = equipmentListRes.data.total; |
| | | } |
| | | |
| | | // // 获取设备类型分布数据 |
| | | // const typeDistributionRes = await getEquipmentTypes({ |
| | | // startDate: dateRange.value ? dateRange.value[0] : null, |
| | | // endDate: dateRange.value ? dateRange.value[1] : null, |
| | | // equipmentType: equipmentType.value |
| | | // }); |
| | | // if (typeDistributionRes.code === 200) { |
| | | // typeDistributionData.value = typeDistributionRes.data.map(item => ({ |
| | | // name: item.typeName, |
| | | // value: item.count, |
| | | // count: item.count, |
| | | // amount: `¥${formatCurrency(item.totalValue)}` |
| | | // })); |
| | | // |
| | | // // 构建折线图数据 |
| | | // typeDistributionLineSeries.value = [ |
| | | // { |
| | | // name: '设备数量', |
| | | // type: 'line', |
| | | // data: typeDistributionRes.data.map(item => item.count) |
| | | // } |
| | | // ]; |
| | | // // 更新x轴数据 |
| | | // xAxis.value[0].data = typeDistributionRes.data.map(item => item.typeName); |
| | | // } |
| | | // 根据 equipmentList 按 deviceName 进行分类统计 |
| | | const deviceNameMap = {}; |
| | | equipmentList.value.forEach(item => { |
| | | const deviceName = item.deviceName; |
| | | if (!deviceNameMap[deviceName]) { |
| | | deviceNameMap[deviceName] = { |
| | | name: deviceName, |
| | | count: 0, |
| | | totalValue: 0 |
| | | }; |
| | | } |
| | | deviceNameMap[deviceName].count += item.number || 1; // 假设 number 为设备数量 |
| | | deviceNameMap[deviceName].totalValue += item.taxIncludingPriceTotal || 0; // 累加含税总价 |
| | | }); |
| | | |
| | | // 转换为 typeDistributionData 格式 |
| | | typeDistributionData.value = Object.values(deviceNameMap).map(item => ({ |
| | | name: item.name, |
| | | value: item.count, |
| | | count: item.count, |
| | | amount: `¥${formatCurrency(item.totalValue)}` |
| | | })); |
| | | |
| | | // 更新x轴数据 |
| | | xAxis.value[0].data = typeDistributionData.value.map(item => item.name); |
| | | |
| | | // 构建折线图数据 |
| | | typeDistributionLineSeries.value = [ |
| | | { |
| | | name: '设备数量', |
| | | type: 'line', |
| | | data: typeDistributionData.value.map(item => item.count) |
| | | } |
| | | ]; |
| | | } |
| | | } catch (error) { |
| | | console.error('获取固定资产数据失败:', error); |
| | | } |
| | |
| | | default: |
| | | return 'info'; |
| | | } |
| | | }; |
| | | |
| | | // 处理日期范围变化 |
| | | const handleDateChange = (newRange) => { |
| | | dateRange.value = newRange; |
| | | fetchData(); |
| | | }; |
| | | |
| | | // 处理筛选条件变化 |
| | | const handleFilterChange = () => { |
| | | fetchData(); |
| | | }; |
| | | |
| | | // 重置筛选条件 |