197 lines
6.5 KiB
Plaintext
197 lines
6.5 KiB
Plaintext
<script setup lang="ts">
|
||
import { useMessage, NModal } from 'naive-ui'
|
||
import { useUserStore } from '@/stores/modules/user'
|
||
import { getCateList, deleteCateItem, updateCate,deleteCate } from '@/api/daikin/base'
|
||
const message = useMessage()
|
||
const store = useUserStore()
|
||
const header = { 'token': store.user.token }
|
||
|
||
const dataA = ref([])
|
||
const dataB = ref([])
|
||
|
||
const editA = ref()
|
||
const editB = ref()
|
||
|
||
const shomkA = ref(false)
|
||
const shomkB = ref(false)
|
||
const dataLength = ref()
|
||
const dataLengths = ref()
|
||
onMounted(async () => {
|
||
// const { data } = await getCateList({ indexId: 1 })
|
||
const { data:dd } = await getCateList({ indexId: 2 })
|
||
// dataA.value = data
|
||
// dataLength.value = data.length
|
||
dataB.value = dd
|
||
dataLengths.value = dd.length
|
||
})
|
||
|
||
|
||
|
||
// async function onSubmitA(row: { id: number; url: any; title: string; time: string; dowhat: string; files: never[]; fileList: never[] }) {
|
||
// if (dataLength.value >= 5&&row.id==='') {
|
||
// message.warning('最多只能添加5个专题,请编辑专题。')
|
||
// return
|
||
// }
|
||
// else {
|
||
// const {id,cateName} =row
|
||
// const { code, msg } = await updateCate({id,cateName,indexId:1})
|
||
// if (code === 200) { message.success("修改成功!") }
|
||
// else { message.error(msg) }
|
||
// window.location.reload();
|
||
// }
|
||
// shomkA.value = false
|
||
// }
|
||
const handleEditA = (index: number, row: any) => {
|
||
console.log(row)
|
||
if (!row) {
|
||
editA.value = {
|
||
id: '',
|
||
cateName: '',
|
||
}
|
||
}
|
||
shomkA.value = true
|
||
if (!row) return
|
||
editA.value = row
|
||
|
||
}
|
||
async function onSubmitB(row: { id: number; url: any; title: string; time: string; dowhat: string; files: never[]; fileList: never[] }) {
|
||
if (dataLengths.value >= 20&&row.id==='') {
|
||
message.warning('最多只能添加20个专题,请编辑专题。')
|
||
return
|
||
}
|
||
else {
|
||
const {id,cateName} =row
|
||
const { code, msg } = await updateCate({id,cateName,indexId:2})
|
||
if (code === 200) { message.success("修改成功!") }
|
||
else { message.error(msg) }
|
||
window.location.reload();
|
||
}
|
||
shomkB.value = false
|
||
}
|
||
const handleEditB = (index: number, row: any) => {
|
||
console.log(row)
|
||
if (!row) {
|
||
editB.value = {
|
||
id: '',
|
||
cateName: '',
|
||
}
|
||
}
|
||
shomkB.value = true
|
||
if (!row) return
|
||
editB.value = row
|
||
|
||
}
|
||
|
||
async function handleDeleteA(index: number, row: any) {
|
||
if(!row.id) return
|
||
const {id} = row
|
||
const {code, msg} = await deleteCate({id})
|
||
if (code === 200) { message.success("修改成功!") }
|
||
else { message.error(msg) }
|
||
window.location.reload();
|
||
|
||
}
|
||
|
||
</script>
|
||
<template>
|
||
|
||
<div class="my30px overflow-y-auto h760px">
|
||
|
||
<!-- <br>
|
||
<div class="text-center py30px text-22px">课题分类列表管理</div>
|
||
<div>
|
||
<el-button type="primary" @click="handleEditA" class="my20px">课题分类新增</el-button>
|
||
<el-table :data="dataA" style="width: 95%"
|
||
:header-cell-style="{ background: '#2A7BF7', color: '#fff', height: '60px', textAlign: 'center', 'font-size': '24px' }"
|
||
:cell-style="{ 'text-align': 'center' }">
|
||
|
||
<el-table-column label="编号" prop="id" />
|
||
<el-table-column label="课题名称" prop="cateName" />
|
||
|
||
<el-table-column label="操作" width="180px">
|
||
<template #default="scope">
|
||
<el-button size="small" @click="handleEditA(scope.$index, scope.row)">编辑</el-button>
|
||
<el-button size="small" type="danger" @click="handleDeleteA(scope.$index, scope.row)">删除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div> -->
|
||
|
||
<!-- <br> -->
|
||
<!-- <div class="text-center py30px text-22px">解决方案列表管理</div> -->
|
||
<div>
|
||
<el-button type="primary" @click="handleEditB" class="my20px">解决方案新增</el-button>
|
||
<el-table :data="dataB" style="width: 95%"
|
||
:header-cell-style="{ background: '#2A7BF7', color: '#fff', height: '60px', textAlign: 'center', 'font-size': '24px' }"
|
||
:cell-style="{ 'text-align': 'center' }">
|
||
|
||
<el-table-column label="编号" prop="id" width="180px"/>
|
||
<el-table-column label="课题名称" prop="cateName" />
|
||
|
||
<el-table-column label="操作" width="180px">
|
||
<template #default="scope">
|
||
<el-button size="small" @click="handleEditA(scope.$index, scope.row)">编辑</el-button>
|
||
<el-button size="small" type="danger" @click="handleDeleteA(scope.$index, scope.row)">删除</el-button>
|
||
</template>
|
||
</el-table-column>
|
||
</el-table>
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
</div>
|
||
|
||
<!-- <el-form-item>
|
||
<el-button type="primary" @click="onSubmitAdd">提交数据</el-button>
|
||
</el-form-item> -->
|
||
|
||
|
||
|
||
<n-modal v-model:show="shomkA">
|
||
<div class="bg-#FFF p30px">
|
||
<el-form :model="editA" label-width="120px" :inline="true">
|
||
|
||
<el-form-item label="课题名称">
|
||
<el-input v-model="editA.cateName" />
|
||
</el-form-item>
|
||
|
||
<br>
|
||
|
||
</el-form>
|
||
<!-- <hr class="mb15px border-#f1f1f1"> -->
|
||
<el-form-item>
|
||
<el-button type="primary" @click="onSubmitA(editA)">确认</el-button>
|
||
</el-form-item>
|
||
</div>
|
||
</n-modal>
|
||
<n-modal v-model:show="shomkB">
|
||
<div class="bg-#FFF p30px">
|
||
<el-form :model="editB" label-width="120px" :inline="true">
|
||
|
||
<el-form-item label="课题名称">
|
||
<el-input v-model="editB.cateName" />
|
||
</el-form-item>
|
||
|
||
<br>
|
||
|
||
</el-form>
|
||
<!-- <hr class="mb15px border-#f1f1f1"> -->
|
||
<el-form-item>
|
||
<el-button type="primary" @click="onSubmitB(editB)">确认</el-button>
|
||
</el-form-item>
|
||
</div>
|
||
</n-modal>
|
||
</template>
|
||
|
||
<style lang="less">
|
||
.top {
|
||
position: absolute;
|
||
right: 30px;
|
||
top: -92px;
|
||
}
|
||
</style> |