index.vue 9.3 KB

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