后端增加资源发布功能
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
<?php /*a:2:{s:67:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\articlecate.php";i:1747384911;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
|
||||
<?php /*a:2:{s:67:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\article\articlecate.php";i:1747387836;s:61:"E:\Demos\DemoOwns\PHP\yunzer\app\admin\view\public\header.php";i:1746849526;}*/ ?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@@ -505,10 +505,31 @@
|
||||
// 更新父级分类选项
|
||||
var $select = $('select[name="cid"]');
|
||||
$select.empty().append('<option value="0">顶级分类</option>');
|
||||
if (data && data.parentOptions) {
|
||||
data.parentOptions.forEach(function (item) {
|
||||
$select.append('<option value="' + item.id + '">' + item.name + '</option>');
|
||||
});
|
||||
// 获取所有分类作为父级选项
|
||||
$.ajax({
|
||||
url: '/admin/article/articlecate',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
if (res.code === 0) {
|
||||
// 当前编辑的分类ID
|
||||
var currentId = data ? data.info.id : 0;
|
||||
// 递归构建分类选项
|
||||
function buildOptions(categories, level) {
|
||||
categories.forEach(function (category) {
|
||||
// 不能选择自己或自己的子分类作为父级
|
||||
if (category.id != currentId) {
|
||||
var prefix = new Array(level + 1).join('├─ ');
|
||||
$select.append('<option value="' + category.id + '">' + prefix + category.title + '</option>'); if (category.children && category.children.length > 0) { buildOptions(category.children, level + 1); }
|
||||
}
|
||||
});
|
||||
} buildOptions(res.data, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
// 设置选中的父级分类
|
||||
if (data && data.info.cid) {
|
||||
$select.val(data.info.cid);
|
||||
}
|
||||
|
||||
// 更新图片预览
|
||||
|
||||
Reference in New Issue
Block a user