inventoryCost.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. <template>
  2. <view class="content">
  3. <view class="cost-list" v-for="(item,index) in costList">
  4. <view style="display: flex;justify-content: space-between;">
  5. <view class="title">{{item.warehouseName}}</view>
  6. <view class="button" @click="toDetail(item.warehouseName)">详细记录</view>
  7. </view>
  8. <view class="goods-table">
  9. <view class="goods-table-title">
  10. <view class="font">货名</view>
  11. <view class="font">储量(吨)</view>
  12. <view class="font">价值(元)</view>
  13. </view>
  14. <view class="goods-table-content" v-for="(item1,index1) in item.goodList">
  15. <view class="font" :class="item.goodList.length>1&&index1==item.goodList.length-1?'active':''">{{item1.goodsName}}</view>
  16. <view class="font" :class="item.goodList.length>1&&index1==item.goodList.length-1?'active':''">{{item1.storage}}</view>
  17. <view class="font">{{item1.cost}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. <u-modal class="record" v-model="isShowDetailBtn" :title-style="{fontSize: '18px',fontWeight:'500'}"
  22. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='导出记录'
  23. showCancelButton='false' @confirm="alertBtn" @cancel="cancelClick">
  24. <view>
  25. <u-radio-group v-model="value">
  26. <u-radio active-color="#22C572" @change="radioChange" v-for="(item, index) in list" :key="index"
  27. :name="item.name" :disabled="item.disabled">
  28. {{item.name}}
  29. </u-radio>
  30. </u-radio-group>
  31. <view class="modal-row">
  32. <view class="">查询日期</view>
  33. <view class="" @click="selectDate">
  34. {{parameter.endDate?parameter.startDate+'-'+parameter.endDate:'请选择查询日期'}}
  35. </view>
  36. </view>
  37. <view class="modal-row">
  38. <view class="">仓库名称</view>
  39. <view>{{parameter.warehouseName}}</view>
  40. </view>
  41. </view>
  42. </u-modal>
  43. <u-calendar v-model="show" :mode="mode" @change="change" range-color='#22C572' btn-type='success'
  44. range-bg-color='rgba(25, 190, 107, 0.13)' active-bg-color='#22C572'></u-calendar>
  45. </view>
  46. </template>
  47. <script>
  48. export default {
  49. data() {
  50. return {
  51. parameter: {
  52. startDate: "",
  53. endDate: '',
  54. warehouseName: ''
  55. },
  56. show: false,
  57. mode: 'range',
  58. list: [{
  59. name: '入库记录',
  60. disabled: false
  61. },
  62. {
  63. name: '出库记录',
  64. disabled: false
  65. }
  66. ],
  67. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  68. value: '入库记录',
  69. costList: [],
  70. isShowDetailBtn: false
  71. }
  72. },
  73. onLoad: function(option) {
  74. this.init()
  75. },
  76. methods: {
  77. selectDate() {
  78. this.show = true
  79. },
  80. change(e) {
  81. this.parameter.startDate = e.startDate
  82. this.parameter.endDate = e.endDate
  83. },
  84. radioChange(e) {
  85. console.log(e);
  86. },
  87. alertBtn() {
  88. let _url = ''
  89. if (this.value == '入库记录') {
  90. _url = '/warehouseBaseInfo/exportphone'
  91. } else {
  92. _url = "/warehouseBaseInfo/exportPhoneOut"
  93. }
  94. this.$api.doRequest('post', _url, {
  95. startDate: this.parameter.startDate,
  96. endDate: this.parameter.endDate,
  97. warehouseName: this.parameter.warehouseName
  98. }).then(res => {
  99. console.log('-----------')
  100. console.log(res.data.data)
  101. uni.downloadFile({
  102. url: res.data.data,
  103. success: function(res) {
  104. var filePath = res.tempFilePath;
  105. uni.openDocument({
  106. filePath: filePath,
  107. showMenu: true,
  108. success: function(res) {
  109. console.log('打开文档成功');
  110. }
  111. });
  112. }
  113. });
  114. })
  115. },
  116. cancelClick() {
  117. this.isShowDetailBtn = false
  118. },
  119. toDetail(warehouseName) {
  120. this.parameter.warehouseName = warehouseName
  121. this.isShowDetailBtn = true
  122. },
  123. init() {
  124. this.$api.doRequest('get', '/costManagementInfo/selectCostManagementInfo', {
  125. compId: uni.getStorageSync('pcUserInfo').compId,
  126. warehouseType: 1
  127. }).then(res => {
  128. uni.hideLoading()
  129. const results = this.makeGroupData(res.data.data, function(item) {
  130. return [item.warehouseName];
  131. });
  132. console.log('this.costList')
  133. console.log(this.costList)
  134. let _data = []
  135. for (let i = 0; i < results.length; i++) {
  136. let _obj = {}
  137. _obj.warehouseName = results[i][0].warehouseName
  138. // 大于两条添加合计行
  139. if (results[i].length > 1) {
  140. let _price = 0
  141. for (let k = 0; k < results[i].length; k++) {
  142. _price += results[i][k].storage
  143. }
  144. _price = _price.toFixed(2)
  145. results[i].push({
  146. 'goodsName': '合计',
  147. 'storage': _price
  148. })
  149. }
  150. _obj.goodList = results[i]
  151. _data.push(_obj)
  152. }
  153. console.log(_data)
  154. this.costList = _data
  155. })
  156. },
  157. makeGroupData(array, fn) {
  158. const groups = {};
  159. array.forEach(function(item) {
  160. const group = JSON.stringify(fn(item));
  161. groups[group] = groups[group] || [];
  162. groups[group].push(item);
  163. });
  164. return Object.keys(groups).map(function(group) {
  165. return groups[group];
  166. })
  167. }
  168. }
  169. }
  170. </script>
  171. <style scoped lang="scss">
  172. .active{
  173. font-size: 32rpx;
  174. font-weight: 700;
  175. }
  176. .modal-row {
  177. display: flex;
  178. justify-content: space-between;
  179. padding: 10rpx 60rpx;
  180. margin-top: 20rpx;
  181. }
  182. .u-radio-group {
  183. width: 100%;
  184. display: flex;
  185. justify-content: space-between;
  186. }
  187. .u-radio {
  188. width: 50% !important;
  189. display: flex;
  190. justify-content: center;
  191. }
  192. .record {
  193. background: red;
  194. display: flex;
  195. justify-content: center;
  196. }
  197. .button {
  198. font-size: 24rpx;
  199. padding: 4rpx 20rpx;
  200. border-radius: 15px;
  201. background: #22C572;
  202. color: white;
  203. // margin: 0 10px;
  204. }
  205. .cost-list {
  206. margin: 20rpx;
  207. background: white;
  208. border-radius: 20rpx;
  209. padding: 20rpx;
  210. .title {
  211. font-size: 32rpx;
  212. font-weight: 500;
  213. color: #333333;
  214. }
  215. .goods-table {
  216. margin-top: 22rpx;
  217. }
  218. .goods-table-title {
  219. display: flex;
  220. border-bottom: 1px solid #EEEEEE;
  221. padding-bottom: 16rpx;
  222. // margin-bottom: ;
  223. .font {
  224. font-size: 27rpx;
  225. font-weight: 400;
  226. color: #B2B3BB;
  227. }
  228. .font:nth-of-type(1) {
  229. width: 40%;
  230. }
  231. .font:nth-of-type(2) {
  232. width: 30%;
  233. }
  234. .font:nth-of-type(3) {
  235. width: 30%;
  236. text-align: right;
  237. }
  238. }
  239. .goods-table-content {
  240. display: flex;
  241. margin: 22rpx;
  242. font-size: 28rpx;
  243. font-weight: 400;
  244. color: #333333;
  245. .font:nth-of-type(1) {
  246. width: 40%;
  247. }
  248. .font:nth-of-type(2) {
  249. width: 30%;
  250. }
  251. .font:nth-of-type(3) {
  252. width: 30%;
  253. text-align: right;
  254. }
  255. }
  256. }
  257. </style>