list.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="system-edit-dic-container">
  3. <el-dialog v-model="isShowDialog" :show-close="false" width="75%" :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=""><path fill="currentColor" 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"></path></svg></i>
  10. </div>
  11. </div>
  12. </template>
  13. <el-table :data="tableData.data" style="width: 100%" v-loading="tableData.loading">
  14. <el-table-column label="时间" prop="ts" :show-overflow-tooltip="true" />
  15. <el-table-column label="属性值" prop="value" :show-overflow-tooltip="true" />
  16. </el-table>
  17. <pagination
  18. v-show="tableData.total > 0"
  19. :total="tableData.total"
  20. v-model:page="tableData.param.pageNum"
  21. v-model:limit="tableData.param.pageSize"
  22. @pagination="typeList"
  23. />
  24. </el-dialog>
  25. </div>
  26. </template>
  27. <script lang="ts">
  28. import { reactive, toRefs, defineComponent, ref, unref } from 'vue';
  29. import { Close } from '@element-plus/icons-vue';
  30. import api from '/@/api/device';
  31. import { ElMessage } from 'element-plus';
  32. interface DicState {
  33. isShowDialog: boolean;
  34. }
  35. // 定义接口来定义对象的类型
  36. interface TableDataRow {
  37. id: number;
  38. name: string;
  39. key: string;
  40. createBy: string;
  41. }
  42. interface TableDataState {
  43. ids: number[];
  44. tableData: {
  45. data: Array<TableDataRow>;
  46. total: number;
  47. loading: boolean;
  48. param: {
  49. pageNum: number;
  50. pageSize: number;
  51. id: number;
  52. };
  53. };
  54. }
  55. export default defineComponent({
  56. name: 'deviceEditPro',
  57. setup(prop, { emit }) {
  58. const formRef = ref<HTMLElement | null>(null);
  59. const state = reactive<DicState>({
  60. isShowDialog: false,
  61. dialogFullScreen: false,
  62. tableData: {
  63. data: [],
  64. total: 0,
  65. loading: false,
  66. param: {
  67. pageNum: 1,
  68. pageSize: 10,
  69. id: 0,
  70. propertyKey:'',
  71. },
  72. },
  73. });
  74. // 打开弹窗
  75. const openDialog = (row: RuleFormState | null,devid) => {
  76. resetForm();
  77. if (row) {
  78. state.tableData.param.id = devid;
  79. state.tableData.param.propertyKey=row.key
  80. typeList();
  81. }
  82. state.isShowDialog = true;
  83. };
  84. const typeList = () => {
  85. state.tableData.loading = true;
  86. api.instance.getLogDetail(state.tableData.param).then((res: any) => {
  87. state.tableData.data = res.List;
  88. state.tableData.total = res.Total;
  89. //state.ruleForm = res.data.dictType
  90. }).finally(() => (state.tableData.loading = false));
  91. };
  92. const resetForm = () => {
  93. state.tableData= {
  94. data: [],
  95. total: 0,
  96. loading: false,
  97. param: {
  98. pageNum: 1,
  99. pageSize: 10,
  100. },
  101. }
  102. };
  103. // 关闭弹窗
  104. const closeDialog = () => {
  105. state.isShowDialog = false;
  106. };
  107. const quanping=()=>{
  108. state.dialogFullScreen = state.dialogFullScreen?false:true;
  109. }
  110. // 取消
  111. const onCancel = () => {
  112. closeDialog();
  113. };
  114. return {
  115. Close,
  116. quanping,
  117. typeList,
  118. openDialog,
  119. closeDialog,
  120. onCancel,
  121. formRef,
  122. ...toRefs(state),
  123. };
  124. },
  125. });
  126. </script>
  127. <style scoped>
  128. .my-header {
  129. display: flex;
  130. flex-direction: row;
  131. justify-content: space-between;
  132. }
  133. </style>