| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- <?php
- use common\helpers\ComponentHelper;
- ComponentHelper::loadComponentView('com-qq-map');
- ?>
- <style>
- .el-table th>.cell {
- color: #333;
- font-weight: bold;
- font-size: 14px;
- }
- .table1 .el-table__footer-wrapper,
- .table1 .el-table__header-wrapper {
- border-bottom: 1.4px solid #D6D6D6;
- }
- .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>
- <div id="app">
- <div class="table-body" style="min-width: 1000px;">
- <div slot="header" class="clearfix" style="height: 20px;">
- <span>小区管理</span>
- <el-button style="float: right; padding: 3px 12px;margin-left: 20px;height: 32px;" type="primary" @click="onCreate">添加小区</el-button>
- </div>
- <div slot="header" class="clearfix" style="margin-top: 20px;">
- <div class="demo-input-suffix" style="margin-top: 20px;margin-bottom: 10px;">
- <el-input size="small" style="width:300px;margin-right: 20px;" placeholder="请输入小区名称/ID" v-model="search.keyword" clearable></el-input>
- <el-input size="small" style="width:300px;margin-right: 20px;" placeholder="输入地址" v-model="search.address" clearable></el-input>
- <el-button type="primary" size="small" @click="toSearch">搜索</el-button>
- </div>
- </div>
- <template>
- <el-table :data="list" stripe style="width: 100%" v-loading="listLoading" class="table1">
- <el-table-column prop="id" label="ID" align="center" width="160"></el-table-column>
- <el-table-column label="小区名称" prop="community_name"></el-table-column>
- <el-table-column label="地址" prop="fully_address" align="left">
- <template slot-scope="scope">
- {{scope.row.area}}{{scope.row.street}}
- </template>
- </el-table-column>
- <el-table-column label="启用" align="center" width="80">
- <template slot-scope="scope">
- <el-switch v-model="scope.row.status" :active-value="1" :inactive-value="0"
- @change="onChangeStatus(scope.row)"></el-switch>
- </template>
- </el-table-column>
- <el-table-column label="添加时间" width="180" align="center">
- <template slot-scope="scope">
- {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
- </template>
- </el-table-column>
- <el-table-column label="操作" width="120" align="center">
- <template slot-scope="scope">
- <el-button @click="onEditRow(scope.row, scope.$index)" type="text" size="mini">编辑</el-button>
- <el-popconfirm @confirm="onDelete(scope.row, scope.$index)" title="您真的要删除当前小区吗?">
- <el-button type="text" slot="reference" style="color: #F56C6C">删除</el-button>
- </el-popconfirm>
- </template>
- </el-table-column>
- </el-table>
- <div flex="main:right cross:center" style="margin-top: 20px;">
- <el-pagination v-if="pagination" :page-size="pagination.defaultPageSize"
- style="display: inline-block;float: right;" background @current-change="pageChange"
- layout="prev, pager, next" :total="pagination.totalCount">
- </el-pagination>
- </div>
- </template>
- <el-dialog :visible.sync="createDialogShow" width="600px" title="添加/修改小区" center>
- <div v-loading="loading">
- <el-form ref="form" :model="form" size="small" label-width="120px">
- <el-form-item label="省市区" prop="address">
- <el-cascader
- @change="addressChange"
- :options="district"
- :props="props"
- v-model="address">
- </el-cascader>
- </el-form-item>
- <el-form-item label="镇">
- <el-select v-model="form.town_id" placeholder="请选择镇">
- <el-option
- v-for="item in town_list"
- :key="item.id"
- :label="item.name"
- :value="item.id">
- </el-option>
- </el-select>
- </el-form-item>
- <el-form-item label="小区名称" prop="community_name" :rules="[
- {required: true, message: '小区名称不能为空'}
- ]">
- <el-input v-model="form.community_name"></el-input>
- </el-form-item>
- <el-form-item label="经纬度" prop="lat_lng" :rules="[
- {required: true, message: '小区名称不能为空'}
- ]">
- <el-input :disabled="true" v-model="form.lat_lng">
- <template #append>
- <com-qq-map
- @on-hide="onHideMapDialog"
- @map-submit="mapEvent"
- :address="form.fully_address"
- :lat="form.lat"
- :long="form.lng"
- :show="mapDialogShow"
- :append-to-body="true"
- >
- 展开地图
- </com-qq-map>
- </template>
- </el-input>
- </el-form-item>
- <el-form-item label="详细地址" prop="fully_address" :rules="[
- {required: true, message: '详细地址不能为空'}
- ]">
- <el-input :disabled="true" v-model="form.fully_address"></el-input>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="onCancel" type="default" size="small">取消</el-button>
- <el-button type="primary" :loading="btnLoading" style="margin-bottom: 10px;" size="small"
- @click="onSubmit">保存</el-button>
- </span>
- </el-dialog>
- </div>
- </div>
- <script>
- const app = new Vue({
- el: '#app',
- data() {
- return {
- btnLoading: false,
- createDialogShow: false,
- listLoading: false,
- list: [],
- pagination: {
- total: 0
- },
- loading: false,
- LoadDataType: -1, //默认显示全部数据
- dialogFormVisible: false, //默认不显示弹窗
- group_buy_attr_list: [],
- goodsDetail: {},
- dialogLoading:false,
- commander_level_limit_text:'',
- user_level_limit_text:'',
- level_map:null,
- selectDate:'',
- search: {
- page: 1,
- limit:10,
- keyword: '',
- address: '',
- },
- levelList:[
- ],
- show: false,
- level: {
- show: false,
- area: null,
- },
- current_area:null,
- form: {
- id: 0,
- community_name: '',
- province_id: 0,
- city_id: 0,
- district_id: 0,
- town_id: '',
- province: '',
- city: '',
- district: '',
- town: '',
- street: '',
- lng: '',
- lat: '',
- fully_address: '',
- lat_lng: '',
- addressComponents: null
- },
- district: [],
- town_id: '',
- town_list: [],
- address: null,
- props: {
- value: 'id',
- label: 'name',
- children: 'list',
- },
- mapDialogShow: false
- }
- },
- methods: {
- //状态按钮的点击事件
- toSearch() {
- this.search.page = 1;
- this.loadData();
- },
- toSearchActivity() {
- this.loadData()
- },
- update(row) {
- this.$confirm('删除该区域代理, 是否继续?', '提示', {
- confirmButtonText: '确定',
- cancelButtonText: '取消',
- type: 'warning'
- }).then(() => {
- this.loading = true;
- request({
- params: {
- r: 'area/default/delete',
- },
- method: 'post',
- data: {
- id: row.id,
- }
- }).then(e => {
- let res = e.data;
- this.listLoading = false;
- if (res.code === 0) {
- this.$message.success(res.msg);
- this.loadData();
- } else {
- this.$message.error(res.msg);
- }
- }).catch(e => {});
- }).catch(() => {
- this.$message({
- type: 'info',
- message: '系统错误'
- });
- });
- },
- pageChange(page) {
- this.search.page = page;
- this.loadData();
- },
- // 请求获取数据--获取拼团商品列表
- loadData() {
- this.listLoading = true;
- let params = {
- r: 'area/community/index'
- };
- params = Object.assign(params, this.search);
- request({
- params: params,
- method: 'get',
- }).then(e => {
- let res = e.data;
- this.listLoading = false;
- if (res.code === 0) {
- this.list = res.data.list;
- this.level_map = res.data.level_map;
- this.pagination = res.data.pagination; //拿到关于页码页容量的数据
- } else {
- this.$message.error(res.msg);
- }
- }).catch(e => {});
- },
- editClick() {
- this.show = true;
- },
- levelSuccess() {
- this.loadData();
- },
- editLevel(row) {
- this.level.show = true;
- this.current_area = row;
- },
- onCancel() {
- this.createDialogShow = false
- },
- onCreate() {
- this.form = {
- id: 0,
- community_name: '',
- province_id: 0,
- city_id: 0,
- district_id: 0,
- town_id: '',
- province: '',
- city: '',
- district: '',
- town: '',
- street: '',
- lng: '',
- lat: '',
- fully_address: '',
- lat_lng: '',
- addressComponents: null
- }
- this.address = null
- this.createDialogShow = true
- this.getDistrict(3);
- },
- addressChange(e) {
- this.town_list = []
- this.town_id = '';
- if (e.length === 3) {
- this.form.province_id = e[0]
- this.form.city_id = e[1]
- this.form.district_id = e[2]
- this.getTownList(e[2]);
- }
- },
- setFullyAddress() {
- let address = '';
- for (let districtKey in this.district) {
- if (this.district[districtKey].id === this.form.province_id) {
- address += this.district[districtKey].name
- for (let districtElementKey in this.district[districtKey].list) {
- if (this.district[districtKey].list[districtElementKey].id === this.form.city_id) {
- address += this.district[districtKey].list[districtElementKey].name
- for (let districtElementChildKey in this.district[districtKey].list[districtElementKey].list) {
- if (this.district[districtKey].list[districtElementKey].list[districtElementChildKey].id === this.form.district_id) {
- address += this.district[districtKey].list[districtElementKey].list[districtElementChildKey].name
- }
- }
- }
- }
- }
- }
- for (let townListKey in this.town_list) {
- if (this.form.town_id === this.town_list[townListKey].id) {
- address += this.town_list[townListKey].name
- }
- }
- address += this.form.community_name
- this.form.fully_address = address
- },
- getTownList(district_id) {
- request({
- params: {
- r: 'area/default/get-town-list',
- district_id: district_id
- },
- }).then(e => {
- if (e.data.code === 0) {
- this.town_list = e.data.data.list;
- }
- }).catch(e => {
- });
- },
- // 获取省市区列表
- getDistrict(level) {
- if (level) {
- level1 = level;
- } else{
- level1 = 1;
- }
- request({
- params: {
- r: 'area/default/district',
- level: level1
- },
- }).then(e => {
- if (e.data.code == 0) {
- this.district = e.data.data.district;
- }
- }).catch(e => {
- });
- },
- areaClick(row) {
- //console.log('选择了用户row='+JSON.stringify(row))
- this.edit.id = row.id
- },
- onSubmit() {
- this.$refs['form'].validate((valid) => {
- if (valid) {
- this.loading = true
- request({
- method: 'post',
- params: {
- r: 'area/community/create',
- },
- data: this.form
- }).then(e => {
- this.loading = false;
- if (e.data.code === 0) {
- this.createDialogShow = false
- this.search.page = 1;
- this.loadData()
- this.$message.success(e.data.msg);
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- this.loading = false;
- });
- } else {
- console.log(valid)
- }
- })
- },
- mapEvent(e) {
- this.form.lat_lng = e.lat + ',' + e.long;
- this.form.lng = e.long;
- this.form.lat = e.lat;
- this.form.fully_address = e.address;
- this.form.addressComponents = e.address_component
- this.form.street = e.address_component.street_number
- this.mapDialogShow = false
- },
- onShowMap(e) {
- if (this.form.id === 0) this.setFullyAddress()
- this.mapDialogShow = true
- },
- onHideMapDialog(e) {
- this.mapDialogShow = false
- },
- onDelete(item, index) {
- request({
- method: 'post',
- params: {
- r: 'area/community/delete',
- },
- data: {id: item.id}
- }).then(e => {
- this.loading = false;
- if (e.data.code === 0) {
- this.$message.success(e.data.msg);
- this.list.splice(index, 1)
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- },
- onChangeStatus(item) {
- request({
- method: 'post',
- params: {
- r: 'area/community/status',
- },
- data: {id: item.id, status: item.status}
- }).then(e => {
- this.loading = false;
- if (e.data.code === 0) {
- this.$message.success(e.data.msg);
- } else {
- this.$message.error(e.data.msg);
- }
- }).catch(e => {
- });
- },
- onEditRow(item, index) {
- this.onCreate()
- this.address = [
- item.province_id,
- item.city_id,
- item.district_id,
- ];
- console.log(item.id)
- this.getTownList(item.district_id);
- this.form = item
- this.form.lat_lng = item.lat + ',' + item.lng;
- }
- },
- // 加载的时候获取到列表页
- mounted() {
- // 数据初始化
- this.LoadDataType = -1;
- this.loadData();
- }
- })
- </script>
|