峰峰执法平台简易案件程序板块 pad端
yang
2022-10-17 4107256a8d1fa9a2db0969122bfc760994b12421
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
<template>
  <div class="addLawList-box">
    <basic-container>
      <div class="law-reason-box">
        <el-row :gutter="20">
          <el-col :span="18">
            <el-input
                type="textarea"
                :rows="5"
                placeholder="请输入内容"
                v-model="addLawForm.projectName">
            </el-input>
          </el-col>
          <el-col :span="6">
            <div>
              <el-select v-model="addLawForm.type" placeholder="请选择执法类别" size="medium" style="width: 60%">
                <el-option label="行政处罚" value="0"></el-option>
                <el-option label="行政强制" value="1"></el-option>
              </el-select>
            </div>
            <div style="margin-top: 20px">
              <el-select v-model="addLawForm.beforeDeptDictDataName" placeholder="请选择所属领域" size="medium"
                         style="width: 60%">
                <el-option
                    v-for="item in lawThemeOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                </el-option>
              </el-select>
            </div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="18">
            <el-autocomplete
                class="mainKey"
                style="width: 100%"
                placeholder="请设置关键字"
                :fetch-suggestions="querySearch"
                v-model="addLawForm.keyword">
            </el-autocomplete>
          </el-col>
        </el-row>
      </div>
      <div class="addLawList-main">
        <div class="addLaw-inside">
          <div class="lawList-search">
            <el-row :gutter="20">
              <el-col :span="8">
                <!--<el-input placeholder="请输入内容" class="input-with-select">
                  <el-button slot="append" icon="el-icon-search"></el-button>
                </el-input>-->
                <el-autocomplete
                    style="width: 100%"
                    class="inline-input"
                    v-model="firstLawParam.lawName"
                    :fetch-suggestions="querySearchHandle"
                    placeholder="请输入内容"
                    :trigger-on-focus="false"
                    @select="handleSelect"
                ></el-autocomplete>
              </el-col>
              <el-col :span="4">
                <el-select @change="handleChange" v-model="firstLawParam.lawTiaoName" placeholder="请选择">
                  <el-option
                      v-for="item in lawListoptions"
                      :key="item.lawTiaoName"
                      :label="item.lawTiaoName"
                      :value="item.lawTiaoName">
                  </el-option>
                </el-select>
              </el-col>
            </el-row>
          </div>
          <div class="law-tiaokuan-content">
            <h1>{{ firstLawParam.lawTiaoContent }}</h1>
          </div>
        </div>
        <div id="mount-point"></div>
        <div class="addLawBtn">
          <img @click="addLawClick" src="../../../assets/lawImg/addIcon.png" alt="">
          <el-button @click="submitlawTiaoContent" class="submitBtn" size="medium" type="primary">保存事项清单</el-button>
        </div>
 
      </div>
    </basic-container>
  </div>
</template>
 
<script>
import {addLaw, getKeywords, getLaw, getLawTiao, lawInfo} from '@/api/lawList/lawList';
import {remote} from "@/api/admin/dict"
import Vue from 'vue'
 
export default {
  name: "addLawList",
  data() {
    return {
      lawTitlelist: [], // 模糊搜索法律条款回显
      lawTypeOptions: [],  //执法类别
      lawThemeOptions: [],  //执法主题
      lawListoptions: [], //法律条款选择
      keywordList: [],//已经设置过的关键字
      addLawForm: {
        id: '',
        projectName: '', //执法原因
        type: '',
        beforeDeptDictDataName: '',
        keyword: '',//关键字
      },
 
      firstLawParam: {//固定的第一条
        lawName: '',
        lawId: '',
        lawTiaoName: '',
        lawTiaoContent: '',
        lawDetailId: '',
        lawTiaoSeq: ''
      },
      nextLawDomArr: [],//动态追加的dom
 
    }
  },
  mounted() {
  },
  created() {
    this.init();
    this.getAllKeywords();
  },
  methods: {
    addLawClick() { //添加新的一条法律内容
      if (!this.nextLawDomArr[this.nextLawDomArr.length - 1]) {
        if (this.firstLawParam.lawTiaoContent == '') {
          this.$message.warning('先添加完当前条信息,再添加下一条')
          return false
        }
      } else {
        if (this.nextLawDomArr[this.nextLawDomArr.length - 1].nextLawParam.lawTiaoContent == '') {
          this.$message.warning('先添加完当前条信息,再添加下一条')
          return false
        }
      }
 
 
      let self = this;
      let periodDiv = Vue.extend({
        template: `
          <div class="addLaw-inside">
          <div class="lawList-search">
            <el-row :gutter="20">
              <el-col :span="8">
                <!--<el-input placeholder="请输入内容" class="input-with-select">
                  <el-button slot="append" icon="el-icon-search"></el-button>
                </el-input>-->
                <el-autocomplete
                    style="width: 100%"
                    class="inline-input"
                    v-model="nextLawParam.lawName"
                    :fetch-suggestions="querySearchHandle"
                    placeholder="请输入内容"
                    :trigger-on-focus="false"
                    @select="handleSelect"
                ></el-autocomplete>
              </el-col>
              <el-col :span="4">
                <el-select @change="handleChange" v-model="nextLawParam.lawTiaoName" placeholder="请选择">
                  <el-option
                      v-for="item in lawListoptions"
                      :key="item.lawTiaoName"
                      :label="item.lawTiaoName"
                      :value="item.lawTiaoName">
                  </el-option>
                </el-select>
              </el-col>
            </el-row>
          </div>
          <div class="law-tiaokuan-content">
            <h1>{{ nextLawParam.lawTiaoContent }}</h1>
          </div>
          <el-button style="font-size: 24px" type="text" @click="deleteLawBtn" icon="el-icon-error"
                     class="deleteLaw"></el-button>
          </div>
        `,
        data() {
          return {
            lawListoptions: [], //法律条款选择
            nextLawParam: {
              lawName: '',
              lawId: '',
              lawTiaoName: '',
              lawTiaoContent: '',
              lawDetailId: '',
              lawTiaoSeq: ''
            },//动态追加的
          }
        },
        methods: {
          deleteLawBtn() {
            for (let i = 0; i < self.nextLawDomArr.length; i++) {
              if (self.nextLawDomArr[i]._uid == this._uid) {
                self.nextLawDomArr.splice(i, 1)
              }
              $(this.$el).remove()
            }
 
          },
          querySearchHandle(queryString, cb) {  //模糊搜素
            getLaw(queryString).then(res => {
              this.lawTitlelist = []
              let resultList = res.data.data
              resultList.forEach(item => {
                this.lawTitlelist.push({
                  value: item.name,
                  id: item.id
                })
              })
              cb(this.lawTitlelist)
            })
          },
          handleSelect(item) {
            this.nextLawParam.lawName = item.value
            this.nextLawParam.lawId = item.id
            lawInfo(item.value).then(res => {
              this.lawListoptions = res.data.data
            })
          },
          handleChange(item) { //改变选中的条目
            getLawTiao(Object.assign({name: this.nextLawParam.lawName, tiaoName: item})).then(res => {
              this.nextLawParam.lawTiaoName = item
              this.nextLawParam.lawTiaoContent = res.data.data.tiaoContent
              this.nextLawParam.lawDetailId = res.data.data.id
              this.nextLawParam.lawTiaoSeq = res.data.data.sortSeq
            })
          }
 
        },
      })
      let component = new periodDiv().$mount();  // 每次添加需要重新new一个periodDiv
      let $dom = $(component.$el);  // 获取动态元素的jquery对象
      $("#mount-point").append($dom);  // 添加元素至相应位置
      this.nextLawDomArr.push(component)
    },
    init() {
      remote('before_dept').then(res => {  //选择所属领域
        this.lawThemeOptions = res.data.data
      })
    },
 
    submitlawTiaoContent() {
      if (!this.nextLawDomArr[this.nextLawDomArr.length - 1]) {
        if (this.firstLawParam.lawTiaoContent == '') {
          this.$message.warning('先添加完当前条信息再保存')
          return false
        }
      } else {
        if (this.nextLawDomArr[this.nextLawDomArr.length - 1].nextLawParam.lawTiaoContent == '') {
          this.$message.warning('先添加完当前条信息再保存')
          return false
        }
      }
 
      let allArr = []
      allArr.push(this.firstLawParam)
      this.nextLawDomArr.forEach(item => {
        allArr.push(item.nextLawParam);
      })
 
      addLaw(Object.assign(this.addLawForm, {lawDetailArr: JSON.stringify(allArr)})).then(res => {
        this.$message.success(res.data.msg)
        this.$store.commit('delVisitedViews', this.$route.path);
        this.$router.push('/lawList');
      })
    },
    querySearchHandle(queryString, cb) {  //模糊搜素
      getLaw(queryString).then(res => {
        this.lawTitlelist = []
        let resultList = res.data.data
        resultList.forEach(item => {
          this.lawTitlelist.push({
            value: item.name,
            id: item.id
          })
        })
        cb(this.lawTitlelist)
      })
    },
    handleSelect(item) {
      this.firstLawParam.lawName = item.value
      this.firstLawParam.lawId = item.id
      lawInfo(item.value).then(res => {
        this.lawListoptions = res.data.data
      })
    },
    handleChange(val) { //改变选中的条目
      getLawTiao(Object.assign({name: this.firstLawParam.lawName, tiaoName: val})).then(res => {
        this.firstLawParam.lawTiaoName = val
        this.firstLawParam.lawTiaoContent = res.data.data.tiaoContent
        this.firstLawParam.lawDetailId = res.data.data.id
        this.firstLawParam.lawTiaoSeq = res.data.data.sortSeq
      })
 
    },
    querySearch(queryString, cb) {
      var keywordList = this.keywordList;
      var results = queryString ? keywordList.filter(this.createFilter(queryString)) : keywordList;
      // 调用 callback 返回建议列表的数据
      cb(results);
    },
    createFilter(queryString) {
      return (keyword) => {
        return (keyword.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
      };
    },
    getAllKeywords() {
      getKeywords().then(res => {
        this.keywordList = res.data.data;
      })
    }
  }
}
</script>
 
<style>
  h1,h2,h3,h4,h5{
    font-weight: normal;
    font-size: 12px;
  }
 .lawList-search{
   margin-top:10px;
 }
  .addLawList-main{
    border-radius: 4px;
    margin-top: 20px;
    padding-bottom: 30px;
  }
  .addLaw-inside{
    background-color: #eff3fb;
    padding:20px;
    box-sizing: border-box;
    margin-top: 20px;
    position: relative;
  }
  .law-tiaokuan-content{
    background-color: #fff;
    padding:40px 40px;
    box-sizing: border-box;
    border-radius: 4px;
    box-shadow: 0 0 10px rgba(172,198,221,0.45);
    margin-top: 20px;
    /*min-height: 150px;*/
  }
  .law-tiaokuan-content h1{
    line-height: 1.8;
    text-indent: 26px;
    font-size: 12px;
  }
  .deleteLaw{
    position: absolute;
    right: -10px;
    top: -10px;
    width: 24px;
    height: 24px;
  }
  .addLawBtn{
    display: flex;
    justify-content: center;
    margin-top: 20px;
    cursor: pointer;
    position: relative;
  }
  .submitBtn{
    position: absolute;
    right: 0px;
    bottom:0
  }
  .addLawBtn img{
    width: 50px;
    height: 50px;
  }
  .deleteLaw{
    cursor: pointer;
  }
</style>
<style lang="scss">
  .mainKey {
    .el-input__inner, .vue-treeselect__control, .el-textarea__inner {
      border: 1px solid #6a76fb;
      box-shadow: 0 0 10px rgba(66,78,208,0.5);
    }
  }
</style>