index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <template>
  2. <div class="deviceManagement-ivrCategroy-container layout-padding">
  3. <div class="layout-padding-auto layout-padding-view pd20">
  4. <div class="flex-center-between mb20">
  5. <p class="table-title">信息列表</p>
  6. <div>
  7. <el-button type="primary" @click="onAddCategory" v-waves v-auth="'300302'">
  8. <SvgIcon name="ele-Plus" class="mr5" />新增
  9. </el-button>
  10. <el-button type="primary" v-waves @click="onImportTable" :disabled="!state.multipleSelection.length">
  11. <SvgIcon name="iconfont icon-daochu" class="mr5"/>导出
  12. </el-button>
  13. </div>
  14. </div>
  15. <!-- 表格 -->
  16. <el-table :data="tableData" v-loading="loading" row-key="id" @selection-change="handleSelectionChange">
  17. <el-table-column type="selection" width="55" :reserve-selection="true"/>
  18. <el-table-column prop="name" label="分类名称" show-overflow-tooltip></el-table-column>
  19. <el-table-column prop="remark" label="备注" show-overflow-tooltip></el-table-column>
  20. <el-table-column prop="creationTime" label="创建时间" show-overflow-tooltip width="170">
  21. <template #default="scope">
  22. <span>{{ formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="操作" width="100" fixed="right" align="center">
  26. <template #default="scope">
  27. <el-button text type="primary" @click="onEditCategroy(scope.row)" v-auth="'300303'" title="修改">
  28. <SvgIcon name="ele-EditPen" size="var(--hotline-table-icon-font-size)" />
  29. </el-button>
  30. <el-button text type="danger" @click="onDelCategroy(scope.row)" v-auth="'300304'" title="删除">
  31. <SvgIcon name="ele-Delete" size="var(--hotline-table-icon-font-size)" />
  32. </el-button>
  33. <!-- <el-button text type="success" @click="configIvr(scope.row)">配置ivr</el-button> -->
  34. </template>
  35. </el-table-column>
  36. <template #empty>
  37. <Empty />
  38. </template>
  39. </el-table>
  40. </div>
  41. <AddCategroy ref="addCategroyRef" @updateList="handleQuery" />
  42. <EditCategroy ref="editCategroyRef" @updateList="handleQuery" />
  43. </div>
  44. </template>
  45. <script lang="ts" setup name="ivrCategroy">
  46. import { defineAsyncComponent, onMounted, ref,reactive, toRefs } from "vue";
  47. import { ElMessage, ElMessageBox } from 'element-plus'
  48. import { getIvrCategories, deleteIvrCategroies } from "/@/api/deviceManagement/ivr";
  49. import { formatDate } from '/@/utils/formatTime';
  50. import table2excel from 'js-table2excel';
  51. // 定义接口来定义对象的类型
  52. interface IvrCategroyState{
  53. loading:boolean;
  54. tableData:Array<any>; //列表数据
  55. multipleSelection:Array<any>; //多选列表
  56. }
  57. // 引入组件
  58. const AddCategroy = defineAsyncComponent(() => import('/@/views/deviceManagement/ivrCategroy/component/addCategroy.vue'))
  59. const EditCategroy = defineAsyncComponent(() => import('/@/views/deviceManagement/ivrCategroy/component/editCatehroy.vue'))
  60. // 定义变量内容
  61. // import { useRouter } from "vue-router";
  62. const state = reactive<IvrCategroyState>({
  63. loading:false,
  64. tableData:[],
  65. multipleSelection:[]
  66. })
  67. const {loading,tableData} = toRefs(state)
  68. const addCategroyRef = ref();
  69. const editCategroyRef = ref();
  70. // 新增分类
  71. const onAddCategory = () => {
  72. addCategroyRef.value.openDialog()
  73. }
  74. // 编辑分类
  75. const onEditCategroy = (row: any) => {
  76. editCategroyRef.value.openDialog(row)
  77. }
  78. //删除分类
  79. const onDelCategroy = (row: any) => {
  80. ElMessageBox.confirm(`此操作将永久删除分类:【${row.name}】,是否继续?`, '提示', {
  81. confirmButtonText: '确认',
  82. cancelButtonText: '取消',
  83. type: 'warning',
  84. draggable: true,
  85. cancelButtonClass:'default-button'
  86. }).then(() => {
  87. deleteIvrCategroies(row.id).then(() => {
  88. ElMessage.success('删除成功');
  89. handleQuery();
  90. });
  91. }).catch(() => { });
  92. }
  93. //查询列表
  94. const handleQuery = () => {
  95. state.loading = true;
  96. getIvrCategories().then((res: any) => {
  97. state.tableData = res?.result ?? [];
  98. setTimeout(() => {
  99. state.loading = false;
  100. }, 300);
  101. })
  102. }
  103. // 配置ivr
  104. // const configIvr = (row:any)=>{
  105. // router.push({
  106. // // path:"/ivrConfig/details",
  107. // name:"ivrConfigDetails",
  108. // params:{
  109. // tagsViewName:row.name+'ivr配置',
  110. // id: row.id,
  111. // }
  112. // })
  113. // }
  114. // 表格多选
  115. const handleSelectionChange = (val: any) => {
  116. state.multipleSelection = val;
  117. }
  118. // 导出表格
  119. const onImportTable = ()=>{
  120. const tabeHeader = [
  121. { key: 'name', colWidth: '', title: '分类名称', type: 'text', isCheck: true },
  122. { key: 'remark', colWidth: '', title: '备注', type: 'text', isCheck: true },
  123. { key: 'creationTime', colWidth: '', title: '创建时间', type: 'text', isCheck: true },
  124. ]
  125. table2excel(tabeHeader, state.multipleSelection, `ivr分类管理 ${formatDate(new Date(),'YYYY-mm-dd HH-MM')}`);
  126. }
  127. onMounted(() => {
  128. handleQuery();
  129. })
  130. </script>
  131. <style scoped lang="scss">
  132. .deviceManagement-ivrCategroy-container {
  133. .el-table {
  134. flex: 1;
  135. }
  136. }
  137. </style>