index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <view class="stock-wrap">
  3. <!-- 统计 -->
  4. <view class="panel-box">
  5. <view class="item-box">
  6. <u-count-to :end-val="totalData&&totalData.totalCurrentStockQty ? totalData.totalCurrentStockQty : 0" separator=","></u-count-to>
  7. <view>库存总数量(个)</view>
  8. </view>
  9. <view class="item-box">
  10. <u-count-to :end-val="totalData&&totalData.totalCurrentStockCost ? totalData.totalCurrentStockCost : 0" separator="," :decimals="2"></u-count-to>
  11. <view>库存总成本(¥)</view>
  12. </view>
  13. </view>
  14. <!-- 库存查询 -->
  15. <view class="stock-con">
  16. <view class="stock-tit">
  17. <view class="u-line"></view>库存查询
  18. </view>
  19. <u-form :model="form" ref="uForm" label-width="180">
  20. <u-form-item label="产品编码"><u-input v-model.trim="form.productCode" placeholder="请输入产品编码" input-align="right" /></u-form-item>
  21. <u-form-item label="原厂编码"><u-input v-model.trim="form.productOrigCode" placeholder="请输入原厂编码" input-align="right" /></u-form-item>
  22. <u-form-item label="产品名称"><u-input v-model.trim="form.productName" placeholder="请输入产品名称" input-align="right" /></u-form-item>
  23. <u-form-item label="产品品牌"><u-input v-model="brandName" @click="brandModal=true" disabled placeholder="请选择产品品牌" input-align="right" /></u-form-item>
  24. <u-form-item label="产品分类"><u-input v-model="productTypeNameArr" @click="showTypeModal=true" disabled placeholder="请选择产品分类" input-align="right" /></u-form-item>
  25. <u-form-item label="只查看有库存"><u-switch slot="right" v-model="form.zeroQtyFlag"></u-switch></u-form-item>
  26. </u-form>
  27. <view class="form-footer-btn">
  28. <u-button size="medium" shape="circle" hover-class="none" @click="handleClean">清空</u-button>
  29. <u-button size="medium" hover-class="none" shape="circle" :custom-style="customBtnStyle" @click="handleSearch">查询</u-button>
  30. </view>
  31. </view>
  32. <!-- 产品品牌 -->
  33. <productBrand :openModal="brandModal" :itemSn="form.productBrandSn" @choose="brandChoose" @clean="brandClean" @close="brandModal=false" />
  34. <!-- 产品分类 -->
  35. <productType :openModal="showTypeModal" :nowData="nowData" @choose="typeChoose" @clean="typeClean" @close="showTypeModal=false" />
  36. </view>
  37. </template>
  38. <script>
  39. import productBrand from '@/pages/common/productBrand.vue'
  40. import productType from '@/pages/common/productType.vue'
  41. import { dealerProductTypeList } from '@/api/dealerProductType'
  42. import { stockCount } from '@/api/stock'
  43. export default{
  44. components: { productBrand, productType },
  45. data(){
  46. return {
  47. form: {
  48. productCode: '', // 产品编码
  49. productName: '', // 产品名称
  50. productOrigCode: '', // 原厂编码
  51. productBrandSn: undefined, // 产品品牌
  52. productTypeSn1: undefined, // 产品分类1
  53. productTypeSn2: undefined, // 产品分类2
  54. productTypeSn3: undefined, // 产品分类3
  55. zeroQtyFlag: false // 库存情况
  56. },
  57. totalData: null,
  58. brandModal: false,
  59. brandName: '',
  60. showTypeModal: false,
  61. nowData: {
  62. data: [],
  63. indArr: [],
  64. nowInd: 0
  65. },
  66. customBtnStyle: { // 自定义按钮样式
  67. backgroundColor: this.$config('primaryColor'),
  68. color: '#fff'
  69. },
  70. }
  71. },
  72. computed: {
  73. productTypeNameArr: function() {
  74. let str = ''
  75. this.nowData.data.map(item => {
  76. str += item.productTypeName+' / '
  77. })
  78. return str ? str.substr(0, str.length-3) : ''
  79. }
  80. },
  81. onLoad() {
  82. const theme = getApp().globalData.theme
  83. uni.setTabBarItem({
  84. "index": 0,
  85. "iconPath": "static/"+theme+"/tabbar/home.png",
  86. "selectedIconPath": "static/"+theme+"/tabbar/home-active.png",
  87. })
  88. uni.setTabBarItem({
  89. "index": 1,
  90. "iconPath": "static/"+theme+"/tabbar/stock.png",
  91. "selectedIconPath": "static/"+theme+"/tabbar/stock-active.png",
  92. })
  93. uni.setTabBarItem({
  94. "index": 2,
  95. "iconPath": "static/"+theme+"/tabbar/shelf.png",
  96. "selectedIconPath": "static/"+theme+"/tabbar/shelf-active.png",
  97. })
  98. uni.setTabBarItem({
  99. "index": 3,
  100. "iconPath": "static/"+theme+"/tabbar/user.png",
  101. "selectedIconPath": "static/"+theme+"/tabbar/user-active.png",
  102. })
  103. uni.setTabBarStyle({
  104. color: this.$config("topBarTitleColors"),
  105. selectedColor: this.$config("primaryColor"),
  106. borderStyle: 'white',
  107. complete: function(res){
  108. console.log(res)
  109. }
  110. })
  111. this.getTotal()
  112. },
  113. methods: {
  114. // 合计
  115. getTotal () {
  116. stockCount({}).then(res => {
  117. if (res.status == 200 && res.data) {
  118. this.totalData = res.data
  119. } else {
  120. this.totalData = null
  121. }
  122. })
  123. },
  124. // 表单清空
  125. handleClean(){
  126. this.form.productCode = ''
  127. this.form.productName = ''
  128. this.form.productOrigCode = ''
  129. this.brandName = ''
  130. this.form.productBrandSn = undefined
  131. this.nowData = {
  132. data: [],
  133. indArr: [],
  134. nowInd: 0
  135. }
  136. this.form.productTypeSn1 = undefined
  137. this.form.productTypeSn2 = undefined
  138. this.form.productTypeSn3 = undefined
  139. this.form.zeroQtyFlag = false
  140. },
  141. // 查询
  142. handleSearch(){
  143. let params = JSON.parse(JSON.stringify(this.form))
  144. if (params.zeroQtyFlag) {
  145. params.zeroQtyFlag = '0'
  146. } else {
  147. params.zeroQtyFlag = ''
  148. }
  149. uni.navigateTo({ url: "/pages/stock/stockSearch?data="+JSON.stringify(params) })
  150. },
  151. // 选择品牌
  152. brandChoose(data){
  153. this.brandName = data.brandName
  154. this.form.productBrandSn = data.brandSn
  155. },
  156. // 清空品牌
  157. brandClean(){
  158. this.brandName = ''
  159. this.form.productBrandSn = undefined
  160. },
  161. // 选择分类
  162. typeChoose(obj){
  163. this.nowData = {
  164. data: obj.data,
  165. indArr: obj.indArr,
  166. nowInd: obj.nowInd
  167. }
  168. this.form.productTypeSn1 = this.nowData.data[0]&&this.nowData.data[0].productTypeSn ? this.nowData.data[0].productTypeSn : undefined
  169. this.form.productTypeSn2 = this.nowData.data[1]&&this.nowData.data[1].productTypeSn ? this.nowData.data[1].productTypeSn : undefined
  170. this.form.productTypeSn3 = this.nowData.data[2]&&this.nowData.data[2].productTypeSn ? this.nowData.data[2].productTypeSn : undefined
  171. },
  172. // 清空分类
  173. typeClean(){
  174. this.nowData = {
  175. data: [],
  176. indArr: [],
  177. nowInd: 0
  178. }
  179. this.form.productTypeSn1 = undefined
  180. this.form.productTypeSn2 = undefined
  181. this.form.productTypeSn3 = undefined
  182. }
  183. }
  184. }
  185. </script>
  186. <style lang="scss">
  187. .stock-wrap{
  188. width: 100%;
  189. padding: 30upx;
  190. .panel-box {
  191. background-color: #ffffff;
  192. padding: 20upx 20upx;
  193. border-radius: 20upx;
  194. box-shadow: 3upx 2upx 6upx #eee;
  195. margin-bottom: 30upx;
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: center;
  199. .item-box{
  200. text-align: center;
  201. width: 50%;
  202. }
  203. .item-box:first-child{
  204. border-right: 1px solid #e4e7ed;
  205. }
  206. }
  207. .stock-con{
  208. background-color: #ffffff;
  209. border-radius: 20upx;
  210. box-shadow: 3upx 2upx 6upx #eee;
  211. padding: 20upx;
  212. .stock-tit{
  213. .u-line{
  214. display: inline-block;
  215. width: 6upx;
  216. height: 40upx;
  217. background-color: red;
  218. vertical-align: bottom;
  219. margin: 0 20upx 0 10upx;
  220. }
  221. }
  222. .form-footer-btn{
  223. margin: 60upx 30upx 30upx;
  224. display: flex;
  225. justify-content: space-between;
  226. }
  227. .form-footer-btn uni-button{
  228. width: 40%;
  229. margin: 0 auto;
  230. font-size: 30upx;
  231. }
  232. }
  233. }
  234. </style>