Commit e639e422 authored by zL's avatar zL

禁止修改名称可为空

parent 9399a8ea
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
<dialog-input <dialog-input
class="dialog_add-form dialog_add-input_name" class="dialog_add-form dialog_add-input_name"
v-model="editTitle" v-model="editTitle"
:errorShowing="isErrorShowing"
placeholder="请输入标题名称" placeholder="请输入标题名称"
/> />
<button class="dialog_add-btn_confirm" @click="changeEdit">确定</button> <button class="dialog_add-btn_confirm" @click="changeEdit">确定</button>
...@@ -12,34 +13,37 @@ ...@@ -12,34 +13,37 @@
</template> </template>
<script> <script>
import { Property, Unit } from "@/plugins/types";
import DialogInput from "@/components/DialogInput.vue"; import DialogInput from "@/components/DialogInput.vue";
export default { export default {
// 引入组件 // 引入组件
components: { components: {
DialogInput DialogInput,
}, },
props: ["selectedEditItem"], props: ["selectedEditItem"],
data() { data() {
return { return {
editTitle: "" editTitle: "",
isErrorShowing: false,
}; };
}, },
watch: { watch: {
selectedEditItem: { selectedEditItem: {
handler(newName, oldName) { handler(newName, oldName) {
if (newName.title) this.editTitle = newName.title; if (newName.title) this.editTitle = newName.title;
if (newName.label) this.editTitle = newName.label; if (newName.label) this.editTitle = newName.label;
}, },
deep: true, deep: true,
immediate: true immediate: true,
} },
}, },
created() {}, created() {},
computed: {}, computed: {},
methods: { methods: {
changeEdit() { changeEdit() {
if (this.editTitle.trim() === "") {
this.isErrorShowing = true;
return;
}
this.$nextTick(() => { this.$nextTick(() => {
if (this.selectedEditItem) { if (this.selectedEditItem) {
if (this.selectedEditItem.hasOwnProperty("title")) if (this.selectedEditItem.hasOwnProperty("title"))
...@@ -59,13 +63,13 @@ export default { ...@@ -59,13 +63,13 @@ export default {
) { ) {
this.$message({ this.$message({
message: "标题不可为空", message: "标题不可为空",
type: "warning" type: "warning",
}); });
return false; return false;
} }
this.$emit("close"); this.$emit("close");
} },
} },
}; };
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment