|
@@ -1,17 +1,36 @@
|
|
|
<template>
|
|
<template>
|
|
|
<div class="alert-table-box">
|
|
<div class="alert-table-box">
|
|
|
- <el-table ref="multipleTableRef" :data="tableData" style="width: 100%" height="100%" stripe
|
|
|
|
|
- :cell-style="colorOfState" @selection-change="handleSelectionChange">
|
|
|
|
|
|
|
+ <el-table
|
|
|
|
|
+ ref="multipleTableRef"
|
|
|
|
|
+ :data="tableData"
|
|
|
|
|
+ style="width: 100%"
|
|
|
|
|
+ height="100%"
|
|
|
|
|
+ :cell-style="colorOfState"
|
|
|
|
|
+ :row-class-name="colorOfRow"
|
|
|
|
|
+ @select="handleShiftSelect"
|
|
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
|
|
+ @row-click="handleRowClick"
|
|
|
|
|
+ @sort-change="handleTimeSort"
|
|
|
|
|
+ :default-sort="{ prop: 'createdAt', order: 'descending' }"
|
|
|
|
|
+ >
|
|
|
<el-table-column type="selection" width="55"></el-table-column>
|
|
<el-table-column type="selection" width="55"></el-table-column>
|
|
|
- <el-table-column label="类型" prop="issueType" width="150">
|
|
|
|
|
|
|
+ <el-table-column label="类型" prop="issueType" width="180">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
{{ getNameByType(row.source, row.issueType) }}
|
|
{{ getNameByType(row.source, row.issueType) }}
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="问题描述" prop="description" width="400" show-overflow-tooltip>
|
|
|
|
|
|
|
+ <el-table-column label="问题描述" prop="description" width="280" show-overflow-tooltip>
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
<span>{{ getSplicedDes(row.description) }}</span>
|
|
<span>{{ getSplicedDes(row.description) }}</span>
|
|
|
- <span class="detail-text" @click="handleDetailClick(row)"> 详情</span>
|
|
|
|
|
|
|
+ <span
|
|
|
|
|
+ class="detail-text"
|
|
|
|
|
+ @click="
|
|
|
|
|
+ handleDetailClick(row);
|
|
|
|
|
+ $event.stopPropagation();
|
|
|
|
|
+ "
|
|
|
|
|
+ >
|
|
|
|
|
+ 详情</span
|
|
|
|
|
+ >
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="地点" prop="workspaceId" width="300">
|
|
<el-table-column label="地点" prop="workspaceId" width="300">
|
|
@@ -19,7 +38,12 @@
|
|
|
{{ getNameByWorkid(row.workshopId, row.workspaceId, locationOptions) }}
|
|
{{ getNameByWorkid(row.workshopId, row.workspaceId, locationOptions) }}
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
- <el-table-column label="时间" prop="createdAt" width="180"></el-table-column>
|
|
|
|
|
|
|
+ <el-table-column
|
|
|
|
|
+ label="时间"
|
|
|
|
|
+ prop="createdAt"
|
|
|
|
|
+ width="180"
|
|
|
|
|
+ sortable="custom"
|
|
|
|
|
+ ></el-table-column>
|
|
|
<el-table-column label="负责人" prop="personNameInCharge" width="100"></el-table-column>
|
|
<el-table-column label="负责人" prop="personNameInCharge" width="100"></el-table-column>
|
|
|
<el-table-column label="处理状态" prop="issueState">
|
|
<el-table-column label="处理状态" prop="issueState">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
@@ -28,7 +52,16 @@
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" width="60" fixed="right">
|
|
<el-table-column label="操作" width="60" fixed="right">
|
|
|
<template #default="{ row }">
|
|
<template #default="{ row }">
|
|
|
- <img src="/src/assets/images/alert/delete.png" alt="" title="点击删除问题数据" @click="handleDelete(row)">
|
|
|
|
|
|
|
+ <el-tooltip effect="dark" content="点击删除问题数据" placement="top">
|
|
|
|
|
+ <img
|
|
|
|
|
+ src="/src/assets/images/alert/delete.png"
|
|
|
|
|
+ alt=""
|
|
|
|
|
+ @click="
|
|
|
|
|
+ handleDelete(row);
|
|
|
|
|
+ $event.stopPropagation();
|
|
|
|
|
+ "
|
|
|
|
|
+ />
|
|
|
|
|
+ </el-tooltip>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
@@ -36,105 +69,197 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ElTable } from 'element-plus';
|
|
|
|
|
-import { onBeforeMount, ref } from 'vue';
|
|
|
|
|
-import { getNameByStateZJC } from './constant.question';
|
|
|
|
|
-import { useIssueType } from '../../hooks/useIssueType';
|
|
|
|
|
-import { useWorkLocation } from '../../hooks/useWorkLocation';
|
|
|
|
|
-
|
|
|
|
|
-const { getAIOptions, getManualOptions, getNameByType } = useIssueType();
|
|
|
|
|
-const { locationOptions, getLocationOptions, getNameByWorkid } = useWorkLocation();
|
|
|
|
|
-
|
|
|
|
|
-const multipleTableRef = ref<InstanceType<typeof ElTable>>();
|
|
|
|
|
-
|
|
|
|
|
-interface DataSourceItem {
|
|
|
|
|
- source: Number, // 问题单来源:1-AI检测、2-人工上报
|
|
|
|
|
- issueType: Number, // 问题单类型
|
|
|
|
|
- description: String, // 问题描述
|
|
|
|
|
- workspaceId: Number[], // 工位id(地点=车间+工位?)
|
|
|
|
|
- createdAt: String,
|
|
|
|
|
- personNameInCharge: String,
|
|
|
|
|
- issueState: Number, // 问题单状态:1-待审核、2-待处理、3-待复核、4-已退回、5-已处理
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-interface Props {
|
|
|
|
|
- tableData: Array<DataSourceItem>;
|
|
|
|
|
- onDetail: (row: DataSourceItem) => unknown; // 详情事件
|
|
|
|
|
- onDelete: (row: DataSourceItem) => unknown; // 删除按钮事件
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const props = defineProps<Props>();
|
|
|
|
|
-
|
|
|
|
|
-const emits = defineEmits(['update:selection'])
|
|
|
|
|
-const handleSelectionChange = (selection: any[]) => {
|
|
|
|
|
- emits("update:selection", selection);
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const handleDetailClick = (row) => {
|
|
|
|
|
- props.onDetail(row);
|
|
|
|
|
-};
|
|
|
|
|
-const handleDelete = (row) => {
|
|
|
|
|
- props.onDelete(row);
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
-const getSplicedDes = (val) => {
|
|
|
|
|
- if (val.length < 20) return val;
|
|
|
|
|
- else {
|
|
|
|
|
- const temp = val.substring(0, 20);
|
|
|
|
|
- return temp + '…';
|
|
|
|
|
|
|
+ import { ElTable } from 'element-plus';
|
|
|
|
|
+ import { onBeforeMount, onMounted, ref } from 'vue';
|
|
|
|
|
+ import { getNameByStateZJC } from './constant.question';
|
|
|
|
|
+ import { useIssueType } from '../../hooks/useIssueType';
|
|
|
|
|
+ import { useWorkLocation } from '../../hooks/useWorkLocation';
|
|
|
|
|
+
|
|
|
|
|
+ const { getAIOptions, getManualOptions, getNameByType } = useIssueType();
|
|
|
|
|
+ const { locationOptions, getLocationOptions, getNameByWorkid } = useWorkLocation();
|
|
|
|
|
+
|
|
|
|
|
+ const multipleTableRef = ref<InstanceType<typeof ElTable>>();
|
|
|
|
|
+
|
|
|
|
|
+ export interface DataSourceItem {
|
|
|
|
|
+ index: Number;
|
|
|
|
|
+ id: Number;
|
|
|
|
|
+ source: Number; // 问题单来源:1-AI检测、2-人工上报
|
|
|
|
|
+ issueType: Number; // 问题单类型
|
|
|
|
|
+ description: String; // 问题描述
|
|
|
|
|
+ workspaceId: Number[]; // 工位id(地点=车间+工位?)
|
|
|
|
|
+ createdAt: String;
|
|
|
|
|
+ personNameInCharge: String;
|
|
|
|
|
+ issueState: Number; // 问题单状态:1-待审核、2-待处理、3-待复核、4-已退回、5-已处理
|
|
|
}
|
|
}
|
|
|
-};
|
|
|
|
|
|
|
|
|
|
-const colorOfState = ({ row, columnIndex }) => {
|
|
|
|
|
- if (columnIndex === 6) {
|
|
|
|
|
- if (row.issueState === 7 || row.issueState === 8) return { color: "#52C41A " };
|
|
|
|
|
- else return { color: "#FF4D4F" };
|
|
|
|
|
- };
|
|
|
|
|
- if (row.isHide) {
|
|
|
|
|
- return { color: "#A8ABB2" };
|
|
|
|
|
|
|
+ interface Props {
|
|
|
|
|
+ tableData: Array<DataSourceItem>;
|
|
|
|
|
+ onDetail: (row: DataSourceItem) => unknown; // 详情事件
|
|
|
|
|
+ onDelete: (row: DataSourceItem) => unknown; // 删除按钮事件
|
|
|
}
|
|
}
|
|
|
-};
|
|
|
|
|
|
|
|
|
|
-const clearAll = () => {
|
|
|
|
|
- multipleTableRef.value!.clearSelection();
|
|
|
|
|
-};
|
|
|
|
|
|
|
+ const props = defineProps<Props>();
|
|
|
|
|
+
|
|
|
|
|
+ const emits = defineEmits(['update:selection', 'update:timeSort']);
|
|
|
|
|
+
|
|
|
|
|
+ const startPoint = ref<number | undefined>();
|
|
|
|
|
+ const endPoint = ref<number | undefined>();
|
|
|
|
|
+ const shiftKeyBoard = ref(false); // shift按钮按住/松开
|
|
|
|
|
+
|
|
|
|
|
+ const selections = ref<DataSourceItem[]>([]);
|
|
|
|
|
+ const handleSelectionChange = (selection: any[]) => {
|
|
|
|
|
+ selections.value = selection;
|
|
|
|
|
+ emits('update:selection', selection);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleShiftSelect = (_, row) => {
|
|
|
|
|
+ props.tableData.forEach((item, index) => {
|
|
|
|
|
+ item.index = index;
|
|
|
|
|
+ });
|
|
|
|
|
+ // 按住shift
|
|
|
|
|
+ if (shiftKeyBoard.value) {
|
|
|
|
|
+ // 有起点startPoint
|
|
|
|
|
+ if (startPoint.value !== undefined) {
|
|
|
|
|
+ endPoint.value = row.index as number;
|
|
|
|
|
+ if (startPoint.value > endPoint.value) {
|
|
|
|
|
+ let temp = startPoint.value;
|
|
|
|
|
+ startPoint.value = endPoint.value;
|
|
|
|
|
+ endPoint.value = temp;
|
|
|
|
|
+ }
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ for (let i = startPoint.value as number; i < (endPoint.value as number); i++) {
|
|
|
|
|
+ multipleTableRef.value!.toggleRowSelection(props.tableData[i], true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, 100);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 没有起点startPoint
|
|
|
|
|
+ else {
|
|
|
|
|
+ startPoint.value = row.index;
|
|
|
|
|
+ endPoint.value = undefined;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ // 没按住shift
|
|
|
|
|
+ else {
|
|
|
|
|
+ startPoint.value = row.index;
|
|
|
|
|
+ endPoint.value = undefined;
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const rowClickSelections = ref<DataSourceItem[]>([]);
|
|
|
|
|
+ const handleRowClick = (row) => {
|
|
|
|
|
+ if (rowClickSelections.value.find((item) => item.id === row.id)) {
|
|
|
|
|
+ let index = rowClickSelections.value.findIndex((item) => item.id === row.id);
|
|
|
|
|
+ rowClickSelections.value.splice(index, 1);
|
|
|
|
|
+ multipleTableRef.value!.toggleRowSelection(row, false);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ rowClickSelections.value.push(row);
|
|
|
|
|
+ multipleTableRef.value!.toggleRowSelection(row, true);
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleDetailClick = (row) => {
|
|
|
|
|
+ props.onDetail(row);
|
|
|
|
|
+ };
|
|
|
|
|
+ const handleDelete = (row) => {
|
|
|
|
|
+ props.onDelete(row);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const handleTimeSort = (column) => {
|
|
|
|
|
+ let curTimeSort = '';
|
|
|
|
|
+ if (column.order === 'ascending') curTimeSort = 'asc';
|
|
|
|
|
+ if (column.order === 'descending') curTimeSort = 'desc';
|
|
|
|
|
+ emits('update:timeSort', curTimeSort);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const getSplicedDes = (val) => {
|
|
|
|
|
+ if (val.length < 15) return val;
|
|
|
|
|
+ else {
|
|
|
|
|
+ const temp = val.substring(0, 14);
|
|
|
|
|
+ return temp + '…';
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const colorOfState = ({ row, columnIndex }) => {
|
|
|
|
|
+ if (columnIndex === 6) {
|
|
|
|
|
+ if (row.issueState === 7 || row.issueState === 8) return { color: '#52C41A ' };
|
|
|
|
|
+ else return { color: '#FF4D4F' };
|
|
|
|
|
+ }
|
|
|
|
|
+ if (row.isHide) {
|
|
|
|
|
+ return { color: '#A8ABB2' };
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const colorOfRow = ({ row }) => {
|
|
|
|
|
+ if (selections.value.includes(row)) {
|
|
|
|
|
+ return 'selected-row';
|
|
|
|
|
+ }
|
|
|
|
|
+ return '';
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ const clearAll = () => {
|
|
|
|
|
+ multipleTableRef.value!.clearSelection();
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ // 改变当前打开详情的表格行的选中状态
|
|
|
|
|
+ const updateCurRowChosen = (row, status: boolean) => {
|
|
|
|
|
+ multipleTableRef.value!.toggleRowSelection(row, status);
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ defineExpose({ clearAll, updateCurRowChosen });
|
|
|
|
|
|
|
|
-defineExpose({ clearAll })
|
|
|
|
|
|
|
+ onBeforeMount(() => {
|
|
|
|
|
+ getAIOptions();
|
|
|
|
|
+ getManualOptions();
|
|
|
|
|
+ getLocationOptions();
|
|
|
|
|
+ });
|
|
|
|
|
|
|
|
-onBeforeMount(() => {
|
|
|
|
|
- getAIOptions();
|
|
|
|
|
- getManualOptions();
|
|
|
|
|
- getLocationOptions();
|
|
|
|
|
-});
|
|
|
|
|
|
|
+ onMounted(() => {
|
|
|
|
|
+ window.addEventListener('keydown', (code) => {
|
|
|
|
|
+ if (code.shiftKey) {
|
|
|
|
|
+ shiftKeyBoard.value = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ window.addEventListener('keyup', (code) => {
|
|
|
|
|
+ if (!code.shiftKey) {
|
|
|
|
|
+ shiftKeyBoard.value = false;
|
|
|
|
|
+ startPoint.value = -1;
|
|
|
|
|
+ endPoint.value = -1;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
-<style scoped lang="scss">
|
|
|
|
|
-.alert-table-box {
|
|
|
|
|
- display: flex;
|
|
|
|
|
- flex-direction: column;
|
|
|
|
|
- height: calc(100vh - 290px);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-.detail-text {
|
|
|
|
|
- color: #1890FF;
|
|
|
|
|
- font-weight: 500;
|
|
|
|
|
- cursor: pointer;
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-:deep(.el-table-fixed-column--right) {
|
|
|
|
|
- .cell {
|
|
|
|
|
|
|
+<style scoped lang="less">
|
|
|
|
|
+ .alert-table-box {
|
|
|
display: flex;
|
|
display: flex;
|
|
|
|
|
+ flex-direction: column;
|
|
|
|
|
+ height: calc(100vh - 290px);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- img {
|
|
|
|
|
- margin-right: 20px;
|
|
|
|
|
|
|
+ .detail-text {
|
|
|
|
|
+ color: #1890ff;
|
|
|
|
|
+ font-weight: 500;
|
|
|
cursor: pointer;
|
|
cursor: pointer;
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
|
|
|
-:deep(.el-table) {
|
|
|
|
|
- ::before {
|
|
|
|
|
- height: 0px;
|
|
|
|
|
|
|
+ :deep(.el-table-fixed-column--right) {
|
|
|
|
|
+ .cell {
|
|
|
|
|
+ display: flex;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ img {
|
|
|
|
|
+ margin-right: 20px;
|
|
|
|
|
+ cursor: pointer;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ :deep(.el-table) {
|
|
|
|
|
+ ::before {
|
|
|
|
|
+ height: 0px;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .selected-row {
|
|
|
|
|
+ background: #f3f8ff;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
-</style>
|
|
|
|
|
|
|
+</style>
|