inventoryCost.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <view class="content">
  3. <view @click='goposition(item)' 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':''">
  16. {{item1.goodsName}}
  17. </view>
  18. <view class="font" :class="item.goodList.length>1&&index1==item.goodList.length-1?'active':''">
  19. {{item1.storage}}
  20. </view>
  21. <view class="font">{{item1.cost}}</view>
  22. </view>
  23. <view v-show="(item1.cargoWeight && item1.cargoWeight != 0)" class="goods-table-content"
  24. v-for="(item1,index1) in item.goodList">
  25. <view class="font" :class="item.goodList.length>1&&index1==item.goodList.length-1?'active':''">
  26. {{item1.goodsName}}(转入)
  27. </view>
  28. <view class="font" :class="item.goodList.length>1&&index1==item.goodList.length-1?'active':''">
  29. {{item1.cargoWeight}}
  30. </view>
  31. </view>
  32. <view v-show="(item1.redemptionWeight && item1.redemptionWeight != 0)" class="goods-table-content"
  33. v-for="(item1,index1) in item.goodList">
  34. <view class="font" :class="item.goodList.length>1&&index1==item.goodList.length-1?'active':''">
  35. {{item1.goodsName}}(待赎回)
  36. </view>
  37. <view class="font" :class="item.goodList.length>1&&index1==item.goodList.length-1?'active':''">
  38. {{item1.redemptionWeight}}
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <u-modal class="record" v-model="isShowDetailBtn" :title-style="{fontSize: '18px',fontWeight:'500'}"
  44. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='导出记录'
  45. :showCancelButton='false' @confirm="alertBtn" @cancel="cancelClick">
  46. <view>
  47. <u-radio-group v-model="value">
  48. <u-radio active-color="#22C572" @change="radioChange" v-for="(item, index) in list" :key="index"
  49. :name="item.name" :disabled="item.disabled">
  50. {{item.name}}
  51. </u-radio>
  52. </u-radio-group>
  53. <view class="modal-row">
  54. <view class="">查询日期</view>
  55. <view class="" @click="selectDate">
  56. {{parameter.endDate?parameter.startDate+' - '+parameter.endDate:'请选择查询日期'}}
  57. </view>
  58. </view>
  59. <view @click='show1=true' class="modal-row">
  60. <view class="">仓库名称</view>
  61. <view>{{parameter.warehouseName}}</view>
  62. </view>
  63. <u-picker mode="selector" v-model="show1" @confirm='warehouseConfirm' range-key='warehouseName'
  64. :default-selector="[0]" :range="warehouseList"></u-picker>
  65. </view>
  66. </u-modal>
  67. <u-calendar v-model="show" :mode="mode" @change="change" range-color='#22C572' btn-type='success'
  68. range-bg-color='rgba(25, 190, 107, 0.13)' active-bg-color='#22C572'></u-calendar>
  69. <u-modal v-model="isShowAlert" :title-style="{fontSize: '18px',fontWeight:'500'}"
  70. :content-style="{fontSize: '14px',fontWeight:'400'}" confirm-color='#22C572' confirm-text='确定' title='提示'
  71. :showCancelButton='false' :content="content" @confirm="alertBtn" @cancel="cancelClick"></u-modal>
  72. </view>
  73. </template>
  74. <script>
  75. import helper from '@/common/helper.js';
  76. import {
  77. mapState
  78. } from 'vuex';
  79. export default {
  80. data() {
  81. return {
  82. isShowAlert: false,
  83. show1: false,
  84. content: '当前登录身份已失效,请重新登录!',
  85. warehouseList: [],
  86. parameter: {
  87. startDate: "",
  88. endDate: '',
  89. warehouseName: '',
  90. warehouseId: ''
  91. },
  92. show: false,
  93. mode: 'range',
  94. list: [{
  95. name: '入库记录',
  96. disabled: false
  97. },
  98. {
  99. name: '出库记录',
  100. disabled: false
  101. }
  102. ],
  103. // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
  104. value: '入库记录',
  105. costList: [],
  106. isShowDetailBtn: false,
  107. searchMonth: '2022-10-10'
  108. }
  109. },
  110. onLoad: function(option) {
  111. console.log(option)
  112. this.searchMonth = option.searchMonth
  113. this.init()
  114. },
  115. onNavigationBarButtonTap() {
  116. this.parameter.warehouseName = this.costList[0].warehouseName
  117. this.parameter.startDate = helper.getNowNumFormatDate(-1)
  118. console.log(this.parameter.startDate)
  119. this.parameter.endDate = helper.getNowFormatDate()
  120. uni.showLoading({
  121. title: '正在加载'
  122. })
  123. this.$api.doRequest('get', '/warehouseBaseInfo/selectWarehouseSelfApp', {
  124. compId: uni.getStorageSync('pcUserInfo').compId,
  125. }).then(res => {
  126. this.warehouseList = res.data.data
  127. this.isShowDetailBtn = true
  128. })
  129. },
  130. computed: {
  131. ...mapState(['hasLogin', 'userInfo']),
  132. },
  133. methods: {
  134. warehouseConfirm(e) {
  135. console.log(e)
  136. this.parameter.warehouseName = this.warehouseList[e[0]].warehouseName
  137. },
  138. alertBtn() {
  139. uni.navigateTo({
  140. url: '/pages/public/login'
  141. })
  142. },
  143. goposition(item) {
  144. uni.navigateTo({
  145. url: '/pages/user/contractLook/position?warehouse=' + item.warehouseName + '&warehouseId=' +
  146. item.warehouseId
  147. })
  148. },
  149. cancelClick() {
  150. this.isShowAlert = false
  151. },
  152. selectDate() {
  153. this.show = true
  154. },
  155. change(e) {
  156. this.parameter.startDate = e.startDate
  157. this.parameter.endDate = e.endDate
  158. },
  159. radioChange(e) {
  160. console.log(e);
  161. },
  162. alertBtn() {
  163. let _url = ''
  164. if (this.value == '入库记录') {
  165. _url = '/warehouseBaseInfo/exportphone'
  166. } else {
  167. _url = "/warehouseBaseInfo/exportPhoneOut"
  168. }
  169. uni.showLoading({
  170. title: '正在加载'
  171. })
  172. this.$api.doRequest('post', _url, {
  173. startDate: this.parameter.startDate + ' 00:00:00',
  174. endDate: this.parameter.endDate + ' 00:00:00',
  175. warehouseName: this.parameter.warehouseName
  176. }).then(res => {
  177. uni.hideLoading()
  178. console.log('-----------')
  179. console.log(res.data.data)
  180. uni.downloadFile({
  181. url: res.data.data,
  182. success: function(res) {
  183. var filePath = res.tempFilePath;
  184. uni.openDocument({
  185. filePath: filePath,
  186. showMenu: true,
  187. success: function(res) {
  188. console.log('打开文档成功');
  189. }
  190. });
  191. }
  192. });
  193. })
  194. },
  195. cancelClick() {
  196. this.isShowDetailBtn = false
  197. },
  198. toDetail(warehouseName) {
  199. // this.parameter.warehouseName = warehouseName
  200. },
  201. init() {
  202. if (!this.hasLogin) {
  203. this.isShowAlert = true;
  204. } else {
  205. uni.showLoading({
  206. title: '正在加载'
  207. })
  208. this.$api.doRequest('get', '/costManagementInfo/selectCostManagementInfo', {
  209. compId: uni.getStorageSync('pcUserInfo').compId,
  210. warehouseType: 1,
  211. searchMoth: this.searchMonth
  212. }).then(res => {
  213. uni.hideLoading()
  214. if (res.data.data) {
  215. const results = this.makeGroupData(res.data.data, function(item) {
  216. return [item.warehouseName];
  217. });
  218. console.log('this.costList')
  219. console.log(this.costList)
  220. let _data = []
  221. for (let i = 0; i < results.length; i++) {
  222. let _obj = {}
  223. _obj.warehouseName = results[i][0].warehouseName
  224. _obj.warehouseId = results[i][0].warehouseId
  225. // 大于两条添加合计行
  226. if (results[i].length > 1) {
  227. let _price = 0
  228. for (let k = 0; k < results[i].length; k++) {
  229. _price += results[i][k].storage
  230. }
  231. _price = _price.toFixed(2)
  232. results[i].push({
  233. 'goodsName': '合计',
  234. 'storage': _price
  235. })
  236. }
  237. _obj.goodList = results[i]
  238. _data.push(_obj)
  239. }
  240. console.log(_data)
  241. this.costList = _data
  242. }
  243. })
  244. }
  245. },
  246. makeGroupData(array, fn) {
  247. const groups = {};
  248. array.forEach(function(item) {
  249. const group = JSON.stringify(fn(item));
  250. groups[group] = groups[group] || [];
  251. groups[group].push(item);
  252. });
  253. return Object.keys(groups).map(function(group) {
  254. console.log(groups, groups[group])
  255. return groups[group];
  256. })
  257. }
  258. }
  259. }
  260. </script>
  261. <style scoped lang="scss">
  262. .active {
  263. font-size: 32rpx;
  264. font-weight: 700;
  265. }
  266. .modal-row {
  267. display: flex;
  268. justify-content: space-between;
  269. padding: 10rpx 60rpx;
  270. margin-top: 20rpx;
  271. margin-bottom: 20rpx;
  272. }
  273. .u-radio-group {
  274. width: 100%;
  275. display: flex;
  276. justify-content: space-between;
  277. }
  278. .u-radio {
  279. width: 50% !important;
  280. display: flex;
  281. justify-content: center;
  282. }
  283. .record {
  284. background: red;
  285. display: flex;
  286. justify-content: center;
  287. }
  288. .button {
  289. font-size: 24rpx;
  290. padding: 4rpx 20rpx;
  291. border-radius: 15px;
  292. background: #22C572;
  293. color: white;
  294. // margin: 0 10px;
  295. }
  296. .cost-list {
  297. margin: 20rpx;
  298. background: white;
  299. border-radius: 20rpx;
  300. padding: 20rpx;
  301. .title {
  302. font-size: 32rpx;
  303. font-weight: 500;
  304. color: #333333;
  305. }
  306. .goods-table {
  307. margin-top: 22rpx;
  308. }
  309. .goods-table-title {
  310. display: flex;
  311. border-bottom: 1px solid #EEEEEE;
  312. padding-bottom: 16rpx;
  313. // margin-bottom: ;
  314. .font {
  315. font-size: 27rpx;
  316. font-weight: 400;
  317. color: #B2B3BB;
  318. }
  319. .font:nth-of-type(1) {
  320. width: 40%;
  321. }
  322. .font:nth-of-type(2) {
  323. width: 30%;
  324. }
  325. .font:nth-of-type(3) {
  326. width: 30%;
  327. text-align: right;
  328. }
  329. }
  330. .goods-table-content {
  331. display: flex;
  332. margin: 22rpx 0;
  333. font-size: 28rpx;
  334. font-weight: 400;
  335. color: #333333;
  336. .font:nth-of-type(1) {
  337. width: 40%;
  338. }
  339. .font:nth-of-type(2) {
  340. width: 30%;
  341. }
  342. .font:nth-of-type(3) {
  343. width: 30%;
  344. text-align: right;
  345. }
  346. }
  347. }
  348. </style>