diff --git a/app/Http/Controllers/Api/ReportController.php b/app/Http/Controllers/Api/ReportController.php
index 35bba8da3..046f926a8 100755
--- a/app/Http/Controllers/Api/ReportController.php
+++ b/app/Http/Controllers/Api/ReportController.php
@@ -119,13 +119,13 @@ class ReportController extends AbstractController
* @apiGroup report
* @apiName store
*
- * @apiParam {Number} [id] 汇报ID
- * @apiParam {String} [sign] 唯一签名,通过[api/report/template]接口返回
- * @apiParam {String} [title] 汇报标题
- * @apiParam {Array} [type] 汇报类型,weekly:周报,daily:日报
- * @apiParam {Number} [content] 内容
- * @apiParam {Number} [receive] 汇报对象
- * @apiParam {Number} [offset] 偏移量
+ * @apiParam {Number} id 汇报ID,0为新建
+ * @apiParam {String} [sign] 唯一签名,通过[api/report/template]接口返回
+ * @apiParam {String} title 汇报标题
+ * @apiParam {Array} type 汇报类型,weekly:周报,daily:日报
+ * @apiParam {Number} content 内容
+ * @apiParam {Number} [receive] 汇报对象
+ * @apiParam {Number} offset 时间偏移量
*
* @apiSuccess {Number} ret 返回状态码(1正确、0错误)
* @apiSuccess {String} msg 返回信息(错误描述)
@@ -133,8 +133,11 @@ class ReportController extends AbstractController
*/
public function store(): array
{
+ $user = User::auth();
+ //
$input = [
"id" => Base::getPostValue("id", 0),
+ "sign" => Base::getPostValue("sign"),
"title" => Base::getPostValue("title"),
"type" => Base::getPostValue("type"),
"content" => Base::getPostValue("content"),
@@ -147,7 +150,6 @@ class ReportController extends AbstractController
'title' => 'required',
'type' => ['required', Rule::in([Report::WEEKLY, Report::DAILY])],
'content' => 'required',
- 'receive' => 'required',
'offset' => ['numeric', 'max:0'],
], [
'id.numeric' => 'ID只能是数字',
@@ -155,14 +157,12 @@ class ReportController extends AbstractController
'type.required' => '请选择汇报类型',
'type.in' => '汇报类型错误',
'content.required' => '请填写汇报内容',
- 'receive.required' => '请选择接收人',
'offset.numeric' => '工作汇报周期格式错误,只能是数字',
'offset.max' => '只能提交当天/本周或者之前的的工作汇报',
]);
if ($validator->fails())
return Base::retError($validator->errors()->first());
- $user = User::auth();
// 接收人
if (is_array($input["receive"])) {
// 删除当前登录人
@@ -207,11 +207,11 @@ class ReportController extends AbstractController
"content" => htmlspecialchars($input["content"]),
]);
}
-
$report->save();
- if (!empty($input["receive_content"])) {
- // 删除关联
- $report->Receives()->delete();
+
+ // 删除关联
+ $report->Receives()->delete();
+ if ($input["receive_content"]) {
// 保存接收人
$report->Receives()->createMany($input["receive_content"]);
}
diff --git a/resources/assets/js/pages/manage/components/ReportEdit.vue b/resources/assets/js/pages/manage/components/ReportEdit.vue
index 2634e6bf3..80982c029 100644
--- a/resources/assets/js/pages/manage/components/ReportEdit.vue
+++ b/resources/assets/js/pages/manage/components/ReportEdit.vue
@@ -36,7 +36,9 @@
:placeholder="$L('选择接收人')"
:transfer="false"/>
- {{ $L("使用我上次的汇报对象") }}
+
+
+ {{ $L("使用我上次的汇报对象") }}
@@ -44,7 +46,7 @@
@@ -66,6 +68,9 @@ export default {
},
data() {
return {
+ loadIng: 0,
+ receiveLoad: 0,
+
reportData: {
sign: "",
title: "",
@@ -99,10 +104,6 @@ export default {
},
methods: {
handleSubmit() {
- if (this.reportData.receive.length === 0) {
- $A.messageError(this.$L("请选择接收人"));
- return false;
- }
if (this.id === 0 && this.reportData.id > 0) {
$A.modalConfirm({
title: '覆盖提交',
@@ -117,6 +118,7 @@ export default {
},
doSubmit() {
+ this.loadIng++;
this.$store.dispatch("call", {
url: 'report/store',
data: this.reportData,
@@ -133,10 +135,13 @@ export default {
}).catch(({msg}) => {
// msg 错误原因
$A.messageError(msg);
+ }).finally(_ => {
+ this.loadIng--;
});
},
getTemplate() {
+ this.loadIng++;
this.$store.dispatch("call", {
url: 'report/template',
data: {
@@ -164,6 +169,8 @@ export default {
}).catch(({msg}) => {
// msg 错误原因
$A.messageError(msg);
+ }).finally(_ => {
+ this.loadIng--;
});
},
@@ -216,12 +223,17 @@ export default {
// 获取上一次接收人
getLastSubmitter() {
+ setTimeout(_ => {
+ this.receiveLoad++;
+ }, 300)
this.$store.dispatch("call", {
url: 'report/last_submitter',
}).then(({data}) => {
this.reportData.receive = data;
}).catch(({msg}) => {
$A.messageError(msg);
+ }).finally(_ => {
+ this.receiveLoad--;
});
},