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
| <template>
| <div class='topic'>
| <v-header
| title="话题管理"
| :bar="bar"
| search
| @on-search="onSearch"
| ></v-header>
| <div class="add">
| <button
| class="m_btn bgc_primary small"
| style="min-width:80px"
| @click="onAdd"
| >新增</button>
| </div>
| <div class="tab">
| <v-tool-table
| :trs="trs"
| :tds="tds"
| >
| <template v-slot:btn="{scope}">
| <div class="table_flex">
| <!-- {{item.scope.id}} -->
| <span @click="onEdit(scope)">编辑</span>
| <span
| v-if="scope.status==1"
| @click="onToggle(scope,0)"
| >禁用</span>
| <span
| v-else
| @click="onToggle(scope,1)"
| >启用</span>
| </div>
| </template>
| </v-tool-table>
| </div>
| <v-tool-page
| :item="paged"
| @on-page="onPage"
| ></v-tool-page>
| </div>
| </template>
|
| <script>
| import { mapState } from "vuex";
| export default {
| props: {},
| components: {},
| data() {
| return {
| bar: [
| { title: "话题", name: "name" },
| {
| title: "状态",
| name: "status",
| type: "select",
| list: ["启用", "禁用"].map((r, v) => {
| return { label: r, value: v + 1 };
| }),
| },
| ],
| trs: [
| { text: "序号", val: "index", width: "50px" },
| { text: "话题名称", val: "name" },
| { text: "话题状态", val: "s" },
| { text: "创建人", val: "createBy" },
| { text: "创建时间", val: "createAt" },
| { text: "操作", val: "btn" },
| ],
| tds: [],
| paged: { page: 0, total: 0, r: 0, limit: 10 },
| os: {},
| search: {},
| };
| },
| computed: {
| ...mapState({ vuex_page: "pageReset" }),
| },
| watch: {
| vuex_page: {
| handler(n) {
| if (n.page === this.$route.path) {
| this.paged.page = 1;
| this.init();
| }
| },
| deep: true,
| },
| },
| inject: ["appPath"],
| methods: {
| onSearch(v) {
| this.search = v;
| // this.search = demo.copy();
| this.paged.page = 1;
| this.init();
| },
| // 分页点击
| onPage(v) {
| if (v.page === this.paged.page && v.page && !v.reset) {
| return 0;
| }
| this.paged.page = v.page;
| this.paged.limit = v.limit;
| this.init();
| },
| // 获取数据
| init() {
| let v = demo.copy(
| Object.assign(this.os, this.search, {
| pageNum: this.paged.page,
| pageSize: this.paged.limit,
| })
| );
| this.$api.post("neighbor/pageNeighborTopicByAdmin", v, (e) => {
| // console.log(e)
| this.paged.total = e.total;
| this.tds = (e.records || []).map((r) => {
| r.s = r.status == 1 ? "启用" : "禁用";
| return r;
| });
| e.records.map((item,index) => {
| item.index = (this.paged.page-1) * this.paged.limit + index + 1
| })
| });
| },
| // 显示隐藏
| onToggle(v, n) {
| let a = [
| "确定将话题状态改为”禁用“?停用后不支持展示到系统,但可以修改话题内容",
| "确定将话题状态改为”启用“?启用后可将该话题展示到系统",
| ];
| this.$js.model("提示", a[n], (res) => {
| if (res) {
| this.$api.post(
| "neighbor/editNeighborTopicByAdmin",
| {
| id: v.id,
| status: v.status === 2 ? 1 : 2,
| },
| () => {
| this.init();
| }
| );
| }
| });
| },
| // 新增
| onAdd() {
| this.$store.dispatch("setFixed", {
| event: "add",
| title: "添加话题",
| data: { type: "act-topic", data: {} },
| timeout: Date.now(),
| });
| },
| //编辑
| onEdit(i) {
| console.log("dddd")
| this.$store.dispatch("setFixed", {
| event: "add",
| data: {
| title: "编辑话题",
| type: "act-editpic",
| data: i,
| },
| time: Date.now(),
| });
| },
| },
| mounted() {},
| };
| </script>
| <style lang='less' scoped>
| .topic {
| overflow-y: auto;
| .add,
| .tab {
| margin-bottom: 10px;
| }
| }
| </style>
|
|