record.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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.getData()
  62. },
  63. methods: {
  64. changeTab({currentIndex}){
  65. if (this.tabIdx !== currentIndex) {
  66. this.tabIdx = currentIndex
  67. this.resetFilter()
  68. this.getData()
  69. }
  70. },
  71. reload(){
  72. this.resetFilter()
  73. this.getData()
  74. },
  75. getData(){
  76. const getByPage=this.tabIdx===0?goodsApi.getInboundByPage:goodsApi.getOutboundByPage
  77. const items=JSON.parse(JSON.stringify(this.items))
  78. getByPage({
  79. page:this.page,
  80. limit:this.limit,
  81. goodsType:this.goodsType
  82. }).then((res)=>{
  83. let data=res.data.map((item)=>{
  84. return{
  85. ...item,
  86. time:this.tabIdx===0?item.inboundTime:item.outboundTime,
  87. }
  88. })
  89. this.items=items.concat(data)
  90. this.total=res.total
  91. })
  92. },
  93. handle({type,item}){
  94. let goodsRecordType=this.tabIdx===0?'in':'out';
  95. let id=this.tabIdx===0?item.inboundId:item.outboundId
  96. const self=this;
  97. if(type==='del'){
  98. uni.showModal({
  99. title: '提示',
  100. content: '是否确定删除',
  101. success: function (res) {
  102. if (res.confirm) {
  103. const deleteBoundById=goodsRecordType==='in'?goodsApi.deleteInboundById:goodsApi.deleteOutboundById;
  104. deleteBoundById(id).then(()=>{
  105. uni.showToast({
  106. title:'删除成功!',
  107. icon:'none'
  108. })
  109. self.resetFilter()
  110. self.getData()
  111. })
  112. }
  113. }
  114. });
  115. }else{
  116. if(type==='detail'){
  117. this.$refs.detail.show(goodsRecordType,id)
  118. }
  119. if(type==='edit'){
  120. this.$refs.edit.show({type:goodsRecordType,item})
  121. }
  122. }
  123. },
  124. resetFilter(){
  125. this.page = 1
  126. this.limit = 10
  127. this.total = 0
  128. this.items=[]
  129. }
  130. },
  131. onReachBottom() {
  132. if(this.total>this.size*this.page){
  133. this.page++
  134. this.getData()
  135. }
  136. }
  137. }
  138. </script>
  139. <style lang="scss" scoped>
  140. .page-wrap{
  141. padding:0 20rpx;
  142. .pageTabs{
  143. background-color: #fff;
  144. }
  145. .pageMain{
  146. margin-top: 20rpx;
  147. background-color: #f5f5f5;
  148. padding-bottom: 50rpx;
  149. .item{
  150. .title{
  151. display: flex;
  152. justify-content: space-between;
  153. align-items: center;
  154. .name{
  155. font-size: 36rpx;
  156. color: #222222;
  157. font-weight: 500;
  158. }
  159. .num{
  160. font-size: 32rpx;
  161. color: #424242;
  162. }
  163. }
  164. .tagbox{
  165. font-size: 24rpx;
  166. color: #666666;
  167. padding: 14rpx 0;
  168. }
  169. .bottom{
  170. .time{
  171. font-size: 24rpx;
  172. color: #666666;
  173. }
  174. }
  175. }
  176. .slot-button{
  177. width: 400rpx;
  178. height: 100%;
  179. display: flex;
  180. flex-direction: row;
  181. justify-content: center;
  182. align-items: center;
  183. color: #fff;
  184. padding-left: 10px;
  185. .bt{
  186. width: 50%;
  187. height: 100%;
  188. font-size: 30rpx;
  189. box-sizing: border-box;
  190. display: flex;
  191. justify-content: center;
  192. align-items: center;
  193. &.edit{
  194. background-color:#007aff;
  195. }
  196. &.del{
  197. background-color:#F56C6C;
  198. }
  199. &.detail{
  200. background-color: #e6a23c;
  201. }
  202. }
  203. }
  204. }
  205. }
  206. </style>