<template>
  <view class="u-flex bottom" :style="customStyle">
	 <view class="select-view">
		<view class="u-flex bottom-left" v-if="showChecked">
		  <view class="left-list"><u-checkbox icon-size="30" size="40" v-model="checked" @change="selectAll" shape="circle"/></view>
		  <view class="left-list">全选</view>
		</view>
		<view class="u-flex bottom-center">
		  <view class="center-list">已选择 {{ partNum }} 种</view>
		  <view class="center-list">合计：<text class="num"> {{ num }} </text> 件</view>
		</view>
	</view>
    <view class="u-flex bottom-right">
      <button :class="['btn', btnActive]" @click="submit">{{ submitTxt }}</button>
    </view>
  </view>
</template>

<script>
	export default {
		props: {
      showChecked: { // 是否显示勾选
        type: Boolean,
        default() {
          return true
        }
      },
			allChecked: { // 是否全选
				type: Boolean,
        default() {
          return false
        }
			},
      btnStatus: { // 确定按钮是否可点击
				type: Boolean,
        default() {
          return false
        }
			},
			partNum: { // 配件数量
				type: Number,
				default () {
					return 0
				}
			},
      num: { // 合计总件数
        type: Number,
				default () {
					return 0
				}
      },
      submitTxt: { // 提交按钮文字
        type: String,
        default () {
					return '确定'
				}
      }
		},
		customStyle: {
			type: String,
			default: 'background-color: #FFFFFF;padding: 0 30rpx;'
		},
		data() {
			return {
        checked: false
			}
		},
    computed: {
      btnActive() {
        return this.btnStatus ? 'btn-active' : ''
      }
    },
    watch: {
      'allChecked': function(newValue, oldValue) {
        if (this.showChecked) this.checked = newValue
      }
    },
		created() {
      if (this.showChecked) this.checked = this.allChecked
		},
		methods: {
      selectAll(event) {
        this.$emit('select', event.value)
      },
			submit() {
        if (this.btnStatus) this.$emit('submit')
      }
		}
	}
</script>
<style scoped lang="scss">
	.bottom {
    width: 100%;
    height: 180rpx;
    // background: #fff;
    justify-content: space-between;
    .u-flex {
      flex-direction: column;
      align-items: center;
    }
	.select-view {
		display: flex;
		align-items: center;
	}
    .bottom-left {
      // margin-left: 30rpx;
      .left-list {
        width: 100%;
        &:nth-of-type(1) {
          padding-left: 3rpx;
        }
        &:nth-of-type(2) {
		  margin-top: 8rpx;
		  font-size: 20rpx;
        }
      }
    }
    .bottom-center {
      flex: 1;
      align-items: flex-start;
      // margin: 0 20rpx;
      .center-list {
        &:nth-of-type(1) {
          color: #666;
          font-size: 26rpx;
        }
        &:nth-of-type(2) {
          color: #333;
          font-size: 32rpx;
          margin-top: 8rpx;
		  font-weight: bold;
          .num {
            color: #2272FF;
            padding-right: 10rpx;
          }
        }
      }
    }
    .bottom-right {
      width: 360rpx;
      // margin-right: 20rpx;
      .btn {
        width: 100%;
        padding: 30rpx;
        border-radius: 52rpx;
        line-height: 44rpx;
        font-size: 32rpx;
        text-align: center;
        background: #D1D4D4;
        color: #fff;
        &::after {
          content: '';
          height: 0;
          border: none;
        }
      }
      .btn-active {
        background: #2272ff;
      }
    }
  }
</style>
