123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- @extends('admin/layout')
- @section('header')
- <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
- @endsection
- @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" style="display: none">
- <label class="col-sm-2 control-label" for="site_id"><span class="red">* </span>站点:</label>
- <div class="col-sm-8 ">
- <select data-placeholder="选择站点..." class="chosen-select" style="width:350px; "
- id="site_id" name="site_id">
- <option value="1">请选择站点</option>
- </select>
- </div>
- </div>
- <div class="form-group" style="display: none">
- <label class="col-sm-2 control-label" for="thumb">缩略图:</label>
- <div class="col-sm-8">
- <button type="button" class="btn btn-primary" name="file_upload">缩略图上传</button>
- <input type="file" value="" style="display: none" name="uploadFile">
- <input type="hidden" id="thumb" name="thumb" value="{{$data->thumb??''}}">
- </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">
- <img style="height: 150px" src="{{$data->thumb??''}}">
- </div>
- </div>
- <div class="form-group" style="display: none">
- <label class="col-sm-2 control-label" for="translator_id">指派:</label>
- <div class="col-sm-8 ">
- <select data-placeholder="选择站点..." class="chosen-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" style="display: none">
- <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="测试标题">
- </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" style="display: none">
- @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="0">
- </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="1">
- </div>
- <label class="col-sm-1 control-label">锚点链接:</label>
- <div class="col-sm-2">
- <input type="text" class="form-control" name="anchor" title=""
- value="2">
- </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" style="display: none">
- <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" style="display: none">
- <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">
- @if(($data->status??null)==1||!$data) {{--如果为添加和待翻译--}}
- @notCustomer
- <button class="btn btn-primary" type="button"
- onclick="units.save({{$data->id??0}})">
- 保存
- </button>
- @endNotCustomer
- @endif
- <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>
- 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 config = {".chosen-select": {}};
- for (var selector in config) $(selector).chosen(config[selector]);
- var units = {
- 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;
- var ajaxConfig = {
- url: url,
- type: 'put',
- data: data,
- success: function (result) {
- layer.msg(result.message, {icon: 6, time: 1000}, function () {
- tips.closeParentLayer();
- window.parent.tips.tableRefresh('#table');
- });
- }
- };
- tips.ajax(ajaxConfig);
- },
- addGroup: function () {
- var html = '<div class="form-group">' +
- '<label class="col-sm-2 control-label" >中文关键词:</label>\n' +
- '<div class="col-sm-2">' +
- '<input type="text" class="form-control" name="cn_keyword"\n' +
- 'value="">\n' +
- '</div>\n' +
- '<label class="col-sm-1 control-label">英文关键词:</label>\n' +
- '<div class="col-sm-2">\n' +
- '<input type="text" class="form-control" name="en_keyword" value="">\n' +
- '</div>\n' +
- '<label class="col-sm-1 control-label" >锚点链接:</label>\n' +
- '<div class="col-sm-2">\n' +
- '<input type="text" class="form-control" name="anchor" value="">\n' +
- '</div>\n' +
- '<div class="col-sm-1">\n' +
- '<button class="btn btn-warning" type="button" onclick="units.delGroup(this)">删除</button>\n' +
- '</div>\n' +
- '</div>';
- $("#group").append(html);
- },
- delGroup: function (_this) {
- $(_this).parent().parent().remove();
- }
- };
- $(document).on('click', '[name=file_upload]', function () {
- $(this).next().trigger('click');
- });
- $(document).on('change', '[name=uploadFile]', function () {
- var _this = this;
- if (!$(this)[0].files[0]) {
- return;
- }
- var formData = new FormData();
- formData.append('file', $(this)[0].files[0]);
- var ln;
- $.ajax({
- url: '/admin/tool/upload?notAsset=1',
- type: 'POST',
- cache: false,
- data: formData,
- processData: false,
- contentType: false,
- beforeSend: function () {
- ln = layer.load();
- },
- complete: function () {
- layer.close(ln);
- },
- success: function (result) {
- var data = result.data;
- var thumbDiv = $("#thumb_div");
- thumbDiv.css('display', '');
- thumbDiv.find("img").attr('src', data.file_url);
- $('#' + $(_this).data('for')).attr('src', data.file_url);
- $(_this).next().val(data.file_url);
- },
- error: function (XMLHttpRequest) {
- if (XMLHttpRequest.status === 500) {
- layer.alert("异步请求失败", {icon: 5});
- return;
- }
- layer.alert(JSON.parse(XMLHttpRequest.responseText).message, {icon: 0});
- }
- });
- });
- </script>
- @endsection
|