edi-block

master
wangxinglong 2022-02-28 13:53:41 +08:00
parent 31e9432ba0
commit 6c80493328
8 changed files with 229 additions and 37 deletions

View File

@ -20,6 +20,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\DbException; use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException; use think\db\exception\ModelNotFoundException;
use think\exception\ValidateException; use think\exception\ValidateException;
use think\facade\Config as CConfig;
/** /**
@ -31,6 +32,7 @@ class Block extends Base
protected function initialize() protected function initialize()
{ {
parent::initialize(); parent::initialize();
$action = $this->request->action(); $action = $this->request->action();
$cid = $this->request->param('cid/d'); $cid = $this->request->param('cid/d');
@ -44,7 +46,12 @@ class Block extends Base
$this->data['currentList'] = $currentShowFields; $this->data['currentList'] = $currentShowFields;
} }
$this->data['jsonList'] = $this->xmSelectJson([$cid]); $this->data['jsonList'] = $this->xmSelectJson([$cid]);
CConfig::load('extra/upload', 'system_upload');
if(empty(config('system_upload'))){
$this->data['uploadConfig'] = System::findById(1);
}else{
$this->data['uploadConfig'] = config('system_upload');
}
} }
public function index() public function index()
@ -176,6 +183,7 @@ class Block extends Base
$this->data['maxKey'] = 0; $this->data['maxKey'] = 0;
} }
$this->data["item"] = $item; $this->data["item"] = $item;
$this->data["config"] = $item;
$this->data["types"] = BlockModel::getTypes(); $this->data["types"] = BlockModel::getTypes();
return $this->view(); return $this->view();

View File

@ -3,6 +3,7 @@
namespace app\controller\manager; namespace app\controller\manager;
use app\model\System;
use Exception; use Exception;
use think\facade\Config as CConfig; use think\facade\Config as CConfig;
@ -63,7 +64,25 @@ class Config extends Base
} }
} }
public function upload()
{
if ($this->request->isPost()) {
$data = input("post.");
System::updateById(1,$data);
unset($data['_token']);
$php = var_export($data, true);
file_put_contents($this->extraPath . 'upload.php', '<?php' . PHP_EOL . 'return ' . $php . ';');
return $this->json();
} else {
CConfig::load('extra/upload', 'system_upload');
if(empty(config('system_upload'))){
$this->data['item'] = System::findById(1);
}else{
$this->data['item'] = config('system_upload');
}
return $this->view();
}
}
public function __call($name, $args) public function __call($name, $args)
{ {
if ($this->request->isPost()) { if ($this->request->isPost()) {

View File

@ -140,7 +140,7 @@ class Block extends Base
public function getContentAttr($value,$data) public function getContentAttr($value,$data)
{ {
if($data['type'] == self::ING_LIST){ if($data['type'] == self::ING_LIST){
return json_decode($value,true) return json_decode($value,true);
} }
return $value; return $value;
} }

View File

@ -24,11 +24,11 @@ return [
// 服务器地址 // 服务器地址
'hostname' => Env::get('database.hostname', '183.221.101.89'), 'hostname' => Env::get('database.hostname', '183.221.101.89'),
// 数据库名 // 数据库名
'database' => Env::get('database.database', 'newest_cms'), 'database' => Env::get('database.database', 'luck_draw'),
// 用户名 // 用户名
'username' => Env::get('database.username', 'newest_cms'), 'username' => Env::get('database.username', 'luck_draw'),
// 密码 // 密码
'password' => Env::get('database.password', '7pMZSGFP3fGm526w'), 'password' => Env::get('database.password', '722s6Gm5n3M3mmpn'),
// 端口 // 端口
'hostport' => Env::get('database.hostport', '3306'), 'hostport' => Env::get('database.hostport', '3306'),
// 数据库连接参数 // 数据库连接参数

View File

@ -11,6 +11,8 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'tree', 'xmSelect', '
let parentMenu = $('#parent-menu'); let parentMenu = $('#parent-menu');
let menuList = parentMenu.data('menu') ? parentMenu.data('menu') : []; let menuList = parentMenu.data('menu') ? parentMenu.data('menu') : [];
let showList = parentMenu.data('show') ? parentMenu.data('show') : [];//各栏目 可展示字段列表 let showList = parentMenu.data('show') ? parentMenu.data('show') : [];//各栏目 可展示字段列表
let image_exts = $('#image_exts').data('exts') ? parentMenu.data('exts') : "jpg|png|gif|bmp|jpeg";//图片上传后缀
xmSelect.render({ xmSelect.render({
el: '#parent-menu', el: '#parent-menu',
paging: false, paging: false,
@ -208,7 +210,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'tree', 'xmSelect', '
, field: 'image_image' , field: 'image_image'
, accept: 'images' , accept: 'images'
, acceptMime: 'images/*' , acceptMime: 'images/*'
, exts: 'jpg|png|gif|bmp|jpeg' , exts: image_exts
, size: 50 * 1204 , size: 50 * 1204
, number: 0 , number: 0
, multiple: false , multiple: false
@ -299,7 +301,7 @@ layui.use(['laytpl', 'table', 'jquery', 'form', 'miniTab', 'tree', 'xmSelect', '
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">排序</label> <label class="layui-form-label">排序</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="content7[${key}][sort]" class="layui-input"> <input type="number" name="content7[${key}][sort]" class="layui-input">
</div> </div>
</div> </div>

View File

@ -3,6 +3,8 @@
.upload-file-div{position: relative} .upload-file-div{position: relative}
.upload-file-div-close{position: absolute;right: 0;top: 0;} .upload-file-div-close{position: absolute;right: 0;top: 0;}
</style> </style>
<div id="image_exts" data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"></div>
<div class="layui-form layuimini-form location-operate-page"> <div class="layui-form layuimini-form location-operate-page">
<div class="page-form"> <div class="page-form">
@ -72,14 +74,28 @@
</div> </div>
<div class="layui-col-xs12 layui-col-md3"> <div class="layui-col-xs12 layui-col-md3">
<span> <span>
<button type="button" class="layui-btn layui-btn-danger upload-btn"> <button type="button" class="layui-btn layui-btn-danger upload-btn"
data-type="image"
data-multiple="false"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>
</span> </span>
<span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn" <span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn"
data-url="/manager/attachment/image" data-url="/manager/attachment/image"
data-type="image" data-type="image"
data-multiple="false"> data-multiple="true"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-list"></i> 选择 <i class="fa fa-list"></i> 选择
</button></span> </button></span>
</div> </div>
@ -99,14 +115,26 @@
</div> </div>
<div class="layui-col-xs12 layui-col-md3"> <div class="layui-col-xs12 layui-col-md3">
<span> <span>
<button type="button" class="layui-btn layui-btn-danger upload-btn"> <button type="button" class="layui-btn layui-btn-danger upload-btn"
data-type="image"
data-multiple="true"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>
</span> </span>
<span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn" <span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn"
data-url="/manager/attachment/image" data-url="/manager/attachment/image"
data-type="image" data-type="image"
data-multiple="true"> data-multiple="true"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-list"></i> 选择 <i class="fa fa-list"></i> 选择
</button></span> </button></span>
</div> </div>
@ -134,7 +162,7 @@
data-multiple='false' data-multiple='false'
data-mimetype='' data-mimetype=''
data-acceptMime='file/*' data-acceptMime='file/*'
data-exts='{:str_replace(",","|",$system["file_type"])}' data-exts="{:str_replace(',','|',$uploadConfig['file_type'])}"
class="layui-btn layui-btn-danger upload-btn"> class="layui-btn layui-btn-danger upload-btn">
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>
@ -170,7 +198,7 @@
data-multiple='false' data-multiple='false'
data-mimetype='' data-mimetype=''
data-acceptMime='video/*' data-acceptMime='video/*'
data-exts='{:str_replace(",","|",$system["file_type"])}' data-exts="{:str_replace(',','|',$uploadConfig['video_type'])}"
class="layui-btn layui-btn-danger upload-btn"> class="layui-btn layui-btn-danger upload-btn">
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>

View File

@ -3,6 +3,7 @@
.upload-file-div{position: relative} .upload-file-div{position: relative}
.upload-file-div-close{position: absolute;right: 0;top: 0;} .upload-file-div-close{position: absolute;right: 0;top: 0;}
</style> </style>
<div id="image_exts" data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"></div>
<div class="layui-form layuimini-form location-operate-page"> <div class="layui-form layuimini-form location-operate-page">
<div class="page-form"> <div class="page-form">
@ -53,7 +54,6 @@
<div class="layui-input-block" style="width:80%;z-index:0;"> <div class="layui-input-block" style="width:80%;z-index:0;">
<div class="editor"></div> <div class="editor"></div>
<textarea name="content1" class="layui-textarea layui-hide">{if (isset($item['content']) && $item['type'] == 1)}{:htmlspecialchars_decode($item['content'])}{/if}</textarea> <textarea name="content1" class="layui-textarea layui-hide">{if (isset($item['content']) && $item['type'] == 1)}{:htmlspecialchars_decode($item['content'])}{/if}</textarea>
</div> </div>
</div> </div>
<!-- 文本--> <!-- 文本-->
@ -74,14 +74,26 @@
</div> </div>
<div class="layui-col-xs12 layui-col-md3"> <div class="layui-col-xs12 layui-col-md3">
<span> <span>
<button type="button" class="layui-btn layui-btn-danger upload-btn"> <button type="button" class="layui-btn layui-btn-danger upload-btn"
data-type="image"
data-multiple="false"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>
</span> </span>
<span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn" <span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn"
data-url="/manager/attachment/image" data-url="/manager/attachment/image"
data-type="image" data-type="image"
data-multiple="false"> data-multiple="false"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-list"></i> 选择 <i class="fa fa-list"></i> 选择
</button></span> </button></span>
</div> </div>
@ -92,7 +104,7 @@
<!-- 组图--> <!-- 组图-->
<div class="layui-form-item content" {if $item['type'] != 4 } style="display:none" {/if}> <div class="layui-form-item content" {if $item['type'] != 4 } style="display:none" {/if}>
<label class="layui-form-label required">轮播图:</label> <label class="layui-form-label required">图:</label>
<div class="layui-inline layui-col-xs12 layui-col-md8"> <div class="layui-inline layui-col-xs12 layui-col-md8">
<div class="layui-row upload-file-div"> <div class="layui-row upload-file-div">
<div class=" layui-col-xs12 layui-col-md8"> <div class=" layui-col-xs12 layui-col-md8">
@ -101,14 +113,25 @@
</div> </div>
<div class="layui-col-xs12 layui-col-md3"> <div class="layui-col-xs12 layui-col-md3">
<span> <span>
<button type="button" class="layui-btn layui-btn-danger upload-btn"> <button type="button" class="layui-btn layui-btn-danger upload-btn"
data-type="image"
data-multiple="true"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>
</span> </span>
<span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn" <span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn"
data-url="/manager/attachment/image" data-url="/manager/attachment/image"
data-type="image" data-type="image"
data-multiple="true"> data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-list"></i> 选择 <i class="fa fa-list"></i> 选择
</button></span> </button></span>
</div> </div>
@ -134,15 +157,20 @@
data-multiple='false' data-multiple='false'
data-mimetype='' data-mimetype=''
data-acceptMime='file/*' data-acceptMime='file/*'
data-exts='{:str_replace(",","|",config("system.file_type"))}' data-exts="{:str_replace(',','|',$uploadConfig['file_type'])}"
class="layui-btn layui-btn-danger upload-btn"> class="layui-btn layui-btn-danger upload-btn">
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>
</span> </span>
<span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn" <span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn"
data-url="/manager/attachment/file" data-url="/manager/attachment/file"
data-type="file" data-field='file_file'
data-multiple="false"> data-accept='file'
data-multiple='false'
data-mimetype=''
data-acceptMime='file/*'
data-exts="{:str_replace(',','|',$uploadConfig['file_type'])}"
>
<i class="fa fa-list"></i> 选择 <i class="fa fa-list"></i> 选择
</button></span> </button></span>
</div> </div>
@ -166,12 +194,13 @@
<span> <span>
<button type="button" <button type="button"
data-url='/manager/upload/video' data-url='/manager/upload/video'
data-type="file"
data-field='video_video' data-field='video_video'
data-accept='file' data-accept='file'
data-multiple='false' data-multiple='false'
data-mimetype='' data-mimetype=''
data-acceptMime='video/*' data-acceptMime='video/*'
data-exts='{:str_replace(",","|",config("system.video_type"))}' data-exts="{:str_replace(',','|',$uploadConfig['video_type'])}"
class="layui-btn layui-btn-danger upload-btn"> class="layui-btn layui-btn-danger upload-btn">
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>
@ -180,6 +209,11 @@
data-url="/manager/attachment/video" data-url="/manager/attachment/video"
data-multiple="false" data-multiple="false"
data-type="file" data-type="file"
data-field='video_video'
data-accept='file'
data-mimetype=''
data-acceptMime='video/*'
data-exts="{:str_replace(',','|',$uploadConfig['video_type'])}"
> >
<i class="fa fa-list"></i> 选择 <i class="fa fa-list"></i> 选择
</button></span> </button></span>
@ -205,14 +239,27 @@
</div> </div>
<div class="layui-col-xs12 layui-col-md3"> <div class="layui-col-xs12 layui-col-md3">
<span> <span>
<button type="button" class="layui-btn layui-btn-danger " id="ImgListNode-upload-btn-{$ckey}"> <button type="button" class="layui-btn layui-btn-danger " id="ImgListNode-upload-btn-{$ckey}"
data-type="image"
data-multiple="false"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-upload"></i> 上传 <i class="fa fa-upload"></i> 上传
</button> </button>
</span> </span>
<span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn" <span><button type="button" class="layui-btn layui-btn-primary upload-choose-btn"
data-url="/manager/attachment/image" data-url="/manager/attachment/image"
data-type="image" data-type="image"
data-multiple="false"> data-multiple="false"
data-field="image_image"
data-accept="images"
data-mimetype="images/*"
data-exts="{:str_replace(',','|',$uploadConfig['img_type'])}"
>
<i class="fa fa-list"></i> 选择 <i class="fa fa-list"></i> 选择
</button></span> </button></span>
</div> </div>
@ -255,7 +302,7 @@
<div class="layui-inline"> <div class="layui-inline">
<label class="layui-form-label">排序</label> <label class="layui-form-label">排序</label>
<div class="layui-input-inline"> <div class="layui-input-inline">
<input type="text" name="content7[{$ckey}][sort]" value="{$citem['sort']??0}" class="layui-input"> <input type="number" name="content7[{$ckey}][sort]" value="{$citem['sort']??0}" class="layui-input">
</div> </div>
</div> </div>

View File

@ -0,0 +1,88 @@
{layout name="manager/layout" /}
<link rel="stylesheet" href="__MANAGER__/css/config.css" media="all">
<div class="layuimini-container">
<div class="layuimini-main">
<div class="layui-form layuimini-form">
<div class="config-group-item">
<div class="config-group-title">图片</div>
<hr>
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label">图片后缀</label>
<div class="layui-input-inline" style="width: 550px">
<input class="layui-input" type="text" name="img_type" value="{$item.img_type ?? ''}" />
</div>
<div class="layui-form-mid layui-word-aux">用,分割</div>
</div>
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label">图片大小</label>
<div class="layui-input-inline" style="width: 550px">
<input class="layui-input" type="number" name="img_size" value="{$item.img_size ?? '0'}" />
</div>
<div class="layui-form-mid layui-word-aux">(单位:M</div>
</div>
</div>
<div class="config-group-item">
<div class="config-group-title">视瓶</div>
<hr>
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label">视瓶后缀</label>
<div class="layui-input-inline" style="width: 550px">
<input class="layui-input" type="text" name="video_type" value="{$item.video_type ?? ''}"/>
</div>
<div class="layui-form-mid layui-word-aux">用,分割</div>
</div>
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label">视瓶大小</label>
<div class="layui-input-inline" style="width: 550px">
<input class="layui-input" type="number" name="video_size" value="{$item.video_size ?? '0'}" />
</div>
<div class="layui-form-mid layui-word-aux">(单位:M</div>
</div>
</div>
<div class="config-group-item">
<div class="config-group-title">文件</div>
<hr>
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label">文件后缀</label>
<div class="layui-input-inline" style="width: 550px">
<input class="layui-input" type="text" name="file_type" value="{$item.file_type ?? ''}" />
</div>
<div class="layui-form-mid layui-word-aux">用,分割</div>
</div>
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label">文件大小</label>
<div class="layui-input-inline" style="width: 550px">
<input class="layui-input" type="number" name="file_size" value="{$item.file_size ?? '0'}"/>
</div>
<div class="layui-form-mid layui-word-aux">(单位:M</div>
</div>
</div>
<div class="config-group-item">
<div class="layui-form-item layui-form-item-lg">
<label class="layui-form-label"></label>
<div class="layui-input-block">
<button class="layui-btn layui-btn-normal" data-url="/manager/config/upload" lay-submit lay-filter="saveConfig">确认保存</button>
</div>
</div>
</div>
</div>
</div>
</div>
<style>
</style>