更新
This commit is contained in:
parent
7c5614a142
commit
6d52c2d2db
@ -60,141 +60,138 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup name="taskEidt">
|
<script lang="ts" setup name="taskEidt">
|
||||||
import type { FormInstance, FormRules } from "element-plus";
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
import Popup from "@/components/popup/index.vue";
|
import Popup from '@/components/popup/index.vue'
|
||||||
import { apiTaskAdd, apiTaskEdit, apiTaskDelete } from "@/api/task";
|
import { apiTaskAdd, apiTaskEdit, apiTaskDelete } from '@/api/task'
|
||||||
import { reactive, onUpdated, type PropType } from "vue";
|
import { reactive, onUpdated, type PropType } from 'vue'
|
||||||
import DialogIndex from "@/views/task_template/list_two.vue";
|
import DialogIndex from '@/views/task_template/list_two.vue'
|
||||||
import { timeFormat } from "@/utils/util";
|
import { timeFormat } from '@/utils/util'
|
||||||
import feedback from "@/utils/feedback";
|
import feedback from '@/utils/feedback'
|
||||||
const route = useRoute();
|
const route = useRoute()
|
||||||
|
|
||||||
const emit = defineEmits(["success", "close"]);
|
const emit = defineEmits(['success', 'close'])
|
||||||
const popupRef = shallowRef<InstanceType<typeof Popup>>();
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
||||||
const mode = ref("add");
|
const mode = ref('add')
|
||||||
const detailsdt = ref({});
|
const detailsdt = ref({})
|
||||||
const isShow = ref(false);
|
const isShow = ref(false)
|
||||||
const title = ref("创建日程安排");
|
const title = ref('创建日程安排')
|
||||||
|
|
||||||
const changeDateTime = (e: any) => {
|
const changeDateTime = (e: any) => {
|
||||||
formData.start_time = timeFormat(e[0]);
|
formData.start_time = timeFormat(e[0])
|
||||||
formData.end_time = timeFormat(e[1]);
|
formData.end_time = timeFormat(e[1])
|
||||||
};
|
}
|
||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
id: "",
|
id: '',
|
||||||
create_user_id: "",
|
create_user_id: '',
|
||||||
status: "",
|
status: '',
|
||||||
template_id: "",
|
template_id: '',
|
||||||
scheduling_id: "",
|
scheduling_id: '',
|
||||||
template_name: "",
|
template_name: '',
|
||||||
start_time: "",
|
start_time: '',
|
||||||
end_time: "",
|
end_time: '',
|
||||||
datetime: "",
|
datetime: ''
|
||||||
});
|
})
|
||||||
|
|
||||||
interface RuleForm {
|
interface RuleForm {
|
||||||
datetime: Date | String;
|
datetime: Date | string
|
||||||
template_id: String;
|
template_id: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const rules = reactive<FormRules<RuleForm>>({
|
const rules = reactive<FormRules<RuleForm>>({
|
||||||
datetime: { required: true, message: "请选择时间范围", trigger: "blur" },
|
datetime: { required: true, message: '请选择时间范围', trigger: 'blur' },
|
||||||
template_id: {
|
template_id: {
|
||||||
required: true,
|
required: true,
|
||||||
message: "请选择任务模板",
|
message: '请选择任务模板',
|
||||||
trigger: "change",
|
trigger: 'change'
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
function customEvent(data: any) {
|
function customEvent(data: any) {
|
||||||
isShow.value = false;
|
isShow.value = false
|
||||||
formData.template_id = data.id;
|
formData.template_id = data.id
|
||||||
formData.template_name = data.title;
|
formData.template_name = data.title
|
||||||
}
|
|
||||||
if (route.query.id) {
|
|
||||||
formData.scheduling_id = route.query.id.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const formRef = ref(null);
|
const formRef = ref(null)
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
task: {
|
task: {
|
||||||
type: Object,
|
type: Object,
|
||||||
defualt: () => {
|
defualt: () => {
|
||||||
null;
|
null
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
});
|
})
|
||||||
const isDisabled = ref(false);
|
const isDisabled = ref(false)
|
||||||
|
|
||||||
const updatedForm = async () => {
|
const updatedForm = async () => {
|
||||||
if (mode.value == "show") {
|
if (mode.value == 'show') {
|
||||||
title.value = "查看日程安排";
|
title.value = '查看日程安排'
|
||||||
isDisabled.value = true;
|
isDisabled.value = true
|
||||||
Object.keys(formData).forEach((key: any) => {
|
Object.keys(formData).forEach((key: any) => {
|
||||||
if (props.task[key] != null && props.task[key] != undefined)
|
if (props.task[key] != null && props.task[key] != undefined)
|
||||||
formData[key] = props.task[key];
|
formData[key] = props.task[key]
|
||||||
});
|
})
|
||||||
formData.datetime = [
|
formData.datetime = [formData.start_time.split(' ')[0], formData.end_time.split(' ')[0]]
|
||||||
formData.start_time.split(" ")[0],
|
|
||||||
formData.end_time.split(" ")[0],
|
|
||||||
];
|
|
||||||
} else {
|
} else {
|
||||||
isDisabled.value = false;
|
isDisabled.value = false
|
||||||
Object.keys(formData).forEach((key: any) => {
|
Object.keys(formData).forEach((key: any) => {
|
||||||
formData[key] = "";
|
formData[key] = ''
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
await nextTick();
|
await nextTick()
|
||||||
formRef.value.resetFields();
|
formRef.value.resetFields()
|
||||||
};
|
}
|
||||||
|
|
||||||
const clickUpdate = () => {
|
const clickUpdate = () => {
|
||||||
mode.value = "edit";
|
mode.value = 'edit'
|
||||||
isDisabled.value = false;
|
isDisabled.value = false
|
||||||
};
|
}
|
||||||
|
|
||||||
// 删除
|
// 删除
|
||||||
const clickDelete = () => {
|
const clickDelete = () => {
|
||||||
feedback.confirm("确定要删除吗?").then(async (e) => {
|
feedback.confirm('确定要删除吗?').then(async (e) => {
|
||||||
if (e == "confirm") {
|
if (e == 'confirm') {
|
||||||
await apiTaskDelete({ id: formData.id });
|
await apiTaskDelete({ id: formData.id })
|
||||||
popupRef.value?.close();
|
popupRef.value?.close()
|
||||||
emit("success");
|
emit('success')
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
};
|
}
|
||||||
|
|
||||||
// 提交按钮
|
// 提交按钮
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
if (mode.value == "show") return popupRef.value?.close();
|
if (mode.value == 'show') return popupRef.value?.close()
|
||||||
else
|
else
|
||||||
formRef.value.validate(async (e: Boolean) => {
|
formRef.value.validate(async (e: boolean) => {
|
||||||
if (e) {
|
if (e) {
|
||||||
const data = { ...formData };
|
const data = { ...formData }
|
||||||
mode.value == "edit" ? await apiTaskEdit(data) : await apiTaskAdd(data);
|
if (route.query.id) {
|
||||||
popupRef.value?.close();
|
data.scheduling_id = route.query.id.toString()
|
||||||
emit("success");
|
|
||||||
}
|
}
|
||||||
});
|
mode.value == 'edit' ? await apiTaskEdit(data) : await apiTaskAdd(data)
|
||||||
};
|
popupRef.value?.close()
|
||||||
|
emit('success')
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
//打开弹窗
|
//打开弹窗
|
||||||
const open = (type = "add") => {
|
const open = (type = 'add') => {
|
||||||
mode.value = type;
|
mode.value = type
|
||||||
popupRef.value?.open();
|
popupRef.value?.open()
|
||||||
};
|
}
|
||||||
|
|
||||||
// 关闭回调
|
// 关闭回调
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
emit("close");
|
emit('close')
|
||||||
};
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
open,
|
open,
|
||||||
updatedForm,
|
updatedForm
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.formdata {
|
.formdata {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user