<template>
  <div>
    <el-table
      class="marT10"
      :data="listPageNum.listTableData"
      style="width: 100% text-align:center;"
      border
      tooltip-effect="dark"
      :header-cell-style="{'background-color': '#fafafa',
    'font-weight':'800'}"
      @selection-change="handleSelectionChange"
      ref="multipleTable"
      v-loading="sbVLoading"
    >
      <el-table-column type="selection" min-width="40" align="center"></el-table-column>
      <el-table-column
        prop="projectCode"
        label="项目编号"
        min-width="70"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        prop="projectName"
        label="项目名称"
        min-width="80"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        prop="regionName"
        label="区域名称"
        min-width="80"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        prop="registrationCode"
        label="注册代码"
        min-width="80"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        prop="devicePosition"
        label="设备内部编号"
        min-width="80"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        prop="workerName"
        label="维保负责人"
        min-width="80"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column
        prop="planInterval"
        label="间隔"
        min-width="60"
        align="center"
        :show-overflow-tooltip="true"
      ></el-table-column>
      <el-table-column label="电梯状态" min-width="80" align="center" :show-overflow-tooltip="true">
        <template slot-scope="rows">
          <div>{{rows.row.liftStatus==='1'?'停保':rows.row.liftStatus==='2'?'正常':rows.row.liftStatus==="3"?'保养中':rows.row.liftStatus==="4"?'维修中':rows.row.liftStatus==="5"?'年检中':'大修中'}}</div>
        </template>
      </el-table-column>
      <el-table-column label="计划时间" min-width="80" align="center" :show-overflow-tooltip="true">
        <template slot-scope="rows">
          <div>{{rows.row.status==='0'?"未设置":rows.row.planDate}}</div>
        </template>
      </el-table-column>
      <el-table-column label="操作" min-width="100" align="center">
        <template slot-scope="{row,$index}">
          <el-button
            @click="MakePlan(row,$index)"
            size="small"
            type="primary"
            plain
            v-if="row.status==='0'&&LiftMaintenancePlanBtn.LiftMaintenancePlanBtn69"
            round
          >制定计划</el-button>
          <el-button
            @click="changePlan(row,$index)"
            size="small"
            type="success"
            plain
            v-if="row.status==='1'&&LiftMaintenancePlanBtn.LiftMaintenancePlanBtn70"
            round
          >修改计划</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagenation">
      <el-pagination
        background
        layout="prev, pager, next, sizes, total, jumper"
        :total="listPageNum.total"
        :current-page="listPageNum.currpage"
        @current-change="changePageNum"
        :page-sizes="[15]"
      ></el-pagination>
    </div>
    <!-- dialog -->
    <div>
      <el-dialog
        title="制订维保计划"
        :visible.sync="plans"
        class="plansNextD"
        width="520px"
        :before-close="addClose"
      >
        <div class="plansNext">
          <el-form :model="PlanData" :rules="planRules" ref="PlanData">
            <el-row type="flex" justify="space-around" class="liHeight">
              <el-col :span="8">
                <span>选择首保日期:</span>
              </el-col>
              <el-col :span="16">
                <el-form-item prop="firstTime">
                  <el-date-picker
                    v-model="PlanData.firstTime"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy 年 MM 月 dd 日"
                    value-format="yyyy-MM-dd"
                  ></el-date-picker>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-around" class="liHeight">
              <el-col :span="8">
                <span>选择首保期数:</span>
              </el-col>
              <el-col :span="16">
                <el-form-item prop="periods">
                  <el-select v-model="PlanData.periods" placeholder="选择首保期数">
                    <el-option
                      v-for="item in keepType"
                      :key="item.status"
                      :label="item.value"
                      :value="item.status"
                    ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-around" class="liHeight" v-if="!PlanData.isKeep">
              <el-col :span="8">
                <span>设置保养间隔:</span>
              </el-col>
              <el-col :span="16">
                <el-form-item prop="interval">
                  <el-select v-model="PlanData.interval" placeholder="选择保养间隔">
                    <el-option v-for="item in IntervalVal" :key="item" :label="item" :value="item"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-around" class="liHeight" v-else>
              <el-col :span="8">
                <span>设置保养间隔:</span>
              </el-col>
              <el-col :span="16">
                <el-form-item prop="interval">
                  <el-input v-model="PlanData.interval" placeholder="请输入维保间隔"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row type="flex" justify="space-around" class="liHeight">
              <el-col :span="8">
                <span>是否按需维保:</span>
              </el-col>
              <el-col :span="4">
                <el-switch
                  v-model="PlanData.isKeep"
                  active-color="#13ce66"
                  inactive-color="#ff4949"
                ></el-switch>
              </el-col>
              <el-col :span="12">
                <i class>*</i>
                根据自己需求设置维保间隔
              </el-col>
            </el-row>
          </el-form>
          <div class="TXc">
            <el-button type="infor" plain size="small" @click="addClose">取消</el-button>
            <el-button type="primary" plain size="small" @click="PlanDeter">确定</el-button>
          </div>
        </div>
      </el-dialog>
    </div>
    <div class="rilidia">
      <el-dialog :visible.sync="setPlans">
        <el-date :rows="planDates" ref="mychild"></el-date>
      </el-dialog>
    </div>

    <!-- 计划打印 -->
    <div class="planPrint">
      <el-dialog title :visible.sync="dialogplanPrint" width="80%">
        <div slot="title" class="dialog-footer">
          <span class="planPrinttitle">项目{{planPrintMonth}}月份维保计划</span>
          <el-date-picker
            class="planPrintmonth"
            v-model="planPrintMonth"
            type="month"
            value-format="yyyy-MM"
            @change="showPlan"
          ></el-date-picker>
        </div>
        <div id="planPrint">
          <div style="margin-bottom: 10px;" v-for="a in planPrintData" :key="a.projectId">
            <div class="policyTop">
              <p
                class="policyTopCompany"
                style="font-size: 16px;font-weight: bold;text-align: center;"
              >{{a.projectName}}{{planPrintMonth}}月份维保计划</p>
              <div>
                <div style="width:28%;margin-bottom: 5px;display:inline-block">
                  <div>
                    <div style="display:inline-block;margin-right:10px">项目编号：</div>
                    <div
                      :title="a.projectCode"
                      style="vertical-align: middle;white-space: nowrap;overflow: hidden;display:inline-block"
                    >{{a.projectCode}}</div>
                  </div>
                </div>
                <div style="width:35%;margin-bottom: 5px;display:inline-block">
                  <div>
                    <div style="display:inline-block;margin-right:10px">项目名称:</div>
                    <div
                      :title="a.projectName"
                      style="vertical-align: top;display:inline-block;white-space: nowrap;overflow: hidden;"
                    >{{a.projectName}}</div>
                  </div>
                </div>
                <div style="width:35%;margin-bottom: 5px;display:inline-block">
                  <div>
                    <div style="display:inline-block;margin-right:10px">甲方名称:</div>
                    <div
                      :title="a.ppCompanyName"
                      style="vertical-align: top;display:inline-block;white-space: nowrap;overflow: hidden;"
                    >{{a.ppCompanyName}}</div>
                  </div>
                </div>
                <div style="width:28%;margin-bottom: 5px;display:inline-block">
                  <div>
                    <div style="display:inline-block;margin-right:10px">维保台量：</div>
                    <div
                      style="vertical-align: middle;display:inline-block;white-space: nowrap;overflow: hidden;"
                    >{{a.num}}</div>
                  </div>
                </div>
                <div style="width:35%;margin-bottom: 5px;display:inline-block">
                  <div>
                    <div style="display:inline-block;margin-right:10px">维保公司：</div>
                    <div
                      :title="a.mtCompanyName"
                      style="vertical-align: top;display:inline-block;white-space: nowrap;overflow: hidden;"
                    >{{a.mtCompanyName}}</div>
                  </div>
                </div>
                <div style="width:35%;margin-bottom: 5px;display:inline-block">
                  <div>
                    <div style="display:inline-block;margin-right:10px">打印时间：</div>
                    <div
                      :title="a.printTime"
                      style="vertical-align: middle;display:inline-block;white-space: nowrap;overflow: hidden;"
                    >{{a.printTime}}</div>
                  </div>
                </div>
              </div>
            </div>
            <table style="width: 100%;color:#101010;border:1px solid #000;font-size:10px">
              <tr>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;"
                  v-for="item in planPrintDatatitle"
                  :key="item.label"
                >{{item.label}}</th>
              </tr>
              <tr v-for="item in showprintList(a.liftList,a.monthDay)" :key="item.registrationCode">
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;"
                >{{item.devicePosition}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;"
                >{{item.registrationCode}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type1}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type2}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type3}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type4}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type5}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type6}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type7}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type8}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type9}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type10}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type11}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type12}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type13}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type14}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type15}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type16}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type17}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type18}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type19}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type20}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type21}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type22}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type23}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type24}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type25}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type26}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type27}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                >{{item.type28}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                  v-if="item.hasOwnProperty('type29')"
                >{{item.type29}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                  v-if="item.hasOwnProperty('type30')"
                >{{item.type30}}</th>
                <th
                  style="border-right: 1px solid black;border-bottom: 1px solid black;width:20px"
                  v-if="item.hasOwnProperty('type31')"
                >{{item.type31}}</th>
              </tr>
              <!-- <el-table-column
              v-for="item in planPrintDatatitle"
              :key="item.liftId"
              :label="item.label"
              :prop="item.prop"
              :min-width="item.prop=='devicePosition'?'90px':(item.prop=='registrationCode'?'90px':'28px')"
              :show-overflow-tooltip="true"
              ></el-table-column>-->
            </table>
            <!-- <el-table
              :data="showprintList(a.liftList,a.monthDay)"
              border
              style="width: 100%;color:#101010"
              class="planPrintData"
            >
              <el-table-column
                v-for="item in planPrintDatatitle"
                :key="item.liftId"
                :label="item.label"
                :prop="item.prop"
              :min-width="item.prop=='devicePosition'?'90px':(item.prop=='registrationCode'?'90px':'28px')"
              :show-overflow-tooltip="true"
              ></el-table-column>
            </el-table>-->
          </div>
        </div>
        <div slot="footer" class="dialog-footer Txc">
          <el-button @click="dialogplanPrint = false">取 消</el-button>
          <el-button type="primary" @click="getPrint">打 印</el-button>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import plandate from "../../components/Maintenance/calendar.vue";
import { get } from "https";
export default {
  components: {
    elDate: plandate
  },
  props: ["listData", "LiftMaintenancePlanBtn"],
  data() {
    var checkfirst = (rule, value, callback) => {
      var time = new Date();
      var year = time.getFullYear();
      var month =
        time.getMonth() + 1 < 10
          ? `0${time.getMonth() + 1}`
          : time.getMonth() + 1;
      var day = time.getDate() < 10 ? `0${time.getDate()}` : time.getDate();
      var newday = `${year}-${month}-${day}`;
      console.log(value == newday);
      if (value === "") {
        return callback(new Error("日期不能为空"));
      } else if (value < newday) {
        return callback(new Error("首次维保日期不能晚于今天"));
      } else {
        return callback();
      }
    };
    var checkinterval = (rule, value, callback) => {
      if (value === "") {
        return callback(new Error("维保间隔不能为空"));
      } else {
        return callback();
      }
    };
    var checkinperiods = (rule, value, callback) => {
      console.log("验证了");
      if (value === "") {
        return callback(new Error("维保间隔不能为空"));
      } else {
        return callback();
      }
    };
    return {
      handleClose: false,
      dialogplanPrint: false,
      planPrintMonth: "",
      policyRow: {},
      planPrintDataTable: [],
      planPrintData: [],
      planPrintDatatitle: [],
      showPlanId: "",

      listPageNum: {
        pagesize: 10,
        currpage: 1,
        total: 0,
        load: false,
        listTableData: []
      },
      sbVLoading: false,
      DataSelection: [],
      PlanData: {
        firstTime: null,
        interval: null,
        periods: null,
        isKeep: false
      },
      IntervalVal: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
      keepType: [
        { status: 1, value: "半月保1" },
        { status: 2, value: "半月保2" },
        { status: 3, value: "半月保3" },
        { status: 4, value: "半月保4" },
        { status: 5, value: "半月保5" },
        { status: 6, value: "季度保6" },
        { status: 7, value: "半月保7" },
        { status: 8, value: "半月保8" },
        { status: 9, value: "半月保9" },
        { status: 10, value: "半月保10" },
        { status: 11, value: "半月保11" },
        { status: 12, value: "半年保12" },
        { status: 13, value: "半月保13" },
        { status: 14, value: "半月保14" },
        { status: 15, value: "半月保15" },
        { status: 16, value: "半月保16" },
        { status: 17, value: "半月保17" },
        { status: 18, value: "季度保18" },
        { status: 19, value: "半月保19" },
        { status: 20, value: "半月保20" },
        { status: 21, value: "半月保21" },
        { status: 22, value: "半月保22" },
        { status: 23, value: "半月保23" },
        { status: 24, value: "年保24" }
      ],
      plans: false,
      setPlans: false,
      planRules: {
        firstTime: [{ validator: checkfirst, trigger: "change" }],
        interval: [{ validator: checkinterval, trigger: ["change", "blur"] }],
        periods: [{ validator: checkinperiods, trigger: "change" }]
      },
      planDates: {}
    };
  },
  created() {
    var date = new Date();
    var year = date.getFullYear();
    var month =
      date.getMonth() + 1 < 10
        ? "0" + (date.getMonth() + 1)
        : date.getMonth() + 1;
    this.planPrintMonth = year + "-" + month;
  },
  mounted() {
    this.getPlanList();
  },
  methods: {
    // 获取维保计划
    getPlanList() {
      this.sbVLoading = true;
      var url = "business/maintenance/plan/list";
      var param = this.listData;
      param.pageNum = this.listPageNum.currpage;
      param.pageSize = this.listPageNum.pagesize;
      param.mtCompanyId = JSON.parse(sessionStorage.getItem("companyID")).id;
      this.axios.post(url, param).then(res => {
        console.log(res);
        if (res.statusCode === "1") {
          console.log(res.data);
          this.listPageNum.listTableData = res.data ? res.data.rows : [];
          this.listPageNum.total = res.data ? res.data.total : 0;
          this.sbVLoading = false;
        } else {
          this.sbVLoading = false;
          this.$message(res.message);
        }
      });
    },
    // 条件重置
    updataReset() {
      this.listPageNum = {
        pagesize: 15,
        currpage: 1,
        total: 0,
        listTableData: []
      };
      var url = "business/maintenance/plan/list";
      var param = {};
      param.pageNum = this.listPageNum.currpage;
      param.pageSize = this.listPageNum.pagesize;
      param.mtCompanyId = JSON.parse(sessionStorage.getItem("companyID")).id;
      this.axios.post(url, param).then(res => {
        if (res.statusCode === "1") {
          this.listPageNum.listTableData = res.data ? res.data.rows : [];
          this.listPageNum.total = res.data ? res.data.total : 0;
        } else {
          this.$message(res.message);
        }
      });
    },
    // 条件查询
    getSeek() {
      this.listPageNum = {
        pagesize: 15,
        currpage: 1,
        total: 0,
        listTableData: []
      };
      this.getPlanList();
    },
    handleSelectionChange(val) {
      this.DataSelection = [];
      this.DataSelection = val;
    },
    handleSizeChange(val) {
      this.listPageNum.pagesize = val;
      this.listPageNum.currpage = 1;
      this.getPlanList();
    },
    changePageNum(val) {
      this.listPageNum.currpage = val;
      this.getPlanList();
    },
    // 制定维保计划
    MakePlan(row, index) {
      this.DataSelection = [];
      this.DataSelection.push(row);
      this.plans = true;
    },
    // 制定维保计划
    PlanDeter() {
      var url = "business/maintenance/generate/plan";
      var param = this.PlanData;
      // 获取参数list
      var getlist = isA => {
        return this.DataSelection.map(item => {
          var a = {};
          if (isA) {
            a.liftId = item.liftId;
            a.mtCompanyId = item.mtCompanyId;
            a.projectId = item.projectId;
            a.workerId = item.workerId;
          } else {
            a.id = item.relevanceId;
          }
          return a;
        });
      };
      param.planList = getlist(true);
      param.relevanceList = getlist(false);
      param.demand = this.PlanData.isKeep ? "1" : "0";
      this.axios.post(url, param).then(res => {
        if (res.statusCode === "1") {
          this.$message({
            type: "success",
            message: res.message
          });
          this.getPlanList();
          this.addClose();
        } else {
          this.$message.error(res.message);
        }
      });
      // param.planList=this.DataSelection.map(item=>{
      //    var a={};
      //    a.liftId=item.liftId;
      //    a.mtCompanyId=item.mtCompanyId;
      //    a.projectId=item.projectId;
      //    a.workerId=item.workerId;
      //    return a;
      // })
    },
    // 判断是否有选中已制定计划
    batchPlan() {
      var _this = this;
      var isPlan = false;
      if (_this.DataSelection.length <= 0) {
        this.$message.error("请选择电梯");
        return;
      }
      for (let item of _this.DataSelection) {
        if (item.status === "1" || item.planDate) isPlan = true;
      }
      if (isPlan) {
        this.$message.error("请取消已制定计划电梯");
        return;
      } else {
        this.plans = true;
      }
    },
    // 修改计划
    changePlan(row, index) {
      console.log(row);
      this.planDates = row;
      this.setPlans = true;
      setTimeout(() => {
        this.$refs.mychild.getPlanList(row);
      }, 10);
    },
    // 关闭新增模态框
    addClose() {
      this.PlanData = {
        firstTime: null,
        interval: null,
        periods: null,
        isKeep: false
      };
      this.DataSelection = [];
      this.plans = false;
      this.getPlanList();
    },
    // 清空维保计划
    emptyPlan() {
      var _this = this;
      var isPlan = false;
      if (_this.DataSelection.length <= 0) {
        this.$message.error("请选择电梯");
        return;
      }
      for (let item of _this.DataSelection) {
        if (item.status === "0" || !item.planDate) isPlan = true;
      }
      if (isPlan) {
        this.$message.error("请取消未制定计划电梯");
        return;
      } else {
        var url = "business/maintenance/batch/clean";
        var param = {
          // mtCompanyId:JSON.parse(sessionStorage.getItem("companyID")).id,
          mtCompanyId: JSON.parse(sessionStorage.getItem("companyID")).id
        };
        param.liftIdList = _this.DataSelection.map(item => {
          return item.liftId;
        });
        _this.axios.post(url, param).then(res => {
          if (res.statusCode === "1") {
            this.$message({ type: "success", message: res.message });
            this.getPlanList();
          } else {
            this.$message.error(res.message);
          }
        });
      }
    },
    printPlan() {
      var _this = this;
      if (_this.DataSelection.length <= 0) {
        this.$message.error("请选择电梯");
        return;
      } else {
        var liftList = [];
        _this.DataSelection.map(a => {
          liftList.push({
            liftId: a.liftId,
            projectId: a.projectId
          });
        });
        this.handleClickPlan(liftList);
      }
    },
    showPlan() {
      this.showPlanList(this.showPlanId);
    },
    handleClickPlan(a) {
      var date = new Date();
      var year = date.getFullYear();
      var month =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1;
      this.planPrintMonth = year + "-" + month;
      this.showPlanId = a;
      this.showPlanList(a);
      this.dialogplanPrint = true;
    },
    showPlanList(a) {
      this.planPrintDatatitle = [];
      this.planPrintData = [];
      this.policyRow = {};
      var url = "business/maintenance/plan/print";
      var param = {
        mtCompanyId: JSON.parse(sessionStorage.getItem("mtCompanyId")),
        liftList: a,
        beginTime: this.planPrintMonth + "-01"
      };

      this.axios.post(url, param).then(result => {
        var data = result;
        if (data.statusCode === "1") {
          this.planPrintData = data.data;
          // this.policyRow={
          //   projectName:data.data.projectName,
          //   projectCode:data.data.projectCode,
          //   ppCompanyName:data.data.ppCompanyName,
          //   num:data.data.num,
          //   mtCompanyName:data.data.mtCompanyName,
          //   printTime:data.data.printTime,
          // }
          var a = this.planPrintMonth.split("-");
          var ddd;
          switch (parseInt(a[1])) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
              ddd = 31;
              break;
            case 4:
            case 6:
            case 9:
            case 11:
              ddd = 30;
              break;
            case 2:
              if ((a[0] % 100 !== 0 && a[0] % 4 == 0) || a[0] % 400 == 0) {
                ddd = 29;
                break;
              } else {
                ddd = 28;
                break;
              }
          }
          var month = data.data.monthDay ? data.data.monthDay : ddd;
          for (var i = 0; i < parseInt(month) + 2; i++) {
            var json = {};
            if (i == 0) {
              json.label = "电梯位置";
              json.prop = "devicePosition";
            } else if (i == 1) {
              json.label = "电梯注册码";
              json.prop = "registrationCode";
            } else {
              json.label = i - 1 + "";
              json.prop = "type" + (i - 1);
            }
            this.planPrintDatatitle.push(json);
          }
          // console.log(this.planPrintDatatitle)
          // this.planPrintData = data.data.liftList.map((item,index) => {
          //   return {
          //     devicePosition:item.devicePosition,
          //     registrationCode:item.registrationCode,
          //     type1:this.kindType(1,item.planList),type2:this.kindType(2,item.planList),type3:this.kindType(3,item.planList),type4:this.kindType(4,item.planList),type5:this.kindType(5,item.planList),type6:this.kindType(6,item.planList),type7:this.kindType(7,item.planList),type8:this.kindType(8,item.planList),type9:this.kindType(9,item.planList),type10:this.kindType(10,item.planList),
          //     type11:this.kindType(11,item.planList),type12:this.kindType(12,item.planList),type13:this.kindType(13,item.planList),type14:this.kindType(14,item.planList),type15:this.kindType(15,item.planList),type16:this.kindType(16,item.planList),type17:this.kindType(17,item.planList),type18:this.kindType(18,item.planList),type19:this.kindType(19,item.planList),type20:this.kindType(20,item.planList),
          //     type21:this.kindType(21,item.planList),type22:this.kindType(22,item.planList),type23:this.kindType(23,item.planList),type24:this.kindType(24,item.planList),type25:this.kindType(25,item.planList),type26:this.kindType(26,item.planList),type27:this.kindType(27,item.planList),type28:this.kindType(28,item.planList),type29:this.kindType(29,item.planList),type30:this.kindType(30,item.planList)
          //   }
          // })
          // console.log(this.planPrintData)
        } else {
          this.$message.error(data.message);
        }
      });
    },
    showprintList(list, monthDay) {
      var a = this.planPrintMonth.split("-");
      var ddd;
      switch (parseInt(a[1])) {
        case 1:
        case 3:
        case 5:
        case 7:
        case 8:
        case 10:
        case 12:
          ddd = 31;
          break;
        case 4:
        case 6:
        case 9:
        case 11:
          ddd = 30;
          break;
        case 2:
          if ((a[0] % 100 == 0 && a[0] % 4 == 0) || a[0] % 400 == 0) {
            ddd = 29;
            break;
          } else {
            ddd = 28;
            break;
          }
      }
      var month = monthDay ? monthDay : ddd;
      var list = list.map((item, index) => {
        if (month == 28) {
          return {
            devicePosition: item.devicePosition,
            registrationCode: item.registrationCode,
            type1: this.kindType(1, item.planList),
            type2: this.kindType(2, item.planList),
            type3: this.kindType(3, item.planList),
            type4: this.kindType(4, item.planList),
            type5: this.kindType(5, item.planList),
            type6: this.kindType(6, item.planList),
            type7: this.kindType(7, item.planList),
            type8: this.kindType(8, item.planList),
            type9: this.kindType(9, item.planList),
            type10: this.kindType(10, item.planList),
            type11: this.kindType(11, item.planList),
            type12: this.kindType(12, item.planList),
            type13: this.kindType(13, item.planList),
            type14: this.kindType(14, item.planList),
            type15: this.kindType(15, item.planList),
            type16: this.kindType(16, item.planList),
            type17: this.kindType(17, item.planList),
            type18: this.kindType(18, item.planList),
            type19: this.kindType(19, item.planList),
            type20: this.kindType(20, item.planList),
            type21: this.kindType(21, item.planList),
            type22: this.kindType(22, item.planList),
            type23: this.kindType(23, item.planList),
            type24: this.kindType(24, item.planList),
            type25: this.kindType(25, item.planList),
            type26: this.kindType(26, item.planList),
            type27: this.kindType(27, item.planList),
            type28: this.kindType(28, item.planList)
          };
        } else if (month == 29) {
          return {
            devicePosition: item.devicePosition,
            registrationCode: item.registrationCode,
            type1: this.kindType(1, item.planList),
            type2: this.kindType(2, item.planList),
            type3: this.kindType(3, item.planList),
            type4: this.kindType(4, item.planList),
            type5: this.kindType(5, item.planList),
            type6: this.kindType(6, item.planList),
            type7: this.kindType(7, item.planList),
            type8: this.kindType(8, item.planList),
            type9: this.kindType(9, item.planList),
            type10: this.kindType(10, item.planList),
            type11: this.kindType(11, item.planList),
            type12: this.kindType(12, item.planList),
            type13: this.kindType(13, item.planList),
            type14: this.kindType(14, item.planList),
            type15: this.kindType(15, item.planList),
            type16: this.kindType(16, item.planList),
            type17: this.kindType(17, item.planList),
            type18: this.kindType(18, item.planList),
            type19: this.kindType(19, item.planList),
            type20: this.kindType(20, item.planList),
            type21: this.kindType(21, item.planList),
            type22: this.kindType(22, item.planList),
            type23: this.kindType(23, item.planList),
            type24: this.kindType(24, item.planList),
            type25: this.kindType(25, item.planList),
            type26: this.kindType(26, item.planList),
            type27: this.kindType(27, item.planList),
            type28: this.kindType(28, item.planList),
            type29: this.kindType(29, item.planList)
          };
        } else if (month == 30) {
          return {
            devicePosition: item.devicePosition,
            registrationCode: item.registrationCode,
            type1: this.kindType(1, item.planList),
            type2: this.kindType(2, item.planList),
            type3: this.kindType(3, item.planList),
            type4: this.kindType(4, item.planList),
            type5: this.kindType(5, item.planList),
            type6: this.kindType(6, item.planList),
            type7: this.kindType(7, item.planList),
            type8: this.kindType(8, item.planList),
            type9: this.kindType(9, item.planList),
            type10: this.kindType(10, item.planList),
            type11: this.kindType(11, item.planList),
            type12: this.kindType(12, item.planList),
            type13: this.kindType(13, item.planList),
            type14: this.kindType(14, item.planList),
            type15: this.kindType(15, item.planList),
            type16: this.kindType(16, item.planList),
            type17: this.kindType(17, item.planList),
            type18: this.kindType(18, item.planList),
            type19: this.kindType(19, item.planList),
            type20: this.kindType(20, item.planList),
            type21: this.kindType(21, item.planList),
            type22: this.kindType(22, item.planList),
            type23: this.kindType(23, item.planList),
            type24: this.kindType(24, item.planList),
            type25: this.kindType(25, item.planList),
            type26: this.kindType(26, item.planList),
            type27: this.kindType(27, item.planList),
            type28: this.kindType(28, item.planList),
            type29: this.kindType(29, item.planList),
            type30: this.kindType(30, item.planList)
          };
        } else if (month == 31) {
          return {
            devicePosition: item.devicePosition,
            registrationCode: item.registrationCode,
            type1: this.kindType(1, item.planList),
            type2: this.kindType(2, item.planList),
            type3: this.kindType(3, item.planList),
            type4: this.kindType(4, item.planList),
            type5: this.kindType(5, item.planList),
            type6: this.kindType(6, item.planList),
            type7: this.kindType(7, item.planList),
            type8: this.kindType(8, item.planList),
            type9: this.kindType(9, item.planList),
            type10: this.kindType(10, item.planList),
            type11: this.kindType(11, item.planList),
            type12: this.kindType(12, item.planList),
            type13: this.kindType(13, item.planList),
            type14: this.kindType(14, item.planList),
            type15: this.kindType(15, item.planList),
            type16: this.kindType(16, item.planList),
            type17: this.kindType(17, item.planList),
            type18: this.kindType(18, item.planList),
            type19: this.kindType(19, item.planList),
            type20: this.kindType(20, item.planList),
            type21: this.kindType(21, item.planList),
            type22: this.kindType(22, item.planList),
            type23: this.kindType(23, item.planList),
            type24: this.kindType(24, item.planList),
            type25: this.kindType(25, item.planList),
            type26: this.kindType(26, item.planList),
            type27: this.kindType(27, item.planList),
            type28: this.kindType(28, item.planList),
            type29: this.kindType(29, item.planList),
            type30: this.kindType(30, item.planList),
            type31: this.kindType(31, item.planList)
          };
        }
      });
      console.log(list);
      return list;
    },
    getPrint() {
      var dom = document.getElementById("planPrint");
      let newContent = dom.innerHTML;
      let oldContent = document.body.innerHTML;
      document.body.innerHTML = newContent;
      window.print();
      window.location.reload();
      document.body.innerHTML = oldContent;
      // var win = window.open('');
    },
    kindType(typeIndex, planList) {
      var value = "";
      planList.map((item, index) => {
        if (item.planDate.charAt(item.planDate.length - 2) == 0) {
          if (item.planDate.substr(item.planDate.length - 1, 1) == typeIndex) {
            if (item.type == 1) {
              value = "月";
            } else if (item.type == 2) {
              value = "季";
            } else if (item.type == 3) {
              value = "半";
            } else if (item.type == 4) {
              value = "全";
            } else {
            }
          } else {
          }
        } else {
          if (
            item.planDate.substring(
              item.planDate.length - 2,
              item.planDate.length
            ) == typeIndex
          ) {
            if (item.type == 1) {
              value = "月";
            } else if (item.type == 2) {
              value = "季";
            } else if (item.type == 3) {
              value = "半";
            } else if (item.type == 4) {
              value = "全";
            } else {
            }
          } else {
          }
        }
      });
      return value;
    }
  }
};
</script>
<style lang="stylus">
.planPrint {
  .el-dialog__body {
    padding: 15px 20px;
  }

  .policyTop {
    font-size: 14px;

    p {
      text-align: center;
    }

    .policyTopCompany {
      font-size: 16px;
      font-weight: bold;
    }

    .el-row {
      .el-col {
        text-align: center;
      }
    }
  }

  .el-dialog__header {
    .el-dialog__headerbtn .el-dialog__close {
      color: #fff;
    }

    background-color: #40A9FF;
    color: #fff;
    font-size: 18px;
    padding: 10px 20px;

    .planPrinttitle {
      border-left: 1px solid #fff;
      padding-left: 7px;
    }

    .planPrintmonth {
      background-color: #40a9ff;

      .el-input__inner {
        background-color: #40a9ff;
        border-color: #40a9ff;
        display: none;
      }

      .el-input__prefix {
        left: 20px;
        top: -22px;
        cursor: pointer;

        .el-input__icon {
          font-size: 20px;
          background-color: #e5e5e5;
          border-radius: 15%;
          width: 40px;
          color: #000;
        }
      }

      .el-input__suffix {
        display: none;
      }
    }
  }

  .el-table.planPrintData {
    font-size: 12px;
  }

  .el-table .cell {
    padding: 2px;
  }

  .el-table .cell.el-tooltip {
    min-width: 0px;
  }

  .el-table td, .el-table th {
    padding: 5px 0;
  }
}
</style>