record.vue 5.6 KB

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