index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. <template>
  2. <div class="device-tels-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="addTrunks" v-waves v-auth="'300502'"> <SvgIcon name="ele-Plus" class="mr5" />新增 </el-button>
  8. <el-button type="primary" v-waves @click="onImportTable" :disabled="!state.multipleSelection.length">
  9. <SvgIcon name="iconfont icon-daochu" class="mr5" />导出
  10. </el-button>
  11. </div>
  12. </div>
  13. <!-- 表格 -->
  14. <el-table :data="tableData" v-loading="loading" row-key="id" @selection-change="handleSelectionChange">
  15. <el-table-column type="selection" width="55" :reserve-selection="true" />
  16. <el-table-column prop="trunkId" label="线路号" show-overflow-tooltip width="100"></el-table-column>
  17. <el-table-column prop="morningBegin" label="早上开始时间" show-overflow-tooltip width="130"></el-table-column>
  18. <el-table-column prop="morningEnd" label="早上结束时间" show-overflow-tooltip width="130"></el-table-column>
  19. <el-table-column prop="afterBegin" label="下午开始时间" show-overflow-tooltip width="130"></el-table-column>
  20. <el-table-column prop="afterEnd" label="下午结束时间" show-overflow-tooltip width="130"></el-table-column>
  21. <el-table-column prop="afterBegin" label="工作日" show-overflow-tooltip width="150">
  22. <template #default="scope">
  23. <span v-for="(item, index) in scope.row.workDay" :key="index"> <span v-show="index">,</span>{{ item.weekName }} </span>
  24. </template>
  25. </el-table-column>
  26. <el-table-column prop="workCategoryModel" label="工作时间IVR" show-overflow-tooltip width="150">
  27. <template #default="scope">
  28. <span>{{ scope.row.workCategoryModel.name }}</span>
  29. </template>
  30. </el-table-column>
  31. <el-table-column prop="restCategoryModel" label="休息时间IVR" show-overflow-tooltip width="150">
  32. <template #default="scope">
  33. {{ scope.row.restCategoryModel.name }}
  34. </template>
  35. </el-table-column>
  36. <el-table-column prop="workToGroupModel" label="工作时间直转分机组" show-overflow-tooltip width="160">
  37. <template #default="scope">
  38. {{ scope.row.workToGroupModel.name }}
  39. </template>
  40. </el-table-column>
  41. <el-table-column prop="restToGroupModel" label="休息时间直转分机组" show-overflow-tooltip width="160">
  42. <template #default="scope">
  43. {{ scope.row.restToGroupModel.name }}
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="是否启用" show-overflow-tooltip prop="isEnable">
  47. <template #default="scope">
  48. <el-tag type="success" v-if="scope.row.isEnable">启用</el-tag>
  49. <el-tag type="info" v-else>禁用</el-tag>
  50. </template>
  51. </el-table-column>
  52. <el-table-column label="创建时间" show-overflow-tooltip width="170">
  53. <template #default="scope">
  54. <span>{{ formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="操作" show-overflow-tooltip width="160" fixed="right" align="center">
  58. <template #default="scope">
  59. <el-button text type="primary" @click="updateTrunks(scope.row)" v-auth="'300503'" title="修改线路"> 修改线路 </el-button>
  60. <el-button text type="success" @click="ivrConfigure(scope.row)" v-auth="'300504'" title="删除线路"> 删除线路 </el-button>
  61. </template>
  62. </el-table-column>
  63. <template #empty>
  64. <Empty />
  65. </template>
  66. </el-table>
  67. </div>
  68. <AddTrunks ref="addTrunksRef" @updateList="getListFn" />
  69. <EditTrunks ref="EditTrunksRef" @updateList="getListFn" />
  70. </div>
  71. </template>
  72. <script lang="ts" name="trunks" setup>
  73. import { onMounted, reactive, toRefs, defineAsyncComponent, ref } from 'vue';
  74. import { ElMessage, ElMessageBox } from 'element-plus';
  75. import { formatDate } from '/@/utils/formatTime';
  76. import { useThemeConfig } from '/@/stores/themeConfig';
  77. import { storeToRefs } from 'pinia';
  78. import { useRoute } from 'vue-router';
  79. import table2excel from 'js-table2excel';
  80. // 引入api
  81. import { getList, removetrunk } from '/@/api/device/trunks';
  82. // 引入组件
  83. const AddTrunks = defineAsyncComponent(() => import('/@/views/device/trunks/component/trunksAdd.vue'));
  84. const EditTrunks = defineAsyncComponent(() => import('/@/views/device/trunks/component/trunksEdit.vue'));
  85. // 定义接口来定义对象的类型
  86. interface TelsState {
  87. loading: boolean;
  88. tableData: Array<any>;
  89. multipleSelection: Array<any>;
  90. }
  91. // 定义变量内容
  92. const state = reactive<TelsState>({
  93. loading: false,
  94. tableData: [],
  95. multipleSelection: [],
  96. });
  97. const { loading, tableData } = toRefs(state);
  98. const addTrunksRef = ref();
  99. const EditTrunksRef = ref();
  100. const route = useRoute();
  101. const storesThemeConfig = useThemeConfig();
  102. const { themeConfig } = storeToRefs(storesThemeConfig);
  103. /** 获取线路列表 */
  104. const getListFn = () => {
  105. state.loading = true;
  106. getList()
  107. .then((response: any) => {
  108. state.tableData = response.result ?? [];
  109. state.loading = false;
  110. })
  111. .catch(() => {
  112. state.loading = false;
  113. });
  114. };
  115. // 新增线路
  116. const addTrunks = () => {
  117. addTrunksRef.value?.openDialog();
  118. };
  119. // 修改路线
  120. const updateTrunks = (row: any) => {
  121. EditTrunksRef.value?.openDialog(row);
  122. };
  123. // 删除路线
  124. const ivrConfigure = (row: any) => {
  125. ElMessageBox.confirm(`此操作将永久删除线路:【${row.trunkId}】, 是否继续?`, '提示', {
  126. confirmButtonText: '确定',
  127. cancelButtonText: '取消',
  128. type: 'warning',
  129. draggable: true,
  130. cancelButtonClass: 'default-button',
  131. })
  132. .then(() => {
  133. removetrunk(row.id).then(() => {
  134. ElMessage.success('删除成功');
  135. getListFn();
  136. });
  137. })
  138. .catch(() => {});
  139. };
  140. // 表格多选
  141. const handleSelectionChange = (val: any) => {
  142. state.multipleSelection = val;
  143. };
  144. // 导出表格
  145. const onImportTable = () => {
  146. const tabeHeader = [
  147. { key: 'trunkId', colWidth: '', title: '线路号', type: 'text', isCheck: true },
  148. { key: 'morningBegin', colWidth: '', title: '早上开始时间', type: 'text', isCheck: true },
  149. { key: 'morningEnd', colWidth: '', title: '早上结束时间', type: 'text', isCheck: true },
  150. { key: 'afterBegin', colWidth: '', title: '下午开始时间', type: 'text', isCheck: true },
  151. { key: 'afterEnd', colWidth: '', title: '下午结束时间', type: 'text', isCheck: true },
  152. { key: 'telStatusText', colWidth: '', title: '工作日', type: 'text', isCheck: true },
  153. { key: 'afterBegin', colWidth: '', title: '工作时间IVR', type: 'text', isCheck: true },
  154. { key: 'afterBegin', colWidth: '', title: '休息时间IVR', type: 'text', isCheck: true },
  155. { key: 'afterBegin', colWidth: '', title: '工作时间直转分机组', type: 'text', isCheck: true },
  156. { key: 'afterBegin', colWidth: '', title: '休息时间直转分机组', type: 'text', isCheck: true },
  157. { key: 'afterBegin', colWidth: '', title: '是否启用', type: 'text', isCheck: true },
  158. { key: 'creationTime', colWidth: '', title: '创建时间', type: 'text', isCheck: true },
  159. ];
  160. table2excel(
  161. tabeHeader,
  162. state.multipleSelection,
  163. `${themeConfig.value.globalTitle}-${route.meta.title} ${formatDate(new Date(), 'YYYY-mm-dd HH-MM')}`
  164. );
  165. };
  166. onMounted(() => {
  167. getListFn();
  168. });
  169. </script>
  170. <style lang="scss" scoped>
  171. .device-tels-container {
  172. .el-table {
  173. flex: 1;
  174. }
  175. }
  176. </style>