<template>
  <div>
    <el-card>
      <el-form
          :model="searchForm"
          label-width="100px"
          @submit.prevent="fnResetPaginationTransfer"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="运输车辆" prop="TRANSPORTVEHICLE">
              <el-input
                  v-model="searchForm.TRANSPORTVEHICLE"
                  placeholder="请输入运输车辆"
              />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="状态" prop="STEP_ID">
              <el-select v-model="searchForm.STEP_ID">
                <el-option
                    v-for="item in stepList"
                    :key="item.STEP_ID"
                    :label="item.STEP_NAME"
                    :value="item.STEP_ID"
                />
              </el-select>
            </el-form-item>
          </el-col>


          <el-col :span="12">
            <el-form-item label-width="10px">
              <el-button type="primary" native-type="submit">搜索</el-button>
              <el-button native-type="reset" @click="fnResetPaginationTransfer">
                重置
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <layout-card>
      <layout-table
          v-model:pagination="pagination"
          :data="list"
          @get-data="fnGetData"
      >
        <el-table-column label="序号" width="60">
          <template #default="{ $index }">
            {{ serialNumber(pagination, $index) }}
          </template>
        </el-table-column>
        <el-table-column prop="WAYBILLNUMBER" label="运单编号" width="230"/>
        <el-table-column label="行车状态" width="130" >
          <template #default="{ row }">
            <el-tag v-if="row.WAYBILLSTATUS === '0'">未出发</el-tag>
            <el-tag v-else-if="row.WAYBILLSTATUS === '1'">已出发</el-tag>
            <el-tag v-else-if="row.WAYBILLSTATUS === '2'">收车后</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="TRANSPORTVEHICLE" label="运输车辆" width="230" />
        <el-table-column prop="NAME" label="从业人员" width="130" />
        <el-table-column prop="PHONE" label="联系电话" width="130" />
        <el-table-column prop="STARTTIME" label="发车时间" />
        <el-table-column prop="STOPTIME" label="收车时间" />
        <el-table-column label="操作" width="180">
          <template #default="{ row }">
            <el-button
                type="primary"
                text
                link
                @click="
                router.push({
                  path: '/driving_inspections/driving_log/drivingLog_info',
                  query: {
                    WAYBILLREGISTRATION_ID: row.WAYBILLREGISTRATION_ID
                  },
                })
              "
            >
              查看
            </el-button>
<!--            <el-button-->
<!--                type="danger"-->
<!--                text-->
<!--                link-->
<!--                @click="deleteItem(row.WAYBILLREGISTRATION_ID)"-->
<!--            >-->
<!--              删除-->
<!--            </el-button>-->
          </template>
        </el-table-column>
      </layout-table>
    </layout-card>
  </div>
</template>

<script setup>
import { serialNumber } from "@/assets/js/utils.js";
import { useRouter } from "vue-router";
import useListData from "@/assets/js/useListData.js";
import { getSafetyDrivingLogList } from "@/request/traffic_driving_log.js";

const router = useRouter();
const { list, pagination, searchForm, fnGetData, fnResetPagination } =
    useListData(getSafetyDrivingLogList);

const fnResetPaginationTransfer = () => {
  fnResetPagination({
    TRANSPORTVEHICLE: searchForm.value.TRANSPORTVEHICLE,
    CONFIRM_DEPARTMENT_ID: searchForm.value.CONFIRM_DEPARTMENT_ID,
    WORK_START_DATE: searchForm.value.WORK_START_DATE,
  });
};

</script>

<style scoped></style>