list-button.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <template name="button">
  2. <view class="button-template">
  3. <!-- 底部按钮 -->
  4. <view class="button-content">
  5. <view class="btn btn-confirm" v-if="btnState.isConfirm" @click.stop="btnConfirm">操作</view>
  6. </view>
  7. <tui-actionsheet
  8. :show="showActionSheet"
  9. :tips="tips"
  10. :item-list="itemList"
  11. :mask-closable="maskClosable"
  12. :color="color"
  13. :size="size"
  14. :is-cancel="isCancel"
  15. @click="handleClickItem"
  16. @cancel="closeActionSheet"
  17. />
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'button',
  23. props: {
  24. status: {//收款款项类型:1订单款,2非订单款,3返佣款 4订单款或者非订单款(因财务阶段无法区分订单非订单), 5供应商退款 10 平台服务费
  25. type: Number
  26. },
  27. dataInfo: {
  28. type: Object
  29. }
  30. },
  31. data() {
  32. return {
  33. receipt:{},
  34. btnState: this.initStatus(),
  35. mapStateArr: [{ label: 'isConfirm', val: [1,4,5], status: true }],
  36. souStateArr:[
  37. {
  38. type:1,
  39. action:[
  40. { text: '作废',handleId:0},
  41. { text: '设为非订单款',handleId:2},
  42. { text: '设为平台服务费',handleId:10},
  43. { text: '设为供应商退款',handleId:4},
  44. ],
  45. },
  46. {
  47. type:2,
  48. action:[
  49. { text: '作废',handleId:0},
  50. { text: '设为普通款',handleId:1},
  51. { text: '设为平台服务费',handleId:10},
  52. { text: '设为供应商退款',handleId:4}
  53. ],
  54. },
  55. {
  56. type:3,
  57. action:[
  58. { text: '作废',handleId:0},
  59. { text: '设为普通款',handleId:1},
  60. { text: '设为供应商退款',handleId:4}
  61. ],
  62. },
  63. {
  64. type:5,
  65. action:[
  66. { text: '作废',handleId:0},
  67. { text: '设为普通款',handleId:1},
  68. { text: '设为平台服务费',handleId:10}
  69. ],
  70. },
  71. {
  72. type:10,
  73. action:[
  74. { text: '作废',handleId:0},
  75. { text: '设为普通款',handleId:1},
  76. { text: '设为非订单款',handleId:2},
  77. { text: '设为供应商退款',handleId:4}
  78. ],
  79. },
  80. ],
  81. showActionSheet: false,
  82. maskClosable: true,
  83. tips: '',
  84. itemList: [],
  85. color: '#9a9a9a',
  86. size: 24,
  87. isCancel: true
  88. }
  89. },
  90. created() {
  91. this.initData(this.status)
  92. this.initActionSheet(this.dataInfo)
  93. },
  94. computed: {},
  95. watch: {
  96. status: {
  97. handler: function(val) {
  98. this.initData(val)
  99. },
  100. deep: true //对象内部的属性监听,也叫深度监听
  101. },
  102. dataInfo:{
  103. handler: function(val) {
  104. this.initActionSheet(val)
  105. },
  106. deep: true //对象内部的属性监听,也叫深度监听
  107. }
  108. },
  109. methods: {
  110. initData(resVal,dataVal) {
  111. /**
  112. * @按钮根据状态显示
  113. * @收款状态:1待确认、4审核未通过、5收款撤销【线上支付成功为审核通过】
  114. */
  115. this.receipt = dataVal
  116. this.btnState = this.initStatus()
  117. this.mapStateArr.forEach(el => {
  118. el.val.forEach(value => {
  119. if (resVal === value) {
  120. this.btnState[el.label] = el.status
  121. }
  122. })
  123. })
  124. },
  125. initActionSheet(dataVal){
  126. this.receipt = dataVal
  127. this.souStateArr.forEach(el => {
  128. if (dataVal.receiptType === el.type) {
  129. this.itemList = el.action
  130. }
  131. })
  132. },
  133. initStatus() {
  134. let btnState = {
  135. isConfirm: false
  136. }
  137. return btnState
  138. },
  139. handleClickItem(data){
  140. const handleAction = this.handleArrayReturn(data.index)
  141. const receipt ={
  142. handleAction:handleAction,
  143. receipt: this.receipt
  144. }
  145. this.$emit('buttonConfirm',receipt)
  146. this.showActionSheet = false
  147. },
  148. handleArrayReturn(data){// 处理操作后结果
  149. let handleValue = {}
  150. this.souStateArr.forEach(el => {
  151. if(this.receipt.receiptType === el.type){
  152. el.action.forEach((value,index) => {
  153. if (data === index) {
  154. handleValue = value
  155. }
  156. })
  157. }
  158. })
  159. return handleValue
  160. },
  161. btnConfirm() {
  162. this.showActionSheet = true
  163. },
  164. closeActionSheet() {
  165. this.showActionSheet = false
  166. },
  167. // btnConfirm(){
  168. // this.$emit('buttonConfirm',data)
  169. // }
  170. }
  171. }
  172. </script>
  173. <style lang="scss">
  174. .button-template {
  175. width: 100%;
  176. height: auto;
  177. float: left;
  178. background: #ffffff;
  179. .button-content {
  180. width: 100%;
  181. height: auto;
  182. float: left;
  183. position: relative;
  184. .btn {
  185. width: 160rpx;
  186. height: 64rpx;
  187. margin: 10rpx 0 0 0;
  188. line-height: 64rpx;
  189. font-size: $font-size-26;
  190. text-align: center;
  191. border-radius: 32rpx;
  192. float: right;
  193. }
  194. .btn-cancel {
  195. background-color: #f6f6f6;
  196. color: #333333;
  197. }
  198. .btn-delete {
  199. background-color: #f6f6f6;
  200. color: #333333;
  201. }
  202. .btn-query {
  203. background-color: #ff5000;
  204. color: #ffffff;
  205. }
  206. .btn-confirm {
  207. background-color: #4688fa;
  208. color: #ffffff;
  209. }
  210. .btn-pay {
  211. background-color: #4688fa;
  212. color: #ffffff;
  213. margin-right: 0;
  214. }
  215. }
  216. }
  217. .tui-actionsheet-btn{
  218. box-sizing: content-box;
  219. }
  220. </style>