|
@@ -50,7 +50,6 @@
|
|
|
<el-input type="textarea" v-model="ruleForm.description" placeholder="请输入工作流描述" maxlength="500" show-word-limit/>
|
|
<el-input type="textarea" v-model="ruleForm.description" placeholder="请输入工作流描述" maxlength="500" show-word-limit/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
<el-form-item label="封面图" prop="coverImage">
|
|
<el-form-item label="封面图" prop="coverImage">
|
|
|
- <div>支持批量上传文件,文件格式不限,最多只能上传 5 份文件</div>
|
|
|
|
|
<!-- 图片类型 -->
|
|
<!-- 图片类型 -->
|
|
|
<FileUploader
|
|
<FileUploader
|
|
|
ref="fileUploader"
|
|
ref="fileUploader"
|
|
@@ -75,6 +74,7 @@
|
|
|
ref="fileUploader"
|
|
ref="fileUploader"
|
|
|
accept="image/*"
|
|
accept="image/*"
|
|
|
:multiple="true"
|
|
:multiple="true"
|
|
|
|
|
+ :limit="5"
|
|
|
:auto-upload="true"
|
|
:auto-upload="true"
|
|
|
list-type="picture-card"
|
|
list-type="picture-card"
|
|
|
:data="{ directory: 'workflow' }"
|
|
:data="{ directory: 'workflow' }"
|
|
@@ -130,7 +130,7 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
|
-import { ref, onMounted, reactive, watchEffect } from 'vue'
|
|
|
|
|
|
|
+import { ref, onMounted, reactive, watchEffect, nextTick } from 'vue'
|
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
import { useRoute, useRouter } from 'vue-router'
|
|
|
import FileUploader from '@/components/FileUploader.vue'
|
|
import FileUploader from '@/components/FileUploader.vue'
|
|
|
import DGTMessage from '@/utils/message'
|
|
import DGTMessage from '@/utils/message'
|
|
@@ -139,13 +139,15 @@ const route = useRoute()
|
|
|
const router = useRouter()
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
import { getCategoryListTree } from '@/api/category.js'
|
|
import { getCategoryListTree } from '@/api/category.js'
|
|
|
-import { publishAdd } from '@/api/publish.js'
|
|
|
|
|
|
|
+import { publishAdd, getPublishDetail,publishEdit } from '@/api/publish.js'
|
|
|
|
|
|
|
|
- import { useI18n } from 'vue-i18n'
|
|
|
|
|
- const { t } = useI18n()
|
|
|
|
|
|
|
+import { useI18n } from 'vue-i18n'
|
|
|
|
|
+const { t } = useI18n()
|
|
|
|
|
|
|
|
// 从路由参数中获取 activePlatform
|
|
// 从路由参数中获取 activePlatform
|
|
|
const activePlatform = ref(route.query.activePlatform || '');
|
|
const activePlatform = ref(route.query.activePlatform || '');
|
|
|
|
|
+// 从路由参数中获取 publishId
|
|
|
|
|
+const publishId = ref(route.query.id || '');
|
|
|
|
|
|
|
|
// 图片
|
|
// 图片
|
|
|
const images = ref([]);
|
|
const images = ref([]);
|
|
@@ -162,6 +164,7 @@ const workflowPriceType = ref('pay'); // 价格类型,默认免费
|
|
|
// 表单实例
|
|
// 表单实例
|
|
|
const ruleFormRef = ref(null)
|
|
const ruleFormRef = ref(null)
|
|
|
const ruleForm = reactive({
|
|
const ruleForm = reactive({
|
|
|
|
|
+ publishId: '',
|
|
|
workflowTitle: '',
|
|
workflowTitle: '',
|
|
|
categoryId1: '',
|
|
categoryId1: '',
|
|
|
categoryId2: '',
|
|
categoryId2: '',
|
|
@@ -194,7 +197,7 @@ const rules = reactive({
|
|
|
{ required: true, message: '请输入工作流标题', trigger: 'blur' },
|
|
{ required: true, message: '请输入工作流标题', trigger: 'blur' },
|
|
|
],
|
|
],
|
|
|
categoryId3: [
|
|
categoryId3: [
|
|
|
- { required: true, message: '请输入工作流标题', trigger: 'blur' },
|
|
|
|
|
|
|
+ { required: true, message: '请输入工作流类型', trigger: 'blur' },
|
|
|
],
|
|
],
|
|
|
description: [
|
|
description: [
|
|
|
{ required: true, message: '请输入工作流描述', trigger: 'blur' },
|
|
{ required: true, message: '请输入工作流描述', trigger: 'blur' },
|
|
@@ -211,6 +214,9 @@ const rules = reactive({
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
|
getCategoryListTreeFn();
|
|
getCategoryListTreeFn();
|
|
|
|
|
+ if(publishId.value){
|
|
|
|
|
+ getDetail();
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
// 提交表单
|
|
// 提交表单
|
|
@@ -240,7 +246,11 @@ const submitForm = async () => {
|
|
|
DGTMessage.warning(fields[firstKey][0].message)
|
|
DGTMessage.warning(fields[firstKey][0].message)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- publishAdd(ruleForm).then(res => {
|
|
|
|
|
|
|
+ let req = publishAdd;
|
|
|
|
|
+ if(publishId.value){
|
|
|
|
|
+ req = publishEdit;
|
|
|
|
|
+ }
|
|
|
|
|
+ req(ruleForm).then(res => {
|
|
|
console.log(res)
|
|
console.log(res)
|
|
|
if(res.code === 200){
|
|
if(res.code === 200){
|
|
|
DGTMessage.success(t('workflowTrade.publishSuccess'))
|
|
DGTMessage.success(t('workflowTrade.publishSuccess'))
|
|
@@ -279,6 +289,35 @@ const getCategoryListTreeFn = () => {
|
|
|
categoryListTree.value = res.rows || [];
|
|
categoryListTree.value = res.rows || [];
|
|
|
})
|
|
})
|
|
|
};
|
|
};
|
|
|
|
|
+const getDetail = () => {
|
|
|
|
|
+ getPublishDetail({id:publishId.value}).then(res => {
|
|
|
|
|
+ const detail = res.data || {};
|
|
|
|
|
+ for(let key in ruleForm){
|
|
|
|
|
+ ruleForm[key] = detail[key];
|
|
|
|
|
+ }
|
|
|
|
|
+ nextTick(() => {
|
|
|
|
|
+ if(ruleForm.workflowFile){
|
|
|
|
|
+ files.value = [{url: ruleForm.workflowFile}];
|
|
|
|
|
+ };
|
|
|
|
|
+ if(ruleForm.coverImage){
|
|
|
|
|
+ coverImage.value = ruleForm.coverImage.split(',').map(item => ({url: item}));
|
|
|
|
|
+ };
|
|
|
|
|
+ if(ruleForm.previewImage){
|
|
|
|
|
+ images.value = ruleForm.previewImage.split(',').map(item => ({url: item}));
|
|
|
|
|
+ };
|
|
|
|
|
+ if(ruleForm.categoryId1){
|
|
|
|
|
+ categoryIdList.value = [ruleForm.categoryId1, ruleForm.categoryId2, ruleForm.categoryId3];
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ setTimeout(() => {
|
|
|
|
|
+ if(detail.workflowContent){
|
|
|
|
|
+ editorContent.value = JSON.parse(detail.workflowContent);
|
|
|
|
|
+ }
|
|
|
|
|
+ console.log('editorContent.value',editorContent.value,ruleForm)
|
|
|
|
|
+ }, 500);
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+};
|
|
|
</script>
|
|
</script>
|
|
|
<style lang="scss">
|
|
<style lang="scss">
|
|
|
.workflow-add{
|
|
.workflow-add{
|