From 6416b40cf242340eaa163c498bd49d8103e73610 Mon Sep 17 00:00:00 2001
From: linwe <872216996@qq.com>
Date: Mon, 29 Jul 2024 17:01:52 +0800
Subject: [PATCH] 代码优化
---
src/views/property/articleComment.vue | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 234 insertions(+), 0 deletions(-)
diff --git a/src/views/property/articleComment.vue b/src/views/property/articleComment.vue
new file mode 100644
index 0000000..d42b9f9
--- /dev/null
+++ b/src/views/property/articleComment.vue
@@ -0,0 +1,234 @@
+<template>
+ <basicContainer>
+ <avue-crud :data="dataList" ref="crud" :table-loading="loading" @current-change="currentChange"
+ @search-change="searchChange" @search-reset="searchReset" @size-change="sizeChange" :option="option"
+ v-model="data" :page="page" @selection-change="selectionChange" @row-del="rowDel"
+ @refresh-change="refreshChange" @on-load="onLoad">
+ <template slot="menuLeft">
+ <!-- <el-button size="small" icon="el-icon-delete" plain v-if="permission.article_delete" @click="handleDelete">删 除
+ </el-button> -->
+ <el-button type="danger" size="small" plain icon="el-icon-delete" v-if="permission.user_delete"
+ @click="handleDelete">批量删除
+ </el-button>
+ </template>
+
+ <template slot-scope="{row, size}" slot="phone">
+ <el-button :size="size" type="text" @click="showStringDispose(row, 'phoneflag')"
+ v-text="textDispose(row, 'phoneflag', 'phone')">
+ </el-button>
+ </template>
+ </avue-crud>
+ </basicContainer>
+</template>
+<script>
+import {
+ getPageList,
+ remove,
+ update,
+ add,
+ getNotice,
+ upcomment
+} from "@/api/article/articleComment"
+import {
+ mapGetters
+} from "vuex"
+
+import website from '@/config/website'
+
+export default {
+ data () {
+ return {
+ page: {
+ pageSize: 10,
+ pageSizes: [10, 20, 30, 50, 100],
+ currentPage: 1,
+ total: 0
+ },
+ dataList: [],
+ loading: true,
+ selectionList: [],
+ option: {
+ labelWidth: 96,
+ searchLabelWidth: 66,
+ searchShow: true,
+ searchMenuSpan: 3,
+ menuWidth: 80,
+
+ selection: true,
+ height: "auto",
+ calcHeight: 54,
+ align: 'center',
+ menuAlign: 'center',
+ addBtn: false,
+ editBtn: false,
+ searchBtn: true,
+ column: [
+ {
+ width: 110,
+ label: '头像',
+ prop: 'avatar',
+ dataType: 'string',
+ type: 'img',
+ },
+ {
+ width: 120,
+ label: '电话',
+ prop: 'phone',
+ searchSpan: 4,
+ search: true,
+ searchLabelWidth: 46,
+ slot: true
+ },
+ {
+ width: 110,
+ label: '昵称',
+ prop: 'name',
+ searchSpan: 4,
+ search: true,
+ },
+ {
+ label: '标题',
+ prop: 'title',
+ searchSpan: 4,
+ search: true,
+ },
+ {
+ label: '评论',
+ prop: 'content'
+ }
+ ]
+ }
+ }
+ },
+ computed: {
+ ...mapGetters(["permission", "userInfo"]),
+ permissionList () {
+ return {
+ addBtn: this.vaildData(this.permission.article_add, true),
+ viewBtn: this.vaildData(this.permission.article_view, true),
+ delBtn: this.vaildData(this.permission.article_delete, true),
+ editBtn: this.vaildData(this.permission.article_edit, true),
+ }
+ },
+ ids () {
+ let ids = []
+ this.selectionList.forEach((ele) => {
+ ids.push(ele.id)
+ })
+ return ids.join(",")
+ },
+
+ textDispose () {
+ return (row, flag, type) => {
+ if (row[flag] || row[type] == null) {
+ return row[type]
+ } else {
+ if (type == 'principalIdCard') {
+ return row[type].replace(/^(.{6})(?:\d+)(.{4})$/, "$1******$2")
+ } else {
+ return row[type].replace(/^(.{3})(?:\d+)(.{4})$/, "$1****$2")
+ }
+ }
+ }
+ }
+ },
+ methods: {
+ showStringDispose (row, type) {
+ row[type] = !row[type]
+ },
+
+ selectionChange (list) {
+ this.selectionList = list
+ },
+ rowDel (row) {
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ })
+ .then(() => {
+ return remove(row.id)
+ })
+ .then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ })
+ },
+ refreshChange () {
+ this.onLoad(this.page, this.query)
+ },
+ handleDelete () {
+ if (this.selectionList.length === 0) {
+ this.$message.warning("请选择至少一条数据")
+ return
+ }
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ })
+ .then(() => {
+ return remove(this.ids)
+ })
+ .then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ this.$refs.crud.toggleSelection()
+ })
+ },
+ searchReset () {
+ this.query = {}
+ this.onLoad(this.page)
+ },
+ searchChange (params, done) {
+ this.query = params
+ this.page.currentPage = 1
+ this.onLoad(this.page, params)
+ done()
+ },
+ currentChange (currentPage) {
+ console.log(currentPage)
+ this.page.currentPage = currentPage
+ },
+ sizeChange (pageSize) {
+ console.log(pageSize)
+ this.page.pageSize = pageSize
+ },
+ onLoad (page, params = {}) {
+ let values = {
+ ...params,
+ }
+ this.loading = true
+ getPageList(page.currentPage, page.pageSize, values).then((res) => {
+ const data = res.data.data
+ this.page.total = data.total
+ this.dataList = data.records
+ this.dataList.forEach(item => {
+ this.$set(item, 'phoneflag', false)
+ if (item.avatar) {
+ // var urls = []
+ // var names = item.avatar.split(",")
+ // names.forEach(name => {
+ // urls.push(website.minioUrl + name)
+ // })
+ item.avatar = website.minioUrl + item.avatar
+ }
+ })
+ this.loading = false
+ })
+ },
+ selectionClear () {
+ this.selectionList = []
+ this.$refs.crud.toggleSelection()
+ },
+ }
+}
+</script>
+
+<style></style>
\ No newline at end of file
--
Gitblit v1.9.3