perf: 领取任务需要设置计划时间

This commit is contained in:
kuaifan 2022-01-08 08:00:50 +08:00
parent bf6f8de7fa
commit bf15be8144
3 changed files with 91 additions and 23 deletions

View File

@ -52,7 +52,7 @@
v-model="addData.times" v-model="addData.times"
:options="timeOptions" :options="timeOptions"
:placeholder="$L('选择计划范围')" :placeholder="$L('选择计划范围')"
format="yyyy-MM-dd HH:mm" format="yyyy/MM/dd HH:mm"
type="datetimerange" type="datetimerange"
placement="bottom" placement="bottom"
@on-change="taskTimeChange(addData.times)" @on-change="taskTimeChange(addData.times)"
@ -72,7 +72,7 @@
:options="timeOptions" :options="timeOptions"
:editable="false" :editable="false"
:placeholder="$L('选择计划范围')" :placeholder="$L('选择计划范围')"
format="yyyy-MM-dd HH:mm" format="yyyy/MM/dd HH:mm"
type="datetimerange" type="datetimerange"
@on-change="taskTimeChange(addData.times)"/> @on-change="taskTimeChange(addData.times)"/>
</FormItem> </FormItem>
@ -104,7 +104,7 @@
:options="timeOptions" :options="timeOptions"
:editable="false" :editable="false"
:placeholder="$L('选择时间')" :placeholder="$L('选择时间')"
format="yyyy-MM-dd HH:mm" format="yyyy/MM/dd HH:mm"
type="datetimerange" type="datetimerange"
@on-change="taskTimeChange(item.times)"/> @on-change="taskTimeChange(item.times)"/>
</Col> </Col>

View File

@ -51,7 +51,7 @@
v-model="timeValue" v-model="timeValue"
:open="timeOpen" :open="timeOpen"
:options="timeOptions" :options="timeOptions"
format="yyyy-MM-dd HH:mm" format="yyyy/MM/dd HH:mm"
type="datetimerange" type="datetimerange"
class="subtask-time" class="subtask-time"
@on-open-change="timeChange" @on-open-change="timeChange"
@ -101,16 +101,32 @@
<p v-if="taskDetail.id"><span>{{taskDetail.id}}</span></p> <p v-if="taskDetail.id"><span>{{taskDetail.id}}</span></p>
</div> </div>
<div class="function"> <div class="function">
<Poptip <EPopover
v-if="getOwner.length === 0" v-if="getOwner.length === 0"
confirm v-model="receiveShow"
ref="receive" placement="bottom">
class="pick" <div class="task-detail-receive">
:title="$L('你确认领取任务吗?')" <div class="receive-title">
placement="bottom" <Icon type="ios-help-circle"/>
@on-ok="onOwner(true)"> {{$L('确认计划时间领取任务')}}
<Button type="primary">{{$L('我要领取任务')}}</Button> </div>
</Poptip> <div class="receive-time">
<DatePicker
v-model="timeValue"
:options="timeOptions"
format="yyyy/MM/dd HH:mm"
type="datetimerange"
:placeholder="$L('请设置计划时间')"
:clearable="false"
:editable="false"/>
</div>
<div class="receive-bottom">
<Button size="small" type="text" @click="receiveShow=false">取消</Button>
<Button :loading="ownerLoad > 0" size="small" type="primary" @click="onOwner(true)">确定</Button>
</div>
</div>
<Button slot="reference" :loading="ownerLoad > 0" class="pick" type="primary">{{$L('我要领取任务')}}</Button>
</EPopover>
<ETooltip v-if="$Electron" :content="$L('新窗口打开')"> <ETooltip v-if="$Electron" :content="$L('新窗口打开')">
<i class="taskfont open" @click="openNewWin">&#xe776;</i> <i class="taskfont open" @click="openNewWin">&#xe776;</i>
</ETooltip> </ETooltip>
@ -265,7 +281,7 @@
v-model="timeValue" v-model="timeValue"
:open="timeOpen" :open="timeOpen"
:options="timeOptions" :options="timeOptions"
format="yyyy-MM-dd HH:mm" format="yyyy/MM/dd HH:mm"
type="datetimerange" type="datetimerange"
@on-open-change="timeChange" @on-open-change="timeChange"
@on-clear="timeClear" @on-clear="timeClear"
@ -441,6 +457,8 @@ export default {
ownerData: {}, ownerData: {},
ownerLoad: 0, ownerLoad: 0,
receiveShow: false,
assistForce: false, assistForce: false,
assistShow: false, assistShow: false,
assistData: {}, assistData: {},
@ -502,7 +520,7 @@ export default {
window.addEventListener('resize', this.innerHeightListener); window.addEventListener('resize', this.innerHeightListener);
// //
this.receiveTaskSubscribe = Store.subscribe('receiveTask', () => { this.receiveTaskSubscribe = Store.subscribe('receiveTask', () => {
this.$refs.receive && this.$refs.receive.handleClick(); this.receiveShow = true;
}); });
}, },
@ -687,11 +705,17 @@ export default {
this.timeForce = false; this.timeForce = false;
this.assistForce = false; this.assistForce = false;
this.addsubForce = false; this.addsubForce = false;
this.receiveShow = false;
this.$refs.owner && this.$refs.owner.handleClose(); this.$refs.owner && this.$refs.owner.handleClose();
this.$refs.assist && this.$refs.assist.handleClose(); this.$refs.assist && this.$refs.assist.handleClose();
} }
}, },
immediate: true immediate: true
},
receiveShow(val) {
if (val) {
this.timeValue = this.taskDetail.end_at ? [this.taskDetail.start_at, this.taskDetail.end_at] : [];
}
} }
}, },
@ -867,27 +891,46 @@ export default {
}, },
onOwner(pick) { onOwner(pick) {
if (pick === true && this.getOwner.length === 0) { let data = {
this.ownerData.owner_userid = [this.userId]; task_id: this.taskDetail.id,
owner: this.ownerData.owner_userid
}
//
if (pick === true) {
if (this.getOwner.length > 0) {
this.receiveShow = false;
$A.messageError("任务已被领取");
return;
}
let times = $A.date2string(this.timeValue, "Y-m-d H:i");
if (times[0] && times[1]) {
if ($A.rightExists(times[0], '00:00') && $A.rightExists(times[1], '00:00')) {
times[1] = times[1].replace("00:00", "23:59");
}
} else {
$A.messageError("请设置计划时间");
return;
}
data.times = times;
data.owner = this.ownerData.owner_userid = [this.userId];
} }
if ($A.jsonStringify(this.taskDetail.owner_userid) === $A.jsonStringify(this.ownerData.owner_userid)) { if ($A.jsonStringify(this.taskDetail.owner_userid) === $A.jsonStringify(this.ownerData.owner_userid)) {
return; return;
} }
let owner = this.ownerData.owner_userid; //
if ($A.count(owner) == 0) owner = ''; if ($A.count(data.owner) == 0) data.owner = '';
this.ownerLoad++; this.ownerLoad++;
this.$store.dispatch("taskUpdate", { this.$store.dispatch("taskUpdate", data).then(({msg}) => {
task_id: this.taskDetail.id,
owner: owner,
}).then(({msg}) => {
$A.messageSuccess(msg); $A.messageSuccess(msg);
this.ownerLoad--; this.ownerLoad--;
this.ownerShow = false; this.ownerShow = false;
this.receiveShow = false;
this.$store.dispatch("getTaskOne", this.taskDetail.id); this.$store.dispatch("getTaskOne", this.taskDetail.id);
}).catch(({msg}) => { }).catch(({msg}) => {
$A.modalError(msg); $A.modalError(msg);
this.ownerLoad--; this.ownerLoad--;
this.ownerShow = false; this.ownerShow = false;
this.receiveShow = false;
}) })
}, },

View File

@ -585,6 +585,31 @@
} }
} }
.task-detail-receive {
padding: 6px 6px 3px;
.receive-title {
font-size: 14px;
.ivu-icon {
font-size: 16px;
color: #f90;
line-height: 18px;
}
}
.receive-time {
margin-top: 10px;
.ivu-date-picker {
width: 280px;
}
}
.receive-bottom {
text-align: right;
margin-top: 12px;
> button + button {
margin-left: 4px;
}
}
}
.task-detail-delete-file-popover { .task-detail-delete-file-popover {
max-width: 200px; max-width: 200px;
.buttons { .buttons {