Authored by 王涛

文档管理前端以及文档

  1 +文档管理组件
  2 +1、预览模式 浏览器参数docId(不展示左侧树)
  1 +表格组件,组件参数:
  2 +// 展示分页
  3 +showPage: {
  4 + type: Boolean,
  5 + default: true
  6 +},
  7 +showBorder: {
  8 + type: Boolean,
  9 + default: true
  10 +},
  11 +// 高度
  12 +height: {
  13 + type: Number,
  14 + default: window.innerHeight
  15 +},
  16 +// 展示下标
  17 +showIndex: {
  18 + type: Boolean,
  19 + default: true
  20 +},
  21 +indexLabel: {
  22 + type: String,
  23 + default: '序号'
  24 +},
  25 +currentPage: {
  26 + type: Number,
  27 + default: 1
  28 +},
  29 +// 分页页码设置
  30 +pageSizes: {
  31 + type: Array,
  32 + default: [50,100, 200, 300, 400]
  33 +},
  34 +// 默认展示
  35 +pageSize: {
  36 + type: Number,
  37 + default: 100
  38 +},
  39 +// 总数
  40 +total: {
  41 + type: Number,
  42 + default: 0
  43 +},
  44 +// 展示组件
  45 +layout: {
  46 + type: String,
  47 + default: "total, sizes, prev, pager, next, jumper"
  48 +},
  49 +// 列
  50 +columns: {
  51 + type: Array,
  52 + default: []
  53 +},
  54 +// 数据
  55 +dataList: {
  56 + type: Array,
  57 + default: []
  58 +},
  59 +// 加载
  60 +loading:{
  61 + type: Boolean,
  62 + default: false
  63 +},
  64 +--------------------------------------------------------------------
  65 +columns参数说明:
  66 +// 单元绑定数据key
  67 +prop: 'fileName',
  68 +// 表头展示名称
  69 +label: '文档名称',
  70 +sortable:true,
  71 +// 对其方式 left center right
  72 +align:'left',
  73 +click:function (row) {
  74 + // 单元格点击出发的函数 row,当前行的数据
  75 +},
  76 +render:function (row){
  77 + // 表格个性化展示,返回html
  78 + return html;
  79 +}
@@ -6,9 +6,10 @@ @@ -6,9 +6,10 @@
6 <div style="text-align: left;padding-left: 10px;padding-top: 3px;font-weight: bold"> 6 <div style="text-align: left;padding-left: 10px;padding-top: 3px;font-weight: bold">
7 <el-link type="info" :underline="false"><i class="iconfont icon-ziliaoku"></i> 文档管理</el-link> 7 <el-link type="info" :underline="false"><i class="iconfont icon-ziliaoku"></i> 文档管理</el-link>
8 </div> 8 </div>
  9 + <!--:default-expanded-keys="[currentNodeData.id]"-->
9 <el-tree ref="tree" style="padding:6px;" :props="props" :data="treeData" node-key="id" 10 <el-tree ref="tree" style="padding:6px;" :props="props" :data="treeData" node-key="id"
10 :expand-on-click-node="false" :expand-on-click-node="true" 11 :expand-on-click-node="false" :expand-on-click-node="true"
11 - :default-expanded-keys="[defaultKeys]" > 12 + >
12 <template #default="{ node, data }"> 13 <template #default="{ node, data }">
13 <div style="display: flex;flex-direction: row;width: 100%;"> 14 <div style="display: flex;flex-direction: row;width: 100%;">
14 <div style="width: calc(100% - 85px);max-width: calc(100% - 85px);overflow: hidden;text-overflow: ellipsis;text-align: left;" @click="nodeClick(node, data)" :title="node.label"> 15 <div style="width: calc(100% - 85px);max-width: calc(100% - 85px);overflow: hidden;text-overflow: ellipsis;text-align: left;" @click="nodeClick(node, data)" :title="node.label">
@@ -35,11 +36,11 @@ @@ -35,11 +36,11 @@
35 <el-input v-model="keyWord" placeholder="请输入关键字" :size="$global.elementSize" 36 <el-input v-model="keyWord" placeholder="请输入关键字" :size="$global.elementSize"
36 style="width: 220px;margin-right:10px" clearable/> 37 style="width: 220px;margin-right:10px" clearable/>
37 <el-button icon="el-icon-search" :size="$global.elementSize" @click="searchFile">搜索</el-button> 38 <el-button icon="el-icon-search" :size="$global.elementSize" @click="searchFile">搜索</el-button>
38 - <el-button :size="$global.elementSize" @click="showUserDialog(true)"> 39 + <el-button :size="$global.elementSize" @click="showUserDialog(true)" v-if="!isView">
39 <i class="iconfont icon-icon--quanxian"></i> 40 <i class="iconfont icon-icon--quanxian"></i>
40 授权 41 授权
41 </el-button> 42 </el-button>
42 - <el-button :size="$global.elementSize" @click="uploadFile"> 43 + <el-button :size="$global.elementSize" @click="downloadFile">
43 <i class="iconfont icon-icon--download"></i> 44 <i class="iconfont icon-icon--download"></i>
44 下载 45 下载
45 </el-button> 46 </el-button>
@@ -47,6 +48,10 @@ @@ -47,6 +48,10 @@
47 <i class="iconfont icon-icon--shangchuan"></i> 48 <i class="iconfont icon-icon--shangchuan"></i>
48 上传 49 上传
49 </el-button> 50 </el-button>
  51 + <el-button type="danger" :size="$global.elementSize" @click="deleteDocument('','file')">
  52 + <i class="iconfont icon-shanchuwenjianjia"></i>
  53 + 删除
  54 + </el-button>
50 </div> 55 </div>
51 <div style="text-align: right;width: 150px"> 56 <div style="text-align: right;width: 150px">
52 <el-button-group> 57 <el-button-group>
@@ -130,5 +135,7 @@ @@ -130,5 +135,7 @@
130 <cm-userright :showDialogVisible="showUserDialogVisible" :users="userFileRight.usernames" @callback="selectUser" 135 <cm-userright :showDialogVisible="showUserDialogVisible" :users="userFileRight.usernames" @callback="selectUser"
131 @hideDialog="showUserDialog"></cm-userright> 136 @hideDialog="showUserDialog"></cm-userright>
132 137
133 - <cm-upload :showDialogVisible="showUploadDialogVisible" @callback="uploadCallBack" @hideDialog="showUploadFile(false)"></cm-upload> 138 + <cm-upload :showDialogVisible="showUploadDialogVisible" @callback="uploadCallBack" @hideDialog="showUploadFile"
  139 + :type="currentNodeData.docType" :docNo="currentNodeData.docNo"
  140 + :category="currentNodeData.id"></cm-upload>
134 </div> 141 </div>
@@ -5,7 +5,25 @@ export default { @@ -5,7 +5,25 @@ export default {
5 name: 'DocumentIndex', 5 name: 'DocumentIndex',
6 template: '', 6 template: '',
7 components: {}, 7 components: {},
8 - props: {}, 8 + props: {
  9 + // 展示文档类型,默认展示类型
  10 + types: {
  11 + type: Array,
  12 + default: ['fxbg', 'gf', 'gzgl', 'jkjc', 'lxwh', 'pzgl', '', 'rcxj']
  13 + },
  14 + // 是否是预览模式
  15 + // 预览模式不展示授权按钮
  16 + isView: {
  17 + type: Boolean,
  18 + default: false
  19 + },
  20 + // 文件类型id(展示该类型下的文件信息)
  21 + // 是否是预览模式 == true,viewDocId,必须传入
  22 + viewTypeId: {
  23 + type: String,
  24 + default: ''
  25 + }
  26 + },
9 data() { 27 data() {
10 return { 28 return {
11 props: { 29 props: {
@@ -23,10 +41,9 @@ export default { @@ -23,10 +41,9 @@ export default {
23 } 41 }
24 } 42 }
25 }, 43 },
26 - setup() { 44 + setup(props, {attrs, slots, emit}) {
27 const {proxy} = Vue.getCurrentInstance(); 45 const {proxy} = Vue.getCurrentInstance();
28 let height = Vue.ref(window.innerHeight - 20); 46 let height = Vue.ref(window.innerHeight - 20);
29 - let defaultKeys = Vue.ref('');  
30 let iconclass = { 47 let iconclass = {
31 'folder': 'icon-wenjianjia', 48 'folder': 'icon-wenjianjia',
32 'docx': 'icon-word-full', 49 'docx': 'icon-word-full',
@@ -133,13 +150,14 @@ export default { @@ -133,13 +150,14 @@ export default {
133 // 加载列表 150 // 加载列表
134 proxy.$http.get("/inspection-report/doc/type/tree", {}, function (res) { 151 proxy.$http.get("/inspection-report/doc/type/tree", {}, function (res) {
135 if (res && res.data) { 152 if (res && res.data) {
  153 +
136 treeData.value = res.data; 154 treeData.value = res.data;
137 - currentNodeData.value = res.data[0];  
138 - let firstId = res.data[0].id;  
139 - defaultKeys.value = firstId; 155 +
  156 + let first = res.data[0];
  157 + currentNodeData.value = first;
140 158
141 // 加载所有 159 // 加载所有
142 - getPage(''); 160 + getPage('0');
143 } 161 }
144 }) 162 })
145 } 163 }
@@ -149,10 +167,10 @@ export default { @@ -149,10 +167,10 @@ export default {
149 let params = { 167 let params = {
150 id: id, 168 id: id,
151 name: keyWord.value, 169 name: keyWord.value,
152 - types:null 170 + types: props.types.join(',')
153 } 171 }
154 // 加载列表 172 // 加载列表
155 - proxy.$http.get(`/inspection-report/file/file/documentPage`, params, function (res) { 173 + proxy.$http.get(`/inspection-report/file/document/list`, params, function (res) {
156 if (res && res.data) { 174 if (res && res.data) {
157 dataList.value = res.data; 175 dataList.value = res.data;
158 } 176 }
@@ -179,34 +197,52 @@ export default { @@ -179,34 +197,52 @@ export default {
179 } 197 }
180 198
181 // 刷新 199 // 刷新
182 - let reload = () => { 200 + let reload = (loadTree) => {
183 // 属性tree 201 // 属性tree
184 setTimeout(function () { 202 setTimeout(function () {
185 let id = currentNodeData.value.id; 203 let id = currentNodeData.value.id;
186 getPage(id); 204 getPage(id);
187 205
188 - getTree(); 206 + if(loadTree && loadTree == true){
  207 + getTree();
  208 + }
  209 +
189 }, 1000) 210 }, 1000)
190 } 211 }
191 212
192 213
193 /** 214 /**
194 - * 删除文档 215 + * 将文档放入回收站
195 * @param id 文档id 216 * @param id 文档id
196 * @param type 文件夹或者文档 217 * @param type 文件夹或者文档
197 */ 218 */
198 let deleteDocument = (id, type) => { 219 let deleteDocument = (id, type) => {
  220 + let params = null;
  221 +
199 let msg = "您确认删除该文件?"; 222 let msg = "您确认删除该文件?";
200 if (type == 'folder') { 223 if (type == 'folder') {
201 msg = "您确认删除该文件以及文件下的文件?"; 224 msg = "您确认删除该文件以及文件下的文件?";
  225 + params = {id: id, type: type}
  226 + } else {
  227 + // 删除文件
  228 + let arr = getCheckedFile();
  229 + let info = [];
  230 + arr.map(function (v) {
  231 + info.push({
  232 + id:v.id,
  233 + type:v.type
  234 + })
  235 + })
  236 + params = info;
202 } 237 }
203 proxy.$global.confirm(msg, function () { 238 proxy.$global.confirm(msg, function () {
  239 + debugger
204 // ok 240 // ok
205 - proxy.$http.get(`/inspection-report/file/file/delete`, {id: id, type: type}, function (res) { 241 + proxy.$http.post(`/inspection-report/file/change`,params , function (res) {
206 if (res && res.code == 0) { 242 if (res && res.code == 0) {
207 proxy.$global.showMsg('删除成功!'); 243 proxy.$global.showMsg('删除成功!');
208 244
209 - reload(); 245 + reload(false);
210 } 246 }
211 }) 247 })
212 248
@@ -253,7 +289,7 @@ export default { @@ -253,7 +289,7 @@ export default {
253 }) 289 })
254 290
255 // 属性tree 291 // 属性tree
256 - reload(); 292 + reload(true);
257 showFolder(false); 293 showFolder(false);
258 } else { 294 } else {
259 console.log('error submit!!') 295 console.log('error submit!!')
@@ -267,44 +303,31 @@ export default { @@ -267,44 +303,31 @@ export default {
267 */ 303 */
268 let searchFile = () => { 304 let searchFile = () => {
269 getPage(''); 305 getPage('');
270 - // let id = currentNodeData.value.id;  
271 - // if (id) {  
272 - // getPage(id);  
273 - // } else {  
274 - // // 浏览器地址传文档id参数  
275 - // let docId = proxy.$global.getQueryVariable('docId');  
276 - // if (docId) {  
277 - // getPage(docId);  
278 - // } else {  
279 - // proxy.$global.showMsg('请选择文档类型!', 'warning');  
280 - // }  
281 - // }  
282 306
283 } 307 }
284 308
285 309
286 -  
287 // 用户授权 310 // 用户授权
288 let showUserDialogVisible = Vue.ref(false); 311 let showUserDialogVisible = Vue.ref(false);
289 let userFileRight = Vue.ref({}); // {roleIds: ["1"], usernames: ["admin"]} 312 let userFileRight = Vue.ref({}); // {roleIds: ["1"], usernames: ["admin"]}
290 let getCheckedFile = () => { 313 let getCheckedFile = () => {
291 - let arr = dataList.value.filter(function (v){  
292 - if(v.checked != undefined && v.checked == true){ 314 + let arr = dataList.value.filter(function (v) {
  315 + if (v.checked != undefined && v.checked == true) {
293 return v; 316 return v;
294 } 317 }
295 }) 318 })
296 319
297 - if(arr.length == 0){  
298 - proxy.$global.showMsg('请选择需要授权的文档!', 'warning'); 320 + if (arr.length == 0) {
  321 + proxy.$global.showMsg('请选择需要操作的文档!', 'warning');
299 return; 322 return;
300 } 323 }
301 324
302 - if(arr.length == 1){ 325 + if (arr.length == 1) {
303 // 查询文件的权限 326 // 查询文件的权限
304 - proxy.$http.get(`/inspection-report/doc/doc/auth/getGrant`, {docId:arr[0].id}, function (res) { 327 + proxy.$http.get(`/inspection-report/doc/doc/auth/getGrant`, {docId: arr[0].id}, function (res) {
305 if (res && res.code == 0) { 328 if (res && res.code == 0) {
306 let map = res.map; 329 let map = res.map;
307 - if(map){ 330 + if (map) {
308 userFileRight.value = res.map; 331 userFileRight.value = res.map;
309 } 332 }
310 } 333 }
@@ -317,9 +340,9 @@ export default { @@ -317,9 +340,9 @@ export default {
317 } 340 }
318 // 用户授权弹框 341 // 用户授权弹框
319 let showUserDialog = (flg) => { 342 let showUserDialog = (flg) => {
320 - if(flg){ 343 + if (flg) {
321 let arr = getCheckedFile(); 344 let arr = getCheckedFile();
322 - if(arr && arr.length > 0){ 345 + if (arr && arr.length > 0) {
323 showUserDialogVisible.value = flg; 346 showUserDialogVisible.value = flg;
324 } 347 }
325 } else { 348 } else {
@@ -338,16 +361,16 @@ export default { @@ -338,16 +361,16 @@ export default {
338 return v.code; 361 return v.code;
339 }); 362 });
340 363
341 - let docIds = getCheckedFile().map(function (v){ 364 + let docIds = getCheckedFile().map(function (v) {
342 return v.id; 365 return v.id;
343 }); 366 });
344 367
345 368
346 // 保存用户权限 369 // 保存用户权限
347 let params = { 370 let params = {
348 - docIds:docIds.join(','),  
349 - roleIds:roleCodes.join(','),  
350 - usernames:userIds.join(',') 371 + docIds: docIds.join(','),
  372 + roleIds: roleCodes.join(','),
  373 + usernames: userIds.join(',')
351 } 374 }
352 proxy.$http.get(`/inspection-report/doc/doc/auth/grant`, params, function (res) { 375 proxy.$http.get(`/inspection-report/doc/doc/auth/grant`, params, function (res) {
353 if (res && res.code == 0) { 376 if (res && res.code == 0) {
@@ -368,7 +391,34 @@ export default { @@ -368,7 +391,34 @@ export default {
368 let showUploadFile = (flg) => { 391 let showUploadFile = (flg) => {
369 showUploadDialogVisible.value = flg; 392 showUploadDialogVisible.value = flg;
370 } 393 }
371 - let uploadCallBack = () =>{ 394 + let uploadCallBack = ({document,fileInfo}) => {
  395 + reload(false);
  396 + console.log(111111111111,document,fileInfo);
  397 + }
  398 +
  399 + /**
  400 + * 文件下载
  401 + */
  402 + let downloadFile = () =>{
  403 + let arr = getCheckedFile();
  404 +
  405 + let info = [];
  406 + arr.map(function (v) {
  407 + // info.push({
  408 + // id:v.id,
  409 + // type:v.type
  410 + // })
  411 +
  412 + info.push(`${v.id}__${v.type}`);
  413 + })
  414 +
  415 + let params = {
  416 + info : info.join(","),
  417 + fileName:''
  418 + }
  419 +
  420 + proxy.$http.downloadFile('/inspection-report/file/download',params);
  421 +
372 422
373 } 423 }
374 424
@@ -377,21 +427,20 @@ export default { @@ -377,21 +427,20 @@ export default {
377 * 挂载完 427 * 挂载完
378 */ 428 */
379 Vue.onMounted(() => { 429 Vue.onMounted(() => {
380 - // 参数是否传文档id  
381 - let docId = proxy.$global.getQueryVariable('docId');  
382 - if (!docId) { 430 + // 预览模式 不展示左侧树
  431 + if (!props.isView) {
383 getTree(); 432 getTree();
384 } else { 433 } else {
385 layout.value = { 434 layout.value = {
386 left: 0, 435 left: 0,
387 right: 24 436 right: 24
388 } 437 }
389 - getPage(docId); 438 + getPage(props.viewTypeId);
390 } 439 }
391 }) 440 })
392 441
393 return { 442 return {
394 - /* viewEdit,*/ 443 + /* viewEdit,*/
395 iconclass, 444 iconclass,
396 layout, 445 layout,
397 height, 446 height,
@@ -400,7 +449,6 @@ export default { @@ -400,7 +449,6 @@ export default {
400 columns, 449 columns,
401 dataList, 450 dataList,
402 total, 451 total,
403 - defaultKeys,  
404 nodeClick, 452 nodeClick,
405 keyWord, 453 keyWord,
406 searchFile, 454 searchFile,
@@ -408,6 +456,9 @@ export default { @@ -408,6 +456,9 @@ export default {
408 activeBtn, 456 activeBtn,
409 activeModel, 457 activeModel,
410 deleteDocument, 458 deleteDocument,
  459 + uploadCallBack,
  460 +
  461 + downloadFile,
411 462
412 currentNodeData, 463 currentNodeData,
413 docForm, 464 docForm,
@@ -18,9 +18,9 @@ @@ -18,9 +18,9 @@
18 <i class="el-icon-chat-round"></i> 18 <i class="el-icon-chat-round"></i>
19 </el-tooltip> 19 </el-tooltip>
20 <template #tip> 20 <template #tip>
21 -<!-- <div class="el-upload__tip">-->  
22 -<!-- 文件命名规范建议:以文档编号+"-" 开头,如:3101-基本信息.xls-->  
23 -<!-- </div>--> 21 + <div class="el-upload__tip" v-if="tips != null && tips != ''">
  22 + {{tips}}
  23 + </div>
24 </template> 24 </template>
25 </el-upload> 25 </el-upload>
26 </template> 26 </template>
@@ -18,6 +18,25 @@ export default { @@ -18,6 +18,25 @@ export default {
18 type: String, 18 type: String,
19 default: '' 19 default: ''
20 }, 20 },
  21 + // 文件分类
  22 + type: {
  23 + type: String,
  24 + default: ''
  25 + },
  26 + // 父级Id
  27 + category: {
  28 + type: String,
  29 + default: ''
  30 + },
  31 + // 文档编号
  32 + docNo: {
  33 + type: String,
  34 + default: ''
  35 + },
  36 + tips: {
  37 + type: String,
  38 + default: ''
  39 + },
21 accept: { 40 accept: {
22 type: String, 41 type: String,
23 default: [".3gpp", 42 default: [".3gpp",
@@ -85,8 +104,22 @@ export default { @@ -85,8 +104,22 @@ export default {
85 emit('hideDialog', false); 104 emit('hideDialog', false);
86 } 105 }
87 let getFile = (param) =>{ 106 let getFile = (param) =>{
88 - console.log(param)  
89 let fileObj = param.file 107 let fileObj = param.file
  108 + let params = {
  109 + file:fileObj,
  110 + type:props.type,
  111 + category:props.category,
  112 + docNo:props.docNo
  113 + }
  114 + // 上传文件
  115 + proxy.$http.uploadFile("/inspection-report/file/upload", params, function (res) {
  116 + if (res && res.code == 0) {
  117 + proxy.$global.showMsg(res.msg);
  118 + // 调用回调
  119 + emit('callback',res.object)
  120 + hidedialog();
  121 + }
  122 + })
90 } 123 }
91 124
92 // 上传按钮点击 125 // 上传按钮点击
1 -  
2 let http = { 1 let http = {
3 - proxy: null,  
4 - isJson: function(obj) {  
5 - var isjson = typeof(obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() ==  
6 - "[object object]" &&  
7 - !obj.length;  
8 - return isjson;  
9 - },  
10 - reqErr : function(status){  
11 - if(status && status == '401'){  
12 - // 登录超时,刷新当前页面===>跳转到登录页面 2 + proxy: null,
  3 + isJson: function (obj) {
  4 + var isjson = typeof (obj) == "object" && Object.prototype.toString.call(obj).toLowerCase() ==
  5 + "[object object]" &&
  6 + !obj.length;
  7 + return isjson;
  8 + },
  9 + reqErr: function (status) {
  10 + if (status && status == '401') {
  11 + // 登录超时,刷新当前页面===>跳转到登录页面
13 window.location.reload(); 12 window.location.reload();
14 - }  
15 - },  
16 - post: function(requestUrl, data, callback) {  
17 - if(http.proxy == null){  
18 - const { proxy } = Vue.getCurrentInstance()  
19 - http.proxy = proxy;  
20 - } 13 + }
  14 + },
  15 + post: function (requestUrl, data, callback) {
  16 + if (http.proxy == null) {
  17 + const {proxy} = Vue.getCurrentInstance()
  18 + http.proxy = proxy;
  19 + }
21 20
22 - const loading = http.proxy.$global.showLoading();  
23 - var access_token = 'access_token=' + http.getToken();  
24 - if (requestUrl.indexOf('?') == -1) {  
25 - requestUrl += '?' + access_token;  
26 - } else {  
27 - requestUrl += '&' + access_token;  
28 - }  
29 - $.ajax({  
30 - url: sessionStorage.getItem('domainName') + requestUrl,  
31 - method: "post",  
32 - processData: false,  
33 - contentType: "application/json;charset=UTF-8",  
34 - dataType: "JSON",  
35 - async: true,  
36 - data: JSON.stringify(data),  
37 - error: function(xhr, textStatus) {  
38 - loading.close();  
39 - console.log("==>",requestUrl, xhr, textStatus) 21 + const loading = http.proxy.$global.showLoading();
  22 + var access_token = 'access_token=' + http.getToken();
  23 + if (requestUrl.indexOf('?') == -1) {
  24 + requestUrl += '?' + access_token;
  25 + } else {
  26 + requestUrl += '&' + access_token;
  27 + }
  28 + $.ajax({
  29 + url: sessionStorage.getItem('domainName') + requestUrl,
  30 + method: "post",
  31 + processData: false,
  32 + contentType: "application/json;charset=UTF-8",
  33 + dataType: "JSON",
  34 + async: true,
  35 + data: JSON.stringify(data),
  36 + error: function (xhr, textStatus) {
  37 + loading.close();
  38 + console.log("==>", requestUrl, xhr, textStatus)
40 http.reqErr(textStatus.status); 39 http.reqErr(textStatus.status);
41 - },  
42 - success: function(data, textStatus, jqXHR) {  
43 - if (callback) {  
44 - callback(data);  
45 - }  
46 - loading.close()  
47 - //console.log("==>", requestUrl, jqXHR, textStatus) 40 + },
  41 + success: function (data, textStatus, jqXHR) {
  42 + if (callback) {
  43 + callback(data);
  44 + }
  45 + loading.close()
  46 + //console.log("==>", requestUrl, jqXHR, textStatus)
48 47
49 - }  
50 - }); 48 + }
  49 + });
51 50
52 - },  
53 - get: function(requestUrl, data, callback,errFunc) {  
54 - if(http.proxy == null){  
55 - const { proxy } = Vue.getCurrentInstance()  
56 - http.proxy = proxy;  
57 - }  
58 - const loading = http.proxy.$global.showLoading();  
59 - var access_token = 'access_token=' + http.getToken();  
60 - if (requestUrl.indexOf('?') == -1) {  
61 - requestUrl += '?' + access_token;  
62 - } else {  
63 - requestUrl += '&' + access_token;  
64 - }  
65 - $.ajax({  
66 - url: sessionStorage.getItem('domainName') + requestUrl,  
67 - method: "get",  
68 - headers: {  
69 - "Authorization": "Bearer " + http.getToken() + ""  
70 - },  
71 - data: data,  
72 - error: function(xhr, textStatus) {  
73 - loading.close();  
74 - console.log("==>",requestUrl, xhr, textStatus) 51 + },
  52 + get: function (requestUrl, data, callback, errFunc) {
  53 + if (http.proxy == null) {
  54 + const {proxy} = Vue.getCurrentInstance()
  55 + http.proxy = proxy;
  56 + }
  57 + const loading = http.proxy.$global.showLoading();
  58 + var access_token = 'access_token=' + http.getToken();
  59 + if (requestUrl.indexOf('?') == -1) {
  60 + requestUrl += '?' + access_token;
  61 + } else {
  62 + requestUrl += '&' + access_token;
  63 + }
  64 + $.ajax({
  65 + url: sessionStorage.getItem('domainName') + requestUrl,
  66 + method: "get",
  67 + headers: {
  68 + "Authorization": "Bearer " + http.getToken() + ""
  69 + },
  70 + data: data,
  71 + error: function (xhr, textStatus) {
  72 + loading.close();
  73 + console.log("==>", requestUrl, xhr, textStatus)
75 http.reqErr(textStatus.status); 74 http.reqErr(textStatus.status);
76 75
77 - if(errFunc){  
78 - errFunc();  
79 - } 76 + if (errFunc) {
  77 + errFunc();
  78 + }
  79 +
  80 + },
  81 + success: function (data, textStatus, jqXHR) {
  82 + if (callback) {
  83 + callback(data);
  84 + }
  85 + loading.close();
  86 + //console.log("==>", requestUrl, jqXHR, textStatus)
  87 + }
  88 + });
  89 + },
80 90
81 - },  
82 - success: function(data, textStatus, jqXHR) {  
83 - if (callback) {  
84 - callback(data);  
85 - }  
86 - loading.close();  
87 - //console.log("==>", requestUrl, jqXHR, textStatus)  
88 - }  
89 - });  
90 - }, 91 + uploadFile(requestUrl, parmas,callback) {
  92 + if (http.proxy == null) {
  93 + const {proxy} = Vue.getCurrentInstance()
  94 + http.proxy = proxy;
  95 + }
  96 + const loading = http.proxy.$global.showLoading();
  97 + var access_token = 'access_token=' + http.getToken();
  98 + if (requestUrl.indexOf('?') == -1) {
  99 + requestUrl += '?' + access_token;
  100 + } else {
  101 + requestUrl += '&' + access_token;
  102 + }
91 103
92 - downloadFile(fileName, content) {  
93 - var filename = fileName;  
94 - var a = document.createElement('a')  
95 - var blob = new Blob([content])  
96 - a.download = filename  
97 - a.href = URL.createObjectURL(blob)  
98 - a.click()  
99 - URL.revokeObjectURL(blob)  
100 - },  
101 - getToken() {  
102 - return localStorage.getItem('access_token');  
103 - }, 104 + var formData = new FormData();
  105 + (function (ps) {
  106 + Object.keys(ps).map(_ => formData.append(_, ps[_]) );
  107 + })(parmas);
104 108
105 - // showMsg(msg, type = 'success') {  
106 - // ElementPlus.ElMessage.success({  
107 - // message: msg,  
108 - // type: type,  
109 - // })  
110 - // }, 109 + $.ajax({
  110 + url: sessionStorage.getItem('domainName') + requestUrl,
  111 + type: 'POST',
  112 + processData: false,
  113 + mimeType: "multipart/form-data",
  114 + contentType: false,
  115 + async: false,
  116 + data: formData,
  117 + error: function (xhr, textStatus) {
  118 + loading.close();
  119 + console.log("==>", requestUrl, xhr, textStatus)
  120 + http.reqErr(textStatus.status);
  121 + },
  122 + success: function (data, textStatus, jqXHR) {
  123 + if (callback) {
  124 + let d = data;
  125 + try {
  126 + d = JSON.parse(data);
  127 + }catch (e) {
  128 + console.log(e);
  129 + }
  130 + callback(d);
  131 + }
  132 + loading.close()
  133 + }
  134 + });
  135 + },
111 136
112 - // showLoading(callback) {  
113 - // const loading = ElementPlus.ElLoading.service({  
114 - // lock: true,  
115 - // text: '加载中...',  
116 - // spinner: 'el-icon-loading',  
117 - // background: 'rgba(0, 0, 0, 0.7)',  
118 - // }); 137 + downloadFile(requestUrl, parmas) {
  138 + var access_token = 'access_token=' + http.getToken();
  139 + if (requestUrl.indexOf('?') == -1) {
  140 + requestUrl += '?' + access_token;
  141 + } else {
  142 + requestUrl += '&' + access_token;
  143 + }
  144 + let formart = function (ps) {
  145 + const keys = Object.keys(ps).map(_ => `${_}=${ps[_]}`).join('&');
  146 + return `${keys}`;
  147 + }
  148 + let p = formart(parmas);
  149 + debugger
  150 + window.open(sessionStorage.getItem('domainName') + requestUrl + "&" + p);
119 151
120 - // if (callback) {  
121 - // callback(loading);  
122 - // }  
123 - // return loading;  
124 - // } 152 + },
  153 + getToken() {
  154 + return localStorage.getItem('access_token');
  155 + },
125 } 156 }
126 157
127 export default http 158 export default http