<template>
  <div class="app-container calendar-list-container">
    <el-form label-position="right" label-width="100px"  style='width:100%;'>
          <el-row :gutter="24" >
          <el-col :xs="23" :sm="23" :md="12" :lg="6" :xl="6" >
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.serviceid')" >
                <div class="block">
                  <el-input v-model="seachQuery.salt" style="width:100%;"> </el-input>
                </div>
              </el-form-item>
            </div>
          </el-col>
            <el-col :xs="23" :sm="23" :md="11" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.truename')" >
                <div class="block">
                  <el-input v-model="seachQuery.truename"  style="width:100%;"> </el-input>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :xs="23" :sm="23" :md="12" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.constellation')"  >
                <div class="block">
                  <el-select v-model="seachQuery.constellationlist" multiple collapse-tags style="width: 100%;" >
                  <el-option v-for="item in constellationoptions" :key="item.id" :label="item.name" :value="item.id" >
                  </el-option>
                </el-select>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :xs="23" :sm="23" :md="11" :lg="5" :xl="5">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.zodiac')"  >
                <div class="block">
                  <el-select v-model="seachQuery.zodiaclist" multiple collapse-tags style="width: 100%;" >
                  <el-option v-for="item in zodiacoptions" :key="item.id" :label="item.name" :value="item.id" >
                  </el-option>
                </el-select>
                </div>
              </el-form-item>
            </div>
          </el-col>
        </el-row>

        <el-row :gutter="24" >
          <el-col :xs="23" :sm="23" :md="12" :lg="6" :xl="6" >
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.np')" >
                <div class="block">
                  <el-select v-model="seachQuery.nplist"  multiple collapse-tags style="width: 100%;" >
                  <el-option v-for="item in provinceoptions" :key="item.code" :label="item.name" :value="item.code" >
                  </el-option>
                </el-select>
                </div>
              </el-form-item>
            </div>
          </el-col>
            <el-col :xs="23" :sm="23" :md="11" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.cityname')" >
                <div class="block">
                  <el-select v-if="mktEnable" disabled class="filter-item" v-model="seachQuery.cityname" placeholder="请选择城市" style="width: 100%;">
                    <el-option v-for="item in branchesOptions" :key="item.branche_code" :label="item.branche_name" :value="item.branche_code">
                    </el-option>
                  </el-select>
                  <el-select v-else class="filter-item" v-model="seachQuery.cityname" placeholder="请选择城市" style="width: 100%;">
                    <el-option v-for="item in branchesOptions" :key="item.branche_code" :label="item.branche_name" :value="item.branche_code">
                    </el-option>
                  </el-select>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :xs="23" :sm="23" :md="12" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.experience')"  >
                <div class="block">
                  <el-input-number style="width: 94px;" v-model="seachQuery.experiencestart" controls-position="right" :max="99"></el-input-number>
                  <el-input-number style="width: 94px;" v-model="seachQuery.experienceend" controls-position="right" :max="99"></el-input-number>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :xs="23" :sm="23" :md="11" :lg="5" :xl="5">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.gender')"  >
                <div class="block">
                  <el-select v-model="seachQuery.gender" style="width: 100%;" >
                    <el-option v-for="item in genderOptions" :key="item.value" :label="item.label" :value="item.value" >
                    </el-option>
                  </el-select>
                </div>
              </el-form-item>
            </div>
          </el-col>
        </el-row>

        <el-row :gutter="24" >
          <el-col :xs="23" :sm="23" :md="12" :lg="6" :xl="6" >
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.education')" >
                <div class="block">
                  <el-select v-model="seachQuery.educationlist" multiple collapse-tags style="width: 100%;" >
                    <el-option v-for="item in educationOptions" :key="item.value" :label="item.label" :value="item.value" >
                    </el-option>
                  </el-select>
                </div>
              </el-form-item>
            </div>
          </el-col>
            <el-col :xs="23" :sm="23" :md="11" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.age')" >
                <div class="block">
                  <el-input-number style="width: 94px;" v-model="seachQuery.agestart" controls-position="right" :max="99"></el-input-number>
                  <el-input-number style="width: 94px;" v-model="seachQuery.ageend" controls-position="right" :max="99"></el-input-number>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :xs="23" :sm="23" :md="12" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.highlight')"  >
                <div class="block">
                  <el-input style="width: 100%;" class="filter-item" v-model="seachQuery.highlight" :maxlength = 10></el-input>
                </div>
              </el-form-item>
            </div>
          </el-col>

          <el-col :xs="23" :sm="23" :md="11" :lg="5" :xl="5">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.characters')"  >
                <div class="block">
                  <el-select v-model="seachQuery.characters" collapse-tags style="width: 100%;" >
                    <el-option v-for="item in charactersOptions" :key="item.value" :label="item.label" :value="item.value" >
                    </el-option>
                  </el-select>
                </div>
              </el-form-item>
            </div>
          </el-col>
        </el-row>
    <el-row :gutter="24" >
          <el-col :xs="23" :sm="23" :md="12" :lg="6" :xl="6" >
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.status')" >
                <div class="block">
                  <el-select v-model="seachQuery.status" style="width: 100%;" >
                    <el-option v-for="item in statusOptions" :key="item.value" :label="item.label" :value="item.value" >
                    </el-option>
                  </el-select>
                </div>
              </el-form-item>
            </div>
          </el-col>
            <el-col :xs="23" :sm="23" :md="11" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.service_start')" >
                <div class="block">
                    <el-date-picker v-model="seachQuery.service_start" value-format="yyyy-MM-dd" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions1" style="width: 100%;">
                    </el-date-picker>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :xs="23" :sm="23" :md="12" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.service_days')"  >
                <div class="block">
                  <el-input-number v-model="seachQuery.days" controls-position="right" :max="99" style="width:100%;"></el-input-number>
                </div>
              </el-form-item>
            </div>
          </el-col>
          <el-col :xs="23" :sm="23" :md="11" :lg="5" :xl="5">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('querylist.babynumber')"  >
                <div class="block">
                  <el-input-number v-model="seachQuery.babynumber" controls-position="right" :max="9999" style="width:100%;"></el-input-number>
                </div>
              </el-form-item>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20" style="margin-bottom:22px;">
          <el-col :xs="23" :sm="23" :md="23" :lg="23" :xl="23">
          <div  align="center" > 
            <el-button :loading ="buttonloading" class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleFilterfirst">
          {{$t('table.search')}}
        </el-button>
        <el-button class="filter-item" type="primary" v-waves  icon="el-icon-delete" @click="handleref">
          {{$t('table.cancel')}}
        </el-button></div>
          </el-col>
      </el-row>
  </el-form>
    <el-table :key='tableKey' :data="list" v-loading="listLoading" element-loading-text="加载中......" border fit
              highlight-current-row
              style="width: 100%">
      <el-table-column align="center" :label="$t('table.id')">
        <template slot-scope="scope">
          <a href="#" @click="infoshow(scope.row.id)"><span style="color:#409EFF">{{scope.row.salt}}</span></a>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('table.truename')">
        <template slot-scope="scope">
          <span>{{scope.row.truename}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('table.age')">
        <template slot-scope="scope">
          <span>{{scope.row.age}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('table.cityname')">
        <template slot-scope="scope">
          <span>{{scope.row.cityname}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('table.status')">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.status == '1' " type="success">{{$t('table.status1')}}</el-tag>
          <el-tag v-else-if="scope.row.status == '2' " >{{$t('table.status2')}}</el-tag>
          <el-tag v-else-if="scope.row.status == '3' " type="warning">{{$t('table.status3')}}</el-tag>
          <el-tag v-else-if="scope.row.status == '4' " type="danger">{{$t('table.status4')}}</el-tag>
          <el-tag v-else type="info">{{$t('table.status5')}}</el-tag>
        </template>
      </el-table-column> 
      <el-table-column align="center" :label="$t('table.np')">
        <template slot-scope="scope">
          <span>{{scope.row.np}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('querylist.experience')">
        <template slot-scope="scope">
          <span>{{scope.row.seniority}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('querylist.gender')">
        <template slot-scope="scope">
          <span>{{scope.row.gender}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('querylist.ethnicgroup')">
        <template slot-scope="scope">
          <span>{{scope.row.ethnicgroup}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('querylist.constellation')">
        <template slot-scope="scope">
          <span>{{scope.row.constellation}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('querylist.zodiac')">
        <template slot-scope="scope">
          <span>{{scope.row.zodiac}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('querylist.babynumber')">
        <template slot-scope="scope">
          <span>{{scope.row.babynumber}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" :label="$t('table.actions')" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <a v-if="scope.row.resume_path === '0' " href="#" @click="resumeEdity(scope.row.id)"><el-tag>编辑简历</el-tag></a>
          <a v-else  href="#" @click="handleCreate(scope.row)"><el-tag type="success">查看简历</el-tag></a>
        </template>
      </el-table-column>
    </el-table>
    <div class="pagination-container">
      <!-- <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                    :current-page="page" :page-sizes="[10,20,30, 50]" :page-size="limit"
                    layout="total, sizes, prev, pager, next, jumper" :total="total">
      </el-pagination> -->
      <el-pagination
            small
            layout="prev, pager, next"
            @size-change="handleSizeChange" @current-change="handleCurrentChange"
            :total="total"
            :page-size="limit"
            :current-page="page">
          </el-pagination>
    </div>
      <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :before-close="handleClose">
      <el-form :rules="rules" ref="addForm" :model="addresumeinfo" label-position="left" label-width="80px"
              style='width: 600px;margin-left:20px'>
      <el-row :gutter="16" style="margin-bottom: 15px;">
        <el-col :span="14">
          <div class="grid-content bg-purple">
            <el-form-item  :label="$t('order.cmphone')" prop="cm_phone">
              <el-input v-model="addresumeinfo.cm_phone" style="width: 220px;" ></el-input>
              <el-input v-model="addresumeinfo.resume_link" type='hidden' style="width: 220px;" ></el-input>
              <el-input v-model="addresumeinfo.id" type='hidden' style="width: 220px;" ></el-input>
            </el-form-item>
          </div>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple" style="width: 300px;">
            <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="resumeShow(addresumeinfo.resume_link)">
              {{$t('table.resumeSelect')}}
            </el-button>
          </div>
        </el-col>
      </el-row> 
      </el-form>
    </el-dialog>
    <el-dialog title="Reading statistics" :visible.sync="dialogPvVisible">
      <el-table :data="pvData" border fit highlight-current-row style="width: 100%">
        <el-table-column prop="key" label="Channel"></el-table-column>
        <el-table-column prop="pv" label="Pv"></el-table-column>
      </el-table>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="dialogPvVisible = false">{{$t('table.confirm')}}</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
  import { queryServiceUserStockCondition, fetchPv, updateArticle, getBranches, getEthnicGroup, getProvince, getZodiac, getConstellation, insertJlServiceUserLog } from '@/api/article'// seachList,
  import waves from '@/directive/waves' // 水波纹指令
  import { parseTime } from '@/utils'
  import regex from '@/utils/regex'
  export default {
    name: 'mmquerystock-form',
    directives: {
      waves
    },
    data() {
      return {
        userMkt: null,
        mktEnable: null,
        tableKey: 0,
        list: null,
        total: null,
        page: 1,
        limit: 10,
        queryType: 'list',
        buttonloading: false,
        listLoading: true,
        listQuery: {
          cityname: null,
          page: 1,
          limit: 10
        },
        queryResume: {
          id: undefined
        },
        checkdate: {
          servant_code: undefined,
          stock_status: undefined,
          start_date: undefined,
          end_date: undefined
        },
        lockForm: {
          id: undefined,
          user: undefined
        },
        addresumeinfo: {
          cm_phone: undefined,
          resume_link: undefined,
          id: undefined
        },
        logJlServiceUser: {
          js_sucode: undefined,
          jl_usercode: undefined,
          jl_date: undefined,
          jl_logtype: undefined,
          jl_cmphone: undefined
        },
        seachQuery: {
          id: null,
          salt: null,
          truename: null,
          constellation: null,
          constellationlist: [],
          zodiaclist: [],
          educationlist: [],
          nplist: [],
          zodiac: null,
          np: null,
          cityname: null,
          experiencestart: null,
          experienceend: null,
          gender: null,
          status: null,
          service_start: null,
          service_end: null,
          babynumber: null, // add↓
          ethnicgroup: null,
          education: null,
          height: null,
          marriage: null,
          highlight: null,
          weight: null,
          agestart: null,
          ageend: null,
          days: null,
          characters: null,
          page: 1,
          limit: 10
        },
        pickerOptions1: {
          shortcuts: [{
            text: '今天',
            onClick(picker) {
              picker.$emit('pick', new Date())
            }
          }, {
            text: '昨天',
            onClick(picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24)
              picker.$emit('pick', date)
            }
          }, {
            text: '一周前',
            onClick(picker) {
              const date = new Date()
              date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
              picker.$emit('pick', date)
            }
          }]
        },
        branchesOptions: [],
        statusOptions: [{ label: '正常', value: '1' }, { label: '封存', value: '4' }],
        sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
        educationOptions: [{ value: '1', label: '初中' }, { value: '2', label: '高中' }, { value: '3', label: '大专' }, { value: '4', label: '大本' }, { value: '5', label: '硕士' }, { value: '6', label: '中专' }],
        marriageOptions: [{ value: 'y', label: '已婚' }, { value: 'n', label: '未婚' }],
        charactersOptions: [{ value: 1, label: '话少，踏实型' }, { value: 2, label: '有主见，能干型' }, { value: 3, label: '开朗乐观型' }],
        genderOptions: [{ label: 1, value: 1 }, { label: 2, value: 2 }, { label: 3, value: 3 }, { label: 5, value: 5 }],
        constellationoptions: [],
        zodiacoptions: [],
        ethnicgroupptions: [],
        provinceoptions: [],
        showReviewer: false,
        dialogFormVisible: false,
        dialogStatus: '',
        textMap: {
          update: 'Edit',
          create: '添加月嫂'
        },
        dialogPvVisible: false,
        pvData: [],
        rules: {
          type: [{ required: true, message: 'type is required', trigger: 'change' }],
          timestamp: [{ type: 'date', required: true, message: 'timestamp is required', trigger: 'change' }],
          title: [{ required: true, message: '请正确录入信息', trigger: 'blur' }],
          cm_phone: [{ required: true, message: '请输入手机号码', trigger: 'blur' },
            { pattern: regex.REPHONE, message: '手机号格式错误', trigger: 'blur' }]
        },
        downloadLoading: false
      }
    },
    filters: {
      statusFilter(status) {
        const statusMap = {
          published: 'success',
          draft: 'info',
          deleted: 'danger'
        }
        return statusMap[status]
      }
    },
    created() {
      this.seachQuery.status = '1'
      this.userMkt = this.$store.getters.mkt
      if (this.userMkt !== 'ALL') {
        this.seachQuery.cityname = this.userMkt
        this.listQuery.cityname = this.userMkt
        this.mktEnable = true
      }
      this.list = []
      this.listLoading = false
      getConstellation().then(response3 => {
        this.constellationoptions = response3.data
      })
      getZodiac().then(response4 => {
        this.zodiacoptions = response4.data
      })
      getEthnicGroup().then(response5 => {
        this.ethnicgroupptions = response5.data
      })
      getProvince().then(response6 => {
        this.provinceoptions = response6.data
      })
      getBranches().then(response7 => {
        this.branchesOptions = response7.data
      })
      this.getList()
    },
    methods: {
      getList() {
        this.listQuery.page = this.page
        this.listQuery.limit = this.limit
        this.listQuery.status = 1
        this.queryType = 'list'
        this.listLoading = true
        queryServiceUserStockCondition(this.listQuery).then(response => {
          this.list = response.data.items
          this.total = response.data.total
          this.listLoading = false
        })
      },
      handleFilter() {
        this.seachQuery.page = this.page
        this.seachQuery.limit = this.limit
        if (this.seachQuery.nplist.length > 0) {
          var npstr = ''
          for (var inp = 0, ln = this.seachQuery.nplist.length; inp < ln; inp++) {
            npstr = npstr + this.seachQuery.nplist[inp] + ','
          }
          this.seachQuery.np = npstr
        }
        if (this.seachQuery.educationlist.length > 0) {
          var educationstr = ''
          for (var ie = 0, le = this.seachQuery.educationlist.length; ie < le; ie++) {
            educationstr = educationstr + this.seachQuery.educationlist[ie] + ','
          }
          this.seachQuery.education = educationstr
        }
        if (this.seachQuery.zodiaclist.length > 0) {
          var zodiacstr = ''
          for (var iz = 0, lz = this.seachQuery.zodiaclist.length; iz < lz; iz++) {
            zodiacstr = zodiacstr + this.seachQuery.zodiaclist[iz] + ','
          }
          this.seachQuery.zodiac = zodiacstr
        }
        if (this.seachQuery.constellationlist.length > 0) {
          var constellationstr = ''
          for (var ic = 0, lc = this.seachQuery.constellationlist.length; ic < lc; ic++) {
            constellationstr = constellationstr + this.seachQuery.constellationlist[ic] + ','
          }
          this.seachQuery.constellation = constellationstr
        }
        if (this.seachQuery.height === 0) {
          this.seachQuery.height = null
        }
        if (this.seachQuery.experiencestart === 0) {
          this.seachQuery.experiencestart = null
        }
        if (this.seachQuery.experienceend === 0) {
          this.seachQuery.experienceend = null
        }
        if (this.seachQuery.weight === 0) {
          this.seachQuery.weight = null
        }
        if (this.seachQuery.babynumber === 0) {
          this.seachQuery.babynumber = null
        }
        if (this.seachQuery.agestart === 0) {
          this.seachQuery.agestart = null
        }
        if (this.seachQuery.ageend === 0) {
          this.seachQuery.ageend = null
        }
        if (this.seachQuery.service_end === 0) {
          this.seachQuery.service_end = null
        }
        this.queryType = 'query'
        const age1 = Number(this.seachQuery.agestart)
        const age2 = Number(this.seachQuery.ageend)
        const diffAge = age2 - age1
        if (diffAge < 0) {
          this.$message.error('请正确输入年龄段')
        } else {
          this.listLoading = true
          this.buttonloading = true
          queryServiceUserStockCondition(this.seachQuery).then(response => {
            this.buttonloading = false
            this.list = response.data.items
            this.total = response.data.total
            this.listLoading = false
          })
        }
      },
      handleFilterfirst() {
        if (this.seachQuery.nplist.length > 0) {
          var npstr = ''
          for (var inp = 0, ln = this.seachQuery.nplist.length; inp < ln; inp++) {
            npstr = npstr + this.seachQuery.nplist[inp] + ','
          }
          this.seachQuery.np = npstr
        }
        if (this.seachQuery.educationlist.length > 0) {
          var educationstr = ''
          for (var ie = 0, le = this.seachQuery.educationlist.length; ie < le; ie++) {
            educationstr = educationstr + this.seachQuery.educationlist[ie] + ','
          }
          this.seachQuery.education = educationstr
        }
        if (this.seachQuery.zodiaclist.length > 0) {
          var zodiacstr = ''
          for (var iz = 0, lz = this.seachQuery.zodiaclist.length; iz < lz; iz++) {
            zodiacstr = zodiacstr + this.seachQuery.zodiaclist[iz] + ','
          }
          this.seachQuery.zodiac = zodiacstr
        }
        if (this.seachQuery.constellationlist.length > 0) {
          var constellationstr = ''
          for (var ic = 0, lc = this.seachQuery.constellationlist.length; ic < lc; ic++) {
            constellationstr = constellationstr + this.seachQuery.constellationlist[ic] + ','
          }
          this.seachQuery.constellation = constellationstr
        }
        if (this.seachQuery.height === 0) {
          this.seachQuery.height = null
        }
        if (this.seachQuery.weight === 0) {
          this.seachQuery.weight = null
        }
        if (this.seachQuery.experiencestart === 0) {
          this.seachQuery.experiencestart = null
        }
        if (this.seachQuery.experienceend === 0) {
          this.seachQuery.experienceend = null
        }
        if (this.seachQuery.babynumber === 0) {
          this.seachQuery.babynumber = null
        }
        if (this.seachQuery.agestart === 0) {
          this.seachQuery.agestart = null
        }
        if (this.seachQuery.ageend === 0) {
          this.seachQuery.ageend = null
        }
        if (this.seachQuery.service_end === 0) {
          this.seachQuery.service_end = null
        }
        this.seachQuery.page = this.page
        this.seachQuery.limit = this.limit
        this.queryType = 'query'
        const age1 = Number(this.seachQuery.agestart)
        const age2 = Number(this.seachQuery.ageend)
        const diffAge = age2 - age1
        if (diffAge < 0) {
          this.$message.error('请正确输入年龄段')
        } else {
          this.listLoading = true
          this.buttonloading = true
          queryServiceUserStockCondition(this.seachQuery).then(response => {
            this.list = response.data.items
            this.buttonloading = false
            this.total = response.data.total
            this.listLoading = false
          })
          this.page = 1
        }
      },
      handleSizeChange(val) {
        this.limit = val
        if (this.queryType === 'list') {
          this.listQuery.limit = val
          this.listQuery.page = this.page
          this.getList()
        } else {
          this.seachQuery.limit = val
          this.seachQuery.page = this.page
          this.handleFilter()
        }
      },
      resumeEdity(id) {
        this.$router.push({ name: 'resume-admin', params: { userId: id }})
      },
      resumeShow(resume_path) {
        this.$refs['addForm'].validate((valid) => {
          if (valid) {
            window.open(resume_path, 'top')
            this.logJlServiceUser.js_sucode = this.addresumeinfo.id
            this.logJlServiceUser.jl_usercode = this.$store.state.user.introduction
            var date1 = new Date()
            this.logJlServiceUser.jl_date = date1.getFullYear() + '-' + (date1.getMonth() + 1) + '-' + date1.getDate()
            this.logJlServiceUser.jl_logtype = 3
            this.logJlServiceUser.jl_cmphone = this.addresumeinfo.cm_phone
            insertJlServiceUserLog(this.logJlServiceUser).then(response3 => {
              if (response3.data === 1) {
                this.dialogStatus = ''
                this.dialogFormVisible = false
              }
            })
          }
        })
      },
      // resumeLock(val) {
      //   var date1 = new Date()
      //   var date2 = new Date(date1)
      //   date2.setDate(date1.getDate() + 3)
      //   this.checkdate.servant_code = val
      //   this.checkdate.start_date = date1.getFullYear() + '-' + (date1.getMonth() + 1) + '-' + date1.getDate()
      //   this.checkdate.end_date = date2.getFullYear() + '-' + (date2.getMonth() + 1) + '-' + date2.getDate()
      //   this.lockForm.id = val
      //   this.lockForm.user = this.$store.state.user.name
      //   this.listLoading = true
      //   checkStockDate(this.checkdate).then(response3 => {
      //     if (response3.data === 1) {
      //       lockMmStocks(this.lockForm).then(response => {
      //         if (response.data === 1) {
      //           this.$message({
      //             message: '锁定成功',
      //             type: 'success'
      //           })
      //         } else {
      //           this.$message({
      //             message: '锁定失败！',
      //             type: 'warning'
      //           })
      //         }
      //         this.listLoading = false
      //       })
      //     } else {
      //       this.listLoading = false
      //       this.$message({
      //         message: '重复锁定！',
      //         type: 'warning'
      //       })
      //     }
      //   })
      // },
      handleCurrentChange(val) {
        this.page = val
        if (this.queryType === 'list') {
          this.listQuery.limit = this.limit
          this.listQuery.page = val
          this.getList()
        } else {
          this.seachQuery.limit = this.limit
          this.seachQuery.page = val
          this.handleFilter()
        }
      },
      handleModifyStatus(row, status) {
        this.$message({
          message: '操作成功',
          type: 'success'
        })
        row.status = status
      },
      resetmminfo() {
        this.addresumeinfo = {
          cm_phone: undefined
        }
      },
      handleCreate(val) {
        this.resetmminfo()
        this.addresumeinfo.resume_link = val.resume_path
        this.addresumeinfo.id = val.id
        this.dialogStatus = 'create'
        this.dialogFormVisible = true
        this.$nextTick(() => {
          this.$refs['addForm'].clearValidate()
        })
      },
      handleClose(done) {
        this.$confirm('确认关闭？').then(_ => {
          done()
        }).catch(_ => {})
      },
      handleUpdate(row) {
        this.temp = Object.assign({}, row) // copy obj
        this.temp.timestamp = new Date(this.temp.timestamp)
        this.dialogStatus = 'update'
        this.dialogFormVisible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].clearValidate()
        })
      },
      updateData() {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            const tempData = Object.assign({}, this.temp)
            tempData.timestamp = +new Date(tempData.timestamp) // change Thu Nov 30 2017 16:41:05 GMT+0800 (CST) to 1512031311464
            updateArticle(tempData).then(() => {
              for (const v of this.list) {
                if (v.id === this.temp.id) {
                  const index = this.list.indexOf(v)
                  this.list.splice(index, 1, this.temp)
                  break
                }
              }
              this.dialogFormVisible = false
              this.$notify({
                title: '成功',
                message: '更新成功',
                type: 'success',
                duration: 2000
              })
            })
          }
        })
      },
      handleDelete(row) {
        this.$notify({
          title: '成功',
          message: '删除成功',
          type: 'success',
          duration: 2000
        })
        const index = this.list.indexOf(row)
        this.list.splice(index, 1)
      },
      handleFetchPv(pv) {
        fetchPv(pv).then(response => {
          this.pvData = response.data.pvData
          this.dialogPvVisible = true
        })
      },
      handleref() {
        this.seachQuery.id = null
        this.seachQuery.salt = null
        this.seachQuery.truename = null
        this.seachQuery.constellationlist = []
        this.seachQuery.constellation = null
        this.seachQuery.zodiac = null
        this.seachQuery.zodiaclist = []
        this.seachQuery.nplist = []
        this.seachQuery.np = null
        this.seachQuery.cityname = null
        this.seachQuery.experiencestart = null
        this.seachQuery.experienceend = null
        this.seachQuery.gender = null
        this.seachQuery.status = '1'
        this.seachQuery.service_start = null
        this.seachQuery.service_end = null
        this.seachQuery.babynumber = null
        this.seachQuery.ethnicgroup = null
        this.seachQuery.educationlist = []
        this.seachQuery.education = null
        this.seachQuery.height = null
        this.seachQuery.marriage = null
        this.seachQuery.highlight = null
        this.seachQuery.weight = null
        this.seachQuery.agestart = null
        this.seachQuery.ageend = null
        this.seachQuery.days = null
        this.seachQuery.characters = null
        if (this.userMkt !== 'ALL') {
          this.seachQuery.cityname = this.userMkt
        }
      },
      handleDownload() {
        this.downloadLoading = true
        import('@/vendor/Export2Excel').then(excel => {
          const tHeader = ['timestamp', 'title', 'type', 'importance', 'status']
          const filterVal = ['timestamp', 'title', 'type', 'importance', 'status']
          const data = this.formatJson(filterVal, this.list)
          excel.export_json_to_excel(tHeader, data, 'table-list')
          this.downloadLoading = false
        })
      },
      infoshow(id) {
        this.$router.push({ name: 'mminfoshow', params: { userId: id }})
      },
      formatJson(filterVal, jsonData) {
        return jsonData.map(v => filterVal.map(j => {
          if (j === 'timestamp') {
            return parseTime(v[j])
          } else {
            return v[j]
          }
        }))
      }
    }
  }
</script>