baizonghao
2023-05-19 794121b3a768300b8d40bed82e57993555271afe
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
<template>
  <div style="height: 100%">
    <el-card style="height: 100%">
      <template slot="header">
        <el-form :inline="true" :model="queryInfo" class="demo-form-inline">
          <el-form-item label="关键字:">
            <el-input placeholder="请输入" v-model="queryInfo.questionTitle"></el-input>
          </el-form-item>
          <el-form-item label="状态:">
            <el-select v-model="queryInfo.status" placeholder="请选择" :style="{ width: '120px' }">
              <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>
            <el-button type="primary" @click="search">查询</el-button>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="addPublicityVisibel = true">添加</el-button>
          </el-form-item>
        </el-form>
      </template>
      <template>
        <el-table :data="publicityList" style="width: 100%">
 
          <el-table-column label="序号" type="index" width="180" align="center">
            <template slot-scope="scope">
              <span>{{ (current - 1) * size + scope.$index + 1 }}</span>
            </template>
          </el-table-column>
          <el-table-column prop="questionTitle" label="问题关键字" width="180" align="center">
          </el-table-column>
          <el-table-column prop="status" label="状态" width="180" header-align="center" align="center">
            <template slot-scope="scope">
              <span v-if="scope.row.status == 0">未发布</span>
              <span v-if="scope.row.status == 1">已发布</span>
              <span v-if="scope.row.status == 2">下架</span>
            </template>
          </el-table-column>
          <el-table-column prop="userName" label="创建人" width="180" header-align="center" align="center">
          </el-table-column>
          <el-table-column prop="releaseTime" label="发布时间" width="180" header-align="center" align="center">
          </el-table-column>
          <el-table-column label="操作" align="conter">
            <template slot-scope="scope">
              <el-button type="text" size="medium" @click="details(scope.row.id)">详情</el-button>
              <el-button type="text" size="medium" @click="punlish(scope.row.id, scope.row.status)"
                :disabled="scope.row.status == 2">
                <span v-if="scope.row.status === 1" style="color:#ff0000">下架</span>
                <span v-else>发布</span>
              </el-button>
              <el-button type="text" size="medium" @click="remove(scope.row.id)" style="color:#ff0000">删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </template>
      <el-pagination @current-change="handleCurrentChange" :current-page="queryInfo.current" :page-size="queryInfo.size"
        layout="prev, pager, next" :total="total"></el-pagination>
    </el-card>
 
    <!--添加常见问题弹窗-->
    <el-dialog title="常见问题添加" :visible.sync="addPublicityVisibel" width="50%" :before-close="addPublicityClose"
      :append-to-body="true">
      <el-row :gutter="15">
        <el-form ref="addPublicityForm" :model="addPublicityForm"  :rules="rules" size="medium" label-width="100px">
          <el-col :span="18">
            <el-form-item label="关键字" prop="questionTitle">
               <el-input v-model="addPublicityForm.questionTitle" type="textarea"  clearable placeholder="请输入关键字,并用','分隔"
                    :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="18">
            <el-form-item label="匹配类型" prop="matchQuestion">
              <el-input v-model="addPublicityForm.matchQuestion" clearable placeholder="请输入匹配类型"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="18">
            <el-form-item label="问题解答" prop="answer">
                <el-input v-model="addPublicityForm.answer" type="textarea" clearable placeholder="请输入问题解答"
                    :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addPublicityVisibel = false">取 消</el-button>
        <el-button type="primary" @click="add">确 定</el-button>
      </span>
    </el-dialog>
 
    <!--公共宣传详情弹窗-->
    <el-dialog title="公共宣传详情" :visible.sync="detailsVisible" width="50%" :append-to-body="true"
      :before-close="detailsVisibleclose">
 
         <el-row :gutter="15">
        <el-form ref="addGroupForm" :model="addGroupForm" size="medium" label-width="100px">
          <el-col :span="24">
            <el-form-item label="关键字 " prop="text">
              <el-input v-model="detailsRow.questionTitle" type="textarea" placeholder="请输入公告内容" disabled
                :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
            </el-form-item>
          </el-col>
            <el-col :span="24">
            <el-form-item label="匹配问题" prop="effectiveEtime">
              <el-input v-model="detailsRow.matchQuestion" disabled></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="问题解答 " prop="text">
              <el-input v-model="detailsRow.answer" type="textarea" placeholder="请输入公告内容" disabled
                :autosize="{ minRows: 4, maxRows: 4 }" :style="{ width: '100%' }"></el-input>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="公告有效期" prop="effectiveStime">
              <el-date-picker v-model="detailsGroupAn.effectiveStime" type="datetime" placeholder="选择日期时间" disabled
                :style="{ width: '100%' }" value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="至" prop="effectiveEtime">
              <el-date-picker v-model="detailsGroupAn.effectiveEtime" type="datetime" placeholder="选择日期时间" disabled
                :style="{ width: '100%' }" value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="发布时间" prop="effectiveEtime">
              <el-date-picker v-model="detailsRow.releaseTime" type="datetime" placeholder="选择日期时间" disabled
                :style="{ width: '100%' }" value-format="yyyy-MM-dd HH:mm:ss">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="创建人" prop="effectiveEtime">
              <el-input v-model="detailsGroupAn.createName" disabled></el-input>
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="状态" prop="status">
              <span v-if="detailsRow.status === 1">已发布</span>
              <span v-else-if="detailsRow.status === 0">未发布</span>
              <span v-else="detailsRow.status === 2">已下架</span>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
<!-- 
      <div style="display:flex; width:180;">
        <div style="display:flex; width:180;">
          <h4>关键字</h4>
          <p>{{ detailsRow.questionTitle }}</p>
        </div>
        <div style="display:flex; width:180;">
          <h4>匹配问题</h4>
          <p>{{ detailsRow.matchQuestion }}</p>
        </div>
        <div style="display:flex; width:180;">
          <h4>问题解答</h4>
          <p>{{ detailsRow.answer }}</p>
        </div>
        <div style="display:flex; width:180;">
          <h4>创建时间</h4>
          <p>{{ detailsRow.ctime }}</p>
        </div>
      </div> -->
 
      <!-- <el-table-column width="180" prop="effectiveStime" label="群组公告"></el-table-column>
            <el-table-column width="120" prop="status" label="状态">
              <template slot-scope="scope">
                <span v-if="scope.row.status === 1">已发布</span>
                <span v-else-if="scope.row.status === 0">未发布</span>
                <span v-else="scope.row.status=== 2">已下架</span>
              </template>
            </el-table-column>
            <el-table-column width="100" prop="createName" label="创建人"></el-table-column>
            <el-table-column width="180" prop="publishTime" label="发布时间">
            </el-table-column> -->
 
    </el-dialog>
 
  </div>
</template>
 
<script>
import {
  getPublicityList,
  addPublicityList
} from '@/api/question'
 
 
export default {
  name: "Question",
  data() {
    return {
 rules: {
        questionTitle: [{
          required: true,
          message: '请输入关键字 ',
          trigger: 'blur'
        }],
         matchQuestion: [{
          required: true,
          message: '请输入匹配问题',
          trigger: 'blur'
        }],
        answer: [{
          required: true,
          message: '请输入问题解答 ',
          trigger: 'blur'
        }],
        },
 
      //详细内容弹框
      detailsVisible: false,
      //详细内容
      detailsRow: [],
      //表单提交内容
      addPublicityForm: {
        publicityTitle: '',
        text: ''
      },
      //添加弹框
      addPublicityVisibel: false,
      //序号当前页
      current: 1,
      //序号数目
      size: 10,
      //页面查询总数
      total: null,
      //查询条件
      queryInfo: {
        questionTitle: '',
        status: null,
        current: 1,
        size: 10
      },
      options: [
        {
          value: null,
          label: '全部'
        },
        {
          value: '0',
          label: '未发布'
        },
        {
          value: '1',
          label: '已发布'
        }
        , {
          value: '2',
          label: '下架 '
        }
      ],
      publicityList: []
      ,
    }
  },
  created() {
    this.init();
 
  },
  methods:
  {
    //删除
    remove(val) {
      this.$http.delete('/api/commonQuestion',{params: {id:val}}).then(res => {
        this.$message({
          message: '删除成功',
          type: 'success'
        })
 
        this.search();
      })
    },
    //发布/下架
    punlish(val, val2) {
      if (val2 == 0) {
        this.$http.get('/api/commonQuestion/release/' + val).then(res => {
          this.$message({
            message: '发布成功',
            type: 'success'
          })
 
          this.search();
        }
        )
      }
      if (val2 == 1) {
        this.$http.get('/api/commonQuestion/offline/' + val).then(res => {
          this.$message({
            message: '下架成功',
            type: 'success'
          })
          this.search();
        }
        );
      }
    },
 
    //详情
    details(val) {
      this.detailsVisible = true;
      this.$http.get('/api/commonQuestion/' + val).then(res => this.detailsRow = res.data.data);
    },
    //添加
    add() {
       this.$refs.addPublicityForm.validate(async (vaild) => {
        if (!vaild) return this.$message.error('输入有误')
      let param = null;
      param = this.addPublicityForm;
      addPublicityList(param).then(res => {
        this.$message({
          message: '操作成功',
          type: 'success'
        });
        this.addPublicityForm={}
        this.init();
      }
      )
      this.addPublicityVisibel = false;
      })
    },
    //关闭之前
    addPublicityClose() {
      this.addPublicityVisibel = false;
    },
    detailsVisibleclose() {
      this.detailsVisible = false;
    },
    //分页方法
    handleCurrentChange(val) {
      this.queryInfo.current = val;
      this.search();
    },
 
    //公共宣传加载
    init() {
      let param = {}
      param.current = this.queryInfo.current
      param.size = this.queryInfo.size
      param.status = this.queryInfo.status !== null ? this.queryInfo.status : ''
      getPublicityList(param).then(res => {
        this.publicityList = res.records;
        this.total = res.total
      })
    },
    //查询
    search() {
      let param = {}
      param.questionTitle = this.queryInfo.questionTitle;
      param.current = this.queryInfo.current
      param.size = this.queryInfo.size
      param.status = this.queryInfo.status !== null ? this.queryInfo.status : ''
      getPublicityList(param).then(res => {
        this.publicityList = res.records;
        this.total = res.total
        this.current = res.current
      })
    },
 
  }
}
</script>
 
<style scoped>
::v-deep(.el-table thead) {
  color: #000000;
}
</style>