|
|
@@ -14,13 +14,11 @@
|
|
|
ref="fileUploader"
|
|
|
accept=".json,.yaml,.yml,.zip"
|
|
|
:multiple="false"
|
|
|
+ :limit="1"
|
|
|
:auto-upload="true"
|
|
|
:drag="true"
|
|
|
v-model="files"
|
|
|
tip="请上传JSON、YAML、ZIP格式的文件,最大10MB"
|
|
|
- @success="handleUploadSuccess"
|
|
|
- @error="handleUploadError"
|
|
|
- @progress="handleUploadProgress"
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -30,11 +28,43 @@
|
|
|
<div class="font_size20 bold">基本信息</div>
|
|
|
</div>
|
|
|
<div class="mt10">
|
|
|
- <el-form-item label="工作流标题" prop="name">
|
|
|
- <el-input v-model="ruleForm.name" placeholder="请输入工作流标题" maxlength="50"/>
|
|
|
+ <el-form-item label="工作流标题" prop="workflowTitle">
|
|
|
+ <el-input v-model="ruleForm.workflowTitle" placeholder="请输入工作流标题" maxlength="50"/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="工作流类型" prop="name">
|
|
|
- <el-input v-model="ruleForm.name" placeholder="请输入工作流标题" maxlength="50" />
|
|
|
+ <el-form-item label="工作流类型" prop="categoryId3">
|
|
|
+ <el-cascader
|
|
|
+ v-model="categoryIdList"
|
|
|
+ :options="categoryListTree"
|
|
|
+ placeholder="请选择工作流类型"
|
|
|
+ style="width:100%"
|
|
|
+ :props="{
|
|
|
+ label: 'categoryName',
|
|
|
+ value: 'categoryId',
|
|
|
+ children: 'children',
|
|
|
+ }"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="工作流描述" prop="description">
|
|
|
+ <el-input type="textarea" v-model="ruleForm.description" placeholder="请输入工作流描述" maxlength="500" show-word-limit/>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="封面图" prop="coverImage">
|
|
|
+ <div>支持批量上传文件,文件格式不限,最多只能上传 5 份文件</div>
|
|
|
+ <!-- 图片类型 -->
|
|
|
+ <FileUploader
|
|
|
+ ref="fileUploader"
|
|
|
+ accept="image/*"
|
|
|
+ :multiple="false"
|
|
|
+ :limit="1"
|
|
|
+ :auto-upload="true"
|
|
|
+ list-type="picture-card"
|
|
|
+ :data="{ directory: 'workflow' }"
|
|
|
+ buttonText=""
|
|
|
+ v-model="coverImage"
|
|
|
+ tip=""
|
|
|
+ @success="handleUploadSuccess"
|
|
|
+ @error="handleUploadError"
|
|
|
+ @progress="handleUploadProgress"
|
|
|
+ />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="工作流预览">
|
|
|
<div>支持批量上传文件,文件格式不限,最多只能上传 5 份文件</div>
|
|
|
@@ -42,7 +72,6 @@
|
|
|
<FileUploader
|
|
|
ref="fileUploader"
|
|
|
accept="image/*"
|
|
|
- :max-size="100"
|
|
|
:multiple="true"
|
|
|
:auto-upload="true"
|
|
|
list-type="picture-card"
|
|
|
@@ -55,7 +84,7 @@
|
|
|
@progress="handleUploadProgress"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="详情">
|
|
|
+ <el-form-item label="详情" prop="workflowContent">
|
|
|
<BlockNoteEditor v-model="editorContent" :editable="true"/>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
@@ -68,16 +97,18 @@
|
|
|
|
|
|
<el-form-item label="付费设置" style="width: 500px">
|
|
|
<div class="gap20 mt10 mb20">
|
|
|
- <div class="payType active gap10">
|
|
|
+ <div class="payType gap10" @click="workflowPriceType = 'pay'"
|
|
|
+ :class="{'active': workflowPriceType === 'pay'}">
|
|
|
<div class="checkType"></div>
|
|
|
<div>付费(用户需付费后使用)</div>
|
|
|
</div>
|
|
|
- <div class="payType gap10">
|
|
|
+ <div class="payType gap10" @click="workflowPriceType = 'free';ruleForm.workflowPrice=''"
|
|
|
+ :class="{'active': workflowPriceType === 'free'}">
|
|
|
<div class="checkType"></div>
|
|
|
- <div>付费(用户需付费后使用)</div>
|
|
|
+ <div>免费(所有用户可免费数据)</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <el-input v-model="ruleForm.name" placeholder="请输入暴米币数量" maxlength="50" type="number">
|
|
|
+ <el-input v-model="ruleForm.workflowPrice" placeholder="请输入暴米币数量" maxlength="50" type="number" v-if="workflowPriceType === 'pay'">
|
|
|
<template #append>暴米币</template>
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
@@ -97,7 +128,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, onMounted, reactive } from 'vue'
|
|
|
+import { ref, onMounted, reactive, watchEffect } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import FileUploader from '@/components/FileUploader.vue'
|
|
|
import DGTMessage from '@/utils/message'
|
|
|
@@ -105,77 +136,104 @@ import BlockNoteEditor from '@/components/BlockNoteEditor.vue';
|
|
|
const route = useRoute()
|
|
|
const router = useRouter()
|
|
|
|
|
|
-
|
|
|
+import { getCategoryListTree } from '@/api/category.js'
|
|
|
+import { publishAdd } from '@/api/publish.js'
|
|
|
|
|
|
// 从路由参数中获取 activePlatform
|
|
|
const activePlatform = ref(route.query.activePlatform || '');
|
|
|
|
|
|
-// 上传文件列表
|
|
|
-const uploadedFiles = ref([])
|
|
|
-// 图片列表
|
|
|
-const images = ref(
|
|
|
- [
|
|
|
- {
|
|
|
- url:"http://jcxxpt.oss-cn-beijing.aliyuncs.com/id_card/2025/12/26/MFE1Qdqi9tXdc0cb704ec71877b97f0f0bde3a1bbb72_20251226111105A001.jpg"
|
|
|
- }
|
|
|
- ]
|
|
|
-)
|
|
|
-const files = ref(
|
|
|
- [
|
|
|
- {
|
|
|
- url:"http://jcxxpt.oss-cn-beijing.aliyuncs.com/common/2025/12/26/Iwk7y3ArgL5Of52f7c2309b56d382f14540de00dd6ea_20251226111356A002.zip"
|
|
|
- }
|
|
|
- ]
|
|
|
-)
|
|
|
-
|
|
|
-// const uploadUrl = ref('/api/upload') // 实际项目中替换为真实的上传接口地址
|
|
|
-
|
|
|
-const editorContent = ref(
|
|
|
- [
|
|
|
- {
|
|
|
- type: "paragraph",
|
|
|
- content: [{ type: "text", text: "只读模式" }]
|
|
|
- },
|
|
|
- // {
|
|
|
- // "id": "378ce968-02c2-4856-888b-c35a355aa84b",
|
|
|
- // "type": "codeBlock",
|
|
|
- // "props": {
|
|
|
- // "language": "text"
|
|
|
- // },
|
|
|
- // "content": [],
|
|
|
- // "children": []
|
|
|
- // }
|
|
|
- ]
|
|
|
-);
|
|
|
+// 图片
|
|
|
+const images = ref([]);
|
|
|
+const coverImage = ref([]);
|
|
|
+//附件
|
|
|
+const files = ref([]);
|
|
|
+// 分类列表树
|
|
|
+const categoryListTree = ref([]);
|
|
|
+// 选择的分类id列表
|
|
|
+const categoryIdList = ref([])
|
|
|
+// 编辑器内容
|
|
|
+const editorContent = ref(null);
|
|
|
+const workflowPriceType = ref('pay'); // 价格类型,默认免费
|
|
|
// 表单实例
|
|
|
const ruleFormRef = ref(null)
|
|
|
const ruleForm = reactive({
|
|
|
- name: '',
|
|
|
- uploadedFiles: []
|
|
|
+ workflowTitle: '',
|
|
|
+ categoryId1: '',
|
|
|
+ categoryId2: '',
|
|
|
+ categoryId3: '',
|
|
|
+ workflowFile: '',
|
|
|
+ workflowPrice: '',
|
|
|
+ description: '',
|
|
|
+ previewImage: '',
|
|
|
+ coverImage: '',
|
|
|
+ workflowContent: '',
|
|
|
+})
|
|
|
+watchEffect(() => {
|
|
|
+ // 将选择的分类id列表赋值给表单的categoryId1、categoryId2、categoryId3
|
|
|
+ ruleForm.categoryId1 = categoryIdList.value[0] || ''
|
|
|
+ ruleForm.categoryId2 = categoryIdList.value[1] || ''
|
|
|
+ ruleForm.categoryId3 = categoryIdList.value[2] || ''
|
|
|
+ // 将编辑器内容赋值给表单的workflowContent
|
|
|
+ ruleForm.workflowContent = JSON.stringify(editorContent.value);
|
|
|
+ ruleForm.coverImage = coverImage.value.map(img => img.url).join(',');;
|
|
|
+
|
|
|
})
|
|
|
// 校验规则
|
|
|
const rules = reactive({
|
|
|
- name: [
|
|
|
+ workflowTitle: [
|
|
|
{ required: true, message: '请输入工作流标题', trigger: 'blur' },
|
|
|
],
|
|
|
+ categoryId3: [
|
|
|
+ { required: true, message: '请输入工作流标题', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ description: [
|
|
|
+ { required: true, message: '请输入工作流描述', trigger: 'blur' },
|
|
|
+ ],
|
|
|
+ coverImage: [
|
|
|
+ { required: true, message: '请上传封面图', trigger: 'change' },
|
|
|
+ ],
|
|
|
+ workflowContent: [
|
|
|
+ { required: true, message: '请输入工作流详情内容', trigger: 'change' },
|
|
|
+ ],
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
+ getCategoryListTreeFn();
|
|
|
});
|
|
|
|
|
|
// 提交表单
|
|
|
const submitForm = async () => {
|
|
|
- console.log('提交表单', ruleForm,images.value)
|
|
|
- return;
|
|
|
+ ruleForm.workflowFile = files.value[0]?.url || '';
|
|
|
+ ruleForm.previewImage = images.value.map(img => img.url).join(',');
|
|
|
+
|
|
|
+ if(!editorContent.value || editorContent.value.length === 0){
|
|
|
+ DGTMessage.warning('请输入工作流详情内容')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if(workflowPriceType.value === 'pay'){
|
|
|
+ if(!ruleForm.workflowPrice){
|
|
|
+ DGTMessage.warning('请输入暴米币数量')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('工作流详情内容',ruleForm)
|
|
|
await ruleFormRef.value.validate((valid, fields) => {
|
|
|
console.log(valid, fields)
|
|
|
if (!valid) {
|
|
|
DGTMessage.warning(fields.name[0].message)
|
|
|
return
|
|
|
}
|
|
|
- DGTMessage.success('表单提交成功')
|
|
|
+ publishAdd(ruleForm).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ if(res.code === 200){
|
|
|
+ DGTMessage.success('提交成功')
|
|
|
+ setTimeout(() => {
|
|
|
+ goBack();
|
|
|
+ }, 2000);
|
|
|
+ }
|
|
|
+ })
|
|
|
})
|
|
|
}
|
|
|
|
|
|
@@ -198,7 +256,14 @@ const handleUploadProgress = (event, file, uploadedFiles) => {
|
|
|
|
|
|
const goBack = () => {
|
|
|
router.back()
|
|
|
-}
|
|
|
+};
|
|
|
+
|
|
|
+const getCategoryListTreeFn = () => {
|
|
|
+ getCategoryListTree().then(res => {
|
|
|
+ console.log(res)
|
|
|
+ categoryListTree.value = res.rows || [];
|
|
|
+ })
|
|
|
+};
|
|
|
</script>
|
|
|
<style lang="scss">
|
|
|
.workflow-add{
|