import { Prop, Provide, Emit, Model } from 'vue-property-decorator';
import { Subject, Subscription } from 'rxjs';
import { Watch, GridControlBase } from '@/studio-core';
import HREmployeeService from '@/service/hremployee/hremployee-service';
import GRID_001Service from './grid-001-grid-service';
import HREmployeeUIService from '@/uiservice/hremployee/hremployee-ui-service';
import { FormItemModel } from '@/model/form-detail';


/**
 * grid部件基类
 *
 * @export
 * @class GridControlBase
 * @extends {GRID_001GridBase}
 */
export class GRID_001GridBase extends GridControlBase {

    /**
     * 获取部件类型
     *
     * @protected
     * @type {string}
     * @memberof GRID_001GridBase
     */
    protected controlType: string = 'GRID';

    /**
     * 建构部件服务对象
     *
     * @type {GRID_001Service}
     * @memberof GRID_001GridBase
     */
    public service: GRID_001Service = new GRID_001Service({ $store: this.$store });

    /**
     * 实体服务对象
     *
     * @type {HREmployeeService}
     * @memberof GRID_001GridBase
     */
    public appEntityService: HREmployeeService = new HREmployeeService({ $store: this.$store });

    /**
     * 应用实体名称
     *
     * @protected
     * @type {string}
     * @memberof GRID_001GridBase
     */
    protected appDeName: string = 'hremployee';

    /**
     * 应用实体中文名称
     *
     * @protected
     * @type {string}
     * @memberof GRID_001GridBase
     */
    protected appDeLogicName: string = '员工';

    /**
     * 逻辑事件
     *
     * @param {*} [params={}]
     * @param {*} [tag]
     * @param {*} [$event]
     * @memberof 
     */
    public grid_uagridcolumn1_u2abac3f_click(params: any = {}, tag?: any, $event?: any) {
        // 取数
        let datas: any[] = [];
        let xData: any = null;
        // _this 指向容器对象
        const _this: any = this;
        let paramJO:any = {};
        let contextJO:any = {};
        xData = this;
        if (_this.getDatas && _this.getDatas instanceof Function) {
            datas = [..._this.getDatas()];
        }
        if(params){
          datas = [params];
        }
        // 界面行为
        const curUIService:HREmployeeUIService  = new HREmployeeUIService();
        curUIService.HREmployee_SignContract(datas,contextJO, paramJO,  $event, xData,this,"HREmployee");
    }

    /**
     * 界面UI服务对象
     *
     * @type {HREmployeeUIService}
     * @memberof GRID_001Base
     */  
    public appUIService:HREmployeeUIService = new HREmployeeUIService(this.$store);

    /**
     * 界面行为模型
     *
     * @type {*}
     * @memberof GRID_001Base
     */  
    public ActionModel: any = {
        SignContract: { name: 'SignContract',disabled: false, visabled: true,noprivdisplaymode:2,dataaccaction: '', target: 'SINGLEKEY'}
    };

    /**
     * 本地缓存标识
     *
     * @protected
     * @type {string}
     * @memberof GRID_001Base
     */
    protected localStorageTag: string = 'hremployee_grid_001_grid';

    /**
     * 所有列成员
     *
     * @type {any[]}
     * @memberof GRID_001GridBase
     */
    public allColumns: any[] = [
        {
            name: 'employeecode',
            label: '员工编号',
            langtag: 'entities.hremployee.grid_001_grid.columns.employeecode',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'employeename',
            label: '员工姓名',
            langtag: 'entities.hremployee.grid_001_grid.columns.employeename',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'organizationname',
            label: '单位',
            langtag: 'entities.hremployee.grid_001_grid.columns.organizationname',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'hrdutyname',
            label: '职务',
            langtag: 'entities.hremployee.grid_001_grid.columns.hrdutyname',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'hrpostname',
            label: '职位',
            langtag: 'entities.hremployee.grid_001_grid.columns.hrpostname',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'certnum',
            label: '证件号码',
            langtag: 'entities.hremployee.grid_001_grid.columns.certnum',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'birthday',
            label: '出生日期',
            langtag: 'entities.hremployee.grid_001_grid.columns.birthday',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'age',
            label: '年龄',
            langtag: 'entities.hremployee.grid_001_grid.columns.age',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'mobile',
            label: '移动电话',
            langtag: 'entities.hremployee.grid_001_grid.columns.mobile',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'email',
            label: '电子邮箱',
            langtag: 'entities.hremployee.grid_001_grid.columns.email',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'empstate',
            label: '员工状态',
            langtag: 'entities.hremployee.grid_001_grid.columns.empstate',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
        {
            name: 'uagridcolumn1',
            label: '操作',
            langtag: 'entities.hremployee.grid_001_grid.columns.uagridcolumn1',
            show: true,
            util: 'PX',
            isEnableRowEdit: false,
        },
    ]

    /**
     * 获取表格行模型
     *
     * @type {*}
     * @memberof GRID_001GridBase
     */
    public getGridRowModel(){
        return {
          srfkey: new FormItemModel(),
        }
    }

    /**
     * 属性值规则
     *
     * @type {*}
     * @memberof GRID_001GridBase
     */
    public rules: any = {
        srfkey: [
            { required: false, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: '员工标识 值不能为空', trigger: 'change' },
            { required: false, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: '员工标识 值不能为空', trigger: 'blur' },
        ],
    }

    /**
     * 获取对应列class
     *
     * @type {*}
     * @memberof GRID_001Base
     */
    public hasRowEdit: any = {
        'employeecode':false,
        'employeename':false,
        'organizationname':false,
        'hrdutyname':false,
        'hrpostname':false,
        'certnum':false,
        'birthday':false,
        'age':false,
        'mobile':false,
        'email':false,
        'empstate':false,
        'uagridcolumn1':false,
    };

    /**
     * 获取对应列class
     *
     * @param {*} $args row 行数据，column 列数据，rowIndex 行索引，列索引
     * @returns {void}
     * @memberof GRID_001Base
     */
    public getCellClassName(args: {row: any, column: any, rowIndex: number, columnIndex: number}): any {
        return ( this.hasRowEdit[args.column.property] && this.actualIsOpenEdit ) ? "edit-cell" : "info-cell";
    }


    /**
     * 导出数据格式化
     *
     * @param {*} filterVal
     * @param {*} jsonData
     * @param {any[]} [codelistColumns=[]]
     * @returns {Promise<any>}
     * @memberof GRID_001GridBase
     */
    public async formatExcelData(filterVal: any, jsonData: any, codelistColumns?: any[]): Promise<any> {
        return super.formatExcelData(filterVal, jsonData, [
            {
                name: 'empstate',
                srfkey: 'CL_HR_0016',
                codelistType : 'DYNAMIC',
                renderMode: 'other',
                textSeparator: '、',
                valueSeparator: ',',
            },
        ]);
    }


    /**
     * 界面行为
     *
     * @param {*} row
     * @param {*} tag
     * @param {*} $event
     * @memberof GRID_001GridBase
     */
	public uiAction(row: any, tag: any, $event: any): void {
        $event.stopPropagation();
        if(Object.is('SignContract', tag)) {
            this.grid_uagridcolumn1_u2abac3f_click(row, tag, $event);
        }
    }
}