<template>
  <el-dialog v-model="visible" title="执行一次" width="40%" label-width="30%" :show-close="false" :lock-scroll="false">
    <el-form :model="form">
      <el-col :span="24">
        <el-form-item label="任务参数" prop="executorParam">
          <el-input v-model="form.executorParam" type="textarea" :rows="3" placeholder="请输入任务参数" class="filter-item" clearable />
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="机器地址" prop="addressList">
          <el-input v-model="form.addressList" type="textarea" :rows="3" placeholder="请输入机器地址" class="filter-item" clearable />
        </el-form-item>
      </el-col>
    </el-form>
    <template #footer>
      <span class="dialog-footer">
        <el-button
          @click="visible = false; form = {};">
          取消
        </el-button>
        <el-button type="primary" @click="submitForm"> 保存 </el-button>
      </span>
    </template>
  </el-dialog>
</template>
<script setup="JobInfoPlayOne" lang="ts">
import { playOneTime } from '@/api/xxljob/info';

const { proxy } = getCurrentInstance();
const visible = ref(false);
const form = ref({});
const chooseRowId = ref(null);

const show = (any) => {
  visible.value = true;
  chooseRowId.value = any.id;
};

const submitForm = async () => {
  form.value.id = chooseRowId.value;
  const res = await playOneTime(form.value);
  if (res.code == 200) {
    proxy?.$modal.msgSuccess('执行成功');
    visible.value = false;
    form.value = {};
  }
};

defineExpose({
  show
});
</script>

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