index.vue 6.9 KB

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