/**
 * simpleAdvanceDeleteAction
 * 简单实现的自定义列表删除 包含了删除失败的提示信息
 * @author fengjiansheng
 * @date 2021-12-30
 */
export default {
    execute(context, param) {
        if (!param.billDefine || !param.billId) {
            context.dom.$Message.info("请配置按钮指定参数");
            return;
        }
        context.dom.$Modal.confirm({
            title: "提示",
            content: "确认删除吗？",
            loading: true,
            onOk: () => {
                this.billDeleted(context, param);
            }
        })
    },
    billDeleted(context, param) {
        let url = `/gms/bill/deleted/${param.billDefine}/${context.selects[0][param.billId]}`
        GMS.$http.post(url).then((data) => {
            if (data.status === 200 && data.data.code === 0) {
                context.dom.$Modal.remove();
                context.dom.$Message.success('删除成功');
                GMS.vbus.$emit('custom-query-refresh');
                GMS.vbus.$emit('tab-count-refresh');
            } else {
                context.dom.$Modal.remove();
                let message = data.data.message
                let f = 'nested exception is '
                if (message.indexOf(f) > -1) {
                    context.dom.$Message.error(data.data.message.split(f)[1])
                } else {
                    context.dom.$Message.error(data.data.message);
                }
            }
        })
    }
}
