<template>
  <div>
    <el-card>
      <el-form
        :model="searchForm"
        label-width="100px"
        @submit.prevent="fnResetPagination"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="运输企业" prop="TRANSPORTCOMPANY">
              <el-input v-model="searchForm.TRANSPORTCOMPANY" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="检查项类型" prop="CHECKITEMTYPE">
              <el-input v-model="searchForm.CHECKITEMTYPE" />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label-width="10px">
              <el-button type="primary" native-type="submit">搜索</el-button>
              <el-button native-type="reset" @click="fnResetPagination">
                重置
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <layout-card>
      <layout-table
        :data="list"
        @get-data="fnGetData"
        v-model:pagination="pagination"
      >
        <el-table-column label="序号" width="60">
          <template #default="{ $index }">
            {{ serialNumber(pagination, $index) }}
          </template>
        </el-table-column>
        <el-table-column prop="CHECKITEMNAME" label="检查项名称" width="130" />
        <el-table-column prop="CHECKITEMTYPE" label="检查项类型" width="130" />
        <el-table-column
          prop="CHECKITEMDESCRIPTION"
          label="检查项说明"
          width="130"
        />
        <el-table-column prop="TRANSPORTCOMPANY" label="运输企业" width="130" />
        <el-table-column
          prop="TRANSPORTCATEGORY"
          label="运输类别"
          width="130"
        />
        <el-table-column prop="CREATETIME" label="创建时间" width="130" />
        <el-table-column label="操作" width="180">
          <template v-slot:default="{ row }">
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/safety_production_related/driving_log/drivingLog_info',
                  query: {
                    DRIVING_LOG_ID: row.DRIVING_LOG_ID,
                  },
                })
              "
            >
              查看
            </el-button>
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/safety_production_related/safety_meeting/add',
                })
              "
            >
              添加
            </el-button>
            <el-button
              type="danger"
              text
              link
              @click="deleteItem(row.DRIVING_LOG_ID)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </layout-table>
    </layout-card>
    <edit
      v-model:visible="data.analysisDialog.visible"
      :info="data.analysisDialog.info"
      @get-data="fnResetPagination"
    />
  </div>
</template>
<script setup>
import { serialNumber } from "@/assets/js/utils";
import useListData from "@/assets/js/useListData.js";
import { reactive } from "vue";
import {
  getSafetyDrivingLogList,
  setDrivingLogDelete,
} from "@/request/traffic_driving_log.js";
import router from "@/router/index.js";
import { ElMessage, ElMessageBox } from "element-plus";

const { list, pagination, searchForm, fnGetData, fnResetPagination } =
  useListData(getSafetyDrivingLogList);
const data = reactive({
  analysisDialog: {
    visible: false,
    info: {},
  },
});
// 删除事件
const deleteItem = async (value) => {
  await ElMessageBox.confirm(`确定要删除吗？`, {
    type: "warning",
  });
  await setDrivingLogDelete({ DRIVING_LOG_ID: value });
  ElMessage.success("删除成功");
  fnGetData();
};
</script>

<style scoped></style>
<template>
  <div>
    <el-card>
      <el-form
        :model="searchForm"
        label-width="100px"
        @submit.prevent="fnResetPagination"
      >
        <el-row>
          <el-col :span="6">
            <el-form-item label="运输企业" prop="TRANSPORTCOMPANY">
              <el-input v-model="searchForm.TRANSPORTCOMPANY" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="检查项类型" prop="CHECKITEMTYPE">
              <el-input v-model="searchForm.CHECKITEMTYPE" />
            </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label-width="10px">
              <el-button type="primary" native-type="submit">搜索</el-button>
              <el-button native-type="reset" @click="fnResetPagination">
                重置
              </el-button>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <layout-card>
      <layout-table
        :data="list"
        @get-data="fnGetData"
        v-model:pagination="pagination"
      >
        <el-table-column label="序号" width="60">
          <template #default="{ $index }">
            {{ serialNumber(pagination, $index) }}
          </template>
        </el-table-column>
        <el-table-column prop="CHECKITEMNAME" label="检查项名称" width="130" />
        <el-table-column prop="CHECKITEMTYPE" label="检查项类型" width="130" />
        <el-table-column
          prop="CHECKITEMDESCRIPTION"
          label="检查项说明"
          width="130"
        />
        <el-table-column prop="TRANSPORTCOMPANY" label="运输企业" width="130" />
        <el-table-column
          prop="TRANSPORTCATEGORY"
          label="运输类别"
          width="130"
        />
        <el-table-column prop="CREATETIME" label="创建时间" width="130" />
        <el-table-column label="操作" width="180">
          <template v-slot:default="{ row }">
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/safety_production_related/driving_log/drivingLog_info',
                  query: {
                    DRIVING_LOG_ID: row.DRIVING_LOG_ID,
                  },
                })
              "
            >
              查看
            </el-button>
            <el-button
              type="primary"
              text
              link
              @click="
                router.push({
                  path: '/safety_production_related/safety_meeting/add',
                })
              "
            >
              添加
            </el-button>
            <el-button
              type="danger"
              text
              link
              @click="deleteItem(row.DRIVING_LOG_ID)"
            >
              删除
            </el-button>
          </template>
        </el-table-column>
      </layout-table>
    </layout-card>
    <edit
      v-model:visible="data.analysisDialog.visible"
      :info="data.analysisDialog.info"
      @get-data="fnResetPagination"
    />
  </div>
</template>
<script setup>
import { serialNumber } from "@/assets/js/utils";
import useListData from "@/assets/js/useListData.js";
import { reactive } from "vue";
import {
  getSafetyDrivingLogList,
  setDrivingLogDelete,
} from "@/request/traffic_driving_log.js";
import router from "@/router/index.js";
import { ElMessage, ElMessageBox } from "element-plus";

const { list, pagination, searchForm, fnGetData, fnResetPagination } =
  useListData(getSafetyDrivingLogList);
const data = reactive({
  analysisDialog: {
    visible: false,
    info: {},
  },
});
// 删除事件
const deleteItem = async (value) => {
  await ElMessageBox.confirm(`确定要删除吗？`, {
    type: "warning",
  });
  await setDrivingLogDelete({ DRIVING_LOG_ID: value });
  ElMessage.success("删除成功");
  fnGetData();
};
</script>

<style scoped></style>
