联调案例库
This commit is contained in:
@@ -64,7 +64,7 @@
|
||||
<template #default="{ row }">
|
||||
<el-button type="primary" link @click="edit(row)">修改</el-button>
|
||||
<!-- <el-button type="danger" link @click="del(row)">删除</el-button> -->
|
||||
<el-popconfirm title="是否确认删除算法?" @confirm="del(row)">
|
||||
<el-popconfirm title="确定删除吗?" confirm-button-type='danger' @confirm="del(row)">
|
||||
<template #reference>
|
||||
<el-button type="danger" link>删除</el-button>
|
||||
</template>
|
||||
|
||||
@@ -2,25 +2,35 @@
|
||||
<el-dialog draggable class="cn-operate-dialog" v-model="dialogVisible" :title="title" width="1200px">
|
||||
<el-scrollbar>
|
||||
<el-form :inline="false" :model="form" class="form-two" label-width="auto" :rules="rules" ref="formRef">
|
||||
<el-form-item label="事件名称">
|
||||
<el-form-item label="事件名称" prop="name">
|
||||
<el-input v-model="form.name" placeholder="请输入事件名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发生事件">
|
||||
<el-input v-model="form.type" placeholder="请输入发生事件" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发生地点">
|
||||
<el-input v-model="form.location" placeholder="请输入发生地点" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="事件经过">
|
||||
<el-form-item label="发生事件" prop="type">
|
||||
<el-input
|
||||
v-model="form.process"
|
||||
placeholder="请输入事件经过"
|
||||
v-model="form.type"
|
||||
placeholder="请输入治理效果"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }"
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="处理措施">
|
||||
<el-form-item label="发生地点" prop="location">
|
||||
<el-input
|
||||
v-model="form.location"
|
||||
placeholder="请输入治理效果"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }"
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="事件经过" prop="process">
|
||||
<el-input
|
||||
v-model="form.process"
|
||||
placeholder="请输入治理效果"
|
||||
:autosize="{ minRows: 2, maxRows: 4 }"
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="处理措施" prop="measures">
|
||||
<el-input
|
||||
v-model="form.measures"
|
||||
placeholder="请输入处理措施"
|
||||
@@ -28,7 +38,7 @@
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="治理效果">
|
||||
<el-form-item label="治理效果" prop="effect">
|
||||
<el-input
|
||||
v-model="form.effect"
|
||||
placeholder="请输入治理效果"
|
||||
@@ -37,8 +47,8 @@
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="附件">
|
||||
<el-upload v-model:file-list="fileList" action="" multiple :limit="3" :on-exceed="handleExceed">
|
||||
<el-button type="primary">添加附件</el-button>
|
||||
<el-upload v-model:file-list="fileList" action="" :auto-upload="false" multiple>
|
||||
<el-button type="primary">上传</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -62,11 +72,13 @@ import { reactive } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import TableStore from '@/utils/tableStore' // 若不是列表页面弹框可删除
|
||||
import editor from '@/components/wangEditor/index.vue'
|
||||
import { uploadFile, getFileNameAndFilePath } from '@/api/system-boot/file'
|
||||
import { libcaseAdd } from '@/api/supervision-boot/database/index'
|
||||
const emit = defineEmits(['onSubmit'])
|
||||
const dialogVisible = ref(false)
|
||||
const title = ref('')
|
||||
const tableStore = inject('tableStore') as TableStore
|
||||
const formRef = ref()
|
||||
const fileList = ref([])
|
||||
const fileList: any = ref([])
|
||||
// 注意不要和表单ref的命名冲突
|
||||
const form = reactive<anyObj>({
|
||||
type: '',
|
||||
@@ -75,24 +87,36 @@ const form = reactive<anyObj>({
|
||||
process: '',
|
||||
measures: '',
|
||||
effect: '',
|
||||
id: ''
|
||||
url: ''
|
||||
})
|
||||
|
||||
const rules = {
|
||||
name: [{ required: true, message: '角色名称不能为空', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }]
|
||||
type: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
|
||||
location: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
|
||||
process: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
|
||||
measures: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }],
|
||||
effect: [{ required: true, message: '角色编码不能为空', trigger: 'blur' }]
|
||||
}
|
||||
|
||||
const handleExceed = (files: any, uploadFiles: any) => {}
|
||||
|
||||
const open = (text: string, data?: anyObj) => {
|
||||
title.value = text
|
||||
dialogVisible.value = true
|
||||
if (data) {
|
||||
fileList.value = []
|
||||
// 表单赋值
|
||||
for (let key in form) {
|
||||
form[key] = data[key]
|
||||
}
|
||||
data.url.split(',').forEach((item: string) => {
|
||||
console.log('🚀 ~ data.url.split ~ item:', item)
|
||||
getFileNameAndFilePath({ filePath: item }).then(res => {
|
||||
fileList.value.push({
|
||||
name: res.data.fileName,
|
||||
url: res.data.name
|
||||
})
|
||||
})
|
||||
})
|
||||
} else {
|
||||
// 在此处恢复默认表单
|
||||
for (let key in form) {
|
||||
@@ -101,25 +125,55 @@ const open = (text: string, data?: anyObj) => {
|
||||
}
|
||||
}
|
||||
const submit = () => {
|
||||
console.log(`1111`, form.summary)
|
||||
console.log(`1111`, fileList.value)
|
||||
|
||||
formRef.value.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
if (form.id) {
|
||||
// await update(form)
|
||||
} else {
|
||||
// await create(form)
|
||||
if (fileList.value.length > 0) {
|
||||
const promises = fileList.value.map(async item => {
|
||||
return new Promise((resolve, reject) => {
|
||||
uploadFile(item.raw, '/supervision/')
|
||||
.then((res: any) => {
|
||||
resolve(res.data.name)
|
||||
})
|
||||
.catch(reject)
|
||||
})
|
||||
})
|
||||
|
||||
try {
|
||||
const fileNames = await Promise.all(promises)
|
||||
form.url = fileNames.join(',') + ''
|
||||
} catch (error) {
|
||||
console.error('上传文件出错', error)
|
||||
return
|
||||
}
|
||||
}
|
||||
ElMessage.success('保存成功')
|
||||
tableStore.index()
|
||||
dialogVisible.value = false
|
||||
|
||||
setTimeout(() => {
|
||||
if (title.value === '新增案例') {
|
||||
console.log('🚀 ~ libcaseAdd ~ form:', form)
|
||||
|
||||
libcaseAdd(form).then(res => {
|
||||
handleClose()
|
||||
})
|
||||
} else {
|
||||
// 其他逻辑
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
}
|
||||
// 事件简介
|
||||
const quit = () => {
|
||||
tableStore.index()
|
||||
|
||||
const handleClose = () => {
|
||||
ElMessage.success(title.value + '成功!')
|
||||
emit('onSubmit')
|
||||
dialogVisible.value = false
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
:deep(.el-upload-list__item-info) {
|
||||
width: 300px !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</TableHeader>
|
||||
<Table ref="tableRef"></Table>
|
||||
<!-- 弹框 -->
|
||||
<PopupEdit ref="popupEditRef" />
|
||||
<PopupEdit ref="popupEditRef" @onSubmit="tableStore.index()" />
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@@ -17,6 +17,8 @@ import TableStore from '@/utils/tableStore'
|
||||
import TableHeader from '@/components/table/header/index.vue'
|
||||
import Table from '@/components/table/index.vue'
|
||||
import PopupEdit from './components/form.vue'
|
||||
import { libcaseBeleteyById } from '@/api/supervision-boot/database/index'
|
||||
import { ElMessage } from 'element-plus'
|
||||
defineOptions({
|
||||
name: 'database/case'
|
||||
})
|
||||
@@ -53,11 +55,46 @@ const tableStore = new TableStore({
|
||||
{
|
||||
title: '治理效果',
|
||||
field: 'effect'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: '140',
|
||||
render: 'buttons',
|
||||
buttons: [
|
||||
{
|
||||
name: 'edit',
|
||||
title: '修改',
|
||||
type: 'primary',
|
||||
|
||||
icon: 'el-icon-Plus',
|
||||
render: 'basicButton',
|
||||
click: row => {
|
||||
popupEditRef.value.open('修改案例', row)
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'delete',
|
||||
title: '删除',
|
||||
type: 'danger',
|
||||
icon: 'el-icon-Delete',
|
||||
render: 'confirmButton',
|
||||
popconfirm: {
|
||||
confirmButtonText: '确认',
|
||||
cancelButtonText: '取消',
|
||||
confirmButtonType: 'danger',
|
||||
title: '确定删除吗?'
|
||||
},
|
||||
click: row => {
|
||||
libcaseBeleteyById({ id: row.id }).then(res => {
|
||||
ElMessage.success('删除成功')
|
||||
tableStore.index()
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
loadCallback: () => {
|
||||
|
||||
}
|
||||
loadCallback: () => {}
|
||||
})
|
||||
|
||||
// 弹框
|
||||
|
||||
Reference in New Issue
Block a user