HelloWorld.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div class="table-container" align="center">
  3. <!-- 新增标题 -->
  4. <h2 class="table-title">1.J1 摩擦力数据表</h2>
  5. <!-- el-table 组件 -->
  6. <el-table
  7. :data="paginatedData"
  8. empty-text="暂无数据"
  9. stripe
  10. highlight-current-row
  11. style="width: 100%%"
  12. >
  13. <!-- el-table-column 组件 -->
  14. <el-table-column
  15. prop="name"
  16. label="摩檫力名称"
  17. width="300"
  18. align="center"
  19. ></el-table-column>
  20. <el-table-column
  21. prop="date"
  22. label="日期"
  23. width="300"
  24. align="center"
  25. ></el-table-column>
  26. <el-table-column
  27. prop="mochali"
  28. label="摩檫力值"
  29. width="300"
  30. align="center"
  31. ></el-table-column>
  32. <el-table-column
  33. prop="his"
  34. label="历史数据"
  35. width="300"
  36. align="center"
  37. >
  38. <template #default="{row}">
  39. <el-button type="primary" size="small" @click="handleConfirmClick(row)">
  40. {{ row.his }}
  41. </el-button>
  42. </template>
  43. </el-table-column>
  44. <el-table-column
  45. prop="btn"
  46. label="确认"
  47. align="center"
  48. >
  49. <template #default="{row}">
  50. <el-button type="primary" size="small" @click="handleConfirmClick(row)">
  51. {{ row.btn }}
  52. </el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <!-- 分页组件 -->
  57. <div class="pagination-container">
  58. <el-pagination
  59. @size-change="handleSizeChange"
  60. @current-change="handleCurrentChange"
  61. :current-page="currentPage"
  62. :page-sizes="[5, 10, 15, 20]"
  63. :page-size="pageSize"
  64. layout="total, sizes, prev, pager, next, jumper"
  65. :total="tableData.length"
  66. ></el-pagination>
  67. </div>
  68. </div>
  69. <div class="table-container" align="center">
  70. <!-- ... existing table and other elements ... -->
  71. <!-- 新增对话框 -->
  72. <el-dialog
  73. title="摩擦力配置"
  74. v-model="dialogVisible"
  75. width="30%"
  76. >
  77. <div style="display: grid; grid-template-columns: 1fr 1fr; row-gap: 15px; align-items: center;">
  78. <span style="text-align: center;">定反位置:</span>
  79. <el-select v-model="selectedPosition" placeholder="请选择">
  80. <el-option
  81. v-for="item in positionOptions"
  82. :key="item.value"
  83. :label="item.label"
  84. :value="item.value">
  85. </el-option>
  86. </el-select>
  87. <span style="text-align: center;">发生日期:</span>
  88. <el-date-picker
  89. v-model="currentRow.date"
  90. type="datetime"
  91. placeholder="选择日期时间"
  92. value-format="yyyy-MM-dd HH:mm:ss"
  93. />
  94. <span style="text-align: center;">摩擦力值:</span>
  95. <el-input
  96. v-model="currentRow.mochali"
  97. placeholder="请输入摩擦力值"
  98. style="width: 100%"
  99. >
  100. <template #append>N</template>
  101. </el-input>
  102. <span style="text-align: center;">起始值:</span>
  103. <div style="display: flex; gap: 10px;">
  104. <el-input
  105. v-model="startValue"
  106. placeholder="起始值"
  107. style="flex: 1"
  108. >
  109. <template #append>N</template>
  110. </el-input>
  111. <el-button
  112. type="primary"
  113. @click="calculateFriction"
  114. >
  115. 计算
  116. </el-button>
  117. </div>
  118. <span style="text-align: center;">终点值:</span>
  119. <el-input
  120. v-model="endValue"
  121. placeholder="终点值"
  122. style="width: 100%"
  123. >
  124. <template #append>N</template>
  125. </el-input>
  126. </div>
  127. <template #footer> <!-- Changed from slot="footer" to template #footer -->
  128. <el-button @click="dialogVisible = false">取消</el-button>
  129. <el-button type="primary" @click="dialogVisible = true">删除</el-button>
  130. <el-button type="primary" @click="dialogVisible = true">确定</el-button>
  131. </template>
  132. </el-dialog>
  133. </div>
  134. </template>
  135. <script>
  136. export default {
  137. data() {
  138. return {
  139. currentPage: 1,
  140. pageSize: 10,
  141. dialogVisible: false, // 新增对话框显示状态
  142. currentRow: null, // 新增当前行数据
  143. positionOptions: [ // 新增下拉选项
  144. { label: '定扳反', value: '定扳反' },
  145. { label: '反扳定', value: '反扳定' }
  146. ],
  147. selectedPosition: '', // 新增选中值
  148. startValue: '',
  149. endValue: '',
  150. // 表格数据
  151. tableData: [
  152. {
  153. name: "原摩擦力",
  154. date: "2025-05-29 12:30:00",
  155. btn: "确认",
  156. mochali: "5100",
  157. his: "历史数据",
  158. },
  159. {
  160. name: "摩擦力1",
  161. date: "2025-05-30 12:30:00",
  162. btn: "确认",
  163. mochali: "6100",
  164. his: "历史数据",
  165. },
  166. {
  167. name: "摩擦力2",
  168. date: "2025-05-31 12:30:00",
  169. btn: "确认",
  170. mochali: "6200",
  171. his: "历史数据",
  172. },
  173. {
  174. name: "摩擦力3",
  175. date: "2025-06-01 12:30:00",
  176. btn: "确认",
  177. mochali: "6500",
  178. his: "历史数据",
  179. },
  180. ],
  181. };
  182. },
  183. computed: {
  184. paginatedData() {
  185. const start = (this.currentPage - 1) * this.pageSize;
  186. const end = start + this.pageSize;
  187. return this.tableData.slice(start, end);
  188. }
  189. },
  190. methods: {
  191. handleSizeChange(val) {
  192. this.pageSize = val;
  193. },
  194. handleCurrentChange(val) {
  195. this.currentPage = val;
  196. },
  197. handleConfirmClick(row) {
  198. this.$message.success(`点击确认: ${row.btn}, 日期: ${row.date}, 值: ${row.mochali}`);
  199. // 这里可以添加更多业务逻辑
  200. this.currentRow = row; // 保存当前行数据
  201. this.dialogVisible = true; // 显示对话框
  202. },
  203. calculateFriction() {
  204. if (this.startValue && this.endValue) {
  205. const start = parseFloat(this.startValue);
  206. const end = parseFloat(this.endValue);
  207. this.currentRow.mochali = Math.abs(end - start).toString();
  208. } else {
  209. this.$message.warning('请输入起始值和终点值');
  210. }
  211. }
  212. }
  213. };
  214. </script>
  215. <style scoped>
  216. .table-container {
  217. padding: 20px;
  218. background: #fff;
  219. border-radius: 4px;
  220. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  221. }
  222. .pagination-container {
  223. margin-top: 20px;
  224. text-align: right;
  225. }
  226. /* 优化表格样式 */
  227. .el-table {
  228. border-radius: 4px;
  229. border: 1px solid #ebeef5;
  230. }
  231. .el-table__body,
  232. .el-table__header {
  233. border-collapse: collapse;
  234. }
  235. .el-table th,
  236. .el-table td {
  237. border-right: 1px solid #ebeef5;
  238. border-bottom: 1px solid #ebeef5;
  239. }
  240. .el-table th:first-child,
  241. .el-table td:first-child {
  242. border-left: 1px solid #ebeef5;
  243. }
  244. .el-table th, .el-table td {
  245. text-align: center;
  246. /* 统一字体大小和行高 */
  247. font-size: 16px;
  248. line-height: 1.5;
  249. padding: 12px 0;
  250. }
  251. .el-table th {
  252. background-color: #f5f7fa;
  253. color: #000000;
  254. font-weight: bold;
  255. }
  256. ::v-deep .el-table__header-wrapper .el-table__header th .cell {
  257. font-weight: bold;
  258. font-size: 16px;
  259. color: #000000;
  260. }
  261. .el-table--striped .el-table__body tr.el-table__row--striped td {
  262. background-color: #fafafa;
  263. }
  264. .el-table__body tr:hover > td {
  265. background-color: #f0f7ff !important;
  266. }
  267. </style>