//监听uni-app的事件
window.appType = {};
document.addEventListener('UniAppJSBridgeReady', () => {
    uni.getEnv(res => {
        window.appType = res;
    });
    //接受子页面传递过来的消息数据
    window.addEventListener('message', (event) => {
        if (event.data.source === 'web') {
            uni.postMessage({
                data: event.data
            });
        }
    });
});

//app改变显示模式
function editTypeClick(type)
{
    window?.postMessage({
        type: 'editTypeClick',
        source: 'app',
        data: type,
    })
}

//app的表单提交保存
function formSave()
{
    window?.postMessage({
        type: 'formSave',
        source: 'app',
        data: {},
    })
}

//切换日志填报的页码
function pageTap(index)
{
    window?.postMessage({
        type: 'pageTap',
        source: 'app',
        data: index,
    })
}

//日志填报，新增表格
function addFormTap()
{
    window?.postMessage({
        type: 'addForm',
        source: 'app',
        data: {},
    })
}

//日志填报，删除当前表格
function delFormTap()
{
    window?.postMessage({
        type: 'delForm',
        source: 'app',
        data: {},
    })
}

//日志填报，更新关联工序
function linkIdsTap(data)
{
    window?.postMessage({
        type: 'linkIds',
        source: 'app',
        data: data,
    })
}


//复制当前表格及内容
function copyFormData()
{
    window?.postMessage({
        type: 'copyFormData',
        source: 'app',
        data: {},
    })
}

//获取PDF地址
function getPdfUrl()
{
    window?.postMessage({
        type: 'getPdfUrl',
        source: 'app',
        data: {},
    })
}
