<template>
  <div style=" background-color: #fff; padding:15px;">
    <div style="margin-top:2px; margin-bottom:15px;" class="inline-block-btn-list">
      <el-button
        v-if="profile.manager_type>0"
        type="primary"
        plain
        @click="dialogTaskOpen()"
        class="first-element-btn"
      >发布任务</el-button>
      <el-date-picker
        class="first-element-btn"
        v-model="filter.time_range"
        type="daterange"
        value-format="timestamp"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        :picker-options="instantPickerOptions"
        @change="onFilterChanged"
      ></el-date-picker>

      <div class="gap-right-8" style="display:inline-block; width:310px;">
        <el-input
          placeholder="输入关键词查找"
          ref="search-bar"
          v-model="filter.keywords"
          class="input-with-select"
          width="200px"
          @keyup.enter.native="onFilterChanged"
        >
          <el-button slot="append" icon="el-icon-search" @click="onFilterChanged"></el-button>
        </el-input>
        <!-- <el-select
        style="width:70px;"
        v-show="true"
        v-model="filter.look_type"
        @change="onFilterChanged">
        <el-option
          v-for="item in lookTypes"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
        </el-select>-->
      </div>
    </div>

    <el-table
      stripe
      v-loading="loading"
      ref="multipleTable"
      :data="tableData"
      tooltip-effect="dark"
      @filter-change="filterHandler"
      style="width: 100%"
    >
      <el-table-column prop="name" label="内容"></el-table-column>
      <el-table-column prop="point" label="奖分" width="80px"></el-table-column>
      <el-table-column prop="creator.name" label="发布人" width="100px"></el-table-column>
      <el-table-column v-if="false" prop="follow.name" label="领取人"></el-table-column>
      <el-table-column
        prop="status"
        label="状态"
        column-key="status"
        :filters="status_list"
        :formatter="taskStatusText" width="200px;"
      ></el-table-column>

      <el-table-column prop="name" label="附件">
        <template slot-scope="scope">
          <div>
            <a
              style="display: block; color:#409EFF; text-decoration: underline;"
              v-for="(item,idx) in scope.row.file_list"
              :key="idx"
              @click="fileProview(item.url, scope.row.file_list, scope.row.id)"
            >{{item.name}}</a>
          </div>

        </template>
      </el-table-column>
      <el-table-column label="截止时间">
        <template slot-scope="scope">

          <div>
            <span>{{dateTimeFormatter('','',scope.row.expiretime)}}</span>
          </div>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="250px">
        <template slot-scope="scope">
          <!-- <div> -->
          <el-button
            type="text"
            @click="dialogTaskOpen('修改任务', scope.row.id, 'false')"
            v-show="profile.is_creator || profile.id==scope.row.creator_id"
            :disabled="profile.id != scope.row.creator_id"
          >修改</el-button>



         <el-button
            type="text"
            @click="confirmDelete(scope.row.id)"
            :disabled="profile.id != scope.row.creator_id"
            v-show="profile.is_creator || profile.id==scope.row.creator_id"
          >删除</el-button>

          <el-button
            type="text"
            @click="show_task(scope.row.id,scope.row.fixed_cycle)"
          >查看详情</el-button>

          <el-button
            type="text"
            @click="getTask(scope.row.id)"
            v-if="scope.row.status == 0 &&  scope.row.creator_id != profile.id"
          >领取</el-button>
          <!-- </div> -->
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      layout="total,sizes, prev, pager, next"
      @size-change="handleSizeChange"
      :page-size="pageLimit"
      :page-sizes="[10, 20, 50, 100]"
      :total="totalCount"
      :current-page.sync="currentPage"
      @current-change="changePage"
    ></el-pagination>

    <!-- 历史完成记录 -->
    <el-dialog
      title="任务历史完成记录"
      :visible.sync="taskFinsh"
      width="614px"
      style="color: #303133;font-size: 17px;"
      :close-on-click-modal="false"
      @close="closeDialog"
      custom-class="historyClass"

    >
      <div style="padding-bottom: 12px;">
        <el-checkbox @change="showFinsh()" v-model="radio">仅显示未完成任务</el-checkbox>
        <!-- <div  @click="showFinsh()" :class="{'active':isActive}" style="width: 15px;height: 15px;border-radius: 50%; border: 1px solid #979797;float: left;cursor: pointer;margin-right: 5px;"></div>
        <span>仅显示未完成任务</span> -->
      </div>
      <!-- <el-radio @change="checkTask" style="clear: both;width: 100%;" v-model="radio" :label = "true">仅显示未完成任务</el-radio> -->
      <el-table
        :data="historyData"
        style="width: 100%">
        <el-table-column
          prop="name"
          label="内容"
          width="180">
        </el-table-column>
        <el-table-column
          prop="point"
          label="积分"
          width="100">
        </el-table-column>
        <el-table-column
          prop="expiretime"
          label="时间">
        </el-table-column>
        <el-table-column
          prop="status"
          label="状态">
          <template slot-scope="scope">
            <span  v-if="scope.row.status == 0">未领取</span>
            <span  v-if="scope.row.status == 1" style="color: #F3BB11;">未完成</span>
            <span  v-if="scope.row.status == 2">已完成</span>
          </template>
        </el-table-column>
        <el-table-column
          label="操作">
          <template slot-scope="scope">
            <span  @click="OpenDetail(scope.row.id, scope.row.fixed_cycle)">查看</span>
          </template>
        </el-table-column>


      </el-table>


      <span slot="footer" class="dialog-footer">
        <el-button @click="CloseTask">关 闭</el-button>
      </span>
    </el-dialog>


    <el-dialog
        title="任务详情"
        :visible.sync="dialogTaskVisible1"
        width="462px"
        height="540px"
        custom-class="DialogStyle"
        :close-on-click-modal="false"
        @close="closeDialog"
      >
        <!-- <div class="ecactly"> -->
        <!-- <div  style="color: #606266;font-size: 17px;font-weight: 550;">任务详情</div> -->
        <div class="history"  v-if="isShow" @click="lookFinsh()" style="color: #26A2FF;font-size: 12px;cursor:pointer;">查看历史完成记录(未完成 {{noFinsh}})</div>
        <!-- </div> -->
        <el-form
          :model="taskForm"
          ref="newTaskForm"
          :rules="taskFormRules"
          @submit.native.prevent
          style="padding-right:20px; clear: both;"
          calss="exactly"
        >
            <el-scrollbar
              wrap-class="column-wrapper scrollable-items-container check-item-box dept_tree"
              :native="false"
              style="height: 300px;"
            >
           <el-form-item label="评分标准：" label-width="100px" v-if="pointype == 20">
          <div style="float: left;width: 63px;height: 58px;margin-right: 5px;"  v-for="(item,index) in point_level_log" :key="index">
                <div  :class="{ 'isActive': point_level==10&&reveiew == 1,'itemCorde':true}"  v-if="item.key == 10">
                  <div >{{item.value}}</div>
                  <div>超预期</div>
                </div>

                 <div  :class="{ 'isActive': point_level==20&&reveiew == 1,'itemCorde':true}" v-if="item.key == 20">
                   <div >{{item.value}}</div>
                 <div>满意</div>
                </div>

                 <div  :class="{ 'isActive': point_level==30&&reveiew == 1,'itemCorde':true}" v-if="item.key == 30">
                  <div>{{item.value}}</div>
                  <div >合格</div>
                </div>

                 <div  :class="{ 'isActive': point_level==40&&reveiew == 1,'itemCorde':true}" v-if="item.key == 40">
                  <div>{{item.value}}</div>
                 <div >不合格</div>
                </div>

              </div>
          </el-form-item>
          <!-- <el-form-item label="奖励积分：" label-width="100px">{{taskForm.point}}</el-form-item> -->
          <el-form-item label="任务名称:"  label-width="100px">{{taskForm.name}}</el-form-item>
          <el-form-item label="重复周期 :"  v-if="isShow" label-width="100px">{{taskForm.fixed_cycle}}</el-form-item>
          <el-form-item label="截止时间：" label-width="100px">{{taskForm.expiretime}}</el-form-item>
          <el-form-item label="任务说明："  label-width="100px" v-if="taskForm.remark!=''"><div style="width: 280px;word-break: break-all;
    word-wrap: break-word;">{{taskForm.remark}}</div></el-form-item>

          <el-form-item label="附件：" label-width="100px"  v-for="(item,index) in taskForm.file_list" :key="index" v-if="item.url !=''" >
            <div @click="openUrl(item.url)" style="width: 280px;word-break: break-all; cursor:pointer;color: #409EFF; word-wrap: break-word;">
              {{item.name}}
            </div>
          </el-form-item>
          <el-form-item label="完成凭证：" label-width="100px" v-if="taskForm.status == 2 && complete_file_list!=''">
            <div style="width: 280px;word-break: break-all; cursor:pointer;color: #409EFF; word-wrap: break-word;"   @click="fileProview(item.url)" v-for="item in complete_file_list">

                  {{item.name}}
            </div>

          </el-form-item>
          <el-form-item label="完成备注：" label-width="100px" v-if="taskForm.status == 2 && complete_remark!=''">
            <div style="width: 280px;word-break: break-all;
    word-wrap: break-word;">{{complete_remark}}</div>
          </el-form-item>

          <el-form-item label="操作记录：" label-width="100px"  >

              <div v-for="(item,index) in history" :key="index" style="line-height: 18px; margin-bottom: 15px; margin-top: 11px">
                <div>
                  <div style="color:#606266;font-size: 14px;">{{item.remark}}</div>
                  <div style="color: #C0C4CC;font-size: 14px;">{{dateFormatter('','',item.create_time)}}</div>
                </div>
              </div>

          </el-form-item>
           </el-scrollbar>
        </el-form>
        <span slot="footer" class="dialog-footer">
        <el-button @click="dialogTaskVisible1 = false">关 闭</el-button>
         <el-button type="primary" v-if="taskForm.status != 2 && taskForm.creator_id != profile.id && taskForm.status != 1 " :loading="loading" @click="taskCompleteConfirm">领取</el-button>

      </span>
      </el-dialog>


    <!-- 任务修改发布弹框 -->
    <el-dialog
      append-to-body
      :title="dialogTaskTitle"
      :visible.sync="dialogTaskVisible"
      width="600px"
      custom-class="changeTask"
      :open="beforeOpen()"
       @close="formReset"
      :close-on-click-modal="false"
    >
      <el-form
        :model="taskForm"
        ref="newTaskForm"
        :rules="taskFormRules"
        @submit.native.prevent
        style="padding-right:20px; clear: both;"
      >
        <el-form-item label="任务名称" prop="name" label-width="100px">
          <el-input
            maxlength="80"
            placeholder="请输入任务名称"
            type="textarea"
            :value="taskForm.name"
            v-model="taskForm.name"
          ></el-input>
        </el-form-item>


        <el-form-item label="积分" prop="point" label-width="100px">
          <el-input-number @change="getPoint" v-model="taskForm.point" :value="taskForm.point" :min="0" :max="10000"></el-input-number>
        </el-form-item>
        <div>
        <el-form-item label="按标准评分"  label-width="100px" style="margin-bottom: 0px;">
         <div style="width: 43px;" @click="getMessage">
         <el-switch
            :disabled="iSplay"
            :value="isSwitch"
            v-model="isSwitch"
            @change="chngePoint"
          >
          </el-switch>
          </div>
        </el-form-item>
        <div style="color:#909399;font-size: 12px;padding-left: 98px;margin: 10px 0 18px 0;">任务可根据结果对应的标准评分</div>
        <div  v-if="isSwitch">
         <el-form-item  label="评分标准" prop="point" label-width="100px" style="margin-bottom: 0px;">
          <div class="corde">
            <div class="cordeOne">
              <!-- <div class="bordeLine">{{oneCorde}}</div> -->
              <el-input type="number" v-model="oneCorde" :value="oneCorde"></el-input>
              <div>超预期</div>
            </div>
             <div class="cordeOne">
               <el-input type="number" v-model="twoCorde" :value="twoCorde"></el-input>
              <div>满意</div>
            </div>
             <div class="cordeOne">
             <el-input type="number"  v-model="taskForm.point" :value="taskForm.point" ></el-input>
              <div>合格</div>
            </div>
             <div class="cordeOne">
               <el-input type="number" v-model="fourCorde" :value="fourCorde"></el-input>
              <div>不合格</div>
            </div>
          </div>
        </el-form-item>
        <div style="padding-left: 98px;color: #909399;font-size: 12px;;margin-bottom: 4px;margin-top: 4px;">系统为您推荐了各标准的积分</div>
        <div style="padding-left: 98px;color: #909399;font-size: 12px;margin-bottom: 20px;">如需调整系统推荐的标准积分比例，<span style="color: #26A2FF;cursor: pointer;" @click="ChangeTask()">点击设置</span></div>
        </div>
        </div>
        <!-- <div v-if="!isSend">
        <el-form-item label="积分" prop="point" label-width="100px">
          <el-input-number v-model="taskForm.point" :value="taskForm.point" :min="1" :max="10000"></el-input-number>
        </el-form-item>
        </div> -->
        <el-form-item
          label="执行者"
          prop="performer"
          label-width="100px"
        >
          <el-select
            v-model="performer"
            filterable
            clearable
            placeholder="选择执行者"
            class="gap-right-8 first-element-btn"
            style="width:290px;"
            @change="ChosePerson"
          >
            <el-option
              v-for="item in employeeOptions"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item>

          <el-form-item
          label="任务类型"
          prop="performer"
          label-width="100px"
        >
          <el-select
            v-model="taskForm.task_type"
            filterable
            clearable
            placeholder="任务类型"
            class="gap-right-8 first-element-btn"

          >
            <el-option
              v-for="item in taskTypeA"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>


        <el-form-item  label="截止时间"  prop="expiretime" label-width="100px">
          <el-date-picker
            v-model="taskForm.expiretime"
            type="datetime"
            format="yyyy-MM-dd HH:mm:ss"
            default-time="18:00:00"
            placeholder="选择截止">
          </el-date-picker>
        </el-form-item>

        <!-- <el-form-item v-if="taskType == 1" label="截止时间" prop="expiretime" label-width="100px">
             <el-date-picker v-model="expiredate" placeholder="选择日期" style="width:140px;" value-format="yyyy-MM-dd"></el-date-picker>

             <el-time-picker v-model="expiretime" placeholder="选择时间" style="width:140px;" value-format="HH:mm" format="HH:mm"></el-time-picker>

           </el-form-item> -->

        <div v-if="showAll" class="showAll" @click="changeShow()">显示全部...</div>
        <div v-else>
          <el-form-item  label="重复周期" prop="fixed_cycle" label-width="100px">
            <el-select
              v-model="taskForm.fixed_cycle"
              filterable
              clearable
              placeholder="选择重复周期"
              class="gap-right-8 first-element-btn"
              style="width:290px;"
            >
              <el-option
                v-for="item in fixed_cycle"
                :key="item.id"
                :label="item.type"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="描述" prop="remark" label-width="100px">
            <el-input
              maxlength="80"
              placeholder="输入任务描述"
              type="textarea"
              :value="taskForm.remark"
              v-model="taskForm.remark"
            ></el-input>
          </el-form-item>

          <el-form-item label="附件上传" label-width="100px">
            <upload_oss
              :headers="Xtoken"
              class="avatar-uploader"
              :action="'http://'+'integralsys.oss-cn-shenzhen.aliyuncs.com'"
              :show-file-list="true"
              :multiple="true"
              :file-list="taskForm.file_list"
              :on-success="handleFilesSuccess"
              :on-preview="onFilePreView"
              :before-upload="beforeFilesUpload"
              :on-remove="onFileRemove"
            >
              <el-button size="small" type="primary">点击上传</el-button>
              <div slot="tip" class="el-upload__tip">仅支持上传图片</div>
            </upload_oss>

            <div style="display:none;">
              <img
                v-for="(item,index) in taskForm.file_list"
                :key="index"
                v-if="(['jpg', 'png', 'bmp', 'jpeg','JPG','PNG']).indexOf(item.name.split('.')[1]) >= 0"
                :src="item.url"
                :preview="index"
                :preview-text="item.name"
              >
            </div>
          </el-form-item>
          <el-form-item
            label="同时分配给"
            prop="follow"
            label-width="100px"
          >
            <el-select
              v-model="follow"
              multiple
              filterable
              clearable
              placeholder="选择分配者"
              class="gap-right-8 first-element-btn"
              style="width:290px;"
              @change="enter"
            >
              <el-option
                v-for="item in employeeOptions"
                :key="item.id"
                :label="item.name"
                :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>

        </div>
      </el-form>
      <!-- </el-scrollbar> -->
      <span slot="footer" class="dialog-footer">
         <el-button @click="dialogTaskClose">取 消</el-button>
         <el-button type="primary" :loading="loading" @click="dialogTaskSend">确 定</el-button>
      </span>
    </el-dialog>
        <Scale  ref="loadingPlease":iShow="iShow"  @chngeShow="chngeShow"  />
  </div>
</template>
<script>
  import Vue from 'vue'
  import qs from 'qs'
  import { getToken } from '@/utils/auth'
  import preview from 'vue-photo-preview'
  import Scale from '@/views/dashboard/components/Scale'
  import upload_oss from '@/views/upload_oss/upload'
  import 'vue-photo-preview/dist/skin.css'

  Vue.use(preview, {
    tapToClose: false
  })
  export default {
     name: 'TaskCreateBtn',
     components: {
      Scale,
       upload_oss
    },
    data() {
      const taskFormRules = {
        name: [
          { required: true, message: '请输入任务名称', trigger: 'blur' },
          { min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur' }
        ],
        expiretime: [
          { required: true, message: '请选择截止时间', trigger: 'blur' }
        ],
        fixed_cycle: [
          { required: true, message: '请选择重复周期', trigger: 'blur' }
        ]
      }
      // if (this.taskType == 2) {
      //   taskFormRules[follow_id] = [
      //     { required: true, message: "请选择负责人", trigger: "blur" }
      //   ];
      // }
      return {
        twoCorde: 0,
        threeCorde: 0,
        fourCorde: 0,
        oneCorde: 0,
        iShow: false,
        one: 0,
        two: 0,
        three: 0,
        four: 0,
        isSwitch: false,
        iSplay: true,
        follow_name:'',
        point_level_log: [],
        pointype: 10,
        point_level: 0,
        reveiew: 0,
        radio: false,
        isActive: false,
        page: 1,  // 历史记录请求页数
        limint: 10, // 历史记录请求条数
        type: 0, // 请求类型参数
        taskFinsh: false,
        isShow: false,
        history:[], // 操作记录表单
        noFinsh:0,
        showAll: false,
        taskInfo:null,
        uploadProof: false,
        dialogTaskVisible1: false,
        expiredate:'',
        expiretime:'',
        fixed_cycle: [
          {id: 0, type: '从不'},
          { id: 1, type: '每天自动分配' },
          { id: 2, type: '每周自动分配' },
          { id: 3, type: '每月自动分配' }
        ],
        taskType: '1',
        activeName: 'first',
        Xtoken: { 'X-Token': getToken() },
        files: [],

        profile: this.$store.getters.user_info,
        filter: {
          status: [],
          keywords: '',
          time_range: []
        },
        loading: false,
        status_list: [
          { text: '未领取', value: 0 },
          { text: '已领取', value: 1 },
          { text: '已完成', value: 2 },
          { text: '已取消', value: -1 }
        ],
          taskTypeA:[
          {name: '普通任务', value: 10},
          {name:'关键任务', value: 20}
        ],
        isChange: true,
        dialogTaskVisible: false,
        dialogTaskTitle: '发布任务',
        totalCount: 0,
        currentPage: 1,
        pageLimit: 10,
        tableData: null,
        dialogCreateCategoryVisible: false,
        dialogEditCategoryVisible: false,
        taskFormApi: '/integral.php/task/new_add',
        isRequest: false,
        employeeOptions: [],
        lookId:null, // 任务id
        taskForm: {
          task_type: 10,
          fixed_cycle: 0,
          name: '',
          remark: '',
          start_time: '',
          expiretime: '',
          point: 0,
          file_list: [],
          follow_id: ''
        },
        performer: [], // 执行者id
        follow: [], // 参与者id
        taskFormRules: taskFormRules,
        accessEnabled: {
          add: 0,
          delete: 0,
          edit: 0
        },
        isSend: false,  // 判断发布任务还是修改任务
        dialogTaskVisibleH: false,
        historyData: [],
        instantPickerOptions: {
          shortcuts: [
            {
              text: '本周',
              onClick(picker) {
                const now = new Date(new Date().toLocaleDateString())
                const start =
                  now.getTime() - (now.getDay() - 1) * 24 * 60 * 60 * 1000
                const end = start + 7 * 24 * 60 * 60 * 1000 - 1000
                picker.$emit('pick', [start, end])
              }
            },
            {
              text: '上周',
              onClick(picker) {
                const now = new Date(new Date().toLocaleDateString())
                const start =
                  now.getTime() - (now.getDay() + 6) * 24 * 60 * 60 * 1000
                const end = start + 7 * 24 * 60 * 60 * 1000 - 1000
                picker.$emit('pick', [start, end])
              }
            },
            {
              text: '本月',
              onClick(picker) {
                const now = new Date()
                const startDate = new Date(now.getFullYear(), now.getMonth(), 1)
                const endDate = new Date(
                  now.getFullYear(),
                  now.getMonth() + 1,
                  0
                )
                picker.$emit('pick', [startDate.getTime(), endDate.getTime()])
              }
            },
            {
              text: '上月',
              onClick(picker) {
                const now = new Date()
                const startDate = new Date(
                  now.getFullYear() - (now.getMonth() > 0 ? 0 : 1),
                  (now.getMonth() + 11) % 12,
                  1
                )
                const endDate = new Date(now.getFullYear(), now.getMonth(), 0)
                picker.$emit('pick', [startDate.getTime(), endDate.getTime()])
              }
            }
          ]
        }
      }
    },
    watch:{
      // expiredate(val,old){
      //   console.log(val)
      //   if(this.expiretime != '' && this.expiredate != '' && this.expiretime != null && this.expiredate != null){
      //     this.taskForm.expiretime = this.expiredate + " " + this.expiretime
      //   }else{
      //     this.taskForm.expiretime = ''
      //   }
      // },
      //  start_time(val,old){
      //   console.log(val)
      //   if(this.start_time != '' && this.start_time != null){
      //     this.taskForm.start_time = this.start_time
      //   }else{
      //     this.taskForm.start_time = ''
      //   }
      // },

    },
    methods: {
       openUrl(url) {
          window.open(url)
      },
        chngeShow() {
        console.log("jddj")
        this.iShow = false;
        this.getLevel();
        setTimeout(() => {
            this.getPoint();
      }, 200)

      },
      ChangeTask() {
       // this.dialogTaskVisible = true;
        this.iShow = true;
       // this.$refs.loadingPlease.dialogTaskClose();
        this.$refs.loadingPlease.getCorde();
      },
       getLevel() {
        console.log("jdfjf");
        this.$http('get','/integral.php/taskscorelevel/getScoreLevel')
          .then(res => {
            if(res.data.code == 1000) {
            let { data = {} } = res.data;
            this.one = data.very_satisfied;
            this.two = data.satisfaction;
            this.three = data.qualified;
            this.four = data.failed;
          }
          })
      },
       formReset() {
        this.iSplay = true;
        this.isSwitch = false;
        this.taskForm.point = 0;
        this.dialogTaskClose();
      },
       getPoint() {

        if(this.taskForm.point > 0) {
          this.iSplay = false;
       //  this.isSwitch = true;
        }else {
          this.iSplay = true;
          this.isSwitch = false;
        }
        console.log(this.one)
        console.log(this.two)
        console.log(this.three)
        console.log(this.four)
        this.oneCorde = Math.round((this.one/this.three)*this.taskForm.point);
        this.twoCorde = Math.round((this.two/this.three)*this.taskForm.point);
        this.threeCorde = this.taskForm.point;
        this.fourCorde = Math.round((this.four/this.three)*this.taskForm.point);
        console.log( (this.twoCorde ))
      },
       chngePoint() {
        console.log(this.isSwitch )
        if(this.taskForm.point > 0) {
          this.iSplay = false;
        }else {
          this.iSplay = true;
        }
        if(this.pointype !=20 && this.isSwitch ) {
            this.oneCorde = Math.round((this.one/this.three)*this.taskForm.point);
            this.twoCorde = Math.round((this.two/this.three)*this.taskForm.point);
            this.threeCorde = this.taskForm.point;
            this.fourCorde = Math.round((this.four/this.three)*this.taskForm.point);
        }
      },
        // 时间转换
      dateFormatter: function (row, column, cellValue) {
        return this.$moment(cellValue * 1000).format('YYYY-MM-DD HH:mm')
      },
      // 查看明细领取任务
      taskCompleteConfirm() {
        let id = this.lookId;
        this.getTask(id);
      },
      ChosePerson(value) {

        const self = this;
        let array = [];
        array.push(value);
        if( self.follow.length !=0) {
          let chose = self.follow;
          let newArray = array.filter(i=>chose.indexOf(i) == -1)
          self.performer = newArray[0];
        }

      },
      enter(value) {
        const self = this;
        let choseArray = [];
        choseArray.push(self.performer)
        let array = [];
        array = value;
        if( self.performer.length !=0) {
          let newArray = array.filter(i=>choseArray.indexOf(i) == -1)
          self.follow = newArray;
        }

      },
      closeDialog() {
        this.uploadProof = false
      },
      fileProview(url, list, key) {
        const $ext_list = ['doc', 'docx', 'pptx', 'xls', 'xlsx', 'ppt', 'txt']
        const $ext_name = url.split('.')[1]
        if ($ext_list.indexOf($ext_name) >= 0) {
          console.log(
            'https://view.officeapps.live.com/op/view.aspx?src=' +
            this.serverdomain +
            url
          )
          window.open(
            'https://view.officeapps.live.com/op/view.aspx?src=' +
            this.serverdomain +
            url,
            '_blank'
          )
        }
        window.open(url)
        const $ext_list1 =  ['jpg', 'png', 'bmp', 'jpeg','JPG','PNG']
        const $ext_name1 = url.split('.')[1]
        if ($ext_list1.indexOf($ext_name1) >= 0) {
          console.log(this.serverdomain + url)

          let ii = 0
          for (const i in list) {
            if (
               ['jpg', 'png', 'bmp', 'jpeg','JPG','PNG'].indexOf(list[i].url.split('.')[1]) >=
              0
            ) {
              if (list[i].url == url) {
                this.openPhotoSwipe(
                  ii,
                  document.querySelectorAll('img[preview="' + key + '"]')
                )

                return
              }
              ii++
            }
          }
        }
      },
      loadWidgetData: function() {
        var self = this
        const params = {
          id: this.profile.id,
          category_tree: 1,
          employee_list: 1
        }
        this.$http('get','/integral.php/ajax_request_common/prepare_integral_options',params)
          .then(function(response) {
            if (response.status == 200) {
              var jsonData = response.data
              try {
                self.employeeOptions = jsonData.employee_list
              } catch (err) {
                console.log(err)
              }
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },
      onFilePreView(file) {
          window.open(file.url);
          return;
        // 点击时查看文件
        const $ext_list = ['doc', 'docx', 'pptx', 'xls', 'xlsx', 'ppt', 'txt']
        const $ext_name = file.name.split('.')[1]
        window.open(file.url)
        if ($ext_list.indexOf($ext_name) >= 0) {
          // console.log(
          //   'https://view.officeapps.live.com/op/view.aspx?src=' +
          //     this.serverdomain +
          //     file.url
          // )
          // window.open(
          //   'https://view.officeapps.live.com/op/view.aspx?src=' +
          //   this.serverdomain +
          //   file.response.url,
          //   '_blank'
          // )
        }
        const $ext_list1 =  ['jpg', 'png', 'bmp', 'jpeg','JPG','PNG']
        const $ext_name1 = file.name.split('.')[1]
        if ($ext_list1.indexOf($ext_name1) >= 0) {
          // console.log(this.serverdomain + file.url)

          let ii = 0
          for (const i in this.taskForm.file_list) {
            if (
               ['jpg', 'png', 'bmp', 'jpeg','JPG','PNG'].indexOf(
                this.taskForm.file_list[i].name.split('.')[1]
              ) >= 0
            ) {
              if (this.taskForm.file_list[i].name == file.name) {
                this.openPhotoSwipe(
                  ii,
                  document.querySelectorAll('img[preview="' + file.uid + '"]')
                )

                return
              }
              ii++
            }
          }
        }
      },

      onFileRemove(file, fileList) {
        this.taskForm.file_list = fileList
      },

      handleFilesSuccess(response, file, fileList) {
        this.$set(this.taskForm, 'file_list', fileList)
      },
      beforeFilesUpload(file) {
        const $ext_list = ['jpg', 'png', 'bmp', 'jpeg','PNG', 'JPG'];

        let len =  file.name.split('.').length - 1;
        const $ext_name = file.name.split('.')[len]
        if ($ext_list.indexOf($ext_name) != -1) {
          const isLt20M = file.size / 1024 / 1024 < 2
          if (!isLt20M) {
            this.$message.warning('您上图片不能大于2M')
            return false

          }
        }else {
          this.$message.warning('文件格式上传错误,仅支持上传图片）')
          return false
        }

      },
      handleSizeChange(val) {
        this.pageLimit = val
        this.onFilterChanged()
      },
      filterHandler: function(value) {
        if (typeof value.status !== 'undefined' && value.status.length == 0) {
          this.filter.status = []
        }
        if (typeof value.status !== 'undefined' && value.status.length > 0) {
          this.filter.status = value['status']
        }

        this.onFilterChanged()
      },

      dialogTaskClose: function() {
        const form = this.$refs['newTaskForm']
        form.clearValidate()
        this.dialogTaskVisible = false;
        this.iSplay = true;
        this.isSwitch = false;
        this.oneCorde = '';
        this.twoCorde = '';
        this.threeCorde = '';
        this.fourCorde = '';
      },
      beforeOpen() {

        // this.oneCorde = '';
        // this.twoCorde = '';
        // this.threeCorde = '';
        // this.fourCorde = '';
      },
      OpenDetail(id,cycle){
        this.dialogTaskVisible1 = true;  // 打开任务弹窗
        this.taskFinsh = false;   // 关闭历史任务详情弹窗
        this.lookId = id;
        // let fixed = cycle;
        // console.log(cycle);
        // if(fixed > 0) {

        //   this.isShow = true;
        // }else {
        //   this.isShow = false;
        // }
        this.loadOpen()
      },
      show_task(id,cycle){
        this.dialogTaskVisible1 = true
        this.lookId = id;
        let fixed = cycle;
        // console.log(cycle);
        if(fixed > 0) {

          this.isShow = true;
        }else {
          this.isShow = false;
        }
        this.loadOpen()
      },


      dialogTaskOpen: function(title, id, isChange) {
       // this.$refs['newTaskForm'].resetFields();
        this.taskTypeA = [
          {name: '普通任务', value: 10},
          {name:'关键任务', value: 20}
        ];
        if(!isChange) {
          this.isChange = true;
        }else {
          this.isChange = false;
        }
        this.activeName = 'first'
        this.lookId = id;
        const self = this
        this.dialogTaskTitle = typeof id === 'undefined' ? '发布任务' : '修改任务'
        this.isSend = typeof id  === 'undefined' ? true : false;
        this.dialogTaskVisible = true
        if (typeof id !== 'undefined') {
          this.taskForm['id'] = id
          self.taskFormApi = '/integral.php/task/update'
          console.log('更换更新接口')
          this.loadTaskInfo(id)
        } else {
          this.taskForm = {
            name: '',
            remark: '',
            fixed_cycle: '',
            expiretime: '',
            point: 0,
            file_list: [],
            follow_id: '',
             task_type: 10,
          }
          self.taskFormApi = '/integral.php/task/new_add'
          console.log('更换增加数据接口')
        }
        this.$nextTick(() => {
          const form = this.$refs['newTaskForm']

          this.$previewRefresh()

          console.log(form)
          if (typeof id === 'undefined') {
            form.resetFields()
            form.clearValidate()
          }
        })
      },
      CloseTask() {
        this.taskFinsh = false;
      },
      showFinsh() {
        const self = this;
        this.isActive = !this.isActive;
        if(this.isActive) {
          self.type = 1;

        }else {
          self.type = 0;

        }
        self.lookFinsh();

      },
      // 显示历史任务
      lookFinsh() {
        const self = this;
        let taskId = self.lookId;
        // this.dialogTaskVisible1= false;
        this.taskFinsh = true;
        this.$http('get','/integral.php/task/get_task_history',{task_id: taskId,page: self.page,size: self.limint,type: self.type,})
          .then(function(res) {
            if (res.status == 200) {
              self.historyData = res.data.data;

            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },
      // 查看详情
      loadOpen: function(id) {
        const self = this
        let taskId = self.lookId;
        this.$http('get','/integral.php/task/getTaskLog',{task_id: taskId})
          .then(function(response) {
            if (response.status == 200) {
             console.log("jinalils")
              var jsonData = response.data.data.task;
              self.history = response.data.data.history;
              self.noFinsh =  response.data.data.not_finish;
              let fixed = response.data.data.history_finish;
                console.log("jinalils")
              self.point_level_log = jsonData.point_level_log;
              console.log( jsonData.point_level_log)
              if(jsonData.point_level_log!='' && jsonData.point_level_log!= null || jsonData.point_level_log!= undefined) {
                if(jsonData.point_level_log[0].key == 40) {
                   self.point_level_log = jsonData.point_level_log.reverse();
                }
              }
              self.pointype = jsonData.point_type;

               self.point_level = jsonData.point_level;
               self.follow_name = jsonData.follow_name;
                 console.log("jinalils")
              console.log(self.point_level==20&&self.reveiew == 1)
              self.reveiew = jsonData.review_status;
              console.log(fixed);
              if(fixed > 0) {
                self.isShow = true;
              }else {
                self.isShow = false;
              }
              console.log( self.history );

              jsonData.expiretime = self.dateTimeFormatter(
                '',
                '',
                jsonData.expiretime
              )

              // switch (jsonData.fixed_cycle) {

              //   case 1:
              //     // jsonData.expiretime ? jsonData.expire_text : '每天任务'
              //     jsonData.expiretime = '每天任务'
              //     break
              //   case 2:
              //     jsonData.expiretime = '每周任务'
              //     break
              //   case 3:
              //     jsonData.expiretime = '每月任务'
              //     break
              // }


              // if (self.dialogEditTaskVisible) {
              //   self.noFinsh = jsonData.not_finish
              //   self.editTaskForm.name = jsonData.name
              //   self.editTaskForm.remark = jsonData.remark
              //   self.editTaskForm.expiretime = jsonData.expiretime
              //   self.editTaskForm.file_list = jsonData.file_list
              //   self.editTaskForm.fixed_cycle = jsonData.fixed_cycle
              //   if (jsonData.data.follow_id > 0) {
              //     self.editTaskForm.follow_id = [jsonData.follow_id]
              //   }
              //   if (jsonData.fixed_cycle >= 0) {
              //     self.editTaskForm.fixed_cycle = jsonData.fixed_cycle
              //     console.log( self.editTaskForm.fixed_cycle);
              //     console.log("lkjdfasd");
              //   }
              // } else {
              console.log(jsonData);

              self.taskForm.name = jsonData.name
              console.log( self.taskForm.name )
              self.taskForm.fixed_cycle = jsonData.fixed_cycle
              self.taskForm.file_list = jsonData.file_list
              self.taskForm.id = jsonData.id
              self.taskForm.status = jsonData.status
              self.taskForm.expiretime = jsonData.expiretime
              console.log(jsonData.expiretime)
              self.taskForm.point = jsonData.point
             // self.taskForm.file_list = jsonData.file_list
              self.taskForm.remark = jsonData.remark
              self.taskForm.creator_id = jsonData.creator_id
              switch (jsonData.fixed_cycle) {
                case 1:

                  return  self.taskForm.fixed_cycle  = '每天任务'
                  break
                case 2:

                  return  self.taskForm.fixed_cycle = '每周任务'

                  break

                case 3:
                  return self.taskForm.fixed_cycle  = '每月任务'
                  break
              }
              // }
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },

      // 修改详情
      loadTaskInfo: function(id) {
        const self = this

        this.$http('get','/integral.php/task/get_task_info',{id: id})
          .then(function(response) {
            if (response.status == 200) {
              var jsonData = response.data
              self.taskInfo = jsonData.data
              jsonData.data.expiretime = self.dateTimeFormatter(
                '',
                '',
                jsonData.data.expiretime
              )
              self.taskForm.fixed_cycle = jsonData.data.fixed_cycle
              self.taskForm.name = jsonData.data.name
              self.taskForm.task_type = jsonData.data.task_type;
              self.taskForm.id = jsonData.data.id
              self.taskTypeA = [
          {name: '普通任务', value: 10},
          {name:'关键任务', value: 20}
        ],
              self.taskForm.expiretime = jsonData.data.expiretime
              console.log( self.taskForm.expiretime);
              console.log("klkkkk")
              self.pointype = jsonData.data.point_type
               if(self.pointype == 10) {

                self.isSwitch = false;

              }else {
                console.log("2345")
                self.isSwitch = true;
              }
              self.point_level = jsonData.data.point_level
              self.point_level_log = jsonData.data.point_level_log;
              console.log(jsonData.data.expiretime.split(' '))

              // self.expiredate = jsonData.data.expiretime.split(' ')[0]
              // self.expiretime = jsonData.data.expiretime.split(' ')[1]
              self.expiretime = jsonData.data.expiretime
              self.taskForm.point = jsonData.data.point
              self.taskForm.file_list = jsonData.data.file_list
              if(jsonData.data.point>0) {
                self.iSplay = false;
              }
              if( jsonData.data.point_type == 20) {
               self.point_level_log.forEach((item, index) =>　{
                 console.log(item)
                 if(item.key == 10) {

                   self.oneCorde = item.value;
                 }else if(item.key == 20) {
                   self.twoCorde = item.value;
                 }else if( item.key == 30) {
                   self.threeCorde = item.value;
                 }else {
                   self.fourCorde = item.value;
                 }
               })
              }
              // self.taskForm.follow_id = [jsonData.data.follow_id];
              self.taskForm.remark = jsonData.data.remark
              if (jsonData.data.follow_id > 0) {
                self.taskForm.follow_id = [jsonData.data.follow_id]
              }
              if (jsonData.data.fixed_cycle == 0) {
                self.taskType = '1'
              } else {
                self.taskType = '2'
              }
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },
      getMessage() {
        console.log("hhjhh")
        if(this.taskForm.point == 0) {
          this.$message({
            type: 'error',
            message: '请输入积分'
          })
        }
      },
      dialogTaskSend: function() {
        if(this.taskForm.point == 0) {
          this.$message({
            type: 'error',
            message: '积分不能为0'
          })
           return;
        }
        const self = this;
        this.taskForm.follow_id = this.follow.concat(self.performer);

        let newArray = [];
        if(self.isSend) {
          for(var i = 0; i < self.taskForm.file_list.length; i ++) {
            if(self.taskForm.file_list[i].response != undefined ) {
              newArray.push({});
              newArray[i].name =  self.taskForm.file_list[i].name;
              newArray[i].response =  self.taskForm.file_list[i].response;
              delete newArray[i].response.extension;
              delete newArray[i].response.file_name;
              delete newArray[i].response.mime_type;
              delete newArray[i].response.path;
              delete newArray[i].response.status;
            }else {
              if(self.taskForm.file_list[i].status != undefined && self.taskForm.file_list[i].uid != undefined) {
                delete self.taskForm.file_list[i].status;
                delete self.taskForm.file_list[i].uid;
              }
              newArray.push(self.taskForm.file_list[i]);
            }
          }


        }else {

          for(var i = 0; i < self.taskForm.file_list.length; i ++) {
            if(self.taskForm.file_list[i].response != undefined ) {
              newArray.push({});
              newArray[i].name =  self.taskForm.file_list[i].name;
              newArray[i].url =  self.taskForm.file_list[i].response.url;

            }else {
              if(self.taskForm.file_list[i].status != undefined && self.taskForm.file_list[i].uid != undefined) {
                delete self.taskForm.file_list[i].status;
                delete self.taskForm.file_list[i].uid;
              }
              newArray.push(self.taskForm.file_list[i]);
            }
          }
        }
        if(this.isSwitch) {
          self.taskForm.point_type = 20;
          self.taskForm.point_level_log = [{key:10,value:this.oneCorde},{key:20,value:this.twoCorde},{key:30,value: self.taskForm.point},{key:40,value: this.fourCorde}]
        }else {
          self.taskForm.point_type = 10;
          self.taskForm.point_level_log = [];
        }
        this.taskForm.file_list = newArray;
        const form = this.$refs['newTaskForm']

      //  if(self.taskForm.follow_id==''|| self.taskForm.follow_id==undefined) {
      //     delete self.taskForm.follow_id
      //   }

        form.validate((valid, invalidFields) => {
          if (valid) {
            this.loading = true
            this.$http('post',self.taskFormApi,qs.stringify({ row: this.taskForm }),
              // headers: {
              //   'Content-Type': 'application/x-www-form-urlencoded'
              // }
            )
              .then(function(response) {
                self.loading = false
                setTimeout(function() {
                  self.isRequest = false
                }, 200)

                var message = ''
                var status = 0
                if (response.status == 200) {
                  var data = response.data

                  message = data.msg

                  if (data.code == 1) {
                    self.expiretime = ''
                    // self.expiredate = ''
                    self.dialogTaskClose()
                    self.loadTaskList()

                    self.taskForm.task_type = 10;
                    console.log(self.oneCorde);
                    self.performer = '';
                    self.follow = [];
                    self.oneCorde = 0
                    self.twoCorde = 0
                    self.threeCorde =0
                    self.fourCorde = 0
                    // self.iSplay = false;
                    self.isSwitch = false;
                    self.$message({
                      message: message,
                      type: 'success'
                    })
                  }
                } else {
                  self.$message({
                    message: response.data.msg,
                    type: 'error'
                  })
                }
              })
              .catch(function(error) {
                console.log(error)
              })
          } else {
            for(let i in invalidFields){
              self.$message.error(invalidFields[i][0].message)
              self.activeName = 'first'
              return false
            }
            //
            console.log(invalidFields)
            return false
          }
        })
      },
      onFilterChanged: function() {
        this.currentPage = 1
        this.loadTaskList()
      },
      dateTimeFormatter: function(row, column, cellValue) {
        return cellValue
          ? this.$moment(cellValue * 1000).format('YYYY-MM-DD HH:mm')
          : ''
      },
      taskStatusText: function(row, column, cellValue) {
        let text = ''
        switch (cellValue) {
          case 0:
            text = '未领取'
            break
          case 1:
            text = '已领取'
            break
          case 2:
            text = '已完成'
            break
          case -1:
            text = '已取消'
            break
        }
        // if (row.expire_text != '') {
        //   if (row.fixed_cycle > 0) {
        //     return text
        //   }
        //   return text + '-' + row.expire_text
        // }
        return text
      },
      loadTaskList: function() {
        this.loading = true
        var self = this
        var params = {
          site_id: this.profile.site_id,
          keywords: this.keywords,
          page: this.currentPage,
          creator_id: 0,
          follow_id: 0,
          status: [0],
          offset:
          (this.currentPage == 1 ? 0 : this.currentPage - 1) * this.pageLimit,
          limit: this.pageLimit
        }
        for (const item in this.filter) {
          const value = this.filter[item]
          if (item == 'status') {
            if (!value || value.length == 0) {
              continue
            }
            params[item] = value
          } else {
            if (value != null) {
              const valueStr = value.toString()
              if (valueStr && valueStr.length > 0) {
                params[item] = valueStr
              }
            }
          }
        }
        console.log(params)
        this.$http('get','/integral.php/task/get_task_list',params)
          .then(function(response) {
            if (response.status == 200) {
              self.loading = false
              var jsonData = response.data
              try {
                self.totalCount = jsonData.data.total
                self.tableData = jsonData.data.list
                // self.tableData = []
                // jsonData.data.list.forEach(item => {
                //   if(item.status == 0){
                //     self.tableData.push(item)
                //   }
                // });
              } catch (err) {
                console.log(err)
              }
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },
      changePage: function(current) {
        if (isNaN(current) || current < 1) {
          return false
        }
        this.loadTaskList()
      },
      onDismissCreateCategoryDialog: function() {
        var form = this.$refs['newCategoryForm']
        form.clearValidate()
        this.newCategoryForm = {
          name: '',
          pid: []
        }
      },
      onDismissEditCategoryDialog: function() {
        var form = this.$refs['categoryForm']
        form.clearValidate()
        this.categoryForm = {
          id: '',
          name: '',
          pid: []
        }
      },
      submitCreateCategoryForm: function(formName) {
        var form = this.$refs[formName]
        var self = this
        form.validate(valid => {
          if (valid) {
            if (form) {
              self.sendCreateCategoryRequest()
            }
          } else {
            return false
          }
        })
      },
      submitEditCategoryForm: function(formName) {
        var form = this.$refs[formName]
        var self = this
        form.validate(valid => {
          if (valid) {
            if (form) {
              self.submitEditCategoryForm(form)
            }
          } else {
            return false
          }
        })
      },

      confirmDelete: function(taskId) {
        this.$confirm('任务删除后不可恢复，确认要删除？', '删除任务', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.deleteTask(taskId)
          })
          .catch(() => {})
      },
      getTask: function(taskId) {
        if (!taskId) {
          return false
        }
        const params = {
          id: taskId
        }
        var self = this

        this.$http('get','/integral.php/task/get_task',params,'','',
          {transformRequest: [
            data => {
              const paramArray = new Array()
              for (const it in data) {
                paramArray.push(
                  encodeURIComponent(it) + '=' + encodeURIComponent(data[it])
                )
              }
              return paramArray.join('&')
            }
          ]},
          // headers: {
          //   'Content-Type': 'application/x-www-form-urlencoded'
          // }
        )
          .then(function(response) {
            var message = ''
            var status = 0
            if (response.status == 200) {
              var data = response.data

              message = data.msg

              if (data.code == 1) {
                self.$message({
                  message: message,
                  type: 'success'
                })
                self.loadTaskList()
                self.dialogTaskVisible1 = false;
              } else {
                self.$message({
                  message: message,
                  type: 'error'
                })
              }
            } else {
              message = '服务器太忙了'
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },
      deleteTask: function(taskId) {
        if (!taskId) {
          return false
        }
        const params = {
          id: taskId
        }
        var self = this

        this.$http('post','/integral.php/task/delete',params,'','',
          {transformRequest: [
            data => {
              const paramArray = new Array()
              for (const it in data) {
                paramArray.push(
                  encodeURIComponent(it) + '=' + encodeURIComponent(data[it])
                )
              }
              return paramArray.join('&')
            }
          ]},
          // headers: {
          //   'Content-Type': 'application/x-www-form-urlencoded'
          // }
        )
          .then(function(response) {
            var message = ''
            var status = 0
            if (response.status == 200) {
              var data = response.data

              message = data.msg

              if (data.code == 1) {
                self.$message({
                  message: message,
                  type: 'success'
                })
                self.loadTaskList()
              } else {
                self.$message({
                  message: message,
                  type: 'error'
                })
              }
            } else {
              message = '服务器太忙了'
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },
      loadRuleDetail: function(ruleId) {
        const params = {
          id: ruleId
        }
        var self = this
        this.$http('get','/integral.php/ajax_request_common/get_rule_info',params)
          .then(function(response) {
            if (response.status == 200) {
              const jsonData = response.data
              try {
                const detailData = self.processDetailData(jsonData)
                self.detailData.name = detailData.name
                self.detailData.remark = detailData.remark
                self.detailData.category_id = detailData.category_id
                self.detailData.items = detailData.items
                self.detailData.id = detailData.id
              } catch (err) {
                console.log(err)
              }
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      }
      // 获取具体权限（对积分管理员/公司管理员生效）
      // loadAccessItemFlag: function () {
      //   var self = this;
      //   this.$http.get('/integral.php/ajax_request_common/get_access_flag', {
      //     params: {
      //       id: this.profile.id,
      //       page_name: 'rule_master'
      //     }
      //   }).then(function (response) {
      //     if (response.status == 200) {
      //       var jsonData = response.data;
      //       try {
      //         self.accessEnabled = jsonData;
      //       } catch (err) {
      //         console.log(err);
      //       }
      //     }
      //   }).catch(function (error) {
      //     console.log(error);
      //   });
      // },
    },
    created() {
      if (this.$route.params.currentMonth) {
        const now = new Date()
        const startDate = new Date(now.getFullYear(), now.getMonth(), 1)
        const endDate = new Date(now.getFullYear(), now.getMonth() + 1, 0)
        this.filter.time_range = [startDate.getTime(), endDate.getTime()]
      }
      this.loadTaskList()
      this.loadWidgetData()
      this.getLevel();
      if (this.profile.manager_type == 4) {
        this.accessEnabled = {
          add: 1,
          delete: 1,
          excel_import: 1,
          edit: 1
        }
      } else if (this.profile.manager_type > 1) {
        // this.loadAccessItemFlag()
      }
    }
  }
</script>
<style scoped lang="scss">
  .el-pagination {
    text-align: center;
    margin-top: 15px;
  }
  .table-item{display: table;}
  .table-item .table-label{display: table-cell; width:90px; text-align: right; margin-right:0.5em;}
  .pswp--supports-fs.pswp--open {
    z-index: 3000;
  }
  /deep/.DialogStyle .el-dialog__header {
    float: left;
    padding: 35px 30px 28px;
  }
  /deep/ .DialogStyle .el-dialog__body {
    padding-left: 50px;
  }
  /deep/ .DialogStyle .el-form-item__label {
    text-align: left;
    font-weight: normal;
  }
  /deep/ .DialogStyle .el-form-item {
    margin-bottom: 10px;
  }
  /deep/ .historyClass .el-dialog__title {
    font-size: 17px;
    color: #303133;
    font-weight: 400;
  }
  /deep/.history {
    float: left;
    padding: 16px 0 0 25px;
  }
  /deep/ .historyClass {
    height: 540px;
  }
  /deep/.historyClass .el-dialog__body {
    padding: 5px 35px;
  }
  /deep/ .historyClass .el-dialog__footer {
    position: absolute;
    bottom: 10px;
    left: 238px;
  }
  .active {
    background:#26A2FF;
    border: none!important;
  }
  /deep/ .el-checkbox .el-checkbox__inner {
    border-radius: 50%;
  }
  /deep/ .changeTask .el-dialog__body {
    padding: 25px 80px;
  }
  /deep/ .changeTask .el-dialog__header{
    padding: 38px 20px 0 40px;
  }
  /deep/ .changeTask .el-form-item__label {
    font-weight: normal;
  }
  /deep/ .changeTask .el-textarea {
    width: 300px;
  }
   .itemCorde {
    width: 63px;height: 58px;display:flex;flex-direction: column;justify-content: center;align-items: center;
    margin-right: 12px;
  }
  .itemCorde div {
    height: 24px;
    line-height: 24px;
    font-size: 14px;
    color: #909399;

  }
    .isActive div {
    color: #26A2FF;
  }
  .corde {
    display: flex;
    flex: 1;
    flex-direction: row;
  }
  .cordeOne {
    display: flex;
    flex-direction: column;
    width: 63px;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
  }
  .bordeLine {
    border: 1px solid #E4E7ED;
    width: 63px;
    height: 36px;
    text-align: center;
  }
  .el-dialog__headerbtn .el-dialog__close {
    display: none;
  }
  .corde /deep/ .el-input__inner::-webkit-outer-spin-button,
.corde /deep/ .el-input__inner::-webkit-inner-spin-button {
   -webkit-appearance: none!important;
   appearance: none!important;
}
/deep/ .el-scrollbar__bar .el-scrollbar__thumb {
  display: none;
}
</style>
