123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217 |
- <template name="button">
- <view class="button-template">
- <!-- 底部按钮 -->
- <view class="button-content">
- <view class="btn btn-confirm" v-if="btnState.isConfirm" @click.stop="btnConfirm">操作</view>
- </view>
- <tui-actionsheet
- :show="showActionSheet"
- :tips="tips"
- :item-list="itemList"
- :mask-closable="maskClosable"
- :color="color"
- :size="size"
- :is-cancel="isCancel"
- @click="handleClickItem"
- @cancel="closeActionSheet"
- ></tui-actionsheet>
- </view>
- </template>
- <script>
- export default {
- name: 'button',
- props: {
- status: {//收款款项类型:1订单款,2非订单款,3返佣款 4订单款或者非订单款(因财务阶段无法区分订单非订单), 5供应商退款
- type: Number
- },
- dataInfo: {
- type: Object
- }
- },
- data() {
- return {
- receipt:{},
- btnState: this.initStatus(),
- mapStateArr: [{ label: 'isConfirm', val: [1], status: true }],
- souStateArr:[
- {
- type:1,
- action:[
- { text: '作废',handleId:0},
- { text: '设为非订单款',handleId:2},
- { text: '设为返佣款',handleId:3},
- { text: '设为供应商退款',handleId:4},
- ],
- },
- {
- type:2,
- action:[
- { text: '作废',handleId:0},
- { text: '设为普通款',handleId:1},
- { text: '设为返佣款',handleId:3},
- { text: '设为供应商退款',handleId:4}
- ],
- },
- {
- type:3,
- action:[
- { text: '作废',handleId:0},
- { text: '设为普通款',handleId:1},
- { text: '设为供应商退款',handleId:4}
- ],
- },
- {
- type:5,
- action:[
- { text: '作废',handleId:0},
- { text: '设为普通款',handleId:1},
- { text: '设为返佣款',handleId:3}
- ],
- },
- ],
- showActionSheet: false,
- maskClosable: true,
- tips: '',
- itemList: [],
- color: '#9a9a9a',
- size: 24,
- isCancel: true
- }
- },
- created() {
- this.initData(this.status)
- this.initActionSheet(this.dataInfo)
- },
- computed: {},
- watch: {
- status: {
- handler: function(val) {
- this.initData(val)
- },
- deep: true //对象内部的属性监听,也叫深度监听
- },
- dataInfo:{
- handler: function(val) {
- this.initActionSheet(val)
- },
- deep: true //对象内部的属性监听,也叫深度监听
- }
- },
- methods: {
- initData(resVal,dataVal) {
- /**
- * @分享按钮统一显示
- * @按钮根据状态显示
- * @(4、5、7、12、22、23、32)显示[查看物流]按钮,其他隐藏
- * @(6)显示[删除订单],其他隐藏
- * @(0、111)显示[取消订单],其他隐藏
- * @(21,31)只显示分享
- * @(13,33)显示[确认收货]和[查看物流]
- */
- this.receipt = dataVal
- this.btnState = this.initStatus()
- this.mapStateArr.forEach(el => {
- el.val.forEach(value => {
- if (resVal === value) {
- this.btnState[el.label] = el.status
- }
- })
- })
- },
- initActionSheet(dataVal){
- this.receipt = dataVal
- this.souStateArr.forEach(el => {
- if (dataVal.receiptType === el.type) {
- this.itemList = el.action
- }
- })
- },
- initStatus() {
- let btnState = {
- isConfirm: false
- }
- return btnState
- },
- handleClickItem(data){
- const handleAction = this.handleArrayReturn(data.index)
- const receipt ={
- handleAction:handleAction,
- receipt: this.receipt
- }
- this.$emit('buttonConfirm',receipt)
- this.showActionSheet = false
- },
- handleArrayReturn(data){// 处理操作后结果
- let handleValue = {}
- this.souStateArr.forEach(el => {
- if(this.receipt.receiptType === el.type){
- el.action.forEach((value,index) => {
- if (data === index) {
- handleValue = value
- }
- })
- }
- })
- return handleValue
- },
- btnConfirm() {
- this.showActionSheet = true
- },
- closeActionSheet() {
- this.showActionSheet = false
- },
- // btnConfirm(){
- // this.$emit('buttonConfirm',data)
- // }
- }
- }
- </script>
- <style lang="scss">
- .button-template {
- width: 100%;
- height: auto;
- float: left;
- background: #ffffff;
- .button-content {
- width: 100%;
- height: auto;
- float: left;
- position: relative;
- .btn {
- width: 160rpx;
- height: 64rpx;
- margin: 10rpx 0 0 0;
- line-height: 64rpx;
- font-size: $font-size-26;
- text-align: center;
- border-radius: 32rpx;
- float: right;
- }
- .btn-cancel {
- background-color: #f6f6f6;
- color: #333333;
- }
- .btn-delete {
- background-color: #f6f6f6;
- color: #333333;
- }
- .btn-query {
- background-color: #ff5000;
- color: #ffffff;
- }
- .btn-confirm {
- background-color: #4688fa;
- color: #ffffff;
- }
- .btn-pay {
- background-color: #4688fa;
- color: #ffffff;
- margin-right: 0;
- }
- }
- }
- .tui-actionsheet-btn{
- box-sizing: content-box;
- }
- </style>
|