ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
* 文件导出功能 ~~~ $json['type']='export'; //设置这个参数可使按钮变成下载链接 $json['submit_name'] = '下载表单';//按钮文字 $json['down_url'] = 'excel';//配置默认下载格式 //设置文件下载类型配合radio表单可设置下载类型和upfile上传标签 $opt[]=['name'=>'Excel表单','val'=>'xlsx']; $opt[]=['name'=>'txt文本','val'=>'txt']; $opt[]=['name'=>'空的Excel表格','val'=>'empty_excel']; $input[] = ['type'=>'radio','val'=>'xlsx','name'=>'文件导出类型','field'=>'file_type','opt'=>$opt,'limit'=>[1]]; $input[] = ['type'=>'upfile','name'=>'导入文件','field'=>'excel','limit_type'=>'all','limit_ext'=>['xlsx','txt'],'limit_up'=>51240,'img_path'=>'excel']; ~~~ ~~~ $json['classify'] = $obj; ~~~ *修改模板组件文件 ~~~ //提交按钮修改为 <view class="button" v-if="NETDATA.submit_off != 1"> <block v-if="NETDATA.type==undefined"> <button class="submit bg_black color_white" form-type="submit"> {{NETDATA.submit_name ? NETDATA.submit_name : '确定'}} </button> </block> <block v-if="NETDATA.type=='export' || NETDATA.type=='url'"> <a class="submit bg_black color_white t-center" :href="down_url">{{NETDATA.submit_name ? NETDATA.submit_name : '下载'}}</a> </block> </view> //计算属性 computed:{ down_url:{ get(){ let newtime = this.newtime = new Date().getTime().toString().substr(0,11); let sign = 'chuxuan'; this.NETDATA.url = Net.http_host + '/api/upload/down.php?sign='+sign+'&stamp='+newtime+'&type='; return this.NETDATA.url + this.NETDATA.down_url; }, set(newdata){ return newdata; } } }, //添加方法 methods: { //>切换下载类型 click_radio(e) { this.first = false; this.NETDATA.down_url=e.val; }, } //>提交逻辑处理 logic(array) { //>仅用于提交逻辑处理(格式: model/p.info:标识) let P = this.NETDATA.P.split(':'); let url = typeof this.url == 'object' ? [P[0]] : P[0]; let that = this; let data = array; data.P = P[1]; // 下载文件--START if (data.P == 'export') { Upload.Upload('upload/down', data).then(res => { console.log('文件下载'); }); return; } // END Net.Net(url, data).then(res => { if (!res.succeed) { return false; } uni.showToast({ title: res.msg, icon: 'success', success() { //>判断是否更新用户数据 if (that.update_user) { data = {}; data.cache = 1; Net.Net('admin/t.cache', data).then(res => { if (!res.succeed) { return false; } uni.setStorageSync('sbh_user', res.user); //>更新用户数据数组 that.Fun_box(); //>关闭浮动框 }); } else { that.Fun_box(); //>关闭浮动框 } } }); }); }, ~~~