<template>
  <div style="background-color: #eeeeee;min-height: 100vh;">
    <div style="padding: 0 0 10% 4%;width: 92%">
      <div style="background-color: white;border-radius: 10px;padding: 5% 5% 5% 5%;min-height: 78vh">
        <!--        一、内容选取-->
        <div v-if="!approvalShow">
          <div style="text-align: left;padding: 4% 0 0 1%;font: bold 14px 新宋体">一、内容选取</div>
          <div style="width: 90%;padding-left: 5%;font-size: 12px">
            <div class="showDiv" style="padding: 1%"></div>
            <div style="display: flex;min-height: 30px;">
              <div style="text-align: left;padding: 1% 0 1% 4%;width: 38%">1.时间选取:</div>
              <div style="width: 50%">
                <picker mode="date" :value="dataForm.planTime" fields="day" @change="bindYearChange">
                  <view class="picker">
                    <input disabled placeholder=" " style="text-align: left"
                           v-model="dataForm.planTime"></input>
                  </view>
                </picker>
              </div>
              <div class="arrowOpen"></div>
            </div>
            <div class="showDiv"></div>
            <div style="display: flex;min-height: 30px;" @click="showPicker(3)">
              <div style="text-align: left;padding: 1% 0 1% 4%;width: 38%">2.是否一天:</div>
              <div style="width: 50%">
                <input disabled placeholder=" " style="text-align: left"
                       v-model="dataForm.isOne"></input>
              </div>
              <div class="arrowOpen"></div>
            </div>
            <div class="showDiv"></div>
            <div v-if="!yjButtonShow" style="display: flex;min-height: 30px;"
                 @click="goToo('/pages/pageplan/businessplan/addEdit/importProject/main?title=明日计划-新增-立项名称选取')">
              <div style="text-align: left;padding: 1% 0 1% 4%;width: 38%">2.立项名称选取:</div>
              <div style="width: 50%">
                <input disabled placeholder="点击此处选择" style="text-align: left"
                       v-model="dataForm.project"></input>
              </div>
              <div class="arrowOpen"></div>
            </div>
            <div v-if="yjButtonShow" style="display: flex;min-height: 30px;">
              <div style="text-align: left;padding: 1% 0 1% 4%;width: 38%">3.立项名称:</div>
              <div style="width: 50%">
                <input disabled placeholder=" " style="text-align: left"
                       v-model="dataForm.project"></input>
              </div>
            </div>
            <div class="showDiv"></div>
            <div style="display: flex;min-height: 30px;">
              <div style="text-align: left;padding: 1% 0 1% 4%;width: 38%">4.负责工长:</div>
              <div style="width: 50%">
                <input disabled placeholder=" " style="text-align: left"
                       v-model="dataForm.planFzgz"></input>
              </div>
            </div>
            <div class="showDiv"></div>
            <div style="display: flex;min-height: 30px;" @click="showPicker(1)">
              <div style="text-align: left;padding: 1% 0 1% 4%;width: 38%">5.带队人选取:</div>
              <div style="width: 50%">
                <input disabled placeholder=" " style="text-align: left"
                       v-model="dataForm.planDd"></input>
              </div>
              <div class="arrowOpen"></div>
            </div>
            <!--<div class="showDiv"></div>
            <div style="display: flex;min-height: 30px;" @click="showPicker(4)">
              <div style="text-align: left;padding: 1% 0 1% 4%;width: 38%">5.工种选取:</div>
              <div style="width: 50%">
                <input disabled placeholder=" " style="text-align: left"
                       v-model="gzForm.job"></input>
              </div>
              <div class="arrowOpen"></div>
            </div>-->
            <div class="showDiv"></div>
            <div style="display: flex;min-height: 30px;">
              <div style="text-align: left;padding: 1% 0 1% 4%;width: 38%" @click="showPicker(2)">6.施工人员选取:</div>
              <div style="width: 50%" @click="showPicker(2)">
                <input disabled placeholder=" " style="text-align: left"
                       v-model="dataForm.selectPersion"></input>
              </div>
              <div class="arrowOpen" @click="showPicker(2)"></div>
              <div style="display: flex;padding: 1px">
                <button type="button" class="qkBtn" size="mini"
                        @click="clearSearch()">清空
                </button>
              </div>
            </div>
            <div class="showDiv"></div>
          </div>
        </div>
        <!--        二、自动生成属性信息-->
        <div style="font-size: 12px">
          <div v-if="!approvalShow" style="text-align: left;padding: 6% 0 1% 1%;font: bold 14px 新宋体">二、自动生成属性信息</div>
          <div v-else style="text-align: left;padding: 6% 0 1% 1%;font: bold 14px 新宋体">一、自动生成属性信息</div>
          <div class="showDivDo"></div>
          <div>
            <div style="padding: 1% 0">
              <span>1.立项属性信息</span>
            </div>
            <div v-if="dataProjectList.length > 0">
              <div style="margin-left: 5%" v-for="(itemChildren,indexSon) in dataProjectList"
                   :key="indexSon">
                <span v-if="itemChildren.projectNewName != null && itemChildren.projectNewName != '' && itemChildren.projectNewName != undefined">
                    ① 立项名称：{{ itemChildren.projectNewName }};<br></span>
                <span v-else>① 立项名称：{{ itemChildren.project }};<br></span>

                <span v-for="(itemDic,index) in dicJsdwList" :key="index"
                      v-if="itemChildren.projectJsdwId == itemDic.dictId">② 建设单位：{{ itemDic.name }}<br></span>
                <span v-for="(itemDic,index) in dicSgddList" :key="index"
                      v-if="itemChildren.projectSgddId == itemDic.dictId">③ 施工地点：{{ itemDic.name }}<br></span>
                <span>④ 施工年份：{{ itemChildren.projectYear ? itemChildren.projectYear : "暂无" }}<br></span>
                <span>⑤ 开工时间：{{ itemChildren.projectStart ? itemChildren.projectStart : "暂无" }}<br></span>
                <span>⑥ 竣工时间：{{ itemChildren.projectEnd ? itemChildren.projectEnd : "暂无" }}<br></span>
                <span>⑦ 施工进度：
                   <span v-for="(itemDic,index) in dicSgjdList" :key="index"
                         v-if="itemChildren.projectSgjdId == itemDic.dictId">{{ itemDic.name }}</span><br>
                </span>
<!--                <span v-for="(itemDic,index) in dicSgjdList" :key="index"
                      v-if="itemChildren.projectSgjdId == itemDic.dictId">⑥ 施工进度：{{ itemDic.name }};<br></span>-->
                <span>⑧ 负责工长：{{ itemChildren.fzgz ? itemChildren.fzgz : "暂无" }}<br></span>
                <span>⑨ 联络员：{{ itemChildren.lly ? itemChildren.lly : "暂无" }}<br></span>
<!--                <span v-for="(itemDic,index) in dicGclbList" :key="index"
                      v-if="itemChildren.projectGclbId == itemDic.dictId">⑨ 工程类别：{{ itemDic.name }};<br></span>-->
                <span>⑩ 工程类别：
                  <span v-for="(itemDic,index) in dicGclbList" :key="index"
                        v-if="itemChildren.projectGclbId == itemDic.dictId">{{ itemDic.name }}</span><br>
                </span>
                <!--
                                <span v-for="(itemDic,index) in dicSJDWList" :key="index"
                                      v-if="itemChildren.projectSgddId == itemDic.dictId">⑥ 施工地点：{{ itemDic.name }};<br></span>-->
                <!--                  <span>工程类别：{{ itemDic.name }};</span>-->


              </div>
            </div>
            <div v-else style="text-align: center">
              <span>无</span>
            </div>
          </div>
          <div style="margin-top: 10%">
            <div style="padding: 1% 0">
              2.合同属性:
            </div>
            <div v-if="dataContractList.length > 0">
              <div style="margin-left: 5%">
                <span>① 合同名称：{{
                    dataContractList[0].contractNewName ? dataContractList[0].contractNewName : dataContractList[0].contractName
                  }};<br></span>
                <span>② 直非友：{{
                    dataContractList[0].zfy ? dataContractList[0].zfy : "暂无"
                  }};<br></span>
                <span>③ 合同年份：{{
                    dataContractList[0].contractYear ? dataContractList[0].contractYear : "暂无"
                  }};<br></span>
                <span>④ 施工单位：{{
                    dataContractList[0].sgdw ? dataContractList[0].sgdw : "暂无"
                  }};<br></span>
                <span>⑤ 监理单位：{{
                    dataContractList[0].jldw ? dataContractList[0].jldw : "暂无"
                  }};<br></span>
                <span>⑥ 一审单位：{{
                    dataContractList[0].ysdw ? dataContractList[0].ysdw : "暂无"
                  }};<br></span>
                <span>⑦ 二审单位：{{
                    dataContractList[0].esdw ? dataContractList[0].esdw : "暂无"
                  }};<br></span>
              </div>
            </div>
            <div v-else style="margin-left: 5%;text-align: center">
              <span>暂无<br></span>
            </div>
          </div>
          <!-- 是否是一天-->
          <div style="margin-top: 10%">
            <div style="padding: 1% 0">
              3.是否1天: {{oneDay}}
            </div>
          </div>
          <!-- 施工人员-->
          <div style="margin-top: 10%">
            <div style="padding: 1% 0">
              4.施工人员:  {{seletPersion}}
            </div>
          </div>
          <div class="showDivDo" style="padding: 2%"></div>
        </div>
        <!--        三、施工内容-->
        <div style="font-size: 14px">
          <div v-if="!approvalShow" style="text-align: left;padding: 8% 0 0 2%;font: bold 14px 新宋体">三、施工内容</div>
          <div v-else style="text-align: left;padding: 8% 0 0 2%;font: bold 14px 新宋体">二、施工内容</div>
          <div class="showDivDo" style="padding: 1%"></div>
          <div>
            <div style="padding: 1% 0">
              <div>1、内容</div>
              <div style="font-size: 11px">每日完成的工程量(用数字表达)，进度百分比及待完成的工程内容</div>
            </div>
            <div>
              <textarea :disabled="approvalShow" v-model="dataForm.planSgSummary" placeholder="每日完成的工程量，进度百分比及待完成的工程内容" maxlength="4000"
                        style="border: 1px dashed black;padding-top: 1%;width:100%"></textarea>
            </div>
          </div>

          <div>
            <div style="padding: 10% 0 1% 0">
              <div>2、材料、机械及工具</div>
              <div style="font-size: 11px">需不落项，且具体到数量</div>
            </div>
            <div>
              <textarea :disabled="approvalShow" v-model="dataForm.planCl" placeholder="主要涉及到材料、机械及工具，具体到使用数量，若没有想到，可以空着不写" maxlength="4000"
                        style="border: 1px dashed black;padding-top: 1%;width:100%"></textarea>
            </div>
          </div>

          <div>
            <div style="padding: 10% 0 1% 0">
              <div>3、自检总结</div>
              <div style="font-size: 11px">①计划派工不为1的情况说明(多数为离职未更改、请假、临时换人、施工项目更改等)</div>
              <div style="font-size: 11px">②实际派工不为1的情况说明(多数为加班，或者突发情况临时请假等)</div>
              <div style="font-size: 11px">③完成工程量与人员匹配情况是否正常，若不正常，给予情况说明</div>
            </div>
            <div>
              <textarea :disabled="approvalShow" v-model="dataForm.planJx" placeholder="主要涉及计划派工、实际派工、工程量匹配，若没有想到,可以空着不写" maxlength="4000"
                        style="border: 1px dashed black;padding-top: 1%;width:100%"></textarea>
            </div>
          </div>
          <div class="showDivDo" style="padding: 2%"></div>
        </div>
        <div style="padding: 10% 0 10% 0;display: flex">
          <button v-if="tj" class="btnBu" type="button"
                  @click="deleteData()">删除
          </button>
          <button v-if="!approvalShow" class="btnBu" type="button"
                  @click="dataFormSubmit()">保存
          </button>
          <button v-if="tj" class="btnBu" type="button"
                  @click="dataFormUp()">提交
          </button>
        </div>
      </div>
    </div>
    <!--    弹框位置-->
    <mpvue-picker v-if="isShow" ref="mpvuePicker"
                  :pickerValueArray='pickerValueArray'
                  :pickerValueDefault='pickerValueDefault'
                  @onConfirm="pickerConfirm"></mpvue-picker>
  </div>

</template>

<script>
import mpvuePicker from 'mpvue-picker'
import uploadImage from '@/components/upload-image'

export default {
  components: {
    mpvuePicker,
    uploadImage,
  },
  data() {

    return {
      id: "",
      isShow: true,
      buttonShow: true,
      pickerValueDefault: [0],
      pickerValueArray: [],
      flag: 0,
      ryList: [],//可分配 未离职 人员列表信息
      sgrList: [],//施工人list
      isOneDayList: [],//是否一天
      chooseId: '',//project 选择的id
      seletPersion: '',
      oneDay: "",//是否一天
      disableAll: false,
      approvalShow: false,//申请按钮关联控制
      yjButtonShow: false,//一级按钮显示控制
      dataProjectList: [],
      dataContractList: [],
      dicSgjdList: [],
      dicSgddList: [],
      dicGclbList: [],
      dicJsdwList: [],
      dicZFYList: [],
      dicSGDWList: [],
      dicJLDWList: [],
      dicSJDWList: [],
      dicGZList: [], // 工种list
      tj: false,
      gzForm: {
        jobId:'',
        job: '',
      },
      dataForm: {
        id: '',
        planTime: '',
        project: '',
        planProjectId: '',
        planDdId: '',
        planDd: '',
        planFzgz: '',
        selectPersionId: '',
        selectPersion: '',
        planPersonNum: '',
        isOneDay: '',
        isOne: '',
        planSgSummary: '',
        planCl: '',
        planJx: '',
        type: '',
        status: '',
        isTotal: '',
      },
    }
  },

  methods: {
    // 清空施工人员
    clearSearch() {
      this.dataForm.selectPersionId = "";
      this.dataForm.selectPersion = "";
      this.$forceUpdate()
    },
    /********************************* 页面跳转 ***********************************/
    goToo(url) {
      wx.navigateTo({
        url: url
      })
    },
    /********************************* 页面跳转 ***********************************/
    /********************************* 弹框 ***********************************/
    //时间弹框
    bindYearChange: function (e) {
      this.clearSearch();
      this.dataForm.planTime = e.mp.detail.value;
      this.sgrList = []
      //获取可分配并且未离职的人员信息列表
      this.$http.request({
        url: this.$http.adornUrl('/business/businessplan/getNewRyList/' + this.dataForm.planTime),
        method: 'get'
      }).then(({data}) => {
        console.log(data)
        if (data && data.code === 0) {
          this.ryList = data.page;
          data.page.forEach((item) => {
            if(item.position === '外部人员' || item.worker === '工人'){
              this.sgrList.push(item);
            }
          })
        }
      })
      this.$forceUpdate();
    },

//     showPicker(num) {
//       //1-带队人 2-员工 3-是否一天 4-工种
//       this.pickerValueArray = [];
//       if (num === 1) {
//         //带队人
//
//         if(!this.dataForm.planTime) {
//           wx.showToast({
//             title: "请选择时间！",
//             icon: "none",
//             duration: 2000,
//           })
//           return;
//         }
//         if(!this.dataForm.isOne) {
//           wx.showToast({
//             title: "请选择是否一天！",
//             icon: "none",
//             duration: 2000,
//           })
//           return;
//         }
//
//         this.$http.request({
//           url: this.$http.adornUrl("/business/businessworker/queryDdry4Plan"),
//           method: 'post',
//           body: this.$http.adornData({
//             "planTime": this.dataForm.planTime,
//             "oneDay": this.dataForm.isOne
//           })
//         }).then(({data}) => {
//           if (data && data.code === 0) {
//             let flag = false; // 判断选中的人标志
//             data.data.forEach((item) => {
//               // 相等  则会将符合条件的人加入数组
//               if (this.dataForm.selectPersionId !== null && this.dataForm.selectPersionId !== '' && this.dataForm.selectPersionId !== undefined) {
//                 if (this.dataForm.selectPersionId.toString().indexOf(",") < 0) {  // 不包含逗号
//                   if (item.userId.toString() != this.dataForm.selectPersionId.toString()) {
//                     this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                   }
//                 } else {
//                   // 包含逗号
//                   this.dataForm.selectPersionId.split(",").forEach((itemChildren) => {
//                     if (item.userId.toString() === itemChildren.toString()) {
//                       flag = true; // 说明已被选择  则会不加入弹框数组里
//                     }
//                   })
//                   if (flag === false) {
//                     this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                   }
//                   flag = false;
//                 }
//               } else {
//                 this.pickerValueArray.unshift({value: item.userId, label: item.name})
//               }
//             })
//             this.flag = 1;
//             this.$refs.mpvuePicker.show();
//           }
//         })
//
//         /*this.ryList.forEach((item) => {
//           if (item.worker === '带队') {
//             if (this.dataForm.planDdId === null
//               || this.dataForm.planDdId === '' || this.dataForm.planDdId === undefined) {
//               this.pickerValueArray.unshift({value: item.userId, label: item.name})
//             } else if (item.userId !== this.dataForm.planDdId) {
//               this.pickerValueArray.unshift({value: item.userId, label: item.name})
//             }
//           }
//         })
//         this.flag = 1;
//         this.$refs.mpvuePicker.show();*/
//       } else if (num === 2) {
//         //员工
// /*        if (this.dataForm.planDdId !== undefined && this.dataForm.planDdId !== "" && this.dataForm.planDdId !== null) {
//           this.ryList.forEach((item, index) => {
//             if (item.userId === this.dataForm.planDdId) {
//               this.ryList.splice(index, 1)
//             }
//           })
//         }
//         let lxFlag = false;*/
//         /*let flag = false; // 判断选中的人标志
//         this.sgrList.forEach((item) => {
//           if (this.gzForm.jobId === null || this.gzForm.jobId === '' || this.gzForm.jobId === undefined) { // 是否选择了工种   如果选择 则在施工人员中符合条件的人  加入弹框数组
//             if (this.dataForm.selectPersionId !== null && this.dataForm.selectPersionId !== '' && this.dataForm.selectPersionId !== undefined) {
//               if (this.dataForm.selectPersionId.toString().indexOf(",") < 0) {  // 不包含逗号
//                 if (item.userId.toString() !== this.dataForm.selectPersionId.toString()) {
//                   this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                 }
//               } else {
//                 // 包含逗号
//                 this.dataForm.selectPersionId.split(",").forEach((itemChildren) => {
//                   if (item.userId.toString() === itemChildren.toString()) {
//                     flag = true; // 说明已被选择  则会不加入弹框数组里
//                   }
//                 })
//                 if (flag === false) {
//                   this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                 }
//                 flag = false;
//               }
//             } else {
//               this.pickerValueArray.unshift({value: item.userId, label: item.name})
//             }
//           }else{
//             // 相等  则会将符合条件的人加入数组
//             if(item.jobId === this.gzForm.jobId){
//               if (this.dataForm.selectPersionId !== null && this.dataForm.selectPersionId !== '' && this.dataForm.selectPersionId !== undefined) {
//                 if (this.dataForm.selectPersionId.toString().indexOf(",") < 0) {  // 不包含逗号
//                   if (item.userId.toString() !== this.dataForm.selectPersionId.toString()) {
//                     this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                   }
//                 } else {
//                   // 包含逗号
//                   this.dataForm.selectPersionId.split(",").forEach((itemChildren) => {
//                     if (item.userId.toString() === itemChildren.toString()) {
//                       flag = true; // 说明已被选择  则会不加入弹框数组里
//                     }
//                   })
//                   if (flag === false) {
//                     this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                   }
//                   flag = false;
//                 }
//               } else {
//                 this.pickerValueArray.unshift({value: item.userId, label: item.name})
//               }
//             }
//           }
//         })*/
//         // 2023年2月6日20:32:59 根据时间、是否一天，取动态获取。
//         if(!this.dataForm.planTime) {
//           wx.showToast({
//             title: "请选择时间！",
//             icon: "none",
//             duration: 2000,
//           })
//           return;
//         }
//         if(!this.dataForm.isOne) {
//           wx.showToast({
//             title: "请选择是否一天！",
//             icon: "none",
//             duration: 2000,
//           })
//           return;
//         }
//
//         this.$http.request({
//           url: this.$http.adornUrl("/business/businessworker/querySgry4Plan"),
//           method: 'post',
//           body: this.$http.adornData({
//             "planTime": this.dataForm.planTime,
//             "oneDay": this.dataForm.isOne
//           })
//         }).then(({data}) => {
//           if (data && data.code === 0) {
//             let flag = false; // 判断选中的人标志
//             data.data.forEach((item) => {
//                 // 相等  则会将符合条件的人加入数组
//                 if (this.dataForm.selectPersionId !== null && this.dataForm.selectPersionId !== '' && this.dataForm.selectPersionId !== undefined) {
//                   if (this.dataForm.selectPersionId.toString().indexOf(",") < 0) {  // 不包含逗号
//                     if (item.userId.toString() != this.dataForm.selectPersionId.toString()) {
//                       this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                     }
//                   } else {
//                     // 包含逗号
//                     this.dataForm.selectPersionId.split(",").forEach((itemChildren) => {
//                       if (item.userId.toString() === itemChildren.toString()) {
//                         flag = true; // 说明已被选择  则会不加入弹框数组里
//                       }
//                     })
//                     if (flag === false) {
//                       this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                     }
//                     flag = false;
//                   }
//                 } else {
//                   this.pickerValueArray.unshift({value: item.userId, label: item.name})
//                 }
//             })
//             this.flag = 2;
//             this.$refs.mpvuePicker.show();
//           }
//         })
//       } else if (num === 3) {
//         this.clearSearch();
//         //是否一天
//         this.isOneDayList.forEach((item) => {
//           if (this.dataForm.isOneDay === null
//             || this.dataForm.isOneDay === '' || this.dataForm.isOneDay === undefined) {
//             this.pickerValueArray.unshift({value: item.dictId, label: item.name})
//           } else if (item.dictId !== this.dataForm.isOneDay) {
//             this.pickerValueArray.unshift({value: item.dictId, label: item.name})
//           }
//         })
//         this.flag = 3;
//         this.$refs.mpvuePicker.show();
//       } else if (num === 4){
//         this.dicGZList.forEach((item) => {
//           if (this.gzForm.jobId === null
//             || this.gzForm.jobId === '' || this.gzForm.jobId === undefined) {
//             this.pickerValueArray.unshift({value: item.dictId, label: item.name})
//           } else if (item.dictId !== this.gzForm.jobId) {
//             this.pickerValueArray.unshift({value: item.dictId, label: item.name})
//           }
//         })
//         this.flag = 4;
//         this.$refs.mpvuePicker.show();
//       }
//     },

    // pickerConfirm(e) {
    //   //1-带队人 2-员工 3-是否一天 4-工种
    //   if (this.flag === 1) {
    //     this.dataForm.planDd = e.label;
    //     this.dataForm.planDdId = e.value[0];
    //     if (this.dataForm.planDdId === undefined || this.dataForm.planDdId === null || this.dataForm.planDdId === "") {
    //       this.dataForm.planPersonNum += 1;
    //     }
    //   } else if (this.flag === 2) {
    //     if (this.dataForm.selectPersionId === null || this.dataForm.selectPersionId === "" || this.dataForm.selectPersionId === undefined) {
    //       this.dataForm.selectPersionId = e.value[0];
    //       this.dataForm.selectPersion = e.label;
    //     } else {
    //       this.dataForm.selectPersionId = this.dataForm.selectPersionId + "," + e.value[0];
    //       this.dataForm.selectPersion = this.dataForm.selectPersion + "," + e.label;
    //     }
    //     this.dataForm.planPersonNum += 1;
    //     this.seletPersion = '施工人员：' + this.dataForm.selectPersion
    //   } else if (this.flag === 3) {
    //     this.dataForm.isOne = e.label;
    //     this.dataForm.isOneDay = e.value[0];
    //   } else if (this.flag === 4) {
    //     this.gzForm.job = e.label;
    //     this.gzForm.jobId = e.value[0];
    //   }
    //   this.$forceUpdate()
    // },

    /********************************* 弹框 ***********************************/
    closePage() {
      wx.navigateBack({
        delta: 1
      })
    },

    //   保存表单数据
    dataFormSubmit() {
      //console.log();
      if(this.dataForm.planTime==null){
        wx.showToast({
          title: '时间未填写，请填写后在进行提交',
          icon: 'none',
          duration: 4000//持续的时间
        })
      }else{
        let url;
        if (this.id !== "") {
          url = '/business/businessplan/update';
        } else {
          url = '/business/businessplan/save';
          this.dataForm.isTotal = 0;
        }
        //console.log(this.dataForm);
        this.$http.request({
          url: this.$http.adornUrl(url),
          method: 'post',
          body: this.$http.adornData({
            "id": this.dataForm.id,
            "planTime": this.dataForm.planTime,
            "planProjectId": this.dataForm.planProjectId,
            "planDdId": this.dataForm.planDdId,
            "selectPersionId": this.dataForm.selectPersionId,
            "planPersonNum": this.dataForm.planPersonNum,
            "isOneDay": this.dataForm.isOneDay,
            "planSgSummary": this.dataForm.planSgSummary,
            "planCl": this.dataForm.planCl,
            "planJx": this.dataForm.planJx,
            "type": this.dataForm.type,
            "status": this.dataForm.status,
            "isTotal": this.dataForm.isTotal,
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.closePage();
          }
        })
      }
    },

    //提交
    dataFormUp() {
      this.$http.request({
        url: this.$http.adornUrl('/business/businessplan/update'),
        method: 'post',
        body: this.$http.adornData({
          "id": this.dataForm.id,
          "planTime": this.dataForm.planTime,
          "planProjectId": this.dataForm.planProjectId,
          "planDdId": this.dataForm.planDdId,
          "selectPersionId": this.dataForm.selectPersionId,
          "planPersonNum": this.dataForm.planPersonNum,
          "isOneDay": this.dataForm.isOneDay,
          "planSgSummary": this.dataForm.planSgSummary,
          "planCl": this.dataForm.planCl,
          "planJx": this.dataForm.planJx,
          "type": 1,
          "status": this.dataForm.status,
          "isTotal": this.dataForm.isTotal,
        })
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.closePage();
        }
      })
    },

    //删除
    deleteData() {
      var ids = [this.id]
      this.$http.request({
        url: this.$http.adornUrl('/business/businessplan/delete'),
        method: 'post',
        body: this.$http.adornData(ids, false)
      }).then(({data}) => {
        if (data && data.code === 0) {
          this.closePage();
        }
      })
    },
    //获取立项和合同属性
    getProjectContent() {
      //获取立项属性  合同属性 最新的明日计划信息
      this.dataProjectList = [];
      this.dataContractList = [];
      if (this.dataForm.planProjectId !== undefined) {
        this.$http.request({
          url: this.$http.adornUrl('/business/businessplan/lxHtPlanInfo/' + this.dataForm.planProjectId),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            let res = data.list;
            //console.log(res);
            //立项
            //以防报错
            if (res.project.length > 0) {
              this.dataProjectList = res.project;
              console.log(this.dataProjectList);
              this.dataProjectList.forEach((item)=>{
                this.dataForm.planFzgz = item.fzgz
                if(item.projectNewName !== null){
                  this.dataForm.project = item.projectNewName
                }else{
                  this.dataForm.project = item.project
                }
              })
              console.log(this.dataForm.project);
            }
            //合同
            if (res.contract[this.dataForm.planProjectId].length > 0) {
              this.dataContractList = res.contract[this.dataForm.planProjectId];
              //console.log(this.dataContractList.length);
            }
            //计划
            if (res.plan !== null && this.id === undefined) {//新选中的立项是否有明日计划  如果有则显示信息
              this.dataForm = {
                ...res.plan
              }
              this.dataForm.id = "";
            }
          } else {
            this.closePage();
          }
        })
      }
      this.$forceUpdate();
    },
  },

  onLoad(params) {
    //console.log(params.id);
    wx.setNavigationBarTitle({
      title: params.title
    })
    this.oneDay = params.oneDay;
    this.seletPersion = params.selectPersion;
    this.gzForm = {} // 工种关联form
    this.id = "";
    this.isShow = true;
    this.buttonShow = true;
    this.yjButtonShow = false;
    this.pickerValueDefaultWeather = [0];
    this.pickerValueArrayWeather = [];
    this.disableAll = false;
    this.buttonShow = true;
    this.dataForm = {};
    this.dataForm.status = 0;
    this.dataForm.type = 0;
    this.dataForm.planPersonNum = 0;
    this.ryList = [];
    this.sgrList = []; // 施工人list
    this.isOneDayList = [];
    this.dicSgjdList = [];
    this.dicSgddList = [];
    this.dicGclbList = [];
    this.dicJsdwList = [];
    this.dicZFYList = [];
    this.dicSGDWList = [];
    this.dicJLDWList = [];
    this.dicSJDWList = [];
    this.dicGZList = [];
    this.dataProjectList = [];
    this.dataContractList = [];
    this.tj = false;

    this.flag = 0;
    this.approvalShow = false;
    //获取字典
    this.$http.request({
      url: this.$http.adornUrl('/business/businessplan/dictList'),
      method: 'get'
    }).then(({data}) => {
      //console.log(data);
      if (data && data.code === 0) {
        data.data.forEach((item) => {
          if (item.dictCode === "is_one_day") {
            this.isOneDayList = item.children;
          } else if (item.dictCode === "work_place") {//施工地点
            this.dicSgddList = item.children;
          } else if (item.dictCode === "work_type") {//工程类别
            this.dicGclbList = item.children;
          } else if (item.dictCode === "work_tatus") {//施工进度
            this.dicSgjdList = item.children;
          } else if (item.dictCode === "construction_unit") {//建设单位
            this.dicJsdwList = item.children;
          } else if (item.dictCode === "is_friend") {//直非友
            this.dicZFYList = item.children;
          } else if (item.dictCode === "building_section") {//施工单位
            this.dicSGDWList = item.children;
          } else if (item.dictCode === "surveillance_unit") {//监理单位
            this.dicJLDWList = item.children;
          } else if (item.dictCode === "approval_unit") {//审批单位(一审单位、二审单位)
            this.dicSJDWList = item.children;
          } else if (item.dictCode === 'jobs') { // 工种
            this.dicGZList = item.children;
          }
        })
        //获取可分配并且未离职的人员信息列表
        this.$http.request({
          url: this.$http.adornUrl('/business/businessplan/fpWlzList'),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            console.log(data)
            this.ryList = data.page;
            data.page.forEach((item) => {
              if(item.position === '外部人员' || item.worker === '工人'){
                this.sgrList.push(item);
              }
            })
            if (params.id) {
              this.id = params.id;
              this.$http.request({
                url: this.$http.adornUrl('/business/businessplan/infoNew/' + this.id),
                method: 'get'
              }).then(({data}) => {
                console.log(data);
                if (data && data.code === 0) {
                  this.dataForm = {
                    ...data.businessPlan
                  }
                  this.dataForm.planDd = data.businessPlan.ddName;
                  this.dataForm.planFzgz = data.businessPlan.fzgz;
                  this.dataForm.selectPersion = data.businessPlan.selectPer;
                  this.dataForm.isOne = data.businessPlan.oneDay;
                  this.getProjectContent();
                } else {
                  this.closePage();
                }
              })
            }
          } else {
            this.closePage();
          }
        })
      } else {
        this.closePage();
      }
    })

    if (params.isLink === "1") {
      this.approvalShow = true;
      this.yjButtonShow = true;
    } else if (params.isLink === "0") {
      this.tj = true;
      this.yjButtonShow = true;
    }
  },

  onShow() {
    this.$forceUpdate();
    //获取当前年月
    let nowDate = new Date()
    let date = {
      year: nowDate.getFullYear(),
      month: nowDate.getMonth() + 1,
      date: nowDate.getDate()
    }

    let pages = getCurrentPages();  // 当前页面栈
    let prevPage = pages[pages.length - 1];// 当前页面
    if (prevPage.data.pro_id) {
      this.dataForm.planProjectId = prevPage.data.pro_id;
      //console.log(this.dataForm.planProjectId);
      this.getProjectContent();
    }

  },
  mounted() {

  },
  onUnload() {
    this.isShow = false;
  }
}
</script>

<style scoped>
.showDiv {
  border-bottom: 1px solid black;
  text-align: center;
}

.showDivDo {
  border-bottom: 2px solid #fde866;
  text-align: center;
}

/* 小箭头 */
.arrowOpen {
  /* 设置透明背景色 */
  border: 6px solid transparent;
  border-top-color: black;
  margin-top: 3%;
}

/*向右小箭头*/
.arrowOpenRight {
  border: 8px solid transparent;
  border-left-color: black;
  margin: 2% 0 3% 2%
}

.btn {
  text-align: center;
  border-radius: 8px;
  width: 20%;
  height: 25px;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
}

.btnBu {
  text-align: center;
  width: 25%;
  margin-top: 4%;
  background-color: #fde866;
  height: 5vh;
  border-radius: 5px;
  font-size: 14px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
}

.qkBtn{
  font-size: 10px;
  font-weight: bold;
  background-color: #c5c8ce;
  width: 48px;
  height: 3.6vh;
  justify-content: center;
  align-items: center;
  text-align: center;
  display: flex;
}
</style>
