/**
 * 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)
      }
      $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 loadPageCard = () => {
      // $api.loadCard()
    }


    return {
      demoFunc,loadPageCard
    }
  }
});
