index.vue 8.4 KB

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