index.vue 8.8 KB

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