guoshilong
2023-11-02 95252960b12c3142171881b5449d3dab14d6b2cf
场所采集上报
2 files modified
1 files added
263 ■■■■■ changed files
api/place/place.js 9 ●●●●● patch | view | raw | blame | history
subPackage/workbench/components/lineItem.vue 7 ●●●● patch | view | raw | blame | history
subPackage/workbench/views/cscj.vue 247 ●●●●● patch | view | raw | blame | history
api/place/place.js
New file
@@ -0,0 +1,9 @@
import http from '@/http/api.js'
export const add = (data) => {
    return http.request({
        url: 'blade-place/place/add',
        method: 'POST',
        data: data
    })
}
subPackage/workbench/components/lineItem.vue
@@ -10,7 +10,12 @@
            </view>
            <view class="r" v-else>
                <slot name="item.useSlot" scope="item"></slot>
                <!-- #ifdef H5-->
                <slot :name="item.useSlot" :scope="item"></slot>
                <!-- #endif -->
                <!-- #ifdef MP -->
                <slot name="{{item.slot}}"></slot>
                <!-- #endif -->
            </view>
        </view>
    </view>
subPackage/workbench/views/cscj.vue
@@ -6,18 +6,20 @@
            </view>
            <view class="item">
                <!--                 <u-form-item class="form-item" labelWidth="100" label="场所地址:" required prop="location">
                    <u--input border="none" v-model="form.location" placeholder="请选择场所地址">
                <u-form-item @click="showPicker = true" class="form-item" labelWidth="100" label="楼栋:" required
                    prop="buildingCode">
                    <u--input border="none" disabledColor="#ffffff" v-model="form.building" placeholder="请选择">
                    </u--input>
                </u-form-item> -->
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
                <u-form-item class="form-item" labelWidth="100" label="场所名称:" required prop="placeName">
                    <u--input border="none" v-model="form.placeName" placeholder="请输入当前位置">
                    <u--input border="none" v-model="form.placeName" placeholder="请输入">
                    </u--input>
                </u-form-item>
                <u-form-item @click="popup" class="form-item" labelWidth="100" label="标签:" required prop="label">
                    <u--input border="none" placeholder="请选择地址标签">
                    <u--input border="none" disabled disabledColor="#ffffff" placeholder="请选择">
                    </u--input>
                    <u-icon slot="right" name="arrow-right"></u-icon>
                </u-form-item>
@@ -28,13 +30,13 @@
                    </view>
                </view>
                <u-form-item class="form-item" labelWidth="100" label="备注:" prop="location">
                    <u--input border="none" v-model="form.remark" placeholder="请输入备注">
                <u-form-item class="form-item" labelWidth="100" label="备注:" prop="remark">
                    <u--input border="none" v-model="form.remark" placeholder="请输入">
                    </u--input>
                </u-form-item>
                <u-form-item class="form-item" labelWidth="100" label="经纬度:" prop="location">
                    <u--input border="none" v-model="form.jwd" placeholder="请输入经纬度">
                    <u--input border="none" disabled disabledColor="#ffffff" v-model="form.jwd" placeholder="请输入">
                    </u--input>
                </u-form-item>
            </view>
@@ -44,12 +46,12 @@
            </view>
            <view class="item">
                <u-form-item class="form-item" labelWidth="100" label="场所负责人:" prop="principal">
                    <u--input border="none" v-model="form.principal" placeholder="请输入场所负责人">
                <u-form-item class="form-item" labelWidth="100" required label="场所负责人:" prop="username">
                    <u--input border="none" v-model="form.username" placeholder="请输入">
                    </u--input>
                </u-form-item>
                <u-form-item class="form-item" labelWidth="100" label="手机号:" prop="location">
                    <u--input border="none" v-model="form.phone" placeholder="请输入手机号">
                <u-form-item class="form-item" labelWidth="100" required label="手机号:" prop="phone">
                    <u--input border="none" v-model="form.phone" placeholder="请输入">
                    </u--input>
                </u-form-item>
            </view>
@@ -102,7 +104,8 @@
                        <view class="orange item">85.9</view>
                        <view class="green item"></view>
                    </view>
                </template></box-title>
                </template>
            </box-title>
        </view>
        <view class="item">
@@ -119,7 +122,7 @@
        <view class="bottom">
            <view class="btn">
                <u-button @click="addRent" type="primary" text="提交"></u-button>
                <u-button @click="submit" type="primary" text="提交"></u-button>
            </view>
        </view>
@@ -132,6 +135,11 @@
        </uni-popup>
        <u-picker :show="showPicker" :defaultIndex="defaultIndex" ref="uPicker" keyName="name" :loading="pickerLoading"
            :columns="pickColumns" @change="changeHandler" @confirm="confirmPicker"
            @cancel="showPicker = false"></u-picker>
    </view>
</template>
@@ -141,6 +149,12 @@
    import {
        getLabelList
    } from "@/api/label/label";
    import {
        getDoorplateAddressList
    } from "@/api/doorplateAddress/doorplateAddress";
    import {
        add
    } from "@/api/place/place";
    export default {
        mixins: [uploadMixin],
        components: {
@@ -148,13 +162,50 @@
        },
        data() {
            return {
                form: {},
                showPicker: false,
                pickerLoading: false,
                pickColumns: [],
                defaultIndex: [0, 0, 0, 0, 0],
                selectValue: [],
                form: {
                    buildingCode: "",
                    label: "",
                    remark: "",
                    imageUrls: [],
                },
                rules: {
                    'userInfo.name': {
                    'buildingCode': {
                        type: 'string',
                        required: true,
                        message: '请填写姓名',
                        message: '请选择楼栋',
                        trigger: ['blur', 'change']
                    },
                    'placeName': {
                        type: 'string',
                        required: true,
                        message: '请输入场所名称',
                        trigger: ['blur', 'change']
                    },
                    'label': {
                        type: 'string',
                        required: true,
                        message: '请选择标签',
                        trigger: ['blur', 'change'],
                    },
                    'username': {
                        type: 'string',
                        required: true,
                        message: '请输入场所负责人',
                        trigger: ['blur', 'change'],
                    },
                    'phone': {
                        type: 'string',
                        required: true,
                        message: '请输入手机号',
                        trigger: ['blur', 'change'],
                    },
                },
@@ -267,7 +318,17 @@
                showLabelList: []
            }
        },
        created() {},
        watch: {
            activeIds: {
                handler(newVal) {
                    this.form.label = newVal.join(",")
                }
            }
        },
        created() {
            this.buildColumn()
        },
        mounted() {
        },
@@ -276,8 +337,156 @@
        },
        onShow() {
            this.getLabel()
            this.getLocation()
        },
        methods: {
            //表单提交
            submit() {
                const that = this
                this.$refs.form.validate().then(valid => {
                    if (valid) {
                        if (this.form.images.length > 0) {
                            let urls = []
                            this.form.images.forEach(e => {
                                urls.push(e.url)
                            })
                            this.form.imageUrls = urls.join(",")
                        }
                        add(this.form).then(res => {
                            uni.showToast({
                                icon: 'success',
                                title: '提交成功',
                                success() {
                                    setTimeout(() => {
                                        that.$u.func.globalNavigator(
                                            "/pages/home/index", "switchTab")
                                    }, 1000)
                                }
                            })
                        })
                    }
                })
            },
            async buildColumn() {
                //设置街道
                const townStreet = await this.getDoorplateAddressList(null, "townStreet")
                this.setColumn(townStreet, 0)
                //设置社区
                const nei = await this.getDoorplateAddressList(townStreet[0].code, "nei")
                this.setColumn(nei, 1)
                //设置路
                const streetRu = await this.getDoorplateAddressList(nei[0].code, "streetRu")
                this.setColumn(streetRu, 2)
                //设置地区
                const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
                this.setColumn(district, 3)
                //设置楼栋
                const building = await this.getDoorplateAddressList(district[0].code, "building")
                this.setColumn(building, 4)
            },
            setColumn(data, index) {
                this.$set(this.pickColumns, index, data)
            },
            getLocation() {
                const that = this
                uni.getLocation({
                    type: 'wgs84', // 坐标系类型
                    success: function(res) {
                        var latitude = res.latitude; // 维度
                        var longitude = res.longitude; // 经度
                        that.form.lng = longitude
                        that.form.lat = latitude
                        that.form.jwd = longitude + "," + latitude
                    },
                    fail: function(res) {
                        console.log('获取定位失败:' + res.errMsg);
                    }
                });
            },
            async getDoorplateAddressList(code, type) {
                const res = await getDoorplateAddressList(code, type)
                return res.data
            },
            confirmPicker(e) {
                console.log(e, "--------------------")
                if (e.value[4]) {
                    this.selectValue = e.value
                    let arr = this.selectValue.map(e => e.name)
                    this.form.building = arr.join("")
                    this.form.buildingCode = e.value[4].code
                }
                this.showPicker = false
            },
            async changeHandler(e) {
                const {
                    columnIndex,
                    index,
                    // 微信小程序无法将picker实例传出来,只能通过ref操作
                    picker = this.$refs.uPicker
                } = e
                console.log(e, "/*/*/*")
                let item = e.values[columnIndex][index]
                console.log(item, "-----------")
                //街道
                if (columnIndex === 0) {
                    //获取社区列表
                    const nei = await this.getDoorplateAddressList(item.code, "nei")
                    picker.setColumnValues(1, nei)
                    const streetRu = await this.getDoorplateAddressList(nei[0].code, "streetRu")
                    picker.setColumnValues(2, streetRu)
                    const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
                    picker.setColumnValues(3, district)
                    const building = await this.getDoorplateAddressList(district[0].code, "building")
                    picker.setColumnValues(4, building)
                }
                if (columnIndex === 1) {
                    const streetRu = await this.getDoorplateAddressList(item.code, "streetRu")
                    picker.setColumnValues(2, streetRu)
                    const district = await this.getDoorplateAddressList(streetRu[0].code, "district")
                    picker.setColumnValues(3, district)
                    const building = await this.getDoorplateAddressList(district[0].code, "building")
                    picker.setColumnValues(4, building)
                }
                if (columnIndex === 2) {
                    const district = await this.getDoorplateAddressList(item.code, "district")
                    picker.setColumnValues(3, district)
                    const building = await this.getDoorplateAddressList(district[0].code, "building")
                    picker.setColumnValues(4, building)
                }
                if (columnIndex === 3) {
                    const building = await this.getDoorplateAddressList(item.code, "building")
                    picker.setColumnValues(4, building)
                }
            },
            //弹出层打开
            popup() {
                this.$refs.uniPopup.open()
@@ -359,7 +568,7 @@
        .item {
            .form-item {
            /deep/ .form-item {
                background-color: #ffffff;
                padding: 2rpx 10px;
                border-bottom: 1px solid #eff1f3;