daikins/.svn/pristine/62/620ac51891b1193f26b98b76018...

469 lines
17 KiB
Plaintext

<script setup lang="ts">
import AppBlock from '@/components/AppBlock.vue'
import { useMessage, NModal, } from 'naive-ui'
import HomeHead from '@/views/home/components/HomeHead.vue'
// import { getImg } from './images'
import { Plus } from '@element-plus/icons-vue'
import type { UploadProps, UploadUserFile } from 'element-plus'
import { useUserStore } from '@/stores/modules/user'
import { getBPCActList, getDetailBPC,updateBPC,addBPC } from '@/api/daikin/base'
const fuckList1 = ref([])
const fuckList2 = ref([])
const fuckList3 = ref([])
const fuckList4 = ref([])
const ids = ref('')
const {push} = useRouter()
onBeforeMount(async () => {
const {data} = await getBPCActList()
const {data:{id, content:{A,B,C,D}}} = await getDetailBPC()
ids.value = id
// swiperList.value = data.map((item: { filePathList: any[] })=>{
// const fileList = item.filePathList.map((itt: any)=>Object.assign(itt,{
// name:itt.originalFileName,
// url:itt.url
// }))
// return {...item,fileList}
// })
fuckList1.value = A||[]
fuckList2.value = B||[]
fuckList3.value = C||[]
fuckList4.value = D||[]
// console.log( data)
})
const store = useUserStore()
const message = useMessage()
function getCurrentDate() {
const currentDate = new Date();
const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
const day = String(currentDate.getDate()).padStart(2, '0');
const formattedDate = `${year}-${month}-${day}`;
return formattedDate;
}
async function onSubmitAdds() {
let newData = swiperList.value.map((item) => {
console.log(item)
item.updateDate = getCurrentDate()
const urls = item.fileList.map((file) => file.response.url);
// const urls = item.fileList.map((file) => file.url);
return { ...item, filePath: urls.join(",") };
});
newData.forEach((item) => {
delete item.fileList;
delete item.show;
});
const data = JSON.stringify(newData)
console.log(typeof data)
console.log(swiperList.value,newData)
const { code, msg } = await updateBPC(data)
if (code === 200) { message.success("修改成功") }
else message.warning(msg)
push({name:'BCP'})
}
async function onSubmitAdd() {
console.log(fuckList1.value,fuckList2.value,fuckList3.value,fuckList4.value)
const id = ids.value
const dog = unref(fuckList1.value)
const dog1 = unref(fuckList2.value)
const dog2 = unref(fuckList3.value)
const dog3 = unref(fuckList4.value)
const { code, msg } = await addBPC({ id, content: { A:dog,B:dog1,C:dog2,D:dog3 } })
if (code === 200) { message.success("修改成功") }
else message.warning(msg)
push({name:'BCP'})
// console.log(unref(form.value.lable2),unref(swiperList.value),unref(dogList.value))
}
async function onSubmit(row: { id: number; url: any; title: string; time: string; files: never[]; fileList: never[] }) {
swiperList.value.push(row)
shomkB.value = false
}
const getDatal=(object1: { value: any[] },object2: { id: string | number })=>{
console.log(object1.value,object2)
if(object1){
object1.value.push(object2);
return
}
object1.value.map(obj=>{
obj.id === object2.id ? { ...obj, ...object2 } : obj
// console.log(i.id)
})
const existingIds = object1.value.map(obj => obj.id);
if (!existingIds.includes(object2.id)) {
if(object2.id===''){
object2.id = Math.floor(Math.random() * 100)
}
object1.value.push(object2);
}
}
async function onSubmits(row: { id: number; url: any; title: string; time: string; dowhat: string; files: never[]; fileList: never[] }) {
// dogList.value.push(row)
// console.log(row)
shomkA.value = false
const index = flg.value
switch(index){
case 1:
getDatal(fuckList1,row)
break;
case 2:
getDatal(fuckList2,row)
break;
case 3:
getDatal(fuckList3,row)
break;
case 4:
getDatal(fuckList4,row)
break;
}
}
const shomkB = ref(false)
const shomksB = () => {
shomkB.value = shomkB.value === false ? true : false
console.log(shomkB.value)
}
const swiperList = ref([])
const dogList = ref()
const editList = ref()
const handleEdit = (index: number, row: any) => {
console.log(row)
if (row && row.url) {
console.log(row.files.length)
if(row.files.length<=0){
row.files.push({ url: row.url });
}
}
else {
editList.value = {
id: '',
status:'New',
filePath: '',
title: '',
updateDate: getCurrentDate(),
fileList: [],
show:true
}
}
shomkB.value = true
if (!row) return
editList.value = row
console.log(row)
}
const shomkA = ref(false)
const flg =ref()
const handleEdits = (index: any) => {
console.log(index)
flg.value =index
dogList.value = {
id: '',
status:'1',
filePath: '',
title: '',
updateDate: getCurrentDate(),
fileList: [],
show:false
}
shomkA.value = true
console.log(dogList.value)
}
const handleDelete = (index: number, row: any) => {
swiperList.value = swiperList.value.filter(item => item.id !== row.id);
console.log(index, row)
}
const handleDeletes = (index: number, row: any) => {
dogList.value = dogList.value.filter(item => item.id !== row.id);
console.log(index, row)
}
const dialogImageUrl = ref('')
const dialogVisible = ref(false)
const handleRemove: UploadProps['onRemove'] = (uploadFile: any, uploadFiles: any) => {
console.log(uploadFile, uploadFiles)
}
const handOnExceed: UploadProps['onExceed'] = (uploadFile: any, uploadFiles: any) => {
message.warning("最多只能上传一张图片!")
}
const handlePreview: UploadProps['onSuccess'] = (uploadFile: any) => {
console.log(uploadFile.url)
editList.value.url = uploadFile.url
}
const handlePreviews: UploadProps['onSuccess'] = (uploadFile: any) => {
console.log("++++++++++++++++++++++++++++")
console.log(uploadFile)
// fuckList.value.url = uploadFile.url
}
const handlePreview1: UploadProps['onSuccess'] = (uploadFile: any) => {
// console.log("++++++++++++++++++++++++++++")
// console.log(uploadFile)
// fuckList.value.url = uploadFile.url
}
const handlePreview2: UploadProps['onSuccess'] = (uploadFile: any) => {
// console.log("++++++++++++++++++++++++++++")
// console.log(uploadFile)
// fuckList.value.url = uploadFile.url
}
const header = { 'token': store.user.token }
// const paths = window.location.origin+'/common/upload'
</script>
<template>
<HomeHead class="top"></HomeHead>
<div class="flex w-full h-full">
<AppBlock class="w-full p30px text-#000">
<div class="font-600 flex items-center">
<!-- <img src="./images/logo.svg" class="h56px mr21px" /> -->
<div class="text-36px text-#000">BCP内容管理</div>
</div>
<div class="my30px overflow-y-auto h760px">
<div class="text-center py30px text-22px">BCP简报列表</div>
<div>
<el-button type="primary" @click="handleEdit" class="my20px">新增简报</el-button>
<el-table :data="swiperList" style="width: 100%" :header-cell-style="{ background:'#2A7BF7',color:'#fff',height:'60px',textAlign: 'center','font-size':'24px'}" :cell-style="{ 'text-align': 'center'}">
<el-table-column label="标题" prop="title" />
<el-table-column label="状态" prop="status" />
<!-- <el-table-column label="时间" prop="status" /> -->
<el-table-column label="文件列表" prop="fileList" >
<template #default="scope">
<div v-if="scope.row.fileList" v-for="(it,index) in scope.row.fileList">
{{it.name}}
</div>
</template>
</el-table-column>
<!-- <el-table-column label="文件列表" prop="files" /> -->
<!-- <el-table-column label="操作"> -->
<!-- <template #default="scope"> -->
<!-- <el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button> -->
<!-- <el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
<!-- </template> -->
<!-- </el-table-column> -->
</el-table>
</div>
<div class="w100% text-center">
<div @click="onSubmitAdds" class="my40px mx-auto bg-#005AE2 text-#fff w400px py15px text-22px rounded-5px">BCP今日简报提交数据</div>
</div>
<hr class="my20px"/>
<div class="text-center py30px text-22px">运营手册</div>
<div>
<el-button type="primary" @click="handleEdits(1)" class="my20px">新增运营手册</el-button>
<el-table :data="fuckList1" style="width: 100%" :header-cell-style="{ background:'#2A7BF7',color:'#fff',height:'60px',textAlign: 'center','font-size':'24px'}" :cell-style="{ 'text-align': 'center'}">
<el-table-column label="标题" prop="title" />
<!-- <el-table-column label="状态" prop="status" />
<el-table-column label="时间" prop="status" /> -->
<el-table-column label="文件列表" prop="fileList" >
<template #default="scope">
<div v-if="scope.row.fileList" v-for="(it,index) in scope.row.fileList">
{{it.name}}
</div>
</template>
</el-table-column>
<!-- <el-table-column label="文件列表" prop="files" /> -->
<!-- <el-table-column label="操作">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column> -->
</el-table>
</div>
<div class="text-center py30px text-22px">供方SCM</div>
<div>
<el-button type="primary" @click="handleEdits(2)" class="my20px">新增供方SCM</el-button>
<el-table :data="fuckList2" style="width: 100%" :header-cell-style="{ background:'#2A7BF7',color:'#fff',height:'60px',textAlign: 'center','font-size':'24px'}" :cell-style="{ 'text-align': 'center'}">
<el-table-column label="标题" prop="title" />
<!-- <el-table-column label="状态" prop="status" />
<el-table-column label="时间" prop="status" /> -->
<el-table-column label="文件列表" prop="fileList" >
<template #default="scope">
<div v-if="scope.row.fileList" v-for="(it,index) in scope.row.fileList">
{{it.name}}
</div>
</template>
</el-table-column>
<!-- <el-table-column label="文件列表" prop="files" /> -->
<!-- <el-table-column label="操作">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column> -->
</el-table>
</div>
<div class="text-center py30px text-22px">BCP情报</div>
<div>
<el-button type="primary" @click="handleEdits(3)" class="my20px">新增BCP情报</el-button>
<el-table :data="fuckList3" style="width: 100%" :header-cell-style="{ background:'#2A7BF7',color:'#fff',height:'60px',textAlign: 'center','font-size':'24px'}" :cell-style="{ 'text-align': 'center'}">
<el-table-column label="标题" prop="title" />
<!-- <el-table-column label="状态" prop="status" />
<el-table-column label="时间" prop="status" /> -->
<el-table-column label="文件列表" prop="fileList" >
<template #default="scope">
<div v-if="scope.row.fileList" v-for="(it,index) in scope.row.fileList">
{{it.name}}
</div>
</template>
</el-table-column>
<!-- <el-table-column label="文件列表" prop="files" /> -->
<!-- <el-table-column label="操作">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column> -->
</el-table>
</div>
<div class="text-center py30px text-22px">滚动列表内容</div>
<div>
<el-button type="primary" @click="handleEdits(4)" class="my20px">新增滚动列表</el-button>
<el-table :data="fuckList4" style="width: 100%" :header-cell-style="{ background:'#2A7BF7',color:'#fff',height:'60px',textAlign: 'center','font-size':'24px'}" :cell-style="{ 'text-align': 'center'}">
<el-table-column label="标题" prop="title" />
<!-- <el-table-column label="状态" prop="status" />
<el-table-column label="时间" prop="status" />
-->
<el-table-column label="文件列表" prop="fileList" >
<template #default="scope">
<div v-if="scope.row.fileList" v-for="(it,index) in scope.row.fileList">
{{it.name}}
</div>
</template>
</el-table-column>
<!-- <el-table-column label="文件列表" prop="files" /> -->
<!-- <el-table-column label="操作">
<template #default="scope">
<el-button size="small" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
<el-button size="small" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
</template>
</el-table-column> -->
</el-table>
</div>
<div class="w100% text-center">
<div @click="onSubmitAdd" class="my40px mx-auto bg-#005AE2 text-#fff w400px py15px text-22px rounded-5px">列表数据提交</div>
</div>
</div>
</AppBlock>
</div>
<n-modal v-model:show="shomkB">
<div class="bg-#FFF p30px">
<el-form :model="editList" label-width="120px" :inline="true">
<el-form-item label="模块归属" v-if="editList.show">
<el-radio-group v-model="editList.status" class="ml-4">
<el-radio label="紧急" size="large">紧急</el-radio>
<el-radio label="重点" size="large">重点</el-radio>
<el-radio label="New" size="large">New</el-radio>
</el-radio-group>
</el-form-item>
<br>
<el-form-item label="标题">
<el-input v-model="editList.title" />
</el-form-item>
<br>
<el-form-item label="文件">
<el-upload v-model:file-list="editList.fileList" class="upload-demo" :headers="header"
action="/test-api/common/upload" :on-change="handleChange">
<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(editList)">确认</el-button>
</el-form-item>
</div>
</n-modal>
<n-modal v-model:show="shomkA">
<div class="bg-#FFF p30px">
<el-form :model="dogList" label-width="120px" :inline="true">
<el-form-item label="模块归属" v-if="dogList.show">
<el-radio-group v-model="dogList.status" class="ml-4">
<el-radio label="紧急" size="large">紧急</el-radio>
<el-radio label="重点" size="large">重点</el-radio>
<el-radio label="New" size="large">New</el-radio>
</el-radio-group>
</el-form-item>
<br>
<el-form-item label="标题">
<el-input v-model="dogList.title" />
</el-form-item>
<br>
<el-form-item label="文件">
<el-upload v-model:file-list="dogList.fileList" class="upload-demo" :headers="header"
action="/test-api/common/upload" :on-change="handleChange">
<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="onSubmits(dogList)">确认</el-button>
</el-form-item>
</div>
</n-modal>
</template>
<style scoped lang="less">
.top {
position: absolute;
right: 30px;
top: -92px;
}
</style>