| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- <?
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('index', __DIR__);
- ?>
- <style>
- .distrow {
- height: 50px !important;
- }
- .distpopup {
- position: absolute;
- right: -2px;
- top: -4px;
- background: #fff;
- box-shadow: 7px 5px 11px grey;
- width: 83px;
- z-index: 5;
- }
- </style>
- <div id="app" v-cloak>
- <el-card shadow="never" style="border:0;min-width: 1000px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
- <div slot="header">
- <div>
- <span>社区列表</span>
- <div style="float: right;margin-top: -5px">
- <el-button type="primary" @click="add" size="small">添加社区</el-button>
- </div>
- </div>
- </div>
- <div class="table-body">
- <div style="padding-bottom: 20px;">
- <div class="flex">
- <div class="flex" style="margin-right: 20px;">
- <div class="input-title" style="flex-shrink: 0;">省级/直辖市名称</div>
- <el-input size="small" style="width: 130px;" placeholder="请输入省级/直辖市名称" v-model="searchData.province_name"> </el-input>
- </div>
- <div class="flex" style="margin-right: 20px;">
- <div class="input-title" style="flex-shrink: 0;">市级名称</div>
- <el-input size="small" style="width: 130px;" placeholder="请输入市级名称" v-model="searchData.city_name">
- </el-input>
- </div>
- <div class="flex" style="margin-right: 20px;">
- <div class="input-title" style="flex-shrink: 0;">区级/县级名称</div>
- <el-input size="small" style="width: 130px;" placeholder="请输入区级/县级名称" v-model="searchData.district_name">
- </el-input>
- </div>
- <div class="flex" style="margin-right: 20px;">
- <div class="input-title" style="flex-shrink: 0;">街道/镇/乡名称</div>
- <el-input size="small" style="width: 140px;" placeholder="请输入街道/镇/乡名称" v-model="searchData.street_name">
- </el-input>
- </div>
- <div class="flex" style="margin-right: 20px;">
- <div class="input-title" style="flex-shrink: 0;">社区名称</div>
- <el-input size="small" style="width: 130px;" placeholder="请输入社区名称" v-model="searchData.community_name">
- </el-input>
- </div>
- <el-button style="padding: 9px 15px !important;" size="small" type="primary" @click="searchs">搜索</el-button>
- <el-button type="warning" @click="clereSearch" v-if="searchData.province_name || searchData.city_name || searchData.district_name || searchData.street_name || searchData.community_name" style="padding: 9px 15px !important;">清除搜索条件</el-button>
- </div>
- </div>
- <el-table :data="communityList" stripe v-loading="loading" size="small" style="margin-bottom: 15px; width: 100%">
- <el-table-column label="省级/直辖市" width="150" prop="province_name">
- <template slot-scope="scope">
- <div class="user_img" flex="cross:center">
- <div>{{scope.row.province_name}}</div>
- </div>
- </template>
- </el-table-column>
- <el-table-column label="市级" prop="city_name" width="200" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.city_name}}</div>
- </template>
- </el-table-column>
- <el-table-column label="区级/县级" prop="district_name" width="200" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.district_name}}</div>
- </template>
- </el-table-column>
- <el-table-column label="乡/镇/街道" prop="street_name" width="200" align="center">
- <template slot-scope="scope">
- <div>{{scope.row.street_name}}</div>
- </template>
- </el-table-column>
- <el-table-column label="社区" prop="community_name" align="center">
- <template slot-scope="scope">
- <div> <span>{{scope.row.community_name}}</span> </div>
- </template>
- </el-table-column>
- <el-table-column label="创建时间" prop="updated_at" align="center">
- <template slot-scope="scope">
- <div>
- {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
- </div>
- </template>
- </el-table-column>
- <el-table-column label="更新时间" prop="updated_at" align="center">
- <template slot-scope="scope">
- <div>
- {{scope.row.updated_at|dateTimeFormat('Y-m-d H:i:s')}}
- </div>
- </template>
- </el-table-column>
- <el-table-column label="操作" prop="action" align="center">
- <template slot-scope="scope">
- <el-button type="text" size="small" @click="editStoreCommunity(scope.row)">编辑</el-button>
- <el-button type="text" size="small" @click="deleteStoreCommunity(scope.row)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- <div style="text-align: right;margin: 20px 0;">
- <el-pagination @current-change="pagination" background layout="prev, pager, next" :page-count="pageCount"></el-pagination>
- </div>
- </div>
- </el-card>
- <el-dialog :visible.sync="dialogVisible" width="30%" :before-close="handleClose" :close-on-click-modal="false">
- <template>
- <el-form :model="ruleForm" :rules="rules" size="small" ref="ruleForm" label-width="100px"
- @submit.native.prevent>
- <el-card shadow="never">
- <el-col :span="50">
- <el-form-item label="社区名称" prop="community_name">
- <el-input v-model="ruleForm.community_name" placeholder="请输入社区名称,最多20个字"></el-input>
- </el-form-item>
- </el-col>
- </el-card>
- <div style="display: flex;justify-content: end">
- <el-button :loading="btnLoading" class="button-item" style="margin-top: 24px;"
- @click="handleCancel" size="small">取消
- </el-button>
- <el-button :loading="btnLoading" class="button-item" type="primary" style="margin-top: 24px;"
- @click="editForm('ruleForm')" size="small">确定
- </el-button>
- </div>
- </el-form>
- </template>
- </el-dialog>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data: {
- searchData: {
- province_name: '',
- city_name: '',
- district_name: '',
- street_name: '',
- community_name: '',
- start_time: '',
- end_time: '',
- },
- ruleForm:{
- 'community_name':''
- },
- btnLoad: false,
- btnLoading:false,
- dialog: {
- createUpload: false,
- execLog: false,
- },
- rules: {
- name: [{
- required: true,
- message: '请输入社区名称',
- trigger: 'change'
- },
- {
- validator: (rule, value, callback) => {
- if (value.length > 20 || value.length < 0) {
- callback('最大长度在1-20个字内');
- }
- callback();
- }
- },
- ],
- },
- dates: null,
- currPage: 1,
- pageCount: 0,
- loading: false,
- communityList: [],
- dialogLoading: false,
- dialogVisible: false,
- },
- mounted() {
- this.loadData();
- },
- methods: {
- searchs() {
- this.currPage = 1;
- this.loadData();
- },
- handleCancel() {
- this.dialogVisible = false; // 关闭弹框
- // 可以在这里添加更多的取消逻辑
- },
- clereSearch() {
- this.searchData.province_name = '';
- this.searchData.city_name = '';
- this.searchData.district_name = '';
- this.searchData.street_name = '';
- this.searchData.community_name = '';
- this.currPage = 1;
- this.loadData();
- },
- // 选中时间
- selectedDates(e) {
- if (e) {
- this.searchData.start_time = e[0];
- this.searchData.end_time = e[1];
- } else {
- this.searchData.start_time = '';
- this.searchData.end_time = '';
- }
- this.currPage = 1;
- this.loadData();
- },
- // 标签页切换
- handleTabClick(e) {
- this.loadData();
- },
- loadData() {
- this.loading = true;
- request({
- params: {
- r: 'store/store-community/index',
- page: this.currPage,
- ...this.searchData,
- },
- method: 'get',
- }).then(e => {
- this.loading = false;
- console.log(e.data)
- if (e.status == 200) {
- this.communityList = e.data.data.list;
- this.pageCount = e.data.data.page_count;
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log('错误信息为',e)
- this.loading = false;
- });
- },
- // 编辑
- add(id) {
- navigateTo({
- r: 'store/store-community/add',
- });
- },
- editStoreCommunity(e){
- this.ruleForm.community_name = e.community_name;
- this.ruleForm.province_id = e.province_id;
- this.ruleForm.city_id = e.city_id;
- this.ruleForm.district_id = e.district_id;
- this.ruleForm.street_id = e.street_id;
- this.ruleForm.community_id = e.id;
- this.dialogVisible = true;
- },
- handleClose(done) {
- done();
- },
- deleteStoreCommunity(e){
- this.loading = true;
- this.$confirm('此操作将删除社区, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- request({
- params: {
- r: 'store/store-community/delete',
- },
- method: 'post',
- data: {
- community_id: e.id,
- }
- }).then(e => {
- if (e.data.code == 0) {
- this.loading = false;
- this.$message.success(e.data.msg);
- this.dialogVisible = false;
- this.loadData();
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log('报错信息为:')
- console.log(e)
- this.$message.error(e);
- })
- }).catch(() => {
- this.loading = false;
- this.$message({
- type: 'info',
- message: '已取消删除'
- });
- });
- },
- editForm(){
- this.loading = true;
- request({
- params: {
- r: 'store/store-community/edit',
- },
- method: 'post',
- data: {
- form: this.ruleForm,
- }
- }).then(e => {
- if (e.data.code == 0) {
- this.$message.success(e.data.msg);
- this.dialogVisible = false;
- this.loadData();
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- console.log('报错信息为:')
- console.log(e)
- this.$message.error(e);
- })
- },
- pagination(currentPage) {
- let self = this;
- self.currPage = currentPage;
- self.loadData();
- }
- }
- });
- </script>
- <style>
- .el-tabs__header {
- font-size: 16px;
- }
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .input-item {
- width: 250px;
- margin-right: 40px;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- .table-body {
- padding: 20px;
- background-color: #fff;
- }
- .table-body .el-button {
- /* padding: 0 !important; */
- padding: 9px;
- border: 0;
- margin: 0 5px;
- }
- .input-item {
- width: 250px;
- margin: 0 0 20px;
- display: inline-block;
- }
- .input-item .el-input__inner {
- border-right: 0;
- }
- .input-item .el-input__inner:hover {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input__inner:focus {
- border: 1px solid #dcdfe6;
- border-right: 0;
- outline: 0;
- }
- .input-item .el-input-group__append {
- background-color: #fff;
- border-left: 0;
- width: 10%;
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- padding: 0;
- }
- .input-item .el-input-group__append .el-button {
- margin: 0;
- }
- .batch {
- margin: 0 0 20px;
- display: inline-block;
- }
- .batch .el-button {
- padding: 9px 15px !important;
- }
- .el-table th>.cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .el-table__footer-wrapper,
- .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- .el-table .el-button {
- padding: 0 !important;
- border: 0;
- margin: 0 5px;
- }
- #app .copy .el-input-group__append {
- background-color: #409EFF;
- border-color: #409EFF;
- padding: 0 10px;
- }
- #app .table-body .copybtn {
- color: #fff;
- padding: 0 30px;
- }
- .el-alert {
- padding: 0;
- padding-left: 5px;
- padding-bottom: 5px;
- }
- .el-alert--info .el-alert__description {
- color: #606266;
- }
- .el-alert .el-button {
- margin-left: 20px;
- }
- .el-alert__content {
- display: flex;
- align-items: center;
- }
- .table-body .el-alert__title {
- margin-top: 5px;
- font-weight: 400;
- }
- .el-table th>.cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .el-table__footer-wrapper,
- .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- .item-box {
- margin-right: 20px;
- }
- .flex {
- display: flex;
- align-items: center;
- }
- .input-title {
- margin-right: 15px;
- }
- .item-box .label {
- margin-right: 8px;
- }
- .com-share-pop {
- display: inline-block;
- }
- .stat-item {
- margin: 10px 0px;
- padding-left: 7px;
- color: #A2A2A2;
- }
- .stat-item>span {
- margin: 0px 10px;
- }
- .user_img{
- position: relative;
- margin-right: 8px;
- /* height: 50px;
- width: 50px; */
- }
- .default-avatar{
- width: 50px;
- height: 50px;
- border-radius: 50%;
- margin-right: 8px;
- }
- .uer-nickname {
- flex: 1;
- }
- </style>
|