index.vue 8.7 KB

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