mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 11:13:26 +00:00
perf: 审批消息预览图片
This commit is contained in:
parent
87e46ec5a5
commit
501872e8d2
@ -985,6 +985,20 @@ class ApproveController extends AbstractController
|
|||||||
'comment_content' => $process['comment_contents']['content'] ?? '',
|
'comment_content' => $process['comment_contents']['content'] ?? '',
|
||||||
'comment_pictures' => $process['comment_contents']['pictures'] ?? []
|
'comment_pictures' => $process['comment_contents']['pictures'] ?? []
|
||||||
];
|
];
|
||||||
|
$thumb = null;
|
||||||
|
if ($type === 'approve_reviewer') {
|
||||||
|
$thumb = $process['var']['other'];
|
||||||
|
} elseif ($type === 'approve_comment_notifier') {
|
||||||
|
$thumb = $data['comment_pictures'] ? $data['comment_pictures'][0] : null;
|
||||||
|
}
|
||||||
|
if ($thumb && file_exists(public_path($thumb))) {
|
||||||
|
$imageSize = getimagesize(public_path($thumb));
|
||||||
|
$data['thumb'] = [
|
||||||
|
'url' => $thumb,
|
||||||
|
'width' => $imageSize[0],
|
||||||
|
'height' => $imageSize[1]
|
||||||
|
];
|
||||||
|
}
|
||||||
$msgAction = null;
|
$msgAction = null;
|
||||||
$msgData = [
|
$msgData = [
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
|
|||||||
@ -149,19 +149,29 @@ class WebSocketDialogMsg extends AbstractModel
|
|||||||
if (!is_array($msg)) {
|
if (!is_array($msg)) {
|
||||||
$msg = Base::json2array($msg);
|
$msg = Base::json2array($msg);
|
||||||
}
|
}
|
||||||
if ($type === 'file') {
|
switch ($type) {
|
||||||
$msg['type'] = in_array($msg['ext'], ['jpg', 'jpeg', 'webp', 'png', 'gif']) ? 'img' : 'file';
|
case 'file':
|
||||||
$msg['path'] = Base::fillUrl($msg['path']);
|
$msg['type'] = in_array($msg['ext'], ['jpg', 'jpeg', 'webp', 'png', 'gif']) ? 'img' : 'file';
|
||||||
$msg['thumb'] = Base::fillUrl($msg['thumb'] ?: Base::extIcon($msg['ext']));
|
$msg['path'] = Base::fillUrl($msg['path']);
|
||||||
} else if ($type === 'record') {
|
$msg['thumb'] = Base::fillUrl($msg['thumb'] ?: Base::extIcon($msg['ext']));
|
||||||
$msg['path'] = Base::fillUrl($msg['path']);
|
break;
|
||||||
$textUserid = is_array($msg['text_userid']) ? $msg['text_userid'] : [];
|
|
||||||
if (isset($msg['text_userid'])) {
|
case 'record':
|
||||||
unset($msg['text_userid']);
|
$msg['path'] = Base::fillUrl($msg['path']);
|
||||||
}
|
$textUserid = is_array($msg['text_userid']) ? $msg['text_userid'] : [];
|
||||||
if ($msg['text'] && !in_array(Doo::userId(), $textUserid)) {
|
if (isset($msg['text_userid'])) {
|
||||||
$msg['text'] = "";
|
unset($msg['text_userid']);
|
||||||
}
|
}
|
||||||
|
if ($msg['text'] && !in_array(Doo::userId(), $textUserid)) {
|
||||||
|
$msg['text'] = "";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'template':
|
||||||
|
if ($msg['data']['thumb']) {
|
||||||
|
$msg['data']['thumb']['url'] = Base::fillUrl($msg['data']['thumb']['url']);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<p>{{$L('申请人')}}:<span class="mark-color">@{{ msg.data.nickname }}</span> {{ msg.data.department }}</p>
|
<p>{{$L('申请人')}}:<span class="mark-color">@{{ msg.data.nickname }}</span> {{ msg.data.department }}</p>
|
||||||
<b>{{$L('评论内容')}}</b>
|
<b>{{$L('评论内容')}}</b>
|
||||||
<p>{{ msg.data.comment_content }}</p>
|
<p>{{ msg.data.comment_content }}</p>
|
||||||
<p v-if="isPicture">[{{$L('图片')}}]</p>
|
<p v-if="msg.data.thumb" v-html="imageHtml(msg.data.thumb)"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-raw no-dark-content">
|
<div class="btn-raw no-dark-content">
|
||||||
<button class="ivu-btn ivu-btn-grey">{{$L('查看详情')}}</button>
|
<button class="ivu-btn ivu-btn-grey">{{$L('查看详情')}}</button>
|
||||||
@ -21,13 +21,18 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
computed: {
|
methods: {
|
||||||
isPicture() {
|
imageHtml(info) {
|
||||||
const {comment_pictures} = this.msg.data
|
const data = $A.imageRatioHandle({
|
||||||
return $A.isArray(comment_pictures) && comment_pictures.length > 0
|
src: info.url,
|
||||||
},
|
width: info.width,
|
||||||
|
height: info.height,
|
||||||
|
crops: {ratio: 3, percentage: '320x0'},
|
||||||
|
scaleSize: 220,
|
||||||
|
})
|
||||||
|
return `<img src="${data.src}" width="${data.width}" height="${data.height}" />`
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
<p>{{$L("开始时间")}}:{{ msg.data.start_time }} ({{ msg.data.start_day_of_week }})</p>
|
<p>{{$L("开始时间")}}:{{ msg.data.start_time }} ({{ msg.data.start_day_of_week }})</p>
|
||||||
<p>{{$L("结束时间")}}:{{ msg.data.end_time }} ({{ msg.data.end_day_of_week }})</p>
|
<p>{{$L("结束时间")}}:{{ msg.data.end_time }} ({{ msg.data.end_day_of_week }})</p>
|
||||||
<p>{{$L("事由")}}:{{ msg.data.description }}</p>
|
<p>{{$L("事由")}}:{{ msg.data.description }}</p>
|
||||||
|
<p v-if="msg.data.thumb" v-html="imageHtml(msg.data.thumb)"></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-raw no-dark-content">
|
<div class="btn-raw no-dark-content">
|
||||||
<button v-if="msg.action === 'pass'" class="ivu-btn ivu-btn-grey">{{$L("已同意")}}</button>
|
<button v-if="msg.action === 'pass'" class="ivu-btn ivu-btn-grey">{{$L("已同意")}}</button>
|
||||||
@ -29,7 +30,17 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {};
|
return {};
|
||||||
},
|
},
|
||||||
computed: {},
|
methods: {
|
||||||
methods: {},
|
imageHtml(info) {
|
||||||
|
const data = $A.imageRatioHandle({
|
||||||
|
src: info.url,
|
||||||
|
width: info.width,
|
||||||
|
height: info.height,
|
||||||
|
crops: {ratio: 3, percentage: '320x0'},
|
||||||
|
scaleSize: 220,
|
||||||
|
})
|
||||||
|
return `<img src="${data.src}" width="${data.width}" height="${data.height}" />`
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user