index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. <template v-if="!form.lockFlag">
  27. <u-form-item label="滞销天数">
  28. <u-input type="number" :min="0" :max="999999" 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" 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. </template>
  35. <u-form-item label="连锁组" v-if="$hasPermissions('M_chainInventory_mobile')"><u-switch slot="right" v-model="form.lockFlag"></u-switch></u-form-item>
  36. </u-form>
  37. <view class="form-footer-btn">
  38. <u-button size="medium" shape="circle" hover-class="none" @click="handleClean">清空</u-button>
  39. <u-button size="medium" hover-class="none" shape="circle" :custom-style="customBtnStyle" @click="handleSearch">查询</u-button>
  40. </view>
  41. </view>
  42. <!-- 产品品牌 -->
  43. <productBrand ref="productBrand" :openModal="brandModal" :itemSn="form.productBrandSn" @choose="brandChoose" @clean="brandClean" @close="brandModal=false" />
  44. <!-- 产品分类 -->
  45. <productType ref="productType" :openModal="showTypeModal" :nowData="nowData" @choose="typeChoose" @clean="typeClean" @close="showTypeModal=false" />
  46. </view>
  47. </template>
  48. <script>
  49. import productBrand from '@/pages/common/productBrand.vue'
  50. import productType from '@/pages/common/productType.vue'
  51. import { dealerProductTypeList } from '@/api/dealerProductType'
  52. import { stockCount } from '@/api/stock'
  53. export default{
  54. components: { productBrand, productType },
  55. data(){
  56. return {
  57. form: {
  58. tenantIdList: [],//门店名称
  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. lockFlag:false,//连锁组
  68. enableFlag: true, // 显示禁用产品
  69. minUnsalableDays: undefined, // 滞销天数最小值
  70. maxUnsalableDays: undefined // 滞销天数最大值
  71. },
  72. totalData: null,
  73. brandModal: false,
  74. brandName: '',
  75. showTypeModal: false,
  76. nowData: {
  77. data: [],
  78. indArr: [],
  79. nowInd: 0
  80. },
  81. customBtnStyle: { // 自定义按钮样式
  82. backgroundColor: this.$config('primaryColor'),
  83. color: '#fff'
  84. },
  85. }
  86. },
  87. computed: {
  88. productTypeNameArr: function() {
  89. let str = ''
  90. this.nowData.data.map(item => {
  91. str += item.productTypeName+' / '
  92. })
  93. return str ? str.substr(0, str.length-3) : ''
  94. }
  95. },
  96. watch: {
  97. 'form.enableFlag' (newValue, oldValue) {
  98. uni.setStorageSync('productEnabledFlag-' + this.$store.state.vuex_userData.orgId, newValue)
  99. },
  100. },
  101. onShow() {
  102. // 是否默认包括禁用产品
  103. const a = uni.getStorageSync('productEnabledFlag-' + this.$store.state.vuex_userData.orgId)
  104. console.log(typeof a == 'boolean')
  105. this.form.enableFlag = typeof a == 'boolean' ? a : true
  106. this.getTotal()
  107. },
  108. methods: {
  109. $message(msg){
  110. uni.showToast({
  111. icon: 'none',
  112. title: msg
  113. })
  114. },
  115. // 校验滞销天数数值范围
  116. checkValueRange () {
  117. if(this.form.lockFlag&&(!this.form.productCode||this.form.productCode&&this.form.productCode.length==0)){
  118. this.$message('请输入产品编码!')
  119. return false
  120. }
  121. const a = !this.form.minUnsalableDays
  122. const b = !this.form.maxUnsalableDays
  123. if(a && !b){
  124. this.$message('请输入滞销天数的起始天数!')
  125. return false
  126. }
  127. if(b && !a){
  128. this.$message('请输入滞销天数的截止天数!')
  129. return false
  130. }
  131. console.log(this.form.minUnsalableDays , this.form.maxUnsalableDays,this.form.minUnsalableDays > this.form.maxUnsalableDays)
  132. if (Number(this.form.minUnsalableDays) > Number(this.form.maxUnsalableDays)) {
  133. this.$message('截止天数应大于起始天数!')
  134. return false
  135. }
  136. this.form.minUnsalableDays = this.form.minUnsalableDays > 999999 ? 999999 : this.form.minUnsalableDays
  137. this.form.maxUnsalableDays = this.form.maxUnsalableDays > 999999 ? 999999 : this.form.maxUnsalableDays
  138. return true
  139. },
  140. // 合计
  141. getTotal () {
  142. stockCount({}).then(res => {
  143. if (res.status == 200 && res.data) {
  144. this.totalData = res.data
  145. } else {
  146. this.totalData = null
  147. }
  148. })
  149. },
  150. // 表单清空
  151. handleClean(){
  152. this.form.tenantIdList=[]
  153. this.form.productCode = ''
  154. this.form.productName = ''
  155. this.form.productOrigCode = ''
  156. this.brandName = ''
  157. this.form.productBrandSn = undefined
  158. this.nowData = {
  159. data: [],
  160. indArr: [],
  161. nowInd: 0
  162. }
  163. this.form.productTypeSn1 = undefined
  164. this.form.productTypeSn2 = undefined
  165. this.form.productTypeSn3 = undefined
  166. this.form.zeroQtyFlag = false
  167. this.form.minUnsalableDays = undefined // 滞销天数最小值
  168. this.form.maxUnsalableDays = undefined // 滞销天数最大值
  169. this.$refs.productBrand.onClean()
  170. },
  171. // 查询
  172. handleSearch(){
  173. if (this.checkValueRange()) {
  174. let params = JSON.parse(JSON.stringify(this.form))
  175. params.zeroQtyFlag = params.zeroQtyFlag ? '0' : ''
  176. params.enableFlag = params.enableFlag ? '' : '1'
  177. if(params.lockFlag){
  178. uni.navigateTo({ url: "/pages/stock/stockSearchGroup?data="+JSON.stringify(params) })
  179. }else{
  180. uni.navigateTo({ url: "/pages/stock/stockSearch?data="+JSON.stringify(params) })
  181. }
  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. .stock-wrap{
  221. width: 100%;
  222. padding: 30upx;
  223. .panel-box {
  224. background-color: #ffffff;
  225. padding: 20upx 20upx;
  226. border-radius: 20upx;
  227. box-shadow: 3upx 2upx 6upx #eee;
  228. margin-bottom: 30upx;
  229. .item-box{
  230. text-align: center;
  231. display: flex;
  232. align-items: center;
  233. justify-content: space-between;
  234. }
  235. }
  236. .stock-con{
  237. background-color: #ffffff;
  238. border-radius: 20upx;
  239. box-shadow: 3upx 2upx 6upx #eee;
  240. padding: 20upx;
  241. .stock-tit{
  242. font-weight: bold;
  243. .u-line{
  244. display: inline-block;
  245. width: 6upx;
  246. height: 30upx;
  247. vertical-align: bottom;
  248. margin: 0 10upx;
  249. border-radius: 5upx;
  250. }
  251. }
  252. .form-footer-btn{
  253. margin: 60upx 30upx 30upx;
  254. display: flex;
  255. justify-content: space-between;
  256. }
  257. .form-footer-btn uni-button{
  258. width: 40%;
  259. margin: 0 auto;
  260. font-size: 30upx;
  261. }
  262. }
  263. }
  264. </style>