2024-05-09 14:18:39 +08:00
|
|
|
|
<template>
|
2024-05-13 18:36:19 +08:00
|
|
|
|
<el-dialog draggable class='cn-operate-dialog' v-model='dialogVisible' :title='title'
|
|
|
|
|
|
style='max-width: 450px;height: 450px'>
|
|
|
|
|
|
<el-scrollbar>
|
|
|
|
|
|
<el-form :inline='false' :model='formData' label-width='120px' :rules='rules' ref='formRef'>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label='表单类型' prop='formType'>
|
|
|
|
|
|
<el-radio-group v-model='formData.formType'>
|
|
|
|
|
|
<el-radio border label='10'>流程表单</el-radio>
|
|
|
|
|
|
<el-radio border label='20'>业务表单</el-radio>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label='流程标识' prop='key'>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model='formData.key'
|
|
|
|
|
|
:disabled='!!formData.id'
|
|
|
|
|
|
clearable
|
|
|
|
|
|
placeholder='请输入流程标识'
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label='流程名称' prop='name'>
|
|
|
|
|
|
<el-input
|
|
|
|
|
|
v-model='formData.name'
|
|
|
|
|
|
:disabled='!!formData.id'
|
|
|
|
|
|
clearable
|
|
|
|
|
|
placeholder='请输入流程名称'
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label='流程分类' prop='category'>
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
v-model='formData.category'
|
|
|
|
|
|
clearable
|
|
|
|
|
|
placeholder='请选择流程分类'
|
|
|
|
|
|
style='width: 100%'
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for='category in categoryList'
|
|
|
|
|
|
:key='category.id'
|
|
|
|
|
|
:label='category.name'
|
|
|
|
|
|
:value='category.id'
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- <el-form-item v-if='formData.id' label='流程图标' prop='icon'>-->
|
|
|
|
|
|
<!-- <UploadImg v-model='formData.icon' :limit='1' height='128px' width='128px' />-->
|
|
|
|
|
|
<!-- </el-form-item>-->
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label='流程描述' prop='description'>
|
|
|
|
|
|
<el-input v-model='formData.description' clearable type='textarea' />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
<el-form-item label='流程表单' prop='formId' v-if='formData.formType == "10"'>
|
|
|
|
|
|
<el-select v-model='formData.formId' clearable style='width: 100%'>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for='form in formList'
|
|
|
|
|
|
:key='form.id'
|
|
|
|
|
|
:label='form.name'
|
|
|
|
|
|
:value='form.id'
|
|
|
|
|
|
/>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- <el-form-item label='表单提交路由' prop='description'>-->
|
|
|
|
|
|
<!-- <el-input v-model='formData.description' clearable type='textarea' />-->
|
|
|
|
|
|
<!-- </el-form-item>-->
|
|
|
|
|
|
<el-form-item v-else label='表单查看路由' prop='formCustomViewPath'>
|
|
|
|
|
|
<el-input v-model='formData.formCustomViewPath' />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-scrollbar>
|
|
|
|
|
|
|
|
|
|
|
|
<template #footer>
|
2024-05-09 14:18:39 +08:00
|
|
|
|
<span class='dialog-footer'>
|
|
|
|
|
|
<el-button @click='dialogVisible = false'>取消</el-button>
|
|
|
|
|
|
<el-button type='primary' @click='submit'>确认</el-button>
|
|
|
|
|
|
</span>
|
2024-05-13 18:36:19 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</el-dialog>
|
2024-05-09 14:18:39 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
<script lang='ts' setup>
|
|
|
|
|
|
import { ref, inject, reactive, nextTick } from 'vue'
|
|
|
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
|
|
import TableStore from '@/utils/tableStore' // 若不是列表页面弹框可删除
|
|
|
|
|
|
import { getFormSimpleList } from '@/api/bpm-boot/form'
|
|
|
|
|
|
import { getCategorySimpleList } from '@/api/bpm-boot/category'
|
|
|
|
|
|
import { addModel, updateModel } from '@/api/bpm-boot/model'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//传入type的名称
|
|
|
|
|
|
const categoryList = ref()
|
|
|
|
|
|
const formList = ref()
|
|
|
|
|
|
|
|
|
|
|
|
const title = ref('')
|
|
|
|
|
|
const tableStore = inject('tableStore') as TableStore
|
|
|
|
|
|
const formRef = ref()
|
|
|
|
|
|
|
|
|
|
|
|
const dialogVisible = ref(false)
|
|
|
|
|
|
// 注意不要和表单ref的命名冲突
|
|
|
|
|
|
const formData = reactive({
|
2024-05-13 18:36:19 +08:00
|
|
|
|
id: '',
|
|
|
|
|
|
key: '',
|
|
|
|
|
|
name: '',
|
|
|
|
|
|
category: '',
|
|
|
|
|
|
icon: '',
|
|
|
|
|
|
description: '',
|
|
|
|
|
|
formType: '20',
|
|
|
|
|
|
formCustomCreatePath: '',
|
|
|
|
|
|
formCustomViewPath: '',
|
|
|
|
|
|
formId: ''
|
2024-05-09 14:18:39 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
//form表单校验规则
|
|
|
|
|
|
const rules = {
|
2024-05-13 18:36:19 +08:00
|
|
|
|
key: [{ required: true, message: '流程标识不能为空', trigger: 'blur' }],
|
|
|
|
|
|
name: [{ required: true, message: '流程名称不能为空', trigger: 'blur' }],
|
|
|
|
|
|
category: [{ required: true, message: '流程分类不能为空', trigger: 'change' }],
|
|
|
|
|
|
formType: [{ required: true, message: '表单类型不能为空', trigger: 'change' }]
|
2024-05-09 14:18:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
const resetForm = () => {
|
2024-05-13 18:36:19 +08:00
|
|
|
|
if (formRef.value) {
|
|
|
|
|
|
formRef.value.resetFields()
|
|
|
|
|
|
}
|
2024-05-09 14:18:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const open = async (text: string, data?: any) => {
|
2024-05-13 18:36:19 +08:00
|
|
|
|
title.value = text
|
|
|
|
|
|
await getFormSimpleList().then(res => {
|
|
|
|
|
|
formList.value = res.data
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
await getCategorySimpleList().then(res => {
|
|
|
|
|
|
categoryList.value = res.data
|
|
|
|
|
|
})
|
|
|
|
|
|
//默认选中第一个tab
|
|
|
|
|
|
if (data) {
|
|
|
|
|
|
// 表单赋值
|
|
|
|
|
|
for (let key in formData) {
|
|
|
|
|
|
formData[key] = data[key]
|
2024-05-09 14:18:39 +08:00
|
|
|
|
}
|
2024-05-13 18:36:19 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
resetForm()
|
|
|
|
|
|
// 在此处恢复默认表单
|
|
|
|
|
|
for (let key in formData) {
|
|
|
|
|
|
formData[key] = ''
|
|
|
|
|
|
}
|
|
|
|
|
|
//随机一个key给该模型
|
|
|
|
|
|
formData.formType = '20'
|
|
|
|
|
|
}
|
|
|
|
|
|
dialogVisible.value = true
|
2024-05-09 14:18:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 提交用户表单数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
const submit = () => {
|
2024-05-13 18:36:19 +08:00
|
|
|
|
formRef.value.validate(async (valid: any) => {
|
|
|
|
|
|
if (valid) {
|
|
|
|
|
|
if (formData.id) {
|
|
|
|
|
|
await updateModel(formData)
|
|
|
|
|
|
ElMessage.success('更新成功')
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
} else {
|
|
|
|
|
|
await addModel(formData).then(res => {
|
|
|
|
|
|
formData.id = res.data
|
|
|
|
|
|
//查询进线数据,避免一直处于loading状态
|
|
|
|
|
|
ElMessage.success('保存成功')
|
|
|
|
|
|
tableStore.index()
|
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-05-09 14:18:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
defineExpose({ open })
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.el-upload-list__item {
|
2024-05-13 18:36:19 +08:00
|
|
|
|
transition: none !important;
|
2024-05-09 14:18:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.el-select {
|
2024-05-13 18:36:19 +08:00
|
|
|
|
min-width: 180px;
|
2024-05-09 14:18:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
</style>
|