index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <div class="system-dic-container">
  3. <el-card shadow="hover">
  4. <div class="system-user-search mb15">
  5. <el-form :model="state.tableData.param" ref="queryRef" :inline="true" label-width="100px">
  6. <el-form-item label="表名称" prop="tableName">
  7. <el-input v-model="state.tableData.param.tableName" placeholder="请输入表名称" clearable size="default" @keyup.enter="queryList" />
  8. </el-form-item>
  9. <el-form-item label="表描述" prop="tableComment">
  10. <el-input v-model="state.tableData.param.tableComment" placeholder="请输入表描述" clearable size="default" @keyup.enter="queryList" />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button size="default" type="primary" class="ml10" @click="queryList">
  14. <el-icon>
  15. <ele-Search />
  16. </el-icon>
  17. 查询
  18. </el-button>
  19. <el-button size="default" @click="resetQuery(queryRef)">
  20. <el-icon>
  21. <ele-Refresh />
  22. </el-icon>
  23. 重置
  24. </el-button>
  25. </el-form-item>
  26. </el-form>
  27. </div>
  28. <el-table :data="state.tableData.data" v-loading="state.tableData.loading" style="width: 100%">
  29. <!-- <el-table-column type="selection" width="55" align="center" /> -->
  30. <el-table-column label="ID" align="center" prop="tableId" width="60" />
  31. <el-table-column label="表名称" prop="tableName" min-width="120" :show-overflow-tooltip="true" />
  32. <el-table-column label="表描述" prop="tableComment" min-width="120" :show-overflow-tooltip="true" />
  33. <el-table-column label="模型名称" prop="className" min-width="120" :show-overflow-tooltip="true" />
  34. <el-table-column label="创建时间" prop="createTime" width="180"/>
  35. <el-table-column label="更新时间" prop="updateTime" width="180"/>
  36. <el-table-column label="操作" width="280" align="center" fixed="right">
  37. <template #default="scope">
  38. <el-button size="small" text type="primary" @click="operate('preview', scope.row)">预览</el-button>
  39. <el-button size="small" text type="primary" @click="operate('editParams', scope.row)">参数编辑</el-button>
  40. <el-button size="small" text type="primary" @click="operate('', scope.row)">代码生成</el-button>
  41. <el-button size="small" text type="primary" @click="operate('buildConfig', scope.row)">生成配置</el-button>
  42. <el-button size="small" text type="danger" @click="operate('delete', scope.row)">删除</el-button>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <pagination
  47. v-show="state.tableData.total>0"
  48. :total="state.tableData.total"
  49. v-model:page="state.tableData.param.pageNum"
  50. v-model:limit="state.tableData.param.pageSize"
  51. @pagination="queryList"
  52. />
  53. </el-card>
  54. <!-- <EditDic ref="editDicRef" :treeData="tableData.data" @queryList="queryList" />
  55. <Detail ref="detailRef" /> -->
  56. <Preview ref="previewRef"/>
  57. <EditParams ref="editParamsRef"/>
  58. <BuildConfig ref="buildConfigRef"/>
  59. </div>
  60. </template>
  61. <script lang="ts" setup>
  62. import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
  63. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  64. import EditDic from './component/edit.vue';
  65. import Detail from './component/detail.vue';
  66. import Preview from './component/preview.vue';
  67. import EditParams from './component/editParams.vue';
  68. import BuildConfig from './component/buildConfig.vue';
  69. import api from '/@/api/heatStation';
  70. // 定义接口来定义对象的类型
  71. interface TableDataRow {
  72. id: number;
  73. name: string;
  74. code: string;
  75. stationId: string;
  76. loopTypes: number;
  77. energyTypes: number;
  78. heatingObject: number;
  79. heatingTypes: number;
  80. heatingArea: string;
  81. forRealArea: string;
  82. decade: string;
  83. status: number;
  84. }
  85. interface TableDataState {
  86. ids: number[];
  87. tableData: {
  88. data: Array<TableDataRow>;
  89. loading: boolean;
  90. param: {
  91. name: string;
  92. code: string;
  93. status: number;
  94. };
  95. };
  96. }
  97. const addDicRef = ref();
  98. const editDicRef = ref();
  99. const detailRef = ref();
  100. const previewRef = ref();
  101. const editParamsRef = ref();
  102. const buildConfigRef = ref();
  103. const queryRef = ref();
  104. const state = reactive({
  105. ids: [],
  106. tableData: {
  107. data: [{
  108. "tableId": 3,
  109. "tableName": "log_opers",
  110. "tableComment": "LogOpers",
  111. "className": "LogOpers",
  112. "tplCategory": "crud",
  113. "packageName": "admin",
  114. "moduleName": "log-opers",
  115. "businessName": "logOpers",
  116. "functionName": "LogOpers",
  117. "functionAuthor": "panda",
  118. "options": "",
  119. "remark": "",
  120. "pkColumn": "oper_id",
  121. "pkGoField": "OperId",
  122. "pkJsonField": "operId",
  123. "columns": null,
  124. "createTime": "2022-01-06 15:02:45",
  125. "updateTime": "2022-01-06 15:02:45"
  126. }],
  127. loading: false,
  128. param: {
  129. tableName: '',
  130. tableComment: '',
  131. status: -1
  132. },
  133. },
  134. });
  135. // 初始化表格数据
  136. const initTableData = () => {
  137. queryList();
  138. };
  139. const queryList = () => {
  140. // state.tableData.loading = true
  141. // api.heatStation.getList(state.tableData.param)
  142. // .then((res: any) => {
  143. // state.tableData.data = res || [];
  144. // state.tableData.loading = false
  145. // });
  146. };
  147. // 页面加载时
  148. onMounted(() => {
  149. initTableData();
  150. });
  151. /** 重置按钮操作 */
  152. const resetQuery = (formEl: FormInstance | undefined) => {
  153. if (!formEl) return;
  154. formEl.resetFields();
  155. queryList();
  156. };
  157. const operate = (type: string, row: any) => {
  158. switch(type) {
  159. case 'preview':
  160. console.log(previewRef.value)
  161. previewRef.value.openDialog(row)
  162. break
  163. case 'editParams':
  164. editParamsRef.value.openDialog(row)
  165. break
  166. case 'buildConfig':
  167. buildConfigRef.value.openDialog(row)
  168. break
  169. case 'delete':
  170. ElMessageBox.confirm(`是否确认删除TABLE编号为"${row.tableId}"的数据项?`, '提示', {
  171. confirmButtonText: '确认',
  172. cancelButtonText: '取消',
  173. type: 'warning',
  174. })
  175. .then(() => {
  176. // api.heatStation.del(row.id).then(() => {
  177. // ElMessage.success('删除成功');
  178. // queryList();
  179. // });
  180. })
  181. .catch(() => {});
  182. break
  183. }
  184. }
  185. </script>