index.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. this.getTotal()
  83. },
  84. methods: {
  85. // 合计
  86. getTotal () {
  87. stockCount({}).then(res => {
  88. if (res.status == 200 && res.data) {
  89. this.totalData = res.data
  90. } else {
  91. this.totalData = null
  92. }
  93. })
  94. },
  95. // 表单清空
  96. handleClean(){
  97. this.form.productCode = ''
  98. this.form.productName = ''
  99. this.form.productOrigCode = ''
  100. this.brandName = ''
  101. this.form.productBrandSn = undefined
  102. this.nowData = {
  103. data: [],
  104. indArr: [],
  105. nowInd: 0
  106. }
  107. this.form.productTypeSn1 = undefined
  108. this.form.productTypeSn2 = undefined
  109. this.form.productTypeSn3 = undefined
  110. this.form.zeroQtyFlag = false
  111. },
  112. // 查询
  113. handleSearch(){
  114. let params = JSON.parse(JSON.stringify(this.form))
  115. if (params.zeroQtyFlag) {
  116. params.zeroQtyFlag = '0'
  117. } else {
  118. params.zeroQtyFlag = ''
  119. }
  120. uni.navigateTo({ url: "/pages/stock/stockSearch?data="+JSON.stringify(params) })
  121. },
  122. // 选择品牌
  123. brandChoose(data){
  124. this.brandName = data.brandName
  125. this.form.productBrandSn = data.brandSn
  126. },
  127. // 清空品牌
  128. brandClean(){
  129. this.brandName = ''
  130. this.form.productBrandSn = undefined
  131. },
  132. // 选择分类
  133. typeChoose(obj){
  134. this.nowData = {
  135. data: obj.data,
  136. indArr: obj.indArr,
  137. nowInd: obj.nowInd
  138. }
  139. this.form.productTypeSn1 = this.nowData.data[0]&&this.nowData.data[0].productTypeSn ? this.nowData.data[0].productTypeSn : undefined
  140. this.form.productTypeSn2 = this.nowData.data[1]&&this.nowData.data[1].productTypeSn ? this.nowData.data[1].productTypeSn : undefined
  141. this.form.productTypeSn3 = this.nowData.data[2]&&this.nowData.data[2].productTypeSn ? this.nowData.data[2].productTypeSn : undefined
  142. },
  143. // 清空分类
  144. typeClean(){
  145. this.nowData = {
  146. data: [],
  147. indArr: [],
  148. nowInd: 0
  149. }
  150. this.form.productTypeSn1 = undefined
  151. this.form.productTypeSn2 = undefined
  152. this.form.productTypeSn3 = undefined
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss">
  158. .stock-wrap{
  159. width: 100%;
  160. padding: 30upx;
  161. .panel-box {
  162. background-color: #ffffff;
  163. padding: 20upx 20upx;
  164. border-radius: 20upx;
  165. box-shadow: 3upx 2upx 6upx #eee;
  166. margin-bottom: 30upx;
  167. display: flex;
  168. justify-content: space-between;
  169. align-items: center;
  170. .item-box{
  171. text-align: center;
  172. width: 50%;
  173. }
  174. .item-box:first-child{
  175. border-right: 1px solid #e4e7ed;
  176. }
  177. }
  178. .stock-con{
  179. background-color: #ffffff;
  180. border-radius: 20upx;
  181. box-shadow: 3upx 2upx 6upx #eee;
  182. padding: 20upx;
  183. .stock-tit{
  184. .u-line{
  185. display: inline-block;
  186. width: 6upx;
  187. height: 40upx;
  188. background-color: red;
  189. vertical-align: bottom;
  190. margin: 0 20upx 0 10upx;
  191. }
  192. }
  193. .form-footer-btn{
  194. margin: 60upx 30upx 30upx;
  195. display: flex;
  196. justify-content: space-between;
  197. }
  198. .form-footer-btn uni-button{
  199. width: 40%;
  200. margin: 0 auto;
  201. font-size: 30upx;
  202. }
  203. }
  204. }
  205. </style>