inventoryCost.vue 10 KB

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