fuliqi
2024-05-29 fe91cc994c78b15bbc4e974e4d7c0eb1177a7a10
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
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
<template>
  <div class="c">
    <div class="bg">
      <div class="main">
        <!-- 带返回的标题 -->
        <TitleIndex title="发布公告" />
        <!-- 内容 -->
        <div class="content">
          <el-form
            :model="ruleForm"
            :rules="rules"
            ref="ruleForm"
            label-width="100px"
            class="demo-ruleForm"
          >
            <el-form-item
              label="标题"
              prop="name"
            >
              <el-input
                v-model="ruleForm.name"
                placeholder="请给公告起一个标题"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="发布人"
              prop="publisher"
            >
              <el-input
                v-model="ruleForm.publisher"
                placeholder="请输入发布人"
              ></el-input>
            </el-form-item>
            <el-form-item
              label="发布人"
              prop="publisher"
            >
              <el-select
                v-model="value"
                placeholder="请选择"
                class="el-input"
              >
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                >
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item
              label="活动形式"
              prop="desc"
            >
              <rich-text />
            </el-form-item>
 
            <el-form-item
              label="封面以及摘要"
              prop="publisher"
            >
              <el-row :gutter="24">
 
                <el-col
                  :span="6"
                  style="padding-left:0"
                >
                  <single-upload
                    :success-call-back="getCategoryImg"
                    upload-action="https://jsonplaceholder.typicode.com/posts/"
                  />
                </el-col>
                <el-col :span="13">
                  <el-input
                    type="textarea"
                    v-model="ruleForm.desc"
                    :rows="9"
                    placeholder="选填,摘要会在消息文章外的场景线路,帮助读者快速了解内容,如不填写则默认抓取正文前64字"
                  ></el-input>
                </el-col>
              </el-row>
 
            </el-form-item>
            <el-form-item style="margin-left: 100px;display: flex;">
              <el-button
                type="primary"
                style="min-width:120px;min-height: 50px;"
                class="btn-style"
                @click="submitForm('ruleForm')"
              >立即创建</el-button>
              <el-button
                @click="resetForm('ruleForm')"
                size="medium"
                style="min-width:120px;min-height: 50px;"
              >保存为草稿</el-button>
              <el-button
                @click="resetForm('ruleForm')"
                style="min-width:120px;min-height: 50px;"
              >预览</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>
 
    </div>
 
  </div>
 
</template>
 
 
<script>
// 引入富文本
import RichText from "../../../components/editor/RichText.vue";
// 引入封面上传
import SingleUpload from "@/components/upload/SingleUpload.vue";
export default {
  components: {
    RichText,
    SingleUpload,
  },
  data() {
    return {
      //图片上传
      imageUrl: "",
      dialogImageUrl: "",
      dialogVisible: false,
      disabled: false,
      options: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
      value: "",
      ruleForm: {
        name: "",
        publisher: "",
        desc: "",
      },
      rules: {
        name: [{ required: true, message: "标题不能为空", trigger: "blur" }],
        desc: [{ required: true, message: "请填写活动形式", trigger: "blur" }],
      },
    };
  },
  methods: {
    // handleAvatarSuccess(res, file) {
    //   this.imageUrl = URL.createObjectURL(file.raw);
    // },
    // beforeAvatarUpload(file) {
    //   const isJPG = file.type === "image/jpeg";
    //   const isLt2M = file.size / 1024 / 1024 < 2;
    //   console.log(isJPG, isLt2M, "Lt2M");
    //   if (!isJPG) {
    //     this.$message.error("上传头像图片只能是 JPG 格式!");
    //   }
    //   if (!isLt2M) {
    //     this.$message.error("上传头像图片大小不能超过 2MB!");
    //   }
    //   return isJPG && isLt2M;
    // },
 
    // 图片上传
    getCategoryImg(data) {
      console.log(data, "Img");
    },
 
    // 立刻创建
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          console.log(this.ruleForm);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    // 返回上一个页面
    goBack() {
      this.$router.back();
    },
    //提交按钮
    onSubmit() {
      console.log("submit!");
    },
  },
};
</script>
 
<style scoped lang="scss">
.flex {
  display: flex;
}
// 内容
.content {
  width: 1262px;
  margin-bottom: 80px;
  background-color: #fff;
  padding: 40px 140px;
  border-radius: 10px;
  //   设置应记的样式
  .font-style {
    font-weight: bold;
    font-size: 18px;
    & > span {
      color: #777777;
      font-size: 14px;
      margin-left: 10px;
    }
  }
  //   设置每个右边的span
  .span-right-style {
    margin-left: 10px;
  }
}
 
.el-input {
  width: 360px;
}
 
// 上传样式
// .avatar-uploader .el-upload {
//   border-radius: 6px;
//   cursor: pointer;
//   position: relative;
//   overflow: hidden;
// }
// .avatar-uploader .el-upload:hover {
//   border-color: #409eff;
// }
// .avatar-uploader-icon {
//   font-size: 28px;
//   color: #8c939d;
//   width: 178px;
//   height: 178px;
//   line-height: 178px;
//   text-align: center;
// }
// .avatar {
//   width: 178px;
//   height: 178px;
//   display: block;
// }
</style>