// 下载文件
function downfile(obj) {
var url = $(obj).attr("files");
//url = "http://10.19.5.48:8081/recordfiles/1201/20221101/I-1425524249_A15377668717_161816_5656.mp3";//测试使用,可以下载
var filename = $(obj).attr("download");
//http://localhost/whtoareaServicecs/Service.asmx/GetRecordFile?appKey=jSX82uMV7iB5&voiceId=ce29436d9306bb1368b87453d98a3a899cc3828d2a465e6d9224df6ace4c210d43511c7266edde57a520f88c58b7d2655d32d9711901b7df34e49eb11bb671263e6657087eb7c49f0300cf7edba0b1dd40df54c03a7ac9323df63ca4e729bcf9
var voiceId = $(obj).attr("voiceId");
var appKey = Config.appKey;
url = "http://10.19.5.41/whtoareaServicecs/Service.asmx/GetRecordFile?appKey=" + appKey + "&voiceId=" + voiceId;
//$.get(url);
//$.get("url", function (data) {
// alert("Data: " + data);
//});
if (!url) return
var link = document.createElement('a') //创建a标签
link.style.display = 'none' //使其隐藏
link.href = url //赋予文件下载地址
link.target = "_blank";
link.setAttribute('download', filename) //设置下载属性 以及文件名
document.body.appendChild(link) //a标签插至页面中
link.click() //强制触发a标签事件
document.body.removeChild(link);
}
#region 保密外呼录音列表
//string recordhf = "Select * From 双呼记录表 Where CASEID = '" + caseid + "' order by STARTTIME ";
string recordhf = "Select * From 双呼记录表 Where CASEID = '" + caseid + "' and DEPTID = '" + AreaOperation.LoginInfo().DEPTID + "' order by STARTTIME ";//获取操作人部门所属外呼录音记录
dt = DbHelperOra.QueryDT(recordhf);
htmls = "<table cellpadding=\"0\" cellspacing=\"0\" style=\"float:left;width:645px;margin-top:0px;\">";
if (dt != null && dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
if (string.IsNullOrEmpty(dt.Rows[i]["VOICEID"].ToString()))
{
continue;//暂未同步到录音文件是不显示当前记录
}
htmls += "<tr style='background-color:#e6f5ff;'>";
htmls += "<td class=\"td_o1\" style=\"width:85px;\">通话开始时间</td>";
htmls += "<td class=\"td_o1\" style=\"width:160px;background-color:#fff;\">" + dt.Rows[i]["STARTTIME"].ToString() + "</td>";
htmls += "<td class=\"td_o1\" style=\"width:85px;\">通话结束时间</td>";
htmls += "<td class=\"td_o1\" style=\"width:160px;background-color:#fff;\">" + dt.Rows[i]["ENDTIME"].ToString() + "</td>";
htmls += "<td class=\"td_o1\" style=\"width:45px; cursor: pointer;\"><a id=\"recordhf" + i + "\" files=\"" + dt.Rows[i]["VOICEID"] + "\" voiceId=\"" + dt.Rows[i]["VOICEID"] + "\" class=\"recordhf_download\" style=\"margin-left:10px; cursor:pointer;text-decoration:underline;text-align:center; \" target=\"_blank\" download=\"" + dt.Rows[i]["VOICEID"] + "\" onclick=\"downfile(this);\" >下载</a></td>";
htmls += "</tr>";
}
}
htmls += "</table>";
tdrecordhf.InnerHtml = htmls;
#endregion
![](https://img-blog.csdnimg.cn/a35f37982d99424183ceabb0ce51d94d.png)