<template>
  <div>
    <el-form :model="searchForm" label-width="0" inline>
      <el-form-item>
        <el-input v-model="searchForm.signId" placeholder="成交单号" />
      </el-form-item>
      <el-form-item>
        <el-input v-model="searchForm.name" placeholder="线索名称" />
      </el-form-item>
      <el-form-item>
        <el-select v-model="searchForm.dealUser" placeholder="登记人" clearable filterable>
          <el-option
            v-for="item in userOptions"
            :key="item.id"
            :label="item.nickname"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="searchForm.dealDate"
          type="daterange"
          range-separator="-"
          start-placeholder="登记日期"
          end-placeholder="登记日期"
        />
      </el-form-item>
      <el-form-item>
        <el-select v-model="searchForm.createUser" placeholder="申请人" clearable filterable>
          <el-option
            v-for="item in userOptions"
            :key="item.id"
            :label="item.nickname"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-date-picker
          v-model="searchForm.createDate"
          type="daterange"
          range-separator="-"
          start-placeholder="申请日期"
          end-placeholder="申请日期"
        />
      </el-form-item>
      <el-form-item>
        <el-button @click="handleSearch">查询</el-button>
        <el-button @click="handleReset">重置</el-button>
        <el-button @click="batchAudit">批量审核</el-button>
      </el-form-item>
    </el-form>

    <el-table :data="tableList" border>
      <el-table-column prop="signId" label="成交单号" width="150px" />
      <el-table-column prop="name" label="线索名称" />
      <el-table-column prop="phone" label="联系方式" width="150px" />
      <el-table-column prop="signId" label="回款金额" />
      <el-table-column prop="signId" label="是否结清" />
      <el-table-column prop="signId" label="备注" width="200px" />
      <el-table-column prop="signId" label="登记人" />
      <el-table-column prop="signId" label="登记时间" width="150px" />
      <el-table-column prop="signId" label="申请人" />
      <el-table-column prop="signId" label="申请时间" width="150px" />
      <el-table-column prop="signId" label="审核状态" fixed="right" />
      <el-table-column label="操作" width="150px" fixed="right">
        <template #default="{ row }">
          <el-button type="primary" style="padding: 0" text @click="handleDetail(row.id)"
            >详情</el-button
          >
          <el-button type="primary" style="padding: 0" text @click="handleCancel(row.id)"
            >撤销</el-button
          >
          <el-button type="primary" style="padding: 0" text @click="handleAudit(row.id)"
            >审核</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <Pagination
      v-model:limit="searchForm.pageSize"
      v-model:page="searchForm.pageNo"
      :total="total"
      @pagination="getList"
    />
  </div>
</template>

<script setup name="Reback">
const searchForm = ref({
  signId: undefined,
  name: undefined,
  dealDate: [],
  dealUser: undefined,
  createDate: [],
  createUser: undefined,
  pageNo: 1,
  pageSize: 20
})

const userOptions = ref([])

const tableList = ref([])
const total = ref(0)

function handleSearch() {
  searchForm.value.pageNo = 1
  getList()
}

function handleReset() {
  searchForm.value = {
    signId: undefined,
    name: undefined,
    dealDate: [],
    dealUser: undefined,
    createDate: [],
    createUser: undefined,
    pageNo: 1,
    pageSize: 20
  }
}

function getList() {
  tableList.value = [{ name: '测试' }]
}

function batchAudit() {
  console.log(123)
}

function handleDetail(id) {
  console.log(id)
}
function handleCancel(id) {
  console.log(id)
}
function handleAudit(id) {
  console.log(id)
}

onMounted(() => {
  handleSearch()
})
</script>

<style lang="scss" scoped></style>
