inventoryCost.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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">{{item1.goodsName}}</view>
  16. <view class="font">{{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. uni.showLoading({
  95. title: '正在加载'
  96. })
  97. this.$api.doRequest('post', _url, {
  98. startDate: this.parameter.startDate,
  99. endDate: this.parameter.endDate,
  100. warehouseName: this.parameter.warehouseName
  101. }).then(res => {
  102. uni.hideLoading()
  103. console.log('-----------')
  104. console.log(res.data.data)
  105. uni.downloadFile({
  106. url: res.data.data,
  107. success: function(res) {
  108. var filePath = res.tempFilePath;
  109. uni.openDocument({
  110. filePath: filePath,
  111. showMenu: true,
  112. success: function(res) {
  113. console.log('打开文档成功');
  114. }
  115. });
  116. }
  117. });
  118. })
  119. },
  120. cancelClick() {
  121. this.isShowDetailBtn = false
  122. },
  123. toDetail(warehouseName) {
  124. this.parameter.warehouseName = warehouseName
  125. this.isShowDetailBtn = true
  126. },
  127. init() {
  128. uni.showLoading({
  129. title: '正在加载'
  130. })
  131. this.$api.doRequest('get', '/costManagementInfo/selectCostManagementInfo', {
  132. compId: uni.getStorageSync('pcUserInfo').compId,
  133. warehouseType: 1
  134. }).then(res => {
  135. uni.hideLoading()
  136. const results = this.makeGroupData(res.data.data, function(item) {
  137. return [item.warehouseName];
  138. });
  139. console.log('this.costList')
  140. console.log(this.costList)
  141. let _data = []
  142. for (let i = 0; i < results.length; i++) {
  143. let _obj = {}
  144. _obj.warehouseName = results[i][0].warehouseName
  145. // 大于两条添加合计行
  146. if (results[i].length > 1) {
  147. let _price = 0
  148. for (let k = 0; k < results[i].length; k++) {
  149. _price += results[i][k].storage
  150. }
  151. _price = _price.toFixed(2)
  152. results[i].push({
  153. 'goodsName': '合计',
  154. 'storage': _price
  155. })
  156. }
  157. _obj.goodList = results[i]
  158. _data.push(_obj)
  159. }
  160. console.log(_data)
  161. this.costList = _data
  162. })
  163. },
  164. makeGroupData(array, fn) {
  165. const groups = {};
  166. array.forEach(function(item) {
  167. const group = JSON.stringify(fn(item));
  168. groups[group] = groups[group] || [];
  169. groups[group].push(item);
  170. });
  171. return Object.keys(groups).map(function(group) {
  172. return groups[group];
  173. })
  174. }
  175. }
  176. }
  177. </script>
  178. <style scoped lang="scss">
  179. .modal-row {
  180. display: flex;
  181. justify-content: space-between;
  182. padding: 10rpx 60rpx ;
  183. margin-top: 20rpx;
  184. margin-bottom: 20rpx;
  185. }
  186. .u-radio-group {
  187. width: 100%;
  188. display: flex;
  189. justify-content: space-between;
  190. }
  191. .u-radio {
  192. width: 50% !important;
  193. display: flex;
  194. justify-content: center;
  195. }
  196. .record {
  197. background: red;
  198. display: flex;
  199. justify-content: center;
  200. }
  201. .button {
  202. font-size: 24rpx;
  203. padding: 4rpx 20rpx;
  204. border-radius: 15px;
  205. background: #22C572;
  206. color: white;
  207. // margin: 0 10px;
  208. }
  209. .cost-list {
  210. margin: 20rpx;
  211. background: white;
  212. border-radius: 20rpx;
  213. padding: 20rpx;
  214. .title {
  215. font-size: 32rpx;
  216. font-weight: 500;
  217. color: #333333;
  218. }
  219. .goods-table {
  220. margin-top: 22rpx;
  221. }
  222. .goods-table-title {
  223. display: flex;
  224. border-bottom: 1px solid #EEEEEE;
  225. padding-bottom: 16rpx;
  226. // margin-bottom: ;
  227. .font {
  228. font-size: 27rpx;
  229. font-weight: 400;
  230. color: #B2B3BB;
  231. }
  232. .font:nth-of-type(1) {
  233. width: 40%;
  234. }
  235. .font:nth-of-type(2) {
  236. width: 30%;
  237. }
  238. .font:nth-of-type(3) {
  239. width: 30%;
  240. text-align: right;
  241. }
  242. }
  243. .goods-table-content {
  244. display: flex;
  245. margin: 22rpx;
  246. font-size: 28rpx;
  247. font-weight: 400;
  248. color: #333333;
  249. .font:nth-of-type(1) {
  250. width: 40%;
  251. }
  252. .font:nth-of-type(2) {
  253. width: 30%;
  254. }
  255. .font:nth-of-type(3) {
  256. width: 30%;
  257. text-align: right;
  258. }
  259. }
  260. }
  261. </style>