mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 11:13:26 +00:00
feat: 工作报告支持批量标记已读
This commit is contained in:
parent
6c81f828bd
commit
c7b76e1009
@ -392,6 +392,48 @@ class ReportController extends AbstractController
|
|||||||
return Base::retSuccess("success", $one);
|
return Base::retSuccess("success", $one);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @api {get} api/report/mark 05. 标记已读/未读
|
||||||
|
*
|
||||||
|
* @apiVersion 1.0.0
|
||||||
|
* @apiGroup report
|
||||||
|
* @apiName mark
|
||||||
|
*
|
||||||
|
* @apiParam {Number} id 报告id(组)
|
||||||
|
* @apiParam {Number} action 操作
|
||||||
|
* - read: 标记已读(默认)
|
||||||
|
* - unread: 标记未读
|
||||||
|
*
|
||||||
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
|
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||||
|
* @apiSuccess {Object} data 返回数据
|
||||||
|
*/
|
||||||
|
public function mark(): array
|
||||||
|
{
|
||||||
|
$user = User::auth();
|
||||||
|
//
|
||||||
|
$id = Request::input('id');
|
||||||
|
$action = Request::input('action');
|
||||||
|
//
|
||||||
|
if (is_array($id)) {
|
||||||
|
if (count(Base::arrayRetainInt($id)) > 100) {
|
||||||
|
return Base::retError("最多只能操作100条数据");
|
||||||
|
}
|
||||||
|
$builder = Report::whereIn("id", Base::arrayRetainInt($id));
|
||||||
|
} else {
|
||||||
|
$builder = Report::whereId(intval($id));
|
||||||
|
}
|
||||||
|
$builder ->chunkById(100, function ($list) use ($action, $user) {
|
||||||
|
/** @var Report $item */
|
||||||
|
foreach ($list as $item) {
|
||||||
|
$item->receivesUser()->updateExistingPivot($user->userid, [
|
||||||
|
"read" => $action === 'unread' ? 0 : 1,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return Base::retSuccess("操作成功");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @api {get} api/report/last_submitter 06. 获取最后一次提交的接收人
|
* @api {get} api/report/last_submitter 06. 获取最后一次提交的接收人
|
||||||
*
|
*
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<ReportMy ref="report" v-if="reportTabs === 'my'" @on-view="onView" @on-edit="onEditReport"/>
|
<ReportMy ref="report" v-if="reportTabs === 'my'" @on-view="onView" @on-edit="onEditReport"/>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
<TabPane :label="tabRebder(reportUnreadNumber)" name="receive">
|
<TabPane :label="tabRebder(reportUnreadNumber)" name="receive">
|
||||||
<ReportReceive v-if="reportTabs === 'receive'" @on-view="onView"/>
|
<ReportReceive v-if="reportTabs === 'receive'" @on-view="onView" @on-read="onRead"/>
|
||||||
</TabPane>
|
</TabPane>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
<DrawerOverlay
|
<DrawerOverlay
|
||||||
@ -114,6 +114,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onRead() {
|
||||||
|
this.$emit("on-read", 0)
|
||||||
|
},
|
||||||
|
|
||||||
onEditReport(id) {
|
onEditReport(id) {
|
||||||
if (this.$Electron) {
|
if (this.$Electron) {
|
||||||
let config = {
|
let config = {
|
||||||
|
|||||||
@ -56,7 +56,18 @@
|
|||||||
:data="lists"
|
:data="lists"
|
||||||
:loading="loadIng > 0"
|
:loading="loadIng > 0"
|
||||||
:no-data-text="$L(noDataText)"
|
:no-data-text="$L(noDataText)"
|
||||||
|
@on-selection-change="selectChange"
|
||||||
stripe/>
|
stripe/>
|
||||||
|
<div class="table-attach">
|
||||||
|
<!-- 选择执行 -->
|
||||||
|
<div class="select-box">
|
||||||
|
<Select v-model="selectAction" :disabled="selectIds.length==0" @on-change="groupSelect=true" :placeholder="$L('请选择')" transfer>
|
||||||
|
<Option value="read">{{ $L('标记已读') }}</Option>
|
||||||
|
<Option value="unread">{{ $L('标记未读') }}</Option>
|
||||||
|
</Select>
|
||||||
|
<Button :loading="loadIng > 0" type="primary" @click="selectClick" :disabled="selectAction=='' || selectIds.length==0">{{$L('执行')}}</Button>
|
||||||
|
</div>
|
||||||
|
<!-- 分页 -->
|
||||||
<Page
|
<Page
|
||||||
:total="listTotal"
|
:total="listTotal"
|
||||||
:current="listPage"
|
:current="listPage"
|
||||||
@ -71,11 +82,10 @@
|
|||||||
@on-page-size-change="setPageSize"/>
|
@on-page-size-change="setPageSize"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {mapState} from "vuex";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ReportReceive",
|
name: "ReportReceive",
|
||||||
data() {
|
data() {
|
||||||
@ -91,6 +101,9 @@ export default {
|
|||||||
keys: {},
|
keys: {},
|
||||||
keyIs: false,
|
keyIs: false,
|
||||||
|
|
||||||
|
selectIds: [],
|
||||||
|
selectAction: '',
|
||||||
|
|
||||||
reportTypeList: [
|
reportTypeList: [
|
||||||
{value: "", label: this.$L('全部')},
|
{value: "", label: this.$L('全部')},
|
||||||
{value: "weekly", label: this.$L('周报')},
|
{value: "weekly", label: this.$L('周报')},
|
||||||
@ -112,6 +125,10 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
initLanguage() {
|
initLanguage() {
|
||||||
this.columns = [{
|
this.columns = [{
|
||||||
|
type: 'selection',
|
||||||
|
width: 50,
|
||||||
|
align: 'right'
|
||||||
|
}, {
|
||||||
title: this.$L("标题"),
|
title: this.$L("标题"),
|
||||||
key: 'title',
|
key: 'title',
|
||||||
sortable: true,
|
sortable: true,
|
||||||
@ -222,6 +239,53 @@ export default {
|
|||||||
this.getLists();
|
this.getLists();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
selectChange(items) {
|
||||||
|
this.selectIds = items.map(({id}) => id);
|
||||||
|
},
|
||||||
|
|
||||||
|
selectClick() {
|
||||||
|
if (this.selectIds.length === 0) {
|
||||||
|
$A.messageWarning('请选择线路');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (this.selectAction) {
|
||||||
|
case 'read':
|
||||||
|
case 'unread':
|
||||||
|
this.readReport(this.selectIds, this.selectAction)
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$A.messageWarning('请选择执行方式');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
readReport(id, action) {
|
||||||
|
const label = action === 'read' ? '标记已读' : '标记未读'
|
||||||
|
$A.modalConfirm({
|
||||||
|
content: `你确定要【${label}】吗?`,
|
||||||
|
cancelText: '取消',
|
||||||
|
okText: '确定',
|
||||||
|
loading: true,
|
||||||
|
onOk: () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
this.$store.dispatch("call", {
|
||||||
|
url: 'report/mark',
|
||||||
|
data: {
|
||||||
|
id,
|
||||||
|
action,
|
||||||
|
}
|
||||||
|
}).then(({msg}) => {
|
||||||
|
resolve(msg);
|
||||||
|
this.getLists();
|
||||||
|
this.$emit("on-read")
|
||||||
|
}).catch(({msg}) => {
|
||||||
|
reject(msg);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
21
resources/assets/sass/pages/common.scss
vendored
21
resources/assets/sass/pages/common.scss
vendored
@ -528,6 +528,27 @@ body {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.table-attach {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 20px;
|
||||||
|
.select-box {
|
||||||
|
margin-right: 12px;
|
||||||
|
.ivu-select {
|
||||||
|
width: auto;
|
||||||
|
max-width: 200px;
|
||||||
|
margin-right: 3px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.ivu-page {
|
||||||
|
padding: 0;
|
||||||
|
margin-top: 0;
|
||||||
|
margin-left: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-container {
|
.page-container {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user