index.vue 6.2 KB

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