|
@@ -15,11 +15,11 @@
|
|
:data="formData.times"
|
|
:data="formData.times"
|
|
:bordered="false"
|
|
:bordered="false"
|
|
>
|
|
>
|
|
- <template #item="{ item, index }">
|
|
|
|
|
|
+ <template #item="{ item }">
|
|
<a-form-item
|
|
<a-form-item
|
|
- :field="`times[${index}].startTime`"
|
|
|
|
|
|
+ :field="`times[${item.no - 1}].startTime`"
|
|
:rules="rules"
|
|
:rules="rules"
|
|
- :label="index + 1 + ''"
|
|
|
|
|
|
+ :label="item.no + ''"
|
|
>
|
|
>
|
|
<select-range-datetime
|
|
<select-range-datetime
|
|
v-model:startTime="item.startTime"
|
|
v-model:startTime="item.startTime"
|
|
@@ -27,7 +27,11 @@
|
|
popup-container=".modify-task"
|
|
popup-container=".modify-task"
|
|
>
|
|
>
|
|
</select-range-datetime>
|
|
</select-range-datetime>
|
|
- <a-button class="ml-10" status="danger" @click="toDelete(index)">
|
|
|
|
|
|
+ <a-button
|
|
|
|
+ class="ml-10"
|
|
|
|
+ status="danger"
|
|
|
|
+ @click="toDelete(item.no - 1)"
|
|
|
|
+ >
|
|
<template #icon>
|
|
<template #icon>
|
|
<svg-icon name="icon-delete"></svg-icon>
|
|
<svg-icon name="icon-delete"></svg-icon>
|
|
</template>
|
|
</template>
|
|
@@ -55,7 +59,6 @@
|
|
import { updateTaskTime, deleteTaskTime } from '@/api/order';
|
|
import { updateTaskTime, deleteTaskTime } from '@/api/order';
|
|
import useLoading from '@/hooks/loading';
|
|
import useLoading from '@/hooks/loading';
|
|
import type { FormInstance, FieldRule } from '@arco-design/web-vue/es/form';
|
|
import type { FormInstance, FieldRule } from '@arco-design/web-vue/es/form';
|
|
- import { deepCopy } from '@/utils/utils';
|
|
|
|
import { TaskItemDetail } from '@/api/types/order';
|
|
import { TaskItemDetail } from '@/api/types/order';
|
|
import { modalConfirm } from '@/utils/arco';
|
|
import { modalConfirm } from '@/utils/arco';
|
|
|
|
|
|
@@ -71,7 +74,12 @@
|
|
|
|
|
|
interface FormDataType {
|
|
interface FormDataType {
|
|
id: number;
|
|
id: number;
|
|
- times: TaskItemDetail['timeList'];
|
|
|
|
|
|
+ times: Array<{
|
|
|
|
+ id: number | null;
|
|
|
|
+ startTime: number | undefined;
|
|
|
|
+ endTime: number | undefined;
|
|
|
|
+ no: number;
|
|
|
|
+ }>;
|
|
}
|
|
}
|
|
|
|
|
|
const defaultFormData = {
|
|
const defaultFormData = {
|
|
@@ -99,7 +107,12 @@
|
|
}
|
|
}
|
|
|
|
|
|
function timeSelected(times: TaskItemDetail['timeList']) {
|
|
function timeSelected(times: TaskItemDetail['timeList']) {
|
|
- formData.times.push(...times);
|
|
|
|
|
|
+ formData.times.push(
|
|
|
|
+ ...times.map((item) => {
|
|
|
|
+ return { ...item, no: 0 };
|
|
|
|
+ })
|
|
|
|
+ );
|
|
|
|
+ updateTimeIndex();
|
|
}
|
|
}
|
|
|
|
|
|
async function toDelete(index: number) {
|
|
async function toDelete(index: number) {
|
|
@@ -113,9 +126,16 @@
|
|
await deleteTaskTime(formData.times[index].id as number);
|
|
await deleteTaskTime(formData.times[index].id as number);
|
|
}
|
|
}
|
|
formData.times.splice(index, 1);
|
|
formData.times.splice(index, 1);
|
|
|
|
+ updateTimeIndex();
|
|
await formRef.value?.validate();
|
|
await formRef.value?.validate();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ function updateTimeIndex() {
|
|
|
|
+ formData.times.forEach((item, index) => {
|
|
|
|
+ item.no = index + 1;
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
/* confirm */
|
|
/* confirm */
|
|
const { loading, setLoading } = useLoading();
|
|
const { loading, setLoading } = useLoading();
|
|
async function confirm() {
|
|
async function confirm() {
|
|
@@ -138,7 +158,12 @@
|
|
}
|
|
}
|
|
/* init */
|
|
/* init */
|
|
function initData() {
|
|
function initData() {
|
|
- formData.times = deepCopy(props.rowData.timeList);
|
|
|
|
|
|
+ formData.times = props.rowData.timeList.map((item, index) => {
|
|
|
|
+ return {
|
|
|
|
+ no: index + 1,
|
|
|
|
+ ...item,
|
|
|
|
+ };
|
|
|
|
+ });
|
|
formData.id = props.rowData.id;
|
|
formData.id = props.rowData.id;
|
|
}
|
|
}
|
|
onMounted(() => {
|
|
onMounted(() => {
|