index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <!-- 平台接入列表 -->
  2. <template>
  3. <div class="page-full">
  4. <el-card shadow="nover" class="page-full-part">
  5. <el-form :model="params" inline ref="queryRef">
  6. <el-form-item prop="deptName" class="mr10">
  7. <el-input @keyup.enter.native="getList" style="width: 240px;" v-model="params.keyWord" placeholder="请输入关键字搜索" clearable />
  8. </el-form-item>
  9. <el-form-item>
  10. <el-button type="primary" @click="getList">
  11. <el-icon>
  12. <ele-Search />
  13. </el-icon>
  14. 查询
  15. </el-button>
  16. <el-button @click="resetQuery()">
  17. <el-icon>
  18. <ele-Refresh />
  19. </el-icon>
  20. 重置
  21. </el-button>
  22. <el-button type="primary" @click="toAddItemPage()">
  23. <el-icon>
  24. <ele-FolderAdd />
  25. </el-icon>
  26. 新增
  27. </el-button>
  28. </el-form-item>
  29. </el-form>
  30. <el-table
  31. :data="tableData"
  32. max-height="calc(100vh - 210px);"
  33. v-loading="loading"
  34. style="width: 100%"
  35. >
  36. <el-table-column label="名称" prop="name" align="center" />
  37. <el-table-column label="状态" prop="simStatus" align="center">
  38. <template #default="scope">
  39. <el-tag type="primary" v-if="scope.row.status">{{ formatStatus(scope.row.status) }}</el-tag>
  40. <el-tag type="danger" v-else>{{ formatStatus(scope.row.status) }}</el-tag>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="说明" prop="remark" align="center" />
  44. <el-table-column width="110" label="操作" fixed="right" prop="handle" align="center">
  45. <template #default="scope">
  46. <el-button size="small" text type="primary" @click="onOpenDetail(scope.row)">详情</el-button>
  47. <el-button size="small" text type="warning" @click="onDel(scope.row)">删除</el-button>
  48. </template>
  49. </el-table-column>
  50. </el-table>
  51. <pagination
  52. v-if="params.total"
  53. :total="params.total"
  54. v-model:page="params.pageNum"
  55. v-model:limit="params.pageSize"
  56. @pagination="getList()"
  57. />
  58. </el-card>
  59. <AddOrEditItem ref="AddOrEditItemRef" @updateList="getList()" />
  60. </div>
  61. </template>
  62. <script lang="ts" setup>
  63. import api from '/@/api/iotCard';
  64. import { defineAsyncComponent, ref } from 'vue';
  65. import { ElMessageBox, ElMessage } from 'element-plus';
  66. import { useSearch } from "/@/hooks/useCommon"
  67. const AddOrEditItem = defineAsyncComponent(() => import('./addOrEditItem.vue'));
  68. const { params, tableData, getList, loading } = useSearch<any[]>(
  69. api.platform.getList,
  70. "Data"
  71. )
  72. getList();
  73. const AddOrEditItemRef = ref();
  74. /** 重置按钮操作 */
  75. const resetQuery = () => {
  76. params.keyWord = ""
  77. getList();
  78. };
  79. /**
  80. * 单一删除
  81. */
  82. const onDel = (row: any) => {
  83. ElMessageBox.confirm(`此操作将卡号为:“${row.accNumber}”,是否继续?`, '提示', {
  84. confirmButtonText: '确认',
  85. cancelButtonText: '取消',
  86. type: 'warning',
  87. }).then(async () => {
  88. await api.simCard.deleteItem({ ids: [row.id] });
  89. ElMessage.success('删除成功');
  90. getList();
  91. });
  92. };
  93. const formatStatus = (val:any) => {
  94. // 1:开启 0:禁用
  95. return ['', '开启', '禁用'][val];
  96. }
  97. const onOpenDetail = (item:any) => {
  98. AddOrEditItemRef.value.openDialog(item);
  99. }
  100. const toAddItemPage = () => {
  101. AddOrEditItemRef.value.openDialog();
  102. }
  103. </script>