UploadGroupDataEditor.vue 2.25 KB
<template>
  <a-modal
      title="上传数据"
      v-if='isVisible'
      v-model:visible="isVisible"
      width="400px"
      height='50%'
      class="detail-modal"
  >
    <a-form :model="formData">
      <a-form-item label="数据包ID">
        <a-input v-model:value="formData.packId" style="width: 100%;" />
      </a-form-item>
			<a-form-item label="任务ID">
        <a-input v-model:value="formData.taskId" style="width: 100%;" />
			</a-form-item>
    </a-form>

    <template #footer>
      <a-button :disabled="formData.packId==''||formData.taskId==''||isNaN(formData.packId)||isNaN(formData.taskId)" type="primary" @click="onSave">保存</a-button>
      <a-button @click="onCancel">关闭</a-button>
    </template>
  </a-modal>
</template>

<script>
import { ref } from "vue";
import clusterResultApi from '@/views/SnapshotCluster/ClusterResult/ClusterResultApi'
import { ElMessage } from "element-plus";

export default {
  name: 'PersonGroupEditor',
  setup(props, { emit }) {
    const isVisible = ref(false);
    // 表单
    function getInitialFormData() {
      return {
        personUnid: '',
        packId: '',
        taskId: '',
        countdate: '',
      }
    }
    const formData = ref(getInitialFormData())

    const initDialog = (data) => {
      console.log('initDialog', data)
      formData.value = getInitialFormData()
      formData.value.personUnid = [data.personUnid]
      formData.value.countdate = data.countdate
      formData.value.packId = ''
      formData.value.taskId = ''
      isVisible.value = true;
    };

    const onCancel = () => {
      isVisible.value = false;
    };
    const onSave = () => {
				formData.value.packId = formData.value.packId*1;
				formData.value.taskId = formData.value.taskId*1;
				clusterResultApi.uploadGroupData(formData.value).then(
						(r) => {
							if(r.code==200){
								ElMessage({
									message: r.msg,
									type: 'success'
								})
								// 刷新列表
								emit('refresh')
								onCancel()
							} else {
								ElMessage({
									message: `保存失败`,
									type: 'error'
								})
							}
						}
				)
    };

    return {
      isVisible,
      formData,
      onSave,
      onCancel,
      initDialog,
    };
  },
};
</script>

<style lang="less" scoped>
</style>