hejianhao
2025-04-16 dab2d210ca06c1faa514c6388fbd5de1ab355360
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
<template>
  <div class="act_add">
    <v-header :title="(info_id ? '编辑' : '新增') + '项目宣传'"></v-header>
    <el-form
      :model="form"
      :rules="rules"
      label-position="right"
      ref="form"
      label-width="100px"
    >
      <div class="fl-fw">
        <el-form-item label="宣传标题:" prop="title">
          <el-input
            class="input-width"
            placeholder="请输入宣传标题"
            size="small"
            v-model.trim="form.title"
          ></el-input>
        </el-form-item>
      </div>
      <el-form-item label="责任方:">
        <el-select
          class="input-width"
          filterable
          v-model="form.responsibility"
          clearable
          placeholder="请选择责任方"
          @change="responsibilityChange"
        >
          <el-option-group
            v-for="group in responsibilityList"
            :key="group.label"
            :label="group.label"
          >
            <el-option
              v-for="item in group.options"
              :key="item.name"
              :label="item.name"
              :value="item.name"
            >
            </el-option>
          </el-option-group>
        </el-select>
      </el-form-item>
      <!-- <div class="fl-fw">
      <el-form-item label="广告设置:">
        <el-checkbox v-model="checked" @change="isTopChange">首页顶部</el-checkbox>
      </el-form-item>
      </div> -->
      <div class="fl-fw">
        <el-form-item label="宣传封面" prop="image">
          <div class="upImage input-width">
            <div class="sec">
              <div v-if="form.image !== ''" class="image-box">
                <img
                  @click="clear"
                  class="clear"
                  src="/static/image/clear.png"
                  alt=""
                />
                <img :src="form.image" alt="" />
              </div>
              <div style="margin: 5px" class="avatar" v-else>
                <vUpload
                  :showImg="true"
                  :boxWidth="800"
                  :boxHeight="400"
                  :width="200"
                  :height="200"
                  @path="onUpload1($event)"
                ></vUpload>
              </div>
            </div>
          </div>
        </el-form-item>
      </div>
      <el-form-item label="内容详情:">
        <div style="width: 90%">
          <editor-bar v-model="form.content" @change="change"></editor-bar>
        </div>
      </el-form-item>
      <div class="fl-fw">
        <el-form-item>
          <el-checkbox v-model="checked" @change="isTopChange"
            >设为置顶</el-checkbox
          >
        </el-form-item>
      </div>
      <el-form-item label="">
        <el-button size="small" type="primary" @click="submitHandle('form')"
          >立即发布</el-button
        >
        <el-button size="small" @click="$router.go(-1)">返回</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
 
<script>
import EditorBar from "com/wangEnduit/index";
import vUpload from "com/upload/upload1";
export default {
  components: {
    EditorBar,
    vUpload,
  },
  data() {
    return {
      btnLoading: false,
      info_id: "",
      checked: false,
      form: {
        id: "",
        title: "",
        content: "",
        isTop: "",
        image: "",
        projectId: "", //项目id
        views: "",
        responsibility: "",
        responsibilityId: "",
        // status:'1', //1 初创项目
        // level:"" ,//项目等级
      },
      rules: {
        title: [
          {
            required: true,
            message: "请输入宣传标题",
            trigger: "blur",
          },
        ],
      },
      // responsibilityList: [
      //   {
      //     value: 1,
      //     label: "公共文化服务项目",
      //   },
      //   {
      //     value: 2,
      //     label: "社会组织参与型项目",
      //   },
      //   {
      //     value: 3,
      //     label: "社会企业带动型项目",
      //   },
      //   {
      //     value: 4,
      //     label: "其他项目",
      //   },
      // ],
      responsibilityList: [],
      typeList: [],
      type2List: [],
      loading: false,
      Authorization: "",
      info_id: "",
      userType: "",
    };
  },
  mounted() {
    this.Authorization = "Bearer " + demo.$session.get("token") || "";
    this.form.projectId = this.$route.query.id;
    this.userType = demo.$session.get("user").userType;
    this.getSelectList();
    //判断有项目Id 获取详情编辑页面回显
    if (this.$route.query.id && this.$route.query.isedit) {
      this.info_id = this.$route.query.id;
      this.getDetails();
    }
  },
  methods: {
    responsibilityChange(val) {
      this.responsibilityList.forEach((item) => {
        item.options.forEach((it) => {
          if (it.name === val && item.label === "街道") {
            this.form.responsibilityId = it.streetId;
          }
          if (it.name === val && item.label === "社区") {
            this.form.responsibilityId = it.communityId;
          }
          if (it.name === val && item.label === "社会组织") {
            this.form.responsibilityId = it.id;
          }
        });
      });
    },
    getSelectList() {
      switch (this.userType) {
        case 1: {
          this.$api.post("streetmanager/pagestreet", {}, (e) => {
            this.responsibilityList.push({
              label: "街道",
              options: e.data.records,
            });
            this.$api.get("communityactivity/community/westList", {}, (e) => {
              this.responsibilityList.push({
                label: "社区",
                options: e,
              });
              this.$api.post(
                "comActSocialOrg/queryAll",
                {
                  page: 1,
                  size: 99999,
                  paramId2: 1,
                },
                (e) => {
                  this.responsibilityList.push({
                    label: "社会组织",
                    options: e.records,
                  });
                }
              );
            });
          });
          break;
        }
        case 2: {
          this.$api.get("communityactivity/community/westList", {}, (e) => {
            this.responsibilityList.push({
              label: "社区",
              options: e,
            });
            this.$api.post(
              "comActSocialOrg/queryAll",
              {
                page: 1,
                size: 99999,
                paramId2: 1,
              },
              (e) => {
                this.responsibilityList.push({
                  label: "社会组织",
                  options: e.records,
                });
              }
            );
          });
          break;
        }
        case 3: {
          this.$api.post(
            "comActSocialOrg/queryAll",
            {
              page: 1,
              size: 99999,
              paramId2: 1,
            },
            (e) => {
              this.responsibilityList.push({
                label: "社会组织",
                options: e.records,
              });
            }
          );
          break;
        }
        default: {
          break;
        }
      }
    },
    isTopChange(v) {
      if (v) {
        this.form.isTop = "1";
      } else {
        this.form.isTop = "0";
      }
    },
    getDetails() {
      this.$api.get(`comActSocialProjectPublicity/${this.info_id}`, {}, (e) => {
        this.form = e;
        e.isTop == 1 ? (this.checked = true) : (this.checked = false);
      });
    },
    // 上传
    onUpload1(e) {
      this.form.image = e;
    },
 
    clear() {
      this.form.image = "";
    },
 
    // 获取数据-编辑
    change(val) {
      console.log(val);
    },
    // 保存
    submitHandle(formName) {
      this.$refs[formName].validate((val) => {
        if (val) {
          if (this.info_id) {
            this.form.id = this.info_id;
            this.$api.post(
              "/comActSocialProjectPublicity/update",
              this.form,
              (e) => {
                demo.toast("编辑成功");
                this.$nextTick(() => {
                  this.$router.go(-1);
                });
              }
            );
          } else {
            this.$api.post("comActSocialProjectPublicity", this.form, (e) => {
              demo.toast("新增成功");
              this.$nextTick(() => {
                this.$router.go(-1);
              });
            });
          }
        }
      });
    },
  },
};
</script>
<style lang='less' scoped>
.act_add {
  overflow: auto;
}
.input-width {
  width: 300px;
}
.upImage {
  /*width: 100%;*/
  display: flex;
  box-sizing: border-box;
  flex-wrap: wrap;
}
.sec {
  &::before {
    content: attr(data-error);
    position: absolute;
    left: 0 !important;
    bottom: -20px;
    font-size: 12px;
    line-height: 20px;
    height: 20px;
    width: calc(~"100% - 100px");
    color: tomato;
  }
}
.sec {
  margin: 10px;
}
.image-box {
  width: 104px;
  height: 104px;
  margin: 5px;
  position: relative;
}
.image-box > img {
  width: 100%;
  height: 100%;
}
.clear {
  position: absolute;
  right: 0;
  top: 0;
  cursor: pointer;
  width: 28px !important;
  height: 28px !important;
}
</style>