jiangping
2025-05-27 3d6a8e384d31432a23f5a8c1a3135a58cbe617b5
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
<template>
    <TableLayout :permissions="['business:knowledge:query']">
        <!-- 搜索表单 -->
        <el-form ref="searchForm" slot="search-form" :model="searchForm" label-width="100px" inline>
            <el-form-item label="标题" prop="title">
                <el-input v-model="searchForm.title" style="width: 120px"  clearable placeholder="请输入标题" @keypress.enter.native="search"></el-input>
            </el-form-item>
          <el-form-item label="省份" prop="area">
            <el-select style="width: 120px"  v-model="searchForm.provinceId" clearable filterable @change="changeProvince" placeholder="请选择">
              <el-option
                  v-for="item in areas"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="城市" prop="area">
            <el-select style="width: 120px" v-model="searchForm.cityId"  clearablefilterable @change="search" placeholder="请选择">
              <el-option
                  v-for="item in citys"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
            <section>
                <el-button type="primary" @click="search">搜索</el-button>
<!--                <el-button type="primary" :loading="isWorking.export" v-permissions="['business:knowledge:exportExcel']" @click="exportExcel">导出</el-button>-->
                <el-button @click="reset">重置</el-button>
            </section>
        </el-form>
        <!-- 表格和分页 -->
        <template v-slot:table-wrap>
            <ul class="toolbar" v-permissions="['business:knowledge:create', 'business:knowledge:delete']">
                <li><el-button type="primary" @click="$refs.operaKnowledgeWindow.open('新建')" icon="el-icon-plus" v-permissions="['business:knowledge:create']">新建</el-button></li>
<!--                <li><el-button @click="deleteByIdInBatch" icon="el-icon-delete" v-permissions="['business:knowledge:delete']">删除</el-button></li>-->
            </ul>
            <div class="list" v-loading="isWorking.search" v-if="tableData.list.length > 0">
                <div class="list-item" v-for="(item, index) in tableData.list" :key="index">
                    <div class="list-item-title" @click="gourl(item.link)">
                        <span >{{item.title}}</span>
                        <i class="el-icon-arrow-right"></i>
                    </div>
                    <div class="list-item-cates" v-if="item.labels">
                        <div class="list-item-cates-row" v-for="(label, index) in item.labels.split(',')" :key="index">  {{label}}</div>
                    </div>
                    <div class="list-item-footer">
                        <div class="left">
                            <div class="list-item-footer-row">适用地区:{{item.cityName ? item.cityName : item.provinceName}}</div>
                            <div class="list-item-footer-row">适用年份:{{item.yearInfo}} 年</div>
                        </div>
                        <div class="right">
                            <el-button type="text" size="medium" style="margin-right: 15px; color: red;" @click="dele(item.id)">删除</el-button>
                            <el-button type="text" size="medium" @click="$refs.operaKnowledgeWindow.open('编辑', item)">修改</el-button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="wu" v-else v-loading="isWorking.search">
                暂无数据
            </div>
            <pagination
                @size-change="handleSizeChange"
                @current-change="handlePageChange"
                :pagination="tableData.pagination"
            >
            </pagination>
        </template>
        <!-- 新建/修改 -->
        <OperaKnowledgeWindow ref="operaKnowledgeWindow" @success="handlePageChange"/>
    </TableLayout>
</template>
 
<script>
import BaseTable from '@/components/base/BaseTable'
import TableLayout from '@/layouts/TableLayout'
import Pagination from '@/components/common/Pagination'
import OperaKnowledgeWindow from '@/components/business/OperaKnowledgeWindow'
import {deleteById, findTreeList} from '@/api/business/knowledge'
export default {
  name: 'Knowledge',
  extends: BaseTable,
  components: { TableLayout, Pagination, OperaKnowledgeWindow },
  data () {
    return {
      // 搜索
      searchForm: {
        provinceId: '',
        cityId: '',
        title: ''
      },
      areas: [],
      citys: []
    }
  },
  created () {
    this.config({
      module: '知识库信息表',
      api: '/business/knowledge',
      'field.id': 'id',
      'field.main': 'id'
    })
    this.search()
    this.getCityTree()
  },
  methods: {
    changeProvince (e) {
      this.citys = []
      this.searchForm.cityId=null
      this.areas.forEach(item => {
        if (item.id === this.searchForm.provinceId) {
          this.citys = item.childAreasList || []
        }
      })
      this.search()
    },
    gourl (url) {
      if (url) {
        window.open(url)
      }
    },
    dele (id) {
      this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async () => {
        const res = await deleteById(id)
        this.search()
        this.$message.success('删除成功')
      }).catch(() => {
 
      })
    },
    async getCityTree () {
      this.areas = await findTreeList({})
    }
  }
}
</script>
 
<style lang="scss" scoped>
    .wu {
        width: 100%;
        height: 200px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #222222;
        font-size: 18px;
        font-weight: bold;
    }
    .list {
        width: 100%;
        display: flex;
        flex-direction: column;
        .list-item {
            width: 100%;
            padding: 20px;
            border-radius: 10px;
            box-sizing: border-box;
            border: 1px solid #ececec;
            margin-bottom: 15px;
            cursor: pointer;
            &:last-child {
                margin: 0;
            }
            .list-item-title {
                width: 100%;
                display: flex;
                align-items: center;
                justify-content: space-between;
                span {
                    flex: 1;
                    color: rgba(54,98,227,1);
                    font-size: 18px;
                }
                i {
                    flex-shrink: 0;
                    margin-left: 30px;
                    font-size: 22px;
                    color: rgba(54,98,227,1);
                }
            }
            .list-item-cates {
                width: 100%;
                display: flex;
                align-items: center;
                margin: 10px 0;
                .list-item-cates-row {
                    padding: 3px 8px;
                    box-sizing: border-box;
                    border-radius: 4px;
                    background-color: rgba(190,190,190,1);
                    color: rgba(255,255,255,1);
                    font-size: 12px;
                    margin-left: 15px;
                    &:first-child {
                        margin: 0 !important;
                    }
                }
            }
            .list-item-footer {
                width: 100%;
                display: flex;
                align-items: center;
                justify-content: space-between;
                .left {
                    display: flex;
                    align-items: center;
                    .list-item-footer-row {
                        color: rgba(154,154,154,1);
                        font-size: 14px;
                        margin-right: 50px;
                    }
                }
 
            }
        }
    }
</style>