index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="公司名" prop="companyId">
  5. <el-select filterable style="width: 220px" v-model="queryParams.companyId" placeholder="请选择公司名" @change="companyChange" clearable size="small">
  6. <el-option
  7. v-for="item in companys"
  8. :key="item.companyId"
  9. :label="item.companyName"
  10. :value="item.companyId"
  11. />
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item >
  15. <treeselect style="width: 220px" :clearable="false" v-model="queryParams.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
  16. </el-form-item>
  17. <el-form-item label="员工姓名" prop="userNickName">
  18. <el-input
  19. style="width: 220px"
  20. v-model="queryParams.userNickName"
  21. placeholder="请输入员工姓名"
  22. clearable
  23. size="small"
  24. @keyup.enter.native="handleQuery"
  25. />
  26. </el-form-item>
  27. <el-form-item label="主叫" prop="callerPhone">
  28. <el-input
  29. style="width: 220px"
  30. v-model="queryParams.callerPhone"
  31. placeholder="请输入主叫"
  32. clearable
  33. size="small"
  34. @keyup.enter.native="handleQuery"
  35. />
  36. </el-form-item>
  37. <el-form-item label="被叫" prop="calleePhone">
  38. <el-input
  39. style="width: 220px"
  40. v-model="queryParams.calleePhone"
  41. placeholder="请输入被叫"
  42. clearable
  43. size="small"
  44. @keyup.enter.native="handleQuery"
  45. />
  46. </el-form-item>
  47. <el-form-item label="状态" prop="status">
  48. <el-select v-model="queryParams.status" placeholder="请选择" clearable size="small">
  49. <el-option
  50. v-for="dict in statusOptions"
  51. :key="dict.dictValue"
  52. :label="dict.dictLabel"
  53. :value="dict.dictValue"
  54. />
  55. </el-select>
  56. </el-form-item>
  57. <el-form-item label="来源渠道" prop="source">
  58. <el-select v-model="queryParams.source" placeholder="请选择" clearable size="small">
  59. <el-option
  60. v-for="dict in sourceOptions"
  61. :key="dict.dictValue"
  62. :label="dict.dictLabel"
  63. :value="dict.dictValue"
  64. />
  65. </el-select>
  66. </el-form-item>
  67. <el-form-item label="时长" prop="times">
  68. <el-select v-model="queryParams.times" placeholder="请选择" clearable size="small">
  69. <el-option
  70. v-for="dict in timesOptions"
  71. :key="dict.dictValue"
  72. :label="dict.dictLabel"
  73. :value="dict.dictValue"
  74. />
  75. </el-select>
  76. </el-form-item>
  77. <el-form-item label="开始时间" prop="startTime">
  78. <el-date-picker v-model="dateRange" size="small" style="width: 220px" value-format="yyyy-MM-dd" type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
  79. </el-form-item>
  80. <el-form-item label="客户创建时间" prop="createTime">
  81. <el-date-picker
  82. style="width:205.4px"
  83. clearable size="small"
  84. v-model="createTimeRange"
  85. type="daterange"
  86. value-format="yyyy-MM-dd"
  87. start-placeholder="开始日期"
  88. end-placeholder="结束日期">
  89. </el-date-picker>
  90. </el-form-item>
  91. <el-form-item>
  92. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  93. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  94. </el-form-item>
  95. </el-form>
  96. <el-row :gutter="10" class="mb8">
  97. <el-col :span="1.5">
  98. <el-button
  99. type="warning"
  100. icon="el-icon-download"
  101. size="mini"
  102. @click="handleExport"
  103. :disabled="!isFilterComplete"
  104. v-hasPermi="['company:companyVoiceLogs:export']"
  105. >导出</el-button>
  106. </el-col>
  107. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  108. </el-row>
  109. <el-table height="500" border v-loading="loading" :data="companyVoiceLogsList" @selection-change="handleSelectionChange">
  110. <el-table-column type="selection" width="55" align="center" />
  111. <el-table-column label="ID" align="center" prop="voiceId" />
  112. <el-table-column label="公司名" align="center" prop="companyName" />
  113. <el-table-column label="员工姓名" align="center" prop="userNickName" />
  114. <el-table-column label="客户id" align="center" prop="customerId" v-if="false"/>
  115. <el-table-column label="客户名称" align="center" prop="customerName" :show-overflow-tooltip="true">
  116. <template slot-scope="scope">
  117. <el-link @click="handleShow(scope.row)" type="primary" v-hasPermi="['crm:customer:query']" >{{scope.row.customerName}}</el-link>
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="录制地址" align="center" show-overflow-tooltip prop="voiceUrl" width="350">
  121. <template slot-scope="scope">
  122. <audio v-if="scope.row.voiceUrl!=null" controls :src="scope.row.voiceUrl"></audio>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="开始时间" align="center" prop="startTime" width="100">
  126. <template slot-scope="scope">
  127. <span>{{ parseTime(scope.row.startTime) }}</span>
  128. </template>
  129. </el-table-column>
  130. <el-table-column label="结束时间" align="center" prop="finishTime" width="100">
  131. <template slot-scope="scope">
  132. <span>{{ parseTime(scope.row.finishTime) }}</span>
  133. </template>
  134. </el-table-column>
  135. <el-table-column label="主叫" align="center" prop="callerPhone" />
  136. <el-table-column label="被叫" align="center" prop="calleePhone" />
  137. <el-table-column label="时长" align="center" prop="times" width="180">
  138. <template slot-scope="scope">
  139. <span v-if="scope.row.voiceUrl!=null">{{ formatTime(scope.row.times)}} </span>
  140. </template>
  141. </el-table-column>
  142. <el-table-column label="计费时长(分)" align="center" prop="billingTime" width="180">
  143. </el-table-column>
  144. <el-table-column label="主叫显示号" align="center" prop="displayCallerNumber" width="110"/>
  145. <el-table-column label="被叫显示号" align="center" prop="displayCalleeNumber" width="110"/>
  146. <el-table-column label="状态" align="center" prop="status" >
  147. <template slot-scope="scope">
  148. <el-tag prop="status" v-for="(item, index) in statusOptions" v-if="scope.row.status==item.dictValue">{{item.dictLabel}}</el-tag>
  149. </template>
  150. </el-table-column>
  151. <el-table-column label="备注" align="center" prop="remark" width="120" />
  152. <el-table-column label="操作" fixed="right" align="center" prop="查看" >
  153. <template slot-scope="scope">
  154. <el-link v-if="scope.row.voiceUrl!=null" :href="scope.row.voiceUrl" target="_blank" >下载录音</el-link>
  155. </template>
  156. </el-table-column>
  157. </el-table>
  158. <pagination
  159. v-show="total>0"
  160. :total="total"
  161. :page.sync="queryParams.pageNum"
  162. :limit.sync="queryParams.pageSize"
  163. @pagination="getList"
  164. />
  165. <el-drawer
  166. size="75%"
  167. :title="show.title" :visible.sync="show.open"
  168. >
  169. <customer-details ref="customerDetails" />
  170. </el-drawer>
  171. </div>
  172. </template>
  173. <script>
  174. import { listCompanyVoiceLogs, getCompanyVoiceLogs, delCompanyVoiceLogs, addCompanyVoiceLogs, updateCompanyVoiceLogs, exportCompanyVoiceLogs } from "@/api/company/companyVoiceLogs";
  175. import { getCompanyList } from "@/api/company/company";
  176. import customerDetails from "@/views/crm/components/customerDetails.vue";
  177. import { treeselect } from "@/api/company/companyDept";
  178. import Treeselect from "@riophae/vue-treeselect";
  179. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  180. export default {
  181. name: "CompanyVoiceLogs",
  182. components: { Treeselect, customerDetails },
  183. watch: {
  184. // 监听deptId
  185. 'deptId': 'currDeptChange'
  186. },
  187. data() {
  188. return {
  189. timesOptions:[],
  190. statusOptions:[],
  191. companys:[],
  192. deptOptions:[],
  193. show:{
  194. title:"客户详情",
  195. open:false,
  196. },
  197. // 遮罩层
  198. loading: true,
  199. // 选中数组
  200. ids: [],
  201. // 非单个禁用
  202. single: true,
  203. // 非多个禁用
  204. multiple: true,
  205. isFilterComplete: false,
  206. // 显示搜索条件
  207. showSearch: true,
  208. // 总条数
  209. total: 0,
  210. // 通话记录表格数据
  211. companyVoiceLogsList: [],
  212. // 弹出层标题
  213. title: "",
  214. dateRange: [],
  215. createTimeRange:[],
  216. sourceOptions:[],
  217. // 是否显示弹出层
  218. open: false,
  219. // 查询参数
  220. queryParams: {
  221. pageNum: 1,
  222. pageSize: 10,
  223. companyId: null,
  224. voiceTitle: null,
  225. voiceUrl: null,
  226. startTime: null,
  227. endTime: null,
  228. voiceType: null,
  229. callerPhone: null,
  230. calleePhone: null,
  231. times: null,
  232. moeny: null,
  233. displayCallerNumber: null,
  234. displayCalleeNumber: null,
  235. deptId:null,
  236. },
  237. // 表单参数
  238. form: {},
  239. // 表单校验
  240. rules: {
  241. }
  242. };
  243. },
  244. created() {
  245. this.getDicts("crm_customer_source").then((response) => {
  246. this.sourceOptions = response.data;
  247. });
  248. this.getDicts("company_voice_logs_status").then((response) => {
  249. this.statusOptions = response.data;
  250. });
  251. this.getDicts("company_voice_logs_times").then((response) => {
  252. this.timesOptions = response.data;
  253. });
  254. getCompanyList().then(response => {
  255. this.companys = response.data;
  256. if(this.companys!=null&&this.companys.length>0){
  257. this.companyId=this.companys[0].companyId;
  258. this.getTreeselect();
  259. }
  260. });
  261. this.getList();
  262. },
  263. methods: {
  264. handleShow(row){
  265. var that=this;
  266. that.show.open=true;
  267. setTimeout(() => {
  268. that.$refs.customerDetails.getDetails(row.customerId);
  269. }, 200);
  270. },
  271. formatTime(value) {
  272. const hours = Math.floor(value / 3600);
  273. const minutes = Math.floor((value % 3600) / 60);
  274. const seconds = value % 60;
  275. if(hours == 0 && minutes == 0 ){
  276. return `${seconds}秒`;
  277. }else if(hours == 0 && minutes != 0 ){
  278. return `${minutes}分钟${seconds}秒`;
  279. }else{
  280. return `${hours}小时${minutes}分钟${seconds}秒`;
  281. }
  282. },
  283. /** 查询通话记录列表 */
  284. getList() {
  285. this.loading = true;
  286. if(this.createTimeRange!=null&&this.createTimeRange.length==2){
  287. this.queryParams.createTimeRange=this.createTimeRange[0]+"--"+this.createTimeRange[1]
  288. }
  289. else{
  290. this.queryParams.createTimeRange=null;
  291. }
  292. if(this.dateRange!=null&&this.dateRange.length==2){
  293. this.queryParams.dateRange=this.dateRange[0]+"--"+this.dateRange[1]
  294. }
  295. else{
  296. this.queryParams.dateRangee=null;
  297. }
  298. listCompanyVoiceLogs(this.queryParams).then(response => {
  299. this.companyVoiceLogsList = response.rows;
  300. this.total = response.total;
  301. this.loading = false;
  302. });
  303. },
  304. // 取消按钮
  305. cancel() {
  306. this.open = false;
  307. this.reset();
  308. },
  309. // 表单重置
  310. reset() {
  311. this.form = {
  312. voiceId: null,
  313. companyId: null,
  314. voiceTitle: null,
  315. voiceUrl: null,
  316. startTime: null,
  317. endTime: null,
  318. voiceType: null,
  319. remark: null,
  320. callerPhone: null,
  321. calleePhone: null,
  322. times: null,
  323. moeny: null,
  324. displayCallerNumber: null,
  325. displayCalleeNumber: null
  326. };
  327. this.resetForm("form");
  328. this.dateRange=[];
  329. },
  330. /** 搜索按钮操作 */
  331. handleQuery() {
  332. this.queryParams.pageNum = 1;
  333. this.isFilterComplete = true;
  334. this.getList();
  335. },
  336. /** 重置按钮操作 */
  337. resetQuery() {
  338. this.resetForm("queryForm");
  339. this.isFilterComplete = false;
  340. this.handleQuery();
  341. },
  342. // 多选框选中数据
  343. handleSelectionChange(selection) {
  344. this.ids = selection.map(item => item.voiceId)
  345. this.single = selection.length!==1
  346. this.multiple = !selection.length
  347. },
  348. /** 新增按钮操作 */
  349. handleAdd() {
  350. this.reset();
  351. this.open = true;
  352. this.title = "添加通话记录";
  353. },
  354. /** 修改按钮操作 */
  355. handleUpdate(row) {
  356. this.reset();
  357. const voiceId = row.voiceId || this.ids
  358. getCompanyVoiceLogs(voiceId).then(response => {
  359. this.form = response.data;
  360. this.open = true;
  361. this.title = "修改通话记录";
  362. });
  363. },
  364. /** 提交按钮 */
  365. submitForm() {
  366. this.$refs["form"].validate(valid => {
  367. if (valid) {
  368. if (this.form.voiceId != null) {
  369. updateCompanyVoiceLogs(this.form).then(response => {
  370. if (response.code === 200) {
  371. this.msgSuccess("修改成功");
  372. this.open = false;
  373. this.getList();
  374. }
  375. });
  376. } else {
  377. addCompanyVoiceLogs(this.form).then(response => {
  378. if (response.code === 200) {
  379. this.msgSuccess("新增成功");
  380. this.open = false;
  381. this.getList();
  382. }
  383. });
  384. }
  385. }
  386. });
  387. },
  388. /** 删除按钮操作 */
  389. handleDelete(row) {
  390. const voiceIds = row.voiceId || this.ids;
  391. this.$confirm('是否确认删除通话记录编号为"' + voiceIds + '"的数据项?', "警告", {
  392. confirmButtonText: "确定",
  393. cancelButtonText: "取消",
  394. type: "warning"
  395. }).then(function() {
  396. return delCompanyVoiceLogs(voiceIds);
  397. }).then(() => {
  398. this.getList();
  399. this.msgSuccess("删除成功");
  400. }).catch(function() {});
  401. },
  402. /** 导出按钮操作 */
  403. handleExport() {
  404. const queryParams = this.queryParams;
  405. this.$confirm('是否确认导出所筛选通话记录数据项?', "警告", {
  406. confirmButtonText: "确定",
  407. cancelButtonText: "取消",
  408. type: "warning"
  409. }).then(function() {
  410. return exportCompanyVoiceLogs(queryParams);
  411. }).then(response => {
  412. this.download(response.msg);
  413. }).catch(function() {});
  414. },
  415. /** 查询部门下拉树结构 */
  416. getTreeselect() {
  417. var that=this;
  418. var param={companyId:this.companyId}
  419. treeselect(param).then((response) => {
  420. this.deptOptions = response.data;
  421. console.log(this.deptOptions)
  422. if(response.data!=null&&response.data.length>0){
  423. //this.queryParams.deptId=response.data[0].id;
  424. }
  425. });
  426. },
  427. companyChange(val){
  428. console.log(val);
  429. this.companyId=val;
  430. this.getTreeselect();
  431. },
  432. currDeptChange(val){
  433. console.log(val)
  434. this.queryParams.deptId=val;
  435. this.getList();
  436. },
  437. }
  438. };
  439. </script>