index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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" :cats="goodsCats"></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. goodsCats:uni.getStorageSync('goodsCats')||[],
  55. keywords: ""
  56. }
  57. },
  58. onShow() {
  59. this.getData();
  60. this.init()
  61. },
  62. methods: {
  63. changeTab({currentIndex}){
  64. if (this.tabIdx !== currentIndex) {
  65. this.tabIdx = currentIndex
  66. this.getData()
  67. }
  68. },
  69. init(){
  70. if(!uni.getStorageSync('goodsCats')){
  71. goodsApi.getCatByList().then((res)=>{
  72. uni.setStorageSync('goodsCats',res.data)
  73. this.goodsCats=res.data
  74. })
  75. }
  76. },
  77. getData(){
  78. goodsApi.counterByCat({goodsType:this.tabIdx+1}).then((res)=>{
  79. this.items=res.data
  80. })
  81. },
  82. onInbound(){
  83. this.$refs.bound.show({type:'in',item:{goodsType:this.tabIdx+1}})
  84. },
  85. onOutbound(item){
  86. this.$refs.bound.show({type:'out',item:{
  87. ...item,
  88. goodsType:this.tabIdx+1
  89. }})
  90. },
  91. onBoundSuccess(type){
  92. uni.navigateTo({
  93. url:`/packageA/pages/goods/record?type=${type}`
  94. })
  95. },
  96. linkToRecord(){
  97. uni.navigateTo({
  98. url:`/packageA/pages/goods/record?type=${this.tabIdx+1}`
  99. })
  100. }
  101. }
  102. }
  103. </script>
  104. <style lang="scss" scoped>
  105. .page-wrap{
  106. padding:0 20rpx;
  107. .pageTabs{
  108. background-color: #fff;
  109. }
  110. .head{
  111. margin-top: 20rpx;
  112. .handle{
  113. display: inline-block;
  114. // background-color: #007aff;
  115. color: #777777;
  116. text-align: center;
  117. padding:16rpx 20rpx;
  118. border-radius: 30rpx;
  119. // border: 1px solid #007aff;
  120. font-size: 28rpx;
  121. line-height: 1;
  122. box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
  123. }
  124. .addbt{
  125. width: 100rpx;
  126. height: 100rpx;
  127. border-radius: 50%;
  128. color: #fff;
  129. background-color: rgba(64,158,255,0.75);
  130. box-shadow:0 0 10rpx rgba(0,0,0,0.6);
  131. position: fixed;
  132. right: 10rpx;
  133. bottom: 20%;
  134. z-index: 99;
  135. text-align: center;
  136. display: flex;
  137. justify-content: center;
  138. align-items: center;
  139. .word{
  140. width: 80rpx;
  141. height: 80rpx;
  142. border-radius: 50%;
  143. margin: 5rpx auto;
  144. font-size: 28rpx;
  145. letter-spacing: 2px;
  146. display: flex;
  147. justify-content: center;
  148. align-items: center;
  149. }
  150. }
  151. }
  152. .pageMain{
  153. margin-top: 20rpx;
  154. background-color: #f5f5f5;
  155. padding-bottom: 50rpx;
  156. .title{
  157. display: flex;
  158. justify-content: space-between;
  159. align-items: center;
  160. padding-top: 16rpx;
  161. }
  162. .bottom{
  163. display: flex;
  164. justify-content: space-between;
  165. align-items: center;
  166. .handle{
  167. padding: 10px 0 10px 20px;
  168. }
  169. }
  170. }
  171. }
  172. </style>