import { message } from "antd/lib/index";
import { getPropertyData, extendInclude, extendRule, getDataFieldValue, setDataFieldValue, initFilter, guid } from "../../utils/common";
import moment from 'moment';
import { Button, Row, Col, Form, Input, Select, Upload, Icon, Modal, Spin,Table } from 'antd';
/**
 * @return {string}
 */
// 编辑
export default {
  onBeforeSaveHandleRecord(params) {
    params.record.TaskID = params.data.TaskID    //TaskID传递消息表ID
    params.record.PUBLISH = params.customParams;
    // params.record.FORM_CODE = params.data.reloadKey.substring(0,params.data.reloadKey.indexOf("_"));
  },
  updateCheckUser: ({ row, pageCode, record, colInfo, resetFields, stateData, saveHeadRecord, saveRowRecord, getSelectedRecords, setState }) => {
    let DetailCheck = getSelectedRecords();
    if (DetailCheck && DetailCheck.length > 1) {
      let ListCheckUserFirst = DetailCheck[0].Nav_Contents;
      //更新行数据
      for (let i = 1; i < DetailCheck.length; i++) {
        //组装数据
        let updateList = [];
        if (ListCheckUserFirst != undefined && ListCheckUserFirst.length > 0) {
          for (let j = 0; j < ListCheckUserFirst.length; j++) {
            if (!ListCheckUserFirst[j].IS_DELETED) {
              let updateObj = { ...ListCheckUserFirst[j] };
              updateObj["ID"] = guid()
              updateList.push(updateObj);
            }
          }
          let iRow = { ...DetailCheck[i] };
          iRow.Nav_Contents = updateList;
          saveRowRecord({ record: iRow, editCode: "T_PT_ASSESSMENT_PLAN_AUDIT_DETAIL_CONTENT" })

          for (var x = 0; x < stateData.Nav_Details.length; x++) {
            if (iRow.ID == stateData.Nav_Details[x].ID) {
              stateData.Nav_Details[x].Nav_Contents = updateList;
            }
          }
        }
        //更新选中人员
        // let tmp = "";
        // for (var x = 0; x < stateData.Nav_TeamDetail.length; x++) {
        //   let contens = stateData.Nav_TeamDetail[x].Nav_DetailContent
        //   if (contens) {
        //     for (let i = 0; i < contens.length; i++) {
        //       if (!contens[i].IS_DELETED) {
        //         if (tmp.indexOf(contens[i].NAME) == -1) {
        //           tmp += (tmp.length > 0 ? "," : "") + contens[i].NAME
        //         }
        //       }
        //     }
        //   }
        // }
        //stateData.CheckUsers = tmp
        setState({ data: stateData });
      }
    }
  },
}
