123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- @extends('admin/layout')
- @section('header')
- <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
- <link href="{{asset('js/plugins/bootstrap-select-1.13.9/dist/css/bootstrap-select.min.css')}}" rel="stylesheet">
- <link href="{{asset('css/plugins/switchery/switchery.css')}}" rel="stylesheet">
- @endsection
- <style>
- .dropdown-menu {
- left: 0 !important;
- right: auto !important;
- }
- </style>
- @section('content')
- <body class="gray-bg">
- <div class="wrapper wrapper-content animated fadeInRight">
- <div class="row">
- <div class="col-sm-12">
- <div class="ibox float-e-margins">
- <div class="ibox-content">
- <form method="get" class="form-horizontal" id="form">
- <div class="form-group">
- <label class="col-sm-2 control-label" for="site_id"><span
- class="red">* </span>请选择站点:</label>
- <div class="col-sm-8 ">
- <select data-placeholder="选择站点..." class="my-select" style="width:350px; "
- id="site_id" name="site_id">
- <option value="">请选择站点</option>
- @foreach ($sites as $site)
- <option value="{{$site->id}}"
- @if(($data->site_id??null)==$site->id) selected @endif
- @if(($siteKeep->site_id??null)==$site->id) selected @endif>
- {{$site->cn_title}}
- </option>
- @endforeach
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label" for="translator_id">指派:</label>
- <div class="col-sm-8 ">
- <select data-placeholder="选择站点..." class="my-select" style="width:350px; "
- id="translator_id" name="translator_id">
- <option value="">请选择翻译人员</option>
- @foreach ($translators as $item)
- <option value="{{$item->id}}"
- @if(($data->translator_id??null)==$item->id) selected @endif>{{$item->username}}</option>
- @endforeach
- </select>
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label" for="thumb">缩略图:</label>
- <div class="col-sm-8">
- <button type="button" class="btn btn-primary" id="imageUpload">缩略图上传</button>
- </div>
- </div>
- <div class="form-group" @if (empty($data->thumb))style="display: none"
- @endif id="thumb_div">
- <div class="col-sm-8 col-sm-offset-2" style="position: relative">
- <span style="position: absolute;left: 180px;cursor: pointer" id="delThumb">删除</span>
- <img style="height: 150px" src="{{$data->thumb??''}}">
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label" for="title"><span class="red">* </span>标题:</label>
- <div class="col-sm-8">
- <input type="text" class="form-control" id="title" name="title"
- value="{{$data->title??''}}">
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label" for="content"><span
- class="red">* </span>正文:</label>
- <div class="col-sm-8">
- <!-- 编辑器容器 -->
- <script id="content" name="content"
- type="text/plain">{!! $data->content??'' !!}</script>
- </div>
- </div>
- <div id="group">
- @foreach($data->group??[[]] as $key=>$item)
- <div class="form-group">
- <label class="col-sm-2 control-label"><span class="red">* </span>中文关键词:</label>
- <div class="col-sm-2">
- <input type="text" class="form-control" name="cn_keyword" title=""
- value="{{$item['cn_keyword']??''}}">
- </div>
- <label class="col-sm-1 control-label">英文关键词:</label>
- <div class="col-sm-2">
- <input type="text" class="form-control" name="en_keyword" title=""
- value="{{$item['en_keyword']??''}}">
- </div>
- <label class="col-sm-1 control-label">锚点链接:</label>
- <div class="col-sm-2">
- <input type="text" class="form-control" name="anchor" title=""
- value="{{$item['anchor']??''}}">
- </div>
- @if($key==0)
- <div class="col-sm-1">
- <button class="btn btn-primary" type="button"
- onclick="units.addGroup()">添加
- </button>
- </div>
- @else
- <div class="col-sm-1">
- <button class="btn btn-warning" type="button"
- onclick="units.delGroup(this)">删除
- </button>
- </div>
- @endif
- </div>
- @endforeach
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label" for="translate_title">英文标题:</label>
- <div class="col-sm-8">
- <input type="text" class="form-control" id="translate_title" name="translate_title"
- value="{{$data->translate_title??''}}">
- </div>
- </div>
- <div class="form-group">
- <label class="col-sm-2 control-label" for="translate_content">英文正文:</label>
- <div class="col-sm-8">
- <script id="translate_content" name="translate_content"
- type="text/plain">{!! $data->translate_content??'' !!}</script>
- </div>
- </div>
- <div class="hr-line-dashed"></div>
- <div class="form-group">
- <div class="col-sm-4 col-sm-offset-2">
- <button class="btn btn-primary" type="button"
- onclick="units.save({{$data->id??0}})">
- 保存
- </button>
- <button class="btn btn-white closeLayer" type="button">取消</button>
- </div>
- </div>
- </form>
- </div>
- </div>
- </div>
- </div>
- </div>
- </body>
- @endsection
- @section('footer')
- @include('vendor.ueditor.assets')
- <script src="{{asset('js/plugins/chosen/chosen.jquery.js')}}"></script>
- <script src="{{asset('js/plugins/switchery/switchery.js')}}"></script>
- <script src="{{asset('js/plugins/bootstrap-select-1.13.9/dist/js/bootstrap-select.min.js')}}"></script>
- <script src="{{asset('js/jquery-ui-1.10.4.min.js')}}"></script>
- <script>
- $(function () {
- $('.my-select').selectpicker({
- liveSearch: true
- });
- });
- var ue = UE.getEditor('content');
- ue.ready(function () {
- ue.setHeight(300);
- {{--ue.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.--}}
- });
- var ueTranslate = UE.getEditor('translate_content');
- ueTranslate.ready(function () {
- ueTranslate.setHeight(300);
- });
- var units = {
- test: function () {
- $("#title").val("");
- ue.setContent("");
- $("[name=cn_keyword]").val("");
- $("[name=en_keyword]").val("");
- $("[name=anchor]").val("");
- $("#translate_title").val("");
- ueTranslate.setContent("");
- },
- save: function (id) {
- var url = '/admin/articles/' + id;
- var data = tips.getFormValues('#form');
- var group = [], cn_keyword, en_keyword, anchor;
- $("#group").find(".form-group").each(function () {
- cn_keyword = $(this).find("[name=cn_keyword]").val();
- en_keyword = $(this).find("[name=en_keyword]").val();
- anchor = $(this).find("[name=anchor]").val();
- if (cn_keyword.length !== 0 && en_keyword !== 0 && anchor !== 0) {
- group.push({
- cn_keyword: cn_keyword,
- en_keyword: en_keyword,
- anchor: anchor
- });
- }
- });
- data.group = group;
- data.thumb = $("#thumb_div").find("img").attr('src');
- var ajaxConfig = {
- url: url,
- type: 'put',
- data: data,
- success: function (result) {
- layer.msg(result.message, {icon: 6, time: 1500}, function () {
- $("#title").val("");
- ue.setContent("");
- $("[name=cn_keyword]").val("");
- $("[name=en_keyword]").val("");
- $("[name=anchor]").val("");
- $("#translate_title").val("");
- ueTranslate.setContent("");
- @php $authUser=auth()->user() @endphp
- @if($authUser->role_id==5)
- tips.closeParentLayer();
- @endif
- });
- }
- };
- tips.ajax(ajaxConfig);
- },
- addGroup: function () {
- var html = '<div class="form-group">' +
- '<label class="col-sm-2 control-label" >中文关键词:</label>' +
- '<div class="col-sm-2">' +
- '<input type="text" class="form-control" name="cn_keyword" value="">' +
- '</div>' +
- '<label class="col-sm-1 control-label">英文关键词:</label>' +
- '<div class="col-sm-2">' +
- '<input type="text" class="form-control" name="en_keyword" value="">' +
- '</div>' +
- '<label class="col-sm-1 control-label" >锚点链接:</label>' +
- '<div class="col-sm-2">' +
- '<input type="text" class="form-control" name="anchor" value="">' +
- '</div>' +
- '<div class="col-sm-1">' +
- '<button class="btn btn-warning" type="button" onclick="units.delGroup(this)">删除</button>' +
- '</div>' +
- '</div>';
- $("#group").append(html);
- },
- delGroup: function (_this) {
- $(_this).parent().parent().remove();
- }
- };
- $(document).on('click', '#imageUpload', function () {
- layer.open({
- title: "缩略图上传",
- type: 2,
- content: '/admin/image/index?siteId=' + $("#site_id").val(),
- area: ['900px', '530px'],
- btn: ['确定', '取消'],
- yes: function (index, layero) {
- var body = layer.getChildFrame('body', index);
- var imgSrc = body.find(".imageActive").find("img").attr('src');
- console.log(imgSrc);
- if (imgSrc) {
- $("#thumb_div").show().find("img").attr('src', imgSrc);
- }
- layer.close(index)
- }
- });
- });
- $(document).on('click', '#delThumb', function () {
- $("#thumb_div").hide().find("img").attr('src', '');
- });
- </script>
- @endsection
|