list-button.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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="itemClick"
  16. @cancel="closeActionSheet"
  17. ></tui-actionsheet>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. name: 'button',
  23. props: {
  24. status: {
  25. type: Number
  26. },
  27. dataInfo: {
  28. type: Object
  29. }
  30. },
  31. data() {
  32. return {
  33. btnState: this.initStatus(),
  34. mapStateArr: [{ label: 'isConfirm', val: [0], status: true }],
  35. souStateArr:[
  36. {
  37. type:1,
  38. action:[
  39. { text: '作废',color: '#2B2B2B' },
  40. { text: '设为返佣款',color: '#2B2B2B' },
  41. { text: '设为供应商退款',color: '#2B2B2B' },
  42. ],
  43. },
  44. {
  45. type:2,
  46. action:[
  47. { text: '作废',color: '#2B2B2B' },
  48. { text: '设为普通款',color: '#2B2B2B' },
  49. { text: '设为返佣款',color: '#2B2B2B' },
  50. { text: '设为供应商退款',color: '#2B2B2B' }
  51. ],
  52. },
  53. {
  54. type:3,
  55. action:[
  56. { text: '作废',color: '#2B2B2B' },
  57. { text: '设为普通款',color: '#2B2B2B' },
  58. { text: '设为供应商退款',color: '#2B2B2B' }
  59. ],
  60. },
  61. {
  62. type:4,
  63. action:[
  64. { text: '作废',color: '#2B2B2B' },
  65. { text: '设为普通款',color: '#2B2B2B' },
  66. { text: '设为返佣款',color: '#2B2B2B' }
  67. ],
  68. },
  69. ],
  70. showActionSheet: false,
  71. maskClosable: true,
  72. tips: '',
  73. itemList: [],
  74. color: '#9a9a9a',
  75. size: 24,
  76. isCancel: true
  77. }
  78. },
  79. created() {
  80. this.initData(this.status,this.dataInfo)
  81. },
  82. computed: {},
  83. watch: {
  84. status: {
  85. handler: function(val) {
  86. this.initData(val)
  87. },
  88. deep: true //对象内部的属性监听,也叫深度监听
  89. }
  90. },
  91. methods: {
  92. initData(resVal,dataVal) {
  93. /**
  94. * @分享按钮统一显示
  95. * @按钮根据状态显示
  96. * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
  97. * @(6)显示[删除订单],其他隐藏
  98. * @(0、111)显示[取消订单],其他隐藏
  99. * @(21,31)只显示分享
  100. * @(13,33)显示[确认收货]和[查看物流]
  101. */
  102. this.btnState = this.initStatus()
  103. this.mapStateArr.forEach(el => {
  104. el.val.forEach(value => {
  105. if (resVal === value) {
  106. this.btnState[el.label] = el.status
  107. }
  108. })
  109. })
  110. this.initActionSheet(dataVal.sourceType)
  111. },
  112. initActionSheet(dataVal){
  113. this.souStateArr.forEach(el => {
  114. if (dataVal === el.type) {
  115. this.itemList = el.action
  116. }
  117. })
  118. },
  119. initStatus() {
  120. let btnState = {
  121. isConfirm: false
  122. }
  123. return btnState
  124. },
  125. btnConfirm() {
  126. this.showActionSheet = true
  127. },
  128. closeActionSheet() {
  129. this.showActionSheet = false
  130. },
  131. // btnConfirm(){
  132. // this.$emit('buttonConfirm',data)
  133. // }
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. .button-template {
  139. width: 100%;
  140. height: auto;
  141. float: left;
  142. background: #ffffff;
  143. .button-content {
  144. width: 100%;
  145. height: auto;
  146. float: left;
  147. position: relative;
  148. .btn {
  149. width: 160rpx;
  150. height: 64rpx;
  151. margin: 10rpx 0 0 0;
  152. line-height: 64rpx;
  153. font-size: $font-size-26;
  154. text-align: center;
  155. border-radius: 6rpx;
  156. float: right;
  157. }
  158. .btn-cancel {
  159. background-color: #f6f6f6;
  160. color: #333333;
  161. }
  162. .btn-delete {
  163. background-color: #f6f6f6;
  164. color: #333333;
  165. }
  166. .btn-query {
  167. background-color: #ff5000;
  168. color: #ffffff;
  169. }
  170. .btn-confirm {
  171. background-color: #4688fa;
  172. color: #ffffff;
  173. }
  174. .btn-pay {
  175. background-color: #4688fa;
  176. color: #ffffff;
  177. margin-right: 0;
  178. }
  179. }
  180. }
  181. .tui-actionsheet-btn{
  182. box-sizing: content-box;
  183. }
  184. </style>