Inspectionstatistics.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div>
  3. <layout>
  4. <layout-header>
  5. <div class="">
  6. <!-- 按钮部分-->
  7. <el-form ref="elSearchFormRef" class="demo-form-inline" :rules="searchRule" >
  8. <el-form-item>
  9. </el-form-item>
  10. </el-form>
  11. </div>
  12. </layout-header>
  13. <layout>
  14. <!-- 左侧树侧形结构-->
  15. <layout-sider :resize-directions="['right']" :width="190" style="margin-right: 10px;">
  16. <div class="JKWTree-tree" style="height: 200px">
  17. <h3>近期设备点检统计</h3>
  18. <el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick" @node-expand="handleNodeExpand">
  19. </el-tree>
  20. </div>
  21. </layout-sider>
  22. <!-- 右侧区域 -->
  23. <layout-content >
  24. <el-main>
  25. <div class="gva-table-box">
  26. <!-- 表格数据 -->
  27. <el-table ref="multipleTable" style="width: 100%;height: 75vh" tooltip-effect="dark"
  28. :row-style="{ height: '25px' }" :header-cell-style="{ padding: '0px' }"
  29. :cell-style="{ padding: '0px' }" :header-row-style="{ height: '20px' }"
  30. :data="djtableData" border row-key="ID"
  31. size="small"
  32. :cell-class-name="gxbgCellClass"
  33. highlight-current-row="true" @row-dblclick="updateCompanyFunc"
  34. @row-click="tableRowClick" :show-overflow-tooltip="true"
  35. @selection-change="handleSelectionChange">
  36. <el-table-column sortable align="center" label="部件编号" prop="部件编号" width="120" />
  37. <el-table-column sortable align="center" label="部件名称" prop="部件名称" width="130" />
  38. <el-table-column align="center" label="检验项目" prop="检验项目" width="60" />
  39. <!-- 年月列表 -->
  40. <template v-for="item in dateDatas">
  41. <el-table-column align="left" sortable :label=item :prop=item width="80"/>
  42. </template>
  43. </el-table>
  44. <!-- 分页 -->
  45. <div class="gva-pagination">
  46. <el-pagination layout="total" :current-page="page" :page-size="pageSize"
  47. :total="total" @current-change="handleCurrentChange" @size-change="handleSizeChange" />
  48. </div>
  49. </div>
  50. </el-main>
  51. </layout-content>
  52. </layout>
  53. </layout>
  54. </div>
  55. </template>
  56. <script setup>
  57. // 全量引入格式化工具 请按需保留
  58. import { Layout, LayoutSider, LayoutContent } from '@arco-design/web-vue';
  59. import {getMITab,InspectionDetail} from "@/api/mes/job.js"
  60. import {ref, reactive} from 'vue'
  61. import { exportExcelFile } from '@/utils/excel'
  62. import {ElMessage} from "element-plus";
  63. defineOptions({name: 'Company'})
  64. // =========== 获取左侧树侧形结构 ===========
  65. const treeData = ref([])
  66. const defaultProps = {
  67. children: 'children',
  68. label: 'label'
  69. }
  70. const getTreeData = async () => {
  71. try {
  72. const res = await getMITab();
  73. if (res.code === 0 && res.data) {
  74. // 将接口数据转换为树形结构
  75. treeData.value = Object.entries(res.data).map(([workshopName, groups]) => ({
  76. label: workshopName, // 车间名称,如"检验车间"
  77. children: Object.entries(groups).map(([groupName, machines]) => ({
  78. label: groupName, // 机组名称,如"检品机组"
  79. children: machines.map(machine => ({
  80. label: machine, // 提取设备编号,如"JP01"
  81. fullName: machine.split('【')[0], // 保留完整设备名称备用
  82. }))
  83. }))
  84. }));
  85. } else {
  86. console.error('获取树形数据失败:', res.msg);
  87. treeData.value = []; // 出错时清空数据
  88. }
  89. } catch (error) {
  90. console.error('请求树形数据时出错:', error);
  91. treeData.value = []; // 出错时清空数据
  92. }
  93. };
  94. // 初始化加载数据
  95. getTreeData();
  96. // =========== 表格数据 ===========
  97. const djtableData = ref('')
  98. const dateDatas = reactive([])
  99. const handleNodeClick = async (node) => {
  100. console.log(node)
  101. if(!node.children){
  102. const res = await InspectionDetail({machineID:node.fullName})
  103. console.log(res)
  104. if(res.code === 0 && res.data){
  105. dateDatas.splice(0,res.data.日期.length,...res.data.日期);
  106. djtableData.value = res.data.项目;
  107. console.log(djtableData.value)
  108. }
  109. }
  110. }
  111. const handleNodeExpand = (data, expanded, node) => {
  112. }
  113. </script>
  114. <style scoped>
  115. .form-container {
  116. display: flex;
  117. flex-wrap: wrap;
  118. }
  119. .form-column {
  120. /*flex: 1;*/
  121. margin-right: 15px; /* 调整列之间的间距 */
  122. }
  123. /* 左侧输入框宽度调整 */
  124. .form-column .el-form-item .el-input {
  125. width: 150px; /* 调整左侧输入框的宽度 */
  126. }
  127. :deep(.hui-plan-usage-lows div) {
  128. color: #8c939d !important;
  129. }
  130. :deep(.lan-plan-usage-lows div) {
  131. color: blue !important;
  132. font-weight: bold;
  133. }
  134. /* 媒体查询,根据需要调整断点 */
  135. @media screen and (max-width: 768px) {
  136. .form-column {
  137. flex: 1 0 100%; /* 在小屏幕下变成单列布局 */
  138. margin-right: 0;
  139. }
  140. }
  141. /*:deep(.el-table td .cell) {*/
  142. /* line-height: 30px !important;*/
  143. /*}*/
  144. .JKWTree-container {
  145. display: flex;
  146. }
  147. .JKWTree-tree {
  148. /*width: 300px;*/
  149. background-color: #fff;
  150. padding: 10px;
  151. margin-right: 20px;
  152. }
  153. .JKWTree-tree h3 {
  154. font-size: 15px;
  155. font-weight: 700;
  156. margin: 10px 0;
  157. }
  158. .JKWTree-content {
  159. flex: 1;
  160. }
  161. /* 选中某行时的背景色 */
  162. :deep(.el-table__body tr.current-row) > td {
  163. background: #ff80ff !important;
  164. }
  165. </style>
  166. <style scoped>
  167. :deep(.el-table td .cell) {
  168. line-height: 20px !important;
  169. }
  170. :deep(.el-tabs__header){
  171. margin-bottom: 0;
  172. }
  173. .search{
  174. margin-left: 0px !important;
  175. margin-right: 10px !important;
  176. }
  177. .bt{
  178. margin-left: 2px !important;
  179. padding: 3px !important;
  180. font-size: 12px;
  181. }
  182. .el-tabs__header{
  183. margin: 0px !important;
  184. }
  185. .gva-table-box{
  186. padding: 0px !important;
  187. }
  188. .mab{
  189. margin-bottom: 5px;
  190. }
  191. </style>