mirror of https://gitee.com/karson/fastadmin.git
附件支持多站点
parent
3c6c284bd5
commit
2808709fd3
|
|
@ -38,6 +38,7 @@ class Attachment extends Backend
|
|||
|
||||
$list = $this->model
|
||||
->where($where)
|
||||
->with('sites')
|
||||
->order($sort, $order)
|
||||
->limit($offset, $limit)
|
||||
->select();
|
||||
|
|
@ -52,6 +53,7 @@ class Attachment extends Backend
|
|||
|
||||
return json($result);
|
||||
}
|
||||
$this->assignconfig('show_sitename', $this->auth->isSuperAdmin());
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
|
@ -64,6 +66,8 @@ class Attachment extends Backend
|
|||
{
|
||||
return $this->index();
|
||||
}
|
||||
$siteId = $this->request->param("site_id");
|
||||
$this->assignconfig('site_id',$siteId);
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ class Sites extends Backend
|
|||
$row['custom'] = !empty($row->config->custom) ? json_decode($row->config->custom,true) : null;
|
||||
$this->view->assign("row", $row);
|
||||
$this->view->assign('editstyle', $this->auth->isSuperAdmin()?'1':'0');
|
||||
$this->assignconfig('site_id',$row->id);
|
||||
$this->view->assign('multilanguage', Seven::build_langs('row[lang]', $row['lang'], ['type'=>'checkbox']));
|
||||
return $this->view->fetch();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
|
||||
class SitesConfig extends \app\common\model\SitesConfig
|
||||
{
|
||||
|
||||
}
|
||||
|
|
@ -22,6 +22,11 @@ class Attachment extends Model
|
|||
}
|
||||
}
|
||||
|
||||
public function sites()
|
||||
{
|
||||
return $this->belongsTo('Sites', 'site_id','id')->field('id,name');
|
||||
}
|
||||
|
||||
public function setUploadtimeAttr($value)
|
||||
{
|
||||
return strtotime($value);
|
||||
|
|
|
|||
|
|
@ -16,9 +16,15 @@ class TakeAttach
|
|||
if ($params instanceof \think\Model) {
|
||||
if(\think\Session::has('user_site_id')) {
|
||||
$params->site_id = \think\Session::get('user_site_id');
|
||||
$params->canDelete = 1;
|
||||
$params->save();
|
||||
return;
|
||||
}
|
||||
if(request()->param('siteid')) {
|
||||
$params->site_id = request()->param('siteid');
|
||||
$params->canDelete = 1;
|
||||
$params->save();
|
||||
}
|
||||
}
|
||||
//del
|
||||
elseif ($params instanceof \think\Controller) {
|
||||
|
|
|
|||
|
|
@ -24,9 +24,14 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
|
|||
[
|
||||
{field: 'state', checkbox: true, },
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'site_id', title: __('Site_id'), visible:Config.show_sitename,
|
||||
formatter: function (value, row, index) {
|
||||
return row.sites==null?'':'<a href="javascript:;" class="searchit" data-field="site_id" data-value="' + row.site_id + '">' + row.sites.name + '</a>';
|
||||
}
|
||||
},
|
||||
{field: 'url', title: __('Preview'), formatter: Controller.api.formatter.thumb},
|
||||
{field: 'url', title: __('Url'), formatter: function(value,row,index){
|
||||
return '<a href="' + value + '" title="'+value+'" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a>';
|
||||
return '<a href="' + Fast.api.cdnurl(value) + '" title="'+Fast.api.cdnurl(value)+'" target="_blank" class="btn btn-default btn-sm"><i class="fa fa-link"></i></a>';
|
||||
}},
|
||||
{field: 'imagewidth', title: __('Imagewidth')},
|
||||
{field: 'imageheight', title: __('Imageheight')},
|
||||
|
|
@ -57,6 +62,17 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
|
|||
// 初始化表格
|
||||
table.bootstrapTable({
|
||||
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
||||
queryParams:function (params) {
|
||||
if(Config.site_id!=null){
|
||||
return {
|
||||
sort: params.sort,
|
||||
order: params.order,
|
||||
filter: JSON.stringify({site_id: Config.site_id}),
|
||||
op: JSON.stringify({site_id: '='}),
|
||||
offset: params.offset,
|
||||
limit: params.limit,
|
||||
};}
|
||||
},
|
||||
sortName: 'id',
|
||||
columns: [
|
||||
[
|
||||
|
|
|
|||
|
|
@ -189,22 +189,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
|||
|
||||
$(document).on("change", "select[name='row[site_id]']", function () {
|
||||
siteid=$(this).val();
|
||||
/*
|
||||
$("#c-channel_id option:selected").prop("selected", false);
|
||||
$("#c-channel_id option").addClass("hide");
|
||||
$("#c-channel_id option[data-siteid='" + $(that).val() + "']").removeClass("hide");
|
||||
|
||||
try{
|
||||
$("#c-channel_id").selectpicker("refresh");
|
||||
}catch(e){}
|
||||
$('#c-channel_id').trigger('change');
|
||||
|
||||
Fast.api.ajax({url: 'posts/sites/get_site_langs', data: {"lang": $(that).val()}}, function (data) {
|
||||
$("#language_choose").html(data.html);
|
||||
Form.api.bindevent($("#language_choose"));
|
||||
return false;
|
||||
});
|
||||
*/
|
||||
$('.plupload').data("siteid", siteid);
|
||||
$('.fachoose').data("siteid", siteid);
|
||||
|
||||
$pid = $('#c-channel_id');
|
||||
|
||||
|
|
@ -212,7 +198,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
|||
if(ret.code=="1"){
|
||||
$pid.empty();
|
||||
$.each(ret.data.list, function(i,k){
|
||||
$pid.append("<option value='" + ret.data.list[i].id + "' "+(ret.data.list[i].disabled==1?'disabled':'')+">"+ ret.data.list[i].name + "</option>");
|
||||
$pid.append("<option data-model='"+ret.data.list[i].model+"' value='" + ret.data.list[i].id + "' "+(ret.data.list[i].disabled==1?'disabled':'')+">"+ ret.data.list[i].name + "</option>");
|
||||
});
|
||||
$pid.selectpicker("refresh");
|
||||
$pid.trigger('change');
|
||||
|
|
@ -222,18 +208,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
|||
return false;
|
||||
});
|
||||
|
||||
/*
|
||||
var ml = $('option:selected', this).data('lang');
|
||||
if(ml==undefined) {
|
||||
$('input[name="row[lang]"]').prop('disabled', false).closest('label').show();
|
||||
return false;
|
||||
}
|
||||
|
||||
$('input[name="row[lang]"]').prop('disabled', true).closest('label').hide();
|
||||
$.each(ml.split(','), function(key,value){
|
||||
$('input[name="row[lang]"][value="'+value+'"]').prop('disabled', false).closest('label').show();
|
||||
});
|
||||
*/
|
||||
});
|
||||
|
||||
$(document).on("change", "select[name='row[channel_id]']", function () {
|
||||
|
|
@ -242,15 +216,20 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
|||
Fast.api.ajax({url: 'posts/archives/get_model_fields', data: {model: model}}, function (data) {
|
||||
$("#extra").html(data.html);
|
||||
Form.api.bindevent($("#extra"));
|
||||
$('#extra .plupload').data("siteid", $("select[name='row[site_id]']").val());
|
||||
$('#extra .fachoose').data("siteid", $("select[name='row[site_id]']").val());
|
||||
return false;
|
||||
});
|
||||
}
|
||||
$('input[name="row[type]"]').val(model);
|
||||
});
|
||||
|
||||
Controller.edit();
|
||||
//if($('#c-site_id').size()>0) $('#c-site_id').trigger('change');
|
||||
//$("select[name='row[site_id]']").trigger('change');
|
||||
$('.plupload').data("siteid", $("select[name='row[site_id]']").val());
|
||||
$('.fachoose').data("siteid", $("select[name='row[site_id]']").val());
|
||||
$("select[name='row[channel_id]']").trigger('change');
|
||||
|
||||
Controller.edit();
|
||||
},
|
||||
edit: function () {
|
||||
$("form").data("validator-options", {ignore: ':hidden'});
|
||||
|
|
@ -285,7 +264,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
|||
appendHtml += '<span><button type="button" id="fachoose-' + objID + '" class="btn btn-primary fachoose" data-input-id="pa-' + objID + '" data-attach-id="pa-' + objID + 'i' + '" data-title-id="pa-' + objID + 't'+ '" data-mimetype="*/*" data-multiple="false"><i class="fa fa-list"></i> ' + __('Choose') + '</button></span> ';
|
||||
appendHtml += '<span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span></dd>';
|
||||
$(appendHtml).insertBefore($(this).parent());
|
||||
Controller.api.bindevent();
|
||||
Form.api.bindevent($(this).closest("dl"));
|
||||
});
|
||||
$(document).on("click", ".fieldlist dd .btn-remove", function () {
|
||||
var rel = parseInt($(this).closest("dl").attr("rel"));
|
||||
|
|
|
|||
|
|
@ -116,6 +116,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
|
||||
$(document).on("change", "select[name='row[site_id]']", function () {
|
||||
siteid=$(this).val();
|
||||
$('.plupload').data("siteid", siteid);
|
||||
$('.fachoose').data("siteid", siteid);
|
||||
//$("#c-pid option:first").prop("selected", true);
|
||||
//$("#c-pid option").addClass("hide");
|
||||
//$("#c-pid option[data-siteid='" + $(that).val() + "']").removeClass("hide");
|
||||
|
|
@ -147,6 +149,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
});
|
||||
|
||||
$("select[name='row[model]']").trigger("change");
|
||||
$("select[name='row[site_id]']").trigger("change");
|
||||
$("input[name='row[type]']:checked").trigger("click");
|
||||
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
|
|
|
|||
|
|
@ -64,13 +64,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
api: {
|
||||
bindevent: function () {
|
||||
$(document).on("change", "#c-site_id", function () {
|
||||
that=this;
|
||||
Fast.api.ajax({url: 'posts/sites/get_site_langs', data: {"lang": $(that).val()}}, function (r,data) {
|
||||
siteid=$(this).val();
|
||||
$('.plupload').data("siteid", siteid);
|
||||
$('.fachoose').data("siteid", siteid);
|
||||
Fast.api.ajax({url: 'posts/sites/get_site_langs', data: {"lang": siteid}}, function (r,data) {
|
||||
$("#language_choose").html(data.html);
|
||||
Form.api.bindevent($("#language_choose"));
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('.plupload').data("siteid", $("#c-site_id").val());
|
||||
$('.fachoose').data("siteid", $("#c-site_id").val());
|
||||
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template'], function
|
|||
var random = $(this).closest('dd').data('index');// Math.floor(Math.random()*(10000-1+1)+1);
|
||||
$tarDiv.html('<input id="c-file-'+random+'" class="form-control upfile" name="'+nodeName+'" type="text" value=""><span><button type="button" id="plupload-f'+random+'" class="btn btn-danger plupload" data-input-id="c-file-'+random+'" data-mimetype="*/*" data-multiple="false"><i class="fa fa-upload"></i>' + __("Upload") + '</button></span><span><button type="button" id="fachoose-f'+random+'" class="btn btn-primary fachoose" data-input-id="c-file-'+random+'" data-mimetype="*/*" data-multiple="false"><i class="fa fa-list"></i>' + __("Choose") + '</button></span><ul class="row list-inline plupload-preview" id="p-image"></ul>');
|
||||
Form.api.bindevent($tarDiv);
|
||||
$('.plupload').data("siteid", Config.site_id);
|
||||
$('.fachoose').data("siteid", Config.site_id);
|
||||
break;
|
||||
case "textarea":
|
||||
$tarDiv.html('<textarea name="'+nodeName+'" class="form-control" cols="50"></textarea>')
|
||||
|
|
|
|||
Loading…
Reference in New Issue