| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098 |
- import 'package:flutter/material.dart';
-
- /// 水质查看页面
- class QualityPage extends StatefulWidget {
- const QualityPage({super.key});
-
- @override
- State<QualityPage> createState() => _QualityPageState();
- }
-
- class _QualityPageState extends State<QualityPage>
- with AutomaticKeepAliveClientMixin {
- int _selectedTabIndex = 0;
-
- @override
- bool get wantKeepAlive => true;
-
- @override
- Widget build(BuildContext context) {
- super.build(context);
- return Scaffold(
- appBar: AppBar(
- title: const Text('水质监测'),
- actions: [
- IconButton(
- icon: const Icon(Icons.refresh),
- onPressed: () {
- setState(() {});
- },
- ),
- ],
- ),
- body: Column(
- children: [
- _buildTabBar(),
- const SizedBox(height: 16),
- Expanded(
- child: _buildTabContent(),
- ),
- ],
- ),
- );
- }
-
- Widget _buildTabBar() {
- final tabs = ['原水', '出厂水', '末梢水'];
-
- return Container(
- padding: const EdgeInsets.symmetric(horizontal: 16),
- child: Row(
- children: List.generate(tabs.length, (index) {
- final isSelected = index == _selectedTabIndex;
- return Expanded(
- child: GestureDetector(
- onTap: () {
- setState(() {
- _selectedTabIndex = index;
- });
- },
- child: Container(
- margin: const EdgeInsets.symmetric(horizontal: 4),
- padding: const EdgeInsets.symmetric(vertical: 12),
- decoration: BoxDecoration(
- color: isSelected
- ? const Color(0xFF1976D2)
- : Colors.grey[200],
- borderRadius: BorderRadius.circular(20),
- ),
- child: Text(
- tabs[index],
- textAlign: TextAlign.center,
- style: TextStyle(
- color: isSelected ? Colors.white : Colors.grey[700],
- fontSize: 14,
- fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
- ),
- ),
- ),
- ),
- );
- }),
- ),
- );
- }
-
- Widget _buildTabContent() {
- switch (_selectedTabIndex) {
- case 0:
- return const _RawWaterQualityTab();
- case 1:
- return const _TreatedWaterQualityTab();
- case 2:
- return const _TapWaterQualityTab();
- default:
- return const _RawWaterQualityTab();
- }
- }
- }
-
- /// 原水水质标签页
- class _RawWaterQualityTab extends StatelessWidget {
- const _RawWaterQualityTab();
-
- @override
- Widget build(BuildContext context) {
- return SingleChildScrollView(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _buildQualityOverview(),
- const SizedBox(height: 16),
- _buildWaterSources(),
- const SizedBox(height: 16),
- _buildIndicatorsTable(),
- ],
- ),
- );
- }
-
- Widget _buildQualityOverview() {
- return Card(
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '原水水质总体情况',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 12),
- Row(
- children: [
- Expanded(
- child: _buildOverviewItem(
- '监测点数',
- '8个',
- Icons.location_on,
- Colors.blue,
- ),
- ),
- const SizedBox(width: 12),
- Expanded(
- child: _buildOverviewItem(
- '达标率',
- '87.5%',
- Icons.check_circle,
- Colors.green,
- ),
- ),
- const SizedBox(width: 12),
- Expanded(
- child: _buildOverviewItem(
- '异常点数',
- '1个',
- Icons.warning,
- Colors.orange,
- ),
- ),
- ],
- ),
- ],
- ),
- ),
- );
- }
-
- Widget _buildOverviewItem(String label, String value, IconData icon, Color color) {
- return Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: color.withOpacity(0.1),
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- children: [
- Icon(icon, color: color, size: 20),
- const SizedBox(height: 8),
- Text(
- label,
- style: TextStyle(
- fontSize: 12,
- color: Colors.grey[600],
- ),
- ),
- const SizedBox(height: 4),
- Text(
- value,
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- color: color,
- ),
- ),
- ],
- ),
- );
- }
-
- Widget _buildWaterSources() {
- final sources = [
- {
- 'name': '长江取水口',
- 'location': '城东',
- 'quality': '良好',
- 'updateTime': '2026-06-17 08:30',
- 'indicators': {
- '浊度': '2.3 NTU',
- 'pH值': '7.2',
- '溶解氧': '6.8 mg/L',
- '氨氮': '0.15 mg/L',
- },
- },
- {
- 'name': '汉江取水口',
- 'location': '城西',
- 'quality': '合格',
- 'updateTime': '2026-06-17 08:45',
- 'indicators': {
- '浊度': '5.1 NTU',
- 'pH值': '7.1',
- '溶解氧': '6.5 mg/L',
- '氨氮': '0.22 mg/L',
- },
- },
- {
- 'name': '东湖取水口',
- 'location': '城南',
- 'quality': '异常',
- 'updateTime': '2026-06-17 09:15',
- 'indicators': {
- '浊度': '15.2 NTU',
- 'pH值': '6.8',
- '溶解氧': '5.2 mg/L',
- '氨氮': '0.45 mg/L',
- },
- },
- ];
-
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '水源监测点',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 12),
- ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemCount: sources.length,
- itemBuilder: (context, index) {
- final source = sources[index];
- return _buildSourceCard(source);
- },
- ),
- ],
- );
- }
-
- Widget _buildSourceCard(Map<String, dynamic> source) {
- Color qualityColor;
- switch (source['quality']) {
- case '良好':
- qualityColor = Colors.green;
- break;
- case '合格':
- qualityColor = Colors.orange;
- break;
- case '异常':
- qualityColor = Colors.red;
- break;
- default:
- qualityColor = Colors.grey;
- }
-
- return Card(
- margin: const EdgeInsets.only(bottom: 12),
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Expanded(
- child: Text(
- source['name'],
- style: const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
- decoration: BoxDecoration(
- color: qualityColor.withOpacity(0.1),
- borderRadius: BorderRadius.circular(12),
- border: Border.all(color: qualityColor),
- ),
- child: Text(
- source['quality'],
- style: TextStyle(
- fontSize: 12,
- color: qualityColor,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ],
- ),
- const SizedBox(height: 8),
- Text(
- '位置:${source['location']}',
- style: TextStyle(
- fontSize: 14,
- color: Colors.grey[600],
- ),
- ),
- const SizedBox(height: 8),
- Text(
- '更新时间:${source['updateTime']}',
- style: TextStyle(
- fontSize: 12,
- color: Colors.grey[500],
- ),
- ),
- const SizedBox(height: 12),
- ...source['indicators'].entries.map((entry) {
- return _buildIndicatorRow(entry.key, entry.value);
- }),
- ],
- ),
- ),
- );
- }
-
- Widget _buildIndicatorRow(String name, String value) {
- return Padding(
- padding: const EdgeInsets.symmetric(vertical: 2),
- child: Row(
- children: [
- SizedBox(
- width: 60,
- child: Text(
- name,
- style: TextStyle(
- fontSize: 13,
- color: Colors.grey[600],
- ),
- ),
- ),
- Expanded(
- child: Text(
- value,
- style: const TextStyle(fontSize: 13),
- ),
- ),
- ],
- ),
- );
- }
-
- Widget _buildIndicatorsTable() {
- return Card(
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '水质指标详情',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 16),
- _buildIndicatorTable(),
- ],
- ),
- ),
- );
- }
-
- Widget _buildIndicatorTable() {
- final indicators = [
- {
- 'name': '浊度',
- 'unit': 'NTU',
- 'standard': '≤5',
- 'maxValue': '10',
- 'currentValue': '2.3-15.2',
- 'status': '部分超标',
- },
- {
- 'name': 'pH值',
- 'unit': '',
- 'standard': '6.5-8.5',
- 'maxValue': '9',
- 'currentValue': '6.8-7.2',
- 'status': '正常',
- },
- {
- 'name': '溶解氧',
- 'unit': 'mg/L',
- 'standard': '≥6',
- 'maxValue': '8',
- 'currentValue': '5.2-6.8',
- 'status': '正常',
- },
- {
- 'name': '氨氮',
- 'unit': 'mg/L',
- 'standard': '≤0.5',
- 'maxValue': '1.0',
- 'currentValue': '0.15-0.45',
- 'status': '正常',
- },
- {
- 'name': '总硬度',
- 'unit': 'mg/L',
- 'standard': '≤450',
- 'maxValue': '500',
- 'currentValue': '120-280',
- 'status': '正常',
- },
- {
- 'name': '总大肠菌群',
- 'unit': '个/L',
- 'standard': '≤3',
- 'maxValue': '100',
- 'currentValue': '0-2',
- 'status': '正常',
- },
- {
- 'name': '菌落总数',
- 'unit': 'CFU/mL',
- 'standard': '≤100',
- 'maxValue': '200',
- 'currentValue': '10-50',
- 'status': '正常',
- },
- ];
-
- return DataTable(
- columnSpacing: 16,
- dataRowHeight: 40,
- headingRowHeight: 40,
- columns: const [
- DataColumn(label: Text('指标', style: TextStyle(fontWeight: FontWeight.bold))),
- DataColumn(label: Text('标准', style: TextStyle(fontWeight: FontWeight.bold))),
- DataColumn(label: Text('当前值', style: TextStyle(fontWeight: FontWeight.bold))),
- DataColumn(label: Text('状态', style: TextStyle(fontWeight: FontWeight.bold))),
- ],
- rows: indicators.map((indicator) {
- Color statusColor;
- switch (indicator['status']) {
- case '正常':
- statusColor = Colors.green;
- break;
- case '部分超标':
- statusColor = Colors.orange;
- break;
- case '超标':
- statusColor = Colors.red;
- break;
- default:
- statusColor = Colors.grey;
- }
-
- return DataRow(
- cells: [
- DataCell(Text('${indicator['name']} (${indicator['unit']})')),
- DataCell(Text(indicator['standard'])),
- DataCell(Text(indicator['currentValue'])),
- DataCell(
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
- decoration: BoxDecoration(
- color: statusColor.withOpacity(0.1),
- borderRadius: BorderRadius.circular(8),
- ),
- child: Text(
- indicator['status'],
- style: TextStyle(
- fontSize: 12,
- color: statusColor,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ),
- ],
- );
- }).toList(),
- );
- }
- }
-
- /// 出厂水水质标签页
- class _TreatedWaterQualityTab extends StatelessWidget {
- const _TreatedWaterQualityTab();
-
- @override
- Widget build(BuildContext context) {
- return const SingleChildScrollView(
- padding: EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _QualityOverviewCard(),
- SizedBox(height: 16),
- _TreatmentPlantList(),
- SizedBox(height: 16),
- _TreatedIndicatorsTable(),
- ],
- ),
- );
- }
- }
-
- /// 末梢水水质标签页
- class _TapWaterQualityTab extends StatelessWidget {
- const _TapWaterQualityTab();
-
- @override
- Widget build(BuildContext context) {
- return const SingleChildScrollView(
- padding: EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- _QualityOverviewCard(),
- SizedBox(height: 16),
- _DistributionPointsList(),
- SizedBox(height: 16),
- _TapIndicatorsTable(),
- ],
- ),
- );
- }
- }
-
- /// 出厂水总体情况卡片
- class _QualityOverviewCard extends StatelessWidget {
- const _QualityOverviewCard();
-
- @override
- Widget build(BuildContext context) {
- return Card(
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '水质总体评价',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 16),
- Row(
- children: [
- Expanded(
- child: _buildOverviewItem(
- '合格率',
- '98.5%',
- Icons.check_circle,
- Colors.green,
- ),
- ),
- const SizedBox(width: 12),
- Expanded(
- child: _buildOverviewItem(
- '监测点数',
- '24个',
- Icons.location_on,
- Colors.blue,
- ),
- ),
- const SizedBox(width: 12),
- Expanded(
- child: _buildOverviewItem(
- '优良率',
- '85.2%',
- StarsIcon(),
- Colors.amber,
- ),
- ),
- ],
- ),
- const SizedBox(height: 16),
- const Text(
- '📋 综合评价:出厂水水质稳定达标,各项指标均在控制范围内。',
- style: TextStyle(
- fontSize: 14,
- color: Colors.green,
- ),
- ),
- ],
- ),
- ),
- );
- }
-
- Widget _buildOverviewItem(String label, String value, IconData icon, Color color) {
- return Container(
- padding: const EdgeInsets.all(12),
- decoration: BoxDecoration(
- color: color.withOpacity(0.1),
- borderRadius: BorderRadius.circular(8),
- ),
- child: Column(
- children: [
- Icon(icon, color: color, size: 20),
- const SizedBox(height: 8),
- Text(
- label,
- style: TextStyle(
- fontSize: 12,
- color: Colors.grey[600],
- ),
- ),
- const SizedBox(height: 4),
- Text(
- value,
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- color: color,
- ),
- ),
- ],
- ),
- );
- }
- }
-
- /// 水厂列表
- class _TreatmentPlantList extends StatelessWidget {
- const _TreatmentPlantList();
-
- @override
- Widget build(BuildContext context) {
- final plants = [
- {
- 'name': '城东水厂',
- 'capacity': '50万吨/日',
- 'efficiency': '95%',
- 'quality': '优良',
- },
- {
- 'name': '城西水厂',
- 'capacity': '30万吨/日',
- 'efficiency': '92%',
- 'quality': '良好',
- },
- {
- 'name': '南区水厂',
- 'capacity': '20万吨/日',
- 'efficiency': '88%',
- 'quality': '良好',
- },
- ];
-
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '水厂运行情况',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 12),
- ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemCount: plants.length,
- itemBuilder: (context, index) {
- final plant = plants[index];
- return _buildPlantCard(plant);
- },
- ),
- ],
- );
- }
-
- Widget _buildPlantCard(Map<String, dynamic> plant) {
- Color qualityColor;
- switch (plant['quality']) {
- case '优良':
- qualityColor = Colors.green;
- break;
- case '良好':
- qualityColor = Colors.orange;
- break;
- default:
- qualityColor = Colors.grey;
- }
-
- return Card(
- margin: const EdgeInsets.only(bottom: 12),
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Row(
- children: [
- Expanded(
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- plant['name'],
- style: const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 8),
- Row(
- children: [
- _buildMiniStat('产能', plant['capacity']),
- const SizedBox(width: 16),
- _buildMiniStat('效率', plant['efficiency']),
- ],
- ),
- ],
- ),
- ),
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
- decoration: BoxDecoration(
- color: qualityColor.withOpacity(0.1),
- borderRadius: BorderRadius.circular(12),
- border: Border.all(color: qualityColor),
- ),
- child: Text(
- plant['quality'],
- style: TextStyle(
- fontSize: 12,
- color: qualityColor,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ],
- ),
- ),
- );
- }
-
- Widget _buildMiniStat(String label, String value) {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- label,
- style: TextStyle(
- fontSize: 12,
- color: Colors.grey[600],
- ),
- ),
- Text(
- value,
- style: const TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- ),
- ),
- ],
- );
- }
- }
-
- /// 水质指标表格
- class _TreatedIndicatorsTable extends StatelessWidget {
- const _TreatedIndicatorsTable();
-
- @override
- Widget build(BuildContext context) {
- return Card(
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '出厂水水质指标',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 16),
- _buildDataTable(
- [
- '浊度 (NTU)', 'pH值', '余氯 (mg/L)', '菌落总数 (CFU/mL)',
- '总大肠菌群 (个/L)', '总硬度 (mg/L)', '溶解氧 (mg/L)'
- ],
- [
- ['0.1', '0.2', '0.3'], ['7.1', '7.2', '7.3'],
- ['0.3', '0.4', '0.5'], ['<10', '<15', '<20'],
- ['0', '0', '0'], ['120', '150', '180'], ['6.5', '7.0', '7.5']
- ],
- ['≤1', '6.5-8.5', '≥0.3', '≤100', '不得检出', '≤450', '≥6.0']
- ),
- ],
- ),
- ),
- );
- }
-
- Widget _buildDataTable(List<String> headers, List<List<String>> data, List<String> standards) {
- return DataTable(
- columnSpacing: 16,
- dataRowHeight: 40,
- headingRowHeight: 40,
- columns: [
- const DataColumn(label: Text('检测点', style: TextStyle(fontWeight: FontWeight.bold))),
- ...headers.map((header) => DataColumn(label: Text(header, style: TextStyle(fontWeight: FontWeight.bold)))),
- const DataColumn(label: Text('标准', style: TextStyle(fontWeight: FontWeight.bold))),
- ],
- rows: data.asMap().entries.entries.map((entry) {
- return DataRow(
- cells: [
- DataCell(Text('点${entry.key + 1}')),
- ...entry.value.map((value) => DataCell(Text(value))),
- DataCell(Text(standards[entry.key])),
- ],
- );
- }).toList(),
- );
- }
- }
-
- /// 供水点列表
- class _DistributionPointsList extends StatelessWidget {
- const _DistributionPointsList();
-
- @override
- Widget build(BuildContext context) {
- final points = [
- {
- 'name': '中心广场',
- 'address': '中山路123号',
- 'quality': '优良',
- 'pressure': '0.35 MPa',
- 'updateTime': '2026-06-17 10:30',
- },
- {
- 'name': '东区居民区',
- 'address': '幸福路456号',
- 'quality': '良好',
- 'pressure': '0.28 MPa',
- 'updateTime': '2026-06-17 10:25',
- },
- {
- 'name': '西区商业区',
- 'address': '解放路789号',
- 'quality': '良好',
- 'pressure': '0.32 MPa',
- 'updateTime': '2026-06-17 10:20',
- },
- ];
-
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '末梢水监测点',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 12),
- ListView.builder(
- shrinkWrap: true,
- physics: const NeverScrollableScrollPhysics(),
- itemCount: points.length,
- itemBuilder: (context, index) {
- final point = points[index];
- return _buildDistributionCard(point);
- },
- ),
- ],
- );
- }
-
- Widget _buildDistributionCard(Map<String, dynamic> point) {
- Color qualityColor;
- switch (point['quality']) {
- case '优良':
- qualityColor = Colors.green;
- break;
- case '良好':
- qualityColor = Colors.orange;
- break;
- default:
- qualityColor = Colors.grey;
- }
-
- return Card(
- margin: const EdgeInsets.only(bottom: 12),
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Row(
- children: [
- Expanded(
- child: Text(
- point['name'],
- style: const TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
- decoration: BoxDecoration(
- color: qualityColor.withOpacity(0.1),
- borderRadius: BorderRadius.circular(12),
- border: Border.all(color: qualityColor),
- ),
- child: Text(
- point['quality'],
- style: TextStyle(
- fontSize: 12,
- color: qualityColor,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ],
- ),
- const SizedBox(height: 8),
- Text(
- '地址:${point['address']}',
- style: TextStyle(
- fontSize: 14,
- color: Colors.grey[600],
- ),
- ),
- const SizedBox(height: 8),
- Row(
- children: [
- _buildMiniStat('水压', point['pressure']),
- const SizedBox(width: 16),
- _buildMiniStat('更新', point['updateTime']),
- ],
- ),
- ],
- ),
- ),
- );
- }
-
- Widget _buildMiniStat(String label, String value) {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text(
- label,
- style: TextStyle(
- fontSize: 12,
- color: Colors.grey[600],
- ),
- ),
- Text(
- value,
- style: const TextStyle(
- fontSize: 14,
- fontWeight: FontWeight.bold,
- ),
- ),
- ],
- );
- }
- }
-
- /// 末梢水指标表格
- class _TapIndicatorsTable extends StatelessWidget {
- const _TapIndicatorsTable();
-
- @override
- Widget build(BuildContext context) {
- return Card(
- child: Padding(
- padding: const EdgeInsets.all(16),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- const Text(
- '末梢水水质指标',
- style: TextStyle(
- fontSize: 16,
- fontWeight: FontWeight.bold,
- ),
- ),
- const SizedBox(height: 16),
- _buildIndicatorTable(),
- ],
- ),
- ),
- );
- }
-
- Widget _buildIndicatorTable() {
- final indicators = [
- {'name': '浊度', 'unit': 'NTU', 'standard': '≤1', 'current': '0.3-0.8', 'status': '正常'},
- {'name': '余氯', 'unit': 'mg/L', 'standard': '≥0.05', 'current': '0.2-0.5', 'status': '正常'},
- {'name': 'pH值', 'unit': '', 'standard': '6.5-8.5', 'current': '7.0-7.5', 'status': '正常'},
- {'name': '菌落总数', 'unit': 'CFU/mL', 'standard': '≤100', 'current': '10-50', 'status': '正常'},
- {'name': '总大肠菌群', 'unit': '个/L', 'standard': '不得检出', 'current': '0', 'status': '正常'},
- ];
-
- return DataTable(
- columnSpacing: 16,
- dataRowHeight: 40,
- headingRowHeight: 40,
- columns: const [
- DataColumn(label: Text('指标', style: TextStyle(fontWeight: FontWeight.bold))),
- DataColumn(label: Text('单位', style: TextStyle(fontWeight: FontWeight.bold))),
- DataColumn(label: Text('标准', style: TextStyle(fontWeight: FontWeight.bold))),
- DataColumn(label: Text('当前值', style: TextStyle(fontWeight: FontWeight.bold))),
- DataColumn(label: Text('状态', style: TextStyle(fontWeight: FontWeight.bold))),
- ],
- rows: indicators.map((indicator) {
- Color statusColor = Colors.green;
- if (indicator['status'] == '部分超标') {
- statusColor = Colors.orange;
- } else if (indicator['status'] == '超标') {
- statusColor = Colors.red;
- }
-
- return DataRow(
- cells: [
- DataCell(Text(indicator['name'])),
- DataCell(Text(indicator['unit'])),
- DataCell(Text(indicator['standard'])),
- DataCell(Text(indicator['current'])),
- DataCell(
- Container(
- padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
- decoration: BoxDecoration(
- color: statusColor.withOpacity(0.1),
- borderRadius: BorderRadius.circular(8),
- ),
- child: Text(
- indicator['status'],
- style: TextStyle(
- fontSize: 12,
- color: statusColor,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- ),
- ],
- );
- }).toList(),
- );
- }
- }
-
- /// 星星图标组件
- class StarsIcon extends StatelessWidget {
- const StarsIcon({super.key});
-
- @override
- Widget build(BuildContext context) {
- return Row(
- mainAxisSize: MainAxisSize.min,
- children: List.generate(5, (index) {
- return Icon(
- index < 4 ? Icons.star : Icons.star_border,
- color: Colors.amber,
- size: 16,
- );
- }),
- );
- }
- }
|