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
<template>
  <div class="box-content">
    <v-header title="物业宣传管理" search :bar="bar" @on-search="onSearch"></v-header>
    <div class="add fl-sb" v-if="propertyShen == 1">
      <div>
        <el-button type="primary" size="small" @click.stop="clickHandle('add')">新增</el-button>
      </div>
    </div>
    <div class="tab">
      <el-table :data="tableList" border ref="multipleTable" size="mini">
        <el-table-column label="序号" align="center" width="50" type="index"></el-table-column>
        <el-table-column label="物业公司" align="center">
          <template slot-scope="scope">{{ scope.row.propertyName || "-" }}</template>
        </el-table-column>
        <el-table-column label="所属小区" align="center">
          <template slot-scope="scope">{{ scope.row.villageName || "-" }}</template>
        </el-table-column>
        <el-table-column label="宣传标题" align="center">
          <template slot-scope="scope">{{ scope.row.title || "-" }}</template>
        </el-table-column>
        <el-table-column label="宣传类型" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.publicityType != 0">{{ reText(scope.row.publicityType) }}</span>
            <span v-else>{{ scope.row.other }}</span>
          </template>
        </el-table-column>
        <el-table-column label="发布时间" align="center">
          <template slot-scope="scope">{{ reTime(scope.row.createdAt) || "-" }}</template>
        </el-table-column>
        <el-table-column label="浏览量" align="center">
          <template slot-scope="scope">{{ scope.row.viewNum }}</template>
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right" width="150">
          <template slot-scope="scope">
            <el-button
              size="small"
              type="text"
              style="padding: 0"
              @click="clickHandle('edit', scope.row)"
            >编辑</el-button>
            <el-button
              @click="clickHandle('delete', scope.row)"
              size="small"
              type="text"
              style="padding: 0"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <v-tool-page :item="paged" @on-page="onPage"></v-tool-page>
  </div>
</template>
 
<script>
import { mapState } from "vuex";
import { propertyType, dateTime } from "../../../utils/common";
const propertyData = propertyType();
export default {
  data() {
    return {
      dialogVisible: false,
      dialogTitle: "新增",
      bar: [],
      tableList: [],
      paged: { page: 0, total: 0, r: 0, limit: 10 },
      search: {},
      btnloading: false,
      communityList: [],
      propertyList: [],
      propertyShen: 0
    };
  },
  computed: {
    ...mapState({ vuex_page: "pageReset" }),
  },
  watch: {
    vuex_page: {
      handler(n) {
        if (n.page === this.$route.path) {
          this.paged.page = 1;
          this.getTable();
        }
      },
      deep: true,
    },
  },
  mounted() {
    this.propertyShen = demo.$session.get("user").isPropertyWorker;
    if (this.propertyShen !== 1) {
      this.bar = [
        { title: "宣传标题关键词", name: "keyword" },
        {
          title: "物业公司",
          name: "propertyId",
          type: "select",
          list: [
            { value: 1, label: "城镇" },
            { value: 2, label: "农村" },
            { value: 3, label: "未知" },
          ],
        },
        {
          title: "所属小区",
          name: "villageId",
          type: "select",
          list: [],
        },
        {
          title: "宣传类型",
          name: "publicityType",
          type: "select",
          list: propertyData,
        },
      ]
    } else {
      this.bar = [
        { title: "宣传标题关键词", name: "keyword" },
        {
          title: "宣传类型",
          name: "publicityType",
          type: "select",
          list: propertyData,
        },
      ]
    }
    if (this.propertyShen != 1) {
      this.$api.get("property/publicity/list/property", {}, (e) => {
        e.forEach((item) => {
          item.value = item.id;
          item.label = item.name;
        });
        this.bar[1].list = e;
      });
      this.$api.post("villagemanager/pagevillage", {}, (e) => {
        e = e.data.records;
        e.forEach((item) => {
          item.value = item.villageId;
          item.label = item.address;
        });
        this.bar[2].list = e;
      });
    }
  },
  methods: {
    reText(type) {
      let text = '-'
      propertyData.forEach(item => {
        if (item.value === type) {
          text = item.label
        }
      })
      return text;
    },
    reTime(t) {
      return dateTime(t);
    },
    onSearch(v) {
      this.search = demo.copy(v);
      this.paged.page = 1;
      this.getTable();
    },
    // 分页点击
    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.getTable();
    },
    // 获取数据
    getTable() {
      let v = demo.copy(
        Object.assign(this.search, {
          pageNum: this.paged.page,
          pageSize: this.paged.limit,
          type: 3,
        })
      );
      this.$api.post("property/publicity/page", v, (e) => {
        this.paged.total = e.total;
        this.paged.r++;
        this.tableList = e.records || [];
      });
    },
    clickHandle(type, row) {
      switch (type) {
        case "add": {
          this.$router.push("/addDynamic");
          break;
        }
        case "edit": {
          this.$router.push("/addDynamic?id=" + row.id);
          break;
        }
        case "delete": {
          this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }).then(() => {
            this.$api.del("property/publicity/delete?id=" + row.id, {}, () => {
              demo.toast("删除成功");
              this.getTable();
            });
          });
          break;
        }
        default: {
          break;
        }
      }
    },
  },
};
</script>
<style>
.el-table .cell {
  font-size: 14px;
  color: #444;
}
.el-dialog {
  width: 800px !important;
}
</style>
<style lang='less' scoped>
.box-content {
  overflow-y: auto;
  .tab,
  .add {
    margin-bottom: 10px;
  }
}
.input-width {
  width: 250px;
}
.textarea-width {
  width: 350px;
}
.uopload-text {
  width: 100px;
  height: 100px;
  border: 1px dashed #999;
}
.label-text {
  width: 120px;
  text-align: right;
}
.content-text {
  width: 400px;
}
.l-15 {
  line-height: 1.5;
}
.goods-box {
  width: 400px;
}
</style>