inventoryCost.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="content">
  3. <view class="cost-list" v-for="(item,index) in costList">
  4. <view class="title">
  5. {{item.warehouseName}}
  6. </view>
  7. <view class="goods-table">
  8. <view class="goods-table-title">
  9. <view class="font">货名</view>
  10. <view class="font">储量(吨)</view>
  11. <view class="font">价值(元)</view>
  12. </view>
  13. <view class="goods-table-content" v-for="(item1,index1) in item.goodList">
  14. <view class="font">{{item1.goodsName}}</view>
  15. <view class="font">{{item1.storage}}</view>
  16. <view class="font">{{item1.cost}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. costList:[]
  27. }
  28. },
  29. onLoad: function(option) {
  30. uni.showLoading({
  31. title: "加载中",
  32. mask: true
  33. })
  34. this.init()
  35. },
  36. methods: {
  37. init() {
  38. this.$api.doRequest('get', '/costManagementInfo/selectCostManagementInfo', {
  39. compId: uni.getStorageSync('pcUserInfo').compId,
  40. warehouseType: 1
  41. }).then(res => {
  42. uni.hideLoading()
  43. const results = this.makeGroupData(res.data.data,function (item) {
  44. return [item.warehouseName];
  45. });
  46. console.log(this.costList)
  47. let _data = []
  48. for(let i=0;i<results.length;i++){
  49. let _obj = {}
  50. _obj.warehouseName = results[i][0].warehouseName
  51. _obj.goodList = results[i]
  52. _data.push(_obj)
  53. }
  54. console.log(_data)
  55. this.costList = _data
  56. })
  57. },
  58. makeGroupData(array,fn){
  59. const groups = {};
  60. array.forEach(function (item) {
  61. const group = JSON.stringify(fn(item));
  62. groups[group] = groups[group] || [];
  63. groups[group].push(item);
  64. });
  65. return Object.keys(groups).map(function (group) {
  66. return groups[group];
  67. })
  68. }
  69. }
  70. }
  71. </script>
  72. <style scoped lang="scss">
  73. .cost-list{
  74. margin: 20rpx;
  75. background: white;
  76. border-radius: 20rpx;
  77. padding: 20rpx;
  78. .title{
  79. font-size: 32rpx;
  80. font-weight: 500;
  81. color: #333333;
  82. }
  83. .goods-table{
  84. margin-top: 22rpx;
  85. }
  86. .goods-table-title{
  87. display: flex;
  88. border-bottom: 1px solid #EEEEEE;
  89. padding-bottom:16rpx;
  90. // margin-bottom: ;
  91. .font{
  92. font-size: 27rpx;
  93. font-weight: 400;
  94. color: #B2B3BB;
  95. }
  96. .font:nth-of-type(1){
  97. width: 40%;
  98. }
  99. .font:nth-of-type(2){
  100. width: 30%;
  101. }
  102. .font:nth-of-type(3){
  103. width: 30%;
  104. text-align: right;
  105. }
  106. }
  107. .goods-table-content{
  108. display: flex;
  109. margin: 22rpx;
  110. font-size: 28rpx;
  111. font-weight: 400;
  112. color: #333333;
  113. .font:nth-of-type(1){
  114. width: 40%;
  115. }
  116. .font:nth-of-type(2){
  117. width: 30%;
  118. }
  119. .font:nth-of-type(3){
  120. width: 30%;
  121. text-align: right;
  122. }
  123. }
  124. }
  125. </style>