mirror of
https://github.com/kuaifan/dootask.git
synced 2026-03-17 11:13:26 +00:00
perf: 工作汇报可留空汇报对象
This commit is contained in:
parent
88362cb1f9
commit
b7ac923d36
@ -119,13 +119,13 @@ class ReportController extends AbstractController
|
|||||||
* @apiGroup report
|
* @apiGroup report
|
||||||
* @apiName store
|
* @apiName store
|
||||||
*
|
*
|
||||||
* @apiParam {Number} [id] 汇报ID
|
* @apiParam {Number} id 汇报ID,0为新建
|
||||||
* @apiParam {String} [sign] 唯一签名,通过[api/report/template]接口返回
|
* @apiParam {String} [sign] 唯一签名,通过[api/report/template]接口返回
|
||||||
* @apiParam {String} [title] 汇报标题
|
* @apiParam {String} title 汇报标题
|
||||||
* @apiParam {Array} [type] 汇报类型,weekly:周报,daily:日报
|
* @apiParam {Array} type 汇报类型,weekly:周报,daily:日报
|
||||||
* @apiParam {Number} [content] 内容
|
* @apiParam {Number} content 内容
|
||||||
* @apiParam {Number} [receive] 汇报对象
|
* @apiParam {Number} [receive] 汇报对象
|
||||||
* @apiParam {Number} [offset] 偏移量
|
* @apiParam {Number} offset 时间偏移量
|
||||||
*
|
*
|
||||||
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
|
||||||
* @apiSuccess {String} msg 返回信息(错误描述)
|
* @apiSuccess {String} msg 返回信息(错误描述)
|
||||||
@ -133,8 +133,11 @@ class ReportController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function store(): array
|
public function store(): array
|
||||||
{
|
{
|
||||||
|
$user = User::auth();
|
||||||
|
//
|
||||||
$input = [
|
$input = [
|
||||||
"id" => Base::getPostValue("id", 0),
|
"id" => Base::getPostValue("id", 0),
|
||||||
|
"sign" => Base::getPostValue("sign"),
|
||||||
"title" => Base::getPostValue("title"),
|
"title" => Base::getPostValue("title"),
|
||||||
"type" => Base::getPostValue("type"),
|
"type" => Base::getPostValue("type"),
|
||||||
"content" => Base::getPostValue("content"),
|
"content" => Base::getPostValue("content"),
|
||||||
@ -147,7 +150,6 @@ class ReportController extends AbstractController
|
|||||||
'title' => 'required',
|
'title' => 'required',
|
||||||
'type' => ['required', Rule::in([Report::WEEKLY, Report::DAILY])],
|
'type' => ['required', Rule::in([Report::WEEKLY, Report::DAILY])],
|
||||||
'content' => 'required',
|
'content' => 'required',
|
||||||
'receive' => 'required',
|
|
||||||
'offset' => ['numeric', 'max:0'],
|
'offset' => ['numeric', 'max:0'],
|
||||||
], [
|
], [
|
||||||
'id.numeric' => 'ID只能是数字',
|
'id.numeric' => 'ID只能是数字',
|
||||||
@ -155,14 +157,12 @@ class ReportController extends AbstractController
|
|||||||
'type.required' => '请选择汇报类型',
|
'type.required' => '请选择汇报类型',
|
||||||
'type.in' => '汇报类型错误',
|
'type.in' => '汇报类型错误',
|
||||||
'content.required' => '请填写汇报内容',
|
'content.required' => '请填写汇报内容',
|
||||||
'receive.required' => '请选择接收人',
|
|
||||||
'offset.numeric' => '工作汇报周期格式错误,只能是数字',
|
'offset.numeric' => '工作汇报周期格式错误,只能是数字',
|
||||||
'offset.max' => '只能提交当天/本周或者之前的的工作汇报',
|
'offset.max' => '只能提交当天/本周或者之前的的工作汇报',
|
||||||
]);
|
]);
|
||||||
if ($validator->fails())
|
if ($validator->fails())
|
||||||
return Base::retError($validator->errors()->first());
|
return Base::retError($validator->errors()->first());
|
||||||
|
|
||||||
$user = User::auth();
|
|
||||||
// 接收人
|
// 接收人
|
||||||
if (is_array($input["receive"])) {
|
if (is_array($input["receive"])) {
|
||||||
// 删除当前登录人
|
// 删除当前登录人
|
||||||
@ -207,11 +207,11 @@ class ReportController extends AbstractController
|
|||||||
"content" => htmlspecialchars($input["content"]),
|
"content" => htmlspecialchars($input["content"]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$report->save();
|
$report->save();
|
||||||
if (!empty($input["receive_content"])) {
|
|
||||||
// 删除关联
|
// 删除关联
|
||||||
$report->Receives()->delete();
|
$report->Receives()->delete();
|
||||||
|
if ($input["receive_content"]) {
|
||||||
// 保存接收人
|
// 保存接收人
|
||||||
$report->Receives()->createMany($input["receive_content"]);
|
$report->Receives()->createMany($input["receive_content"]);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,7 +36,9 @@
|
|||||||
:placeholder="$L('选择接收人')"
|
:placeholder="$L('选择接收人')"
|
||||||
:transfer="false"/>
|
:transfer="false"/>
|
||||||
<a class="report-user-link" href="javascript:void(0);" @click="getLastSubmitter">
|
<a class="report-user-link" href="javascript:void(0);" @click="getLastSubmitter">
|
||||||
<Icon type="ios-share-outline" />{{ $L("使用我上次的汇报对象") }}
|
<Icon v-if="receiveLoad > 0" type="ios-loading" class="icon-loading"/>
|
||||||
|
<Icon v-else type="ios-share-outline" />
|
||||||
|
{{ $L("使用我上次的汇报对象") }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
@ -44,7 +46,7 @@
|
|||||||
<TEditor v-model="reportData.content" height="100%"/>
|
<TEditor v-model="reportData.content" height="100%"/>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
<FormItem class="report-foot">
|
<FormItem class="report-foot">
|
||||||
<Button type="primary" @click="handleSubmit" class="report-bottom">{{$L(id > 0 ? '修改' : '提交')}}</Button>
|
<Button type="primary" @click="handleSubmit" :loading="loadIng > 0" class="report-bottom">{{$L(id > 0 ? '修改' : '提交')}}</Button>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
</Form>
|
</Form>
|
||||||
</template>
|
</template>
|
||||||
@ -66,6 +68,9 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
loadIng: 0,
|
||||||
|
receiveLoad: 0,
|
||||||
|
|
||||||
reportData: {
|
reportData: {
|
||||||
sign: "",
|
sign: "",
|
||||||
title: "",
|
title: "",
|
||||||
@ -99,10 +104,6 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
if (this.reportData.receive.length === 0) {
|
|
||||||
$A.messageError(this.$L("请选择接收人"));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.id === 0 && this.reportData.id > 0) {
|
if (this.id === 0 && this.reportData.id > 0) {
|
||||||
$A.modalConfirm({
|
$A.modalConfirm({
|
||||||
title: '覆盖提交',
|
title: '覆盖提交',
|
||||||
@ -117,6 +118,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
doSubmit() {
|
doSubmit() {
|
||||||
|
this.loadIng++;
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'report/store',
|
url: 'report/store',
|
||||||
data: this.reportData,
|
data: this.reportData,
|
||||||
@ -133,10 +135,13 @@ export default {
|
|||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
// msg 错误原因
|
// msg 错误原因
|
||||||
$A.messageError(msg);
|
$A.messageError(msg);
|
||||||
|
}).finally(_ => {
|
||||||
|
this.loadIng--;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getTemplate() {
|
getTemplate() {
|
||||||
|
this.loadIng++;
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'report/template',
|
url: 'report/template',
|
||||||
data: {
|
data: {
|
||||||
@ -164,6 +169,8 @@ export default {
|
|||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
// msg 错误原因
|
// msg 错误原因
|
||||||
$A.messageError(msg);
|
$A.messageError(msg);
|
||||||
|
}).finally(_ => {
|
||||||
|
this.loadIng--;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -216,12 +223,17 @@ export default {
|
|||||||
|
|
||||||
// 获取上一次接收人
|
// 获取上一次接收人
|
||||||
getLastSubmitter() {
|
getLastSubmitter() {
|
||||||
|
setTimeout(_ => {
|
||||||
|
this.receiveLoad++;
|
||||||
|
}, 300)
|
||||||
this.$store.dispatch("call", {
|
this.$store.dispatch("call", {
|
||||||
url: 'report/last_submitter',
|
url: 'report/last_submitter',
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
this.reportData.receive = data;
|
this.reportData.receive = data;
|
||||||
}).catch(({msg}) => {
|
}).catch(({msg}) => {
|
||||||
$A.messageError(msg);
|
$A.messageError(msg);
|
||||||
|
}).finally(_ => {
|
||||||
|
this.receiveLoad--;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user