123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- <template>
- <view style="overflow-x: auto;">
- <template>
- <view class="uni-container">
- <uni-table ref="table" :style="'width:'+(maxWidth+40)+'px'" :loading="loading" border stripe
- :emptyText="$t('base.common.noData')">
- <uni-tr>
- <uni-th :width="item.width" align="center"
- v-for="item in reportTitleList" :key="item.title"><rich-text :nodes="language=='zh-Hans'?item.title:item.languageName"></rich-text></uni-th>
- </uni-tr>
- <uni-tr v-for="(item, index) in reportDataList" :key="index">
- <uni-td v-for="title in reportTitleList" :align="title.align" :key="title.name">
- <view class="name">{{ item[title.name] || item[title.defaultValue] }}</view>
- </uni-td>
- </uni-tr>
- </uni-table>
- </view>
- </template>
- </view>
- </template>
- <script>
- import {
- showReport, //原料进厂汇总表
- } from "../../api/report"
- export default {
- data() {
- return {
- reportDataList: [],
- reportTitleList: [],
- loading: true,
- maxWidth: 0,
- language:'zh-Hans'
- }
- },
- onLoad(options) {
- this.language = uni.getStorageSync('CURRENT_LANG')
- console.log(options);
- this.getList(options.url, options.data)
- },
- methods: {
- getList(url, data) {
- var that = this;
- showReport(data).then(res => {
- console.log("获取到的报表信息-------------,", res);
- if (res.statusCode == 200) {
- that.reportDataList = res.data.data.values
- that.reportTitleList = res.data.data.columns
- if (that.reportTitleList && that.reportTitleList.length == 0) {
- wx.showToast({
- title: '报表未配置列信息!',
- icon: "none",
- duration: 1000,
- })
- return;
- }
- that.loading = false
- that.reportTitleList.forEach(item => {
- that.maxWidth = that.maxWidth + (item.width == null || item.width == '' ? 0 :
- item.width)
- })
- }
- console.log("获取到的报表信息,", res.data.data);
- })
- setTimeout(() => {
- this.loading = false
- }, 2000)
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- /deep/ .uni-table {
- position: relative;
- border-radius: 5px;
- background-color: #fff;
- box-sizing: border-box;
- display: table;
- overflow-x: auto;
- word-break: keep-all;
- }
- .tableHead {
- font-weight: bold;
- color: #333333;
- background: #F4F6FF;
- z-index: 20;
- position: fixed;
- }
- .tableBody {
- height: 500px;
- overflow: scroll;
- margin-top: 42px;
- }
- .li {
- height: 30px;
- line-height: 30px;
- list-style: none;
- padding: 0;
- margin: 0;
- white-space: nowrap;
- }
- .li span {
- display: inline-block;
- padding: 6px 8px;
- line-height: 1;
- text-align: center;
- overflow: hidden;
- vertical-align: middle;
- text-overflow: ellipsis;
- white-space: nowrap;
- border-right: 1px solid #f2f2f2;
- }
- /deep/ .uni-table {
- position: relative;
- border-radius: 5px;
- background-color: #fff;
- box-sizing: border-box;
- display: table;
- overflow-x: auto;
- word-break:keep-all;
- white-space: nowrap
- }
- /deep/ .uni-table-th {
- padding: 16rpx 20rpx;
- background-color: #4680F9;
- color: #fff;
- font-size: 24rpx;
- }
- /deep/ .uni-table-td {
- padding: 16rpx 20rpx;
- font-size: 24rpx;
- line-height: 32rpx;
- }
- </style>
|