    <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('dc.orderno')" >
                  <div class="block">
                    <el-input style="width: 100%;" class="filter-item"
                        v-model="seachQuery.wue_orderno" :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('dc.phone')" >
                  <div class="block">
                    <el-input style="width: 100%;" class="filter-item"
                        v-model="seachQuery.wue_phone" :maxlength = 20>
                    </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('dc.bankcard')" >
                  <div class="block">
                    <el-input style="width: 100%;" class="filter-item"
                        v-model="seachQuery.wue_bank_card" :maxlength = 20>
                    </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('dc.appstatus')" >
                <div class="block">
                  <el-select class="filter-item" v-model="seachQuery.wue_type" 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-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('dc.applicantdate')" >
                <div class="block">
                  <el-date-picker v-model="seachQuery.wue_applydate" 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="11" :lg="6" :xl="6">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('dc.approvedate')" >
                <div class="block">
                  <el-date-picker v-model="seachQuery.wue_approverdate" 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('dc.paydate')" >
                <div class="block">
                  <el-date-picker v-model="seachQuery.wue_paydate" 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="11" :lg="5" :xl="5">
            <div class="grid-content bg-purple" >
              <el-form-item  :label="$t('dc.auditor')" >
                <div class="block">
                  <el-select class="filter-item" v-model="seachQuery.wue_approveruser" style="width: 100%;">
                    <el-option v-for="item in consultantOptions" :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" style="margin-bottom:15px;">
            <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>
          <el-button class="filter-item" type="primary" icon="document" @click="handleDownload" :loading="downloadLoading">{{$t('excel.export')}} excel</el-button>
          </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 align="center" :label="$t('dc.orderno')" width="145">
            <template slot-scope="scope">
              <span>{{scope.row.wue_orderno}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.phone')" width="110">
            <template slot-scope="scope">
              <span>{{scope.row.wue_phone}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.appstatus')">
            <template slot-scope="scope">
              <span v-if="scope.row.wue_type === 1">已申请</span>
              <span v-else-if="scope.row.wue_type === 2" >已审核</span>
              <span v-else-if="scope.row.wue_type === 3" >已打款</span>
              <span v-else >已拒绝</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.name')">
            <template slot-scope="scope">
              <span>{{scope.row.wue_account_name}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.bankcard')" width="160">
            <template slot-scope="scope">
              <span>{{scope.row.wue_bank_card}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.bankname')">
            <template slot-scope="scope">
              <span>{{scope.row.wv_account_bank}}</span>
            </template>
          </el-table-column>
          <el-table-column  align="right" :label="$t('dc.amount')">
            <template slot-scope="scope">
              <span>{{scope.row.wue_applysum | numFilter}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.applicantdate')">
            <template slot-scope="scope">
              <span>{{scope.row.wue_applydate}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.approvedate')">
            <template slot-scope="scope">
              <span>{{scope.row.wue_approverdate}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.auditor')">
            <template slot-scope="scope">
              <span>{{scope.row.wue_approveruser}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('dc.cltname')">
            <template slot-scope="scope">
              <span>{{scope.row.cltname}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('equipment.cp_comments')">
            <template slot-scope="scope">
              <span>{{scope.row.wue_remarks}}</span>
            </template>
          </el-table-column>
          <el-table-column align="center" :label="$t('table.actions')" width="110" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <a v-if="scope.row.wue_type == '1'"  @click="hrefordertempedit(scope.row)"><el-tag >{{$t('dc.approve')}}</el-tag></a>
            <a v-else  ><el-tag type="danger">{{$t('dc.approve')}}</el-tag></a>
            <a v-if="scope.row.wue_type == '2'"  href="#" @click="hrefpay(scope.row)"><el-tag >{{$t('dc.pay')}}</el-tag></a>
            <a v-else ><el-tag  type="danger">{{$t('dc.pay')}}</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>
        </div>

        <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" :before-close="handleClose">
          <el-form ref="addForm" :model="approveinfo" label-position="left" label-width="100px"
                  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('dc.phone')" prop="ot_startdate">
                    <el-input v-model="approveinfo.wue_phone" :controls = false :precision="2" :disabled="true" :max="999999" ></el-input>
                </el-form-item>
              </div>
            </el-col>
            </el-row>
          <el-row :gutter="16" style="margin-bottom: 15px;">
            <el-col :span="14">
              <div class="grid-content bg-purple">
                <el-form-item  :label="$t('dc.status')" prop="cm_phone">
                  <template>
                    <el-radio v-model="approveinfo.wue_type" label="2">通过</el-radio>
                    <el-radio v-model="approveinfo.wue_type" label="4">拒绝</el-radio>
                  </template>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
            <el-row :gutter="16" style="margin-bottom: 15px;">
            <el-col :span="14">
              <div class="grid-content bg-purple">
                <el-form-item  :label="$t('dc.amount')" prop="ot_startdate">
                    <el-input-number :disabled="true"  v-model="approveinfo.wue_approversum" :controls = false :precision="2" :max="999999" ></el-input-number>
                </el-form-item>
              </div>
            </el-col>
            </el-row>
            <el-row :gutter="16" style="margin-bottom: 15px;">
            <el-col :span="8">
              <div class="grid-content bg-purple" style="width: 300px;">
                <el-form-item  :label="$t('dc.remarks')" prop="ot_enddate" style="width: 310px;">
                  <div class="block">
                    <el-input
                        type="textarea"
                        :autosize="{ minRows: 12, maxRows: 15}"
                        placeholder="请输入备注"
                        :maxlength = 150
                        v-model="approveinfo.wue_remarks">
                    </el-input>
                  </div>
                </el-form-item>
              </div>
            </el-col>
          </el-row>
            </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button  type="primary" @click="approveGo" :loading ="dialogbuttonloading">{{$t('table.confirm')}}</el-button>
            <el-button @click="resetForm('addForm')">{{$t('navbar.reset')}}</el-button>
          </div>
        </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 { fetchPv, updateArticle, createArticle } from '@/api/article'
      import { getJlAdminUsers, queryDcIntroducerExtracts, updateDcIntroducerExtract } from '@/api/dc'
      import waves from '@/directive/waves' // 水波纹指令
      import { parseTime } from '@/utils'
      // arr to obj ,such as { CN : "China", US : "USA" }
      export default {
        name: 'introducerextract',
        directives: {
          waves
        },
        filters: {
          numFilter(value) {
            return parseFloat(value).toFixed(2)
          }
        },
        data() {
          return {
            tableKey: 0,
            list: null,
            total: null,
            page: 1,
            limit: 10,
            queryType: 'list',
            listLoading: true,
            buttonloading: false,
            dialogbuttonloading: false,
            wue_applysum: null,
            listQuery: {
              importance: undefined,
              title: undefined,
              type: undefined,
              sort: '+id'
            },
            checkdate: {
              servant_code: undefined,
              stock_status: undefined,
              start_date: undefined,
              end_date: undefined
            },
            seachQuery: {
              wue_orderno: null,
              wue_phone: null,
              wue_bank_card: null,
              wue_type: null,
              wue_applydate: null,
              wue_applysum: null,
              wue_approverdate: null,
              wue_approversum: null,
              wue_approveruser: null,
              wue_paydate: null,
              page: null,
              limit: null
            },
            idcardquery: {
              idcard: null
            },
            ordertemepdel: {
              id: undefined
            },
            checksalt: {
              salt: undefined
            },
            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)
                }
              }]
            },
            sortOptions: [{ label: 'ID Ascending', key: '+id' }, { label: 'ID Descending', key: '-id' }],
            statusOptions: [{ value: '1', label: '已申请' }, { value: '2', label: '已审批' }, { value: '3', label: '已打款' }, { value: '4', label: '已拒绝' }],
            consultantOptions: [],
            showReviewer: false,
            approveinfo: {
              id: null,
              wue_type: null,
              wue_approversum: null,
              wue_applysum: null,
              wue_approveruser: null,
              wue_approverdate: null,
              wue_phone: null,
              wue_remarks: null
            },
            updateextract: {
              id: null,
              wue_type: null,
              wue_paydate: null,
              wue_phone: null,
              wue_approversum: null,
              wue_applysum: null
            },
            ethnicgroupptions: '',
            provinceoptions: '',
            dialogFormVisible: false,
            checkidcard: {
              idcard: undefined
            },
            dialogStatus: '',
            textMap: {
              update: 'Edit',
              create: '添加月嫂'
            },
            dialogPvVisible: false,
            pvData: [],
            updateStatus: {
              id: undefined,
              status: undefined
            },
            downloadLoading: false
          }
        },
        created() {
          this.getList()
          getJlAdminUsers().then(response5 => {
            this.consultantOptions = response5.data
          })
        },
        methods: {
          getList() {
            this.listQuery.page = this.page
            this.listQuery.limit = this.limit
            this.queryType = 'list'
            this.listLoading = true
            queryDcIntroducerExtracts(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
            queryDcIntroducerExtracts(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
            queryDcIntroducerExtracts(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()
            }
          },
          approveGo() {
            this.dialogbuttonloading = true
            this.approveinfo.wue_approveruser = this.$store.getters.introduction
            var date1 = new Date()
            this.approveinfo.wue_approverdate = date1.getFullYear() + '-' + (date1.getMonth() + 1) + '-' + date1.getDate() + ' ' + date1.getHours() + ':' + date1.getMinutes() + ':' + date1.getSeconds()
            if (this.approveinfo.wue_approversum > this.approveinfo.wue_applysum || this.approveinfo.wue_approversum <= 0) {
              this.$message({
                message: '录入金额错误!',
                type: 'warning'
              })
              this.approveinfo.wue_approversum = this.approveinfo.wue_applysum
              this.dialogbuttonloading = false
            } else {
              updateDcIntroducerExtract(this.approveinfo).then(response => {
                this.dialogbuttonloading = false
                if (response.data === 1) {
                  this.dialogFormVisible = false
                  this.$notify({
                    title: '成功',
                    message: '审核成功',
                    type: 'success',
                    duration: 2000
                  })
                  this.getList()
                } else {
                  this.dialogFormVisible = false
                  this.$notify({
                    title: '失败',
                    message: '审核失败',
                    type: 'warning',
                    duration: 2000
                  })
                }
              })
            }
          },
          handleModifyStatus(row, status) {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            row.status = status
          },
          handleClose(done) {
            this.$confirm('确认关闭？').then(_ => {
              done()
            }).catch(_ => {})
          },
          hrefordertempedit(row) {
            this.approveinfo.id = row.id
            this.approveinfo.dialogStatus = 'create'
            this.approveinfo.wue_type = '2'
            this.approveinfo.wue_approversum = row.wue_applysum
            this.approveinfo.wue_phone = row.wue_phone
            this.approveinfo.wue_applysum = row.wue_applysum
            this.approveinfo.wue_approveruser = null
            this.approveinfo.wue_remarks = null
            this.approveinfo.wue_approverdate = null
            this.dialogFormVisible = true
            this.$nextTick(() => {
              this.$refs['addForm'].clearValidate()
            })
          },
          hrefpay(row) {
            createArticle(this.temp).then(() => {
              this.$confirm('付款金额:' + row.wue_approversum + ' 是否继续?', '确认付款', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
              }).then(() => {
                this.listLoading = true
                var date1 = new Date()
                this.updateextract.id = row.id
                this.updateextract.wue_type = 3
                this.updateextract.wue_phone = row.wue_phone
                this.updateextract.wue_approversum = row.wue_approversum
                this.updateextract.wue_applysum = row.wue_applysum
                this.wue_applysum = row.wue_applysum
                this.updateextract.wue_paydate = date1.getFullYear() + '-' + (date1.getMonth() + 1) + '-' + date1.getDate() + ' ' + date1.getHours() + ':' + date1.getMinutes() + ':' + date1.getSeconds()
                updateDcIntroducerExtract(this.updateextract).then(response => {
                  this.listLoading = false
                  if (response.data === 1) {
                    createArticle(this.temp).then(() => {
                      this.$notify({
                        title: '成功',
                        message: '保存成功',
                        type: 'success',
                        duration: 2000
                      })
                    })
                    this.getList()
                  } else {
                    createArticle(this.temp).then(() => {
                      this.$notify({
                        title: '错误',
                        message: '错误',
                        type: 'error',
                        duration: 2000
                      })
                    })
                  }
                })
              }).catch(() => {
              })
            })
          },
          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
            })
          },
          handleDownload() {
            this.downloadLoading = true
            import('@/vendor/Export2Excel').then(excel => {
              const tHeader = ['单据编号', '申请人手机号', '单据状态', '开户名', '银行卡号', '申请提现金额', '申请日期', '审核日期', '审核人']
              const filterVal = ['wue_orderno', 'wue_phone', 'wue_type', 'wue_account_name', 'wue_bank_card', 'wue_applysum', 'wue_applydate', 'wue_approverdate', 'wue_approveruser']
              const list = this.list
              for (let i = 0; i < list.length; i++) {
                if (list[i].wue_type === 1) {
                  list[i].wue_type = '已申请'
                } else if (list[i].wue_type === 2) {
                  list[i].wue_type = '已审批'
                } else if (list[i].wue_type === 3) {
                  list[i].wue_type = '已打款'
                } else if (list[i].wue_type === 4) {
                  list[i].wue_type = '拒绝'
                }
                var a = parseFloat(list[i].wue_applysum).toFixed(2)
                list[i].wue_applysum = a
              }
              const data = this.formatJson(filterVal, list)
              excel.export_json_to_excel({
                header: tHeader,
                data,
                filename: '推荐人奖励提现表',
                autoWidth: this.autoWidth
              })
              this.downloadLoading = false
              this.getList()
            })
          },
          handleref() {
            this.seachQuery.wue_orderno = null
            this.seachQuery.wue_phone = null
            this.seachQuery.wue_bank_card = null
            this.seachQuery.wue_type = null
            this.seachQuery.wue_applydate = null
            this.seachQuery.wue_applysum = null
            this.seachQuery.wue_approverdate = null
            this.seachQuery.wue_approversum = null
            this.seachQuery.wue_approveruser = null
            this.seachQuery.wue_paydate = null
          },
          resetForm(formName) {
            this.approveinfo.wue_type = '2'
            this.approveinfo.wue_approversum = null
            this.approveinfo.wue_approveruser = null
            this.approveinfo.wue_remarks = null
            this.approveinfo.wue_approverdate = 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-input-number.is-without-controls .el-input__inner{
      padding-left: 15px;
      padding-right: 15px;
      text-align: right;
    }
    .el-rate{
      line-height: 0;
      margin-top:8px;
    }
    
    .el-checkbox.el-checkbox {
        margin-left: 30px;
    }
  </style>
    