stock.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <view class="app-content">
  3. <view class="ex-page">
  4. <view class="input-wrap">
  5. <view style="padding:0 0upx 0 20upx;" >
  6. <button class="admin-button-com middle blue"
  7. style="background-color:green;border:1upx solid green;margin-right:20upx;"
  8. @click="allOutSelectShop(1)">全部调拨出库</button>
  9. <button class="admin-button-com middle default" @click="clearAll()" style="margin-right:20upx;">清空全部库存</button>
  10. <button class="admin-button-com middle default" @click="downStock()">下载Excel</button>
  11. </view>
  12. </view>
  13. <view class="top-bar" style="margin-left:80upx;font-size:38upx;padding:30upx 0 20upx 0;">
  14. <text @click="showStock">实时库存</text>
  15. <text style="margin-left:50upx;" @click="showAllItem">全部花材</text>
  16. </view>
  17. <view style="margin-left:30upx;padding-top:10upx;padding-bottom:10upx;font-size:26upx;">这个页面,请使用app打开,小程序打开会卡死</view>
  18. <scroll-view scroll-y scroll-with-animation class="main-view">
  19. <view class="space-view ex-table">
  20. <t-table :headerBackgroundColor="'#F0F2F6'">
  21. <t-tr header>
  22. <t-th><view style="width:200upx;text-align:left;">花材</view></t-th>
  23. <t-th>库存</t-th>
  24. <t-th>路上</t-th>
  25. <t-th>大客</t-th>
  26. <t-th>批发</t-th>
  27. <t-th>零售</t-th>
  28. <t-th><view @click="clearAllStock()">成本</view></t-th>
  29. </t-tr>
  30. <block v-if="!$util.isEmpty(classItemData)">
  31. <block v-for="(classItem,classIndex) in classItemData" :key="classIndex">
  32. <block v-if="classItem.child && !$util.isEmpty(classItem.child)">
  33. <t-tr>
  34. <t-td>
  35. <text style="color:#3385FF;font-weight:bold;width:200upx;text-align:left;">
  36. {{ classItem.className }}
  37. </text>
  38. </t-td>
  39. <t-td></t-td>
  40. <t-td></t-td>
  41. <t-td></t-td>
  42. <t-td></t-td>
  43. <t-td></t-td>
  44. <t-td></t-td>
  45. </t-tr>
  46. <template v-if="classItem.child && !$util.isEmpty(classItem.child)">
  47. <block v-for="(productItem, productIndex) in classItem.child" :key="productIndex">
  48. <t-tr>
  49. <t-td>
  50. <view style="width:200upx;text-align:left;color:#333333;font-size:29upx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;" @click="pageTo({url:'/admin/item/detail?id='+productItem.id})">
  51. {{productItem.name}}
  52. </view>
  53. </t-td>
  54. <t-td>
  55. <view style="color:#333333;font-weight:bold;font-size:29upx;" @click="pageTo({url:'/admin/item/detail?id='+productItem.id})">
  56. {{productItem.stock?parseFloat(productItem.stock):0}}
  57. </view>
  58. </t-td>
  59. <t-td>
  60. <text v-if="Number(productItem.onStock)>0" style="color:#0a97a9;font-size:30upx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;" @click="pageTo({url:'/admin/item/detail?id='+productItem.id,})">
  61. {{productItem.onStock}}
  62. </text>
  63. <text v-else style="color:#0a97a9;font-size:30upx; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;" @click="pageTo({url:'/admin/item/detail?id='+productItem.id,})">
  64. -
  65. </text>
  66. </t-td>
  67. <t-td>
  68. <view style="font-size:28upx;" @click="pageTo({url:'/admin/item/detail?id='+productItem.id})">
  69. ¥{{productItem.hjPrice?parseFloat(productItem.hjPrice):0}}
  70. </view>
  71. </t-td>
  72. <t-td>
  73. <view style="color:#3385FF;font-size:30upx;" @click="pageTo({url:'/admin/item/detail?id='+productItem.id})">
  74. ¥{{productItem.price?parseFloat(productItem.price):0}}
  75. </view>
  76. </t-td>
  77. <t-td>
  78. <view style="font-size:28upx;" @click="pageTo({url:'/admin/item/detail?id='+productItem.id})">
  79. ¥{{productItem.skPrice?parseFloat(productItem.skPrice):0}}
  80. </view>
  81. </t-td>
  82. <t-td>
  83. <view style="font-size:28upx;color:red;" @click="pageTo({url:'/admin/item/detail?id='+productItem.id})">
  84. ¥{{productItem.avCost?parseFloat(productItem.avCost):0}}
  85. </view>
  86. </t-td>
  87. </t-tr>
  88. </block>
  89. </template>
  90. </block>
  91. </block>
  92. </block>
  93. </t-table>
  94. </view>
  95. </scroll-view>
  96. </view>
  97. </view>
  98. </template>
  99. <script>
  100. import AppWrapperEmpty from "@/components/app-wrapper-empty";
  101. import SelectList from "@/components/plugin/selectList";
  102. import { getProductDataApi,generateItemTable } from "@/api/product";
  103. import { allOut } from "@/api/stock-out"
  104. import { clearStock } from "@/api/inventory";
  105. import { list } from "@/mixins";
  106. import ShopSelect from "@/components/module/shopSelect";
  107. import DateSelect from "@/components/module/dateSelect";
  108. import {mapActions, mapGetters} from "vuex";
  109. import AppSearchModule from "@/components/module/app-search";
  110. export default {
  111. components: { SelectList, AppWrapperEmpty,ShopSelect,DateSelect,AppSearchModule},
  112. mixins: [list],
  113. computed: {
  114. ...mapGetters(["getDictionariesInfo","getLoginInfo","getMyShopInfo"])
  115. },
  116. data() {
  117. return {
  118. isShow:false,
  119. customizationTime:'',
  120. shopId:'',
  121. itemId:'',
  122. nowTime: "",
  123. showTimeDropdown: false,
  124. nowShop: "",
  125. showShopDropdown: false,
  126. dataList: [],
  127. profile:[],
  128. storageData:[],
  129. searchContent:'',
  130. shopId:0,
  131. classItemData:[],
  132. form:{shopId:0,shopName:'',hasSelect:0},
  133. confirmIn:0
  134. };
  135. },
  136. onShow(){
  137. let that = this
  138. if(this.form.hasSelect == 1){
  139. that.$util.confirmModal({content:'确认全部出库到'+this.form.shopName+'?'},() => {
  140. that.form.hasSelect = 0
  141. uni.showLoading({mask:true})
  142. allOut({shopId:this.form.shopId,confirmIn:that.confirmIn}).then(res=>{
  143. uni.hideLoading()
  144. if(res.code == 1){
  145. that.$msg(res.msg)
  146. that.showStock()
  147. }
  148. })
  149. })
  150. }
  151. },
  152. onLoad() {
  153. this.showStock()
  154. },
  155. methods: {
  156. downStock(){
  157. uni.showLoading({title:'下载中',mask:true})
  158. generateItemTable().then(res => {
  159. if(res.code == 1){
  160. uni.hideLoading()
  161. let file = res.data.file
  162. let shortFile = res.data.shortFile
  163. uni.downloadFile({
  164. url: file,
  165. header: {"Content-Type": 'application/vnd.ms-excel'},
  166. filePath: `${wx.env.USER_DATA_PATH}/${shortFile}`,
  167. success: (res) => {
  168. if (res.statusCode === 200) {
  169. wx.saveFileToDisk({
  170. filePath: res.filePath,
  171. success: function(res) {
  172. console.log(res)
  173. },
  174. fail:function(res) {
  175. console.log(res)
  176. }
  177. })
  178. }
  179. },
  180. fail:()=>{
  181. uni.showToast({title:'请用电脑打开小程序下载',mask:true,icon:'none'})
  182. }
  183. });
  184. }
  185. })
  186. },
  187. clearAllStock(){
  188. let that = this
  189. that.$util.confirmModal({content:'确认全部清除?'},() => {
  190. clearStock().then(res=>{
  191. if(res.code == 1){
  192. that.$msg(res.msg)
  193. that.showStock()
  194. }
  195. })
  196. })
  197. },
  198. init(){
  199. },
  200. clearAll(){
  201. this.$msg('请联系管理员')
  202. },
  203. allOutSelectShop(flag){
  204. //是否直接入库
  205. this.confirmIn = flag
  206. this.$util.pageTo({url: '/admin/shop/selectShop',query: {style:2}})
  207. },
  208. showStock(){
  209. this.shopId = this.getMyShopInfo.id;
  210. let type = '';
  211. let that = this
  212. uni.showLoading()
  213. getProductDataApi({ type, shopId: this.shopId,status:0,requestType:'hasStockList'}).then(res=>{
  214. uni.hideLoading()
  215. if(res.code == 1){
  216. that.classItemData = res.data.classItem ? res.data.classItem : []
  217. }
  218. })
  219. },
  220. showAllItem(){
  221. this.shopId = this.getMyShopInfo.id;
  222. let type = '';
  223. let that = this
  224. uni.showLoading()
  225. getProductDataApi({ type, shopId: this.shopId,status:0,requestType:'itemList'}).then(res=>{
  226. uni.hideLoading()
  227. if(res.code == 1){
  228. that.classItemData = res.data.classItem ? res.data.classItem : []
  229. }
  230. })
  231. }
  232. }
  233. };
  234. </script>
  235. <style lang="scss" scoped>
  236. .ex-page {
  237. background: white;
  238. padding-top:20upx;
  239. height: 100%;
  240. display: flex;
  241. flex-direction: column;
  242. .input-wrap {
  243. display: flex;
  244. padding: 0upx 20upx 0upx 13upx;
  245. .search-bar {
  246. flex: 1;
  247. }
  248. }
  249. .top-bar {
  250. width: 100%;
  251. z-index: 20;
  252. .bar{
  253. width: 50%;
  254. height: 100%;
  255. text-align: center;
  256. &:nth-child(1){
  257. border-right: 1upx solid #eeeeec;
  258. }
  259. }
  260. }
  261. .main-view {
  262. margin-top:10upx;
  263. flex: 1;
  264. background-color: #f9fbfc;
  265. .space-view {
  266. background-color: #fff;
  267. }
  268. .ex-info {
  269. padding: 30upx;
  270. .info-cell {
  271. display: flex;
  272. align-items: center;
  273. font-size: 28upx;
  274. &:not(:first-child) {
  275. margin-top: 20upx;
  276. }
  277. .cell-label {
  278. width: 110upx;
  279. color: #666666;
  280. }
  281. .cell-value {
  282. margin-left: 40upx;
  283. color: #333;
  284. &.warning {
  285. color: #ffaf1d;
  286. }
  287. &.success {
  288. color: #27c325;
  289. }
  290. }
  291. }
  292. }
  293. .ex-table {
  294. ::v-deep.icon-info {
  295. color: #333333;
  296. }
  297. }
  298. }
  299. .bar-view {
  300. display: flex;
  301. justify-content: space-between;
  302. align-items: center;
  303. padding: 0 30upx;
  304. width: 100%;
  305. height: 100upx;
  306. box-shadow: 0upx -1upx 6upx 0upx rgba(4, 0, 0, 0.06);
  307. .info-view {
  308. font-size: 26upx;
  309. }
  310. .btn-view {
  311. display: flex;
  312. .admin-button-com {
  313. margin: 0 10upx;
  314. }
  315. }
  316. }
  317. }
  318. </style>