Compare commits
No commits in common. "52ce51e00b740c5f763479ccdf411d769dc63e0e" and "7ff8481e70f227c94da4dbca32d36a6e8c6630e7" have entirely different histories.
52ce51e00b
...
7ff8481e70
@ -183,21 +183,3 @@ export function reqHomepageProductCategory(data){
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
//产品树更新 /product/homepage_category_tree_update.dspy
|
|
||||||
export function reqHomepageCategoryTreeUpdate(data){
|
|
||||||
return request({
|
|
||||||
url: '/product/homepage_category_tree_update.dspy',
|
|
||||||
method: 'post',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//产品树删除 /product/homepage_category_tree_delete.dspy
|
|
||||||
export function reqHomepageCategoryTreeDelete(data){
|
|
||||||
return request({
|
|
||||||
url: '/product/homepage_category_tree_delete.dspy',
|
|
||||||
method: 'post',
|
|
||||||
headers: { 'Content-Type': 'application/json' },
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@ -91,7 +91,7 @@
|
|||||||
|
|
||||||
<!-- 操作按钮 -->
|
<!-- 操作按钮 -->
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" @click="submitForm">{{ isEdit ? '保存' : '新增' }}</el-button>
|
<el-button type="primary" @click="submitForm">保存</el-button>
|
||||||
<el-button @click="resetForm">重置</el-button>
|
<el-button @click="resetForm">重置</el-button>
|
||||||
<el-button @click="drawer = false">取消</el-button>
|
<el-button @click="drawer = false">取消</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -104,7 +104,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { reqNcMatchMenu,reqAddProductMenu,reqHomepageCategoryTreeUpdate,reqHomepageCategoryTreeDelete } from '@/api/ncmatch';
|
import { reqNcMatchMenu,reqAddProductMenu } from '@/api/ncmatch';
|
||||||
export default {
|
export default {
|
||||||
name: 'menuMangement',
|
name: 'menuMangement',
|
||||||
data() {
|
data() {
|
||||||
@ -116,7 +116,6 @@ export default {
|
|||||||
direction: 'rtl',
|
direction: 'rtl',
|
||||||
labelPosition: 'right',
|
labelPosition: 'right',
|
||||||
|
|
||||||
isEdit: false,
|
|
||||||
formLabelAlign: {
|
formLabelAlign: {
|
||||||
name: '',
|
name: '',
|
||||||
icon: '',
|
icon: '',
|
||||||
@ -207,16 +206,8 @@ export default {
|
|||||||
}).catch(() => {});
|
}).catch(() => {});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 提交表单(区分新增与保存)
|
// 提交表单
|
||||||
submitForm() {
|
submitForm() {
|
||||||
// reqHomepageCategoryTreeUpdate({id:row.id,name:row.name,poriority:row.poriority,source:row.source,url_link:window.location.href}).then(res=>{
|
|
||||||
// if(res.status){
|
|
||||||
// this.$message.success('编辑成功!');
|
|
||||||
// this.getCategories();
|
|
||||||
// }else{
|
|
||||||
// this.$message.error(res.msg);
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
this.$refs.menuForm.validate((valid) => {
|
this.$refs.menuForm.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
// 创建FormData对象
|
// 创建FormData对象
|
||||||
@ -252,21 +243,8 @@ export default {
|
|||||||
console.log(`${key}:`, value);
|
console.log(`${key}:`, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 这里调用API保存数据(根据 isEdit 区分)
|
// 这里调用API保存数据
|
||||||
if (this.isEdit) {
|
|
||||||
this.updateMenuData({
|
|
||||||
id: this.formLabelAlign.id,
|
|
||||||
name: this.formLabelAlign.name,
|
|
||||||
poriority: this.formLabelAlign.poriority,
|
|
||||||
source: this.formLabelAlign.source,
|
|
||||||
parentid: this.formLabelAlign.parentid,
|
|
||||||
url_link: window.location.href,
|
|
||||||
// 如果是顶级并且未改图标,不传 icon 字段
|
|
||||||
// 图标更新仅在新增或更换图片时通过另一路径处理
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.saveMenuData(formData);
|
this.saveMenuData(formData);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.$message.error('请检查表单信息!');
|
this.$message.error('请检查表单信息!');
|
||||||
return false;
|
return false;
|
||||||
@ -274,7 +252,7 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
// 新增菜单数据
|
// 保存菜单数据
|
||||||
saveMenuData(formData) {
|
saveMenuData(formData) {
|
||||||
// 这里添加实际的API调用
|
// 这里添加实际的API调用
|
||||||
// 例如:
|
// 例如:
|
||||||
@ -296,21 +274,6 @@ export default {
|
|||||||
// console.log('FormData数据已准备就绪,可以发送到服务器');
|
// console.log('FormData数据已准备就绪,可以发送到服务器');
|
||||||
},
|
},
|
||||||
|
|
||||||
// 保存(编辑)菜单数据(非文件字段)
|
|
||||||
updateMenuData(payload) {
|
|
||||||
reqHomepageCategoryTreeUpdate(payload).then(res => {
|
|
||||||
if (res.status) {
|
|
||||||
this.$message.success('保存成功!');
|
|
||||||
this.drawer = false;
|
|
||||||
this.getCategories();
|
|
||||||
} else {
|
|
||||||
this.$message.error(res.msg);
|
|
||||||
}
|
|
||||||
}).catch(error => {
|
|
||||||
this.$message.error('保存失败:' + error.message);
|
|
||||||
})
|
|
||||||
},
|
|
||||||
|
|
||||||
// 重置表单
|
// 重置表单
|
||||||
resetForm() {
|
resetForm() {
|
||||||
this.$refs.menuForm.resetFields();
|
this.$refs.menuForm.resetFields();
|
||||||
@ -320,7 +283,6 @@ export default {
|
|||||||
addNode(row, type) {
|
addNode(row, type) {
|
||||||
this.drawer = true;
|
this.drawer = true;
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
this.isEdit = false;
|
|
||||||
if (type === 'child') {
|
if (type === 'child') {
|
||||||
this.formLabelAlign.parentid = row.id;
|
this.formLabelAlign.parentid = row.id;
|
||||||
} else if (type === 'sibling') {
|
} else if (type === 'sibling') {
|
||||||
@ -347,22 +309,17 @@ export default {
|
|||||||
this.formLabelAlign = { ...row };
|
this.formLabelAlign = { ...row };
|
||||||
// 编辑时清除iconFile,避免重复上传
|
// 编辑时清除iconFile,避免重复上传
|
||||||
this.formLabelAlign.iconFile = null;
|
this.formLabelAlign.iconFile = null;
|
||||||
this.isEdit = true;
|
console.log('编辑节点:', row);
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
deleteNode(row) {
|
deleteNode(row) {
|
||||||
|
this.$confirm('确定要删除这个菜单吗?', '提示', {
|
||||||
reqHomepageCategoryTreeDelete({id:row.id}).then(res=>{
|
confirmButtonText: '确定',
|
||||||
if(res.status){
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
console.log('删除节点:', row);
|
||||||
this.$message.success('删除成功!');
|
this.$message.success('删除成功!');
|
||||||
this.getCategories();
|
}).catch(() => {});
|
||||||
|
|
||||||
}else{
|
|
||||||
this.$message.error(res.msg);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
},
|
},
|
||||||
buildTree(data, parentId = null) {
|
buildTree(data, parentId = null) {
|
||||||
if (!Array.isArray(data)) {
|
if (!Array.isArray(data)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user