Commit 52588906 authored by xinzhedeai's avatar xinzhedeai

公共方法

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