DATA_REMOVEOBJECT.ftl 2.0 KB
Newer Older
Shine-zwj's avatar
Shine-zwj committed
1 2 3 4 5 6
<#--  删除数据  -->
<#macro dataRemoveObject item>
    /**
     * ${item.getCaption()}
     *
     * @param {any[]} args 当前数据
Shine-zwj's avatar
Shine-zwj committed
7
     * @param {any} context 行为附加上下文
Shine-zwj's avatar
Shine-zwj committed
8 9 10 11 12 13
     * @param {*} [params] 附加参数
     * @param {*} [$event] 事件源
     * @param {*} [xData]  执行行为所需当前部件
     * @param {*} [actionContext]  执行行为上下文
     * @param {*} [srfParentDeName]  父实体名称
     */
Shine-zwj's avatar
Shine-zwj committed
14
    public ${item.getFullCodeName()}(args: any[], context: any = {}, params: any = {}, $event?: any, xData?: any, actionContext?: any, srfParentDeName?: string) {
Shine-zwj's avatar
Shine-zwj committed
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
        <#if item.getPSAppDataEntity?? && item.getPSAppDataEntity()??>
        // 准备上下文参数
        const tempContext = {...context};
        if (xData && xData.context) {
            Object.assign(tempContext, xData.context);
        }
        const data = args[0];
        const appEntityService: ${srfclassname('${item.getPSAppDataEntity().getCodeName()}')}Service = new ${srfclassname('${item.getPSAppDataEntity().getCodeName()}')}Service();
        const key = appEntityService.APPDEKEY.toLowerCase();
        const name = appEntityService.APPDENAME.toLowerCase();
        if (data.hasOwnProperty(name)) {
            Object.assign(tempContext, { [name]: data[name] });
        }
        if (data.hasOwnProperty(key)) {
            Object.assign(tempContext, { [name]: data[key] });
        }
        try {
Shine-zwj's avatar
Shine-zwj committed
32
            appEntityService.Remove(tempContext, data).then((response: any) => {
Shine-zwj's avatar
Shine-zwj committed
33 34 35 36 37 38 39 40 41 42
                if (!response.status || response.status !== 200) {
                    this.$Notice.error({ title: '错误', desc: '当前环境无法执行删除数据逻辑[执行行为异常]' });
                }
            })
        } catch (error: any) {
            this.$Notice.error({ title: '错误', desc: '当前环境无法执行删除数据逻辑[执行行为异常]' });
        }
        <#else>
        this.$Notice.error({ title: '错误', desc: '删除数据行未配置实体' });
        </#if>
Shine-zwj's avatar
Shine-zwj committed
43 44
    }
</#macro>