package com.engine.salary.util;

import com.api.browser.bean.SearchConditionItem;
import com.api.browser.bean.SearchConditionOption;
import com.api.browser.util.ConditionFactory;
import com.api.browser.util.ConditionType;
import weaver.hrm.User;

import java.util.List;



/**
 * @Author weaver_cl
 * @Description:
 * @Version V1.0
 **/
public class SalaryFormItemUtil {

    /**
     * 下拉框
     * @param user
     * @param selectOptions
     * @param colSpan
     * @param fieldcol
     * @param labelcol
     * @param isQuickSearch
     * @param label
     * @return
     */
    public static SearchConditionItem selectItem(User user, List<SearchConditionOption> selectOptions, int colSpan, int fieldcol,
                                                 int labelcol, boolean isQuickSearch, String label,String name) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem select = conditionFactory.createCondition(ConditionType.SELECT,502327,name);
        select.setOptions(selectOptions);
        select.setColSpan(colSpan);
        select.setFieldcol(fieldcol);
        select.setLabelcol(labelcol);
        select.setIsQuickSearch(isQuickSearch);
        select.setLabel(label);
        return select;
    }


    /**
     * checkbox
     * @param user
     * @param colSpan
     * @param fieldcol
     * @param viewAttr
     * @param isQuickSearch
     * @param label
     * @param name
     * @return
     */
    public static SearchConditionItem checkboxItem(User user, int colSpan, int fieldcol,
                                                   int viewAttr, boolean isQuickSearch, String label,String name) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem checkbox = conditionFactory.createCondition(ConditionType.CHECKBOX,502327,name);
        checkbox.setColSpan(colSpan);
        checkbox.setFieldcol(fieldcol);
        checkbox.setViewAttr(viewAttr);
        checkbox.setIsQuickSearch(isQuickSearch);
        checkbox.setLabel(label);
        return checkbox;
    }


    /**
     * 输入框数字
     * @param user
     * @param rules
     * @param colSpan
     * @param fieldcol
     * @param viewAttr
     * @param label
     * @return
     */
    public static SearchConditionItem inputNumberItem(User user,String rules,int colSpan, int fieldcol,
                                                       int viewAttr, String label,String name) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem inputnumber = conditionFactory.createCondition(ConditionType.INPUTNUMBER,502327, name);
        inputnumber.setColSpan(colSpan);
        inputnumber.setFieldcol(fieldcol);
        inputnumber.setViewAttr(viewAttr);
        inputnumber.setLabel(label);
        inputnumber.setRules(rules);

        return inputnumber;
    }

    public static SearchConditionItem inputNumberItemWithMaxAndMin(User user,String rules,int colSpan, int fieldcol,
                                                      int viewAttr, String label, String name, String max, String min) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem inputnumber = conditionFactory.createCondition(ConditionType.INPUTNUMBER,502327, name);
        inputnumber.setColSpan(colSpan);
        inputnumber.setFieldcol(fieldcol);
        inputnumber.setViewAttr(viewAttr);
        inputnumber.setLabel(label);
        inputnumber.setRules(rules);
        inputnumber.setMax(max);
        inputnumber.setMin(min);

        return inputnumber;
    }


    /**
     * 输入框文本
     * @param user
     * @param rules
     * @param colSpan
     * @param fieldcol
     * @param viewAttr
     * @param length
     * @param label
     * @return
     */
    public static SearchConditionItem inputItem(User user,String rules,int colSpan, int fieldcol,
                                                int viewAttr,int length, String label,String name) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem input = conditionFactory.createCondition(ConditionType.INPUT,25034, name);
        input.setColSpan(colSpan);
        input.setFieldcol(fieldcol);
        input.setViewAttr(viewAttr);
        input.setLength(length);
        input.setLabel(label);
        input.setRules(rules);
        return input;
    }

    /**
     * 浏览按钮
     * @param user
     * @param colSpan
     * @param fieldcol
     * @param viewAttr
     * @param isQuickSearch
     * @param label
     * @param rules
     * @param type
     * @return
     */
    public static SearchConditionItem browserItem(User user,int colSpan, int fieldcol,
                                                  int viewAttr,boolean isQuickSearch,String label,String rules,String type,String name) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem browser = conditionFactory.createCondition(ConditionType.BROWSER,502327,name,type);
        browser.setColSpan(colSpan);
        browser.setFieldcol(fieldcol);
        browser.setViewAttr(viewAttr);
        browser.setIsQuickSearch(isQuickSearch);
        browser.setLabel(label);
        browser.setRules(rules);
        return browser;
    }


    /**
     * 日期区间
     * @param user
     * @param colSpan
     * @param fieldcol
     * @param viewAttr
     * @param label
     * @param rules
     * @return
     */
    public static SearchConditionItem rangeDateItem(User user,int colSpan, int fieldcol,int viewAttr
                                                        ,String label,String rules,String name1,String name2) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem rangeDate = conditionFactory.createCondition(ConditionType.TIMEPICKER,502327,new String[]{name1,name2});
        rangeDate.setColSpan(colSpan);
        rangeDate.setFieldcol(fieldcol);
        rangeDate.setViewAttr(viewAttr);
        rangeDate.setLabel(label);
        rangeDate.setRules(rules);
        return  rangeDate;
    }


    /**
     * 多行文本框
     * @param user
     * @param colSpan
     * @param fieldcol
     * @param isQuickSearch
     * @param viewAttr
     * @param length
     * @param label
     * @param name
     * @return
     */
    public static SearchConditionItem textareaItem(User user,int colSpan, int fieldcol,boolean isQuickSearch,
                                                int viewAttr,int length, String label,String name) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem textarea = conditionFactory.createCondition(ConditionType.TEXTAREA,502227, name);
        textarea.setColSpan(colSpan);
        textarea.setFieldcol(fieldcol);
        textarea.setIsQuickSearch(isQuickSearch);
        textarea.setViewAttr(viewAttr);
        textarea.setLength(length);
        textarea.setLabel(label);

        return textarea;
    }


    /**
     * 日期
     * @param user
     * @param colSpan
     * @param fieldcol
     * @param isQuickSearch
     * @param viewAttr
     * @param label
     * @param name
     * @return
     */
    public static SearchConditionItem datePickerItem(User user,int colSpan, int fieldcol,boolean isQuickSearch,
                                                   int viewAttr,String label,String name) {
        ConditionFactory conditionFactory = new ConditionFactory(user);
        SearchConditionItem datePicker = conditionFactory.createCondition(ConditionType.DATEPICKER,502227, name);
        datePicker.setColSpan(colSpan);
        datePicker.setFieldcol(fieldcol);
        datePicker.setIsQuickSearch(isQuickSearch);
        datePicker.setViewAttr(viewAttr);
        datePicker.setLabel(label);
        return datePicker;
    }






}
