format.vue 7.9 KB

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