index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <el-container style="height: 90vh; border: 1px solid #eee; padding: 20px;">
  3. <el-container>
  4. <el-aside style="width: 600px; margin-right: 20px;">
  5. <div class="config-container">
  6. <el-form ref="formRef" :model="form" :rules="rules" label-width="150px" @submit.native.prevent="saveConfig">
  7. <el-form-item label="基础类参数" prop="baseParams">
  8. <el-input v-model="form.baseParams" placeholder="请输入基础类参数"></el-input>
  9. </el-form-item>
  10. <el-form-item label="情景依托类参数" prop="scenarioParams">
  11. <el-input v-model="form.scenarioParams" placeholder="请输入情景依托类参数"></el-input>
  12. </el-form-item>
  13. <el-form-item label="规划边界类参数" prop="boundaryParams">
  14. <el-input v-model="form.boundaryParams" placeholder="请输入规划边界类参数"></el-input>
  15. </el-form-item>
  16. <el-form-item label="其他参数" prop="otherParams">
  17. <el-input v-model="form.otherParams" placeholder="请输入其他参数"></el-input>
  18. </el-form-item>
  19. <el-form-item label="备注" prop="remarks">
  20. <el-input v-model="form.remarks" type="textarea" placeholder="请输入备注"></el-input>
  21. </el-form-item>
  22. <el-form-item label="日期" prop="date">
  23. <el-date-picker
  24. v-model="form.date"
  25. type="date"
  26. placeholder="请选择日期"
  27. format="YYYY-MM-DD"
  28. value-format="YYYY-MM-DD"
  29. ></el-date-picker>
  30. </el-form-item>
  31. <el-button type="primary" @click="saveConfig">保存配置</el-button>
  32. </el-form>
  33. </div>
  34. </el-aside>
  35. <el-main style="display: block;background-color: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);">
  36. <h2>碳排放形势预测分析</h2>
  37. <el-row :gutter="20">
  38. <el-col :span="12">
  39. <el-card shadow="hover">
  40. <div slot="header">
  41. <span>历史碳排放数据</span>
  42. </div>
  43. <div>
  44. <el-table :data="historicalData" style="width: 100%">
  45. <el-table-column prop="year" label="年份" width="100"></el-table-column>
  46. <el-table-column prop="emission" label="碳排放量 (吨)" width="180"></el-table-column>
  47. </el-table>
  48. </div>
  49. </el-card>
  50. </el-col>
  51. <el-col :span="12">
  52. <el-card shadow="hover">
  53. <div slot="header">
  54. <span>未来碳排放预测</span>
  55. </div>
  56. <div>
  57. <el-table :data="futureData" style="width: 100%">
  58. <el-table-column prop="year" label="年份" width="100"></el-table-column>
  59. <el-table-column prop="predictedEmission" label="预测碳排放量 (吨)" width="180"></el-table-column>
  60. </el-table>
  61. </div>
  62. </el-card>
  63. </el-col>
  64. </el-row>
  65. <el-row :gutter="20" style="margin-top: 20px;">
  66. <el-col :span="24">
  67. <el-card shadow="hover">
  68. <div slot="header">
  69. <span>碳排放趋势图</span>
  70. </div>
  71. <div>
  72. <div id="chart" style="width: 100%; "></div>
  73. </div>
  74. </el-card>
  75. </el-col>
  76. </el-row>
  77. </el-main>
  78. </el-container>
  79. </el-container>
  80. </template>
  81. <script setup>
  82. import { ref, onMounted } from 'vue';
  83. import { ElMessage } from 'element-plus';
  84. import * as echarts from 'echarts';
  85. const form = ref({
  86. baseParams: '',
  87. scenarioParams: '',
  88. boundaryParams: '',
  89. otherParams: '',
  90. remarks: '',
  91. date: ''
  92. });
  93. const formRef = ref(null);
  94. const rules = {
  95. baseParams: [
  96. { required: true, message: '请输入基础类参数', trigger: 'blur' }
  97. ],
  98. scenarioParams: [
  99. { required: true, message: '请输入情景依托类参数', trigger: 'blur' }
  100. ],
  101. boundaryParams: [
  102. { required: true, message: '请输入规划边界类参数', trigger: 'blur' }
  103. ],
  104. otherParams: [
  105. { required: true, message: '请输入其他参数', trigger: 'blur' }
  106. ],
  107. remarks: [
  108. { required: true, message: '请输入备注', trigger: 'blur' }
  109. ],
  110. date: [
  111. { required: true, message: '请选择日期', trigger: 'change' }
  112. ]
  113. };
  114. const historicalData = ref([
  115. { year: '2020', emission: 1000 },
  116. { year: '2021', emission: 1100 },
  117. { year: '2022', emission: 1200 },
  118. { year: '2023', emission: 1300 },
  119. { year: '2024', emission: 1400 }
  120. ]);
  121. const futureData = ref([
  122. { year: '2025', predictedEmission: 1500 },
  123. { year: '2026', predictedEmission: 1600 },
  124. { year: '2027', predictedEmission: 1700 },
  125. { year: '2028', predictedEmission: 1800 },
  126. { year: '2029', predictedEmission: 1900 }
  127. ]);
  128. const saveConfig = () => {
  129. formRef.value.validate((valid) => {
  130. if (valid) {
  131. ElMessage({
  132. message: '保存成功',
  133. type: 'success'
  134. });
  135. } else {
  136. ElMessage({
  137. message: '请填写完整的信息',
  138. type: 'error'
  139. });
  140. return false;
  141. }
  142. });
  143. };
  144. onMounted(() => {
  145. const chart = echarts.init(document.getElementById('chart'));
  146. const option = {
  147. title: {
  148. text: '碳排放趋势图'
  149. },
  150. tooltip: {
  151. trigger: 'axis'
  152. },
  153. xAxis: {
  154. type: 'category',
  155. data: ['2018', '2019', '2020', '2021', '2022', '2023', '2024', '2025', '2026', '2027']
  156. },
  157. yAxis: {
  158. type: 'value'
  159. },
  160. series: [
  161. {
  162. name: '历史数据',
  163. type: 'line',
  164. data: [1521, 1543, 1578, 1456, 1347, 1435, 1654]
  165. },
  166. {
  167. name: '预测数据',
  168. type: 'line',
  169. data: [null, null, null, null, null, null, null, 1700, 1800, 1900]
  170. }
  171. ]
  172. };
  173. chart.setOption(option);
  174. });
  175. </script>
  176. <style scoped>
  177. .el-container {
  178. height: 100vh;
  179. border: 1px solid #eee;
  180. padding: 20px;
  181. background-color: #f5f7fa;
  182. }
  183. .el-header {
  184. background-color: #fff;
  185. padding: 20px;
  186. border-radius: 8px;
  187. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  188. }
  189. .el-aside {
  190. background-color: #fff;
  191. padding: 20px;
  192. border-radius: 8px;
  193. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  194. }
  195. .config-container {
  196. max-width: 600px;
  197. width: 100%;
  198. }
  199. h1, h2 {
  200. font-size: 24px;
  201. color: #303133;
  202. margin-bottom: 20px;
  203. text-align: left;
  204. }
  205. .el-form {
  206. max-width: 100%;
  207. margin: 0 auto;
  208. }
  209. .el-form-item {
  210. margin-bottom: 20px;
  211. }
  212. .el-form-item__label {
  213. color: #606266;
  214. font-weight: bold;
  215. }
  216. .el-textarea__inner {
  217. height: 100px;
  218. }
  219. .el-button {
  220. margin-top: 20px;
  221. width: 100%;
  222. background-color: #409eff;
  223. border-color: #409eff;
  224. color: #fff;
  225. font-size: 16px;
  226. padding: 12px 20px;
  227. border-radius: 4px;
  228. transition: all 0.3s;
  229. }
  230. .el-button:hover {
  231. background-color: #66b1ff;
  232. border-color: #66b1ff;
  233. }
  234. .el-card {
  235. margin-bottom: 20px;
  236. }
  237. .el-table {
  238. width: 100%;
  239. }
  240. #chart {
  241. width: 100%;
  242. height: 400px;
  243. }
  244. </style>