index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. <template>
  2. <view class="page-wrap">
  3. <view class="pageTabs">
  4. <uni-segmented-control :current="tabIdx" :values="tabs" style-type="text" active-color="#007aff" @clickItem="changeTab" />
  5. </view>
  6. <view class="head">
  7. <uni-section title="物资列表" type="line">
  8. <template v-slot:right>
  9. <view class="handle" @click="linkToRecord">出库/入库记录</view>
  10. </template>
  11. </uni-section>
  12. <view class="addbt" @click="onInbound('in',tabIdx+1)">
  13. <view class="word">物资入库</view>
  14. </view>
  15. </view>
  16. <view class="pageMain">
  17. <uni-card v-for="(item,idx) in items" :key="idx" padding="0">
  18. <template v-slot:title>
  19. <view class="title">
  20. <view class="name">
  21. <uni-tag :text="item.goodsCatTitle" type="primary"></uni-tag>
  22. </view>
  23. <uni-tag :text="`${item.count}`" custom-style="background-color: #ecf5ff; border-color: #d9ecff; color: #409eff;"></uni-tag>
  24. </view>
  25. </template>
  26. <view class="bottom">
  27. <view class="groupName">
  28. <uni-tag :text="item.groupName" type="success" :inverted="true"></uni-tag>
  29. </view>
  30. <div class="handle" @click="onOutbound(item)"><uni-tag text="出库" type="warning" size="normal" /></div>
  31. </view>
  32. </uni-card>
  33. </view>
  34. <CreateBound ref="bound" @success="onBoundSuccess"></CreateBound>
  35. </view>
  36. </template>
  37. <script>
  38. import CreateBound from './components/CreateBound.vue'
  39. import goodsApi from '@/api/goods.js'
  40. export default {
  41. components:{
  42. CreateBound
  43. },
  44. computed:{
  45. goodsType(){
  46. return this.tabIdx+1
  47. }
  48. },
  49. data() {
  50. return {
  51. tabIdx:0,
  52. tabs:['行业物质','镇办物资'],
  53. items:[],
  54. keywords: ""
  55. }
  56. },
  57. onShow() {
  58. this.getData();
  59. this.init()
  60. },
  61. methods: {
  62. changeTab({currentIndex}){
  63. if (this.tabIdx !== currentIndex) {
  64. this.tabIdx = currentIndex
  65. this.getData()
  66. }
  67. },
  68. init(){
  69. if(!uni.getStorageSync('goodsCats')){
  70. goodsApi.getCatByList().then((res)=>{
  71. uni.setStorageSync('goodsCats',res.data)
  72. })
  73. }
  74. },
  75. getData(){
  76. goodsApi.counterByCat({goodsType:this.tabIdx+1}).then((res)=>{
  77. this.items=res.data
  78. })
  79. },
  80. onInbound(){
  81. this.$refs.bound.show({type:'in',item:{goodsType:this.tabIdx+1}})
  82. },
  83. onOutbound(item){
  84. this.$refs.bound.show({type:'out',item:{
  85. ...item,
  86. goodsType:this.tabIdx+1
  87. }})
  88. },
  89. onBoundSuccess(type){
  90. uni.navigateTo({
  91. url:`/pages/goods/record?type=${type}`
  92. })
  93. },
  94. linkToRecord(){
  95. uni.navigateTo({
  96. url:`/pages/goods/record?type=${this.tabIdx+1}`
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style lang="scss" scoped>
  103. .page-wrap{
  104. padding:0 20rpx;
  105. .pageTabs{
  106. background-color: #fff;
  107. }
  108. .head{
  109. margin-top: 20rpx;
  110. .handle{
  111. display: inline-block;
  112. // background-color: #007aff;
  113. color: #777777;
  114. text-align: center;
  115. padding:16rpx 20rpx;
  116. border-radius: 30rpx;
  117. // border: 1px solid #007aff;
  118. font-size: 28rpx;
  119. line-height: 1;
  120. box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  121. }
  122. .addbt{
  123. width: 100rpx;
  124. height: 100rpx;
  125. border-radius: 50%;
  126. color: #fff;
  127. background-color: rgba(64,158,255,0.75);
  128. box-shadow:0 0 10rpx rgba(0,0,0,0.6);
  129. position: fixed;
  130. right: 10rpx;
  131. bottom: 20%;
  132. z-index: 99;
  133. text-align: center;
  134. display: flex;
  135. justify-content: center;
  136. align-items: center;
  137. .word{
  138. width: 80rpx;
  139. height: 80rpx;
  140. border-radius: 50%;
  141. margin: 5rpx auto;
  142. font-size: 28rpx;
  143. letter-spacing: 2px;
  144. display: flex;
  145. justify-content: center;
  146. align-items: center;
  147. }
  148. }
  149. }
  150. .pageMain{
  151. margin-top: 20rpx;
  152. background-color: #f5f5f5;
  153. padding-bottom: 50rpx;
  154. .title{
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. padding-top: 16rpx;
  159. }
  160. .bottom{
  161. display: flex;
  162. justify-content: space-between;
  163. align-items: center;
  164. .handle{
  165. padding: 10px 0 10px 20px;
  166. }
  167. }
  168. }
  169. }
  170. </style>