|
|
@@ -134,7 +134,7 @@
|
|
|
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
|
|
|
<el-form ref="dirTemplateRef" :model="form" :rules="rules" label-width="80px">
|
|
|
<el-form-item label="模板名称" prop="tmplName">
|
|
|
- <el-input v-model="form.tmplName" placeholder="请输入模板名称"/>
|
|
|
+ <el-input v-model="tempTitle" placeholder="请输入模板名称"/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="模板内容" prop="tmplContent">
|
|
|
<el-tree
|
|
|
@@ -149,8 +149,8 @@
|
|
|
<span>{{ node.label }}</span>
|
|
|
<span>
|
|
|
<a class="btm" @click="append(data)"> 增加 </a>
|
|
|
- <a class="btm" @click="updataNode(data)"> 修改 </a>
|
|
|
- <a class="btm" style="margin-left: 8px" @click="remove(node, data)"> 删除 </a>
|
|
|
+ <a class="btm" v-if="data.id != 1" @click="updataNode(data)"> 修改 </a>
|
|
|
+ <a class="btm" v-if="data.id != 1" style="margin-left: 8px" @click="remove(node, data)"> 删除 </a>
|
|
|
</span>
|
|
|
</span>
|
|
|
</template>
|
|
|
@@ -188,6 +188,7 @@ import {
|
|
|
listDirTemplate,
|
|
|
updateDirTemplate
|
|
|
} from "@/api/biz/dirTemplate";
|
|
|
+import { ElMessage} from 'element-plus'
|
|
|
|
|
|
const {proxy} = getCurrentInstance();
|
|
|
|
|
|
@@ -204,8 +205,9 @@ const showMenuName = ref(false)
|
|
|
const newName = ref()
|
|
|
const tempId = ref(1000)
|
|
|
const upNodeData = ref()
|
|
|
+const tempTitle = ref('')
|
|
|
const tempData = ref([
|
|
|
- {id:1,label:'folder',children:[
|
|
|
+ {id:1,label:tempTitle,children:[
|
|
|
|
|
|
]}
|
|
|
])
|
|
|
@@ -288,7 +290,12 @@ function handleUpdate(row) {
|
|
|
reset();
|
|
|
const _tmplId = row.tmplId || ids.value
|
|
|
getDirTemplate(_tmplId).then(response => {
|
|
|
+ console.log('response',response);
|
|
|
form.value = response.data;
|
|
|
+ tempTitle.value = response.data.tmplName
|
|
|
+ const arr = JSON.parse(response.data.tmplContent)
|
|
|
+ tempData.value = [{id:1,label:tempTitle,children:[]}]
|
|
|
+ tempData.value[0].children = arr
|
|
|
open.value = true;
|
|
|
title.value = "修改目录模板";
|
|
|
});
|
|
|
@@ -297,8 +304,15 @@ function handleUpdate(row) {
|
|
|
/** 提交按钮 */
|
|
|
function submitForm() {
|
|
|
proxy.$refs["dirTemplateRef"].validate(valid => {
|
|
|
- const str = JSON.stringify(tempData.value)
|
|
|
+ if(!tempTitle.value){
|
|
|
+ return ElMessage({
|
|
|
+ message: "模板名不能为空",
|
|
|
+ type: "error"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ const str = JSON.stringify(tempData.value[0].children)
|
|
|
form.value.tmplContent = str
|
|
|
+ form.value.tmplName = tempTitle.value
|
|
|
if (valid) {
|
|
|
if (form.value.tmplId != null) {
|
|
|
updateDirTemplate(form.value).then(response => {
|
|
|
@@ -357,16 +371,23 @@ const remove = (node, data)=>{
|
|
|
}
|
|
|
// 修改目录节点
|
|
|
const updataNode = (data)=>{
|
|
|
+ newName.value = ''
|
|
|
newName.value = data.label
|
|
|
showMenuName.value = true
|
|
|
upNodeData.value = data
|
|
|
}
|
|
|
const submitMenuName = ()=>{
|
|
|
+ if(!newName.value){
|
|
|
+ return ElMessage({
|
|
|
+ message: "目录名不能为空",
|
|
|
+ type: "error"
|
|
|
+ })
|
|
|
+ }
|
|
|
const oldArr = tempData.value
|
|
|
const getNewData = (data)=>{
|
|
|
data.map(item=>{
|
|
|
if(item.id == upNodeData.value.id){
|
|
|
- console.log(1);
|
|
|
+ // console.log(1);
|
|
|
item.label = newName.value
|
|
|
return
|
|
|
}
|
|
|
@@ -392,6 +413,9 @@ const cancelMenuName = ()=>{
|
|
|
}
|
|
|
const cancelAddTemp = ()=>{
|
|
|
open.value = false
|
|
|
+ newName.value = ''
|
|
|
+ tempTitle.value = ''
|
|
|
+ tempData.value = []
|
|
|
}
|
|
|
|
|
|
getList();
|