<template>
  <div>
    <div>
      <el-tabs v-model="work" type="card">
        <el-tab-pane label="我的任务" name="1">
        </el-tab-pane>
        <el-tab-pane label="任务文件" name="2">
        </el-tab-pane>
      </el-tabs>
    </div>
    <div class="taskMine" style=" background-color: #fff;padding:0 15px 15px 30px;">
      <div v-if="work == '1'">
        <div style="margin-top:2px; margin-bottom:15px;" class="inline-block-btn-list">
          <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>
          <span class="taskType">
      <el-select style="width:150px;" v-show="true" v-model="checkList" @change="checkListValue" v-if="profile.manager_type > 0">
          <el-option
            v-for="item in taskTypeList"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </span>


          <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>
          </div>
        </div>

        <el-table

          stripe
          v-loading="loading"
          ref="multipleTable"
          :data="tableData"
          tooltip-effect="dark"
          @filter-change="filterHandler"
          style="width: 100% text-align: left;"
        >
          <el-table-column prop="name" label="内容"></el-table-column>
          <el-table-column prop="remark" label="备注" :show-overflow-tooltip="true" width="200"></el-table-column>
          <el-table-column label="奖分"   width="100">
             <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.finally_point!=''|| scope.row.finally_point != null ">
                {{scope.row.finally_point}}
              </span>
              <span   v-if="scope.row.finally_point ==''|| scope.row.finally_point == null ">{{scope.row.point}}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column v-if="task_type == 0" prop="follow.name" label="领取人"></el-table-column> -->
          <el-table-column prop="status" label="状态" :filters="status_list" >
            <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.is_finish == 0">未完成</span> -->
               <span  v-if="scope.row.status == 0 || scope.row.status == 1">未完成</span>
              <span  v-if="scope.row.status == 2">已完成</span>
            </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="操作">
            <template slot-scope="scope">
              <div>
                <el-button type="text" @click="dialogTaskOpen(scope.row.id, scope.row.fixed_cycle, 0)">查看</el-button>
                <el-button
                  v-show="profile.is_creator || profile.id==scope.row.creator_id && review_status!= 1 && review_status_text !='已通过' && scope.row.status != 2 "
                  type="text"
                  @click="dialogEditTaskOpen(scope.row.id)"
                >修改</el-button>
                <el-button
                  type="text"
                  @click="confirmDelete(scope.row.id)"
                  v-show="scope.row.creator_id == profile.id"
                >删除</el-button>
                <!-- && task_type != 0 -->
                <el-button
                  v-if="scope.row.get_self != 0 && scope.row.status == 1 && scope.row.follow_id == profile.id"
                  type="text"
                  @click="TaskRelease(scope.row.id)"
                >释放</el-button>

                <!-- <el-button
                  v-if="scope.row.status == 2  && scope.row.review && scope.row.review.status==0"
                  type="text"
                  disabled
                >审核中</el-button>
                <el-button v-if="scope.row.status == 2 && scope.row.review && scope.row.review.status==1" type="text">已通过</el-button>
                <el-button
                  v-if="scope.row.status == 2 && scope.row.review && scope.row.review.status==-1"
                  type="text"
                  disabled
                >被驳回</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>

      </div>
      <div v-if="work == '2'">
        <TaskFile />
      </div>

      <!-- 任务查看弹窗 -->
      <el-dialog
        title="任务详情"
        :visible.sync="dialogTaskVisible"
        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"><div style="width: 280px;word-break: break-all;
    word-wrap: break-word;">{{taskForm.name}}</div></el-form-item>
          <el-form-item
            label="执行者"
            prop="follow_id"
            label-width="100px"
          >
            <!-- <div
              v-for="item in employeeOptions"
            >

             <span v-if="taskForm.follow_id == item.id ">{{item.name}}</span>
            </div> -->
            <div>{{follow_name}}</div>
          </el-form-item>
           <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 in point_level_log">
                <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" v-if="reveiew == 1 && review_status_mark =='已通过' ">{{newpoint}}</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-if=" taskForm.file_list != ''">
            <div   v-for="item in taskForm.file_list"  @click="openUrl(item.url)" style="width: 280px;color: #409EFF;word-break: break-all; cursor:pointer;
    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 @click="fileProview(item.url)" style="width: 280px;word-break: break-all; cursor:pointer;color: #409EFF; word-wrap: break-word;" v-for="item in complete_file_list">
             {{item.url}}

            </div>

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

          <el-form-item label="操作记录：" label-width="100px"  >
            <!-- <el-scrollbar
              wrap-class="column-wrapper scrollable-items-container check-item-box dept_tree"
              :native="false"
              style="height: 100px;"
            > -->
              <div v-for="item in history" 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-scrollbar> -->
          </el-form-item>


           </el-scrollbar>
        </el-form>

           <div slot="footer" class="dialog-footer">
            <el-button @click="CloseHistory()">关 闭</el-button>
              <!-- <el-button type="primary" v-if="taskForm.status != 2 && taskForm.creator_id != profile.id" :loading="loading" @click="taskCompleteConfirm">完成任务</el-button> -->
            <el-button type="primary"  v-if="taskForm.status != 2 && taskForm.creator_id != profile.id" @click="taskCompleteConfirm">完成任务</el-button>
            <el-button type="primary" v-if="taskForm.status == 2  && taskForm.creator_id != profile.id && review_status_text !='已通过'&& review_status != 1 " @click="TaskCancel(taskForm.id)">撤消完成</el-button>
          </div>

      </el-dialog>

      <!-- 历史完成记录 -->
      <el-dialog
        title="任务历史完成记录"
        :visible.sync="taskFinsh"
        width="614px"
        height="540px"
        custom-class="historyClass"
        :close-on-click-modal="false"
        @close="closeDialog"
      >
        <div  style="padding-bottom: 12px;padding-top: 1px;" >
          <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="截止时间">
            <template slot-scope="scope">
              <span>{{dateTimeFormatter('','',scope.row.expiretime)}}</span>
            </template>
          </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="dialogTaskOpen(scope.row.id, scope.row.fixed_cycle, 5)" style="cursor: pointer;color: rgb(38, 162, 255);">查看</span>
            </template>
          </el-table-column>
        </el-table>
        <div style="width: 560px;margin: 0 auto;">
          <el-pagination
            background
            layout="total, prev, pager, next"

            @size-change="handleChangeTask()"
            :page-size="pageTask"
            :page-sizes="[10, 20, 50, 100]"
            :total="totalTask"
            :current-page.sync="currenTask"
            @current-change="changePageTask"
          ></el-pagination>
        </div>
        <span slot="footer" class="dialog-footer">
        <el-button @click="CloseTask">关 闭</el-button>
      </span>
      </el-dialog>
      <!-- 完成任务弹窗 -->
      <el-dialog
        title="完成任务"
        :visible.sync="finshTask"
        width="462px"
        custom-class="finshTask"
        :close-on-click-modal="false"
      >
        <el-form
          :model="finshForm"
          ref="newTaskForm"
          :rules="taskFormRules"
          @submit.native.prevent
        >
          <el-form-item label="填写说明(选填):" prop="remark" label-width="140px">
            <el-input
              type="textarea"
              :maxlength="200"
              :minlength="100"
              placeholder="请输入内容"
              v-model="finshForm.remark"
            >
            </el-input>

          </el-form-item>
          <el-form-item label="图片上传(选填):"label-width="140px">
            <upload_oss
              :headers="Xtoken"
              class="avatar-uploader"
              :action="'http://'+'integralsys.oss-cn-shenzhen.aliyuncs.com'"
              :show-file-list="true"
              :file-list="proof_file_list"
              :on-success="handleFilesSuccess"
              :on-preview="onFilePreView"
              :before-upload="beforeFilesUpload"
              :on-remove="onFileRemove"
            >
              <el-button size="small" type="primary">点击上传</el-button>
            </upload_oss>
          </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
        <el-button @click="finshTask=false">取消</el-button>
        <el-button type="primary"  :loading="loading"  @click="dialogTaskComplete">确认完成</el-button>
      </span>
      </el-dialog>
      <!-- 任务修改弹窗 -->
      <el-dialog
        title="修改任务"
        custom-class="changeTask"
        :visible.sync="dialogEditTaskVisible"
        width="600px"
        :close-on-click-modal="false"
      >
        <el-form :model="editTaskForm" ref="newEditTaskForm" style="clear: both;" :rules="editTaskFormRules" @submit.native.prevent>
          <div style="padding: 5px 50px;">
            <el-form-item label="任务名称" prop="name" label-width="100px">
              <el-input v-model="editTaskForm.name" :value="editTaskForm.name" auto-complete="off"></el-input>
            </el-form-item>

            <el-form-item label="奖励积分" prop="point" label-width="100px">
              <el-input-number
                v-model="editTaskForm.point"
                :value="editTaskForm.point"
                :min="0"
                :max="10000"
                @change="getPoint"
              ></el-input-number>
            </el-form-item>


          <div>
        <el-form-item label="按标准评分"  label-width="100px" style="margin-bottom: 0px;">
         <el-switch
            :disabled="iSplay"
            :value="isSwitch"
            v-model="isSwitch"
            @change="chngePoint"
          >
          </el-switch>
        </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">
              <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="editTaskForm.point" :value="editTaskForm.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: 2px;">系统为您推荐了各标准的积分</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>

            <el-form-item  label="截止时间"  prop="expiretime" label-width="100px">
              <el-date-picker
                v-model="editTaskForm.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  label="重复周期" prop="fixed_cycle" label-width="100px">
              <el-select
                v-model="editTaskForm.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="follow_id"
              label-width="100px"
            >
              <el-select
                v-model="editTaskForm.follow_id"
                filterable
                clearable
                placeholder="选择负责人"
                class="gap-right-8 first-element-btn"
                style="width:290px;"
              >
                <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="editTaskForm.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="remark" label-width="100px">
              <el-input placeholder="备注（最多100字）" maxlength="100" type="textarea" :value="editTaskForm.remark" v-model="editTaskForm.remark"></el-input>
            </el-form-item>
            <el-form-item label="附件上传" label-width="100px">
              <!-- <el-alert
                title="温馨提示："
                type="success"
                description="" style="margin-bottom:15px;">
                <p style="margin: 0" class="diy-tip">1、可上传图片（jpg, png, bmp, jpeg）格式</p>
                <p style="margin: 0" class="diy-tip">2、可上传文件（doc, docx, pptx, xls, xlsx, ppt, txt, pdf）格式</p>
              </el-alert> -->
              <upload_oss
                :headers="Xtoken"
                class="avatar-uploader"
                :action="'http://'+'integralsys.oss-cn-shenzhen.aliyuncs.com'"
                :show-file-list="true"
                :file-list="editTaskForm.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 editTaskForm.file_list"
                  :key="index"
                  v-if="(['jpg', 'png', 'bmp', 'jpeg','JPG','PNG']).indexOf(item.name.split('.')[1]) >= 0"
                  :src="item.url"
                  :preview="item.uid"
                  :preview-text="item.name"
                >
              </div>
            </el-form-item>
          </div>
          <!-- </el-scrollbar> -->
          <!-- </el-tab-pane>
        </el-tabs> -->
        </el-form>
        <span slot="footer" class="dialog-footer">
        <el-button @click="dialogEditTaskClose()">取 消</el-button>
        <el-button type="primary" :loading="loading" @click="dialogEditTaskSend">确 定</el-button>
      </span>
      </el-dialog>
         <Scale  ref="loadingPlease":iShow="iShow"  @chngeShow="chngeShow"  />
    </div>
  </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 'vue-photo-preview/dist/skin.css'
  import TaskFile from '@/views/integral/TaskFile';
  import upload_oss from "@/views/upload_oss/upload"
  Vue.use(preview, {
    tapToClose: false
  })
  export default {
    components: {
      TaskFile,
      Scale,
      upload_oss
    },
    data() {
      const editTaskFormRules = {
        name: [
          { required: true, message: '请输入任务名称', trigger: 'blur' },
          { min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur' }
        ],
        expiretime: [
          { required: true, message: '请选择截止时间', trigger: 'blur' }
        ],

      }
      return {
        finally_point: 0,
        newpoint: 0,
        complete_remark: '',
        twoCorde: 0,
        threeCorde: 0,
        fourCorde: 0,
        oneCorde: 0,
        iShow: false,
        one: 0,
        two: 0,
        three: 0,
        four: 0,
        isSwitch: false,
        iSplay: true,
        reveiew: 1, // 是否审核
        review_status_mark:'',
        follow_name:'', // 执行者名称
        isHistory: false, // 判断从历史任务进入
        pageTask: 4,
        totalTask: 15,
        currenTask: 1,
        finshTask: false, // 历史任务弹窗
        finshText:'',
        finshForm: {
          remark: ''
        },
        isActive: false,
        fixed_cycle: [
          {id: 0, type: '从不'},
          { id: 1, type: '每天自动分配' },
          { id: 2, type: '每周自动分配' },
          { id: 3, type: '每月自动分配' }
        ],
        historyData:[], // 历史记录弹框
        lookId:null, // 任务id
        isShow: false, // 是否显示历史记录
        work: '1',
        task_type: 0, // 3：我发布的任务 4：我领取的任务 0：所有任务
          taskTypeA:[
          {name: '普通任务', value: 10},
          {name:'关键任务', value: 20}
        ],
        checkList: 0,
        taskTypeList: [
          { value: 3, label: '我发布的任务' },
          { value: 4, label: '我参与的任务' },
          { value: 0, label: '我全部的任务' }
        ],
        Xtoken: { 'X-Token': getToken() },
        profile: this.$store.getters.user_info,
        filter: {
          finish_status: [],
          keywords: '',
          time_range: [],
          // follow_id: 0,
          // follow_id: 0,
          // creator_id: 0
        },
        pointype: 0,
        point_level: 0, // 等级
        point_level_log:[],
        status_list: [
          // { text: '未领取', value: 0 },
          { text: '未完成', value: 1 },
          { text: '已完成', value: 2 }
        ],
        radio: false,
        page: 1,  // 历史记录请求页数
        limint: 10, // 历史记录请求条数
        type: 0, // 请求类型参数
        taskFinsh: false,
        history:[], // 操作记录表单
        noFinsh:0, // 未完成得任务数
        uploadProof: false,
        employeeOptions: [],
        dialogTaskVisible: false,
        dialogEditTaskVisible: false,
        activeName: 'first',
        dialogTaskTitle: '发布任务',
        totalCount: 0,
        currentPage: 1,
        pageLimit: 10,
        tableData: null,
        dialogCreateCategoryVisible: false,
        dialogEditCategoryVisible: false,
        taskFormApi: '/integral.php/task/add',
        isRequest: false,
        loading: false,
        newArray:[],
        historyId:'',
        pointype:　10,
        taskForm: {
          name: '',
          remark: '',
          expiretime: '',
          point: 0,
          creator_id: 0,
          follow_id:'',
          file_list: []
        },
        review_status_text:'',
        review_status:'',
        complete_remark:'', // 完成任务备注说明
        complete_file_list:'', // 完成任务上传附件
        proof_file_list: [],
        task: '普通任务',
        fixed_cycle: [
          { id: 0, type: '从不' },
          { id: 1, type: '每天自动分配' },
          { id: 2, type: '每周自动分配' },
          { id: 3, type: '每月自动分配' }
        ],
        editTaskForm: {
          fixed_cycle: '',
          task_type: 10,
          name: '',
          remark: '',
          expiretime: '',
          point: 0,
          file_list: [],
          follow_id: '',
        },
        editTaskFormRules: editTaskFormRules,
        taskFormRules: {
          name: [
            { required: true, message: '请输入任务名称', trigger: 'blur' },
            { min: 3, max: 50, message: '长度在 3 到 50 个字符', trigger: 'blur' }
          ],
          expiretime: [
            { required: true, message: '请选择截止时间', trigger: 'blur' }
          ]
        },
        accessEnabled: {
          add: 0,
          delete: 0,
          edit: 0
        },
        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: {
      work(val, old) {

      }
    },
    methods: {
      chngeShow() {
        console.log("jddj")
        this.iShow = false;
        this.getLevel();
        this.getPoint();
      },
      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;
          }
          })
      },
       getPoint() {
         const self = this;
        console.log(this.editTaskForm.point)
        if(this.editTaskForm.point > 0) {
          this.iSplay = false;
       //  this.isSwitch = true;
        }else {
          this.iSplay = true;
         // this.isSwitch = false;
        }

        self.oneCorde = Math.round((self.one/self.three)*self.editTaskForm.point);
        self.twoCorde = Math.round((self.two/self.three)*self.editTaskForm.point);
        self.threeCorde = this.editTaskForm.point;
        self.fourCorde = Math.round((self.four/self.three)*self.editTaskForm.point);

        console.log( (self.threeCorde ))

      },
       chngePoint() {
        console.log(this.isSwitch )
        if(this.editTaskForm.point > 0) {
          this.iSplay = false;
        }else {
          this.iSplay = true;
        }
        console.log(this.pointype !=20 && this.isSwitch )
        if(this.pointype !=20 && this.isSwitch ) {
            this.oneCorde = Math.round((this.one/this.three)*this.editTaskForm.point);
            this.twoCorde = Math.round((this.two/this.three)*this.editTaskForm.point);
            this.threeCorde = this.editTaskForm.point;
            this.fourCorde = Math.round((this.four/this.three)*this.editTaskForm.point);
        }
      },
      // 时间转换
      dateFormatter: function (row, column, cellValue) {
        return this.$moment(cellValue * 1000).format('YYYY-MM-DD HH:mm')
      },
      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++
            }
          }
        }
      },
      // 修改窗口
      dialogEditTaskOpen(id) {
        console.log(id);
        this.dialogEditTaskVisible = true
        this.activeName = 'first'
        this.editTaskForm['id'] = id;
        this.taskTypeA = [
          {name: '普通任务', value: 10},
          {name:'关键任务', value: 20}
        ];
        this.taskFormApi = '/integral.php/task/update'
        this.loadTaskChange(id)
      },
      dialogEditTaskClose() {
        const form = this.$refs['newEditTaskForm']
        form.clearValidate()
        this.dialogEditTaskVisible = false
        this.iSplay = true;
        this.isSwitch = false;
        this.oneCorde = '';
        this.twoCorde = '';
        this.threeCorde = '';
        this.fourCorde = '';
      },
      // 确认修改
      dialogEditTaskSend() {
        const self = this
        // this.editTaskForm.follow_id = this.follow_id;
        console.log(this.follow_id)
        const form = this.$refs['newEditTaskForm'];
        let newArray = [];
        for(var i = 0; i < self.editTaskForm.file_list.length; i ++) {
          if(self.editTaskForm.file_list[i].response != undefined ) {
            newArray.push({});
            newArray[i].name =  self.editTaskForm.file_list[i].name;
            newArray[i].url =  self.editTaskForm.file_list[i].response.url;

          }else {
            if(self.editTaskForm.file_list[i].status != undefined && self.editTaskForm.file_list[i].uid != undefined) {
              delete self.editTaskForm.file_list[i].status;
              delete self.editTaskForm.file_list[i].uid;
            }
            newArray.push(self.editTaskForm.file_list[i]);
          }
        }
         if(this.isSwitch) {
          self.editTaskForm.point_type = 20;
          self.editTaskForm.point_level_log = [{key:10,value:this.oneCorde},{key:20,value:this.twoCorde},{key:30,value: self.editTaskForm.point},{key:40,value: this.fourCorde}]
        }else {
          self.editTaskForm.point_type = 10;
          self.editTaskForm.point_level_log = [];
        }
        this.editTaskForm.file_list = newArray;
        form.validate(valid => {
          if (valid) {

            this.loading = true
            this.$http('post',self.taskFormApi,qs.stringify({ row: this.editTaskForm }),
              // 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.$message({
                      message: message,
                      type: 'success'
                    })
                    self.dialogEditTaskClose()
                    self.loadTaskList()
                  } else {
                    self.$message({
                      message: message,
                      type: 'error'
                    })
                  }
                } else {
                  message = '服务器太忙了'
                }
              })
              .catch(function(error) {
                console.log(error)
              })
          } else {
            return false
          }
        })
      },
      onFileRemove(file, fileList) {
        console.log(file);
        console.log(fileList);
        console.log(this.uploadProof);
        if (this.uploadProof) { // 上传凭证图片
          this.proof_file_list = fileList
        } else {
          this.editTaskForm.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
        }

      },
      handleFilesSuccess(response, file, fileList) {

        if (this.uploadProof) { // 查看任务详情上传图片
          this.proof_file_list = fileList
        } else { // 编辑任务弹窗详情
          this.taskForm.file_list = fileList
          this.editTaskForm.file_list = fileList;
        }
      },
      // 获取员工id
      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)
          })
      },
      openUrl(url) {
          window.open(url)
      },
      onFilePreView(file) {
        // 点击时查看文件
        const $ext_list = ['doc', 'docx', 'pptx', 'xls', 'xlsx', 'ppt', 'txt', 'pdf', 'zip', 'rar']
        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
          // )
          if ($ext_name == 'txt' || $ext_name == 'pdf') {
            window.open(this.serverdomain + file.url)
          } else {
            window.open(
              'https://view.officeapps.live.com/op/view.aspx?src=' +
              this.serverdomain +
              file.response.url,
              '_blank'
            )
          }
          // window.open('https://view.officeapps.live.com/op/view.aspx?src='+this.serverdomain+file.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) {
          let ii = 0
          if (this.dialogTaskVisible == true) { // 查看任务详情
            for (const i in this.proof_file_list) {
              if (
                 ['jpg', 'png', 'bmp', 'jpeg','JPG','PNG'].indexOf(
                  this.proof_file_list[i].name.split('.')[1]
                ) >= 0
              ) {
                if (this.proof_file_list[i].name == file.name) {
                  this.openPhotoSwipe(
                    ii,
                    document.querySelectorAll(`img[preview='${file.uid}']`)
                  )
                  return
                }
                ii++
              }
            }
          } else {
            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) {
                  // console.log(ii)
                  this.openPhotoSwipe(
                    ii,
                    document.querySelectorAll('img[preview="' + file.uid + '"]')
                  )

                  return
                }
                ii++
              }
            }
          }
        }
      },
      handleRemove(file, fileList) {
        console.log(file, fileList)
      },

      handleSizeChange(val) {
        window.scrollTo(0,0);
        this.pageLimit = val
        this.onFilterChanged()
      },
      filterHandler: function(value) {
        const filter = []
        for (const item in value) {
          filter.push(value[item])
        }
        console.log(filter[0])
        this.filter.status = filter[0]
        this.onFilterChanged()
      },

      dialogTaskClose: function() {
        const form = this.$refs['newTaskForm']
        form.clearValidate()

      },
      CloseTask() {
        this.taskFinsh = false;
        this.currenTask = 1;
        let id = this.historyId;
        this.isHistory = false;
        this.loadTaskInfo(id);
      },
      // 显示为完成任务
      showFinsh() {
        const self = this;
        console.log(this.radio);
        if(this.radio) {
          self.type = 1;

        }else {
          self.type = 0;

        }
        self.lookFinsh();

      },
      // 显示历史任务列表
      lookFinsh() {
        console.log("jinlaillios")
        const self = this;
        // this.dialogTaskVisible = false;
        this.taskFinsh = true;
        let id = self.historyId;
        console.log(id);
        console.log("udhfodsueh");
        this.$http('get','/integral.php/task/get_task_history',{page: self.currenTask,size: self.pageTask,type: self.type,task_id: id,})
          .then(function(res) {
            if (res.status == 200) {
              self.historyData = res.data.data;
              self.totalTask = res.data.total;
              console.log(self.totalTask);
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },
      dialogTaskOpen: function(id, cycle, history) {
        // 大于0从历史任务进来
        if(history > 0) {
          this.isHistory = true;

        } else {
          this.isHistory = false;
          this.historyId = id;
        }
        console.log( this.isHistory + "查看history");
        this.lookId = id;
        // 判断为每周每天每月任务得时候才显示历史任务
        let fixed = cycle;
        const self = this
        this.dialogTaskTitle =
          typeof id === 'undefined' ? '发布任务' : '修改任务'
        this.dialogTaskVisible = true  // 任务详情窗口

        this.taskFinsh = false;  //  历史完成任务窗口
        if (typeof id !== 'undefined') {
          this.taskForm['id'] = id
          self.taskFormApi = '/integral.php/task/update'
          console.log('更换更新接口')
          this.loadTaskInfo(id)
        } else {
          this.taskForm = {
            name: '',
            remark: '',
            expiretime: '',
            point: 0
          }
          self.taskFormApi = '/integral.php/task/add'
          console.log('更换增加数据接口')
        }
        this.$nextTick(() => {
          const form = this.$refs['newTaskForm']
          if (typeof id === 'undefined') {
            form.resetFields()
            form.clearValidate()
          }
        })
      },
      // 修改详情
      loadTaskChange: 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.data
              console.log(jsonData);
              // self.taskInfo = jsonData.data
              jsonData.expiretime = self.dateTimeFormatter(
                '',
                '',
                jsonData.expiretime
              )
              self.noFinsh =  response.data.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
              self.pointype = jsonData.point_type;
              self.review_status = jsonData.review_status;
              self.review_status_text = jsonData.review_status_text;
              self.editTaskForm.task_type =  jsonData.task_type;
              self.taskTypeA = [
                {name: '普通任务', value: 10},
                {name:'关键任务', value: 20}
                ]
              console.log(self.pointype == 10);
              if(self.pointype == 10) {

                self.isSwitch = false;

              }else {
                console.log("2345")
                self.isSwitch = true;
              }
              self.point_level = jsonData.point_level
              console.log(jsonData.point_level_log);
              // if(jsonData.point_level_log != null ||　jsonData.point_level_log !=  undefined) {
              //   console.log("jinlaol")
                self.point_level_log = jsonData.point_level_log;
              //   console.log( self.point_level_log );
              // }

              self.editTaskForm.point = jsonData.point
               if( jsonData.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;
                 }
               })
              }
              console.log(jsonData.point_level_log)

              if(jsonData.point>0) {
                self.iSplay = false;
              }
              // if (jsonData.follow_id > 0) {
                console.log("进来了")
                self.editTaskForm.follow_id =jsonData.follow_id
                self.$set(self.editTaskForm, 'follow_id', jsonData.follow_id)
                console.log( self.editTaskForm.follow_id )
              // }
              if (jsonData.fixed_cycle >= 0) {
                self.editTaskForm.fixed_cycle = jsonData.fixed_cycle
                console.log( self.editTaskForm.fixed_cycle);
                console.log("lkjdfasd");
              }
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },

      // 查看详情
      loadTaskInfo: function(id) {
        const self = this

        this.$http('get','/integral.php/task/getTaskLog',{task_id: id})
          .then(function(response) {
            if (response.status == 200) {
              var jsonData = response.data.data.task;
              self.follow_name = jsonData.follow_name;
              self.history = response.data.data.history;
              self.noFinsh =  response.data.data.not_finish;
              self.review_status = jsonData.review_status;
              self.review_status_text = jsonData.review_status_text;
              let fixed = response.data.data.history_finish;
              // console.log(jsonData.point_level )
              //  if(jsonData.point_level_log != null ||　jsonData.point_level_log !=  undefined) {
                self.point_level_log = jsonData.point_level_log;
              // }

              self.point_level = jsonData.point_level;
              self.complete_remark = jsonData.complete_remark;
              console.log(self.point_level==20&&self.reveiew == 1)
              self.reveiew =jsonData.review_status;
              self.review_status_mark  = jsonData.review_status_text; // 审核
              console.log(jsonData.review_status)
              console.log( jsonData.review_status_mark);
              if(self.reveiew== 1 &&　　jsonData.review_status_text=="已通过") {
               console.log("jinlial")
               self.newpoint = 　　jsonData.finally_point;

             }
              self.pointype = jsonData.point_type;
              console.log(fixed);
              if(fixed > 0) {
                self.isShow = true;
              }else {
                self.isShow = false;
              }
              console.log(self.isShow)

              if(jsonData.status == 2) {
                self.complete_remark = jsonData.complete_remark;
                self.complete_file_list = jsonData.complete_file_list;

              }
              console.log(  self.complete_remark );

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




              if (self.dialogEditTaskVisible) {
                self.editTaskForm.file_list = jsonData.file_list;
                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.file_list = jsonData.file_list;
                self.taskForm.name = jsonData.name
                self.taskForm.fixed_cycle = jsonData.fixed_cycle
                self.taskForm.id = jsonData.id
                self.taskForm.status = jsonData.status
                self.taskForm.expiretime = jsonData.expiretime
                self.taskForm.point = jsonData.point
                self.taskForm.file_list = jsonData.file_list
                self.taskForm.remark = jsonData.remark
                if (jsonData.follow_id > 0) {
                  self.taskForm.follow_id =jsonData.follow_id
                  console.log( self.taskForm.follow_id )
                }
                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)
          })
      },
      CloseHistory() {

        if(this.isHistory == true) {

          //this.dialogTaskVisible= true;
          this.lookFinsh();
        }else {

          this.dialogTaskVisible= false;
        }
      },
      taskCompleteConfirm() {
        // this.$confirm('是否需要上传凭证?', '提示', {
        //   confirmButtonText: '上传凭证',
        //   cancelButtonText: '继续完成',
        //   showClose: false
        // }).then(() => {
        this.uploadProof = true
        this.dialogTaskVisible = true
        this.finshTask = true;
        // })
        //   .catch(() => {

        //   })
      },
      // 确认完成任务弹窗
      dialogTaskComplete: function() {
        const self = this
        this.loading = true
        if (self.isRequest) {
          return
        }
        const form = this.$refs['newTaskForm']
        // const params = {}
        // params.id = this.taskForm.id
        // params.file_list = this.proof_file_list
        let newArray = [];
        for(var i = 0; i < self.proof_file_list.length; i ++) {
          if(self.proof_file_list[i].response != undefined ) {
            newArray.push({});
            newArray[i].name =  self.proof_file_list[i].name;
            newArray[i].response =  self.proof_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.proof_file_list[i].status != undefined && self.proof_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]);
          }
        }

        form.validate(valid => {
          if (valid) {
            this.$http('post','/integral.php/task/complete',qs.stringify({ id: this.lookId, file_list: newArray, remark: self.finshForm.remark }),
              // headers: {
              //   'Content-Type': 'application/x-www-form-urlencoded'
              // }
            )
              .then(function(response) {
                self.loading = false
                setTimeout(function() {
                  self.isRequest = false
                  self.uploadProof = false // 重置上传凭证标志位
                  self.proof_file_list = [] // 重置上传凭证文件
                }, 200)

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

                  message = data.msg

                  if (data.code == 1) {
                    self.$message({
                      message: message,
                      type: 'success'
                    })
                    //self.dialogTaskVisible = false;  // 任务详情弹窗关闭
                    self.finshTask = false;  // 完成任务弹窗关闭
                    // if(self.isHistory) {
                    //   // 历史任务进来
                    //   self.dialogTaskVisible = false;
                    //   self.taskFinsh = true;
                    //   self.lookFinsh();
                    // }else {

                    // }
                    self.loadTaskList();
                    self.loadTaskInfo(self.lookId);
                    self.finshForm.remark = '';
                    // self.dialogTaskClose()
                    //self.loadTaskList()
                  } else {
                    self.$message({
                      message: message,
                      type: 'error'
                    })
                  }
                } else {
                  message = '服务器太忙了'
                }
              })
              .catch(function(error) {
                console.log(error)
              })
          } else {
            return false
          }
        })
      },
      checkListValue: function() {
        console.log("触发")
        this.task_type = this.checkList;
        this.loadTaskList();
      },
      onFilterChanged: function() {
        this.currentPage = 1;
        this.loadTaskList()
      },
      dateTimeFormatter: function(row, column, cellValue, fixed_cycle) {
        // if (cellValue == 0) {
        //   switch (fixed_cycle) {
        //     case 1:
        //       return '每天任务'
        //     case 2:
        //       return '每周任务'
        //     case 3:
        //       return '每月任务'
        //   }
        // }
        // return cellValue
        //   ? this.$moment(cellValue * 1000).format('YYYY-MM-DD HH:mm:ss')
        //   : ''
        return  this.$moment(cellValue * 1000).format('YYYY-MM-DD HH:mm:ss');
      },
      taskStatusText: function(row, column, cellValue) {
        let text = ''
        switch (cellValue) {
          case 0:
            text = '未领取'
            break
          case 1:
            text = '已领取'
            return text
          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() {
        const self = this;
        if(this.profile.manager_type > 0) {

        }else {
          this.task_type = 4;
        }
        var params = {
          page: this.currentPage,
          size: this.pageLimit,
          task_type: self.task_type,
        }
        for (const item in this.filter) {
          const value = this.filter[item]
          console.log(item);
          console.log(item.length);
          console.log(self.status_list.length);
          if (item == 'status') {
            if(value.length!= self.status_list.length) {
              params.finish_status = value[0]
            }else {
              params.finish_status = 0
            }
          }else if(item == 'time_range') {
            if (!value || value.length < 2) {
              continue
            }
            const timeRangeArr = value.map(x => parseInt(x / 1000))
            timeRangeArr[1] += 60 * 60 * 24 - 1
            params[item] = timeRangeArr.join(',')

          } else {
            if (value != null) {
              const valueStr = value.toString()
              if (valueStr && valueStr.length > 0) {
                params[item] = valueStr
              }
            }
          }
        }

        console.log(params);
        // if (self.task_type == 3) {
        //   // 我发布的任务
        //   params['creator_id'] = self.$store.getters.user_info.id
        //   params['follow_id'] = 0
        // }
        // if (self.task_type == 4) {
        //   // 我领取的任务
        //   params['follow_id'] = self.$store.getters.user_info.id
        //   params['creator_id'] = 0
        // }

        this.$http('get','/integral.php/task/new_my_task_list',params)
          .then(function(response) {
            if (response.status == 200) {
              self.loading = false
              var jsonData = response.data
              try {
                self.totalCount = jsonData.total
                console.log(jsonData);
                self.tableData = jsonData.list
                //  self.filter = [];
                console.log(self.tableData);
              } catch (err) {
                console.log(err)
              }
            }
          })
          .catch(function(error) {
            console.log(error)
          })
      },
      changePage: function(current) {
        if (isNaN(current) || current < 1) {
          return false
        }
        this.loadTaskList()
      },
      changePageTask(val) {
        self.currenTask = val;
        this.lookFinsh()
      },
      handleChangeTask(val) {
        this.pageTask = val
        this.lookFinsh()
      },
      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
          }
        })
      },
      // 撤销完成
      TaskCancel(taskId) {
        const self = this
        this.$confirm('确定要撤消完成状态吗？', '请确认', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.$http('get','/integral.php/task/cancel',{ id: taskId },
              // headers: {
              //   'Content-Type': 'application/x-www-form-urlencoded'
              // }
            )
              .then(function(response) {
                if (response.status == 200) {
                  var data = response.data
                  const message = data.msg
                  if (data.code == 1) {
                    self.$message({
                      message: message,
                      type: 'success'
                    })
                    //self.dialogTaskVisible = false
                    self.loadTaskList()
                    //self.loadTaskInfo(taskId)
                    self.loadTaskInfo(self.lookId);
                  } else {
                    self.$message({
                      message: message,
                      type: 'error'
                    })
                  }
                } else {

                }
              })
              .catch(function(error) {
                console.log(error)
              })
          })
          .catch(() => {})
      },
      TaskRelease(taskId) {
        const self = this
        this.$confirm('确定要释放这个任务吗？', '请确认', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.$http('get','/integral.php/task/release',{ id: taskId },
              // headers: {
              //   'Content-Type': 'application/x-www-form-urlencoded'
              // }
            )
              .then(function(response) {
                if (response.status == 200) {
                  var data = response.data
                  const message = data.msg
                  if (data.code == 1) {
                    self.$message({
                      message: message,
                      type: 'success'
                    })
                    self.dialogTaskVisible = false
                    self.loadTaskList()
                    self.loadTaskInfo(taskId)
                  } else {
                    self.$message({
                      message: message,
                      type: 'error'
                    })
                  }
                } else {
                }
              })
              .catch(function(error) {
                console.log(error)
              })
          })
          .catch(() => {})
      },
      //删除任务
      confirmDelete: function(taskId) {
        this.$confirm('任务删除后不可恢复，确认要删除？', '删除任务', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        })
          .then(() => {
            this.deleteTask(taskId)
          })
          .catch(() => {})
      },
      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)
          })
      }
    },
    filters: {
      dateTimeFormatter: function(cellValue) {
        // console.log(cellValue)
        return cellValue
          ? this.$moment(cellValue * 1000).format('MM-DD HH:mm')
          : ''
      }
    },
    created() {
      this.getLevel();
      this.loadTaskList()
      this.loadWidgetData()
      console.log(this.profile.manager_type + "测试测试");
      if(this.profile.manager_type > 0) {

      }else {
        console.log("jinlail")
        this.task_type = 4;
      }
      if (this.profile.manager_type == 4) {
        this.accessEnabled = {
          add: 1,
          delete: 1,
          excel_import: 1,
          edit: 1
        }
      } else if (this.profile.manager_type > 1) {
      }
    }
  }
</script>
<style lang="scss" scoped>


  .inline-block-btn-list {
    padding-top: 26px;
    margin-top: 0px!important;
  }
  .task-file-upload .el-upload--picture-card {
    background-color: #fbfdff;
    border: 1px dashed #c0ccda;
    border-radius: 6px;
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
    width: 91px;
    height: 91px;
    line-height: 91px;
    vertical-align: top;
  }
  .file-list-mine .el-upload.el-upload--text {
    display: none;
  }
  .pswp--supports-fs.pswp--open {
    z-index: 3000;
  }
  .taskMine .taskType .el-input__inner{
    background-color: #409eff;
    border: #409eff;
    color: #fff;
  }
  .exactly .el-form-item {
    margin-bottom: 0!important;
  }
  /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 20px 0 45px;

  }
  /deep/ .historyClass .el-dialog__footer {
    position: absolute;
    bottom: -5px;
    left: 238px;
  }
  .active {
    background:#26A2FF;
    border: none!important;
  }

  /deep/  .el-form-item .el-form-item__content .el-textarea {
    display: inline-block;
    width: 269px!important;
    height: 118px;
  }
  /deep/ .el-form-item  .el-form-item__content .el-textarea__inner {
    height: 118px;
  }
  /deep/ .finshTask .el-form-item__label {
    font-weight: normal;
  }
  /deep/ .finshTask .el-dialog__footer {
    padding-top: 150px;
  }
  /deep/ .finshTask .el-dialog__header {
    padding: 30px 0 0 35px;
    color: #303133;
    font-size: 17px;
  }
  /deep/ .finshTask.el-dialog__body {
    padding: 30px;
  }
  /deep/ .el-checkbox .el-checkbox__inner {
    border-radius: 50%;
  }
  /deep/ .changeTask .el-dialog__body {
    padding: 25px 10px;
  }
  /deep/ .changeTask .el-dialog__header{
    padding: 38px 20px 0 40px;
  }
  /deep/ .changeTask .el-form-item__label {
    font-weight: normal;
  }
  /deep/ .el-dialog__headerbtn {
    display: none;
  }
  .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;
  }
  .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;
  }
  .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;
}
.el-scrollbar__wrap{overflow-x:hidden;}
/deep/ .el-scrollbar__bar .el-scrollbar__thumb {
  display: none;
}
</style>
