
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/matching/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
    });

}


function viewAttachmentFileDetail(businessId, businessCode) {
    const businessTypeCode = "payment_matching";
    let url = g.ctx + "pc/sys/businessAttachment/businessAttachmentDetail?businessId="
        + businessId + "&businessCode=" + businessCode + "&businessTypeCode=" + businessTypeCode;
    const buttons = [{
        text: itablei8n.close, handler: function () {
            attachmentFileDetailDialog.dialog('close');
        }
    }]
    var attachmentFileDetailDialog = openDialog("attachmentFileDetailDialog", url, {
        title: '报关单附件',
        width: '800px',
        height: '500px',
        cache: false,
        modal: true,
        border: false,
        draggable: true,
        shadow: false,
        buttons: buttons,
        onClose: function () {
            attachmentFileDetailDialog.dialog('destroy');
        },
        onOpen: function() {
            // dialog打开后，等待iframe加载完成
            const iframe = $(this).find('iframe')[0];
            // iframe.onload = async function() {
            //     await $.ajax({
            //         type: 'get',
            //         url: g.ctx + 'pc/order/deliveryOrder/rest/findAccountStatement?id=' + businessId,
            //         async: false,
            //         success: function (data) {
            //             accountStatementCodeList = data;
            //         }, error: function (data) {
            //             topWin.layer.close(index);
            //             topWin.layer.alert(data.responseJSON.message, {icon: 2});
            //         }
            //     });
            // 将父页面的函数引用传递给iframe
            // iframe.contentWindow.uploadValidation = accountStatementExistValidation;
            // iframe.contentWindow.deleteValidation = accountStatementExistValidation;
            // iframe.contentWindow.remarkValidation = accountStatementExistValidation;
            // };
        }
    })
}