Accept Merge Request #60: (feature/zy -> develop)
Merge Request: feature: 面板 Created By: @zhuyu Accepted By: @zhuyu URL: https://g-bcrc3009.coding.net/p/allocatr/d/allocatr/git/merge/60?initial=true
This commit is contained in:
commit
35ac2312c8
|
|
@ -55,7 +55,6 @@ class Doc extends Backend
|
|||
$groupdata = $result;
|
||||
}
|
||||
|
||||
$this->view->assign("typeList", $this->model->getTypeList());
|
||||
$this->view->assign('groupdata', $groupdata);
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +90,7 @@ class Doc extends Backend
|
|||
|
||||
foreach ($list as $k => $row) {
|
||||
$list[$k]['url'] = cdnurl($row['path']);
|
||||
$list[$k]['filetype'] = pathinfo($list[$k]['url'], PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
$result = ['total' => $list->total(), 'rows' => $list->items()];
|
||||
|
|
|
|||
|
|
@ -106,6 +106,8 @@ class Task extends Backend
|
|||
}
|
||||
|
||||
$list[$k]['refuse_reason'] = $row['refuse_reason'] ?? '';
|
||||
$list[$k]['url'] = cdnurl($row['prove_file_path']);
|
||||
$list[$k]['filetype'] = pathinfo($list[$k]['url'], PATHINFO_EXTENSION);
|
||||
}
|
||||
|
||||
$result = array("total" => $list->total(), "rows" => $list->items());
|
||||
|
|
|
|||
|
|
@ -23,24 +23,22 @@ class Doc extends Model
|
|||
protected $updateTime = false;
|
||||
protected $deleteTime = false;
|
||||
|
||||
// 追加属性
|
||||
protected $append = [
|
||||
'type_text'
|
||||
];
|
||||
|
||||
|
||||
|
||||
public function getTypeList()
|
||||
|
||||
|
||||
public function getUrlAttr($value, $data)
|
||||
{
|
||||
return ['1' => __('Type 1'), '2' => __('Type 2'), '3' => __('Type 3')];
|
||||
$value = cdnurl($data['path']);
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
|
||||
public function getTypeTextAttr($value, $data)
|
||||
public function getFileTypeAttr($value, $data)
|
||||
{
|
||||
$value = $value ?: ($data['type'] ?? '');
|
||||
$list = $this->getTypeList();
|
||||
return $list[$value] ?? '';
|
||||
$value = cdnurl($data['path']);
|
||||
$ext = pathinfo($value, PATHINFO_EXTENSION);
|
||||
|
||||
return $ext;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -64,4 +64,18 @@ class Task extends Model
|
|||
{
|
||||
return $this->belongsTo('app\admin\model\Admin', 'exec_admin_id', 'id', [], 'LEFT')->setEagerlyType(1);
|
||||
}
|
||||
|
||||
public function getUrlAttr($value, $data)
|
||||
{
|
||||
$value = cdnurl($data['prove_file_path']);
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function getFileTypeAttr($value, $data)
|
||||
{
|
||||
$value = cdnurl($data['prove_file_path']);
|
||||
$ext = pathinfo($value, PATHINFO_EXTENSION);
|
||||
|
||||
return $ext;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,19 +6,6 @@
|
|||
{:build_select('group[]', $groupdata, null, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
|
||||
{foreach name="typeList" item="vo"}
|
||||
<option value="{$key}" {in name="key" value="0"}selected{/in}>{$vo}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
|
|
|||
|
|
@ -7,18 +7,6 @@
|
|||
{:build_select('group[]', $groupdata, $groupids, ['class'=>'form-control selectpicker', 'multiple'=>'', 'data-rule'=>'required'])}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
||||
<select id="c-type" data-rule="required" class="form-control selectpicker" name="row[type]">
|
||||
{foreach name="typeList" item="vo"}
|
||||
<option value="{$key}" {in name="key" value="$row.type"}selected{/in}>{$vo}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Title')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
|
@ -38,7 +26,7 @@
|
|||
<input id="c-path" data-rule="required" class="form-control" size="50" name="row[path]" type="text" value="{$row.path|htmlentities}">
|
||||
<div class="input-group-addon no-border no-padding">
|
||||
<span><button type="button" id="plupload-path" class="btn btn-danger plupload" data-input-id="c-path" data-mimetype="*" data-multiple="true" data-preview-id="p-path"><i class="fa fa-upload"></i> {:__('Upload')}</button></span>
|
||||
<span><button type="button" id="fachoose-path" class="btn btn-primary fachoose" data-input-id="c-path" data-mimetype="*" data-multiple="true"><i class="fa fa-list"></i> {:__('Choose')}</button></span>
|
||||
<span><a href="{$row.url}" class="btn btn-primary btn-info btn-preview" data-type="{$row.filetype}">预览</a></span>
|
||||
</div>
|
||||
<span class="msg-box n-right" for="c-path"></span>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,24 @@
|
|||
<input id="c-desc" class="form-control" name="row[desc]" type="text" value="{$row.desc|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Exec_admin_id')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-exec_admin_id" data-rule="required" data-source="auth/admin/selectpage" data-field="nickname" class="form-control selectpage" name="row[exec_admin_id]" type="text" value="{$row.exec_admin_id|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Expire_start_time')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-expire_start_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expire_start_time]" type="text" value="{$row.expire_start_time|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="control-label col-xs-12 col-sm-2">{:__('Expire_end_time')}:</label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
<input id="c-expire_end_time" data-rule="required" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[expire_end_time]" type="text" value="{$row.expire_end_time|htmlentities}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group layer-footer">
|
||||
<label class="control-label col-xs-12 col-sm-2"></label>
|
||||
<div class="col-xs-12 col-sm-8">
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
[
|
||||
{checkbox: true},
|
||||
{field: 'id', title: __('Id')},
|
||||
{field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal},
|
||||
{field: 'title', title: __('Title'), operate: 'LIKE'},
|
||||
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
|
|
@ -36,9 +35,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
{
|
||||
name: 'detail',
|
||||
title: __('查看详情'),
|
||||
classname: 'btn btn-xs btn-primary btn-dialog',
|
||||
classname: 'btn btn-xs btn-primary btn-preview',
|
||||
icon: 'fa fa-list',
|
||||
url: 'oa/doc/detail'
|
||||
extend: function(row) {
|
||||
return 'data-type="' + row.filetype + '" data-url="' + row.url + '"';
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -46,6 +47,38 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
]
|
||||
});
|
||||
|
||||
$(document).on('click', '.btn-preview', function (e) {
|
||||
e.preventDefault();
|
||||
var fileType = $(this).data('type'); // 自动从 data-type 获取,比如 pdf, jpg, doc
|
||||
var url = $(this).attr('href');
|
||||
|
||||
if (fileType === 'pdf') {
|
||||
Layer.open({
|
||||
type: 2,
|
||||
title: '预览PDF文件',
|
||||
area: ['80%', '80%'],
|
||||
content: url
|
||||
});
|
||||
} else if (['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(fileType)) {
|
||||
Layer.photos({
|
||||
photos: {
|
||||
"title": "图片预览",
|
||||
"data": [{"src": url}]
|
||||
},
|
||||
anim: 5
|
||||
});
|
||||
} else if (['mp4', 'webm', 'ogg'].includes(fileType)) {
|
||||
Layer.open({
|
||||
type: 1,
|
||||
title: '视频预览',
|
||||
area: ['800px', '500px'],
|
||||
content: `<video src="${url}" width="100%" height="100%" controls autoplay></video>`
|
||||
});
|
||||
} else {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
|
|
|
|||
|
|
@ -33,6 +33,19 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
{field: 'title', title: __('Title'), operate: 'LIKE'},
|
||||
{field: 'desc', title: __('Desc'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6')}, formatter: Table.api.formatter.status},
|
||||
{field: 'operate', title: __('查看附件'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
|
||||
buttons:[
|
||||
{
|
||||
name: 'detail',
|
||||
title: __('查看详情'),
|
||||
classname: 'btn btn-xs btn-primary btn-preview',
|
||||
icon: 'fa fa-list',
|
||||
extend: function(row) {
|
||||
return 'data-type="' + row.filetype + '" data-url="' + row.url + '"';
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{field: 'refuse_reason', title: __('Refuse_reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
||||
{field: 'expire_start_time', title: __('Expire_start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
{field: 'expire_end_time', title: __('Expire_end_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
|
||||
|
|
@ -138,6 +151,39 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
|
|||
]
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.btn-preview', function (e) {
|
||||
e.preventDefault();
|
||||
var fileType = $(this).data('type'); // 自动从 data-type 获取,比如 pdf, jpg, doc
|
||||
var url = $(this).attr('href');
|
||||
|
||||
if (fileType === 'pdf') {
|
||||
Layer.open({
|
||||
type: 2,
|
||||
title: '预览PDF文件',
|
||||
area: ['80%', '80%'],
|
||||
content: url
|
||||
});
|
||||
} else if (['jpg', 'jpeg', 'png', 'gif', 'webp'].includes(fileType)) {
|
||||
Layer.photos({
|
||||
photos: {
|
||||
"title": "图片预览",
|
||||
"data": [{"src": url}]
|
||||
},
|
||||
anim: 5
|
||||
});
|
||||
} else if (['mp4', 'webm', 'ogg'].includes(fileType)) {
|
||||
Layer.open({
|
||||
type: 1,
|
||||
title: '视频预览',
|
||||
area: ['800px', '500px'],
|
||||
content: `<video src="${url}" width="100%" height="100%" controls autoplay></video>`
|
||||
});
|
||||
} else {
|
||||
window.open(url, '_blank');
|
||||
}
|
||||
});
|
||||
|
||||
// 为表格绑定事件
|
||||
Table.api.bindevent(table);
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user