chengf
2026-02-10 24bfd38bb9f89042028f757e05386cdd2558fc67
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<template>
    <view>
        <!--标题和返回-->
        <cu-custom :bgColor="NavBarColor" isBack :backRouterName="backRouteName">
            <block slot="backText">返回</block>
            <block slot="content">文案生成方案</block>
        </cu-custom>
         <!--表单区域-->
        <view>
            <form>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">方案名称:</text></view>
                  <input  placeholder="请输入方案名称" v-model="model.schemeName"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">API服务器:</text></view>
                  <input  placeholder="请输入API服务器" v-model="model.workflowUrl"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">API服务器文件上传地址:</text></view>
                  <input  placeholder="请输入API服务器文件上传地址" v-model="model.fileUploadUrl"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">API 密钥:</text></view>
                  <input  placeholder="请输入API 密钥" v-model="model.authToken"/>
                </view>
              </view>
              <view class="cu-form-group">
                <view class="flex align-center">
                  <view class="title"><text space="ensp">智能体编号:</text></view>
                  <input  placeholder="请输入智能体编号" v-model="model.appId"/>
                </view>
              </view>
                <view class="padding">
                    <button class="cu-btn block bg-blue margin-tb-sm lg" @click="onSubmit">
                        <text v-if="loading" class="cuIcon-loading2 cuIconfont-spin"></text>提交
                    </button>
                </view>
            </form>
        </view>
    </view>
</template>
 
<script>
    import myDate from '@/components/my-componets/my-date.vue'
 
    export default {
        name: "CopywritingSchemeForm",
        components:{ myDate },
        props:{
          formData:{
              type:Object,
              default:()=>{},
              required:false
          }
        },
        data(){
            return {
                CustomBar: this.CustomBar,
                NavBarColor: this.NavBarColor,
                loading:false,
                model: {},
                backRouteName:'index',
                url: {
                  queryById: "/copywritingScheme/copywritingScheme/queryById",
                  add: "/copywritingScheme/copywritingScheme/add",
                  edit: "/copywritingScheme/copywritingScheme/edit",
                },
            }
        },
        created(){
             this.initFormData();
        },
        methods:{
           initFormData(){
               if(this.formData){
                    let dataId = this.formData.dataId;
                    this.$http.get(this.url.queryById,{params:{id:dataId}}).then((res)=>{
                        if(res.data.success){
                            console.log("表单数据",res);
                            this.model = res.data.result;
                        }
                    })
                }
            },
            onSubmit() {
                let myForm = {...this.model};
                this.loading = true;
                let url = myForm.id?this.url.edit:this.url.add;
                this.$http.post(url,myForm).then(res=>{
                   console.log("res",res)
                   this.loading = false
                   this.$Router.push({name:this.backRouteName})
                }).catch(()=>{
                    this.loading = false
                });
            }
        }
    }
</script>