forked from SmartBench/CMVR-IOT-UI
135 lines
3.0 KiB
Vue
135 lines
3.0 KiB
Vue
<template>
|
|
<el-dialog
|
|
v-model="visible"
|
|
:title="title"
|
|
width="700px"
|
|
destroy-on-close
|
|
>
|
|
<el-form
|
|
ref="formRef"
|
|
:model="formData"
|
|
:rules="formRules"
|
|
label-width="80px"
|
|
>
|
|
<el-form-item label="界面名称" prop="uiKey">
|
|
<el-select v-model="formData.uiKey">
|
|
<el-option
|
|
v-for="dict in ti_ui_config"
|
|
:key="dict.value"
|
|
:label="dict.label"
|
|
:value="dict.label"
|
|
/>
|
|
</el-select>
|
|
</el-form-item>
|
|
<el-form-item label="上传图片">
|
|
<FileUpload v-model="imgUrl" :limit="1" :fileSize="5" :fileType="['png', 'jpg', 'jpeg']" />
|
|
</el-form-item>
|
|
<el-form-item label="描述" prop="remark">
|
|
<el-input
|
|
v-model="formData.remark"
|
|
type="textarea"
|
|
:rows="3"
|
|
placeholder="请输入描述"
|
|
/>
|
|
</el-form-item>
|
|
</el-form>
|
|
<FunctionSelection :funcIds="props.formData.funcIds" :selectNode="selectNode" :selectIds="selectIds" @updateSelectRows="getSelectRows" />
|
|
<template #footer>
|
|
<span class="dialog-footer">
|
|
<el-button @click="handleCancel">取消</el-button>
|
|
<el-button type="primary" @click="handleConfirm">确认</el-button>
|
|
</span>
|
|
</template>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script setup>
|
|
import { ref, watch } from 'vue'
|
|
import { useDict } from '@/utils/dict'
|
|
import FunctionSelection from './FunctionSelection.vue'
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
const props = defineProps({
|
|
visible: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
title: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
formData: {
|
|
type: Object,
|
|
default: () => {}
|
|
},
|
|
selectNode: {
|
|
type: Object,
|
|
default: () => {}
|
|
}
|
|
})
|
|
const emit = defineEmits(['update:visible', 'confirm'])
|
|
|
|
const imgUrl = ref('')
|
|
const { ti_ui_config } = useDict("ti_ui_config");
|
|
|
|
const formRef = ref()
|
|
|
|
// 表单验证规则
|
|
const formRules = {
|
|
uiKey: [
|
|
{ required: true, message: '请输入界面名称', trigger: 'blur' }
|
|
]
|
|
}
|
|
|
|
const visible = ref(props.visible)
|
|
|
|
watch(() => props.visible, (newVal) => {
|
|
visible.value = newVal
|
|
if (props.formData.uiUrl) {
|
|
imgUrl.value = props.formData.uiUrl
|
|
}
|
|
if (props.formData.funcIds) {
|
|
selectIds.value = props.formData.funcIds.split(',')
|
|
}
|
|
})
|
|
|
|
watch(visible, (newVal) => {
|
|
emit('update:visible', newVal)
|
|
})
|
|
|
|
function handleConfirm() {
|
|
if (selectIds.value.length === 0) {
|
|
ElMessage.warning('请先选择功能')
|
|
return
|
|
}
|
|
if (!formRef.value) return
|
|
|
|
formRef.value.validate((valid) => {
|
|
const obj = {
|
|
...props.formData,
|
|
funcIds: selectIds.value.toString()
|
|
}
|
|
if (imgUrl.value && imgUrl.value.length > 0) {
|
|
obj.uiUrl = imgUrl.value
|
|
}
|
|
emit('confirm', valid, { ...obj })
|
|
})
|
|
}
|
|
|
|
function handleCancel() {
|
|
visible.value = false
|
|
}
|
|
|
|
const selectIds = ref([])
|
|
const getSelectRows = (arr) => {
|
|
selectIds.value = arr.map(item => item.id);
|
|
};
|
|
</script>
|
|
|
|
<style scoped>
|
|
.dialog-footer {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
gap: 12px;
|
|
}
|
|
</style> |