var that;
shr.defineClass("shr.dormitorysystem.WaterElectricityEdit",  shr.framework.Edit, {

    initalizeDOM: function () {
        shr.dormitorysystem.WaterElectricityEdit.superClass.initalizeDOM.call(this);
        that = this;
        var operateState = _self.getOperateState().toUpperCase();
        if("ADDNEW"==operateState) {
            var grid_f7_json = {
                onchange: (e, value) => {
                    if (value.current) {
                        var current = value.current;
                        $('#empName').shrTextField("setValue", current.name);
                        $('#empNumber').shrTextField("setValue", current.number);
                        $('#positionStatus').shrTextField("setValue", current['employeeType.name']);
                        $('#adminOrg').shrPromptBox("setValue",
                            {
                                id: current['adminOrgUnit.id'],
                                name: current['adminOrgUnit.name']
                            }
                        );
                        $('#position').shrPromptBox("setValue",
                            {
                                id: current['position.id'],
                                name: current['position.name']
                            }
                        );
                        $('#hrOrgUnit').shrPromptBox("setValue",
                            {
                                id: '00000000-0000-0000-0000-000000000000CCE7AED4',
                                name: 'HR组织'
                            }
                        );
                        $('#stutas').shrSelect("setValue", 'unLock');
                    }
                }
            };
            $('#person').shrPromptBox(grid_f7_json);

        }

    },
    /**
     * 保存
     */
    saveAction: function(event) {
        var _self = this;
        var operateState = _self.getOperateState().toUpperCase();
        if("ADDNEW"==operateState) {
            var startDate = $('#startDate').val();
            if(startDate){
                $('#yearMonth').shrTextField("setValue",startDate);
                var date1 = new Date(startDate);
                var date2= new Date(date1.getFullYear(),date1.getMonth()+1,0);
                var date2Str = date2.toLocaleDateString().replaceAll("/","-");
                $('#endDate').shrDateTimePicker("setValue",date2Str)
            }
            var person = $('#person').shrPromptBox("getValue");
            let timestamp = new Date().getTime();
            var number="TWE"+person.number+startDate+timestamp;
            $('#number').shrTextField("setValue",number);
        }
        if (_self.validate() && _self.verify()) {
            _self.doSave(event, 'save');
        }else{
            if(_self != top){// in iframe
                shr.setIframeHeight(window.name);
            }

        }
    },
});