/**
 * Created by 1 at 2023-12-20 17:03:56
 * 注册事件类【机构数据填报编辑】，参看event.defaultEvent.js
 */
window.$swEvent.setup("mztb.base.partyDataFill.partyDataFillCard", {
    setup(page) {
        const {$params, $refs, $widgets, $model, $utils, $tabRouter, $api, $lifecycle, $engine, $parent} = page || {};
        const {$$message, $$http, $$sys, $$UtilPub} = $utils || {};

        // 示例
        const demoFunc = () => {

        };

        $lifecycle.onLoad = () => {
            if (!$params.id) {
                $model.card.setFormVal("fo_type", Number($params.type))
                $model.card.setFormVal("fo_task", Number($params.type) === 2 ? Number($params.task + "99") : Number($params.task)) //如果是年报 年份后面添加标识 99
                $model.card.setFormVal("fo_task_text", $params.task_text)
            }
            withRegisterDeptTypeDisable($model.card.getFormVal("fo_pi_reg_dept"));
            // $api.loadOne("partyForm")
            if (Number($model.card.getFormVal("fo_state") === 2) || Number($model.card.getFormVal("fo_state") === 1)) {
                $refs.saveButton.hide()
            }
            if (Number($model.card.getFormVal("fo_type")) === 1) { // 月报
                $refs.yearEnd.hide()
            }
        }

        // 聚合数据集操作
        Object.assign($engine, {
            buildSaveParams(params) {// 将需要保存的数据集 构建到参数里面
                if (Number($model.card.getFormVal("fo_type")) === 2) { // 年报
                    params.yearEndPersonsForm = {
                        form: $model.yearEndPersonsForm.data.form
                    }
                }
                params.financeForm = {
                    form: $model.financeForm.data.form
                }
                params.businessForm = {
                    form: $model.businessForm.data.form
                }
                // params.partyForm = {
                //     form: $model.partyForm.data.form
                // }
            }
        })

        const withRegisterDeptTypeDisable = (type) => {
            console.log("登记部门类型： ", type)
            switch (Number(type)) {
                case 1 : // 字典值 市场监管部门
                    oneHide();
                    break;
                case 2 : // 民政部门登记
                case 5: // 一个机构多个牌子
                    twoHide();
                    break;
                case 3 : // 编制部门登记
                    threeHide();
                    break;
            }
        }

        const twoHide = () => { // 民政部门登记禁用
            $api.widgetDisable({
                financeForm: [
                    "fi_cs_weal"
                    ,"fi_cs_heating_fee"
                    ,"fi_cs_service_fee"
                    ,"fi_pff_living_subsidy"
                    ,"fi_year_expend"
                    ,"fi_sell_fee"
                    ,"fi_operating_profit"
                    ,"fi_pff_bounty"
                    ,"fi_ni_public_subsidy"
                    ,"fi_mc_travel"
                    ,"fi_ye_commodity_service"
                    ,"fi_ycs_salary"
                    ,"fi_ycs_personage_family_fee"
                    ,"fi_gtd_year"
                    ,"fi_payable_money_year"
                    ,"fi_cs_go_abroad"
                    ,"fi_mc_taxes"
                    ,"fi_manage_cost"
                    ,"fi_income_from_investment"
                    ,"fi_nonbusiness_income"
                    ,"fi_yit_business"
                    ,"fi_pff_student_grent"
                    ,"fi_operating_costs"
                    ,"fi_sell_cost"
                    ,"fi_operation_revenue"
                    ,"fi_ycs_operating_expense"
                    ,"fi_yit_enterpricse"
                    ,"fi_asset_loss"
                    ,"fi_pff_subsidy"
                    ,"fi_pff_fuxue"
                    ,"fi_taxes"
                    ,"fi_base_pay"
                    ,"fi_cs_expend"
                    ,"fi_finance_cost"
                    ,"fi_grand_total_depr"
                    ,"fi_cs_travel_expense"
                    ,"fi_fc_interests"
                    ,"fi_pff_relief"
                    ,"fi_fair_value_chanage"]
            })
        }
        const threeHide = () => { // 编制部门登记禁用
            $api.widgetDisable({
                financeForm: [
                    "fi_ysf_menage_fee"
                    ,"fi_bf_tax"
                    ,"fi_operating_profit"
                    ,"fi_bf_staff_costs"
                    ,"fi_ni_public_subsidy"
                    ,"fi_mc_travel"
                    ,"fi_ysf_business_fee"
                    ,"fi_gtd_year"
                    ,"fi_change_in_not_assets"
                    ,"fi_mf_tax"
                    ,"fi_mf_assets"
                    ,"fi_yit_donation"
                    ,"fi_year_sum_fee"
                    ,"fi_bf_assets"
                    ,"fi_payable_money_year"
                    ,"fi_mf_staff_costs"
                    ,"fi_mc_taxes"
                    ,"fi_mf_every_day_fee"
                    ,"fi_manage_cost"
                    ,"fi_income_from_investment"
                    ,"fi_nonbusiness_income"
                    ,"fi_operating_costs"
                    ,"fi_yit_subsidy"
                    ,"fi_sell_cost"
                    ,"fi_operation_revenue"
                    ,"fi_asset_loss"
                    ,"fi_yit_membershiop_fees"
                    ,"fi_taxes"
                    ,"fi_bf_every_day_fee"
                    ,"fi_base_pay"
                    ,"fi_finance_cost"
                    ,"fi_grand_total_depr"
                    ,"fi_fc_interests"
                    ,"fi_fair_value_chanage" ]
            })
        }
        const oneHide = () => { // 市场监管部门登记禁用
            $api.widgetDisable({
                financeForm: [
                    "fi_cs_weal"
                    ,"fi_cs_heating_fee"
                    ,"fi_cs_service_fee"
                    ,"fi_ysf_menage_fee"
                    ,"fi_pff_living_subsidy"
                    ,"fi_year_expend"
                    ,"fi_bf_tax"
                    ,"fi_sell_fee"
                    ,"fi_pff_bounty"
                    ,"fi_bf_staff_costs"
                    ,"fi_ye_commodity_service"
                    ,"fi_ysf_business_fee"
                    ,"fi_change_in_not_assets"
                    ,"fi_mf_tax"
                    ,"fi_ycs_salary"
                    ,"fi_mf_assets"
                    ,"fi_ycs_personage_family_fee"
                    ,"fi_yit_donation"
                    ,"fi_year_sum_fee"
                    ,"fi_bf_assets"
                    ,"fi_cs_go_abroad"
                    ,"fi_mf_staff_costs"
                    ,"fi_mf_every_day_fee"
                    ,"fi_yit_business"
                    ,"fi_pff_student_grent"
                    ,"fi_yit_subsidy"
                    ,"fi_ycs_operating_expense"
                    ,"fi_yit_enterpricse"
                    ,"fi_year_income_total"
                    ,"fi_pff_subsidy"
                    ,"fi_pff_fuxue"
                    ,"fi_yit_membershiop_fees"
                    ,"fi_bf_every_day_fee"
                    ,"fi_cs_expend"
                    ,"fi_cs_travel_expense"
                    ,"fi_pff_relief" ]
            })
        }


        const loadPageCard = () => {
            // $api.loadCard()
        }


        return {
            demoFunc, loadPageCard
        }
    }
});
/* ===== 标识为禁用字段
* 编制部门登记
    fi_cs_weal                    '商品和服务支出（福利费）',
    fi_cs_heating_fee             '商品和服务支出（取暖费）',
    fi_ysf_menage_fee             '本年费用合计（管理费用）', =======
    fi_cs_service_fee             '商品和服务支出（劳务费）',
    fi_pff_living_subsidy         '对个人和家庭补助支出（生活补助）',
    fi_year_expend                '本年支出合计',
    fi_bf_tax                     '业务活动成本（税费）',======
    fi_sell_fee                   '销售税金',
    fi_operating_profit           '营业利润', =====
    fi_pff_bounty                 '对个人和家庭补助支出（奖励金）',
    fi_bf_staff_costs             '业务活动成本（人员费用）',=====
    fi_ni_public_subsidy          '营业外收入（政府补助）', =====
    fi_mc_travel                  '管理费用（差旅费）', =====
    fi_ye_commodity_service       '本年支出合计（商品和服务支出）',
    fi_ysf_business_fee           '本年费用合计（业务活动成本）', ======
	fi_gtd_year                   '累计折旧（本年折旧）' =========
    fi_change_in_not_assets       '净资产变动额', =====
    fi_mf_tax                     '管理费用（税费）', ====
    fi_ycs_salary                 '本年支出合计（工资福利支出）',
    fi_mf_assets                  '管理费用（固定资产折旧）',=====
    fi_ycs_personage_family_fee   '本年支出合计（对个人和家庭补助支出）',
    fi_yit_donation               '本年收入合计（捐赠收入）', ======
    fi_year_sum_fee               '本年费用合计', ======
    fi_bf_assets                  '业务活动成本（固定资产折旧）', =====
    fi_property_total             '资产总计',
    fi_payable_money_year         '本年应交增值税', ======
    fi_cs_go_abroad               '商品和服务支出（因公出国 / 境费）',
    fi_mf_staff_costs             '管理费用（人员费用）',====
    fi_mc_taxes                   '管理费用（税金）', =====
    fi_mf_every_day_fee           '管理费用（日常费用）',=====
    fi_liabilities_total          '负债合计',
    fi_manage_cost                '管理费用', ======
    fi_income_from_investment     '投资收益', =====
    fi_nonbusiness_income         '营业外收入',======
    fi_yit_business               '本年收入合计（经营收入）',
    fi_pff_student_grent          '对个人和家庭补助支出（助学金）',
    fi_operating_costs            '营业成本', ==========
    fi_yit_subsidy                '本年收入合计（政府补助收入）', ======
    fi_sell_cost                  '销售费用', ==========
    fi_operation_revenue          '营业收入', =========
    fi_ycs_operating_expense      '本年支出合计（经营支出）',
    fi_yit_enterpricse            '本年收入合计（事业收入）',
    fi_asset_loss                 '资产减值损失', =====
    fi_year_income_total          '本年收入合计',
    fi_pff_subsidy                '对个人和家庭补助支出（生产补贴）',
    fi_pff_fuxue                  '对个人和家庭补助支出（抚恤金）',
    fi_yit_membershiop_fees       '本年收入合计（会费收入）', ====
    fi_taxes                      '营业税金及附加', =========
    fi_bf_every_day_fee           '业务活动成本（日常费用）',=====
    fi_base_pay                   '应付职工底薪', =======
    fi_cs_expend                  '商品和服务支出（工会经费）',
    fi_finance_cost               '财务费用', ======
    fi_grand_total_depr           '累计折旧', ======
    fi_cs_travel_expense          '商品和服务支出（差旅费）',
    fi_fc_interests               '财务费用（利息净支出）', ========
    fi_pff_relief                 '对个人和家庭补助支出（救济费）',
    fi_fair_value_chanage         '公允价值变动收益' =======
* */

/*
 *民政部门登记
    fi_cs_weal                    '商品和服务支出（福利费）',===
    fi_cs_heating_fee             '商品和服务支出（取暖费）',====
    fi_ysf_menage_fee             '本年费用合计（管理费用）', ====
    fi_cs_service_fee             '商品和服务支出（劳务费）',=====
    fi_pff_living_subsidy         '对个人和家庭补助支出（生活补助）',=====
    fi_year_expend                '本年支出合计', ====
    fi_bf_tax                     '业务活动成本（税费）',
    fi_sell_fee                   '销售税金', ====
    fi_operating_profit           '营业利润', ====
    fi_pff_bounty                 '对个人和家庭补助支出（奖励金）',====
    fi_bf_staff_costs             '业务活动成本（人员费用）',
    fi_ni_public_subsidy          '营业外收入（政府补助）',=====
    fi_mc_travel                  '管理费用（差旅费）', ====
    fi_ye_commodity_service       '本年支出合计（商品和服务支出）',====
    fi_ysf_business_fee           '本年费用合计（业务活动成本）',
    fi_change_in_not_assets       '净资产变动额',
    fi_mf_tax                     '管理费用（税费）',
    fi_ycs_salary                 '本年支出合计（工资福利支出）',=====
    fi_mf_assets                  '管理费用（固定资产折旧）',
    fi_ycs_personage_family_fee   '本年支出合计（对个人和家庭补助支出）', ====
    fi_yit_donation               '本年收入合计（捐赠收入）',
    fi_year_sum_fee               '本年费用合计',
    fi_bf_assets                  '业务活动成本（固定资产折旧）',
    fi_property_total             '资产总计',
	fi_gtd_year                   '累计折旧（本年折旧）' =========
    fi_payable_money_year         '本年应交增值税', ====
    fi_cs_go_abroad               '商品和服务支出（因公出国 / 境费）',=====
    fi_mf_staff_costs             '管理费用（人员费用）',
    fi_mc_taxes                   '管理费用（税金）', =====
    fi_mf_every_day_fee           '管理费用（日常费用）',
    fi_liabilities_total          '负债合计',
    fi_manage_cost                '管理费用', =====
    fi_income_from_investment     '投资收益', ====
    fi_nonbusiness_income         '营业外收入', ====
    fi_yit_business               '本年收入合计（经营收入）',======
    fi_pff_student_grent          '对个人和家庭补助支出（助学金）',=====
    fi_operating_costs            '营业成本', ======
    fi_yit_subsidy                '本年收入合计（政府补助收入）',
    fi_sell_cost                  '销售费用', ======
    fi_operation_revenue          '营业收入', ======
    fi_ycs_operating_expense      '本年支出合计（经营支出）',=====
    fi_yit_enterpricse            '本年收入合计（事业收入）',=====
    fi_asset_loss                 '资产减值损失', =====
    fi_year_income_total          '本年收入合计',
    fi_pff_subsidy                '对个人和家庭补助支出（生产补贴）'====
    fi_pff_fuxue                  '对个人和家庭补助支出（抚恤金）',===
    fi_yit_membershiop_fees       '本年收入合计（会费收入）',
    fi_taxes                      '营业税金及附加', ====
    fi_bf_every_day_fee           '业务活动成本（日常费用）',
    fi_base_pay                   '应付职工底薪', =====
    fi_cs_expend                  '商品和服务支出（工会经费）',=====
    fi_finance_cost               '财务费用', ====
    fi_grand_total_depr           '累计折旧', ====
    fi_cs_travel_expense          '商品和服务支出（差旅费）',======
    fi_fc_interests               '财务费用（利息净支出）', ======
    fi_pff_relief                 '对个人和家庭补助支出（救济费）',=====
    fi_fair_value_chanage         '公允价值变动收益' =====
 */

/*
市场监管部门
    fi_cs_weal                    '商品和服务支出（福利费）',======
    fi_cs_heating_fee             '商品和服务支出（取暖费）',======
    fi_ysf_menage_fee             '本年费用合计（管理费用）'
    fi_cs_service_fee             '商品和服务支出（劳务费）',=======
    fi_pff_living_subsidy         '对个人和家庭补助支出（生活补助）',=====
    fi_year_expend                '本年支出合计',=====
    fi_bf_tax                     '业务活动成本（税费）',====
    fi_sell_fee                   '销售税金', =====
    fi_operating_profit           '营业利润',
    fi_pff_bounty                 '对个人和家庭补助支出（奖励金）',=====
    fi_bf_staff_costs             '业务活动成本（人员费用）',=====
    fi_ni_public_subsidy          '营业外收入（政府补助）',
    fi_mc_travel                  '管理费用（差旅费）',
    fi_ye_commodity_service       '本年支出合计（商品和服务支出）',====
    fi_ysf_business_fee           '本年费用合计（业务活动成本）',======
    fi_change_in_not_assets       '净资产变动额', =====
    fi_mf_tax                     '管理费用（税费）',=====
    fi_ycs_salary                 '本年支出合计（工资福利支出）',=====
    fi_mf_assets                  '管理费用（固定资产折旧）', =====
    fi_ycs_personage_family_fee   '本年支出合计（对个人和家庭补助支出）',====
    fi_yit_donation               '本年收入合计（捐赠收入）',====
    fi_year_sum_fee               '本年费用合计',=======
	fi_gtd_year                   '累计折旧（本年折旧）'
    fi_bf_assets                  '业务活动成本（固定资产折旧）',=====
    fi_property_total             '资产总计',
    fi_payable_money_year         '本年应交增值税',
    fi_cs_go_abroad               '商品和服务支出（因公出国 / 境费）',=====
    fi_mf_staff_costs             '管理费用（人员费用）',======
    fi_mc_taxes                   '管理费用（税金）',
    fi_mf_every_day_fee           '管理费用（日常费用）',======
    fi_liabilities_total          '负债合计',
    fi_manage_cost                '管理费用',======
    fi_income_from_investment     '投资收益',
    fi_nonbusiness_income         '营业外收入',
    fi_yit_business               '本年收入合计（经营收入）',====
    fi_pff_student_grent          '对个人和家庭补助支出（助学金）',====
    fi_gtd_year                   '累计折旧（本年折旧）',
    fi_operating_costs            '营业成本',
    fi_yit_subsidy                '本年收入合计（政府补助收入）',====
    fi_sell_cost                  '销售费用',
    fi_operation_revenue          '营业收入',
    fi_ycs_operating_expense      '本年支出合计（经营支出）',=====
    fi_yit_enterpricse            '本年收入合计（事业收入）',====
    fi_asset_loss                 '资产减值损失',
    fi_year_income_total          '本年收入合计', =====
    fi_pff_subsidy                '对个人和家庭补助支出（生产补贴）',====
    fi_pff_fuxue                  '对个人和家庭补助支出（抚恤金）',=====
    fi_yit_membershiop_fees       '本年收入合计（会费收入）',======
    fi_taxes                      '营业税金及附加',
    fi_bf_every_day_fee           '业务活动成本（日常费用）',=====
    fi_base_pay                   '应付职工底薪',
    fi_cs_expend                  '商品和服务支出（工会经费）',====
    fi_finance_cost               '财务费用',
    fi_grand_total_depr           '累计折旧',
    fi_cs_travel_expense          '商品和服务支出（差旅费）',=====
    fi_fc_interests               '财务费用（利息净支出）',
    fi_pff_relief                 '对个人和家庭补助支出（救济费）',====
    fi_fair_value_chanage         '公允价值变动收益'
 */