提交信息:

**新增功能:**
1. 新增 `AiUploader.vue` 组件中的 `withoutToken` 属性,允许用户选择是否使用 token 进行上传。
2. 新增 `AppPatrolReport.vue` 页面,用于事件上报,包括事件类型、描述、位置、所属网格等信息。
3. 新增 `SelectGird.vue` 页面,用于选择所属网格。
4. 新增 `back-icon.png` 图片资源。

**代码优化:**
1. 对 `AppPatrolReport.vue` 页面的样式进行了优化,提高了用户体验。

**修复问题:**
无

**备注:**
本次提交主要新增了事件上报功能,包括相关页面和组件,以及对代理配置的修改。
This commit is contained in:
liuye
2024-10-31 11:06:38 +08:00
parent 369002d676
commit 6a833be062
16 changed files with 521 additions and 1 deletions

View File

@@ -58,6 +58,10 @@ export default {
size: {default: 10 * 1024 * 1024}, size: {default: 10 * 1024 * 1024},
disabled: Boolean, disabled: Boolean,
sourceType: {default: () => ['album', 'camera']}, sourceType: {default: () => ['album', 'camera']},
withoutToken: {
type: Number,
default: 0,
},
}, },
computed: { computed: {
...mapState(['token']), ...mapState(['token']),
@@ -139,7 +143,8 @@ export default {
uni.hideLoading() uni.hideLoading()
} else { } else {
this.$http.post(this.api, formData, { this.$http.post(this.api, formData, {
params: {type: this.type} params: {type: this.type},
withoutToken: this.withoutToken == 1 ? true : false,
}).then((res) => { }).then((res) => {
if (res?.data) { if (res?.data) {
this.$emit('data', res.data) this.$emit('data', res.data)

View File

@@ -0,0 +1,258 @@
<template>
<div class="AppPatrolReport">
<div class="contents">
<u-form :model="forms" ref="uForm" label-width="auto" :border-bottom="false">
<u-form-item label="事件类型" prop="groupName" required :border-bottom="false" right-icon="arrow-right">
<span @click="show = true" class="right-span" :style="forms.groupName ? '' : 'color:#999;'">{{ forms.groupName || '请选择事件类型' }}</span>
<u-select v-model="show" :list="myList" value-name="id" label-name="groupName" @confirm="selectStatus"></u-select>
</u-form-item>
<u-form-item label="事件描述" prop="content" required :border-bottom="false" label-position="top" class="contents border">
<u-input v-model="forms.content" placeholder="请输入事件描述..." type="textarea" auto-height height="100" maxlength="500"/>
</u-form-item>
<u-form-item label="上报位置" prop="content" required :border-bottom="false" label-position="top" class="contents">
<u-input v-model="forms.mapInfo.address" placeholder="请输入上报位置..." type="textarea" auto-height height="60" maxlength="100"/>
</u-form-item>
<div class="line"></div>
<!-- <u-form-item label="上报位置" prop="mapInfo" required :border-bottom="false" class="border">
<span @click="toMap" class="right-span" :style="forms.mapInfo.address ? '' : 'color:#999;'">{{ forms.mapInfo.address || '请选择上报位置' }}</span>
</u-form-item> -->
<u-form-item label="所属网格" prop="girdName" required right-icon="arrow-right" :border-bottom="false">
<!-- <AiPagePicker type="gird" v-model="forms.girdId" @change="confirmGird" valueObj nodeKey="id" formType="2" class="right-span">
<AiMore v-model="forms.girdName" placeholder="请选择所属网格"/>
</AiPagePicker> -->
<span @click="toSelectGird" class="right-span" :style="forms.girdName ? '' : 'color:#999;'">{{ forms.girdName || '请选择所属网格' }}</span>
</u-form-item>
<div class="line"></div>
<u-form-item label="图片上传(最多9张)" prop="files" :border-bottom="false" class="avatars" label-position="top">
<AiUploader :def.sync="forms.files" multiple placeholder="上传图片" :limit="9" action="/admin/file/add2" :withoutToken="1"></AiUploader>
</u-form-item>
<div class="line"></div>
<u-form-item label="姓名" prop="name" required :border-bottom="false" class="border">
<u-input v-model="forms.name" placeholder="请输入姓名" />
</u-form-item>
<u-form-item label="联系方式" prop="phone" required :border-bottom="false" >
<u-input v-model="forms.phone" placeholder="请输入联系方式" />
</u-form-item>
<div class="line"></div>
</u-form>
</div>
<div class="btn" @click="confirm">
<span>提交</span>
</div>
</div>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: 'AppPatrolReport',
appName: '事件添加',
data() {
return {
forms: {
groupName: '',
groupId: '',
content: '',
mapInfo: {address: ''},
girdId: '',
girdName: '',
files: [],
name: '',
phone: ''
},
flag: false,
show: false,
myList: []
}
},
computed: {
...mapState(['user']),
},
onLoad() {
this.typeList()
uni.$on('selectGird', res => {
console.log(res)
this.forms.girdId = res.id
this.forms.girdName = res.girdName
})
},
onShow() {
document.title = '事件上报'
// this.forms.name = this.user.name
// this.forms.phone = this.user.phone
// this.forms.girdId = this.user.girdId
// this.forms.girdName = this.user.girdName
// uni.$on('chooseLat', res => {
// this.forms.mapInfo = {...res}
// })
},
methods: {
typeList() {
this.$http.post(`/app/appclapeventgroup/list?current=1&size=100000`, null, {
params: {
size: 9999,
},
withoutToken: true
}).then((res) => {
if (res.code == 0) {
this.myList = res.data.records
this.$forceUpdate()
}
})
},
selectStatus(e) {
this.forms.groupName = e[0].label
this.forms.groupId = e[0].value
},
confirmGird(v) {
this.forms.girdId = v.id
this.forms.girdName = v.girdName
},
toMap() {
uni.navigateTo({url: `./Map`})
},
toSelectGird() {
uni.navigateTo({url: `./SelectGird`})
},
confirm() {
if(this.flag) return
if (!this.forms.groupName) {
return this.$u.toast('请选择事件类型')
}
if (!this.forms.content) {
return this.$u.toast('请输入事件描述')
}
if (!this.forms.mapInfo.address) {
return this.$u.toast('请输入上报位置')
}
if (!this.forms.girdName) {
return this.$u.toast('请选择所属网格')
}
if (!this.forms.name) {
return this.$u.toast('请输入姓名')
}
if (!this.forms.phone) {
return this.$u.toast('请输入手机号')
}
this.flag = true
this.$http.post(`/app/appclapeventinfo/addOrUpdate`, {...this.forms, ...this.forms.mapInfo}, {
withoutToken: true
}).then((res) => {
if (res.code == 0) {
this.$u.toast('事件上报成功')
uni.$emit('getListInit')
setTimeout(() => {
uni.navigateBack()
}, 600)
}
})
},
},
}
</script>
<style scoped lang="scss">
.AppPatrolReport {
height: 100%;
.contents {
padding-bottom: 140px;
::v-deep .u-form {
.u-form-item {
// padding: 0 45px !important;
.u-form-item__body {
.u-form-item--right__content__slot {
padding-bottom: 0;
.u-input {
text-align: right !important;
}
}
}
}
.u-form-item:first-child {
.u-form-item__body {
border-bottom: 1px solid #ddd;
}
}
.line {
height: 24px;
background: #f3f6f9;
}
.contents {
padding-bottom: 20px !important;
.u-form-item__body {
.u-form-item--right__content__slot {
.u-input {
text-align: left !important;
}
}
}
}
.avatars {
padding-bottom: 20px !important;
.u-form-item__body {
// .default {
// width: 160px;
// height: 160px;
// }
}
}
}
}
.border {
::v-deep .u-form-item__body {
border-bottom: 1px solid #ddd;
}
}
.btn {
position: fixed;
bottom: 0;
width: 100%;
box-sizing: border-box;
background: #3975c6;
padding: 34px 0;
text-align: center;
font-size: 32px;
font-weight: 500;
color: #ffffff;
}
.right-span {
display: inline-block;
width: 100%;
text-align: right;
::v-deep .u-icon__label {
font-size: 28px!important;
}
::v-deep .uicon-arrow-right{
color: #c0c4cc!important;
}
}
::v-deep .uni-input-placeholder {
color: #999!important;
font-size: 28px!important;
}
}
</style>

View File

@@ -0,0 +1,257 @@
<template>
<div class="SelectGird">
<div class="header-middle">
<div class="hint">
<span v-for="(item, index) in slectList" :key="index">
<span v-if="index" style="margin:0 4px;" v-text="`/`"/>
<span style="color:#3F8DF5" @click="girdNameClick(item, index)" v-text="item.girdName"/>
</span>
</div>
<div class="showTypes">
<div v-if="treeList.length > 0">
<div class="cards" v-for="(item, index) in treeList" :key="index" @click="itemClick(item)">
<div class="imges">
<img src="./components/img/xzh.png" alt="" class="imgselect" v-if="item.isChecked"
@click.stop="girdClick(item, index)"/>
<img src="./components/img/xz.png" alt="" class="imgselect" v-else @click.stop="girdClick(item, index)"/>
<img src="./components/img/gird--select-icon.png" alt="" class="avatras"/>
</div>
<div class="rightes fill">
<div class="applicationNames fill">{{ item.girdName }}</div>
<u-icon v-if="item.hasChildren" @click="itemClick(item)" name="arrow-right" color="#ddd"/>
</div>
</div>
</div>
<AiEmpty class="emptyWrap" v-else/>
</div>
</div>
<div class="subBtn" @click="submit">
<div>确定选择</div>
</div>
</div>
</template>
<script>
export default {
name: 'SelectGird',
data() {
return {
SelectGird: {},
allData: null,
treeList: [],
slectList: [],
userList: [],
parentGirdId: '',
isFormMap: 0, //1为网格地图 一级不允许选中
}
},
// computed: {
// ...mapState(['user']),
// isMyGirds() {
// return !!this.$route.query.self
// },
// isGridMember() {
// return this.user.girdCheckType > 0
// }
// },
onLoad(option) {
// if (option.isFormMap) {
// this.isFormMap = option.isFormMap
// }
// this.isGridMember ? this.getAllGrids() : this.$u.toast('当前人员不是网格员或网格管理员')
this.getAllGrids()
},
methods: {
getAllGrids() {
this.slectList = []
// let {girdMemberId} = this.user,
// url = `/app/appgirdinfo/queryAppGirdInfoByGirdLevel`,
// params = {girdMemberId}
// if (this.isMyGirds) {
// url = `/app/appgirdmemberinfo/queryMyGirdListByLevel2AndUser`
// params = {}
// }
this.$http.post(`/app/appgirdinfo/listByInfo?parentGirdId=96a62329e2204914a8b657d45b5aa4a4`, null, {
withoutToken: true
}).then((res) => {
if (res?.data) {
let parents = res.data.map(e => e.parentGirdId)
this.allData = res.data.map(e => ({...e, hasChildren: parents.includes(e.id)}))
this.treeInit()
}
})
},
treeInit() {
let last = uni.getStorageSync("lastSelectedGrid")
if (last) {
this.$http.post("/app/appgirdinfo/listFatherGirdInfo", null, {
params: {girdId: last},
withoutToken: true
}).then(res => {
if (res?.data) {
this.slectList = [{girdName: '可选范围', id: ''}, res.data].flat()
this.getGridsByGridMemberAndParent({id: last})
}
})
} else {
this.treeList = this.allData.filter(e => !e.parentGirdId || this.isMyGirds)
this.treeList.map((item) => item.isChecked = false)
let obj = {girdName: '可选范围', id: ''}
this.slectList.push(obj)
}
},
itemClick(row) {
if (row.hasChildren) {
let obj = {
girdName: row.girdName,
id: row.id,
}
this.slectList.push(obj)
this.getGridsByGridMemberAndParent(row)
}
},
getGridsByGridMemberAndParent(row) {
let {id: parentGirdId} = row
this.treeList = this.allData.filter(e => e.parentGirdId == parentGirdId)
},
girdNameClick(row, index) {
this.userList = []
if (!index) { //第一级别
this.slectList = []
uni.setStorageSync("lastSelectedGrid", '')
this.treeInit()
} else {
var list = []
this.slectList.map((item, i) => {
if (i <= index) {
list.push(item)
}
})
this.slectList = list
this.getGridsByGridMemberAndParent(row)
}
},
girdClick(row, index) {
if (this.treeList[index].isChecked) {//取消
this.treeList[index].isChecked = false
this.SelectGird = {}
} else {
this.treeList.map((item) => {
item.isChecked = false
})
this.treeList[index].isChecked = true
this.SelectGird = row
}
this.$forceUpdate()
},
submit() {
if (this.SelectGird.id != null) {
//uni.setStorageSync("lastSelectedGrid", this.SelectGird.parentGirdId)
uni.navigateBack({
success: () => {
uni.$emit("selectGird", this.SelectGird)
}
})
} else {
return this.$u.toast('请选择网格')
}
}
}
}
</script>
<style scoped lang="scss">
.SelectGird {
min-height: 100vh;
background: #fff;
padding-bottom: 140px;
box-sizing: border-box;
.header-middle {
.hint {
padding: 28px 20px 28px 32px;
line-height: 56px;
box-shadow: 0px 1px 0px 0px #e4e5e6;
font-size: 30px;
font-weight: 500;
word-break: break-all;
}
.showTypes {
.cards {
display: flex;
align-items: center;
height: 120px;
line-height: 120px;
// background: pink;
padding: 0 0 0 32px;
.imges {
display: flex;
align-items: center;
// width: 200px;
.imgselect {
width: 48px;
height: 48px;
vertical-align: middle;
}
.avatras {
width: 74px;
height: 74px;
border-radius: 8px;
margin-left: 36px;
}
}
img {
width: 74px;
height: 74px;
border-radius: 8px;
}
.rightes {
display: flex;
border-bottom: 1px solid #e4e5e6;
padding: 0 16px;
.applicationNames {
display: inline-block;
font-size: 36px;
font-weight: 500;
color: #333333;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
vertical-align: bottom;
}
}
}
}
}
.subBtn {
position: fixed;
bottom: 0;
left: 0;
width: 100%;
height: 118px;
background: #f4f8fb;
div {
width: 192px;
height: 80px;
line-height: 80px;
text-align: center;
background: #1365dd;
border-radius: 4px;
font-size: 32px;
color: #fff;
margin: 20px 34px 0 0;
float: right;
}
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 545 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 866 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 892 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB