detail.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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="">
  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%">
  18. <el-table-column v-for="(item, index) in jData" :key="item" :label="item" :prop="item" show-overflow-tooltip align="center" min-width="130">
  19. <template #header>
  20. <div>
  21. {{ item }}
  22. </div>
  23. <div>
  24. <span v-if="item == 'created_at'">时间</span>
  25. {{ titleData[item] }}
  26. </div>
  27. </template>
  28. </el-table-column>
  29. </el-table>
  30. <pagination v-show="tableData.total > 0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="typeList" />
  31. </el-dialog>
  32. </div>
  33. </template>
  34. <script lang="ts">
  35. import { reactive, toRefs, defineComponent, ref } from 'vue';
  36. import api from '/@/api/datahub';
  37. interface DicState {
  38. isShowDialog: boolean;
  39. }
  40. // 定义接口来定义对象的类型
  41. interface TableDataRow {
  42. id: number;
  43. name: string;
  44. key: string;
  45. createBy: string;
  46. }
  47. interface TableDataState {
  48. ids: number[];
  49. tableData: {
  50. data: Array<TableDataRow>;
  51. total: number;
  52. loading: boolean;
  53. param: {
  54. pageNum: number;
  55. pageSize: number;
  56. id: number;
  57. };
  58. };
  59. }
  60. export default defineComponent({
  61. name: 'deviceEditPro',
  62. setup() {
  63. const formRef = ref<HTMLElement | null>(null);
  64. const state = reactive<DicState>({
  65. isShowDialog: false,
  66. dialogFullScreen: false,
  67. titleData: {},
  68. jsonsData: [],
  69. jData: [],
  70. tableData: {
  71. data: [],
  72. total: 0,
  73. loading: false,
  74. param: {
  75. pageNum: 1,
  76. pageSize: 10,
  77. id: 0,
  78. },
  79. },
  80. });
  81. // 打开弹窗
  82. const openDialog = (row: RuleFormState | null) => {
  83. resetForm();
  84. if (row) {
  85. state.tableData.param.id = row.id;
  86. api.tnode.getList({ tid: row.id }).then((res: any) => {
  87. res.list.forEach((item, index) => {
  88. state.titleData[item.key] = item.name;
  89. });
  90. //state.titleData = res.list;
  91. //state.tableData.total = res.Total;
  92. });
  93. typeList();
  94. }
  95. state.isShowDialog = true;
  96. };
  97. const typeList = () => {
  98. api.template.getdata(state.tableData.param).then((res: any) => {
  99. const jsonData = JSON.parse(res.data);
  100. state.tableData.data = jsonData;
  101. state.jData = Object.keys(jsonData[0]);
  102. state.jData.forEach((item, index) => {
  103. state.jsonsData[index] = jsonData[item];
  104. });
  105. state.tableData.total = res.Total;
  106. //state.ruleForm = res.data.dictType
  107. });
  108. };
  109. const resetForm = () => {
  110. state.jsonsData = [];
  111. state.jData = [];
  112. state.tableData = {
  113. data: [],
  114. total: 0,
  115. loading: false,
  116. param: {
  117. pageNum: 1,
  118. pageSize: 10,
  119. },
  120. }
  121. };
  122. // 关闭弹窗
  123. const closeDialog = () => {
  124. state.isShowDialog = false;
  125. };
  126. const quanping = () => {
  127. state.dialogFullScreen = state.dialogFullScreen ? false : true;
  128. }
  129. // 取消
  130. const onCancel = () => {
  131. closeDialog();
  132. };
  133. return {
  134. quanping,
  135. typeList,
  136. openDialog,
  137. closeDialog,
  138. onCancel,
  139. formRef,
  140. ...toRefs(state),
  141. };
  142. },
  143. });
  144. </script>
  145. <style scoped>
  146. .my-header {
  147. display: flex;
  148. flex-direction: row;
  149. justify-content: space-between;
  150. }
  151. </style>