Browse Source

回显示excel

master
maochaoying 2 years ago
parent
commit
040f1b3bd1
  1. 14
      src/api/index.js
  2. 51
      src/components/Excel.vue
  3. 13
      src/components/Task.vue
  4. 18
      src/pages/index.vue
  5. 5
      src/store/modules/task.js

14
src/api/index.js

@ -6,3 +6,17 @@ export const getNuclearExcelApi = id => {
method: 'GET', method: 'GET',
}) })
} }
export const startAutoCheckApi = id => {
return request({
url: `/check/auto/${id}`,
method: 'GET',
})
}
export const breakOffAutoCheckApi = id => {
return request({
url: `/check/stop/${id}`,
method: 'GET',
})
}

51
src/components/Excel.vue

@ -4,7 +4,7 @@
<div v-if="isTableHeader(item)" class="table_header_box"> <div v-if="isTableHeader(item)" class="table_header_box">
{{ getHeaderText(item) }} {{ getHeaderText(item) }}
</div> </div>
<div class="box" v-else>
<div :class="getClass(item)" v-else>
<p class="line1">{{ getLine(item, 1) }}</p> <p class="line1">{{ getLine(item, 1) }}</p>
<p class="line2">{{ getLine(item, 2) }}</p> <p class="line2">{{ getLine(item, 2) }}</p>
</div> </div>
@ -20,6 +20,37 @@ const props = defineProps({
}, },
}) })
const getClass = index => {
// item
const arr = props.excelData.filter(item => item.num == index)
if (arr?.length > 0) {
const item = arr[0]
if (item.result == 1) {
//
return 'box success'
} else if (item.result == 2) {
//
return 'box fail'
} else if (item.result == 3) {
//
return 'box process'
} else {
//
if (canClick(index)) {
return 'box cur'
} else {
return 'box'
}
}
}
}
const canClick = item => {
if (getLine(item, 1) && getLine(item, 2)) {
return true
}
return false
}
const getLine = (index, position) => { const getLine = (index, position) => {
const arr = props.excelData.filter(item => item.num == index) const arr = props.excelData.filter(item => item.num == index)
if (arr?.length > 0) { if (arr?.length > 0) {
@ -78,6 +109,24 @@ const getHeaderText = index => {
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;
} }
.success {
cursor: pointer;
background: #e1fff1;
color: #01ff82;
}
.fail {
cursor: pointer;
background: #fee2e2;
color: #fe0c0c;
}
.process {
cursor: pointer;
background: #4350dc;
color: #ffffff;
}
.cur {
cursor: pointer;
}
.table_header_box { .table_header_box {
background: #f1f1f1; background: #f1f1f1;
box-sizing: border-box; box-sizing: border-box;

13
src/components/Task.vue

@ -49,6 +49,7 @@
<script lang="jsx"> <script lang="jsx">
import { taskListApi, delExcelByTaskIdApi, delTaskApi } from '@/api/task' import { taskListApi, delExcelByTaskIdApi, delTaskApi } from '@/api/task'
import { useAccountStore, useTaskStore } from '@/store' import { useAccountStore, useTaskStore } from '@/store'
import moment from 'moment'
import Cookie from '@/utils/cookie' import Cookie from '@/utils/cookie'
const accountStore = useAccountStore() const accountStore = useAccountStore()
const taskStore = useTaskStore() const taskStore = useTaskStore()
@ -68,6 +69,7 @@ export default {
{ {
colKey: 'publishTime', colKey: 'publishTime',
title: '发布时间', title: '发布时间',
cell: (h, { row }) => moment(row.publishTime).format('YYYY-MM-DD'),
}, },
{ {
colKey: 'nuclearStationName', colKey: 'nuclearStationName',
@ -83,7 +85,11 @@ export default {
title: '任务状态', title: '任务状态',
cell: (h, { row }) => { cell: (h, { row }) => {
if (row.status == 0) { if (row.status == 0) {
return <t-tag theme="success">开始任务</t-tag>
return (
<t-tag theme="success" onClick={() => this.startTask(row.id)}>
开始任务
</t-tag>
)
} else if (row.status == 1) { } else if (row.status == 1) {
return <t-tag theme="warning">进行中</t-tag> return <t-tag theme="warning">进行中</t-tag>
} else if (row.status == 2) { } else if (row.status == 2) {
@ -137,6 +143,11 @@ export default {
}, },
}, },
methods: { methods: {
startTask(taskId) {
accountStore.changePage(0)
taskStore.getExcelList(taskId)
taskStore.updateCurrentTaskId(taskId)
},
viewDetail(taskId) { viewDetail(taskId) {
accountStore.changePage(0) accountStore.changePage(0)
taskStore.getExcelList(taskId) taskStore.getExcelList(taskId)

18
src/pages/index.vue

@ -198,8 +198,11 @@
:class=" :class="
taskStore.currentTaskId == null ? 'auto_btn cant_btn' : 'auto_btn' taskStore.currentTaskId == null ? 'auto_btn cant_btn' : 'auto_btn'
" "
@click="startAutoCheck"
> >
<p class="title">[开启]自动核查</p>
<p class="title">
{{ taskStore.checkStatus ? '[暂停]自动核查' : '[开启]自动核查' }}
</p>
<div class="icon_box"> <div class="icon_box">
<svg <svg
xmlns="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg"
@ -263,9 +266,22 @@ import Task from 'cpns/Task'
import Publish from 'cpns/Publish' import Publish from 'cpns/Publish'
import User from 'cpns/User' import User from 'cpns/User'
import Debug from 'cpns/Debug' import Debug from 'cpns/Debug'
import { startAutoCheckApi, breakOffAutoCheckApi } from '@/api'
const accountStore = useAccountStore() const accountStore = useAccountStore()
const taskStore = useTaskStore() const taskStore = useTaskStore()
const startAutoCheck = async () => {
if (taskStore.checkStatus) {
taskStore.updateCheckStatus(false)
const res = await breakOffAutoCheckApi(taskStore.currentTaskId)
} else {
//
taskStore.updateCheckStatus(true)
//
const res = await startAutoCheckApi(taskStore.currentTaskId)
}
}
const role = computed(() => { const role = computed(() => {
return Cookie.getCookie('r') return Cookie.getCookie('r')
}) })

5
src/store/modules/task.js

@ -7,10 +7,15 @@ export const useTaskStore = defineStore({
type: 0, // 0为实时数据 1为历史数据 type: 0, // 0为实时数据 1为历史数据
excelData: [], excelData: [],
currentTaskId: null, currentTaskId: null,
// 核查按钮状态
checkStatus: false,
} }
}, },
// actions // actions
actions: { actions: {
updateCheckStatus(flag) {
this.checkStatus = flag
},
updateCurrentTaskId(currentTaskId) { updateCurrentTaskId(currentTaskId) {
this.currentTaskId = currentTaskId this.currentTaskId = currentTaskId
}, },

Loading…
Cancel
Save