record.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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="pageMain">
  7. <uni-swipe-action class="item-action-box">
  8. <uni-card padding="10px 0" margin="5px 0" v-for="item in items" :key="item.memberId">
  9. <uni-swipe-action-item class="item-action" :auto-close="true">
  10. <template v-slot:right>
  11. <view class="slot-button">
  12. <view class="bt edit" @click="handle({type:'edit',item})"><text class="slot-button-text">编辑</text></view>
  13. <view class="bt del" @click="handle({type:'del',item})"><text class="slot-button-text">删除</text></view>
  14. </view>
  15. </template>
  16. <view class="item" @click="handle({type:'detail',item})">
  17. <view class="title">
  18. <view class="name">{{item.accountName}}</view>
  19. <view class="num">
  20. <uni-tag :text="`${item.qty}`" custom-style="background-color: #ecf5ff; border-color: #d9ecff; color: #409eff;"></uni-tag>
  21. </view>
  22. </view>
  23. <view class="tagbox">
  24. <uni-tag :text="item.goodsCatTitle" custom-style="background-color: #ecf5ff; border-color: #d9ecff; color: #409eff;"></uni-tag>
  25. </view>
  26. <view class="bottom">
  27. <view class="time">{{item.time}}</view>
  28. </view>
  29. </view>
  30. </uni-swipe-action-item>
  31. </uni-card>
  32. </uni-swipe-action>
  33. </view>
  34. <RecordDetail ref="detail"></RecordDetail>
  35. <RecordEdit ref="edit" @success="reload"></RecordEdit>
  36. </view>
  37. </template>
  38. <script>
  39. import goodsApi from '@/api/goods.js'
  40. import RecordDetail from './components/RecordDetail.vue'
  41. import RecordEdit from './components/RecordEdit.vue'
  42. export default {
  43. components:{
  44. RecordDetail,
  45. RecordEdit
  46. },
  47. data() {
  48. return {
  49. tabIdx:0,
  50. tabs:['入库记录','出库记录'],
  51. items:[],
  52. goodsType:undefined,
  53. page:1,
  54. limit:10,
  55. total:0,
  56. keywords:""
  57. }
  58. },
  59. onLoad({type}) {
  60. this.goodsType=type
  61. this.tabIdx=type- 1
  62. this.resetFilter()
  63. this.getData()
  64. },
  65. methods: {
  66. changeTab({currentIndex}){
  67. if (this.tabIdx !== currentIndex) {
  68. this.tabIdx = currentIndex
  69. this.resetFilter()
  70. this.getData()
  71. }
  72. },
  73. reload(){
  74. this.resetFilter()
  75. this.getData()
  76. },
  77. getData(){
  78. const getByPage=this.tabIdx===0?goodsApi.getInboundByPage:goodsApi.getOutboundByPage
  79. const items=JSON.parse(JSON.stringify(this.items))
  80. getByPage({
  81. page:this.page,
  82. limit:this.limit,
  83. goodsType:this.goodsType
  84. }).then((res)=>{
  85. let data=res.data.map((item)=>{
  86. return{
  87. ...item,
  88. time:this.tabIdx===0?item.inboundTime:item.outboundTime,
  89. }
  90. })
  91. this.items=items.concat(data)
  92. this.total=res.total
  93. })
  94. },
  95. handle({type,item}){
  96. let goodsRecordType=this.tabIdx===0?'in':'out';
  97. let id=this.tabIdx===0?item.inboundId:item.outboundId
  98. const self=this;
  99. if(type==='del'){
  100. uni.showModal({
  101. title: '提示',
  102. content: '是否确定删除',
  103. success: function (res) {
  104. if (res.confirm) {
  105. const deleteBoundById=goodsRecordType==='in'?goodsApi.deleteInboundById:goodsApi.deleteOutboundById;
  106. deleteBoundById(id).then(()=>{
  107. uni.showToast({
  108. title:'删除成功!',
  109. icon:'none'
  110. })
  111. self.resetFilter()
  112. self.getData()
  113. })
  114. }
  115. }
  116. });
  117. }else{
  118. if(type==='detail'){
  119. this.$refs.detail.show(goodsRecordType,id)
  120. }
  121. if(type==='edit'){
  122. this.$refs.edit.show({type:goodsRecordType,item})
  123. }
  124. }
  125. },
  126. resetFilter(){
  127. this.page = 1
  128. this.limit = 10
  129. this.total = 0
  130. this.items=[]
  131. }
  132. },
  133. onReachBottom() {
  134. if(this.total>this.size*this.page){
  135. this.page++
  136. this.getData()
  137. }
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .page-wrap{
  143. padding:0 20rpx;
  144. .pageTabs{
  145. background-color: #fff;
  146. }
  147. .pageMain{
  148. margin-top: 20rpx;
  149. background-color: #f5f5f5;
  150. padding-bottom: 50rpx;
  151. .item{
  152. .title{
  153. display: flex;
  154. justify-content: space-between;
  155. align-items: center;
  156. .name{
  157. font-size: 36rpx;
  158. color: #222222;
  159. font-weight: 500;
  160. }
  161. .num{
  162. font-size: 32rpx;
  163. color: #424242;
  164. }
  165. }
  166. .tagbox{
  167. font-size: 24rpx;
  168. color: #666666;
  169. padding: 14rpx 0;
  170. }
  171. .bottom{
  172. .time{
  173. font-size: 24rpx;
  174. color: #666666;
  175. }
  176. }
  177. }
  178. .slot-button{
  179. width: 400rpx;
  180. height: 100%;
  181. display: flex;
  182. flex-direction: row;
  183. justify-content: center;
  184. align-items: center;
  185. color: #fff;
  186. padding-left: 10px;
  187. .bt{
  188. width: 50%;
  189. height: 100%;
  190. font-size: 30rpx;
  191. box-sizing: border-box;
  192. display: flex;
  193. justify-content: center;
  194. align-items: center;
  195. &.edit{
  196. background-color:#007aff;
  197. }
  198. &.del{
  199. background-color:#F56C6C;
  200. }
  201. &.detail{
  202. background-color: #e6a23c;
  203. }
  204. }
  205. }
  206. }
  207. }
  208. </style>