Commit 52588906 authored by xinzhedeai's avatar xinzhedeai

公共方法

parent d14c2194
......@@ -137,25 +137,19 @@ var http = {
},
responseType:'blob' //在请求中加上这一行,特别重要
}).then(res => {
// let response = res.data
// console.log('res.statusCode', response)
// if(response.statusCode >= 300){
// // alert('系统发生错误')
// return
// }
// resolve(res.data)
// 返回格式是文件流格式
// 在请求拿到文件流res以后,使用a标签下载
let fileData = res.data
let blob = new Blob([ fileData], { type: 'application/msword;charset=UTF-8' }/* , {
type: `application/vnd.openxmlformats-officedocument.wordprocessingml.document;charset=utf-8;`
} */)
var a = document.createElement('a');
document.body.appendChild(a);
a.style = 'display: none';
var url = window.URL.createObjectURL(blob);
a.href = url;
a.setAttribute('download', 'YH.docx')
a.setAttribute('download', 'YH-'+ getTargetDateYMD().replaceAll('-', '') +'.docx')
a.click();
a.remove();
window.URL.revokeObjectURL(url);
......
......@@ -65,7 +65,7 @@ function getTargetDateYM(dayLength, type) {
*
* @functionName: getPageName
* @Description: get page name from URL
* @author: Double
* @author: zjb
*
*/
function getPageName() {
......@@ -82,7 +82,7 @@ function getPageName() {
*
* @functionName: getOS
* @Description: get operating system
* @author: Double
* @author: zjb
*
*/
function getOS() {
......@@ -122,7 +122,7 @@ function getOS() {
*
* @functionName: getNavigator
* @Description: get navigator
* @author: Double
* @author: zjb
*
*/
function getNavigator() {
......@@ -152,7 +152,7 @@ function getNavigator() {
*
* @functionName: isPC
* @Description: 判断使用设备是否为PC
* @author: Double
* @author: zjb
*
*/
function isPC() {
......@@ -172,7 +172,7 @@ function isPC() {
*
* @functionName: getParameter
* @Description: get parameter from URL
* @author: Double
* @author: zjb
*
*/
function getParameter(name) {
......@@ -207,7 +207,7 @@ function getParameter(name) {
*
* @functionName: setParameter
* @Description: set parameter to URL
* @author: Double
* @author: zjb
*
*/
function setParameter() {
......@@ -230,7 +230,7 @@ function setParameter() {
*
* @functionName: trim
* @Description: 由于IE8不支持trim方法,此处自定义
* @author: Double
* @author: zjb
*
*/
String.prototype.trim = function() {
......@@ -240,7 +240,7 @@ String.prototype.trim = function() {
/**
* @functionName: setCookie
* @Description: set cookies
* @author: Double
* @author: zjb
*/
function setCookie(name, value, days) {
if(name === 'whMap'|| name === 'columnArr'){ // 页面搜索条件记录 更改存取方式
......@@ -266,7 +266,7 @@ function setCookie(name, value, days) {
*
* @functionName: getCookie
* @Description: get cookies
* @author: Double
* @author: zjb
*
*/
function getCookie(name) {
......@@ -284,7 +284,7 @@ function getCookie(name) {
*
* @functionName: jumpBack
* @Description: 从详情页跳回
* @author: Double
* @author: zjb
*
*/
function jumpBack(destination) {
......@@ -300,7 +300,7 @@ function jumpBack(destination) {
*
* @functionName: delCookie
* @Description: delete cookies
* @author: Double
* @author: zjb
*
*/
function delCookie(name) {
......@@ -315,7 +315,7 @@ function delCookie(name) {
*
* @functionName: serializeObject
* @Description: form序列化成object
* @author: Double
* @author: zjb
* @param: form
*/
var serializeObject = function() {
......@@ -341,7 +341,7 @@ var serializeObject = function() {
*
* @functionName: formatDate
* @Description: 格式化Date对象
* @author: Double
* @author: zjb
* @param: date, symbol-选填
*/
function formatDate() {
......@@ -367,7 +367,7 @@ function formatDate() {
*
* @functionName: formatTime
* @Description: 格式化Date对象的time
* @author: Double
* @author: zjb
* @param: date
*/
function formatTime() {
......@@ -403,7 +403,7 @@ function formatTime() {
*
* @functionName: objToStr
* @Description: 将JSON转换为String, 作为参数传进函数
* @author: Double
* @author: zjb
* @param: obj
*/
function objToStr(obj) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment