From c9aab697d365bfcd7e25fc04173ef3d551a53c56 Mon Sep 17 00:00:00 2001
From: zhongrj <646384940@qq.com>
Date: Thu, 21 Dec 2023 13:59:43 +0800
Subject: [PATCH] 新增社区管理
---
src/views/community/index.vue | 369 ++++++++++++++++++++++++++++++++++++++++++++++++++++
src/api/community/index.js | 49 +++++++
2 files changed, 418 insertions(+), 0 deletions(-)
diff --git a/src/api/community/index.js b/src/api/community/index.js
new file mode 100644
index 0000000..cb54567
--- /dev/null
+++ b/src/api/community/index.js
@@ -0,0 +1,49 @@
+import request from '@/router/axios';
+
+export const getList = (current, size, params) => {
+ return request({
+ url: '/api/blade-community/community/page',
+ method: 'get',
+ params: {
+ ...params,
+ current,
+ size,
+ }
+ })
+}
+
+export const remove = (ids) => {
+ return request({
+ url: '/api/blade-community/community/remove',
+ method: 'post',
+ params: {
+ ids,
+ }
+ })
+}
+
+export const add = (row) => {
+ return request({
+ url: '/api/blade-community/community/submit',
+ method: 'post',
+ data: row
+ })
+}
+
+export const update = (row) => {
+ return request({
+ url: '/api/blade-community/community/submit',
+ method: 'post',
+ data: row
+ })
+}
+
+export const getCommunity = (id) => {
+ return request({
+ url: '/api/blade-community/community/detail',
+ method: 'get',
+ params: {
+ id
+ }
+ })
+}
diff --git a/src/views/community/index.vue b/src/views/community/index.vue
new file mode 100644
index 0000000..c030c75
--- /dev/null
+++ b/src/views/community/index.vue
@@ -0,0 +1,369 @@
+<template>
+ <basic-container>
+ <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" ref="crud" @row-del="rowDel"
+ v-model="form" :permission="permissionList" @row-update="rowUpdate" @row-save="rowSave"
+ :before-open="beforeOpen" @search-change="searchChange" @search-reset="searchReset"
+ @selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange"
+ @refresh-change="refreshChange" @on-load="onLoad">
+ <template slot="menuLeft">
+ <el-button size="small" icon="el-icon-delete" plain v-if="permission.community_delete"
+ @click="handleDelete">删 除
+ </el-button>
+ </template>
+ </avue-crud>
+ </basic-container>
+</template>
+
+<script>
+import { getList, remove, update, add, getCommunity } from "@/api/community/index"
+import { mapGetters } from "vuex"
+import website from '@/config/website'
+export default {
+ data () {
+ return {
+ form: {},
+ query: {},
+ loading: true,
+ page: {
+ pageSize: 10,
+ currentPage: 1,
+ total: 0,
+ },
+ datetime: "",
+ selectionList: [],
+ option: {
+ height: "auto",
+ calcHeight: 54,
+ dialogWidth: 950,
+ tip: false,
+ searchShow: true,
+ searchMenuSpan: 3,
+ menuWidth: 280,
+ border: true,
+ //stripe:true,
+ index: true,
+ viewBtn: true,
+ selection: true,
+ dialogClickModal: false,
+ column: [
+ {
+ label: "社区名称",
+ prop: "name",
+ searchSpan: 5,
+ search: true,
+ span: 12,
+ labelWidth: 120,
+ width: 220,
+ overHidden: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入社区名称",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "社区编号",
+ prop: "code",
+ searchSpan: 5,
+ search: true,
+ span: 12,
+ labelWidth: 120,
+ width: 220,
+ overHidden: true,
+ rules: [
+ {
+ required: true,
+ message: "请输入社区编号",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "所属街道",
+ prop: "streetCode",
+ search: true,
+ searchSpan: 4,
+ width: 150,
+ labelWidth: 120,
+ type: "tree",
+ dicUrl: "/api/blade-system/region/tree?parentCode=361102",
+ props: {
+ label: "name",
+ value: "id"
+ },
+ rules: [
+ {
+ required: true,
+ message: "请选择所属街道",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "社区民警",
+ prop: "resPoliceUserId",
+ labelWidth: 120,
+ type: "tree",
+ dicUrl: "/api/blade-system/user/getUserListByParam?roleName=民警",
+ props: {
+ label: "name",
+ value: "id"
+ },
+ rules: [
+ {
+ required: true,
+ message: "请选择所属街道",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "社区图片",
+ prop: "picUrl",
+ width: 80,
+ labelWidth: 120,
+ type: "upload",
+ listType: "picture-img",
+ action: "/api/blade-resource/oss/endpoint/put-file",
+ propsHttp: {
+ res: "data",
+ url: "link",
+ },
+ span: 24,
+ },
+
+ {
+ label: "地址",
+ prop: "address",
+ span: 24,
+ labelWidth: 120,
+ rules: [
+ {
+ required: true,
+ message: "请输入地址",
+ trigger: "blur",
+ },
+ ],
+ },
+ {
+ label: "社区简介",
+ prop: "remark",
+ labelWidth: 120,
+ component: "AvueUeditor",
+ options: {
+ action: "/api/blade-resource/oss/endpoint/put-file",
+ props: {
+ res: "data",
+ url: "link",
+ },
+ },
+ hide: true,
+ minRows: 6,
+ span: 24,
+ },
+
+ ],
+ },
+ data: [],
+ }
+ },
+ watch: {
+ },
+ computed: {
+ ...mapGetters(["permission", "userInfo"]),
+ permissionList () {
+ return {
+ addBtn: this.vaildData(this.permission.community_add, true),
+ viewBtn: this.vaildData(this.permission.community_view, true),
+ delBtn: this.vaildData(this.permission.community_delete, true),
+ editBtn: this.vaildData(this.permission.community_edit, true),
+ }
+ },
+ ids () {
+ let ids = []
+ this.selectionList.forEach((ele) => {
+ ids.push(ele.id)
+ })
+ return ids.join(",")
+ },
+ },
+ methods: {
+ rowSave (row, done, loading) {
+ if (row.picUrl.length > 0) {
+ var urls = []
+ var split = row.picUrl.split(",")
+ split.forEach(url => {
+ var names = url.split("jczz/")
+ urls.push(names[1])
+ })
+ row.picUrl = urls.join(",")
+ }
+ row.userid = this.userInfo.user_id
+ add(row).then(
+ () => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ done()
+ },
+ (error) => {
+ window.console.log(error)
+ loading()
+ }
+ )
+ },
+ rowUpdate (row, index, done, loading) {
+ if (row.picUrl.length > 0) {
+ var urls = []
+ var split = row.picUrl.split(",")
+ split.forEach(url => {
+ var names = url.split("jczz/")
+ urls.push(names[1])
+ })
+ row.picUrl = urls.join(",")
+ }
+ update(row).then(
+ () => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ done()
+ },
+ (error) => {
+ window.console.log(error)
+ loading()
+ }
+ )
+ },
+ rowDel (row) {
+ this.$confirm("确定将选择数据删除?", {
+ confirmButtonText: "确定",
+ cancelButtonText: "取消",
+ type: "warning",
+ })
+ .then(() => {
+ return remove(row.id)
+ })
+ .then(() => {
+ this.onLoad(this.page)
+ this.$message({
+ type: "success",
+ message: "操作成功!",
+ })
+ })
+ },
+ searchReset () {
+ this.query = {}
+ this.onLoad(this.page)
+ },
+ searchChange (params, done) {
+ this.query = params
+ this.page.currentPage = 1
+ this.onLoad(this.page, params)
+ done()
+ },
+ selectionChange (list) {
+ this.selectionList = list
+ },
+ selectionClear () {
+ this.selectionList = []
+ this.$refs.crud.toggleSelection()
+ },
+ 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()
+ })
+ },
+ beforeOpen (done, type) {
+ if (["edit", "view"].includes(type)) {
+ getCommunity(this.form.id).then((res) => {
+ this.form = res.data.data
+ if (this.form.picUrl.length > 0) {
+ var urls = []
+ var names = this.form.picUrl.split(",")
+ names.forEach(name => {
+ urls.push(website.minioUrl + name)
+ })
+ this.form.picUrl = urls.join(",")
+ }
+ })
+ }
+ // con
+ done()
+ },
+ currentChange (currentPage) {
+ this.page.currentPage = currentPage
+ },
+ sizeChange (pageSize) {
+ this.page.pageSize = pageSize
+ },
+ refreshChange () {
+ this.onLoad(this.page, this.query)
+ },
+ onLoad (page, params = {}) {
+ const { dateTime } = this.query
+ let values = {
+ ...params,
+ }
+ if (dateTime) {
+ values = {
+ ...params,
+ startTime: dateTime[0],
+ endTime: dateTime[1],
+ ...this.query,
+ }
+ values.dateTime = null
+ }
+ this.loading = true
+ getList(page.currentPage, page.pageSize, values).then((res) => {
+ const data = res.data.data
+ this.page.total = data.total
+ this.data = data.records
+ this.data.forEach(item => {
+ if (item.picUrl) {
+ if (item.picUrl.length > 0) {
+ var urls = []
+ var names = item.picUrl.split(",")
+ names.forEach(name => {
+ urls.push(website.minioUrl + name)
+ })
+ item.picUrl = urls.join(",")
+ }
+ }
+ })
+ this.loading = false
+ this.selectionClear()
+ })
+ }
+ }
+}
+</script>
+
+<style>
+.avue-upload__icon {
+ line-height: 6;
+}
+</style>
--
Gitblit v1.9.3