list-button.vue 4.4 KB

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