index1.vue 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <div class="app-content">
  3. <el-radio v-model="radio2" label="1" @change="changeRadio2">牲畜类别</el-radio>
  4. <el-radio v-model="radio2" label="2" @change="changeRadio2">栏舍名称</el-radio>
  5. <template v-if="aa">
  6. <u-table ref="plTable" v-loading="listLoading" :max-height="height" use-virtual @table-body-scroll="tableScroll" :data-changes-scroll-top="radio === 1" :row-height="rowHeight" border>
  7. <u-table-column v-for="(item,key) in tableConfig" :key="'a'+key" :label="item.label" :show-overflow-tooltip="item.showOverflow" align="center" :prop="item.prop" :fixed="key==0">
  8. <u-table-column v-for="(item1,key1) in item.children" v-if="item.children || item.children.length>0" :key="'B'+key1" align="center" :label="item1.label" :prop="item1.prop" :min-width="item1.width">
  9. <u-table-column v-for="(item2,key2) in item1.children" v-if="item1.children || item1.children.length>0" :key="'C'+key2" :label="item2.label" :prop="item2.prop" />
  10. </u-table-column>
  11. </u-table-column>
  12. </u-table>
  13. </template>
  14. </div>
  15. </template>
  16. <script>
  17. import { postJson } from '@/api/common'
  18. export default {
  19. name: 'PastureInventoryManagement',
  20. data() {
  21. return {
  22. radio: 1,
  23. height: document.documentElement.clientHeight - 125,
  24. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  25. rowHeight: 30,
  26. listLoading:false,
  27. tableConfig:[],
  28. radio2: '1',
  29. aa:false
  30. }
  31. },
  32. mounted() {
  33. this.setData()
  34. },
  35. methods: {
  36. setData() {
  37. this.aa = false
  38. setTimeout(()=>{
  39. this.aa = true
  40. this.$nextTick(() => {
  41. let list = []
  42. let url = 'authdata/GetReportform'
  43. let data = {
  44. "name":"",
  45. "page":1,
  46. "offset":1,
  47. "returntype":"Map",
  48. "checked":0,
  49. "parammaps":{
  50. "pastureid":"1647481173",
  51. "startTime":"2022-03-11",
  52. "stopTime":"2022-03-17",
  53. "fname":"",
  54. },
  55. }
  56. if(this.radio2 == '1'){
  57. data.name = 'getMaterialAnalysisLS'
  58. }else if(this.radio2 == '2'){
  59. data.name = 'getMaterialAnalysisSC'
  60. }
  61. this.listLoading = true
  62. postJson(url,data).then(response => {
  63. this.listLoading = false
  64. this.tableConfig = response.data.list.data2
  65. list = response.data.list.data1
  66. this.$refs.plTable.reloadData(list)
  67. })
  68. })
  69. },50)
  70. },
  71. tableScroll({ scrollTop, scrollLeft, table, judgeFlse }) {
  72. // {scrollTop, scrollLeft, table, judgeFlse: 这个参数返回一个boolean值,为true则代表表格滚动到了底部了,false没有滚动到底部,必须开起大数据渲染模式才能有值哦}, event
  73. // console.log(scrollTop, scrollLeft, table, judgeFlse)
  74. },
  75. changeRadio2() {
  76. console.log(this.radio2)
  77. if (this.radio2 == '1') {
  78. this.setData()
  79. } else if (this.radio2 == '2') {
  80. this.setData()
  81. }
  82. }
  83. }
  84. }
  85. </script>
  86. <style lang="scss" scoped>
  87. .app-content{padding: 20px 20px}
  88. </style>