index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="deviceManagement-telsGroup-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="onAddTelsGroup" v-waves v-auth="'300202'">
  8. <SvgIcon name="ele-Plus" class="mr5" />新增
  9. </el-button>
  10. <el-button type="primary" v-waves @click="onImportTable"
  11. :disabled="!state.multipleSelection.length">
  12. <SvgIcon name="iconfont icon-daochu" class="mr5" />导出
  13. </el-button>
  14. </div>
  15. </div>
  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="no" label="编号" show-overflow-tooltip></el-table-column>
  19. <el-table-column prop="name" label="分机组名称" show-overflow-tooltip></el-table-column>
  20. <el-table-column prop="distributionText" label="呼叫分配方式" show-overflow-tooltip></el-table-column>
  21. <el-table-column label="是否默认分组" show-overflow-tooltip>
  22. <template #default="scope">
  23. {{ scope.row.isDefault ? '是' : '否' }}
  24. </template>
  25. </el-table-column>
  26. <el-table-column prop="remark" label="备注" show-overflow-tooltip></el-table-column>
  27. <el-table-column prop="creationTime" label="创建时间" show-overflow-tooltip width="170">
  28. <template #default="scope">
  29. <span>{{ formatDate(scope.row.creationTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
  30. </template>
  31. </el-table-column>
  32. <el-table-column label="操作" width="100" fixed="right" align="center">
  33. <template #default="scope">
  34. <el-button text type="primary" @click="configure(scope.row)" v-auth="'300203'" title="配置分机组">
  35. <SvgIcon name="ele-EditPen" size="var(--hotline-table-icon-font-size)" />
  36. </el-button>
  37. </template>
  38. </el-table-column>
  39. <template #empty>
  40. <Empty />
  41. </template>
  42. </el-table>
  43. </div>
  44. <!-- 配置分机组 -->
  45. <el-dialog v-model="isShowDialog" draggable :title="dialogTitle">
  46. <el-form :model="ruleForm" label-width="110px" ref="ruleFormRef">
  47. <el-row :gutter="35">
  48. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
  49. <el-form-item label="分机编号" prop="no">
  50. <el-input v-model="ruleForm.no" disabled></el-input>
  51. </el-form-item>
  52. </el-col>
  53. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
  54. <el-form-item label="分机组名称" prop="name"
  55. :rules="[{ required: true, message: '请输入分机组名称', trigger: 'blur' }]">
  56. <el-input v-model="ruleForm.name" placeholder="请输入分机组名称" clearable></el-input>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
  60. <el-form-item label="呼叫分配方式" prop="distribution"
  61. :rules="[{ required: true, message: '请选择ivr类型', trigger: 'change' }]">
  62. <el-select v-model="ruleForm.distribution" placeholder="请选择呼叫分配方式" class="w100">
  63. <el-option v-for="item in distributions" :key="item.key" :label="item.value"
  64. :value="item.key" />
  65. </el-select>
  66. </el-form-item>
  67. </el-col>
  68. <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
  69. <el-form-item label="默认分组" prop="isDefault"
  70. :rules="[{ required: false, message: '请选择ivr类型', trigger: 'change' }]">
  71. <el-switch v-model="ruleForm.isDefault" />
  72. </el-form-item>
  73. </el-col>
  74. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  75. <el-form-item label="选择分机" prop="telNos"
  76. :rules="[{ required: true, message: '请选择分机', trigger: 'change' }]">
  77. <el-transfer v-model="ruleForm.telNos" :titles="['所有分机', '已选分机']" :props="{ key: 'no' }"
  78. :data="telsList" :filterable="true">
  79. <template #default="{ option }">
  80. <span>分机 - {{ option.no }}</span>
  81. </template>
  82. </el-transfer>
  83. </el-form-item>
  84. </el-col>
  85. <!-- 语音文件 -->
  86. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  87. <el-form-item label="语音文件" prop="voiceList"
  88. :rules="[{ required: false, message: '选择语音文件', trigger: 'change' }]">
  89. <el-transfer v-model="ruleForm.voiceList" :titles="['选择语音文件', '按照选择顺序播放']"
  90. target-order="push" :data="voiceData" :filterable="true">
  91. <template #default="{ option }">
  92. <span>{{ option.label }}</span>
  93. </template>
  94. </el-transfer>
  95. </el-form-item>
  96. </el-col>
  97. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  98. <el-form-item label="备注" prop="remark">
  99. <el-input v-model="ruleForm.remark" type="textarea" :autosize="{ minRows: 4, maxRows: 6 }"
  100. placeholder="请输入备注" clearable></el-input>
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. </el-form>
  105. <template #footer>
  106. <span class="dialog-footer">
  107. <el-button @click="isShowDialog = false" class="default-button">取 消</el-button>
  108. <el-button type="primary" @click="save" :loading="loading">保 存</el-button>
  109. </span>
  110. </template>
  111. </el-dialog>
  112. </div>
  113. </template>
  114. <script lang="ts" name="tels" setup>
  115. import { ref, reactive, toRefs, onMounted } from "vue";
  116. import { ElMessage } from 'element-plus';
  117. import { storeToRefs } from 'pinia';
  118. import { formatDate } from '/@/utils/formatTime';
  119. import { useUserInfo } from '/@/stores/userInfo';
  120. import table2excel from 'js-table2excel';
  121. // 引入需要的api
  122. import { getTelsGroupList, addTelsGroup, updateTelsGroup, baseInfoTelsGroup } from '/@/api/deviceManagement/telsGroup';
  123. import { getTelsList } from '/@/api/deviceManagement/tels';
  124. import { voicequerylist } from '/@/api/deviceManagement/ivr';
  125. // 定义接口来定义对象的类型
  126. interface TelsGroupState {
  127. ruleForm: {
  128. no: string; // 分机组编号
  129. name: string; // 分机组名称
  130. remark: string; // 分机组备注
  131. telNos: Array<any>; //选择的分机
  132. voiceList: Array<any>; //语音列表
  133. voice: string; //格式化之后的语音列表
  134. distribution: object; //呼叫分配方式
  135. isDefault: boolean; //是否默认分组
  136. }
  137. distributions: Array<any>; //呼叫分配方式列表
  138. loading: boolean;
  139. tableData: Array<any>; //列表数据
  140. voiceData: Array<any>; //音频文件
  141. isShowDialog: boolean;
  142. telsList: Array<any>; //分机列表
  143. multipleSelection: Array<any>; //多选列表
  144. }
  145. // 定义变量内容
  146. const dialogTitle = ref('配置分机组');
  147. const ruleFormRef = ref();
  148. const state = reactive<TelsGroupState>({
  149. ruleForm: {
  150. no: '', // 分机组编号
  151. name: '', // 分机组名称
  152. remark: '', // 分机组备注
  153. telNos: [],
  154. voiceList: [],
  155. voice: "",
  156. distribution: {},
  157. isDefault: false
  158. },
  159. distributions: [],
  160. loading: false,
  161. tableData: [],
  162. voiceData: [],
  163. isShowDialog: false,
  164. telsList: [],
  165. multipleSelection: []
  166. })
  167. const storesUserInfo = useUserInfo();
  168. const { userInfos } = storeToRefs(storesUserInfo);
  169. const { ruleForm, distributions, loading, tableData, voiceData, isShowDialog, telsList } = toRefs(state);
  170. /** 获取所有语音文件列表 */
  171. const getAudioList = () => {
  172. if (userInfos.value.authBtnList.includes('300201')) { // 校验是否有权限 页面基础信息
  173. voicequerylist().then((response: any) => {
  174. state.voiceData = response.result.map((item: any) => {
  175. return {
  176. key: item,
  177. label: item
  178. }
  179. })
  180. setTimeout(() => {
  181. state.loading = false;
  182. }, 300);
  183. }).catch(() => {
  184. state.loading = false;
  185. });
  186. baseInfoTelsGroup().then((res: any) => {// 获取页面基础信息
  187. state.distributions = res?.result.distributions ?? [];
  188. })
  189. } else {
  190. ElMessage.warning('您没有权限查看页面基础信息');
  191. }
  192. };
  193. /** 获取分机列表 */
  194. const getList = () => {
  195. state.loading = true;
  196. getTelsGroupList().then((response: any) => {
  197. state.tableData = response?.result ?? [];
  198. for (let i of state.tableData) {
  199. i.voiceList = i.voice ? i.voice.split('+') : [];
  200. i.telNos = i.tels;
  201. }
  202. setTimeout(() => {
  203. state.loading = false;
  204. }, 300);
  205. }).catch(() => {
  206. state.loading = false;
  207. });
  208. };
  209. const configure = (row: any) => { //配置分机
  210. state.ruleForm = JSON.parse(JSON.stringify(row));
  211. dialogTitle.value = "配置分机组";
  212. if (row.telNos) { //处理成穿梭框需要的数据格式
  213. let arr: string[] = [];
  214. for (let i of row.telNos) {
  215. arr.push(i.no)
  216. }
  217. state.ruleForm.telNos = arr;
  218. } else {
  219. state.ruleForm.telNos = <any>[]
  220. }
  221. state.isShowDialog = true;
  222. }
  223. //新增分机组
  224. const onAddTelsGroup = () => {
  225. dialogTitle.value = "新增分机组";
  226. ruleFormRef.value?.resetFields();
  227. ruleFormRef.value?.resetFields();
  228. if (state.tableData.length) {
  229. state.ruleForm = {
  230. no: String(Number(state.tableData.length + 1)), // ivr编号
  231. name: '',
  232. remark: '',
  233. telNos: [],
  234. voiceList: [],
  235. voice: "",
  236. distribution: {},
  237. isDefault: false
  238. }
  239. } else {
  240. state.ruleForm.no = '1';
  241. }
  242. state.isShowDialog = true;
  243. }
  244. /** 获取分机列表 */
  245. const getTelList = () => {
  246. getTelsList().then((response: any) => {
  247. state.telsList = response?.result ?? [];
  248. }).catch(() => {
  249. });
  250. };
  251. // 保存分机组配置
  252. const save = () => {
  253. ruleFormRef.value.validate((valid: boolean) => {
  254. if (valid) {
  255. if (state.ruleForm.voiceList.length) {
  256. state.ruleForm.voice = state.ruleForm.voiceList.join("+");
  257. }
  258. state.loading = true;
  259. if (dialogTitle.value == '新增分机组') {
  260. addTelsGroup(state.ruleForm).then(() => {
  261. ElMessage.success("操作成功");
  262. setTimeout(() => {
  263. getList();
  264. }, 1000);
  265. state.isShowDialog = false;
  266. state.loading = false;
  267. }).catch(() => {
  268. state.loading = false;
  269. });
  270. } else if (dialogTitle.value == '配置分机组') {
  271. updateTelsGroup(state.ruleForm).then(() => {
  272. ElMessage.success("操作成功");
  273. setTimeout(() => {
  274. getList();
  275. }, 1000);
  276. state.isShowDialog = false;
  277. state.loading = false;
  278. }).catch(() => {
  279. state.loading = false;
  280. });
  281. }
  282. } else {
  283. return false;
  284. }
  285. });
  286. }
  287. // 表格多选
  288. const handleSelectionChange = (val: any) => {
  289. state.multipleSelection = val;
  290. }
  291. // 导出表格
  292. const onImportTable = () => {
  293. const tabeHeader = [
  294. { key: 'no', colWidth: '', title: '编号', type: 'text', isCheck: true },
  295. { key: 'name', colWidth: '', title: '分机组名称', type: 'text', isCheck: true },
  296. { key: 'distributionText', colWidth: '', title: '呼叫分配方式', type: 'text', isCheck: true },
  297. { key: 'isDefault', colWidth: '', title: '是否默认分组', type: 'text', isCheck: true },
  298. { key: 'remark', colWidth: '', title: '备注', type: 'text', isCheck: true },
  299. { key: 'creationTime', colWidth: '', title: '创建时间', type: 'text', isCheck: true },
  300. ]
  301. table2excel(tabeHeader, state.multipleSelection, `分机组管理 ${formatDate(new Date(), 'YYYY-mm-dd HH-MM')}`);
  302. }
  303. // 页面加载时
  304. onMounted(() => {
  305. getTelList(); //获取分机列表
  306. getList();
  307. getAudioList();
  308. });
  309. </script>
  310. <style lang="scss" scoped>
  311. .deviceManagement-telsGroup-container {
  312. .el-table {
  313. flex: 1;
  314. }
  315. }
  316. </style>