
function detail(optType){
    var id = '';
    if (optType===otpTypeEnum.EDIT||optType===2||optType===3||optType===5){
        var row = $(el.tb).datagrid('getSelected'), userId = $(el.userId).val();
        if (!row) {
            topWin.layer.alert('请选中一条记录', {icon: 0});
            return false;
        }
        id = row.id;
    }
    var buttons = [];
    if (optType===0||optType===1){
        buttons.push(
            {
                text: '提交',
                iconCls: 'icon-save',
                handler: function () {
                    topWin.frames['editDialog'].saveOrUpdate(function () {
                        topWin.layer.msg('数据保存成功', {icon: 1});
                        dialogElement.dialog('close');
                        $(el.tb).datagrid('reload');
                    });
                }
            }, {
                text: '关闭',
                iconCls: 'icon-cancel',
                handler: function () {
                    dialogElement.dialog('close');
                }
            }
        );
    }else if (optType===2){
        buttons.push(
            {
                text: '关闭',
                iconCls: 'icon-cancel',
                handler: function () {
                    dialogElement.dialog('close');
                }
            }
        );
    }else if (optType===5){
        buttons.push(
            {
                text: '通过',
                iconCls: 'icon-ok',
                handler: function () {
                    topWin.frames['editDialog'].financeConfirm(1,function (data) {
                        topWin.layer.msg('操作成功', {icon: 1});
                        dialogElement.dialog('close');
                        $(el.tb).datagrid('reload');
                    });
                }
            },
            {
                text: '拒绝',
                iconCls: 'icon-cancel',
                handler: function () {
                    topWin.frames['editDialog'].financeConfirm(0,function (data) {
                        topWin.layer.msg('操作成功', {icon: 1});
                        dialogElement.dialog('close');
                        $(el.tb).datagrid('reload');
                    });
                }
            },
            {
                text: '关闭',
                iconCls: 'icon-clear',
                handler: function () {
                    el.addOrEditDialog.dialog('close');
                }
            }
        );
    }
    var dialogElement = openDialog("editDialog", g.ctx + "pc/finance/payment/notice/detail?id="+id+"&optType="+optType, {
        title: (optType === otpTypeEnum.ADD ? "新增" :optType===otpTypeEnum.EDIT?"编辑":optType===3?"复制":optType===4?"采购确认":optType===2?"查看":"财务确认"),
        width: '100%',
        height: '100%',
        cache: false,
        modal: true,
        border: false,
        draggable: false,
        shadow: false,
        onClose: function () {
            dialogElement.dialog('destroy');
        },
        buttons: buttons
    });

}

/**
 * 财务审批
 *
 * @param approveStatus 审批结果 0:拒绝 1:同意
 * @param submitData 提交数据
 */
function financeApprove(approveStatus, submitData) {
    submitData.roleType = 2;
    submitData.approveStatus = approveStatus;

    var loading = topWin.layer.msg('数据保存中, 请耐心等待......', {icon: 16, time: 0, shade: 0.1});
    $.ajax({
        url: g.ctx + 'pc/finance/payment/notice/rest/finance/approve',
        type: 'POST',
        data: JSON.stringify(submitData),
        contentType: 'application/json',
        success: function (data) {
            topWin.layer.close(loading);
            el.addOrEditDialog.dialog('close');
            $(el.tb).datagrid('reload');

            topWin.layer.msg('操作成功', {icon: 1});
        },
        error: function (data) {
            topWin.layer.close(loading);
            topWin.layer.alert(data.responseJSON.message, {icon: 2});
        }
    });
}