This commit is contained in:
liuye
2022-10-08 16:58:38 +08:00
5 changed files with 350 additions and 29 deletions

View File

@@ -27,7 +27,7 @@ export default {
return hash == "#resourceClassification" ? resourceClassification :
hash == "#resourceManagement" ? resourceManagement :
hash == "#resourceMap" ? resourceMap :
hash == "#addResource" ? addResource:resourceList
hash == "#addResource" ? addResource : resourceList
}
},
components: {

View File

@@ -1,15 +1,292 @@
<template>
<div>新增资源</div>
<section class="addResource">
<ai-detail>
<template #title>
<ai-title title="添加社会资源" isShowBack isShowBottomBorder @onBackClick="cancel"></ai-title>
</template>
<template slot="content">
<ai-card>
<template #content>
<el-form ref="form" class="ai-form" :model="form" :rules="rules" label-width="110px" label-position="right">
<el-form-item label="资源分类" style="width: 100%;" prop="categoryId">
<ai-select v-model="form.categoryId" :selectList="categoryList"/>
</el-form-item>
<el-form-item style="width: 100%" label="资源名称" prop="resourceName">
<el-input size="small" placeholder="请输入资源名称" show-word-limit v-model="form.resourceName" :maxlength="20"></el-input>
</el-form-item>
<el-form-item style="width: 100%" label="地区" prop="areaId">
<ai-area-get v-model="form.areaId" :instance="instance" @select="handleAreaSelect"/>
</el-form-item>
<el-form-item style="width: 100%" label="地址" prop="address">
<el-input size="small" placeholder="请输入地址" v-model="form.address" show-word-limit maxlength="50"></el-input>
</el-form-item>
<el-form-item style="width: 100%" label="地理位置" prop="location">
<el-button @click="showMap = true">地图标绘</el-button>
</el-form-item>
<el-form-item style="width: 100%" label="资源信息">
<el-input size="small" type="textarea" :rows="5" placeholder="请输入资源信息" show-word-limit v-model="form.information" :maxlength="500"></el-input>
</el-form-item>
</el-form>
</template>
</ai-card>
</template>
<template #footer>
<el-button @click="cancel">取消</el-button>
<el-button type="primary" @click="confirm()">提交</el-button>
</template>
</ai-detail >
<ai-dialog title="地图" :visible.sync="showMap" @opened="getCorpLocation" width="800px" class="mapDialog" @onConfirm="selectMap">
<div id="map"></div>
<el-form label-width="80px" style="padding: 10px 20px 0 20px;">
<el-row type="flex" justify="space-between">
<el-form-item label="经度">
<el-input disabled size="small" v-model="placeDetail.lng"></el-input>
</el-form-item>
<el-form-item label="纬度">
<el-input disabled size="small" v-model="placeDetail.lat"></el-input>
</el-form-item>
</el-row>
</el-form>
<el-input id="searchPlaceInput" size="medium" class="searchPlaceInput" clearable v-model="searchPlace" autocomplete="on" @change="placeSearch.search(searchPlace)" placeholder="请输入关键字">
<el-button type="primary" slot="append" @click="placeSearch.search(searchPlace)">搜索</el-button>
</el-input>
<div id="searchPlaceOutput" />
</ai-dialog>
</section>
</template>
<script>
import AMapLoader from '@amap/amap-jsapi-loader'
export default {
name: 'addResource'
name: 'addResource',
props: {
instance: Function,
dict: Object,
areaId: String,
permissions: Function,
},
data() {
var locate = (rule, value, callback) => {
if(!this.form.lat.length || !this.form.lng.length) {
return callback(new Error('请标绘地理位置'))
} else {
callback()
}
}
return {
form: {
categoryName: '',
categoryId: '',
resourceName: '',
areaId: '',
areaName: '',
address: '',
lng: '', // 经度
lat: '', // 纬度
information: '',
},
categoryList: [],
searchPlace: '',
placeDetail: {
lng: '', // 经度
lat: '', // 纬度
},
map: null,
placeDetail: {
lng: '',
lat: '',
},
showMap: false,
searchPlace: '',
// locate
}
},
created() {
this.getCategoryList()
},
computed: {
rules() {
return {
categoryId: [{ required: true, message: '请选择资源分类', trigger: 'blur' }],
resourceName: [{ required: true, message: '请输入资源名称', trigger: 'blur' }],
areaId: [{ required: true, message: '选择地区', trigger: 'change' }],
address: [{ required: true, message: '请输入地址', trigger: 'change' }],
location: [{ required: true, validator: this.locate, trigger: 'change' }],
}
}
},
methods: {
cancel() {
// currentPage: resourceManagement
this.$router.push({hash: "#AppCommunityResource", query: {}})
},
getCategoryList() {
this.instance.post(`/app/appresourcecategory/list`,null,{
params: {
current: 1,
size: 3000,
}
}).then(res=> {
if(res?.data) {
this.categoryList = res.data.records.map(item=> {
return {
dictName: item.categoryName,
dictValue: item.id
}
})
}
})
},
handleAreaSelect(v) {
if(v.length) {
this.form.areaName = v[0]?.label
}
},
selectMap() {
this.form.lng = this.placeDetail.lng
this.form.lat = this.placeDetail.lat
this.showMap = false
},
getCorpLocation() {
this.instance.post('/app/appdvcpconfig/getCorpLocation').then((res) => {
if (res.code == 0) {
this.initMap(res.data)
}
})
},
initMap({ lng, lat }) {
AMapLoader.load({
key: 'b553334ba34f7ac3cd09df9bc8b539dc',
version: '2.0',
plugins: ['AMap.PlaceSearch', 'AMap.AutoComplete', 'AMap.Geocoder'],
}).then((AMap) => {
this.map = new AMap.Map('map', {
resizeEnable: true,
zooms: [6, 20],
center: [lng, lat],
zoom: 11,
})
this.placeSearch = new AMap.PlaceSearch({ map: this.map })
new AMap.AutoComplete({
input: 'searchPlaceInput',
output: 'searchPlaceOutput',
}).on('select', (e) => {
if (e?.poi) {
this.placeSearch.setCity(e.poi.adcode)
this.movePosition(e.poi.location)
}
})
this.map.on('click', (e) => {
new AMap.Geocoder().getAddress(e.lnglat, (sta, res) => {
if (res?.regeocode) {
this.placeDetail = {
lng: e.lnglat?.lng,
lat: e.lnglat?.lat,
address: res.regeocode.formattedAddress,
}
}
})
this.movePosition(e.lnglat)
})
})
},
movePosition(center) {
if (this.map) {
this.map.clearMap()
this.map.panTo(center)
this.map.add([
new AMap.Marker({
position: center,
clickable: true,
}),
])
this.map.setFitView()
}
},
confirm() {
this.$refs.form.validate((valid) => {
if(valid) {
this.instance.post(`/app/appresourceinfo/addOrUpdate`, {
...this.form
}).then(res => {
if (res.code == 0) {
this.$message.success('新增成功')
this.cancel()
}
})
}
})
},
},
}
</script>
<style lang="scss" scope>
<style lang="scss" scoped>
.addResource {
::v-deep .amap-logo {
display: none!important;
}
::v-deep .amap-copyright {
display: none!important;
}
::v-deep .mapDialog {
.el-dialog__body {
padding: 0;
.ai-dialog__content {
padding: 0;
}
.ai-dialog__content--wrapper {
padding: 0 !important;
position: relative;
}
#map {
width: 100%;
height: 420px;
}
.searchPlaceInput {
position: absolute;
width: 250px;
top: 30px;
left: 25px;
}
#searchPlaceOutput {
position: absolute;
width: 250px;
left: 25px;
height: initial;
top: 80px;
background: white;
z-index: 250;
max-height: 300px;
overflow-y: auto;
.auto-item {
text-align: left;
font-size: 14px;
padding: 8px;
box-sizing: border-box;
}
}
}
}
}
</style>

View File

@@ -9,13 +9,12 @@
</ai-search-bar>
<ai-table :tableData="tableData" :total="total" :current.sync="search.current" :size.sync="search.size"
@getList="getList()" :col-configs="colConfigs" :dict="dict">
<!-- @sort-change="changeTableSort" -->
<!-- <el-table-column label="商品图" slot="merchandisePhoto" align="center" width="130">
<el-table-column label="分类图标" slot="categoryIcon" align="center">
<template v-slot="{ row }">
<ai-uploader :disabled="true" :instance="instance" v-model="row.merchandisePhoto" :limit="9"></ai-uploader>
<ai-uploader :disabled="true" valueIsUrl :instance="instance" v-model="row.categoryIcon" :limit="1"></ai-uploader>
</template>
</el-table-column> -->
</el-table-column>
<el-table-column slot="options" label="状态" align="center">
<template slot-scope="{ row }">
@@ -23,25 +22,26 @@
<el-button type="text" title="删除" @click="handleDelete(row.id)">删除</el-button>
</template>
</el-table-column>
</ai-table>
</template>
</ai-list>
<ai-dialog title="添加资源分类" :visible.sync="dialog" :customFooter="true" :destroyOnClose="true" width="720px" @onConfirm="onConfirm" @closed="form={}">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="分类名称" prop="categoryName">
<el-input v-model.trim="form.categoryName" placeholder="请输入" type="text" maxlength="20"></el-input>
</el-form-item>
<el-form-item label="分类图标" prop="categoryIcon">
<ai-uploader :instance="instance" isShowTip v-model="form.categoryIcon" :limit="1"></ai-uploader>
<ai-uploader :instance="instance" valueIsUrl isShowTip v-model="form.categoryIcon" :limit="1"></ai-uploader>
</el-form-item>
</el-form>
<div class="dialog-footer" slot="footer">
<el-button @click="dialog=false;form={}">取消</el-button>
<el-button type="primary" @click="onConfirm">确定</el-button>
</div>
</ai-dialog>
</section>
</template>
@@ -67,17 +67,17 @@ export default {
dialog: false,
form: {
categoryName: '',
categoryIcon: ''
categoryIcon: '',
}
}
},
computed: {
colConfigs() {
return [
{prop: 'resourceName', label: '分类名称', width: '300px'},
{prop: 'categoryName', label: '资源数量', align: 'center'},
// {prop: "merchandisePhoto",slot: "merchandisePhoto",align: "center",label: "商品图"},
{prop: 'option'}
{prop: 'categoryName', label: '分类名称', width: '300px'},
{prop: 'resourceNum', label: '资源数量', align: 'center'},
{slot: "categoryIcon"},
{slot: 'option'},
]
},
rules() {
@@ -100,7 +100,9 @@ export default {
}).then(res=> {
if(res?.data) {
this.tableData = res.data.records
this.total = res.total
this.total = res.data.total
console.log(this.tableData);
}
})
},
@@ -108,13 +110,39 @@ export default {
onConfirm() {
this.$refs.form.validate((valid) => {
if(valid) {
this.instance.post(`/app/appresourcecategory/addOrUpdate`, ...this.form).then(res=> {
console.log(res,this.form.categoryIcon);
this.instance.post(`/app/appresourcecategory/addOrUpdate`, {...this.form}).then(res=> {
if(res.code == 0) {
this.$message.success('新增成功')
this.dialog = false
this.getList()
}
})
}
})
},
}
handleDelete(ids) {
this.$confirm('确定删除该数据?').then(() => {
this.instance.post(`/app/appresourcecategory/delete?ids=${ids}`).then(res=> {
if (res.code== 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
toEdit(id) {
this.getDetail(id)
this.dialog = true
},
getDetail(ids) {
this.instance.post(`/app/appresourcecategory/queryDetailById?id=${ids}`).then(res=> {
if(res.data) {
console.log(res.data);
this.form = res.data
}
})
}
},
}
</script>

View File

@@ -21,7 +21,7 @@
import resourceMap from "./resourceMap.vue"
import resourceManagement from "./resourceManagement.vue"
import resourceClassification from './resourceClassification.vue'
import {mapState} from 'vuex'
import { mapState } from 'vuex'
export default {
name: 'resourceList',

View File

@@ -5,7 +5,7 @@
<ai-search-bar>
<template #left>
<el-button type="primary" size="small" icon="iconfont iconAdd" @click="addResource">&nbsp;添加资源</el-button>
<ai-select v-model="search.categoryId" @change="search.current = 1, getList()" placeholder="资源种类" :selectList="dict.getDict('cwpStatus')" />
<ai-select v-model="search.categoryId" @change="search.current = 1, getList()" placeholder="资源种类" :selectList="categoryList" />
</template>
<template #right>
<el-input size="small" placeholder="资源姓名" v-model="search.resourceName" clearable
@@ -15,7 +15,6 @@
</ai-search-bar>
<ai-table :tableData="tableData" :total="total" :current.sync="search.current" :size.sync="search.size"
@getList="getList()" :col-configs="colConfigs" :dict="dict">
<!-- @sort-change="changeTableSort" -->
</ai-table>
</template>
</ai-list>
@@ -41,6 +40,7 @@ export default {
},
total: 0,
tableData: [],
categoryList: [],
}
},
computed: {
@@ -55,30 +55,46 @@ export default {
},
created() {
this.getList()
this.getCategoryList()
},
methods: {
getList() {
this.instance.post(`/app/appresourceinfo/list`,null,{
params: {
...this.search,
areaId: this.areaId,
// areaId: this.areaId,
}
}).then(res=> {
if(res?.data) {
this.tableData = res.data.records
this.total = res.total
this.total = res.data.total
}
})
},
addResource() {
this.$router.push({hash: "#addResource", query: {}})
}
},
getCategoryList() {
this.instance.post(`/app/appresourcecategory/list`,null,{
params: {
current: 1,
size: 3000,
}
}).then(res=> {
if(res?.data) {
this.categoryList = res.data.records.map(item=> {
return {
dictName: item.categoryName,
dictValue: item.id
}
})
}
})
},
}
}
</script>
<style lang="scss" scope>
.resourceManagement {
}
.resourceManagement {}
</style>