mcwl-pc/app/pages/publish-workflow/index.vue

183 lines
7.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<n-form
ref="formRef"
:model="formData"
:rules="rules"
label-placement="left"
label-width="auto"
require-mark-placement="right-hanging"
size="large"
:style="{
maxWidth: '640px',
}"
>
<n-form-item label="工作流名称" path="inputValue">
<n-input v-model:value="formData.inputValue" placeholder="Input" />
</n-form-item>
<n-form-item label="工作流名称" path="inputValue">
<!-- <n-input v-model:value="model.inputValue" placeholder="Input" /> -->
<n-select v-model:value="formData.value" :options="cuileioptions" />
</n-form-item>
<n-form-item label="Checkbox Group" path="checkboxGroupValue">
<n-checkbox-group v-model:value="formData.checkboxGroupValue">
<n-space>
<n-checkbox value="Option 1"> Option 1 </n-checkbox>
<n-checkbox value="Option 2"> Option 2 </n-checkbox>
<n-checkbox value="Option 3"> Option 3 </n-checkbox>
</n-space>
</n-checkbox-group>
</n-form-item>
<n-form-item label="Radio Group" path="radioGroupValue">
<n-radio-group v-model:value="formData.radioGroupValue" name="radiogroup1">
<n-space>
<n-radio value="Radio 1"> Radio 1 </n-radio>
<n-radio value="Radio 2"> Radio 2 </n-radio>
<n-radio value="Radio 3"> Radio 3 </n-radio>
</n-space>
</n-radio-group>
</n-form-item>
<n-form-item label="Radio Button Group" path="radioGroupValue">
<n-radio-group v-model:value="formData.radioGroupValue" name="radiogroup2">
<n-radio-button value="Radio 1"> Radio 1 </n-radio-button>
<n-radio-button value="Radio 2"> Radio 2 </n-radio-button>
<n-radio-button value="Radio 3"> Radio 3 </n-radio-button>
</n-radio-group>
</n-form-item>
<div style="display: flex; justify-content: flex-end">
<n-button round type="primary" @click="addWorkflow"> </n-button>
</div>
</n-form>
<!-- <pre
>{{ JSON.stringify(model, null, 2) }}
</pre> -->
</template>
<script setup lang="ts">
import type { FormInst, FormItemRule } from "naive-ui";
import { useMessage } from "naive-ui";
import { defineComponent, ref } from "vue";
import { commonApi } from "@/api/common";
const formRef = ref<FormInst | null>(null);
const cuileioptions = ref([
{ label: "Option 1", value: "Option 1" },
{ label: "Option 2", value: "Option 1" },
{ label: "Option 3", value: "Option 1" },
]);
const message = useMessage();
const rules: Record<string, FormItemRule[]> = {
}
const formData = ref({
inputValue: null,
textareaValue: null,
selectValue: null,
multipleSelectValue: null,
datetimeValue: null,
nestedValue: {
path1: null,
path2: null,
},
switchValue: false,
checkboxGroupValue: null,
radioGroupValue: null,
radioButtonGroupValue: null,
inputNumberValue: null,
timePickerValue: null,
transferValue: null,
})
const addWorkflow = async() => {
try {
const params = {
workFlow:{
workflowName:'工作流名称',
category:'1', //垂类
theme:'1', //主体
style:'1', //风格
functions:'1', //功能
activityParticipation:'1', //参与活动
jurisdiction:1, //是否公开权限 1公开 2自见
original:1, //0代表原创 1代表转载
authorName:'作者名称', //原文作者名字
onlineUse:0, //是否允许在线使用0允许 1不允许
download: 1, //是否允许下载工作流0允许 1不允许
sell:1, //是否允许出售或商用(0允许 1不允许)
},
workFlowVersionList:[
{
versionName:'1.0', // 版本名称
versionDescription:'"<p>这是一个描述</p><p><img src=\"https://img1.baidu.com/it/u=3001150338,397170470&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422\" /></p><p>这是两张图片之间的一些文字说明</p><p><img src=\"https://img12.iqilu.com/10339/clue/202405/29/68ec17f5-9621-461f-ad22-a6820a3f9cf5.jpg\" /></p>"', //版本描述
filePath:'https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/JANUARY/2/19/4/877e449c-3c0d-4630-a304-91ec110499f2.png', //文件路径
fileName:'文件名称其实是个图片', //文件名称
imagePaths:'https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/JANUARY/2/19/4/877e449c-3c0d-4630-a304-91ec110499f2.png,https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/JANUARY/2/19/4/877e449c-3c0d-4630-a304-91ec110499f2.png,https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/JANUARY/2/19/4/877e449c-3c0d-4630-a304-91ec110499f2.png', //第三部的图片路径最多20张,切割
hideGenInfo:0, //是否隐藏生成信息 0隐藏 1不隐藏
},
{
versionName:'2.0', // 版本名称
versionDescription:'"<p>这是一个描述</p><p><img src=\"https://img1.baidu.com/it/u=3001150338,397170470&fm=253&fmt=auto&app=138&f=JPEG?w=800&h=1422\" /></p><p>这是两张图片之间的一些文字说明</p><p><img src=\"https://img12.iqilu.com/10339/clue/202405/29/68ec17f5-9621-461f-ad22-a6820a3f9cf5.jpg\" /></p>"', //版本描述
filePath:'https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/JANUARY/2/19/4/877e449c-3c0d-4630-a304-91ec110499f2.png', //文件路径
fileName:'文件名称其实是个图片', //文件名称
imagePaths:'https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/JANUARY/2/19/4/877e449c-3c0d-4630-a304-91ec110499f2.png,https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/JANUARY/2/19/4/877e449c-3c0d-4630-a304-91ec110499f2.png,https://ybl2112.oss-cn-beijing.aliyuncs.com/2025/JANUARY/2/19/4/877e449c-3c0d-4630-a304-91ec110499f2.png', //第三部的图片路径最多20张,切割
hideGenInfo:0, //是否隐藏生成信息 0隐藏 1不隐藏
}
]
}
const res = await request.post("/WorkFlow/addWorkFlow", params);
}catch (error) {
console.log(error);
}
}
// const handleValidateButtonClick = (e: MouseEvent) => {
// e.preventDefault();
// formRef.value?.validate((errors) => {
// if (!errors) {
// message.success("验证成功");
// } else {
// console.log(errors);
// message.error("验证失败");
// }
// });
// };
const modelPartCategory = ref([]); //垂类一级
const modelChildCategory = ref([]); //垂类一级
const workFlowFunctions = ref([]); //垂类一级
const getDictType = async() => {
// model_part_category:[], //垂类一级
// model_child_category:[], //垂类二级
// work_flow_functions:[], //功能
try {
const [res1, res2, res3, res4] = await Promise.all([
commonApi.dictType({ type: "model_part_category" }),
commonApi.dictType({ type: "model_child_category" }),
commonApi.dictType({ type: "work_flow_functions" }),
commonApi.dictType({ type: "work_flow_style" }), //风格
]);
modelPartCategory.value = res1.data;
modelChildCategory.value = res2.data;
workFlowFunctions.value = res3.data;
let categoryList = modelPartCategory;
// 遍历第一个数据数组,检查是否有子项
categoryList.value.forEach((item) => {
// 给每个对象添加一个children属性初始化为空数组
item.children = [];
// 遍历第二个数据数组
modelChildCategory.value.forEach((child) => {
// 检查parentId是否与dictValue相等
if (child.partId === item.dictCode) {
// 将符合条件的子项放入children数组中
item.children.push(child);
}
});
});
categoryList = categoryList;
} catch (error) {
console.log(error);
}
};
getDictType()
</script>