list-button.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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], 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. * @按钮根据状态显示
  105. * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
  106. * @(6)显示[删除订单],其他隐藏
  107. * @(0、111)显示[取消订单],其他隐藏
  108. * @(21,31)只显示分享
  109. * @(13,33)显示[确认收货]和[查看物流]
  110. */
  111. this.receipt = dataVal
  112. this.btnState = this.initStatus()
  113. this.mapStateArr.forEach(el => {
  114. el.val.forEach(value => {
  115. if (resVal === value) {
  116. this.btnState[el.label] = el.status
  117. }
  118. })
  119. })
  120. },
  121. initActionSheet(dataVal){
  122. this.receipt = dataVal
  123. this.souStateArr.forEach(el => {
  124. if (dataVal.receiptType === el.type) {
  125. this.itemList = el.action
  126. }
  127. })
  128. },
  129. initStatus() {
  130. let btnState = {
  131. isConfirm: false
  132. }
  133. return btnState
  134. },
  135. handleClickItem(data){
  136. const handleAction = this.handleArrayReturn(data.index)
  137. const receipt ={
  138. handleAction:handleAction,
  139. receipt: this.receipt
  140. }
  141. this.$emit('buttonConfirm',receipt)
  142. this.showActionSheet = false
  143. },
  144. handleArrayReturn(data){// 处理操作后结果
  145. let handleValue = {}
  146. this.souStateArr.forEach(el => {
  147. if(this.receipt.receiptType === el.type){
  148. el.action.forEach((value,index) => {
  149. if (data === index) {
  150. handleValue = value
  151. }
  152. })
  153. }
  154. })
  155. return handleValue
  156. },
  157. btnConfirm() {
  158. this.showActionSheet = true
  159. },
  160. closeActionSheet() {
  161. this.showActionSheet = false
  162. },
  163. // btnConfirm(){
  164. // this.$emit('buttonConfirm',data)
  165. // }
  166. }
  167. }
  168. </script>
  169. <style lang="scss">
  170. .button-template {
  171. width: 100%;
  172. height: auto;
  173. float: left;
  174. background: #ffffff;
  175. .button-content {
  176. width: 100%;
  177. height: auto;
  178. float: left;
  179. position: relative;
  180. .btn {
  181. width: 160rpx;
  182. height: 64rpx;
  183. margin: 10rpx 0 0 0;
  184. line-height: 64rpx;
  185. font-size: $font-size-26;
  186. text-align: center;
  187. border-radius: 32rpx;
  188. float: right;
  189. }
  190. .btn-cancel {
  191. background-color: #f6f6f6;
  192. color: #333333;
  193. }
  194. .btn-delete {
  195. background-color: #f6f6f6;
  196. color: #333333;
  197. }
  198. .btn-query {
  199. background-color: #ff5000;
  200. color: #ffffff;
  201. }
  202. .btn-confirm {
  203. background-color: #4688fa;
  204. color: #ffffff;
  205. }
  206. .btn-pay {
  207. background-color: #4688fa;
  208. color: #ffffff;
  209. margin-right: 0;
  210. }
  211. }
  212. }
  213. .tui-actionsheet-btn{
  214. box-sizing: content-box;
  215. }
  216. </style>