Blame view

src/components/admin/AddAdvert.vue 7.23 KB
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
1
  <template>
5c5dc3cd   wuxw   开发完成营销广告功能
2
3
4
5
6
7
8
9
10
11
12
13
14
    <el-dialog :title="$t('advertManage.add.title')" :visible.sync="visible" width="50%" @close="handleClose">
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-form-item :label="$t('advertManage.add.adName')" prop="adName">
          <el-input v-model="form.adName" :placeholder="$t('advertManage.add.adNamePlaceholder')" />
        </el-form-item>
  
        <el-form-item :label="$t('advertManage.add.classify')" prop="classify">
          <el-select v-model="form.classify" :placeholder="$t('advertManage.add.classifyPlaceholder')" style="width: 100%;">
            <el-option v-for="item in classifyOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('advertManage.add.locationTypeCd')" prop="locationTypeCd">
70492aa4   wuxw   通知发送
15
16
          <el-select v-model="form.locationTypeCd" :placeholder="$t('advertManage.add.locationPlaceholder')"
            style="width: 100%;">
5c5dc3cd   wuxw   开发完成营销广告功能
17
18
19
20
21
            <el-option v-for="item in locationOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('advertManage.add.advertType')" prop="advertType">
70492aa4   wuxw   通知发送
22
23
          <el-select v-model="form.advertType" :placeholder="$t('advertManage.add.advertTypePlaceholder')"
            style="width: 100%;">
5c5dc3cd   wuxw   开发完成营销广告功能
24
25
26
27
28
            <el-option v-for="item in advertTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
  
        <el-form-item :label="$t('advertManage.add.pageUrl')">
70492aa4   wuxw   通知发送
29
          <el-input v-model="form.pageUrl" :placeholder="$t('advertManage.add.pageUrlPlaceholder')" style="width: 100%;" />
5c5dc3cd   wuxw   开发完成营销广告功能
30
31
32
        </el-form-item>
  
        <el-form-item :label="$t('advertManage.add.seq')" prop="seq">
70492aa4   wuxw   通知发送
33
          <el-input v-model="form.seq" :placeholder="$t('advertManage.add.seqPlaceholder')" style="width: 100%;" />
5c5dc3cd   wuxw   开发完成营销广告功能
34
35
36
        </el-form-item>
  
        <el-form-item :label="$t('advertManage.add.startTime')" prop="startTime">
b25b036d   wuxw   v1.9 优化日期
37
          <el-date-picker v-model="form.startTime" type="datetime" value-format="yyyy-MM-dd HH:mm:ss"          :placeholder="$t('advertManage.add.startTimePlaceholder')" 
70492aa4   wuxw   通知发送
38
            style="width: 100%;" />
5c5dc3cd   wuxw   开发完成营销广告功能
39
40
41
        </el-form-item>
  
        <el-form-item :label="$t('advertManage.add.endTime')" prop="endTime">
b25b036d   wuxw   v1.9 优化日期
42
          <el-date-picker v-model="form.endTime" type="datetime" :placeholder="$t('advertManage.add.endTimePlaceholder')" value-format="yyyy-MM-dd HH:mm:ss"          style="width: 100%;"  />
5c5dc3cd   wuxw   开发完成营销广告功能
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
        </el-form-item>
  
        <el-form-item :label="$t('advertManage.add.viewType')" prop="viewType">
          <el-select v-model="form.viewType" :placeholder="$t('advertManage.add.viewTypePlaceholder')" style="width: 100%;">
            <el-option v-for="item in viewTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
          </el-select>
        </el-form-item>
  
        <el-form-item v-if="form.viewType === '8888'" :label="$t('advertManage.add.image')">
          <upload-image-url ref="uploadImage" :limit="1" @notifyUploadCoverImage="handleImageChange" />
        </el-form-item>
  
        <div class="dialog-footer">
          <el-button @click="visible = false">{{ $t('common.cancel') }}</el-button>
          <el-button type="primary" @click="handleSubmit">{{ $t('common.confirm') }}</el-button>
        </div>
      </el-form>
    </el-dialog>
  </template>
  
  <script>
  import { saveAdvert } from '@/api/admin/advertManageApi'
  import UploadImageUrl from '@/components/upload/UploadImageUrl'
  
  export default {
    name: 'AddAdvert',
    components: {
      UploadImageUrl
    },
    data() {
      return {
        visible: false,
        form: {
          adName: '',
          classify: '',
          locationTypeCd: '',
          advertType: '',
          pageUrl: '',
          seq: '',
          startTime: '',
          endTime: '',
          viewType: '8888',
          adTypeCd: '20000',
          locationObjId: '-1',
70492aa4   wuxw   通知发送
87
          vedioName: '',
5c5dc3cd   wuxw   开发完成营销广告功能
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
          photos: []
        },
        rules: {
          adName: [
            { required: true, message: this.$t('advertManage.validate.adNameRequired'), trigger: 'blur' }
          ],
          classify: [
            { required: true, message: this.$t('advertManage.validate.classifyRequired'), trigger: 'change' }
          ],
          locationTypeCd: [
            { required: true, message: this.$t('advertManage.validate.locationRequired'), trigger: 'change' }
          ],
          advertType: [
            { required: true, message: this.$t('advertManage.validate.advertTypeRequired'), trigger: 'change' }
          ],
          seq: [
            { required: true, message: this.$t('advertManage.validate.seqRequired'), trigger: 'blur' },
            { pattern: /^\d+$/, message: this.$t('advertManage.validate.seqNumber'), trigger: 'blur' }
          ],
          startTime: [
            { required: true, message: this.$t('advertManage.validate.startTimeRequired'), trigger: 'change' }
          ],
          endTime: [
            { required: true, message: this.$t('advertManage.validate.endTimeRequired'), trigger: 'change' }
          ],
          viewType: [
            { required: true, message: this.$t('advertManage.validate.viewTypeRequired'), trigger: 'change' }
          ]
        },
        classifyOptions: [
          { value: '9001', label: this.$t('advertManage.classify.logistics') },
          { value: '9002', label: this.$t('advertManage.classify.catering') },
          { value: '9003', label: this.$t('advertManage.classify.travel') },
          { value: '9004', label: this.$t('advertManage.classify.hotel') },
          { value: '9005', label: this.$t('advertManage.classify.education') },
          { value: '9006', label: this.$t('advertManage.classify.internet') }
        ],
        locationOptions: [
          { value: '1000', label: this.$t('advertManage.location.device') },
          { value: '2000', label: this.$t('advertManage.location.ownerHome') },
          { value: '3000', label: this.$t('advertManage.location.businessHome') },
          { value: '5000', label: this.$t('advertManage.location.serviceHome') },
          { value: '6000', label: this.$t('advertManage.location.convenienceHome') },
          { value: '4000', label: this.$t('advertManage.location.staffHome') }
        ],
        advertTypeOptions: [
          { value: '1', label: this.$t('advertManage.advertType.site') },
          { value: '2', label: this.$t('advertManage.advertType.outside') },
          { value: '3', label: this.$t('advertManage.advertType.noJump') }
        ],
        viewTypeOptions: [
          { value: '8888', label: this.$t('advertManage.add.image') }
        ]
      }
    },
    methods: {
      open() {
        this.visible = true
        this.resetForm()
      },
      resetForm() {
        this.$refs.form && this.$refs.form.resetFields()
b9a05476   wuxw   优化代码
150
        this.$refs.uploadImage && this.$refs.uploadImage.clearImages()
5c5dc3cd   wuxw   开发完成营销广告功能
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
      },
      handleClose() {
        this.resetForm()
      },
      handleImageChange(images) {
        if (images && images.length > 0) {
          this.form.photos = images
        } else {
          this.form.photos = []
        }
      },
      async handleSubmit() {
        try {
          await this.$refs.form.validate()
  
          const params = {
            ...this.form,
            photos: this.form.photos
          }
  
          await saveAdvert(params)
6ec243d6   wuxw   v1.9 点击提交后,成功提示没有...
172
          this.$message.success(this.$t('common.operationSuccess'))
5c5dc3cd   wuxw   开发完成营销广告功能
173
174
175
176
177
178
179
180
181
          this.$emit('success')
          this.visible = false
        } catch (error) {
          console.error(error)
        }
      }
    }
  }
  </script>