<template>
  <div id="content-container" :class="{'expand-right': expandRight}">
    <page-loading :show="pageLoading"></page-loading>
    <!--Page Title-->
    <div id="page-title">
      <h1 class="page-header text-overflow">新增项目</h1>
      <!--Searchbox-->
      <!--<div class="searchbox">-->
      <!--<div class="input-group custom-search-form">-->
      <!--<input type="text" class="form-control" placeholder="Search..">-->
      <!--<span class="input-group-btn">-->
      <!--<button class="text-muted" type="button"><i class="demo-pli-magnifi-glass"></i></button>-->
      <!--</span>-->
      <!--</div>-->
      <!--</div>-->
    </div>
    <!--End page title-->

    <!--Breadcrumb-->
    <!--<ol class="breadcrumb">-->
    <!--<li><a href="#">Home</a></li>-->
    <!--<li><a href="#">Layouts</a></li>-->
    <!--<li class="active">Demo</li>-->
    <!--</ol>-->
    <!--End breadcrumb-->

    <!--Page content-->
    <div class="page-content">
      <data-form
        element-loading-text="拼命加载中"
        :title="formTitle"
        :btnTitle="formBtnTitle"
        :schema="formSchema"
        :model="formModel"
        :showTitle="false"
        :btnData="formBtnData"
        ref="childrenForm"
        @radioValueChanged="radioValueChanged"
        @selectorValueChanged="selectorValueChanged"
        @addOption="setCascaderMultipleValue"
        @handleClose="handleClose"
      >
      </data-form>

    </div>
    <!--End Page content-->
  </div>
</template>

<script type="text/ecmascript-6">
import PageLoading from '../../components/PageLoading.vue'
import DataForm from '../../components/form/DataForm.vue'
import Api from '../../server/index.js'
import {baseUrl} from '../../config/env.js';
import {getItem} from '../../config/mUtils.js'
import LogDataTable from "../../components/LogDataTable";

export default {
  beforeRouteEnter (to, from, next) {
    next(function (vm) {
      global.getMenuIndex(vm)
    })
  },
  data () {
    return {
      expandRight: false,
      isSuperAdmin: false,
      draftDeptId: '',
      //form表单数据源
      loadingJudgeData: { //表单加载圈是否隐藏的判断数据源
        documentTypeDataDone: true,
        operationDone: true,
      },
      formTitle: '新增发文',
      formBtnTitle: '提交',
      formSchema: {},
      formModel: {},
      formProjectManagerData: [], // 项目负责人数据源
      formProjectAdmin: [],//项目管理员
      formBranchLeader: [],//分管领导
      formMainLeader: [],
      formAuthData: [ //权限数据源
        {
          label: '全员',
          value: 0
        },
        {
          label: '党员',
          value: 1
        },
        {
          label: '自定义',
          value: 2
        },
      ],
      formSignedData: [ //是否会签数据源
        {
          label: '否',
          value: false
        },
        {
          label: '是',
          value: true
        },
      ],
      formContentTypeData: [ //文章类型数据源

        {
          label: '发文',
          model: 2
        },
        {
          label: '收文',
          model: 1
        },
      ],
      formOpenRangeData: [ //公开范围
        {
          label: '成果转化类(TT)',
          value: 1
        },
        {
          label: '市场创收类(SC)',
          value: 2
        },
        {
          label: '研究开发类(RD)',
          value: 3
        },
        {
          label: '窗口服务类(CK)',
          value: 4
        },
        {
          label: '平台专项类(ZX)',
          value: 5
        },
        {
          label: '目标责任类(ZR)',
          value: 6
        },
        {
          label: '自主研发类',
          value: 7
        },
      ],
      formQuarterData: [ //季度分类数据源
        {
          label: '第一季度',
          model: '第一季度'
        },
        {
          label: '第二季度',
          model: '第二季度'
        },
        {
          label: '第三季度',
          model: '第三季度'
        },
        {
          label: '第四季度',
          model: '第四季度'
        },
      ],
      formPeopleData: [], //使用人的数据源
      formDocumentTypeData: [], //文种类型的数据源
      formFileData: [], //附件数据源
      formPermissionsData: [],  //自定义人员列表
      formCustomizePeopleData: [],  //自定义人员选中数据
      draftManData: getItem('userName'), //拟稿人
      draftManId: getItem('userInfoId'), //拟稿人
      draftDeptNameData: eval(getItem('orgNameData')).join('>'),  //拟稿部门
      // nuclearManData: '',  //核稿人
      formMissionData: [],  //会签部门
      formMissionMemberData: [], //会签人员
      crossStatus: getItem('crossStatus'),
      //获取当前用户角色
      roles: JSON.parse(getItem('roles')),
      formPeopleWeightData: [],
    }
  },
  created () {
    this.judgeSuperAdmin()
    this.init()
    this.initFormData()
    this.getAllPeople()
    this.initFormSchema()
    // this.getPersonStatus();
    this.getDocumentType()
  },
  watch: {
    nuclearManData () {
      this.initFormData()
    },
//      formMissionMemberData() {
//        this.initFormSchema();
//      }
  },
  computed: {
    //判断加载圈是否能隐藏
    pageLoading: {
      get: function () {
        return !(this.loadingJudgeData.documentTypeDataDone && this.loadingJudgeData.operationDone)
      },
      set: function () {

      }
    }
  },
  methods: {
    // 判断form字段是否可以编辑
    judgeFormEditable (step) {
      return (this.canEdit && this.projectStep === step)
    },
    getAllPeople () {
      let params = {
        path: {
          id: 0
        }
      }
      Api.Administration.getPeers(params).then((result) => {
        this.loadingJudgeData.peopleDataDone = true
        this.loadingJudgeData.formProjectAdmin = true
        if (result.status === 0) {
          this.formProjectManagerData = this.assembleOrgData(result.data)
          this.formProjectAdmin = this.assembleOrgData(result.data)
          this.formBranchLeader = this.assembleOrgData(result.data)
          this.formMainLeader = this.assembleOrgData(result.data)
          this.formPeopleData = this.assembleOrgData(result.data)
        } else {
          this.$message.error(result.msg)
        }
      })
    },
    init () {
      console.log("init执行了没")
      let orgIdArray = JSON.parse(getItem('orgIdData'))
      let userInfoId = getItem('userInfoId')
      let orgId = orgIdArray[orgIdArray.length - 1]
      this.draftDeptId = orgId
      Api.PersonnelManagement.personLeaderMember(orgId).then((result) => {
        if (result.status === 0) {
          let memberList = []
          for (let member of result.data) {
            memberList.push(member.personName)
            this.formPeopleData.push(member.personName)
          }
          this.formModel.nuclearMan = memberList.join('，')
          if (!this.formModel.isSigned) {
            this.formModel.signedPerson = memberList.join(',')
          }
        }
      })
      let orgList = []
      Api.Common.getOrganization().then((result) => {
        if (result.status === 0) {
          orgList = result.data[0].childList
          for (let org of orgList) {
            this.formMissionData.push({
              label: org.name,
              model: org.id
            })
          }
          if (!this.formModel.isSigned) {
            this.formModel.signedDepts.push(orgId)
            this.formModel.executeDepts.push(orgId)
            this.getSignedMember()
          }
        }
      })
      let params = {
        path: {
          id: 0
        }
      }
      Api.Administration.getPeers(params).then((result) => {
        if (result.status === 0) {
          this.formPermissionsData = this.assembleOrgData(result.data)
        } else {
          this.$message.error(result.msg)
        }
      })
    },
    //判断是否是超级管理员
    judgeSuperAdmin () {
      this.isSuperAdmin = (getItem('userId') == 0)
    },
    /*
     * form相关
     */
    //获取表单数据源
    initFormData () {
      this.formModel = {
        formOpenRangeData: this.formOpenRangeData,
        step: 0,
        draftMan: this.draftManData,
        draftManId: this.draftManId,
        draftDeptName: this.draftDeptNameData,
        projectName: '',
        copying: '',
        cC: '',
        difficultyFactor: 1,
        isSigned: false,
        signedDepts: [],
        executeDepts: [],
        signedPerson: '',
        openRange: '',

        permissionsPeople: [],
        projectAdmin:[],
        branchLeaders:[],
        MainLeader:[],
        // permissions: 0,
        // nuclearMan: '',
        // contentTitle: '',
        // contentClass: '',
        // CategoryID: '',
        receiveNum: '',
        gross: '',
        budget: '',
        // budgetRate: '',
        // contRate: '',
        scheme: '',
        goal: '',
        // content: '',
        membersList: [],
        // imprintNum: '',
        endDate: '',
        fileData: [],
        imprintDate: '',
        executeDate: '',
        formProjectNo: '',
        documentType: 2,
        year: moment().format('YYYY'),
      }
      this.formBtnData = [
        {
          title: this.formBtnTitle,
          type: 'primary',
          callback: () => {
            if (this.formValidate()) {
              this.formSubmit()
            }
          }
        },
        {
          title: '取消',
          type: 'default',
          callback: () => {
            this.$router.go(-1)
          }
        },
      ]
    },
    initFormSchema () {
      this.formSchema = [
        {
          type: 'custom-input',
          title: '立项人',
          model: 'draftMan',
          externalValue: {
            disabled: true,
          }
        },
        {
          type: 'custom-input',
          title: '立项部门',
          model: 'draftDeptName',
          externalValue: {
            disabled: true
          }
        },
        {
          type: 'custom-date-picker',
          title: '填表日期',
          model: 'imprintDate',
          externalValue: {
            disabled: false,
            dateFormat: 'yyyy-MM-dd'
          }
        },
        {
          type: 'custom-radio',
          title: '项目类别',
          model: 'openRange',
          rules: [
            {required: true, message: '项目类别不能为空'}
          ],
          externalValue: {
            options: this.formOpenRangeData,

          }
        },
        {
          type: 'custom-input',
          title: '项目编码',
          model: 'projectNo',
          externalValue: {
            disabled: false
          }
        },
        {
          type: 'custom-input',
          title: '项目名称',
          model: 'projectName',
          externalValue: {
            disabled: false
          }
        },
        {
          type: 'custom-selector',
          title: '执行部门',
          model: 'executeDepts',
          rules: [
            {required: true, message: '执行部门不能为空'}
          ],
          externalValue: {
            multiple: true,
            options: this.formMissionData
          }
        },
        {
          type: 'custom-date-picker',
          title: '执行时间',
          model: 'executeDate',
          rules: [
            {required: true, message: '执行时间不能为空'}
          ],
          externalValue: {
            disabled: false,
            dateFormat: 'yyyy-MM-dd'
          }
        },
        {
          type: 'custom-cascader-multiple',
          title: '项目组成员',
          model: 'permissionsPeople',
          closable: true,
          externalValue: {
            disabled: this.formModel.openRange === '',
            value: this.formCustomizePeopleData,
            tagNameByC: this.formModel.permissionsPeople,
            changeOnSelect: true,
            options: this.formPermissionsData
          }
        },
        {
          type: 'custom-cascader',
          title: '项目负责人',
          model: 'projectManagerData',
          rules: [
            {required: true, message: '项目负责人不能为空'}
          ],
          externalValue: {
            // disabled: !this.judgeFormEditable('apply'),
            disable: true,
            options: this.formProjectManagerData
          }
        },
        {
          type: 'custom-cascader',
          title: '项目管理员',
          model: 'projectAdmin',
          rules: [
            {required: true, message: '项目管理员不能为空'}
          ],
          externalValue: {
            // disabled: !this.judgeFormEditable('apply'),
            disable: true,
            options: this.formProjectAdmin
          }
        },
        {
          type: 'custom-cascader',
          title: '分管领导',
          model: 'branchLeaders',
          rules: [
            {required: true, message: '分管领导不能为空'}
          ],
          externalValue: {
            // disabled: !this.judgeFormEditable('apply'),
            disable: true,
            options: this.formBranchLeader
          }
        },
        {
          type: 'custom-cascader',
          title: '主要领导',
          model: 'MainLeader',
          rules: [
            {required: true, message: '主要领导不能为空'}
          ],
          externalValue: {
            // disabled: !this.judgeFormEditable('apply'),
            disable: true,
            options: this.formMainLeader
          }
        },
        {
          type: 'custom-input',
          title: '项目来源',
          model: 'cC',
          externalValue: {
            disabled: false
          }
        },
        {
          type: 'custom-input-number',
          title: '难度系数',
          model: 'difficultyFactor',
          // rules: [
          //   {required: true, message: '难度系数不能为空'},
          //   {type: 'number', message: '难度系数必须为数字值或小数'}
          // ],
          externalValue: {
            disabled: false
          }
        },
        // {
        //   type: 'custom-input',
        //   title: '项目编码',
        //   model: 'receiveNum',
        //   // rules: [],
        //   externalValue: {
        //     disabled: false
        //   }
        // },
        {
          type: 'custom-input-number',
          title: '项目总额(万元)',
          model: 'gross',
          // rules: [
          //   {required: true, message: '项目总金额不能为空'},
          //   {type: 'number', message: '项目总金额必须为数字值'}
          // ],
          externalValue: {}
        },
        {
          type: 'custom-input-number',
          title: '支出预算(万元)',
          model: 'budget',
          // rules: [
          //   {required: true, message: '支出预算不能为空'},
          //   {type: 'number', message: '支出预算必须为数字值'}
          // ],
          externalValue: {}
        },
        {
          type: 'custom-textarea',
          title: '支出测算方案',
          model: 'scheme',
          // rules: [
          //   {required: true, message: '项目说明不能为空'},
          // ],
          externalValue: {}
        },
        {
          type: 'custom-textarea',
          title: '项目绩效目标',
          model: 'goal',
          // rules: [
          //   {required: true, message: '项目说明不能为空'},
          // ],
          externalValue: {}
        },
        {
          type: 'custom-dynamic',
          title: '季度考核指标',
          model: 'membersList',
          externalValue: {
            btnData: {
              title: '新增',
              callback: () => {
                this.formPeopleWeightData.push(
                  {
                    span: 24,
                    model: {
                      quarter: '',
                      number: '',
                      indexName: '',
                      levelA: '',
                      levelB: '',
                      levelC: '',
                      levelD: '',
                      budgetRate: '',
                      contRate: '',
                    },
                    schema: [
                      {
                        type: 'custom-selector',
                        title: '季度',
                        model: 'quarter',
                        span: 5,
                        externalValue: {
                          multiple: false,
                          options: this.formQuarterData
                        }
                      },
                      {
                        type: 'custom-input-number',
                        title: '序号',
                        model: 'number',
                        span: 4,
                        externalValue: {}
                      },
                      {
                        type: 'custom-input',
                        title: '指标名称',
                        model: 'indexName',
                        span: 7,
                        externalValue: {}
                      },
                      {
                        type: 'custom-input',
                        title: 'A档',
                        model: 'levelA',
                        span: 4,
                        externalValue: {}
                      },
                      {
                        type: 'custom-input',
                        title: 'B档',
                        model: 'levelB',
                        span: 4,
                        externalValue: {}
                      },
                      {
                        type: 'custom-input',
                        title: 'C档',
                        model: 'levelC',
                        span: 4,
                        externalValue: {}
                      },
                      {
                        type: 'custom-input',
                        title: 'D档',
                        model: 'levelD',
                        span: 4,
                        externalValue: {}
                      },
                      {
                        type: 'custom-input',
                        title: '预算累计执行率',
                        model: 'budgetRate',
                        span: 6,
                        externalValue: {}
                      },
                      {
                        type: 'custom-input',
                        title: '成本累计控制率',
                        model: 'contRate',
                        span: 6,
                        externalValue: {}
                      },
                      {
                        type: 'delete',
                        callback: (index) => {
                          this.formPeopleWeightData.splice(index, 1)
                          this.formModel.membersList = this.formPeopleWeightData
                          this.initFormSchema()
                        }
                      },
                    ],
                  },
                )
                this.formModel.membersList = this.formPeopleWeightData
                this.initFormSchema()
              }
            },
            dynamicData: this.formPeopleWeightData
          }
        },
        {
          type: 'custom-upload-file',
          title: '附件',
          model: 'fileData',
          externalValue: {
            name: 'file',
            actionUrl: `${baseUrl}/api/common/file-upload`,
            requestHeader: {},
            requestData: {},
            uploadFileSuccess: (response, file, fileList) => {
              console.log('回调成功')
              console.log(response)
              if (response.status === 0) {
                this.formFileData.push({
                  id: file.uid,
                  name: file.name + '-' + getItem('userName') + '-' + getItem('orgNameStr'),
                  url: baseUrl + response.data.url
                })
                for (let i = 0; i < this.formFileData.length; i++) {
                  this.formModel.fileData = this.formFileData[i].url
                }
//                  this.personBaseFormModel.fileUrl = (this.formFileData);
              } else {
                this.$message.error(response.msg)
              }
            },
            uploadFilePreview: (file) => {
              console.log('预览:')
              console.log(file)
              window.open(file.url, '_blank')
            },
            uploadFileRemove: (file, fileList) => {
              for (let i = 0; i < this.formFileData.length; i++) {
                if (file.uid === this.formFileData[i].uid) {
                  this.formFileData.splice(i, 1)
                  break
                }
              }
              this.initFormSchema()
            },
            fileList: this.formFileData
          }
        },
        // {
        //   type: "custom-input-number",
        //   title: '印文数量(份)',
        //   model: 'imprintNum',
        //   rules: [],
        //   externalValue: {}
        // },
        {
          type: 'submit'
        }
      ]
    },
    getPersonStatus () {
      /*根据账号ID,查询人员信息*/
      let id = this.formModel.draftManId
      // alert(id);
      Api.PersonnelManagement.personDocumentNew(id).then((result) => {
        if (result.status === 0) {
          let personBaseFormModel = result.data.ext
          this.crossStatus = personBaseFormModel.crossStatus
        } else {
          this.$message.info(result.msg)
        }
      })
    },

    //获取文种
    getDocumentType () {
      let param = {
        query: {},
        data: {
          category: 'publicationCategory',
        }
      }
      //判断只有协会的人员可以选择所有的发文,技交所人员不能选择鄂技协和鄂技协纪要
      Api.SystemSetting.getBaseData(param).then((result) => {
        this.loadingJudgeData.documentTypeDataDone = true
        if (result.status === 0) {
          var role = this.roles
          console.log(this.roles)
          /*if(this.crossStatus == 2 || this.crossStatus == 1){
            for (let i = 0; i < result.data.length; i++) {
              let purchaseItem = result.data[i];
              this.formDocumentTypeData.push({
                model: purchaseItem.id,
                label: purchaseItem.termName
              });
            }
          }else{
            for (let i = 0; i < result.data.length; i++) {
              let purchaseItem = result.data[i];
              if(purchaseItem.termNo != 12 && purchaseItem.termNo != 13){
                this.formDocumentTypeData.push({
                  model: purchaseItem.id,
                  label: purchaseItem.termName
                });
              }

            }
          }*/
          for (let i = 0; i < result.data.length; i++) {
            let purchaseItem = result.data[i]
            if (purchaseItem.termNo == 1
              || purchaseItem.termNo == 2
              || purchaseItem.termNo == 3
              || purchaseItem.termNo == 5
              || purchaseItem.termNo == 14
              || purchaseItem.termNo == 15
            ) {
              this.formDocumentTypeData.push({
                model: purchaseItem.id,
                label: purchaseItem.termName
              })
            }
          }
          if (this.crossStatus == 2 || this.crossStatus == 1) {
            this.formDocumentTypeData.push({
              model: '978108623924236290',
              label: '鄂技协'
            })
            this.formDocumentTypeData.push({
              model: '978108532228362241',
              label: '鄂技协纪要'
            })
          }
          //判断专人选择专项文种
          if (role.toString().indexOf('办公室主任') > -1 || role.toString().indexOf('人事专员') > -1) {
            this.formDocumentTypeData.push({
              model: '978255291938586740',
              label: '鄂技交办公会议纪要'
            })
          }
          if (role.toString().indexOf('人事主管') > -1 || role.toString().indexOf('人事专员') > -1) {
            this.formDocumentTypeData.push({
              model: '976656351180701697',
              label: '鄂技交党总支部会议纪要'
            })
          }
          if (role.toString().indexOf('党建专员') > -1) {
            this.formDocumentTypeData.push({
              model: '976656222025498625',
              label: '鄂技交党'
            })
          }
          if (role.toString().indexOf('财务专员') > -1) {
            this.formDocumentTypeData.push({
              model: '976656179017105409',
              label: '鄂技交财'
            })
            this.formDocumentTypeData.push({
              model: '976656079536603137',
              label: '鄂技交人'
            })
          }
          if (role.toString().indexOf('工会干事') > -1) {
            this.formDocumentTypeData.push({
              model: '976656401982111746',
              label: '鄂技交工'
            })
          }
          if (role.toString().indexOf('纪检') > -1) {
            this.formDocumentTypeData.push({
              model: '976656263691714561',
              label: '鄂技交纪'
            })
          }
          console.log(this.formDocumentTypeData)
        } else {
          this.$message.error(result.msg)
        }
      })
    },
    //获取文本编号
    getDocumentCode () {
      let param = {
        path: {
          id: this.formModel.CategoryID
        }
      }
      this.loadingJudgeData.operationDone = false
      Api.Administration.getDocumentCode(param).then((result) => {
        this.loadingJudgeData.operationDone = true
        if (this.formModel.CategoryID == '978255291938586738') {
          this.formModel.receiveNum = '无文号'
        } else {
          if (result.status === 0) {
            this.formModel.receiveNum = result.data
            this.initFormSchema()
          } else {
            this.$message.error(result.msg)
          }
        }

      })
    },
    //根据会签部门自动获取会签人（部门主任）
    getSignedMember () {
      if ($.inArray(this.draftDeptId, this.formModel.signedDepts) < 0) {
        this.formModel.signedDepts.splice(0, 0, this.draftDeptId)
      }
      let signedsData = (this.formModel.signedDepts || []).join(',')
      this.formMissionMemberData.splice(0, this.formMissionMemberData.length)
      Api.PersonnelManagement.personLeaderMember(signedsData).then((result) => {
        if (result.status === 0) {
          for (let member of result.data) {
            if ($.inArray(member.personName, this.formMissionMemberData) >= 0) {
              continue
            }
            this.formMissionMemberData.push(member.personName)
          }
          this.formModel.signedPerson = this.formMissionMemberData.join('，')
//            this.initFormSchema();
        }
      })
    },
    //选择是否带任务后刷新界面
    radioValueChanged () {
      this.initFormSchema()
    },
    //选择自有发文后显示发文类型
    selectorValueChanged (model) {
      if (model === 'contentClass') {
        this.initFormSchema()
      }
      if (model === 'CategoryID') {
        let categoryItem = this.formDocumentTypeData.find(item => item.model == this.formModel.CategoryID)
        if (categoryItem) {
          if (categoryItem.label == '其他') {
            return
          }
        }
        this.getDocumentCode()
      }
      if (model === 'signedDepts') {
        this.getSignedMember()
      }
    },
    //多选级联下拉框值传值
    cascaderMultipleValueChanged (model) {
      this.formCustomizePeopleData = model
    },
    //表单验证
    formValidate () {
      return this.$refs.childrenForm.validate()
    },
    //清空表单
    formResetFields () {
      this.formFileData = []
      this.$refs.childrenForm.resetFields()
      this.initFormSchema()
      this.formPeopleWeightData = []
    },

    //取消提交
    formCancel () {
      this.formResetFields()
    },
    //表单提交
    formSubmit (data) {
      this.$refs.childrenForm.letTextEditorSubmit()
      let ext = {}
      $.extend(true, ext, this.formModel)
      let membersList = []
      for (let i = 0; i < this.formPeopleWeightData.length; i++) {
        membersList.push(this.formPeopleWeightData[i].model)
      }
      ext.membersList = membersList
      let feesList = []
      let projectParentId = ''
      if (this.projectStep === 'apply') {
        projectParentId = ''
      } else {
        projectParentId = this.formModel.projectId
      }
      ext.feesList = feesList
      ext.applyDate = moment(ext.applyDate).format('YYYY-MM-DD')
      ext.endDate = moment(ext.endDate).format('YYYY-MM-DD')
      ext.applyFileData = this.formApplyFileData
      ext.executeFileData = this.formExecuteFileData
      ext.checkFileData = this.formCheckFileData
      let param = {
        data: {
          projectInfoReq: {
            projectCategory: 'init',
            projectStep: 'init',
            projectName: this.formModel.projectName,
            projectNo: this.formModel.projectNo,
            projectParentId: projectParentId,
            description: this.formModel.description,
            ext: ext,
          },
          // 考核集合
          membersList: membersList,
          // 获取项目负责人ID
          map: {
            projectManagerData: this.formModel.projectManagerData[1],
            projectAdmin: this.formModel.projectAdmin[1],
            branchLeaders: this.formModel.branchLeaders[1],
            MainLeader: this.formModel.MainLeader[1]
          }
        }

      }
      $.extend(true, param, this.formModel)
      console.log('param', param)
      param.membersList = membersList
      param['ext'] = {
        formProjectNo: param.formProjectNo,
        membersList: param.membersList,
        // projectManagerData: this.formModel.projectManagerData,
        draftMan: param.draftMan,
        draftDeptName: param.draftDeptName,
        projectName: param.projectName,
        copying: param.copying,
        cC: param.cC,
        difficultyFactor: param.difficultyFactor,
        isSigned: param.isSigned,
        signedDepts: param.signedDepts,
        executeDepts: param.executeDepts,
        signedPerson: param.signedPerson,
        // nuclearMan: param.nuclearMan,
        openRange: param.openRange,
        // permissions: param.permissions,
        permissionsPeople: this.formCustomizePeopleData,
        // contentClass: param.contentClass,
        // imprintNum: param.imprintNum,
        imprintDate: moment(param.imprintDate).format('YYYY-MM-DD HH:mm:ss'),
        executeDate: moment(param.imprintDate).format('YYYY-MM-DD HH:mm:ss'),
        // CategoryID: param.CategoryID,
        receiveNum: param.receiveNum,
        gross: param.gross,
        budget: param.budget,
        scheme: param.scheme,
        goal: param.goal,
        isTask: false,
        year: param.year,
        fileData: this.formFileData,
        fileDataList: this.formFileData,
        documentType: param.documentType,
        // budgetRate: param.budgetRate,
        // contRate: param.contRate
      }
      param.fileData=this.formFileData
//        return false;
      this.loadingJudgeData.operationDone = false
      console.log('新增之前的参数', param)
      Api.ProjectManagements.addProjectInit(param).then((result) => {
        this.loadingJudgeData.operationDone = true
        if (result.status === 0) {
          this.$message({
            type: 'success',
            message: '新增成功!'
          })
          this.$router.go(-1)
        } else {
          this.$message.error(result.msg)
        }
      })
    },
    //递归组装级联选择器数据源
    assembleOrgData (source) {
      let dest = []
      for (let i = 0; i < source.length; i++) {
        let org = {
          value: source[i].id,
          label: source[i].name
        }
        if (source[i].childList && source[i].childList.length > 0) {
          org['children'] = this.assembleOrgData(source[i].childList)
        }
        dest.push(org)
      }
      return dest
    },

    setCascaderMultipleValue (value) {
//        this.formCustomizePeopleData = [];  //清空级联选择器选中值
      let extOptionChildrens = this.formPermissionsData.find(item => item.value == value[0]).children
      let checkV = extOptionChildrens.find(item => item.value == value[1])
      let checkInclude = this.formModel.permissionsPeople.find(item => item.value == value[1])
      if (!checkInclude) {
        this.formModel.permissionsPeople.push(checkV)
        this.formCustomizePeopleData.push(value[value.length - 1])
      }
    },

    handleClose (model) {
      this.formModel.permissionsPeople.find((item, index) => {
        if (item.value === model.value) {
          this.formModel.permissionsPeople.splice(index, 1)
          this.formCustomizePeopleData.splice(index, 1)
          this.initFormSchema()
          return true
        }
      })
    },

  },
  components: {
    PageLoading, DataForm
  }
}
</script>

<style scoped lang="less" rel="stylesheet/less">
.expand-right {
  @media (min-width: 768px) {
    padding-left: 0 !important;
  }
}

.page-content {
  padding: 15px;
}
</style>
