index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <div class="app-container">
  3. <div class="voice-layout">
  4. <!-- 左侧分组列表 -->
  5. <div class="voice-left-panel">
  6. <div class="group-title">
  7. <span>语音分组</span>
  8. <el-button
  9. type="primary"
  10. size="mini"
  11. icon="el-icon-plus"
  12. circle
  13. @click="handleAddGroup"
  14. ></el-button>
  15. </div>
  16. <div class="group-list">
  17. <div
  18. class="group-item"
  19. :class="{ active: currentGroupId === null }"
  20. @click="selectGroup(null)"
  21. >全部</div>
  22. <div
  23. v-for="item in groupList"
  24. :key="item.id"
  25. class="group-item"
  26. :class="{ active: currentGroupId === item.id }"
  27. @click="selectGroup(item.id)"
  28. >
  29. <span class="group-item-name">{{ item.voiceGroupName }}</span>
  30. <i class="el-icon-edit group-item-edit" @click.stop="handleEditGroup(item)"></i>
  31. </div>
  32. </div>
  33. </div>
  34. <!-- 右侧内容区 -->
  35. <div class="voice-right-panel">
  36. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="120px">
  37. <el-form-item label="语音文本" prop="voiceTxt">
  38. <el-input
  39. v-model="queryParams.voiceTxt"
  40. placeholder="请输入语音文本"
  41. clearable
  42. size="small"
  43. @keyup.enter.native="handleQuery"
  44. />
  45. </el-form-item>
  46. <el-form-item>
  47. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  48. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  49. </el-form-item>
  50. </el-form>
  51. <el-row :gutter="10" class="mb8">
  52. <el-col :span="1.5">
  53. <el-button
  54. type="primary"
  55. plain
  56. icon="el-icon-plus"
  57. size="mini"
  58. @click="handleAdd"
  59. v-hasPermi="['qw:QwSopTempVoice:add']"
  60. >新增</el-button>
  61. </el-col>
  62. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  63. </el-row>
  64. <el-table border v-loading="loading" :data="QwSopTempVoiceList" @selection-change="handleSelectionChange">
  65. <el-table-column type="selection" width="55" align="center" />
  66. <el-table-column label="语音文本" align="center" prop="voiceTxt" />
  67. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  68. <template slot-scope="scope">
  69. <el-button
  70. size="mini"
  71. type="text"
  72. icon="el-icon-delete"
  73. @click="handleDelete(scope.row)"
  74. v-hasPermi="['qw:QwSopTempVoice:remove']"
  75. >删除</el-button>
  76. </template>
  77. </el-table-column>
  78. </el-table>
  79. <pagination
  80. v-show="total>0"
  81. :total="total"
  82. :page.sync="queryParams.pageNum"
  83. :limit.sync="queryParams.pageSize"
  84. @pagination="getList"
  85. />
  86. </div>
  87. </div>
  88. <!-- 添加或修改模板对应的销售语音文件对话框 -->
  89. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  90. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  91. <el-form-item label="语音分组" prop="groupId">
  92. <el-select
  93. v-model="form.groupId"
  94. placeholder="请选择语音分组"
  95. clearable
  96. size="small"
  97. style="width: 100%"
  98. >
  99. <el-option
  100. v-for="item in groupList"
  101. :key="item.id"
  102. :label="item.voiceGroupName"
  103. :value="item.id"
  104. />
  105. </el-select>
  106. </el-form-item>
  107. <el-form-item label="语音文本" prop="voiceTxt">
  108. <el-input type="textarea" :rows="6" v-model="form.voiceTxt" placeholder="请输入语音文本" />
  109. </el-form-item>
  110. </el-form>
  111. <div slot="footer" class="dialog-footer">
  112. <el-button type="primary" @click="submitForm">确 定</el-button>
  113. <el-button @click="cancel">取 消</el-button>
  114. </div>
  115. </el-dialog>
  116. </div>
  117. </template>
  118. <script>
  119. import { listQwSopTempVoice, getQwSopTempVoice, delQwSopTempVoice, addQwSopTempVoice, updateQwSopTempVoice, exportQwSopTempVoice } from "@/api/qw/QwSopTempVoice";
  120. import { removeSidebar } from "@/api/qw/QwSopTempVoice";
  121. import { listQwSopTempVoiceGroup, addQwSopTempVoiceGroup, updateQwSopTempVoiceGroup } from "@/api/qw/QwSopTempVoiceGroup";
  122. export default {
  123. name: "QwSopTempVoice",
  124. data() {
  125. return {
  126. // 分组列表
  127. groupList: [],
  128. // 当前选中的分组ID,null表示全部
  129. currentGroupId: null,
  130. // 是否录制完成字典
  131. recordTypeOptions: [
  132. { dictLabel: '是', dictValue: '1' },
  133. { dictLabel: '否', dictValue: '2' }
  134. ],
  135. // 遮罩层
  136. loading: true,
  137. // 导出遮罩层
  138. exportLoading: false,
  139. // 选中数组
  140. ids: [],
  141. // 非单个禁用
  142. single: true,
  143. // 非多个禁用
  144. multiple: true,
  145. // 显示搜索条件
  146. showSearch: true,
  147. // 总条数
  148. total: 0,
  149. // 模板对应的销售语音文件表格数据
  150. QwSopTempVoiceList: [],
  151. // 弹出层标题
  152. title: "",
  153. // 是否显示弹出层
  154. open: false,
  155. // 查询参数
  156. queryParams: {
  157. pageNum: 1,
  158. pageSize: 10,
  159. companyUserId: null,
  160. companyId: null,
  161. qwUserId: null,
  162. tempId: null,
  163. ruleId: null,
  164. dayId: null,
  165. contentId: null,
  166. groupId: null,
  167. voiceTxt: null,
  168. voiceUrl: null,
  169. userVoiceUrl: null,
  170. recordType: null,
  171. duration: null,
  172. status: null
  173. },
  174. // 表单参数
  175. form: {},
  176. // 表单校验
  177. rules: {
  178. groupId: [
  179. { required: true, message: "请选择语音分组", trigger: "change" }
  180. ]
  181. }
  182. };
  183. },
  184. created() {
  185. this.getGroupList();
  186. this.getList();
  187. },
  188. methods: {
  189. /** 获取语音分组列表 */
  190. getGroupList() {
  191. listQwSopTempVoiceGroup({ pageNum: 1, pageSize: 999 }).then(response => {
  192. this.groupList = response.rows;
  193. });
  194. },
  195. /** 选择分组 */
  196. selectGroup(groupId) {
  197. this.currentGroupId = groupId;
  198. this.queryParams.groupId = groupId;
  199. this.queryParams.pageNum = 1;
  200. this.getList();
  201. },
  202. /** 新增分组 */
  203. handleAddGroup() {
  204. this.$prompt('请输入语音分组名称', '新增分组', {
  205. confirmButtonText: '确定',
  206. cancelButtonText: '取消',
  207. inputPattern: /\S/,
  208. inputErrorMessage: '分组名称不能为空'
  209. }).then(({ value }) => {
  210. addQwSopTempVoiceGroup({ voiceGroupName: value }).then(() => {
  211. this.msgSuccess('新增成功');
  212. this.getGroupList();
  213. });
  214. }).catch(() => {});
  215. },
  216. /** 修改分组名称 */
  217. handleEditGroup(item) {
  218. if (!item) return;
  219. this.$prompt('请输入新的分组名称', '修改分组', {
  220. confirmButtonText: '确定',
  221. cancelButtonText: '取消',
  222. inputPattern: /\S/,
  223. inputErrorMessage: '分组名称不能为空',
  224. inputValue: item.voiceGroupName
  225. }).then(({ value }) => {
  226. updateQwSopTempVoiceGroup({ id: item.id, voiceGroupName: value }).then(() => {
  227. this.msgSuccess('修改成功');
  228. this.getGroupList();
  229. });
  230. }).catch(() => {});
  231. },
  232. /** 查询模板对应的销售语音文件列表 */
  233. getList() {
  234. this.loading = true;
  235. listQwSopTempVoice(this.queryParams).then(response => {
  236. this.QwSopTempVoiceList = response.rows;
  237. this.total = response.total;
  238. this.loading = false;
  239. });
  240. },
  241. // 取消按钮
  242. cancel() {
  243. this.open = false;
  244. this.reset();
  245. },
  246. // 表单重置
  247. reset() {
  248. this.form = {
  249. id: null,
  250. companyUserId: null,
  251. companyId: null,
  252. qwUserId: null,
  253. tempId: null,
  254. ruleId: null,
  255. dayId: null,
  256. contentId: null,
  257. groupId: null,
  258. voiceTxt: null,
  259. voiceUrl: null,
  260. userVoiceUrl: null,
  261. recordType: null,
  262. duration: null,
  263. createTime: null,
  264. updateTime: null,
  265. status: 0
  266. };
  267. this.resetForm("form");
  268. },
  269. /** 搜索按钮操作 */
  270. handleQuery() {
  271. this.queryParams.pageNum = 1;
  272. this.getList();
  273. },
  274. /** 重置按钮操作 */
  275. resetQuery() {
  276. this.resetForm("queryForm");
  277. this.handleQuery();
  278. },
  279. // 多选框选中数据
  280. handleSelectionChange(selection) {
  281. this.ids = selection.map(item => item.id)
  282. this.single = selection.length!==1
  283. this.multiple = !selection.length
  284. },
  285. /** 新增按钮操作 */
  286. handleAdd() {
  287. this.reset();
  288. this.open = true;
  289. this.title = "添加模板对应的销售语音文本";
  290. },
  291. /** 修改按钮操作 */
  292. handleUpdate(row) {
  293. this.reset();
  294. const id = row.id || this.ids
  295. getQwSopTempVoice(id).then(response => {
  296. this.form = response.data;
  297. this.open = true;
  298. this.title = "修改模板对应的销售语音文本";
  299. });
  300. },
  301. /** 提交按钮 */
  302. submitForm() {
  303. this.$refs["form"].validate(valid => {
  304. if (valid) {
  305. if (this.form.id != null) {
  306. updateQwSopTempVoice(this.form).then(response => {
  307. this.msgSuccess("修改成功");
  308. this.open = false;
  309. this.getList();
  310. });
  311. } else {
  312. addQwSopTempVoice(this.form).then(response => {
  313. this.msgSuccess("新增成功");
  314. this.open = false;
  315. this.getList();
  316. });
  317. }
  318. }
  319. });
  320. },
  321. /** 删除按钮操作 */
  322. handleDelete(row) {
  323. this.$confirm('是否确认删除模板对应的销售语音文本---"' + row.voiceTxt + '"---的数据项?', "警告", {
  324. confirmButtonText: "确定",
  325. cancelButtonText: "取消",
  326. type: "warning"
  327. }).then(function() {
  328. return removeSidebar(row);
  329. }).then(() => {
  330. this.getList();
  331. this.msgSuccess("删除成功");
  332. }).catch(() => {});
  333. },
  334. /** 导出按钮操作 */
  335. handleExport() {
  336. const queryParams = this.queryParams;
  337. this.$confirm('是否确认导出所有模板对应的销售语音文件数据项?', "警告", {
  338. confirmButtonText: "确定",
  339. cancelButtonText: "取消",
  340. type: "warning"
  341. }).then(() => {
  342. this.exportLoading = true;
  343. return exportQwSopTempVoice(queryParams);
  344. }).then(response => {
  345. this.download(response.msg);
  346. this.exportLoading = false;
  347. }).catch(() => {});
  348. }
  349. }
  350. };
  351. </script>
  352. <style scoped>
  353. .app-container {
  354. position: relative;
  355. height: calc(100vh - 150px);
  356. overflow: hidden;
  357. box-sizing: border-box;
  358. }
  359. .voice-layout {
  360. position: absolute;
  361. top: 20px;
  362. left: 20px;
  363. right: 20px;
  364. bottom: 20px;
  365. display: flex;
  366. }
  367. .voice-left-panel {
  368. width: 200px;
  369. min-width: 200px;
  370. background: #fff;
  371. border-right: 1px solid #e8e8e8;
  372. display: flex;
  373. flex-direction: column;
  374. }
  375. .group-title {
  376. display: flex;
  377. align-items: center;
  378. justify-content: space-between;
  379. font-size: 16px;
  380. font-weight: bold;
  381. padding: 16px 16px 12px;
  382. border-bottom: 1px solid #e8e8e8;
  383. flex-shrink: 0;
  384. }
  385. .group-list {
  386. padding: 8px 8px 0;
  387. overflow-y: auto;
  388. flex: 1;
  389. }
  390. .group-item {
  391. padding: 10px 12px;
  392. cursor: pointer;
  393. border-radius: 4px;
  394. font-size: 14px;
  395. color: #333;
  396. transition: all 0.2s;
  397. display: flex;
  398. align-items: center;
  399. justify-content: space-between;
  400. }
  401. .group-item-name {
  402. flex: 1;
  403. overflow: hidden;
  404. text-overflow: ellipsis;
  405. white-space: nowrap;
  406. }
  407. .group-item-edit {
  408. font-size: 13px;
  409. color: #999;
  410. flex-shrink: 0;
  411. margin-left: 6px;
  412. }
  413. .group-item-edit:hover {
  414. color: #1890ff;
  415. }
  416. .group-item:hover {
  417. background: #f0f2f5;
  418. }
  419. .group-item.active {
  420. background: #e6f7ff;
  421. color: #1890ff;
  422. font-weight: bold;
  423. }
  424. .voice-right-panel {
  425. flex: 1;
  426. padding-left: 16px;
  427. min-width: 0;
  428. overflow-y: auto;
  429. overflow-x: hidden;
  430. }
  431. </style>