gaoluyang
2025-07-01 4a716a9b964f760ee414f48a6998f6728b3a5c8d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParams" class="search-form">
      <el-form-item label="任务名称">
        <el-input
            v-model="queryParams.taskName"
            placeholder="请输入"
            clearable
            :style="{ width: '100%' }"
        />
      </el-form-item>
      <el-form-item label="设备名称">
        <el-input
            v-model="queryParams.deviceName"
            placeholder="请输入"
            clearable
            :style="{ width: '100%' }"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handleQuery">查询</el-button>
        <el-button @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-card>
      <!-- 标签页 -->
      <el-tabs
          v-model="activeTab"
          class="info-tabs"
          @tab-click="handleTabClick"
      >
        <el-tab-pane
            v-for="tab in tabs"
            :key="tab.name"
            :label="tab.label"
            :name="tab.name"
        />
      </el-tabs>
      <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">新建</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="tableColumns"
                  @selection-change="handleSelectionChange"
                  :show-selection="true"
                  :border="true"
                  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"
            :page-num="pageNum"
            :page-size="pageSize"
            :total="total"
            @pagination="handleQuery"
            :layout="'total, prev, pager, next, jumper'"
        />
      </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({
  taskName: "",
  deviceName: "",
})
// 当前标签
const activeTab = ref("task");
const tabName = ref("task");
// 标签页数据
const tabs = reactive([
  { 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: "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: "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(() => {
  radioChange('taskManage');
});
// 标签页点击
const handleTabClick = (tab) => {
  tabName.value = tab.props.name;
  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
  pageSize.value = 10
  getList()
}
const getList = () => {
  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;
    })
  }
  
  
};
// 重置查询
const resetQuery = () => {
  Object.keys(queryParams).forEach((key) => {
    if (key !== "pageNum" && key !== "pageSize") {
      queryParams[key] = "";
    }
  });
  handleQuery();
};
 
// 新增、编辑
const handleAdd = (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) {
    proxy.$modal.msgWarning("请选择要删除的数据");
    return;
  }
  const deleteIds = selectedRows.value.map(item => item.id);
  proxy.$modal.confirm('是否确认删除所选数据项?').then(function() {
    if (activeRadio.value === "taskManage") {
      return delTimingTask(deleteIds)
    } else {
      return delQrCode(deleteIds)
    }
  }).then(() => {
    handleQuery()
    proxy.$modal.msgSuccess("删除成功")
  }).catch(() => {})
};
// 选择行
const handleSelectionChange = (selection) => {
  selectedRows.value = selection;
};
</script>
 
<style scoped>
 
</style>