433 lines
13 KiB
Plaintext
433 lines
13 KiB
Plaintext
<script setup lang="ts">
|
|
import { useMessage, NModal, NSelect } from 'naive-ui'
|
|
import { useUserStore } from '@/stores/modules/user'
|
|
import { getLabCsrActList, updateLab, getCateList, addLab, getLabActList,actLABDel,updateActOne,deleteCateItem ,editCateItem} from '@/api/daikin/base'
|
|
import { time } from 'echarts';
|
|
import UserList from '@/views/home/intelligence/process/UserPages.vue'
|
|
|
|
const ids = ref('')
|
|
const { push } = useRouter()
|
|
const options = ref()
|
|
|
|
const actTopUserLists = ref()
|
|
const actMidUserLists = ref()
|
|
const actDownUserLists = ref()
|
|
const Data = ref()
|
|
onBeforeMount(async () => {
|
|
getSwiperList()
|
|
const { data: dataBot } = await getCateList({ indexId: 2 })
|
|
const { data: dataBot1 } = await getCateList({ indexId: 1 })
|
|
const { data: dataBot3 } = await getCateList({ indexId: 3 })
|
|
options.value = dataBot
|
|
list.value.map(item => {
|
|
if (item.id === 2) {
|
|
item.options = dataBot
|
|
}
|
|
if (item.id === 1) {
|
|
item.options = dataBot1
|
|
}
|
|
if (item.id === 3) {
|
|
item.options = dataBot3
|
|
}
|
|
})
|
|
opt.value = list.value[0]
|
|
console.log(list.value)
|
|
// const { data } = await getLabCsrActList()
|
|
const { data: dts } = await getLabActList()
|
|
actDownUserLists.value = dts.actDownUserList
|
|
actMidUserLists.value = dts.actMidUserList
|
|
actTopUserLists.value = dts.actTopUserList
|
|
Data.value = dts
|
|
|
|
// const datas = data.map((item: any)=>Object.assign(item,{
|
|
// indexId:item.indexId+'',
|
|
// }))
|
|
// swiperList.value =datas
|
|
// swiperList.value = datas.map((item: { filePathList: any[] })=>{
|
|
// const fileList = item.filePathList.map((itt: any)=>Object.assign(itt,{
|
|
// name:itt.originalFileName,
|
|
// url:itt.url
|
|
// }))
|
|
// return {...item,fileList}
|
|
// })
|
|
// console.log( swiperList.value )
|
|
})
|
|
|
|
|
|
const store = useUserStore()
|
|
const message = useMessage()
|
|
|
|
|
|
async function onSubmitAdd() {
|
|
console.log(swiperList.value)
|
|
let newData = swiperList.value.map((item) => {
|
|
// const urls = item.fileList.map((file) => file.response.url);
|
|
const urls = item.fileList.map((file) => {
|
|
if (file.response) {
|
|
return file.response.url
|
|
}
|
|
else {
|
|
return file.url
|
|
}
|
|
});
|
|
return { ...item, filePath: urls.join(",") };
|
|
});
|
|
|
|
newData.forEach((item) => {
|
|
delete item.fileList;
|
|
});
|
|
// const data = JSON.stringify(newData)
|
|
console.log(newData)
|
|
|
|
const { code, msg } = await updateLab(newData)
|
|
// const { code, msg } = await editCateItem(newData)
|
|
if (code === 200) { message.success("修改成功") }
|
|
else message.warning(msg)
|
|
// getSwiperList()
|
|
// push({name:'Diffspace'})
|
|
|
|
}
|
|
async function onSubmit(row) {
|
|
// swiperList.value.push(row)
|
|
console.log(row)
|
|
if (row.indexId === '') {
|
|
message.info("请选择分类选项!")
|
|
return
|
|
}
|
|
if (!row.catId || row.catId === '') {
|
|
message.info("请选择所属模块!")
|
|
return
|
|
}
|
|
|
|
row.title = '【' + row.catId + '】' + row.title
|
|
|
|
if(row.fileList&&row.fileList.length>0){
|
|
if (row.fileList[0].response) {
|
|
row.filePath = row.fileList[0].response.url
|
|
}
|
|
else {
|
|
row.filePath = row.fileList[0].url
|
|
}
|
|
}
|
|
const {msg,code} = await updateActOne(row)
|
|
if (code === 200) {
|
|
message.success("操作成功")
|
|
getSwiperList()
|
|
}
|
|
// else message.warning(msg)
|
|
// swiperList.value.map(obj => {
|
|
// obj.id === row.id ? { ...obj, ...row } : obj
|
|
|
|
// // console.log(i.id)
|
|
// })
|
|
// const existingIds = swiperList.value.map(obj => obj.id);
|
|
// if (!existingIds.includes(row.id)) {
|
|
// if (row.id === '') {
|
|
// row.id = Math.floor(Math.random() * 100)
|
|
// }
|
|
|
|
// swiperList.value.push(row);
|
|
// }
|
|
shomkB.value = false
|
|
|
|
|
|
console.log(swiperList.value)
|
|
}
|
|
|
|
async function onSubmitAdds() {
|
|
|
|
const actTopUserList = unref(actTopUserLists.value)
|
|
const actMidUserList = unref(actMidUserLists.value)
|
|
const actDownUserList = unref(actDownUserLists.value)
|
|
const { id, bannerUserList, leftUserList, rightUserList, memberUserList, bannerContent, leftContent, rightContent, memberContent } = Data.value
|
|
const { code, msg } = await addLab({ id, bannerUserList, leftUserList, rightUserList, memberUserList, bannerContent, leftContent, rightContent, memberContent, actTopUserList, actMidUserList, actDownUserList })
|
|
if (code === 200) { message.success("修改成功") }
|
|
else message.warning(msg)
|
|
}
|
|
|
|
const shomkB = ref(false)
|
|
const shomksB = () => {
|
|
shomkB.value = shomkB.value === false ? true : false
|
|
console.log(shomkB.value)
|
|
}
|
|
|
|
|
|
let swiperList = 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: '',
|
|
indexId: '1',
|
|
title: '',
|
|
filePath: '',
|
|
fileList: [],
|
|
catId: ''
|
|
}
|
|
}
|
|
shomkB.value = true
|
|
if (!row) return
|
|
editList.value = row
|
|
|
|
console.log(row)
|
|
}
|
|
const list = ref([{
|
|
id: 1,
|
|
title: '部品业种',
|
|
options: [{ id: '1', cateName: 'DEVICE' }, { id: '2', cateName: '加工品' }, { id: '3', cateName: '原材料' }]
|
|
},
|
|
{
|
|
id: 3,
|
|
title: '走访类型',
|
|
options: [{ id: '1', cateName: '供方走访' }, { id: '2', cateName: '展会走访' }, { id: '3', cateName: '企业走访' }]
|
|
},
|
|
{
|
|
id: 2,
|
|
title: '探索方向',
|
|
options: []
|
|
},
|
|
])
|
|
const opt = ref()
|
|
const radioClick = (e) => {
|
|
opt.value = list.value.find(item => item.id == e)
|
|
// console.log(ll)
|
|
}
|
|
const handleDelete = async (index: number, row: any) => {
|
|
swiperList.value = swiperList.value.filter(item => item.id !== row.id);
|
|
const id = row.id
|
|
|
|
if(!id) return
|
|
|
|
const {code,msg} =await actLABDel({id})
|
|
if(code===200){message.info("操作成功!")}
|
|
else{
|
|
message.error(msg)
|
|
}
|
|
getSwiperList()
|
|
}
|
|
|
|
const handOnExceed: UploadProps['onExceed'] = (uploadFile: any, uploadFiles: any) => {
|
|
message.warning("最多只能上传一个文件!")
|
|
}
|
|
|
|
const header = { 'token': store.user.token }
|
|
|
|
const showModal = ref(false)
|
|
const setUserList = ref()
|
|
const flg = ref()
|
|
const getUser = (id: any) => {
|
|
showModal.value = !showModal.value
|
|
flg.value = id
|
|
if (id === 1) {
|
|
setUserList.value = actTopUserLists.value
|
|
}
|
|
}
|
|
|
|
|
|
// 获取子组件传过来的值
|
|
const handleChild = (data: any) => {
|
|
const { showModal: show, multipleSelection } = data
|
|
showModal.value = unref(show)
|
|
// userList.value = multipleSelection
|
|
let userIdList: any[] = []
|
|
multipleSelection.value.forEach((i: { userId: any }) => {
|
|
|
|
userIdList.push(i.userId)
|
|
})
|
|
if (flg.value === 1) {
|
|
actTopUserLists.value = userIdList
|
|
// actDownUserLists.value = userIdList
|
|
// actMidUserLists.value = userIdList
|
|
}
|
|
else {
|
|
actMidUserLists.value = userIdList
|
|
}
|
|
console.log(userIdList)
|
|
onSubmitAdds()
|
|
|
|
}
|
|
const CloseThiss = (data: boolean) => {
|
|
console.log(data)
|
|
showModal.value = data
|
|
}
|
|
const value = ref()
|
|
const optt = [{ id: '1', cateName: '核心部品强化' }, { id: '2', cateName: '新领域部材探索' }, { id: '3', cateName: '外部调研报告' }]
|
|
const listData = ref()
|
|
const thisSelect = (e) => {
|
|
|
|
pageInfo.index = e
|
|
|
|
}
|
|
const thisSelects = () => {
|
|
pageInfo.index = ''
|
|
}
|
|
|
|
const pageInfo = reactive({
|
|
currentPage:1,
|
|
pageSize:10,
|
|
total:10,
|
|
index:''
|
|
})
|
|
const ss = computed(() => [pageInfo.index,pageInfo.currentPage])
|
|
watch(() => unref(ss),
|
|
async (v) => {
|
|
|
|
getSwiperList()
|
|
|
|
},
|
|
{ immediate: true, deep: true },
|
|
)
|
|
|
|
async function getSwiperList() {
|
|
const indexId = pageInfo.index
|
|
const { rows,total } = await getLabCsrActList({ indexId,pageNum:pageInfo.currentPage,pageSize:pageInfo.pageSize })
|
|
pageInfo.total = total
|
|
if (!rows) return
|
|
const datas = rows.map((item: any) => Object.assign(item, {
|
|
indexId: item.indexId + '',
|
|
}))
|
|
swiperList.value = datas
|
|
swiperList.value = datas.map((item: { filePathList: any[] }) => {
|
|
const fileList = item.filePathList.map((itt: any) => Object.assign(itt, {
|
|
name: itt.originalFileName,
|
|
url: itt.url
|
|
}))
|
|
return { ...item, fileList }
|
|
})
|
|
}
|
|
const handleSizeChange=(e)=>{
|
|
console.log(e)
|
|
}
|
|
|
|
const handleCurrentChange=(e)=>{
|
|
console.log(e)
|
|
}
|
|
|
|
</script>
|
|
|
|
<template>
|
|
<div class="relative w-full h-full">
|
|
<div class="flex my20px">
|
|
|
|
<el-button type="primary" @click="handleEdit" class="mr-20px">新增研究方向内容</el-button>
|
|
<div class="leading-30px w125px h50px ml20px">请选择类别:</div>
|
|
<n-select class="w250px" size="large" v-if="optt" :show-arrow="false" :show-checkmark="false" v-model:value="value" :options="optt" label-field="cateName"
|
|
value-field="id" @update:value="thisSelect" />
|
|
<el-button type="primary" @click="thisSelects" class="ml-20px mt5px">重置</el-button>
|
|
</div>
|
|
|
|
<el-table :data="swiperList" style="width: 100%,height: 600px;overflow-y: auto;"
|
|
:header-cell-style="{ background: '#2A7BF7', color: '#fff', height: '60px', textAlign: 'center', 'font-size': '24px' }"
|
|
:cell-style="{ 'text-align': 'center','overflow-y':'auto' }">
|
|
|
|
<el-table-column label="标题" prop="title" />
|
|
<el-table-column label="分类选项" width="280">
|
|
<template #default="scope">
|
|
<div>
|
|
<div v-if="scope.row.indexId === '1'">核心部品强化</div>
|
|
<div v-if="scope.row.indexId === '2'">新领域部材探索</div>
|
|
<div v-if="scope.row.indexId === '3'">外部调研报告</div>
|
|
</div>
|
|
</template>
|
|
</el-table-column>
|
|
<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="fileList" >
|
|
<template #default="scope">
|
|
<div v-if="actTopUserLists" v-for="(it,index) in actTopUserLists">
|
|
{{it.nickName}}
|
|
</div>
|
|
</template>
|
|
|
|
</el-table-column> -->
|
|
<el-table-column label="操作" :header-style="{ background: 'red' }">
|
|
<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>
|
|
|
|
|
|
|
|
<el-form-item>
|
|
<div class="my20px fixed bottom-25px left-20% z-2000 h50px w-200px">
|
|
<!-- <el-button type="primary" @click="onSubmitAdd">提交数据</el-button> -->
|
|
<el-button type="primary" @click="getUser(1)"> 查看范围</el-button>
|
|
<!-- <el-button type="primary" @click="getUser(2)" >新领域探索通知范围</el-button> -->
|
|
<!-- <el-button type="primary" @click="showModal=!showModal" >编辑通知范围</el-button> -->
|
|
</div>
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
<div class=" fixed bottom-65px right-100px ">
|
|
<el-pagination v-model:current-page="pageInfo.currentPage" v-model:page-size="pageInfo.pageSize"
|
|
layout="prev, pager, next, jumper" :total="pageInfo.total"
|
|
@size-change="handleSizeChange" @current-change="handleCurrentChange" />
|
|
</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="分类选项">
|
|
<el-radio-group v-model="editList.indexId" class="ml-4" @change="radioClick">
|
|
<el-radio label="1" size="large">核心部品强化</el-radio>
|
|
<el-radio label="2" size="large">新领域部材探索</el-radio>
|
|
<el-radio label="3" size="large">外部调研报告</el-radio>
|
|
</el-radio-group>
|
|
</el-form-item>
|
|
<br>
|
|
<el-form-item :label="opt.title">
|
|
<n-select class="min-w220px" size="large" v-if="opt.options" v-model:value="editList.catId"
|
|
:options="opt.options" label-field="cateName" value-field="cateName" />
|
|
</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" :on-exceed="handOnExceed" :limit="1">
|
|
<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="showModal">
|
|
<UserList :userDataList="setUserList" @clickChild="handleChild" @CloseThis="CloseThiss" />
|
|
</n-modal>
|
|
</template>
|
|
|
|
<style scoped lang="less">
|
|
.top {
|
|
position: absolute;
|
|
right: 30px;
|
|
top: -92px;
|
|
}
|
|
</style> |