myExportLog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <view class="myExportLog">
  3. <u-navbar :back-icon-color="'#fff'" :is-back="true" :border-bottom="true" :back-text="$t('common.Back')"
  4. :background="{background:'#1777FE'}" :back-text-style="{color:'#fff'}" :custom-back="back">
  5. <view class="search-wrap">
  6. <view>
  7. <view>
  8. <view style="display: inline-block;margin-left: 50%;transform: translateX(-146upx)">
  9. <u-icon name="play-left-fill" size="30" color="#fff" @click="yearChange('sub')"></u-icon>
  10. <!-- <text @click="show=true" style="color: #fff;font-size: 34upx;margin: 0 10upx;">{{params.year}}{{$i18n.locale=='zh'?'年':'year'}}</text>-->
  11. <text @click="show=true"
  12. style="color: #fff;font-size: 34upx;margin: 0 10upx;">{{params.year}}</text>
  13. <u-icon name="play-right-fill" size="30" color="#fff" @click="yearChange('add')"></u-icon>
  14. </view>
  15. </view>
  16. <u-popup v-model="show" mode="bottom" :mask-close-able="false">
  17. <view style="">
  18. <text style="margin: 30upx;color: #1890FF;float: left;"
  19. @click="show=false">{{$i18n.locale=='zh'?'取消':'cancel'}}</text>
  20. <text style="margin: 30upx;color: #1890FF;float: right;"
  21. @click="btn">{{$i18n.locale=='zh'?'确定':'sure'}}</text>
  22. <view style="clear: both;"></view>
  23. </view>
  24. <view style="height: 600upx">
  25. <picker-view :indicator-style="'height: 50upx'" :value="[yearList.indexOf(params.year)]"
  26. @change="bindChange" class="picker-view">
  27. <picker-view-column>
  28. <!-- <view class="item" v-for="(item,index) in yearList" :key="index">{{item}}{{$i18n.locale=='zh'?'年':'year'}}</view>-->
  29. <view class="item" v-for="(item,index) in yearList" :key="index">{{item}}</view>
  30. </picker-view-column>
  31. </picker-view>
  32. </view>
  33. </u-popup>
  34. </view>
  35. </view>
  36. </u-navbar>
  37. <view class="log">
  38. <view style="height: 100%;position: relative;">
  39. <scroll-view scroll-y="true" class="left" :style="{height:navHeight+'px'}">
  40. <view v-for="(fItem, fIndex) in 12" :key="fItem+fIndex" class="row"
  41. :class="[fIndex===isCheckMonth ?'on':'']" @tap="showMonth(fItem,fIndex)">
  42. <view class="text" style="text-algin:center;">
  43. <text v-if="$i18n.locale=='zh'">{{ fItem }}月</text>
  44. <text v-if="$i18n.locale=='en'">{{ monthSimplify(monthList[fIndex]) }}</text>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. <view class="right">
  49. <view class="box" v-if="isloading">
  50. <u-loading :show="true" size="40" type="primary" style="margin-top: 30upx;"></u-loading>
  51. </view>
  52. <view class="box" v-else-if="isNoData">
  53. <text class="text-NoData">{{ i18n('Nodataavailable') }}</text>
  54. </view>
  55. <scroll-view scroll-y v-else class="box list" :style="{height:navHeight+'px'}">
  56. <view class="content">
  57. <view v-for="(item,index) in dataList" class="oneLog">
  58. <view class="title">
  59. <text v-if="$i18n.locale=='zh'" class="text">第{{ item.backup2 }}期</text>
  60. <text v-if="$i18n.locale=='en'" class="text">No. {{ item.backup2 }}</text>
  61. </view>
  62. <view class="time">
  63. <text class="text">{{ dateFormat(item.time) }}</text>
  64. </view>
  65. <view class="download">
  66. <view class="btn" @click="download(item)">
  67. <text class="text">
  68. {{ i18n('resourceDetailsDownload') }}
  69. </text>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </scroll-view>
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import UNavbar from '@/components/uni-nav-bar/uni-nav-bar.vue'
  82. export default {
  83. name: "myExportLog",
  84. components: {
  85. UNavbar,
  86. },
  87. data() {
  88. return {
  89. title: '',
  90. dataList: [],
  91. params: {
  92. year: '',
  93. yearMap: '',
  94. month: '',
  95. language: this.$i18n.locale
  96. },
  97. isCheckMonth: '',
  98. isloading: false,
  99. isNoData: false,
  100. show: false,
  101. pH: 0, //窗口高度
  102. navHeight: 0, //元素的所需高度
  103. monthList: [
  104. 'January',
  105. 'February',
  106. 'March',
  107. 'April',
  108. 'May',
  109. 'June',
  110. 'July',
  111. 'August',
  112. 'September',
  113. 'October',
  114. 'November',
  115. 'December',
  116. ]
  117. }
  118. },
  119. computed: {
  120. yearList() {
  121. let arr = []
  122. for (let i = 1950; i <= 2050; i++) {
  123. arr.push(i)
  124. }
  125. return arr
  126. }
  127. },
  128. watch: {
  129. 'params.year'() {
  130. this.getByDate()
  131. },
  132. 'params.month'() {
  133. this.getByDate()
  134. },
  135. },
  136. onReady() {
  137. let that = this;
  138. uni.getSystemInfo({ //调用uni-app接口获取屏幕高度
  139. success(res) { //成功回调函数
  140. that._data.pH = res.windowHeight //windoHeight为窗口高度,主要使用的是这个
  141. let titleH = uni.createSelectorQuery().select(".left"); //想要获取高度的元素名(class/id)
  142. titleH.boundingClientRect(data => {
  143. let pH = that._data.pH;
  144. that._data.navHeight = pH - data.top //计算高度:元素高度=窗口高度-元素距离顶部的距离(data.top)
  145. }).exec()
  146. }
  147. })
  148. },
  149. onLoad(e) {
  150. let date = new Date()
  151. this.params.year = date.getFullYear()
  152. this.params.month = date.getMonth() + 1
  153. this.isCheckMonth = Number(this.params.month) - 1
  154. this.params.month = this.appendZero(this.params.month)
  155. },
  156. created() {
  157. this.init();
  158. },
  159. onShow() {
  160. this.token = uni.getStorageSync('Auth-Token') ? 'Bearer ' + uni.getStorageSync('Auth-Token') : '';
  161. this.userId = uni.getStorageSync('user') ? JSON.parse(uni.getStorageSync('user')).id : '';
  162. this.init();
  163. },
  164. methods: {
  165. dateFormat(data) {
  166. return data.replace(/-/g, '/')
  167. },
  168. init() {
  169. this.getByDate()
  170. },
  171. bindChange(e) {
  172. const val = e.detail.value
  173. this.params.yearMap = this.yearList[val[0]]
  174. },
  175. btn() {
  176. this.params.year = this.params.yearMap;
  177. this.show = false;
  178. },
  179. yearChange(type) {
  180. let temp = this.params.year;
  181. if (type === 'sub') {
  182. if (this.yearList.includes(temp - 1)) {
  183. this.params.year = this.params.yearMap = temp - 1
  184. }
  185. }
  186. if (type === 'add') {
  187. if (this.yearList.includes(temp + 1)) {
  188. this.params.year = this.params.yearMap = temp + 1
  189. }
  190. }
  191. },
  192. async getByDate() {
  193. this.isloading = true
  194. this.isNoData = false
  195. this.dataList = []
  196. this.$myRequest({
  197. url: '/op/fileDownloads/getByDate',
  198. data: this.params
  199. }).then(res => {
  200. if (res.data && Array.isArray(res.data) && res.data.length > 0) {
  201. this.dataList = res.data
  202. }
  203. }).catch(err => {
  204. console.log(err)
  205. }).finally(() => {
  206. this.isloading = false
  207. if (this.dataList && this.dataList.length === 0) {
  208. this.isNoData = true
  209. }
  210. });
  211. },
  212. showMonth(item, index) {
  213. this.isCheckMonth = index
  214. this.params.month = this.appendZero(item)
  215. this.getByDate()
  216. },
  217. appendZero(obj) {
  218. if (obj < 10) {
  219. return '0' + obj
  220. } else {
  221. return obj
  222. }
  223. },
  224. download(item) {
  225. let _this = this
  226. let url = item.fileUrl.replace(/(.docx)|(.doc)$/, '.pdf'); // 前端临时修改doc、docx为pdf
  227. uni.downloadFile({
  228. url: 'https://m.geidcp.com/api/file' + url, // TODO pub路径重复
  229. success: (data) => {
  230. if (data.statusCode === 200) {
  231. //文件保存到本地
  232. uni.saveFile({
  233. tempFilePath: data.tempFilePath,
  234. success: function(res) {
  235. let eg = _this.$i18n.locale == 'zh' ? '文件已保存:' :
  236. 'The file is saved:'
  237. uni.showToast({
  238. icon: 'none',
  239. mask: true,
  240. title: eg + res.savedFilePath, //保存路径
  241. duration: 3000,
  242. });
  243. setTimeout(() => {
  244. //打开文档查看
  245. uni.openDocument({
  246. filePath: res.savedFilePath,
  247. success: function(res) {
  248. // console.log('打开文档成功');
  249. }
  250. });
  251. }, 3000)
  252. }
  253. });
  254. } else {
  255. let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
  256. uni.showToast({
  257. icon: 'none',
  258. mask: true,
  259. title: eg,
  260. });
  261. }
  262. },
  263. fail: (err) => {
  264. let eg = _this.$i18n.locale == 'zh' ? '失败请重新下载' : 'Please download again if failed'
  265. uni.showToast({
  266. icon: 'none',
  267. mask: true,
  268. title: eg,
  269. });
  270. },
  271. });
  272. },
  273. back() {
  274. // #ifdef H5
  275. history.back()
  276. // #endif
  277. // #ifndef H5
  278. uni.navigateBack()
  279. // #endif
  280. },
  281. i18n(data) {
  282. return this.$t('common.' + data);
  283. },
  284. monthSimplify(data) {
  285. return data.slice(0, 3)
  286. }
  287. }
  288. }
  289. </script>
  290. <style scoped lang="scss">
  291. uni-page-body {
  292. padding-top: 0;
  293. }
  294. page {
  295. background: #fff;
  296. height: 100%;
  297. }
  298. .search-wrap {
  299. margin: 0 20rpx;
  300. flex: 1;
  301. color: black;
  302. }
  303. .picker-view {
  304. width: 750rpx;
  305. height: 600rpx;
  306. margin-top: 20rpx;
  307. }
  308. .item {
  309. //height: 50px;
  310. align-items: center;
  311. justify-content: center;
  312. text-align: center;
  313. }
  314. .myExportLog {
  315. height: 100%;
  316. position: relative;
  317. }
  318. .log {
  319. height: calc(100% - 88upx);
  320. .left,
  321. .right {
  322. position: absolute;
  323. height: 100%;
  324. top: 0;
  325. bottom: 0upx;
  326. }
  327. .left {
  328. width: 24%;
  329. left: 0upx;
  330. background: #fff;
  331. }
  332. .right {
  333. width: 76%;
  334. left: 24%;
  335. background-color: #f6f7f9;
  336. margin-left: 0;
  337. padding: 0 20upx;
  338. }
  339. .row {
  340. width: 100%;
  341. height: 90upx;
  342. display: flex;
  343. align-items: center;
  344. .text {
  345. width: 100%;
  346. position: relative;
  347. font-size: 28upx;
  348. display: flex;
  349. justify-content: center;
  350. color: #3c3c3c;
  351. text-align: center;
  352. .block {
  353. position: absolute;
  354. width: 0upx;
  355. left: 0;
  356. }
  357. }
  358. &.on {
  359. height: 90upx;
  360. background-color: #ebeff8;
  361. .text {
  362. font-size: 30upx;
  363. color: #1777fe;
  364. .block {
  365. width: 6upx;
  366. height: 100%;
  367. left: 10upx;
  368. }
  369. }
  370. }
  371. }
  372. .box {
  373. height: 100%;
  374. width: 100%;
  375. text-align: center;
  376. }
  377. .list {
  378. height: 100%;
  379. width: 100%;
  380. text-align: center;
  381. .content {
  382. width: 100%;
  383. display: flex;
  384. justify-content: space-between;
  385. flex-wrap: wrap;
  386. }
  387. }
  388. .oneLog {
  389. width: 220upx;
  390. height: 346upx;
  391. background: #fff;
  392. border-radius: 16upx;
  393. margin: 40upx 0;
  394. box-shadow: 0 2upx 8upx #cccccc;
  395. .title {
  396. width: 100%;
  397. height: 110upx;
  398. margin-top: 40upx;
  399. background: #0965b5;
  400. text-align: center;
  401. .text {
  402. line-height: 110upx;
  403. color: #fff;
  404. }
  405. }
  406. .time {
  407. width: 100%;
  408. height: 100upx;
  409. text-align: center;
  410. .text {
  411. line-height: 100upx;
  412. }
  413. }
  414. .download {
  415. height: 50upx;
  416. text-align: center;
  417. .btn {
  418. height: 100%;
  419. display: inline-block;
  420. padding: 0 36upx;
  421. background: #1a73e8;
  422. border-radius: 10upx;
  423. .text {
  424. color: #fff;
  425. line-height: 50upx;
  426. }
  427. }
  428. }
  429. }
  430. }
  431. </style>