1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <template>
- <el-dialog
- :model-value="visible"
- @update:model-value="(val) => emit('update:visible', val)"
- :title="title"
- width="500"
- >
- <el-input
- v-model.trim="ivalue"
- :maxlength="100"
- show-word-limit
- type="textarea"
- placeholder="请输入"
- />
- <template #footer>
- <div class="dialog-footer">
- <el-button @click="emit('update:visible', false)">取消</el-button>
- <el-button type="primary" @click="submit"> 确定 </el-button>
- </div>
- </template>
- </el-dialog>
- </template>
- <script setup lang="ts">
- import { ElMessage } from "element-plus";
- import { ref, watchEffect } from "vue";
- const props = defineProps<{
- visible: boolean;
- value: string;
- title: string;
- updateValue: (value: string) => void;
- }>();
- const emit = defineEmits<{
- (e: "update:visible", visible: boolean): void;
- }>();
- const ivalue = ref(props.value);
- watchEffect(() => {
- ivalue.value = props.value;
- });
- const submit = async () => {
- if (ivalue.value.length === 0) {
- return ElMessage.error("点位名称不能为空!");
- }
- await props.updateValue(ivalue.value);
- emit("update:visible", false);
- };
- </script>
|