<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
        <el-form-item label="派遣公司名称" prop="name">
          <el-input
              v-model="queryParams.name"
              clearable
              style="width: 300px"
              @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="默认账号" prop="default_account">
          <el-input
              v-model="queryParams.default_account"
              clearable
              style="width: 300px"
              @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item label="编号" prop="base_code">
          <el-input
              v-model="queryParams.base_code"
              clearable
              style="width: 300px"
              @keyup.enter="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
          <el-button icon="Refresh" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
  
      <el-table v-loading="loading" :data="list">
        <el-table-column label="编号" align="left" prop="base_code" width="200" fixed/>
        <el-table-column label="派遣公司名称" align="left" prop="name"  width="260" fixed />
        <el-table-column label="默认账号" align="left" prop="default_account" width="180" fixed/>
        <el-table-column label="前缀" align="left" prop="prefix" width="100"/>
        <el-table-column label="规模" align="center" prop="scale" />
        <el-table-column label="联系人" align="center" prop="contracts" />
        <el-table-column label="联系电话" align="center" prop="contract_number" width="120"/>
        <el-table-column label="公司地址（省市县区 ）" align="left" prop="district" width="200"/>
        <el-table-column label="详细地址" align="left" prop="address" width="200"/>
        <el-table-column label="是否使用电子合同" align="center" prop="line_contract" width="180">
          <template #default="{row}">
            {{row.line_contract=='1'?'是':'否'}}
          </template>
        </el-table-column>
        <el-table-column label="统一社会信用代码" align="left" prop="id_no" width="180"/>
        <el-table-column label="电子签章应用id" align="left" prop="seal_id" width="180"/>
        <el-table-column label="电子签章应用秘钥" align="left" prop="secret_key" width="280"/>
        <el-table-column label="注册日期" align="left" prop="register_time" width="180"/>
        <el-table-column label="创建时间" align="left" prop="create_time" width="180"/>
        <el-table-column label="更新时间" align="left" prop="update_time" width="180"/>
  
        <el-table-column label="操作" width="180" align="center" class-name="small-padding fixed-width">
          <template #default="{row}">
            <el-button link type="primary"  @click="handleSalaryAdvance(row)" icon="EditPen">设置预支工资</el-button>
          </template>
        </el-table-column>
      </el-table>
  
      <pagination
          v-show="total > 0"
          :total="total"
          v-model:page="queryParams.page"
          v-model:limit="queryParams.limit"
          @pagination="getList"
      />
    </div>
  </template>
  
<script setup>


  import {dispatchL} from "@/api/dispatch";
  
  const { proxy } = getCurrentInstance();
  
  const list = ref([]);
  const policyOpen = ref(false);
  const loading = ref(true);
  const showSearch = ref(true);
  const total = ref(0);

  const data = reactive({
    form: {
    },
    queryParams: {
      page: 1,
      limit: 10,
    },
  });
  
  const { queryParams, form } = toRefs(data);

  /** 查询列表 */
  function getList() {
    loading.value = true;
    dispatchL(queryParams.value).then(response => {
      list.value = response.data;
      total.value = response.count;
      loading.value = false;
    });
  }
  
  /** 搜索按钮操作 */
  function handleQuery() {
    queryParams.value.page = 1;
    queryParams.value.limit = 10;
    getList();
  }
  /** 重置按钮操作 */
  function resetQuery() {
    proxy.resetForm("queryRef");
    handleQuery();
  }
  
  /** 设置预支公司按钮操作 */
  function handleSalaryAdvance(row) {
    proxy.$router.push('dispatch/salary/advance?id='+row.id+'&code='+row.base_code)
  }
  getList();

  </script>
  