53 lines
1.9 KiB
JavaScript
53 lines
1.9 KiB
JavaScript
const mCommon = {
|
|
unitList: [],
|
|
unionList: [],
|
|
async getUnionList() {
|
|
const {data} = await $.get("/platform/vi/common/unions")
|
|
data.forEach(v => {
|
|
v.text = v.unionname
|
|
v.value = v.id
|
|
})
|
|
data.unshift({text: "全部工会", value: null})
|
|
this.unionList = data
|
|
},
|
|
async getUnitList(unionId) {
|
|
const {data} = await $.get("/platform/vi/common/units", {unionId})
|
|
data.forEach(v => {
|
|
v.text = v.name
|
|
v.value = v.id
|
|
})
|
|
data.unshift({text: "全部单位", value: null})
|
|
this.unitList = data
|
|
},
|
|
previewFile(filepath, filename, fileList, index, fileId) {
|
|
|
|
const doctype = ['doc', 'docx', 'xls', 'xlsx'];
|
|
const pictype = ['jpg', 'png', 'gif', 'jpeg'];
|
|
let filetype = filepath.substring(filepath.lastIndexOf('.') + 1, filepath.length);
|
|
if (doctype.indexOf(filetype) > -1) {
|
|
const path = APP_DOMAIN + "/file/mange/preview?filepath=" + filepath + "&fileid=" + fileId
|
|
window.open(path);
|
|
} else if (pictype.indexOf(filetype) > -1) {
|
|
let ele = document.createElement("div");
|
|
fileList.forEach(v => {
|
|
let fp = v.filepath.substring(v.filepath.lastIndexOf('.') + 1, v.filepath.length);
|
|
if (pictype.indexOf(fp) > -1) {
|
|
const image = new Image();
|
|
const src = FILE_DOMAIN + v.filepath
|
|
image.src = src
|
|
image.alt = v.filename
|
|
ele.appendChild(image);
|
|
}
|
|
|
|
})
|
|
const viewer = new Viewer(ele, {
|
|
title: function (img, obj) {
|
|
return img.getAttribute("alt");
|
|
}
|
|
});
|
|
viewer.show();
|
|
} else {
|
|
alert('该文件不支持在手机端预览')
|
|
}
|
|
}
|
|
} |