index.vue 6.4 KB

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