267 lines
7.5 KiB
Plaintext
267 lines
7.5 KiB
Plaintext
<script setup lang="ts">
|
|
import HomeHead from '@/views/home/components/HomeHead.vue'
|
|
// import HomeHeadSearch from '@/views/home/components/HomeHeadSearch.vue'
|
|
import { NModal, useMessage } from 'naive-ui'
|
|
import { getCateList, editCateItem,getCateItemList,deleteCateItem ,getLabActList} from '@/api/daikin/base'
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
import { useDate } from '@/views/home/hooks/useDate'
|
|
import { useMyStore } from '@/stores/modules/mystor'
|
|
|
|
const myStore = useMyStore();
|
|
const message = useMessage()
|
|
const store = useUserStore()
|
|
const header = { 'token': store.user.token }
|
|
const userCode = ['admin', 'theme_dandang', 'tech_service'].includes(store.user.roleCode)
|
|
const { day, week } = useDate()
|
|
const route = useRoute()
|
|
const { push } = useRouter()
|
|
|
|
const dataA = ref([])
|
|
|
|
|
|
const shomkA = ref(false)
|
|
|
|
const actMidIsSelects=ref()
|
|
const activeName = ref()
|
|
const tabsList = ref()
|
|
const cateIds = ref()
|
|
const starId = ref()
|
|
const state = reactive<any>({
|
|
pageNum: 1,
|
|
cateId:route.params.id!==':id'?route.params.id:starId.value,
|
|
})
|
|
|
|
onMounted(async () => {
|
|
const { data } = await getLabActList()
|
|
actMidIsSelects.value = data.actMidIsSelect
|
|
const indexId = myStore.data
|
|
console.log(indexId)
|
|
const { data: dataBot } = await getCateList({indexId})
|
|
|
|
tabsList.value = dataBot
|
|
if(dataBot.length>0){
|
|
starId.value = dataBot[0].id
|
|
|
|
}
|
|
|
|
console.log(starId.value)
|
|
cateIds.value = route.params.id
|
|
activeName.value = route.params.id!==':id'?route.params.id:starId.value+''
|
|
|
|
})
|
|
async function getItemList() {
|
|
const {rows} =await getCateItemList(state)
|
|
dataA.value = rows
|
|
}
|
|
|
|
const ss = computed(() => [state.pageNum, state.cateId])
|
|
watch(() => unref(ss),
|
|
async (v) => {
|
|
getItemList()
|
|
},
|
|
{ immediate: true, deep: true },
|
|
)
|
|
|
|
const handleClick = (tab: TabsPaneContext, event: Event) => {
|
|
state.cateId = tab.props.label
|
|
cateIds.value = tab.props.label
|
|
starId.value = tab.props.label
|
|
console.log(tab.props.label)
|
|
}
|
|
|
|
const editA = ref({
|
|
id: '',
|
|
title: '',
|
|
cateId: '',
|
|
fileList: []
|
|
})
|
|
|
|
async function onSubmit(row: { id: number; url: any; title: string; time: string; dowhat: string; files: never[]; fileList: never[] }) {
|
|
console.log(row)
|
|
|
|
const { id, title, fileList } = row
|
|
const cateId = cateIds.value===':id'?activeName.value:cateIds.value
|
|
let filePath
|
|
console.log(cateId)
|
|
if (fileList && fileList.length > 0) {
|
|
filePath = fileList.map(file => {
|
|
if(file.response){
|
|
return file.response.url
|
|
}
|
|
else{
|
|
return file.url
|
|
}
|
|
}).join(',')
|
|
}
|
|
console.log({id,title,cateId,filePath})
|
|
if(cateId&&cateId=='undefined'){
|
|
message.error("请先添加类别!")
|
|
return
|
|
}
|
|
const { code, msg } = await editCateItem({ id, title, cateId, filePath })
|
|
if (code === 200) { message.success("添加成功!") }
|
|
else { message.error(msg) }
|
|
|
|
window.location.reload();
|
|
shomkA.value = false
|
|
}
|
|
|
|
const handleEdit = (row: any) => {
|
|
console.log(row)
|
|
row.fileList = row.filePathList.map(item=>Object.assign(item,{
|
|
name:item.originalFileName
|
|
}))
|
|
shomkA.value = true
|
|
if (!row) return
|
|
editA.value = row
|
|
|
|
}
|
|
async function handleDelete(obj) {
|
|
const {id} = obj
|
|
const { code,msg} =await deleteCateItem({id})
|
|
if (code === 200) { message.success("删除成功!") }
|
|
else { message.error(msg) }
|
|
window.location.reload();
|
|
}
|
|
|
|
|
|
async function downloadFile(data) {
|
|
// console.log(data)
|
|
if(actMidIsSelects.value===2){
|
|
message.info("没有访问权限")
|
|
return
|
|
}
|
|
const url = data.it.url
|
|
|
|
try {
|
|
const response = await fetch(url);
|
|
const blob = await response.blob();
|
|
|
|
const downloadUrl = URL.createObjectURL(blob);
|
|
const link = document.createElement('a');
|
|
link.href = downloadUrl;
|
|
link.download = data.it.originalFileName; // 替换为你要保存的文件名
|
|
link.click();
|
|
URL.revokeObjectURL(downloadUrl);
|
|
} catch (error) {
|
|
message.error('下载文件出错:', error);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</script>
|
|
<template>
|
|
<HomeHead class="top">
|
|
<!-- <template #content>
|
|
<HomeHeadSearch />
|
|
</template> -->
|
|
</HomeHead>
|
|
<div class="h-full relative flex flex-col">
|
|
<div class="font-600 flex items-end mt30px">
|
|
<!-- <el-button v-if="userCode" type="primary" class="button"
|
|
@click="push({ name: 'DiffspaceTabModify' })">管理</el-button> -->
|
|
<div class="text-36px">差别化课题</div>
|
|
<div class="text-18px ml40px mr25px">{{ day }}</div>
|
|
<div class="text-18px">{{ week }}</div>
|
|
</div>
|
|
<div class="q-wrapper flex-1 mt30px text-#142142 flex flex-col bg-#fff p30px rounded-20px">
|
|
<el-tabs v-model="activeName" @tab-click="handleClick">
|
|
<el-tab-pane v-for="(item,ind) in tabsList" :label="item.id" :name="item.id+''" :index="item.id">
|
|
<template #label>
|
|
<span class="custom-tabs-label">
|
|
<span class="text-20px">{{ item.cateName }}</span>
|
|
</span>
|
|
</template>
|
|
</el-tab-pane>
|
|
</el-tabs>
|
|
|
|
<div>
|
|
<div v-if="dataA" v-for="iet in dataA" class="py25px px10px text-18px ">
|
|
<span class="content">{{iet.title}}</span>
|
|
<el-dropdown max-height="100px" @command="downloadFile" class="top--5px w50px block float-left">
|
|
<el-icon size="25" color="#0054E4">
|
|
<CaretBottom />
|
|
</el-icon>
|
|
|
|
<template #dropdown>
|
|
<el-dropdown-menu>
|
|
<el-dropdown-item v-if="iet.filePathList" v-for="it in iet.filePathList"
|
|
:command="{ it }">{{ it.originalFileName }}</el-dropdown-item>
|
|
</el-dropdown-menu>
|
|
</template>
|
|
</el-dropdown>
|
|
<!--
|
|
<div v-if="userCode" class="w120px block float-right">
|
|
<el-button size="small" @click="handleEdit(iet)">编辑</el-button>
|
|
<el-button size="small" type="danger" @click="handleDelete(iet)">删除</el-button>
|
|
</div> -->
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
<!-- <el-button v-if="userCode" type="primary" class="" @click="shomkA = !shomkA">新增内容</el-button> -->
|
|
</div>
|
|
<n-modal v-model:show="shomkA">
|
|
<div class="bg-#FFF p30px">
|
|
<el-form :model="editA" label-width="120px" :inline="true">
|
|
|
|
|
|
<br>
|
|
<el-form-item label="标题">
|
|
<el-input v-model="editA.title" />
|
|
</el-form-item>
|
|
|
|
<br>
|
|
<el-form-item label="文件">
|
|
<el-upload v-model:file-list="editA.fileList" class="upload-demo" :headers="header"
|
|
action="/test-api/common/upload">
|
|
<el-button type="primary">选择文件</el-button>
|
|
|
|
</el-upload>
|
|
</el-form-item>
|
|
</el-form>
|
|
<hr class="mb15px border-#f1f1f1">
|
|
<el-form-item>
|
|
<el-button type="primary" @click="onSubmit(editA)">确认</el-button>
|
|
</el-form-item>
|
|
</div>
|
|
</n-modal>
|
|
</template>
|
|
<style lang="less">
|
|
.el-tabs__content{
|
|
padding: 0;
|
|
}
|
|
.content{
|
|
display: block;
|
|
max-width:1100px;
|
|
float: left;
|
|
white-space: nowrap;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
}
|
|
.top {
|
|
position: absolute;
|
|
right: 30px;
|
|
top: -92px;
|
|
}
|
|
|
|
.button {
|
|
position: absolute;
|
|
top: 0px;
|
|
right: 20px;
|
|
z-index: 500;
|
|
}
|
|
</style> |