    <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('wxmini.wd_username')" >
                  <div class="block">
                   <el-input style="width: 100%;" class="filter-item"
                      v-model="seachQuery.wd_username" :maxlength = "20">
                  </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('wxmini.wd_date')" >
                <div class="block">
                  <el-date-picker v-model="seachQuery.wd_date" value-format="yyyy-MM-dd" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions" 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('wxmini.wd_result')" >
                <div class="block">
                  <el-select class="filter-item" v-model="seachQuery.wd_result">
                    <el-option v-for="item in resultOPtions" :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="5" :xl="5">
              <div class="grid-content bg-purple" >
                <el-form-item  :label="$t('wxmini.wd_create_date')" >
                  <div class="block">
                  <el-date-picker v-model="seachQuery.wd_create_date" value-format="yyyy-MM-dd" align="right" type="date" placeholder="选择日期" :picker-options="pickerOptions" style="width: 100%;">
                  </el-date-picker>
                  </div>
                </el-form-item>
              </div>
          </el-col>
          </el-row>
           <el-row :gutter="24" style="margin-bottom:15px;">
          <el-col :span="24">
              <div  align="center" > <el-button class="filter-item" type="primary" v-waves :loading ="buttonloading" 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-row :gutter="24">
            <div align="right">
              <el-button class="filter-item" style="margin-left: 10px;" @click="hrefAdd" type="primary"
                    icon="el-icon-edit">{{$t('table.add')}}
            </el-button>&nbsp;&nbsp;&nbsp;</div>    
          </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 type="index" align="center" :label="$t('table.seq')" width="70">
            <template slot-scope="scope">
              <a href="#" @click="infoshow(scope.row.id)"><span style="color:#409EFF">{{scope.$index+1}}</span></a>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('wxmini.wd_username')">
            <template slot-scope="scope">
               <span>{{scope.row.wd_username}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('wxmini.wd_date')">
            <template slot-scope="scope">
              <span>{{scope.row.wd_date}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('wxmini.wd_result')">
            <template slot-scope="scope">
               <el-rate v-model="scope.row.wd_result" disabled ></el-rate>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('wxmini.wd_comment')">
            <template slot-scope="scope" align="right">
              <a href="#" @click="comment_show(scope.row.wd_comment)">
                <span style="color:#409EFF" >查看<i class="el-icon-view el-icon--right"></i></span>
              </a>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('wxmini.imgs')">
            <template slot-scope="scope">
              <span>{{scope.row.imgs}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('wxmini.wd_create_date')">
            <template slot-scope="scope">
              <span>{{scope.row.wd_create_date}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('wxmini.wd_create_user')">
            <template slot-scope="scope">
              <span>{{scope.row.wd_create_user_name}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('table.actions')">
          <template slot-scope="scope">
            <a href="#" @click="hrefedit(scope.row.id)"><el-tag >{{$t('table.edit')}}</el-tag></a>
            <a href="#" @click="hrefdel(scope.row.id)"><el-tag >{{$t('table.delete')}}</el-tag></a>
          </template>
        </el-table-column>
        </el-table>
        <el-dialog title="评论内容" :visible.sync="dialogFormVisible" :before-close="handleClose">
          <div class="editor-content" v-html="content"></div>
        </el-dialog>
        <div class="pagination-container">
          <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                        :current-page="page" :page-sizes="[10,300,500,1000]" :page-size="limit"
                        layout="total, sizes, prev, pager, next, jumper" :total="total">
          </el-pagination>
        </div>
      </div>
    </template>
    <script>
      import { fetchPv, createArticle } from '@/api/article'
      import waves from '@/directive/waves' // 水波纹指令
      import { parseTime } from '@/utils'
      import { queryWXDianPings, deleteWXDianPing } from '@/api/wxmini'
      // arr to obj ,such as { CN : "China", US : "USA" }
      export default {
        name: 'introducer',
        directives: {
          waves
        },
        data() {
          return {
            content: null,
            tableKey: 0,
            resultOPtions: [{ label: '一星', value: 1 }, { label: '二星', value: 2 }, { label: '三星', value: 3 }, { label: '四星', value: 4 }, { label: '五星', value: 5 }],
            list: null,
            dis: 1,
            total: null,
            page: 1,
            limit: 10,
            queryType: 'list',
            listLoading: true,
            buttonloading: false,
            dialogStatus: null,
            dialogbuttonloading: false,
            dialogImageUrl: undefined,
            listQuery: {
              importance: undefined,
              title: undefined,
              type: undefined,
              sort: '+id'
            },
            commentShow: {
              comment: null
            },
            seachQuery: {
              wd_username: null,
              wd_date: null,
              wd_result: null,
              wd_create_date: null,
              page: null,
              limit: null
            },
            pickerOptions: {
              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)
                }
              }]
            },
            showReviewer: false,
            dialogVisible: false,
            dialogFormVisible: false,
            dialogPvVisible: false,
            dialogAuditingDC: false,
            dialogAuditing: '',
            pvData: [],
            textMap: {
              update: 'Edit',
              create: '添加月嫂'
            }
          }
        },
        created() {
          this.getList()
        },
        methods: {
          getList() {
            this.list = []
            this.listQuery.page = this.page
            this.listQuery.limit = this.limit
            this.queryType = 'list'
            this.listLoading = true
            queryWXDianPings(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
            this.queryType = 'query'
            this.listLoading = true
            queryWXDianPings(this.seachQuery).then(response => {
              this.list = response.data.items
              this.total = response.data.total
              this.listLoading = false
            })
          },
          handleFilterfirst() {
            this.seachQuery.page = 1
            this.seachQuery.limit = 10
            this.queryType = 'query'
            this.listLoading = true
            this.buttonloading = true
            queryWXDianPings(this.seachQuery).then(response => {
              this.list = response.data.items
              this.total = response.data.total
              this.listLoading = false
              this.buttonloading = false
            })
          },
          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()
            }
          },
          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
          },
          handleClose(done) {
            done()
          },
          hrefdel(id) {
            createArticle(this.temp).then(() => {
              this.$confirm('此操作将永久删除该, 是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                var delParas = {
                  id: null
                }
                delParas.id = id
                deleteWXDianPing(delParas).then(response => {
                  if (response.data === 1) {
                    this.getList()
                    this.$notify({
                      title: '成功',
                      message: '删除成功',
                      type: 'success',
                      duration: 2000
                    })
                  } else {
                    this.$notify({
                      title: '失败',
                      message: '删除失败',
                      type: 'error',
                      duration: 2000
                    })
                  }
                })
              }).catch(() => {})
            })
          },
          hrefAdd() {
            this.$router.push({ name: 'dianpingadd' })
          },
          hrefedit(id) {
            this.$router.push({ name: 'dianpingedit', params: { dianpingID: id }})
          },
          infoshow(id) {
            this.$router.push({ name: 'dianpingshow', params: { dianpingID: id }})
          },
          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
            })
          },
          comment_show(comment) {
            this.commentShow.comment = comment
            this.content = comment
            this.dialogFormVisible = true
          },
          handleref() {
            this.seachQuery.wd_username = null
            this.seachQuery.wd_date = null
            this.seachQuery.wd_result = null
            this.seachQuery.wd_create_date = null
          },
          resetForm(formName) {
            this.$refs['uploadReq'].clearFiles()
            this.updateIntroducer.id = null
            this.updateIntroducer.wv_phone = null
            this.updateIntroducer.wv_account_number = null
            this.updateIntroducer.wv_account_bank = null
            this.updateIntroducer.wv_account_number_path = null
            this.updateIntroducer.wv_consultant = null
          },
          formatJson(filterVal, jsonData) {
            return jsonData.map(v => filterVal.map(j => {
              if (j === 'timestamp') {
                return parseTime(v[j])
              } else {
                return v[j]
              }
            }))
          }
        }
      }
    </script>
    <style>
    .el-form--label-left .el-form-item__label{
      text-align:right
    }
    .el-rate{
      line-height: 0;
      margin-top:8px;
    }
    .el-checkbox.el-checkbox {
        margin-left: 30px;
    }
    .disabled .el-upload--picture-card {
        display: none;
    }
    </style>
    