index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <div class="system-dic-container">
  3. <el-card shadow="hover">
  4. <div class="system-user-search mb15">
  5. <el-form :model="tableData.param" ref="queryRef" :inline="true" label-width="68px">
  6. <el-form-item label="" prop="">
  7. <el-radio-group v-model="radioValue" size="default">
  8. <el-radio-button label="换热站" v-auth="'heatStation'" />
  9. <el-radio-button label="环路" v-auth="'loop'" />
  10. </el-radio-group>
  11. </el-form-item>
  12. <el-form-item label="环路名称" prop="name">
  13. <el-select v-model="tableData.param.name" placeholder="环路名称" clearable size="default" style="width: 240px">
  14. <el-option label="已发布" :value="1" />
  15. <el-option label="未发布" :value="0" />
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item label="环路编号" prop="name">
  19. <el-select v-model="tableData.param.name" placeholder="环路编号" clearable size="default" style="width: 240px">
  20. <el-option label="已发布" :value="1" />
  21. <el-option label="未发布" :value="0" />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button size="default" type="primary" class="ml10" v-auth="'query'" @click="typeList">
  26. <el-icon>
  27. <ele-Search />
  28. </el-icon>
  29. 查询
  30. </el-button>
  31. <el-button size="default" v-auth="'reset'" @click="resetQuery(queryRef)">
  32. <el-icon>
  33. <ele-Refresh />
  34. </el-icon>
  35. 重置
  36. </el-button>
  37. </el-form-item>
  38. </el-form>
  39. </div>
  40. <el-table :data="tableData.data" style="width: 100%" @selection-change="handleSelectionChange" v-loading="tableData.loading">
  41. <el-table-column type="index" width="55" label="序号" align="center" />
  42. <el-table-column label="日期" v-col="'key'" prop="key" min-width="120" :show-overflow-tooltip="true" />
  43. <el-table-column :label="radioValue === '换热站' ? '换热站' : '环路名称'" v-col="'name'" prop="name" :show-overflow-tooltip="true">
  44. <template #default="{ row }">
  45. <el-button type="text" @click="goPage(row)">
  46. {{ radioValue === '换热站' ? '换热站' : '环路名称' }}
  47. </el-button>
  48. </template>
  49. </el-table-column>
  50. <el-table-column :label="radioValue === '换热站' ? '换热站编号' : '环路编号'" v-col="'number'" prop="number" min-width="120" :show-overflow-tooltip="true">
  51. <template #default>
  52. {{ radioValue === '换热站' ? '换热站编号' : '环路编号' }}
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="一网供水流量" prop="value" min-width="120" :show-overflow-tooltip="true" />
  56. <el-table-column label="一网供水压力" prop="value" min-width="120" :show-overflow-tooltip="true" />
  57. <el-table-column label="一网供水温度" prop="value" min-width="120" :show-overflow-tooltip="true" />
  58. <el-table-column label="一网回水流量" prop="value" min-width="120" :show-overflow-tooltip="true" />
  59. <el-table-column label="一网回水压力" prop="value" min-width="120" :show-overflow-tooltip="true" />
  60. <el-table-column label="一网回水温度" prop="value" min-width="120" :show-overflow-tooltip="true" />
  61. <el-table-column label="二网供水流量" prop="value" min-width="120" :show-overflow-tooltip="true" />
  62. <el-table-column label="二网供水压力" prop="value" min-width="120" :show-overflow-tooltip="true" />
  63. <!-- <el-table-column prop="status" label="状态" width="100" align="center">
  64. <template #default="scope">
  65. <el-tag type="success" size="small" v-if="scope.row.status">已发布</el-tag>
  66. <el-tag type="info" size="small" v-else>未发布</el-tag>
  67. </template>
  68. </el-table-column> -->
  69. </el-table>
  70. <pagination v-show="tableData.total > 0" :total="tableData.total" v-model:page="tableData.param.pageNum" v-model:limit="tableData.param.pageSize" @pagination="typeList" />
  71. </el-card>
  72. </div>
  73. </template>
  74. <script lang="ts">
  75. import { toRefs, reactive, onMounted, ref, defineComponent } from 'vue';
  76. import { ElMessageBox, ElMessage, FormInstance } from 'element-plus';
  77. // import EditDic from './component/editPro.vue';
  78. import api from '/@/api/device';
  79. import { useRouter } from 'vue-router';
  80. // 定义接口来定义对象的类型
  81. interface TableDataRow {
  82. id: number;
  83. name: string;
  84. deviceType: string;
  85. status: number;
  86. desc: string;
  87. createBy: string;
  88. }
  89. interface TableDataState {
  90. ids: number[];
  91. tableData: {
  92. data: Array<TableDataRow>;
  93. total: number;
  94. loading: boolean;
  95. param: {
  96. pageNum: number;
  97. pageSize: number;
  98. name: string;
  99. deviceType: string;
  100. status: string;
  101. dateRange: string[];
  102. };
  103. };
  104. }
  105. export default defineComponent({
  106. name: 'deviceproduct',
  107. setup() {
  108. const addDicRef = ref();
  109. const editDicRef = ref();
  110. const queryRef = ref();
  111. const router = useRouter()
  112. const state = reactive({
  113. radioValue: '换热站',
  114. ids: [],
  115. tableData: {
  116. data: [{ name: '换热站', key: '2022-10-25', value: 1 }],
  117. total: 0,
  118. loading: false,
  119. param: {
  120. pageNum: 1,
  121. pageSize: 10,
  122. status: '',
  123. dateRange: [],
  124. },
  125. },
  126. });
  127. // 初始化表格数据
  128. const initTableData = () => {
  129. typeList();
  130. };
  131. const typeList = () => {
  132. state.tableData.loading = true;
  133. api.product.getList(state.tableData.param).then((res: any) => {
  134. state.tableData.data = res.product;
  135. state.tableData.total = res.total;
  136. }).finally(() => (state.tableData.loading = false));
  137. };
  138. // 打开新增产品弹窗
  139. const onOpenAddDic = () => {
  140. editDicRef.value.openDialog();
  141. };
  142. // 打开修改产品弹窗
  143. const onOpenEditDic = (row: TableDataRow) => {
  144. editDicRef.value.openDialog(row);
  145. };
  146. // 删除产品
  147. const onRowDel = (row: TableDataRow) => {
  148. let msg = '你确定要删除所选数据?';
  149. let ids: number[] = [];
  150. if (row) {
  151. msg = `此操作将永久删除产品:“${row.name}”,是否继续?`;
  152. ids = [row.id];
  153. } else {
  154. ids = state.ids;
  155. }
  156. if (ids.length === 0) {
  157. ElMessage.error('请选择要删除的数据。');
  158. return;
  159. }
  160. ElMessageBox.confirm(msg, '提示', {
  161. confirmButtonText: '确认',
  162. cancelButtonText: '取消',
  163. type: 'warning',
  164. })
  165. .then(() => {
  166. api.product.delete(ids).then(() => {
  167. ElMessage.success('删除成功');
  168. typeList();
  169. });
  170. })
  171. .catch(() => { });
  172. };
  173. // 页面加载时
  174. onMounted(() => {
  175. // initTableData();
  176. });
  177. /** 重置按钮操作 */
  178. const resetQuery = (formEl: FormInstance | undefined) => {
  179. if (!formEl) return;
  180. formEl.resetFields();
  181. typeList();
  182. };
  183. // 多选框选中数据
  184. const handleSelectionChange = (selection: TableDataRow[]) => {
  185. // state.ids = selection.map((item) => item.id);
  186. };
  187. const goPage = (row: TableDataRow) => {
  188. if (state.radioValue === '换热站') {
  189. router.push('/heating/monitor/loopSupervision/list/heatStationDetail')
  190. } else {
  191. router.push('/heating/monitor/loopSupervision/list/loopDetail')
  192. }
  193. }
  194. return {
  195. addDicRef,
  196. editDicRef,
  197. queryRef,
  198. onOpenAddDic,
  199. onOpenEditDic,
  200. onRowDel,
  201. typeList,
  202. resetQuery,
  203. handleSelectionChange,
  204. ...toRefs(state),
  205. goPage
  206. };
  207. },
  208. });
  209. </script>