2023-08-11 18:23:36 +08:00
|
|
|
<template>
|
2023-08-12 16:05:13 +08:00
|
|
|
<div class="edit-popup">
|
|
|
|
<popup
|
|
|
|
ref="popupRef"
|
|
|
|
title="创建日程安排"
|
|
|
|
:async="true"
|
|
|
|
width="800px"
|
|
|
|
@confirm="handleSubmit"
|
|
|
|
@close="handleClose"
|
|
|
|
>
|
|
|
|
<el-form class="formdata" :model="detailsdt" label-width="120px">
|
|
|
|
<el-form-item label="任务日期">
|
|
|
|
<el-date-picker v-model="formData.time" type="date" placeholder="选择日期" />
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="任务模板">
|
|
|
|
<el-input
|
|
|
|
v-model="formData.template_name"
|
|
|
|
@click="isShow = true"
|
|
|
|
clearable
|
|
|
|
placeholder="请输入任务模板"
|
|
|
|
/>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</popup>
|
|
|
|
<el-dialog v-model="isShow" title="选择任务" width="60%">
|
|
|
|
<DialogIndex @customEvent="customEvent" />
|
|
|
|
</el-dialog>
|
|
|
|
</div>
|
2023-08-11 18:23:36 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts" setup name="taskEidt">
|
2023-08-12 16:05:13 +08:00
|
|
|
import type { FormInstance } from 'element-plus'
|
|
|
|
import Popup from '@/components/popup/index.vue'
|
|
|
|
import { apiTaskAdd } from '@/api/task'
|
|
|
|
import { reactive, onUpdated, type PropType } from 'vue'
|
|
|
|
import DialogIndex from '@/views/task_template/list_two.vue'
|
|
|
|
const route = useRoute()
|
2023-08-11 18:23:36 +08:00
|
|
|
|
2023-08-12 16:05:13 +08:00
|
|
|
const emit = defineEmits(['success', 'close'])
|
|
|
|
const popupRef = shallowRef<InstanceType<typeof Popup>>()
|
|
|
|
const mode = ref('add')
|
|
|
|
const detailsdt = ref({})
|
|
|
|
const isShow = ref(false)
|
2023-08-11 18:23:36 +08:00
|
|
|
|
|
|
|
// 表单数据
|
|
|
|
const formData = reactive({
|
2023-08-12 16:05:13 +08:00
|
|
|
time: '',
|
|
|
|
template_id: '',
|
|
|
|
scheduling_id: '',
|
|
|
|
template_name: ''
|
|
|
|
})
|
|
|
|
function customEvent(data: any) {
|
|
|
|
isShow.value = false
|
|
|
|
formData.template_id = data.id
|
|
|
|
formData.template_name = data.title
|
|
|
|
}
|
|
|
|
if (route.query.id) {
|
|
|
|
formData.scheduling_id = route.query.id.toString()
|
|
|
|
}
|
2023-08-11 18:23:36 +08:00
|
|
|
|
|
|
|
// 提交按钮
|
2023-08-12 16:05:13 +08:00
|
|
|
const handleSubmit = async () => {
|
|
|
|
const data = { ...formData }
|
|
|
|
console.log(data)
|
|
|
|
mode.value == 'edit' ? await apiTaskAdd(data) : await apiTaskAdd(data)
|
|
|
|
popupRef.value?.close()
|
|
|
|
emit('success')
|
|
|
|
}
|
2023-08-11 18:23:36 +08:00
|
|
|
//打开弹窗
|
2023-08-12 16:05:13 +08:00
|
|
|
const open = (type = 'add') => {
|
|
|
|
mode.value = type
|
|
|
|
popupRef.value?.open()
|
|
|
|
}
|
2023-08-11 18:23:36 +08:00
|
|
|
|
|
|
|
// 关闭回调
|
|
|
|
const handleClose = () => {
|
2023-08-12 16:05:13 +08:00
|
|
|
emit('close')
|
|
|
|
}
|
2023-08-11 18:23:36 +08:00
|
|
|
|
|
|
|
defineExpose({
|
2023-08-12 16:05:13 +08:00
|
|
|
open
|
|
|
|
})
|
2023-08-11 18:23:36 +08:00
|
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.formdata {
|
2023-08-12 16:05:13 +08:00
|
|
|
.el-form-item {
|
|
|
|
.el-date-picker {
|
|
|
|
width: 100%;
|
|
|
|
}
|
2023-08-11 18:23:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|