From 2808709fd3e6c2220abba00a7d8bb2715bafe804 Mon Sep 17 00:00:00 2001 From: devlike Date: Fri, 9 Feb 2018 23:47:54 +0800 Subject: [PATCH] =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=94=AF=E6=8C=81=E5=A4=9A?= =?UTF-8?q?=E7=AB=99=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/controller/general/Attachment.php | 4 ++ application/admin/controller/posts/Sites.php | 1 + application/admin/model/SitesConfig.php | 9 ++++ application/common/model/Attachment.php | 5 +++ extend/seven/behavior/TakeAttach.php | 6 +++ .../assets/js/backend/general/attachment.js | 18 +++++++- public/assets/js/backend/posts/archives.js | 43 +++++-------------- public/assets/js/backend/posts/channel.js | 3 ++ public/assets/js/backend/posts/page.js | 10 ++++- public/assets/js/backend/posts/sites.js | 2 + 10 files changed, 66 insertions(+), 35 deletions(-) create mode 100644 application/admin/model/SitesConfig.php diff --git a/application/admin/controller/general/Attachment.php b/application/admin/controller/general/Attachment.php index a9b79bbc..61dc1f4e 100644 --- a/application/admin/controller/general/Attachment.php +++ b/application/admin/controller/general/Attachment.php @@ -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(); } diff --git a/application/admin/controller/posts/Sites.php b/application/admin/controller/posts/Sites.php index 77f9881a..cb83383b 100644 --- a/application/admin/controller/posts/Sites.php +++ b/application/admin/controller/posts/Sites.php @@ -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(); } diff --git a/application/admin/model/SitesConfig.php b/application/admin/model/SitesConfig.php new file mode 100644 index 00000000..842fc282 --- /dev/null +++ b/application/admin/model/SitesConfig.php @@ -0,0 +1,9 @@ +belongsTo('Sites', 'site_id','id')->field('id,name'); + } + public function setUploadtimeAttr($value) { return strtotime($value); diff --git a/extend/seven/behavior/TakeAttach.php b/extend/seven/behavior/TakeAttach.php index c6b88826..120cd389 100644 --- a/extend/seven/behavior/TakeAttach.php +++ b/extend/seven/behavior/TakeAttach.php @@ -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) { diff --git a/public/assets/js/backend/general/attachment.js b/public/assets/js/backend/general/attachment.js index 780aa240..d5c048bf 100644 --- a/public/assets/js/backend/general/attachment.js +++ b/public/assets/js/backend/general/attachment.js @@ -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?'':'' + row.sites.name + ''; + } + }, {field: 'url', title: __('Preview'), formatter: Controller.api.formatter.thumb}, {field: 'url', title: __('Url'), formatter: function(value,row,index){ - return ''; + return ''; }}, {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: [ [ diff --git a/public/assets/js/backend/posts/archives.js b/public/assets/js/backend/posts/archives.js index 04663c0d..849923ff 100644 --- a/public/assets/js/backend/posts/archives.js +++ b/public/assets/js/backend/posts/archives.js @@ -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(""); + $pid.append(""); }); $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 += ' '; appendHtml += ''; $(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")); diff --git a/public/assets/js/backend/posts/channel.js b/public/assets/js/backend/posts/channel.js index 58b26d0e..7a05516a 100644 --- a/public/assets/js/backend/posts/channel.js +++ b/public/assets/js/backend/posts/channel.js @@ -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]")); diff --git a/public/assets/js/backend/posts/page.js b/public/assets/js/backend/posts/page.js index 4d0dba12..8853cdb7 100644 --- a/public/assets/js/backend/posts/page.js +++ b/public/assets/js/backend/posts/page.js @@ -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]")); } diff --git a/public/assets/js/backend/posts/sites.js b/public/assets/js/backend/posts/sites.js index 9ddb1277..fd3bf7b5 100644 --- a/public/assets/js/backend/posts/sites.js +++ b/public/assets/js/backend/posts/sites.js @@ -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(''); Form.api.bindevent($tarDiv); + $('.plupload').data("siteid", Config.site_id); + $('.fachoose').data("siteid", Config.site_id); break; case "textarea": $tarDiv.html('')