list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="system-edit-dic-container">
  3. <el-dialog v-model="isShowDialog" :show-close="false" width="850" :fullscreen="dialogFullScreen">
  4. <template #header="{ close, titleId, titleClass }">
  5. <div class="my-header">
  6. <h4 :id="titleId" :class="titleClass">数据记录</h4>
  7. <div>
  8. <i class="iconfont " :class="!dialogFullScreen ? 'icon-fullscreen' : 'icon-tuichuquanping'" @click="quanping" style="font-size: 22px;cursor: pointer;"></i>
  9. <i class="el-icon" @click="close" style="font-size: 22px;cursor: pointer; margin-left: 10px; position: relative; top: 3px;"><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" data-v-029747aa="">
  10. <path fill="currentColor"
  11. d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z">
  12. </path>
  13. </svg></i>
  14. </div>
  15. </div>
  16. </template>
  17. <el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading">
  18. <el-table-column label="时间" prop="ts" align="center" width="180" />
  19. <el-table-column label="属性值" prop="value" align="center" show-overflow-tooltip />
  20. </el-table>
  21. <pagination v-show="tableData.total > 0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="typeList" />
  22. </el-dialog>
  23. </div>
  24. </template>
  25. <script lang="ts">
  26. import { reactive, toRefs, defineComponent, ref, unref } from 'vue';
  27. import { Close } from '@element-plus/icons-vue';
  28. import api from '/@/api/device';
  29. import { ElMessage } from 'element-plus';
  30. interface DicState {
  31. isShowDialog: boolean;
  32. }
  33. // 定义接口来定义对象的类型
  34. interface TableDataRow {
  35. id: number;
  36. name: string;
  37. key: string;
  38. createBy: string;
  39. }
  40. interface TableDataState {
  41. ids: number[];
  42. tableData: {
  43. data: Array<TableDataRow>;
  44. total: number;
  45. loading: boolean;
  46. param: {
  47. pageNum: number;
  48. pageSize: number;
  49. id: number;
  50. };
  51. };
  52. }
  53. export default defineComponent({
  54. name: 'deviceEditPro',
  55. setup(prop, { emit }) {
  56. const formRef = ref<HTMLElement | null>(null);
  57. const state = reactive<DicState>({
  58. isShowDialog: false,
  59. dialogFullScreen: false,
  60. tableData: {
  61. data: [],
  62. total: 0,
  63. loading: false,
  64. param: {
  65. pageNum: 1,
  66. pageSize: 10,
  67. id: 0,
  68. propertyKey: '',
  69. },
  70. },
  71. });
  72. // 打开弹窗
  73. const openDialog = (row: RuleFormState | null, devid) => {
  74. resetForm();
  75. if (row) {
  76. state.tableData.param.id = devid;
  77. state.tableData.param.propertyKey = row.key
  78. typeList();
  79. }
  80. state.isShowDialog = true;
  81. };
  82. const typeList = () => {
  83. state.tableData.loading = true;
  84. api.instance.getLogDetail(state.tableData.param).then((res: any) => {
  85. state.tableData.data = res.List;
  86. state.tableData.total = res.Total;
  87. //state.ruleForm = res.data.dictType
  88. }).finally(() => (state.tableData.loading = false));
  89. };
  90. const resetForm = () => {
  91. state.tableData = {
  92. data: [],
  93. total: 0,
  94. loading: false,
  95. param: {
  96. pageNum: 1,
  97. pageSize: 10,
  98. },
  99. }
  100. };
  101. // 关闭弹窗
  102. const closeDialog = () => {
  103. state.isShowDialog = false;
  104. };
  105. const quanping = () => {
  106. state.dialogFullScreen = state.dialogFullScreen ? false : true;
  107. }
  108. // 取消
  109. const onCancel = () => {
  110. closeDialog();
  111. };
  112. return {
  113. Close,
  114. quanping,
  115. typeList,
  116. openDialog,
  117. closeDialog,
  118. onCancel,
  119. formRef,
  120. ...toRefs(state),
  121. };
  122. },
  123. });
  124. </script>
  125. <style scoped>
  126. .my-header {
  127. display: flex;
  128. flex-direction: row;
  129. justify-content: space-between;
  130. }
  131. </style>