index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <view class="stock-wrap">
  3. <!-- 统计 -->
  4. <view class="panel-box" v-if="totalData&&$hasPermissions('M_stockTj_mobile')">
  5. <view class="item-box">
  6. <view>库存总数量(个)</view>
  7. <u-count-to :end-val="totalData&&totalData.totalCurrentStockQty ? totalData.totalCurrentStockQty : 0" separator=","></u-count-to>
  8. </view>
  9. <view class="item-box" v-if="$hasPermissions('M_showCostPrice_mobile')">
  10. <view>库存总成本(¥)</view>
  11. <u-count-to :end-val="totalData&&totalData.totalCurrentStockCost ? totalData.totalCurrentStockCost : 0" separator="," :decimals="2"></u-count-to>
  12. </view>
  13. </view>
  14. <!-- 库存查询 -->
  15. <view class="stock-con" v-if="$hasPermissions('M_stockQuery_mobile')">
  16. <view class="stock-tit flex align_center">
  17. <view class="u-line" :style="{background: '#335fb6'}"></view>
  18. 库存查询
  19. </view>
  20. <u-form :model="form" ref="uForm" label-width="100">
  21. <u-form-item label="产品编码"><u-input v-model.trim="form.productCode" border="bottom" placeholder="请输入产品编码" input-align="right" /></u-form-item>
  22. <u-form-item label="条形码"><u-input v-model.trim="form.qrCode" border="bottom" placeholder="请输入条形码" input-align="right" /></u-form-item>
  23. <u-form-item label="原厂编码"><u-input v-model.trim="form.productOrigCode" border="bottom" placeholder="请输入原厂编码" input-align="right" /></u-form-item>
  24. <u-form-item label="产品名称"><u-input v-model.trim="form.productName" border="bottom" placeholder="请输入产品名称" input-align="right" /></u-form-item>
  25. <u-form-item label="产品品牌" @click="brandModal=true"><u-input v-model="brandName" border="bottom" readonly placeholder="请选择产品品牌" input-align="right" /></u-form-item>
  26. <u-form-item label="产品分类" @click="showTypeModal=true"><u-input v-model="productTypeNameArr" border="bottom" readonly placeholder="请选择产品分类" input-align="right" /></u-form-item>
  27. <u-form-item label="滞销天数">
  28. <u-input type="number" :min="0" :max="999999" border="bottom" v-model.trim="form.minUnsalableDays" placeholder="起始天数" input-align="left" />
  29. <text style="display: block;text-align: center;line-height: 32px;"></text>
  30. <u-input type="number" :min="0" :max="999999" border="bottom" v-model.trim="form.maxUnsalableDays" placeholder="截止天数" input-align="right" />
  31. </u-form-item>
  32. <u-form-item label="只查看有库存"><u-switch slot="right" v-model="form.zeroQtyFlag"></u-switch></u-form-item>
  33. <u-form-item label="包括禁用产品"><u-switch slot="right" v-model="form.enableFlag"></u-switch></u-form-item>
  34. </u-form>
  35. <view class="form-footer-btn">
  36. <u-button size="medium" shape="circle" hover-class="none" @click="handleClean">清空</u-button>
  37. <u-button size="medium" hover-class="none" shape="circle" :custom-style="customBtnStyle" @click="handleSearch">查询</u-button>
  38. </view>
  39. </view>
  40. <!-- 产品品牌 -->
  41. <productBrand ref="productBrand" :openModal="brandModal" :itemSn="form.productBrandSn" @choose="brandChoose" @clean="brandClean" @close="brandModal=false" />
  42. <!-- 产品分类 -->
  43. <productType ref="productType" :openModal="showTypeModal" :nowData="nowData" @choose="typeChoose" @clean="typeClean" @close="showTypeModal=false" />
  44. </view>
  45. </template>
  46. <script>
  47. import productBrand from '@/pages/common/productBrand.vue'
  48. import productType from '@/pages/common/productType.vue'
  49. import { dealerProductTypeList , stockCount } from '@/config/api'
  50. export default{
  51. components: { productBrand, productType },
  52. data(){
  53. return {
  54. form: {
  55. productCode: '', // 产品编码
  56. qrCode: '', // 挑选码
  57. productName: '', // 产品名称
  58. productOrigCode: '', // 原厂编码
  59. productBrandSn: undefined, // 产品品牌
  60. productTypeSn1: undefined, // 产品分类1
  61. productTypeSn2: undefined, // 产品分类2
  62. productTypeSn3: undefined, // 产品分类3
  63. zeroQtyFlag: false ,// 库存情况
  64. enableFlag: true, // 显示禁用产品
  65. minUnsalableDays: undefined, // 滞销天数最小值
  66. maxUnsalableDays: undefined // 滞销天数最大值
  67. },
  68. totalData: null,
  69. brandModal: false,
  70. brandName: '',
  71. showTypeModal: false,
  72. nowData: {
  73. data: [],
  74. indArr: [],
  75. nowInd: 0
  76. },
  77. customBtnStyle: { // 自定义按钮样式
  78. backgroundColor: '#335fb6',
  79. color: '#fff'
  80. },
  81. }
  82. },
  83. computed: {
  84. productTypeNameArr: function() {
  85. let str = ''
  86. this.nowData.data.map(item => {
  87. str += item.productTypeName+' / '
  88. })
  89. return str ? str.substr(0, str.length-3) : ''
  90. }
  91. },
  92. watch: {
  93. 'form.enableFlag' (newValue, oldValue) {
  94. uni.setStorageSync('productEnabledFlag-' + this.$store.state.vuex_userData.orgId, newValue)
  95. },
  96. },
  97. onShow() {
  98. // 是否默认包括禁用产品
  99. const a = uni.getStorageSync('productEnabledFlag-' + this.$store.state.vuex_userData.orgId)
  100. console.log(typeof a == 'boolean')
  101. this.form.enableFlag = typeof a == 'boolean' ? a : true
  102. this.getTotal()
  103. },
  104. methods: {
  105. $message(msg){
  106. uni.showToast({
  107. icon: 'none',
  108. title: msg
  109. })
  110. },
  111. // 校验滞销天数数值范围
  112. checkValueRange () {
  113. const a = !this.form.minUnsalableDays
  114. const b = !this.form.maxUnsalableDays
  115. if(a && !b){
  116. this.$message('请输入滞销天数的起始天数!')
  117. return false
  118. }
  119. if(b && !a){
  120. this.$message('请输入滞销天数的截止天数!')
  121. return false
  122. }
  123. console.log(this.form.minUnsalableDays , this.form.maxUnsalableDays,this.form.minUnsalableDays > this.form.maxUnsalableDays)
  124. if (Number(this.form.minUnsalableDays) > Number(this.form.maxUnsalableDays)) {
  125. this.$message('截止天数应大于起始天数!')
  126. return false
  127. }
  128. this.form.minUnsalableDays = this.form.minUnsalableDays > 999999 ? 999999 : this.form.minUnsalableDays
  129. this.form.maxUnsalableDays = this.form.maxUnsalableDays > 999999 ? 999999 : this.form.maxUnsalableDays
  130. return true
  131. },
  132. // 合计
  133. getTotal () {
  134. stockCount({}).then(res => {
  135. if (res.status == 200 && res.data) {
  136. this.totalData = res.data
  137. } else {
  138. this.totalData = null
  139. }
  140. })
  141. },
  142. // 表单清空
  143. handleClean(){
  144. this.form.productCode = ''
  145. this.form.qrCode = ''
  146. this.form.productName = ''
  147. this.form.productOrigCode = ''
  148. this.brandName = ''
  149. this.form.productBrandSn = undefined
  150. this.nowData = {
  151. data: [],
  152. indArr: [],
  153. nowInd: 0
  154. }
  155. this.form.productTypeSn1 = undefined
  156. this.form.productTypeSn2 = undefined
  157. this.form.productTypeSn3 = undefined
  158. this.form.zeroQtyFlag = false
  159. this.form.minUnsalableDays = undefined // 滞销天数最小值
  160. this.form.maxUnsalableDays = undefined // 滞销天数最大值
  161. this.$refs.productBrand.onClean()
  162. },
  163. // 查询
  164. handleSearch(){
  165. if (this.checkValueRange()) {
  166. let params = JSON.parse(JSON.stringify(this.form))
  167. params.zeroQtyFlag = params.zeroQtyFlag ? '0' : ''
  168. params.enableFlag = params.enableFlag ? '' : '1'
  169. uni.navigateTo({ url: "/pages/stock/stockSearch?data="+JSON.stringify(params) })
  170. }
  171. },
  172. // 选择品牌
  173. brandChoose(data){
  174. this.brandName = data.brandName
  175. this.form.productBrandSn = data.brandSn
  176. },
  177. // 清空品牌
  178. brandClean(){
  179. this.brandName = ''
  180. this.form.productBrandSn = undefined
  181. },
  182. // 选择分类
  183. typeChoose(obj){
  184. this.nowData = {
  185. data: obj.data,
  186. indArr: obj.indArr,
  187. nowInd: obj.nowInd
  188. }
  189. this.form.productTypeSn1 = this.nowData.data[0]&&this.nowData.data[0].productTypeSn ? this.nowData.data[0].productTypeSn : undefined
  190. this.form.productTypeSn2 = this.nowData.data[1]&&this.nowData.data[1].productTypeSn ? this.nowData.data[1].productTypeSn : undefined
  191. this.form.productTypeSn3 = this.nowData.data[2]&&this.nowData.data[2].productTypeSn ? this.nowData.data[2].productTypeSn : undefined
  192. },
  193. // 清空分类
  194. typeClean(){
  195. this.nowData = {
  196. data: [],
  197. indArr: [],
  198. nowInd: 0
  199. }
  200. this.form.productTypeSn1 = undefined
  201. this.form.productTypeSn2 = undefined
  202. this.form.productTypeSn3 = undefined
  203. }
  204. }
  205. }
  206. </script>
  207. <style lang="scss">
  208. page{
  209. background: #f8f8f8;
  210. }
  211. .stock-wrap{
  212. padding: 0 30upx;
  213. .panel-box {
  214. background-color: #ffffff;
  215. padding: 20upx 20upx;
  216. border-radius: 20upx;
  217. .item-box{
  218. text-align: center;
  219. display: flex;
  220. align-items: center;
  221. justify-content: space-between;
  222. font-size: 14px;
  223. }
  224. margin-bottom: 20upx;
  225. }
  226. .stock-con{
  227. background-color: #ffffff;
  228. padding: 20upx;
  229. border-radius: 20upx;
  230. .stock-tit{
  231. font-weight: bold;
  232. .u-line{
  233. display: inline-block;
  234. width: 6upx;
  235. height: 30upx;
  236. vertical-align: bottom;
  237. margin: 0 10upx;
  238. border-radius: 5upx;
  239. }
  240. border-bottom: 1px solid #eee;
  241. }
  242. .form-footer-btn{
  243. margin: 60upx 30upx 30upx;
  244. display: flex;
  245. justify-content: space-between;
  246. }
  247. .form-footer-btn uni-button{
  248. width: 40%;
  249. margin: 0 auto;
  250. font-size: 30upx;
  251. }
  252. }
  253. }
  254. </style>