Browse Source

详情页面

master
maochaoying 2 years ago
parent
commit
da4f018bc4
  1. 10
      src/components/Task.vue
  2. 32
      src/pages/index.vue
  3. 3
      src/store/index.js
  4. 32
      src/store/modules/task.js

10
src/components/Task.vue

@ -48,7 +48,10 @@
<script lang="jsx">
import { taskListApi, delExcelByTaskIdApi, delTaskApi } from '@/api/task'
import { useAccountStore, useTaskStore } from '@/store'
import Cookie from '@/utils/cookie'
const accountStore = useAccountStore()
const taskStore = useTaskStore()
export default {
data() {
return {
@ -108,6 +111,9 @@ export default {
>
上传Excel
</t-button>
<t-button onClick={() => this.viewDetail(row.id)}>
查看详情
</t-button>
</div>
),
},
@ -120,6 +126,10 @@ export default {
},
},
methods: {
viewDetail(taskId) {
accountStore.changePage(0)
taskStore.getExcelList(taskId)
},
handleSuccess({ response }) {
console.log(response)
if (response?.code == 200) {

32
src/pages/index.vue

@ -2,7 +2,7 @@
<div class="home_container">
<div class="header_container">
<svg
@click="accountStore.changePage(0)"
@click="clickLogo"
class="logo"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
@ -43,7 +43,7 @@
</g>
</svg>
<div class="menu_list">
<div class="menu" @click="accountStore.changePage(1)">
<div class="menu" @click="clickTaskTab">
<svg
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
@ -191,7 +191,7 @@
<div class="main_content" v-if="accountStore.activePage == 0">
<div class="two_content_container">
<Image />
<Excel :excelData="excelData" />
<Excel :excelData="taskStore.excelData" />
</div>
<div class="bottom_operation_container ignore-height">
<div class="auto_btn">
@ -249,7 +249,7 @@
</template>
<script setup>
import { useAccountStore } from '@/store'
import { useAccountStore, useTaskStore } from '@/store'
import Cookie from '@/utils/cookie'
import { ref, onMounted, computed } from 'vue'
import Excel from 'cpns/Excel'
@ -261,30 +261,30 @@ import User from 'cpns/User'
import Debug from 'cpns/Debug'
import { getNuclearExcelApi } from '@/api'
const accountStore = useAccountStore()
const taskStore = useTaskStore()
const role = computed(() => {
return Cookie.getCookie('r')
})
const clickLogo = () => {
accountStore.changePage(0)
taskStore.updateType(0)
}
const clickTaskTab = () => {
accountStore.changePage(1)
taskStore.updateType(1)
}
const logout = () => {
accountStore.clearLoginInfo()
Cookie.clearAllCookie()
window.location.href = '/login'
}
const excelData = ref([])
onMounted(async () => {
const res = await getNuclearExcelApi(1)
if (res?.code == 200) {
// dataserialNumber
const list = res.data.list
list.map(item => {
const arr = item.serialNumber.split('-')
item.num = parseInt(arr[0]) * 14 + parseInt(arr[1]) + 1
})
excelData.value = list
}
taskStore.getExcelList(1)
})
</script>

3
src/store/index.js

@ -1,6 +1,7 @@
import { createPinia } from 'pinia'
import { useAccountStore } from './modules/account'
import { useTaskStore } from './modules/task'
const store = createPinia()
export default store
export { useAccountStore }
export { useAccountStore, useTaskStore }

32
src/store/modules/task.js

@ -0,0 +1,32 @@
import { defineStore } from 'pinia'
import { getNuclearExcelApi } from '@/api'
export const useTaskStore = defineStore({
id: 'task', // id必填,且需要唯一
state: () => {
return {
type: 0, // 0为实时数据 1为历史数据
excelData: [],
}
},
// actions
actions: {
updateType(type) {
this.type = type
},
updateExcelData(excelData) {
this.excelData = excelData
},
async getExcelList(taskId) {
const res = await getNuclearExcelApi(taskId)
if (res?.code == 200) {
// 根据data的serialNumber算出序列号
const list = res.data.list
list.map(item => {
const arr = item.serialNumber.split('-')
item.num = parseInt(arr[0]) * 14 + parseInt(arr[1]) + 1
})
this.excelData = list
}
},
},
})
Loading…
Cancel
Save