index.vue 8.6 KB

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