gaoluyang
2025-07-01 049dd638c4de83fd8415c258c29d9ef71fd58141
src/views/inspectionManagement/index.vue
@@ -1,18 +1,10 @@
<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParams" class="search-form">
      <el-form-item label="供应商名称">
      <el-form-item label="搜索">
        <el-input
            v-model="queryParams.supplierName"
            placeholder="请输入"
            clearable
            :style="{ width: '100%' }"
        />
      </el-form-item>
      <el-form-item label="煤种">
        <el-input
            v-model="queryParams.coal"
            placeholder="请输入"
            v-model="queryParams.searchAll"
            placeholder="请输入关键字"
            clearable
            :style="{ width: '100%' }"
        />
@@ -36,22 +28,55 @@
            :name="tab.name"
        />
      </el-tabs>
      <!-- 操作按钮区 -->
      <el-space>
        <el-button type="primary" :icon="Plus" @click="handleAdd">新建</el-button>
        <el-button type="danger" :icon="Delete" @click="handleDelete">删除</el-button>
        <el-button type="info" plain :icon="Download">导出</el-button>
      </el-space>
      <div style="display: flex;flex-direction: row;justify-content: space-between;" v-if="tabName === 'task'">
        <el-radio-group v-model="activeRadio" @change="radioChange">
          <el-radio-button v-for="tab in radios"
                           :key="tab.name"
                           :label="tab.label"
                           :value="tab.name"/>
        </el-radio-group>
        <!-- 操作按钮区 -->
        <el-space v-if="activeRadio !== 'task'">
          <el-button type="primary" :icon="Plus" @click="handleAdd(undefined)">新建</el-button>
          <el-button type="danger" :icon="Delete" @click="handleDelete">删除</el-button>
          <!-- <el-button type="info" plain :icon="Download">导出</el-button> -->
        </el-space>
      </div>
      <div>
        <div>
          <ETable :loading="tableLoading"
                  :table-data="tableData"
                  :columns="columns"
                  :columns="tableColumns"
                  @selection-change="handleSelectionChange"
                  :show-selection="true"
                  :border="true"
                  :maxHeight="480"
                  @edit="handleAdd"></ETable>
                  style="width: 100%;height: calc(100vh - 30em)"
                  operationsWidth="130"
                  :operations="operationsArr"
                  @edit="handleAdd"
                  @viewFile="viewFile"
                  v-if="tabName === 'task'"
          ></ETable>
          <el-table ref="table" :data="tableData" height="480" v-loading="tableLoading" border v-else style="width: 100%;height: calc(100vh - 25em)">
            <el-table-column label="序号" type="index" width="60" align="center" />
            <el-table-column prop="deviceName" label="设备名称" :show-overflow-tooltip="true">
              <template #default="scope">
                {{scope.row.qrCode.deviceName}}
              </template>
            </el-table-column>
            <el-table-column prop="location" label="所在位置描述" :show-overflow-tooltip="true">
              <template #default="scope">
                {{scope.row.qrCode.location}}
              </template>
            </el-table-column>
            <el-table-column prop="scanner" label="巡检人"></el-table-column>
            <el-table-column prop="scanTime" label="巡检时间"></el-table-column>
            <el-table-column fixed="right" label="操作">
              <template #default="scope">
                <el-button link type="primary" @click="handleAdd(scope.row)">查看附件</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <pagination
            v-if="total>0"
@@ -63,56 +88,93 @@
        />
      </div>
    </el-card>
    <form-dia ref="formDia" @closeDia="handleQuery"></form-dia>
    <qr-code-dia ref="qrCodeDia" @closeDia="handleQuery"></qr-code-dia>
    <view-files ref="viewFiles"></view-files>
    <view-qr-code-files ref="viewQrCodeFiles"></view-qr-code-files>
  </div>
</template>
<script setup>
import {Download, Delete, Plus} from "@element-plus/icons-vue";
import {onMounted, ref} from "vue";
const { proxy } = getCurrentInstance()
import Pagination from "@/components/Pagination/index.vue";
import ETable from "@/components/Table/ETable.vue";
import FormDia from "@/views/inspectionManagement/components/formDia.vue";
import QrCodeDia from "@/views/inspectionManagement/components/qrCodeDia.vue";
import {
  delInspectionTask,
  delTimingTask,
  inspectionTaskList,
  timingTaskList
} from "@/api/inspectionManagement/index.js";
import ViewFiles from "@/views/inspectionManagement/components/viewFiles.vue";
import {delQrCode, qrCodeList, qrCodeScanRecordList} from "@/api/inspectionUpload/index.js";
import ViewQrCodeFiles from "@/views/inspectionManagement/components/viewQrCodeFiles.vue";
const formDia = ref()
const qrCodeDia = ref()
const viewFiles = ref()
const viewQrCodeFiles = ref()
// 查询参数
const queryParams = reactive({
  supplierName: "",
  coal: "",
  searchAll: "",
})
// 当前标签
const activeTab = ref("task");
const tabName = ref("qrCode");
const tabName = ref("task");
// 标签页数据
const tabs = reactive([
  { name: "task", label: "任务下发" },
  { name: "task", label: "生产巡检" },
  { name: "qrCodeScanRecord", label: "现场巡检记录" },
]);
// 单选框
const activeRadio = ref("taskManage");
const radios = reactive([
  { name: "taskManage", label: "定时任务管理" },
  { name: "task", label: "定时任务记录" },
  { name: "qrCode", label: "二维码管理" },
]);
// 表格
const selectedRows = ref([]);
const tableData = ref([]);
const operationsArr = ref([]);
const tableColumns = ref([]);
const tableLoading = ref(false);
const total = ref(0);
const pageNum = ref(1);
const pageSize = ref(10);
const columns = ref([
  { prop: "saleDate", label: "销售日期", minWidth: 160 },
  { prop: "customer", label: "客户", minWidth: 120 },
  { prop: "coal", label: "煤种", minWidth: 150 },
  { prop: "unit", label: "单位", minWidth: 150 },
  { prop: "priceIncludingTax", label: "单价(含税)", minWidth: 150 },
  { prop: "inventoryQuantity", label: "库存数量", minWidth: 120 },
  { prop: "saleQuantity", label: "销售数量", minWidth: 120 },
  { prop: "salePrice", label: "销售单价(含税)", minWidth: 150 },
  { prop: "totalAmount", label: "销售总价(含税)", minWidth: 120 },
  { prop: "freight", label: "运费", minWidth: 90 },
  { prop: "taxCoal", label: "购销煤税率(%)", minWidth: 120 },
  { prop: "taxTrans", label: "运输税率(%)", minWidth: 120 },
  { prop: "grossProfit", label: "毛利润", minWidth: 90 },
  { prop: "netProfit", label: "净利润", minWidth: 90 },
  { prop: "taskName", label: "巡检任务名称", minWidth: 160 },
  { prop: "inspectionLocation", label: "地点", minWidth: 120 },
  { prop: "remarks", label: "备注", minWidth: 150 },
  { prop: "inspector", label: "执行巡检人", minWidth: 150 },
  { prop: "frequencyType", label: "频次", minWidth: 150,
    formatter: (row, column, cellValue) => {
    if (cellValue === 'DAILY') {
      return '每日';
    } else if (cellValue === 'MONTHLY') {
      return '每月';
    } else if (cellValue === 'WEEKLY') {
      return '每周';
    } else {
      return '季度'
    }
    }},
  { prop: "frequencyDetail", label: "开始日期与时间", minWidth: 150 },
  { prop: "registrant", label: "登记人", minWidth: 100 },
  { prop: "registrationDate", label: "登记日期", minWidth: 100 },
  { prop: "createTime", label: "登记日期", minWidth: 100 },
]);
const columns1 = ref([
  { prop: "deviceName", label: "设备名称", minWidth: 160 },
  { prop: "location", label: "所在位置描述", minWidth: 120 },
  { prop: "createBy", label: "创建者", minWidth: 100 },
  { prop: "createTime", label: "创建时间", minWidth: 100 },
]);
onMounted(() => {
  handleTabClick({ props: { name: "task" } });
  radioChange('taskManage');
});
// 标签页点击
const handleTabClick = (tab) => {
@@ -120,6 +182,19 @@
  tableData.value = [];
  getList();
};
const radioChange = (value) => {
  if (value === "taskManage") {
    tableColumns.value = columns.value;
    operationsArr.value = ['edit']
  } else if (value === "task") {
    tableColumns.value = columns.value;
    operationsArr.value = ['viewFile']
  } else {
    tableColumns.value = columns1.value;
    operationsArr.value = ['edit']
  }
  getList();
}
// 点击查询
const handleQuery = () => {
  pageNum.value = 1
@@ -127,7 +202,35 @@
  getList()
}
const getList = () => {
  // tableLoading.value = true;
  tableLoading.value = true;
  if (tabName.value === 'task') {
    if (activeRadio.value === "task") {
      inspectionTaskList({...queryParams, size: pageSize.value, current: pageNum.value}).then(res => {
        tableLoading.value = false;
        tableData.value = res.data.records;
        total.value = res.data.total;
      })
    } else if (activeRadio.value === "qrCode") {
      qrCodeList({...queryParams, size: pageSize.value, current: pageNum.value}).then(res => {
        tableLoading.value = false;
        tableData.value = res.data.records;
        total.value = res.data.total;
      })
    } else {
      timingTaskList({...queryParams, size: pageSize.value, current: pageNum.value}).then(res => {
        tableLoading.value = false;
        tableData.value = res.data.records;
        total.value = res.data.total;
      })
    }
  } else {
    qrCodeScanRecordList({size: pageSize.value, current: pageNum.value}).then(res => {
      tableLoading.value = false;
      tableData.value = res.data.records;
      total.value = res.data.total;
    })
  }
  
};
// 重置查询
@@ -142,8 +245,26 @@
// 新增、编辑
const handleAdd = (row) => {
  console.log(row)
  const type = row === undefined ? 'add' : 'edit'
  nextTick(() => {
    if (tabName.value === 'task') {
      if (activeRadio.value === "taskManage") {
        formDia.value?.openDialog(type, row)
      } else if (activeRadio.value === "qrCode") {
        qrCodeDia.value?.openDialog(type, row)
      }
    } else {
      viewQrCodeFiles.value?.openDialog(row)
    }
  })
};
// 查看附件
const viewFile = (row) => {
  nextTick(() => {
    viewFiles.value?.openDialog(row)
  })
}
// 删除任务
const handleDelete = () => {
  if (selectedRows.value.length === 0) {
@@ -152,7 +273,11 @@
  }
  const deleteIds = selectedRows.value.map(item => item.id);
  proxy.$modal.confirm('是否确认删除所选数据项?').then(function() {
    return delSalesRecord(deleteIds)
    if (activeRadio.value === "taskManage") {
      return delTimingTask(deleteIds)
    } else {
      return delQrCode(deleteIds)
    }
  }).then(() => {
    handleQuery()
    proxy.$modal.msgSuccess("删除成功")