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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
<template>
  <div class="quest_add">
    <!-- <v-header title="问卷调查"></v-header> -->
    <div class="nav-title">
      <div class="left-tab">
        <span :class="tabIndex==index ? 'active' : ''" v-for="(item , index) in tabList" :key="index" @click="tabClick(index)">{{item.text}}</span>
      </div>
      <div class="right-tab">
        <el-button @click="cancel">关闭</el-button>
        <el-button type="primary" plain @click="releaseMsg()">发布</el-button>
        <el-button type="primary" @click="save">保存</el-button>
      </div>
    </div>
    <!-- 基础信息 -->
    <el-form v-if="isShowadd" ref="msgform" :model="msgform"  label-width="110px">
      <el-form-item label="问卷调查主题" class="title">
        <el-input class="custom-input" v-model="msgform.title" placeholder="请输入主题,不超过25字" maxlength="25" show-word-limit></el-input>
      </el-form-item>
      <el-form-item label="调研时间" class="time">
        <el-date-picker
          v-model="msgform.time"
          type="daterange"
          range-separator="至"
          format="yyyy-MM-dd"
          :default-time="['00:00:00', '23:59:59']"
          start-placeholder="开始日期"
          end-placeholder="结束日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="调研对象">
        <el-radio-group v-model="msgform.identity">
          <el-radio
            v-for="item in residentCheck"
            :key="item.value"
            :label="item.value"
            :disabled="item.value !== 1 && isCheckdisabled"
          >{{item.label}}</el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- <el-form-item label="广告设置" class="guangg">
         <el-checkbox-group v-model="msgform.type" @change="advertisementChange">
            <span class="banner-list">
              <el-checkbox :label="1" name="type">首页弹窗</el-checkbox>
              <p>
                <viewer>
                  <img src="../../../assets/image/tanc.png">
                </viewer>
                </p>
            </span>
            <span class="banner-list">
              <el-checkbox :label="2"  name="type">首页顶部</el-checkbox>
              <p><viewer><img src="../../../assets/image/banner.png"></viewer></p>
            </span>
            <span class="banner-list">
              <el-checkbox :label="3"  name="type">首页应用</el-checkbox>
              <p><viewer><img src="../../../assets/image/db.png"></viewer></p>
            </span>
            <span class="banner-list">
              <el-checkbox :label="4"  name="type">设置封面</el-checkbox>
              <p><viewer><img src="../../../assets/image/fengm.png"></viewer></p>
            </span>
        </el-checkbox-group>
      </el-form-item> -->
 
      <el-form-item label="强制调研" v-if="isForceShow">
          <el-radio-group v-model="msgform.isForce">
            <el-radio :label="1">是</el-radio>
            <el-radio :label="2">否</el-radio>
          </el-radio-group>
          <p class="alert-text">解释说明:如果确定强制调研,那么用户每次进入小程序时都会提醒去填写问卷调查,如果不强制调研,那么用户可以选择不再接受该弹窗提醒。</p>
      </el-form-item>
 
      <!-- <el-form-item label="应用名称" :class="isremark ? 'guangg' :''">
        <el-input class="custom-input" v-model="msgform.remark" placeholder="不超过4个字" maxlength="4" show-word-limit></el-input>
      </el-form-item> -->
    </el-form>
 
    <!-- 问卷内容 -->
      <div class="form-box"  v-show="isShowFrom">
        <home ref="forms" @run="run" :list="list"></home>
    <!--    <fc-designer ref="designer"/>-->
      </div>
  </div>
</template>
 
<script>
 
import home from "../../form/Home";
 
export default {
  components:{ home },
 
  data() {
    return{
      btnLoading:false,
      msgform:{
        time: [],
        title:"",
        identity:1,
        type:[],
        remark:'',
        isForce:2,
      },
      residentCheck:[
        {
          value: 1,
          label:"全部居民"
        },
         {
          value: 2,
          label:"党员"
        },
         {
          value: 3,
          label:"志愿者"
        },
      ],
      isCheckdisabled:false,
      tabList:[
        {
          id:1,
          text:"基础信息"
        },
         {
          id:1,
          text:"问卷内容"
        }
      ],
      tabIndex:"0",
      isShowFrom: false,
      isShowadd: true,
      fromData:[],
      list:[],
      isForceShow:false,
      isremark:false,
      isFabu:false,
    }
  },
 
  created() {
    this.list = [
      {
        type:0,
        label:'单选框组',
        required:false,
        options:[{label:'选项一1',value:''},{label:'选项二1',value:''}]
      },
    ]
  },
 
  mounted() {
    if(this.$route.params.id && !this.$route.params.info) {
      console.log("我是编辑")
      let val = this.$route.params.id;
      this.getDetails(val)
    }
 
    if(this.$route.params.info) {
      let val = this.$route.params.id;
      this.isFabu = true;
      this.getDetails(val)
      console.log("我是复制")
    }
  },
 
  methods: {
    getDetails(id) {
      this.$api.get("questnaire/view", {questId:id}, e => {
        if (e) {
          const arr = [];
          this.msgform.title = e.title;
          this.msgform.remark = e.remark;
          this.msgform.isForce = +e.isForce;
          this.msgform.time = [e.startTime, e.endTime];
          this.list = JSON.parse(e.jsonObject);
 
          if (+e.adverPositionApplication === 1) {
            arr.push(3);
          }
          if (+e.adverPositionPopup === 1) {
            arr.push(1);
          }
          if (+e.adverPositionTop === 1) {
            arr.push(2);
          }
          if (+e.isCover === 1) {
            arr.push(4);
          }
          this.msgform.type = arr;
        }
      });
    },
 
    onSubmit() {
 
      const type = this.msgform.type;
      let parmas = {
        isForce: this.msgform.isForce,
        adverPositionApplication: type.includes(3) ? 1 : 2,
        adverPositionPopup: type.includes(1) ? 1 : 2,
        adverPositionTop: type.includes(2) ? 1 : 2,
        isCover: type.includes(4) ? 1 : 2,
        remark: this.msgform.remark,
        startTime: this.$$moment(this.msgform.time[0]).format('YYYY-MM-DD HH:mm:ss'),
        endTime: this.$$moment(this.msgform.time[1]).format('YYYY-MM-DD HH:mm:ss'),
        title: this.msgform.title,
        identity: this.msgform.identity,
        jsonObject: JSON.stringify(this.fromData),
        isRelease:'2'
      }
 
      //编辑
      if (this.$route.params.id && !this.$route.params.info) {
        this.$api.post("questnaire/edit", {...parmas, id: this.$route.params.id}, (e) => {
          demo.toast("修改成功");
          setTimeout(() => {
            this.$router.back();
          }, 1e3);
        });
      };
 
      /**新增 */
      if(!this.$route.params.id && !this.$route.params.info) {
        this.$api.post("questnaire/add", parmas, (e) => {
          demo.toast("保存成功");
          setTimeout(() => {
            this.$router.back();
          }, 1e3);
        });
      };
 
      //复制
      if(this.$route.params.id && this.$route.params.info) {
        this.$api.post("questnaire/add", parmas, (e) => {
          demo.toast("复制成功");
          setTimeout(() => {
            this.$router.back();
          }, 1e3);
        });
      };
    },
 
    save() {
 
      if(!this.msgform.title) {
        return demo.toast("问卷调查主题必填!")
      }
      if(!this.msgform.time.length) {
        return demo.toast("调研时间必选!")
      }
      // if(!this.msgform.type.length) {
      //   return demo.toast("广告设置必选!")
      // }
      // if(this.isremark && !this.msgform.remark) {
      //   return demo.toast("应用名称必填!")
      // }
 
      this.$refs.forms.run();
      this.onSubmit()
    },
 
    run(e){
      this.fromData = e;
    },
 
    /**
     * 广告设置
     * 1.选了应用就会让必须设置应用名称
     */
    advertisementChange(val) {
      // 包含首页弹窗
      if (val.includes(1)) {
        // this.msgform.isForce = 1;
        this.isForceShow = true;
      } else {
        this.isForceShow = false;
      }
      //包含应用
      this.isremark = val.includes(3);
    },
 
 
    tabClick(index) {
      this.tabIndex = index;
      if(index == '0') {
        this.isShowFrom = false;
        this.isShowadd = true;
      }else {
        this.isShowFrom = true;
        this.isShowadd = false;
      }
    },
 
    releaseMsg() {
 
      if(!this.msgform.title) {
        return demo.toast("问卷调查主题必填!")
      }
      if(!this.msgform.time.length) {
        return demo.toast("调研时间必选!")
      }
      // if(!this.msgform.type.length) {
      //   return demo.toast("广告设置必选!")
      // }
      // if(this.isremark && !this.msgform.remark) {
      //   return demo.toast("应用名称必填!")
      // }
 
      this.$refs.forms.run();
      this.$confirm('确认要发布吗?发布后将无法进行修改?', '温馨提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
 
          const type = this.msgform.type;
          let parmas = {
            isRelease:'1',
            isForce: this.msgform.isForce,
            adverPositionApplication: type.includes(3) ? 1 : 2,
            adverPositionPopup: type.includes(1) ? 1 : 2,
            adverPositionTop: type.includes(2) ? 1 : 2,
            isCover: type.includes(4) ? 1 : 2,
            remark: this.msgform.remark,
            startTime: this.$$moment(this.msgform.time[0]).format('YYYY-MM-DD HH:mm:ss'),
            endTime: this.$$moment(this.msgform.time[1]).format('YYYY-MM-DD HH:mm:ss'),
            title: this.msgform.title,
            identity: this.msgform.identity,
            jsonObject: JSON.stringify(this.fromData)
          }
 
                //编辑
          if (this.$route.params.id && !this.$route.params.info) {
            this.$api.post("questnaire/edit", {...parmas, id: this.$route.params.id}, (e) => {
              demo.toast("修改成功");
              setTimeout(() => {
                this.$router.back();
              }, 1e3);
            });
            return
          };
 
          this.$api.post("questnaire/add", parmas, (e) => {
            demo.toast("处理成功");
            setTimeout(() => {
              this.$router.back();
            }, 1e3);
          });
 
        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已取消发布'
          });
        });
 
    },
 
    /**取消 */
    cancel() {
      this.$router.back();
    },
 
  },
 
};
</script>
<style lang="less" scoped>
.quest_add {
  overflow-y: auto;
}
.form-box {
  min-width: 1000px;
}
/deep/.el-form-item__label {
  position: relative;
}
.title /deep/.el-form-item__label::after {
  content: ' *';
  color: #F56C6C;
  font-size: 150%;
  position: absolute;
  left: 2px;
  top: -3px;
}
.time /deep/.el-form-item__label::after {
  content: ' *';
  color: #F56C6C;
  font-size: 150%;
  position: absolute;
  left: 29px;
  top: -3px;
}
.guangg /deep/.el-form-item__label::after {
  content: ' *';
  color: #F56C6C;
  font-size: 150%;
  position: absolute;
  left: 30px;
  top: -3px;
}
.custom-input,.custom-input /deep/.el-input__inner {
  width: 350px;
}
.alert-text {
  font-size: 12px;
  color: #888;
}
.nav-title {
  width: 100%;
  height: 50px;
  line-height: 65px;
  padding-bottom: 15px;
  border-bottom: 1px #e6e6e6  solid;
  margin-bottom: 30px;
  .left-tab {
    float: left;
    span {
      margin-right: 35px;
      cursor: pointer;
      color: #606266;
    }
    .active {
      color: #409EFF;
      font-size: 16px;
      font-weight: 700;
    }
  }
  .right-tab {
    float:right;
  }
}
.banner-list {
  float: left;
  display: inline-block;
  margin-right: 15px;
  img {
    width: 100px;
    height: 170px;
  }
}
</style>