format.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <view class="format">
  3. <view v-if="pagetype==0">
  4. <view class="box mb20">
  5. <view class="tit">文档示例图:</view>
  6. <image :src="example" class="examimg" mode="widthFix"></image>
  7. <view class="rebtn mt20" style="height: 80rpx;" @click="getDownFn">下载模板示例</view>
  8. </view>
  9. <view class="box mb20">
  10. <view class="tit">具体格式说明</view>
  11. <view class="txt"><text class="cir"></text>仅支持文件后缀为【.xlsx】和【.xls】</view>
  12. <view class="txt"><text class="cir"></text>一个文件只包含一个sheet页,请删除其他sheet (也不可隐藏)</view>
  13. <view class="txt"><text class="cir"></text>表中不支持多列姓名,只支持一列姓名</view>
  14. <view class="txt"><text class="cir"></text>姓名在第一列</view>
  15. <view class="txt"><text class="cir"></text>一种信息占一列</view>
  16. <view class="txt"><text class="cir"></text>不支持合并单元格</view>
  17. <view class="txt"><text class="cir"></text>不得使用筛选、冻结、公式、宏等功能</view>
  18. <!-- <image :src="example" class="examimg" mode="widthFix"></image>
  19. <view class="ttxt">图例参考</view> -->
  20. </view>
  21. <view class="rebtn" @click="pagetype=1">下一步</view>
  22. <view class="txc f14 co6 fw5 mt12" @click="getKnow">我已知晓,不再提示</view>
  23. </view>
  24. <!-- 下一步 -->
  25. <view v-if="pagetype==1">
  26. <view class="box mb20" >
  27. <view class="tit">选取文件</view>
  28. <view class="txt"><text class="cir"></text>将文件发送至文件传输助手或好友</view>
  29. <view class="txt"><text class="cir"></text>点击下方按钮进行选取</view>
  30. </view>
  31. <view v-show="filelist.length<1">
  32. <lsj-upload
  33. ref="lsjUpload"
  34. childId="upload1"
  35. :width="width"
  36. :height="height"
  37. :option="option"
  38. :size="size"
  39. :count="count"
  40. :formats="formats"
  41. :debug="debug"
  42. :instantly="instantly"
  43. @change="change"
  44. @uploadEnd="onuploadEnd"
  45. >
  46. <view class="rebtn" :style="{width: width,height: height}">去微信聊天中选取</view>
  47. </lsj-upload>
  48. </view>
  49. <view class="rebtn btn1" v-if="filelist.length>0">去微信聊天中选取</view>
  50. <!-- 文件上传位置 -->
  51. <view class="excbox flext" v-for="(ite,idx) in filelist" :key='idx'>
  52. <view class="flext flex1 excl" @click="getDown(ite.path)">
  53. <image :src="excimg" class="limg"></image>
  54. {{ite.name}}
  55. </view>
  56. <view class="excr" @click.stop="getDelFj(ite.name,idx)">删除文件</view>
  57. </view>
  58. <view class="fbtn" v-if="filelist.length">
  59. <view class="fbtnr flexcc" @click="getFinsh">完成导入</view>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import config from '@/config'
  66. const baseUrl = config.baseUrl
  67. const clientid = config.Clientid
  68. import { getToken } from '@/utils/auth'
  69. // import tabSearch from "@/components/toptab/search.vue"
  70. export default {
  71. data(){
  72. return{
  73. example:require("@/mine/static/score/example.png"),
  74. pagetype:0,
  75. option: {
  76. // 上传服务器地址,需要替换为你的接口地址
  77. url: baseUrl+'/score/data/importData', // 该地址非真实路径,需替换为你项目自己的接口地址
  78. // 上传附件的key
  79. name: 'file',
  80. // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
  81. header: {
  82. // 示例参数可删除
  83. 'Authorization': 'Bearer ' + getToken(),
  84. "Clientid":clientid
  85. },
  86. // 根据你接口需求自定义body参数
  87. formData: {
  88. }
  89. },
  90. // 选择文件后是否立即自动上传,true=选择后立即上传
  91. instantly: false,
  92. // 必传宽高且宽高应与slot宽高保持一致
  93. width: '678rpx',
  94. height: '98rpx',
  95. // 限制允许上传的格式,空串=不限制,默认为空
  96. formats: 'xls,xlsx',
  97. // 文件上传大小限制
  98. size: 100,
  99. // 文件数量限制 默认10
  100. count: 1,
  101. // 文件回显列表
  102. files: new Map(),
  103. // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道
  104. wxFiles: [],
  105. // 是否打印日志
  106. debug: false,
  107. filelist:[],
  108. excimg: require("@/mine/static/score/exc.png"),
  109. downimg: require("@/mine/static/score/down.png"),
  110. tabIndex:0,
  111. scorknow:0,
  112. }
  113. },
  114. onLoad: function(e) {
  115. if(e.type&&e.type=='look'){
  116. var data = JSON.parse(uni.getStorageSync('filelist'))//取出缓存数据
  117. this.filelist=data.item
  118. this.files=data.files
  119. }
  120. var scorknow=this.$store.state.user.scorknow||0;
  121. this.scorknow=scorknow;
  122. if(scorknow==1||scorknow==3){
  123. this.pagetype=1
  124. }
  125. },
  126. methods:{
  127. onuploadEnd(item) {
  128. console.log(item,1)
  129. },
  130. onprogre(e){
  131. console.log(e,3)
  132. },
  133. change(files){
  134. var newarr=[...files.values()];
  135. this.files = files;
  136. this.filelist=JSON.parse(JSON.stringify(newarr))
  137. // console.log(this.filelist)
  138. },
  139. getFinsh(){
  140. // let pages = getCurrentPages(); //获取所有页面栈实例列表
  141. // let nowPage = pages[pages.length - 1]; //当前页页面实例
  142. // let prevPage = pages[pages.length - 2]; //上一页页面实例
  143. // prevPage.file = this.filelist; //修改上一页data里面的messageId
  144. // prevPage.files=this.files;
  145. var obj={
  146. file:this.filelist,
  147. files:this.files,
  148. }
  149. uni.$emit("refreshscorefile",obj)
  150. uni.navigateBack({
  151. delta: 1 //返回层数,2则上上页
  152. });
  153. },
  154. getKnow(){
  155. var s=this.scorknow;
  156. var a=1;
  157. if(s==2){a=3;}
  158. this.$store.dispatch('checkKnow', a).then(() => {
  159. this.pagetype=1
  160. }).catch(() => {
  161. })
  162. },
  163. onuploadEnd(item) {
  164. },
  165. getDelFj(name,idx){
  166. this.filelist.splice(idx,1)
  167. this.$refs['lsjUpload'].clear(name);
  168. var obj={
  169. file:this.filelist,
  170. files:new Map(),
  171. }
  172. uni.$emit("refreshscorefile",obj)
  173. },
  174. // 下载文件
  175. getDownFn(e){
  176. var aurl='/profile/upload/template/成绩导入.xls'
  177. uni.showLoading({
  178. title: '加载中'
  179. });
  180. var url=baseUrl+aurl;
  181. uni.downloadFile({
  182. url: url,//文件的下载路径
  183. success(result) {
  184. uni.hideLoading()
  185. var filePath = result.tempFilePath;
  186. uni.openDocument({
  187. filePath: filePath,
  188. showMenu: true,
  189. success: function (res) {
  190. }
  191. });
  192. },
  193. fail(res) {uni.hideLoading()}
  194. })
  195. },
  196. getDown(e){
  197. var filePath = e;
  198. uni.openDocument({
  199. filePath: filePath,
  200. showMenu: true,
  201. success: function (res) {
  202. }
  203. });
  204. },
  205. },
  206. }
  207. </script>
  208. <style lang="scss" scoped>
  209. .format{padding: 40rpx 36rpx;
  210. .box{width: 100%;background: #ffffff;padding:40rpx 26rpx 26rpx ;box-sizing: border-box;border-radius: 18rpx;
  211. .tit{font-size: 32rpx;font-weight: bold;color: #161616;}
  212. .txt{font-size: 30rpx;color: #161616;margin-top: 24rpx;display: flex;align-items: flex-start;
  213. .cir{width: 16rpx;height: 16rpx;background: #1f57e6;border-radius: 50%;margin-right: 24rpx;display:inline-block;flex: 0 0 auto;margin-top: 12rpx;}
  214. }
  215. .examimg{width: 540rpx;margin: 34rpx auto 0;}
  216. .ttxt{font-size: 28rpx;color: #AAAAAA;margin-top: 36rpx;text-align: center;}
  217. }
  218. .excbox{margin-top: 60rpx;background: #FFFFFF;
  219. border-radius: 18rpx;padding: 32rpx 40rpx;box-sizing: border-box;
  220. .excl{font-size: 30rpx;font-weight: 500;
  221. color: #161616;
  222. .limg{width: 36rpx;height: 38rpx;margin-right:36rpx ;flex: 0 0 auto;}
  223. }
  224. .excr{font-size: 30rpx;font-weight: 500;color: #FE5A0E;display: flex;align-items: center;flex: 0 0 auto;margin-left: 20rpx;
  225. }
  226. }
  227. }
  228. .fbtn{display: flex;align-items: center;position: fixed;left: 0;right: 0;bottom: 0;background-color: #f1f1f1;padding: 34rpx;
  229. .fbtnl{padding: 0 16rpx;flex: 0 0 auto;
  230. image{width: 42rpx;height: 42rpx;margin-bottom: 8rpx;}
  231. }
  232. .fbtnr{height: 98rpx;background: #1f57e6;border-radius: 48rpx;font-size: 34rpx;font-weight: 500;
  233. color: #FFFFFF;flex: 1;}
  234. }
  235. </style>