Commit c151e788 authored by 张俊's avatar 张俊

新增编辑任务调整

parent b1bf6882
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</template> </template>
<script setup> <script setup>
import { reactive, ref, onBeforeMount, toRefs } from "vue"; import { reactive, ref, onBeforeMount, toRefs, watch } from "vue";
const props = defineProps({ const props = defineProps({
modelValue: { modelValue: {
type: [String, Number], type: [String, Number],
...@@ -35,6 +35,13 @@ const emit = defineEmits(["update:modelValue", "change"]); ...@@ -35,6 +35,13 @@ const emit = defineEmits(["update:modelValue", "change"]);
const nowIndex = ref(""); const nowIndex = ref("");
watch(
() => props.modelValue,
() => {
nowIndex.value = props.modelValue;
}
);
const changeInner = (val) => { const changeInner = (val) => {
nowIndex.value = val; nowIndex.value = val;
emit("update:modelValue", val); emit("update:modelValue", val);
...@@ -42,7 +49,7 @@ const changeInner = (val) => { ...@@ -42,7 +49,7 @@ const changeInner = (val) => {
}; };
onBeforeMount(() => { onBeforeMount(() => {
nowIndex.value = props.default; nowIndex.value = props.modelValue;
}); });
</script> </script>
......
...@@ -33,10 +33,12 @@ const props = defineProps({ ...@@ -33,10 +33,12 @@ const props = defineProps({
}, },
}); });
const ruleFormRef = ref(null);
const state = reactive({ const state = reactive({
ruleForm: { ruleForm: {
name: props.data?.name, name: props.data?.name || "",
desc: props.data?.desc, desc: props.data?.desc || "",
}, },
rules: { rules: {
name: [ name: [
...@@ -47,10 +49,28 @@ const state = reactive({ ...@@ -47,10 +49,28 @@ const state = reactive({
}, },
}); });
const save = () => {}; const save = () => {
return new Promise((resolve, reject) => {
ruleFormRef.value.validate((valid, fields) => {
if (valid) {
props.data.name = state.ruleForm.name;
props.data.desc = state.ruleForm.desc;
resolve();
} else {
reject();
console.log("error submit!", fields);
}
});
});
};
const clear = () => {
ruleFormRef.value.resetFields();
};
defineExpose({ defineExpose({
save, save,
clear,
}); });
</script> </script>
......
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
<img src="@/assets/imgs/img_data-complete.png" /> <img src="@/assets/imgs/img_data-complete.png" />
<p class="tips">新增成功</p> <p class="tips">新增成功</p>
<div class="apaas_button btns"> <div class="apaas_button btns">
<el-button type="default" @click="goStepOne"> 返回列表 </el-button> <el-button type="default" @click="goToList"> 返回列表 </el-button>
<el-button type="primary" @click="putawayAction"> 继续新增 </el-button> <el-button type="primary" @click="goStepOne"> 继续新增 </el-button>
</div> </div>
</div> </div>
</div> </div>
...@@ -17,8 +17,16 @@ import { useRouter, useRoute } from "vue-router"; ...@@ -17,8 +17,16 @@ import { useRouter, useRoute } from "vue-router";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const state = reactive({ data: 1 });
const { data } = toRefs(state); const emit = defineEmits(["clear"]);
const goToList = () => {
router.push("/auto-maintenance/task-manage");
};
const goStepOne = () => {
emit("clear");
};
</script> </script>
<style scoped> <style scoped>
......
...@@ -40,9 +40,9 @@ ...@@ -40,9 +40,9 @@
</div> </div>
</div> </div>
<div class="content_main log_content_nor" :style="step == 3 ? { height: 'calc(100vh - 234px)' } : {}"> <div class="content_main log_content_nor" :style="step == 3 ? { height: 'calc(100vh - 234px)' } : {}">
<base-info v-show="step == 1"></base-info> <base-info v-show="step == 1" :data="state.data" ref="baseInfoRef"></base-info>
<use-content v-show="step == 2"></use-content> <use-content v-show="step == 2" :data="state.data" ref="useContentRef"></use-content>
<finish v-show="step == 3"></finish> <finish v-show="step == 3" @clear="clearData"></finish>
</div> </div>
<div class="content_foot apaas_button" v-if="step == 1 || step == 2"> <div class="content_foot apaas_button" v-if="step == 1 || step == 2">
<el-button type="default" @click="cancel"> 取消 </el-button> <el-button type="default" @click="cancel"> 取消 </el-button>
...@@ -68,18 +68,57 @@ const router = useRouter(); ...@@ -68,18 +68,57 @@ const router = useRouter();
const route = useRoute(); const route = useRoute();
const step = ref(1); const step = ref(1);
const baseInfoRef = ref(null);
const useContentRef = ref(null);
const state = reactive({ data: 1 }); const state = reactive({
data: {},
});
const cancel = () => { const cancel = () => {
router.back(); router.back();
}; };
const confirm = (val) => { const confirm = async (val) => {
step.value = step.value + val; let flag = true;
if (val == 1) {
if (step.value == 1) {
//下一步
await baseInfoRef.value
.save()
.then()
.catch(() => {
flag = false;
});
} else if (step.value == 2) {
//保存
await useContentRef.value
.save()
.then(() => {
saveTask();
})
.catch(() => {
flag = false;
});
}
}
if (flag) {
step.value = step.value + val;
}
}; };
const saveTask = () => {};
const useScript = () => {}; const useScript = () => {};
const clearData = () => {
baseInfoRef.value.clear();
useContentRef.value.clear();
state.data = {};
step.value = 1;
};
onBeforeMount(() => {});
</script> </script>
<style scoped> <style scoped>
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
</bg-upload> </bg-upload>
</div> </div>
<bg-form-gap title="执行主机"></bg-form-gap> <bg-form-gap title="执行主机"></bg-form-gap>
<el-form ref="ruleFormRef" :model="state.ruleForm" :rules="state.rules" label-position="top" label-width="120px"> <el-form ref="pcFormRef" :model="state.ruleForm" :rules="state.rules" label-position="top" label-width="120px">
<el-form-item label="主机分组名称" prop="name" style="width: 1100px"> <el-form-item label="主机分组名称" prop="pcName" style="width: 1100px">
<el-select v-model="state.ruleForm.name" style="width: 1020px" clearable placeholder="请选择"> <el-select v-model="state.ruleForm.pcName" style="width: 1020px" clearable placeholder="请选择">
<el-option v-for="item in state.options" :key="item.value" :label="item.label" :value="item.value" /> <el-option v-for="item in state.options" :key="item.value" :label="item.label" :value="item.value" />
</el-select> </el-select>
<span class="add-pc can_click_text">去创建</span> <span class="add-pc can_click_text">去创建</span>
...@@ -26,21 +26,31 @@ ...@@ -26,21 +26,31 @@
</template> </template>
<script setup> <script setup>
import { reactive, ref, onBeforeMount, toRefs } from "vue"; import { reactive, ref, onBeforeMount, toRefs, onMounted } from "vue";
import { useRouter, useRoute } from "vue-router"; import { useRouter, useRoute } from "vue-router";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
const router = useRouter(); const router = useRouter();
const route = useRoute(); const route = useRoute();
const props = defineProps({
data: {
type: Object,
default: () => {},
},
});
const pcFormRef = ref(null);
const state = reactive({ const state = reactive({
useType: 0, useType: 0,
useData: ["文本执行", "文件执行"], useData: ["文本执行", "文件执行"],
useText: "", useText: props.data?.useText || "",
doc_file: [], doc_file: props.data?.doc_file || [],
ruleForm: { ruleForm: {
name: "", pcName: props.data?.pcName || "",
}, },
rules: { rules: {
name: [{ required: true, message: "请选择主机分组", trigger: "change" }], pcName: [{ required: true, message: "请选择主机分组", trigger: "change" }],
}, },
options: [ options: [
{ {
...@@ -49,6 +59,50 @@ const state = reactive({ ...@@ -49,6 +59,50 @@ const state = reactive({
}, },
], ],
}); });
const save = () => {
return new Promise((resolve, reject) => {
pcFormRef.value.validate((valid, fields) => {
if (valid) {
props.data.pcName = state.ruleForm.pcName;
if (state.useType == 0) {
props.data.useText = state.useText;
} else {
props.data.doc_file = state.doc_file;
}
resolve();
} else {
reject();
console.log("error submit!", fields);
}
});
});
};
const clear = () => {
pcFormRef.value.resetFields();
state.useText = "";
state.doc_file = [];
state.useType = 0;
};
onMounted(() => {
if (
(props.data && props.data.useText == "" && props.data.doc_file.length == 0) ||
(!props.data.useText && !props.data.doc_file)
) {
state.useType = 0;
} else if (props.data && props.data.useText !== "") {
state.useType = 1;
} else if (props.data && props.data.doc_file.length == 0) {
state.useType = 0;
}
});
defineExpose({
save,
clear,
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment