package com.dxhy.domestic.model.vo;

import java.io.Serializable;
import java.util.List;

import com.dxhy.common.util.AmountFormatUtil;
import com.dxhy.common.util.MathUtil;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * 列表展示页通用标题
 * 
 * @author dxhy
 */
@Data
public class CommonListResponseVO<T> implements Serializable {

    @ApiModelProperty("总条数")
    private Long total;
    @ApiModelProperty("总计税额")
    private String totalTaxAmount;
    @ApiModelProperty("总计金额")
    private String totalAmount;
    @ApiModelProperty("数据列表")
    private List<T> datalist;

    @ApiModelProperty("标题内容")
    private Title titlelist;
    @ApiModelProperty("操作按钮")
    private Operating operating;
    @ApiModelProperty("loading")
    private Boolean listLoading;
    @ApiModelProperty("是否有勾选框")
    private Boolean selection;
    @ApiModelProperty("是否显示序号")
    private Boolean numberSerial;
    @ApiModelProperty("标题名称对应字段宽度")
    private List<String> titlewidth;
    @ApiModelProperty("超出范围是否显示省略")
    private List<Boolean> showOverflowTooltip;
    @ApiModelProperty("是否可输入")
    private List<Boolean> inputfixed;
    @ApiModelProperty("标题名称对应字段图片展示")
    private List<Boolean> iconfixed;
    @ApiModelProperty("标题名称对应字段固定")
    private List<Boolean> titlefixed;

    /**
     * 设置页面标题及其对应参数
     */
    public void setTitleProperties(String[] titleHeaders, String[] titleProperties) {
        if (this.titlelist == null) {
            this.titlelist = new Title();
        }
        this.titlelist.setTitlelist(titleHeaders);
        this.titlelist.setTitleprop(titleProperties);
    }

    public void formatTotalAmount() {
        this.setTotalTaxAmount(AmountFormatUtil.fmtMicrometer(MathUtil.round(this.totalTaxAmount)));
        this.setTotalAmount(AmountFormatUtil.fmtMicrometer(MathUtil.round(this.totalAmount)));
    }

    @Data
    public static class Title {

        @ApiModelProperty("标题名称")
        private String[] titlelist;

        @ApiModelProperty("标题名称对应字段")
        private String[] titleprop;

    }

    @Data
    public static class Operating {

        private String width;

        private Integer[] btn;

        private Boolean showhide;
    }
}
