This commit is contained in:
liuye
2024-07-04 17:31:16 +08:00
parent f8a7ffaca9
commit c1e1ac4b8b
29 changed files with 6984 additions and 0 deletions

View File

@@ -0,0 +1,433 @@
<template>
<ai-detail class="activitiesAdd">
<ai-title slot="title" :title="id? '编辑活动':'创建活动'" isShowBottomBorder isShowBack @onBackClick="cancel(true)"/>
<template slot="content">
<ai-card title="基本信息">
<template #content>
<el-form class="ai-form" ref="form" :model="form" :rules="formRules" size="small" label-width="120px">
<el-form-item label="活动名称" prop="title" style="width: 100%">
<el-input v-model="form.title" placeholder="请输入" show-word-limit maxlength="64"></el-input>
</el-form-item>
<el-form-item label="活动说明" style="width: 100%">
<el-input type="textarea" :rows="5" v-model="form.detail" placeholder="请输入" show-word-limit maxlength="500"></el-input>
</el-form-item>
<el-form-item label="活动图片" prop="files">
<ai-uploader
:instance="instance"
v-model="form.files"
:limit="9">
</ai-uploader>
</el-form-item>
<el-form-item prop="areaId" style="width: 100%;" label="活动地区" :rules="[{required: true, message: '请选择地区', trigger: 'change'}]">
<ai-area-select
clearable
@fullname="v => form.areaName = v"
:disabled-level="$store.state.user.info.areaList.length"
always-show
:instance="instance"
v-model="form.areaId">
</ai-area-select>
</el-form-item>
<el-form-item label="活动地点" style="width: 100%;" prop="address" :rules="[{required: true, message: '请选择活动地点', trigger: 'change'}]">
<el-input v-model="form.address" disabled>
<template slot="append">
<el-button @click="showMap = true">选择位置</el-button>
</template>
</el-input>
</el-form-item>
<el-form-item label="积分类型" prop="type" style="width: 100%" :rules="[{required: true, message: '请选择积分类型', trigger: 'change'}]">
<el-radio-group v-model="form.type" @change="$refs.form.clearValidate()">
<el-radio label="0">打卡得积分</el-radio>
<el-radio label="1">报名得积分</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="打卡范围" prop="clockRange" style="width: 100%" v-if="form.type === '0'">
<el-input type="number" v-model="form.clockRange" placeholder="请输入" >
<template slot="append"></template>
</el-input>
</el-form-item>
<el-form-item :label="form.type === '0' ? '进场打卡时间' : '报名时间'" prop="intoTime">
<el-date-picker style="width: 100%" v-model="form.intoTime" type="datetimerange" start-placeholder="开始日期" :picker-options="timeOption"
end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" ></el-date-picker>
</el-form-item>
<el-form-item v-if="form.type === '0'" label="进场得积分" prop="intoIntegral">
<el-input v-model="form.intoIntegral" type="number" placeholder="请输入" style="width: 100%">
<template slot="append">积分</template>
</el-input>
</el-form-item>
<el-form-item v-if="form.type === '0'" :label="form.type === '0' ? '离场打卡时间' : '离场时间'" prop="exitTime">
<el-date-picker style="width: 100%" v-model="form.exitTime" type="datetimerange" start-placeholder="开始日期" :picker-options="timeOption"
end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss">
</el-date-picker>
</el-form-item>
<el-form-item v-if="form.type === '0'" label="离场得积分" prop="exitIntegral">
<el-input v-model="form.exitIntegral" type="number" placeholder="请输入" style="width: 100%">
<template slot="append">积分</template>
</el-input>
</el-form-item>
<el-form-item v-if="form.type === '1'" label="报名得积分" prop="enrollIntegral" :rules="[{required: true, message: '请选择报名得积分', trigger: 'blur'}]">
<el-input v-model="form.enrollIntegral" type="number" placeholder="请输入" style="width: 100%">
<template slot="append">积分</template>
</el-input>
</el-form-item>
</el-form>
<ai-dialog title="地图" :visible.sync="showMap" @opened="initMap" :destroyOnclose="false" 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>
</template>
</ai-card>
</template>
<template #footer>
<el-button class="delete-btn footer-btn" @click="cancel(false)">取消</el-button>
<el-button class="footer-btn" type="primary" @click="confirm()">保存</el-button>
</template>
</ai-detail>
</template>
<script>
import AMapLoader from '@amap/amap-jsapi-loader'
export default {
props: {
instance: Function,
dict: Object,
params: Object,
},
data() {
var validLocation = (rule, value, callback) => {
if(!this.form.lat || !this.form.lng) {
return callback(new Error('请标绘地理位置'))
} else {
callback()
}
}
return {
form: {
title: '',
detail: '',
lng: '',
lat: '',
type: '0',
areaId: '',
enrollIntegral: '',
files: [],
address: '',
clockRange: '',
intoTime: [],
intoBegintime: '',
intoEndtime: '',
intoIntegral: '',
exitTime: [],
exitBegintime: '',
exitEndtime: '',
exitIntegral: '',
},
formRules: {
title: [{required: true, message: "请输入活动名称", trigger: "blur"}],
location: [{required: true, validator: validLocation, trigger: "blur"}],
clockRange: [{required: true, message: "请输入打卡范围", trigger: "blur"}],
intoTime: [{required: true, message: "请选择进场打卡时间", trigger: "blur"}],
intoIntegral: [{required: true, message: "请输入进场得积分", trigger: "blur"}],
exitTime: [{required: true, message: "请选择离场打卡时间", trigger: "blur"}]
},
id: '',
isEdit: false,
info: {},
mapDetail: null,
map: null,
placeSearch: null,
placeDetail: {
lng: '',
lat: '',
address: ''
},
lng: '',
lat: '',
showMap: false,
searchPlace: '',
timeOption: {
disabledDate(date) {
return date.getTime() < Date.now() - 24 * 60 * 60 * 1000
}
},
}
},
created() {
this.form.areaId = this.$store.state.user.info.areaId
this.$dict.load('tfx_activityStatus')
if(this.params && this.params.id) {
this.id = this.params.id
this.getDetail()
setTimeout(() => {
},500)
}
},
watch: {
'form.intoTime': {
handler(val) {
if(val) {
this.form.intoBegintime = val[0]
this.form.intoEndtime = val[1]
}
}
},
'form.exitTime': {
handler(val) {
if(val) {
this.form.exitBegintime = val[0]
this.form.exitEndtime = val[1]
}
}
}
},
mounted () {
this.$nextTick(() => {
this.instance.post("/app/appdvcpconfig/getCorpLocation").then(res => {
if (res.code == 0) {
this.lng = res.data.lng
this.lat = res.data.lat
}
})
})
},
methods: {
selectMap() {
this.form.lng = this.placeDetail.lng
this.form.lat = this.placeDetail.lat
this.form.address = this.placeDetail.address
this.showMap = false
},
initMap() {
if (this.map) return
AMapLoader.load({
key: '54a02a43d9828a8f9cd4f26fe281e74e',
version: '2.0',
plugins: ['AMap.PlaceSearch', 'AMap.AutoComplete', 'AMap.Geocoder'],
}).then((AMap) => {
this.map = new AMap.Map('map', {
resizeEnable: true,
zooms: [6, 20],
center: this.form.lng ? [this.form.lng, this.form.lat] : [this.lng, this.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()
}
},
cancel (isRefresh) {
this.$emit('change', {
type: 'List',
isRefresh: !!isRefresh
})
},
getMap(lng,lat,address) {
AMapLoader.load({
key: '54a02a43d9828a8f9cd4f26fe281e74e',
version: '2.0',
plugins: ['AMap.PlaceSearch', 'AMap.AutoComplete', 'AMap.Geocoder'],
}).then((AMap) => {
this.mapDetail = new AMap.Map(document.getElementById("mapDetail"), {
resizeEnable: true,
zooms: [6, 20],
zoom: 11,
center:[lng,lat],
})
let marker = new AMap.Marker({
position: new AMap.LngLat(lng,lat),
title: address
})
this.mapDetail.add(marker);
})
},
update() {
this.isEdit = true
this.getDetail()
},
getDetail() {
this.instance.post(`/app/appintegraltask/queryDetailById`,null, {
params: {id:this.id}
}).then((res) => {
if(res?.data) {
this.form = res.data
this.form.intoTime = [res.data.intoBegintime,res.data.intoEndtime]
this.form.exitTime = [res.data.exitBegintime,res.data.exitEndtime]
this.info = res.data
this.placeDetail.lng = res.data.lng
this.placeDetail.lat = res.data.lat
this.getMap(this.info.lng,this.info.lat,this.info.address)
}
})
},
selectCandidate(v) {
this.form.candidateUsers = v
},
selectVote(e) {
this.form.voteUsers = e
},
handleAreaSelect(v) {
this.form.areaName = v?.[0]?.label
},
confirm() {
this.$refs.form.validate((valid) => {
if (valid) {
if(new Date(this.form.intoBegintime).getTime() <= Date.now()){
return this.$message.error('进场打卡开始时间不能小于当前时间')
}
let intoEnd = new Date(this.form.intoEndtime).getTime()
let exitBegin = new Date(this.form.exitBegintime).getTime()
if(exitBegin <= intoEnd) {
return this.$message.error('离场的开始时间不能小于且等于进场的结束时间')
}
this.instance.post(`/app/appintegraltask/addOrUpdate`,{
...this.form
}).then(res => {
if(res.code == 0) {
this.$message.success(this.id ? '编辑成功' : '新增成功')
this.cancel(true)
}
}).catch(err => {
console.log(err);
})
}
})
},
},
}
</script>
<style lang="scss" scope>
.activitiesAdd {
height: 100%;
:deep( .amap-logo ){
display: none!important;
}
:deep( .amap-copyright ){
display: none!important;
}
:deep( .el-date-editor .el-input ){
width: 100%;
}
.tips {
width: 100%;
border: 1px solid #f82;
background-color: #fff3e9;
color: #f82;
padding: 8px 16px;
box-sizing: border-box;
border-radius: 4px;
margin-bottom: 32px;
font-size: 13px;
}
.amap-container {
height: 380px;
}
}
.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

@@ -0,0 +1,192 @@
<template>
<ai-detail class="activitiesAdd">
<template slot="title">
<ai-title title="活动详情" isShowBack isShowBottomBorder @onBackClick="cancel(false)"></ai-title>
</template>
<template slot="content">
<ai-card title="基本信息">
<template #content>
<ai-wrapper>
<ai-info-item label="活动名称" :value="info.title"></ai-info-item>
<ai-info-item label="创建人" :value="info.createUserName"></ai-info-item>
<ai-info-item label="活动说明" isLine :value="info.detail"></ai-info-item>
<ai-info-item label="活动图片" isLine>
<ai-uploader
disabled
:instance="instance"
:value="info.files">
</ai-uploader>
</ai-info-item>
<ai-info-item label="活动地区" isLine :value="info.areaName"></ai-info-item>
<ai-info-item label="活动地点" :value="info.address"></ai-info-item>
<ai-info-item label="地图位置" isLine><div id="mapDetail"></div></ai-info-item>
<ai-info-item label="积分类型" isLine :value="info.type === '0' ? '打卡得积分' : '报名得积分'"></ai-info-item>
<ai-info-item label="活动状态">
{{ dict.getLabel('fdIntegralTaskStatus',info.status) }}
</ai-info-item>
<ai-info-item v-if="info.type === '0'" label="打卡范围">{{ info.clockRange }}</ai-info-item>
<ai-info-item :label="info.type === '0' ? '进场打卡时间' : '报名时间'">{{ info.intoBegintime }}{{ info.intoEndtime}}</ai-info-item>
<ai-info-item v-if="info.type === '0'" label="进场得积分">{{ info.intoIntegral || 0 }}</ai-info-item>
<ai-info-item v-if="info.type === '0'" :label="info.type === '0' ? '离场打卡时间' : '离场时间'">{{ info.exitBegintime }}{{ info.exitEndtime}}</ai-info-item>
<ai-info-item v-if="info.type === '0'" label="离场得积分">{{ info.exitIntegral || 0 }}</ai-info-item>
<ai-info-item v-if="info.type === '1'" label="报名得积分">{{ info.enrollIntegral || 0 }}</ai-info-item>
</ai-wrapper>
</template>
</ai-card>
<ai-card title="打卡记录" v-if="info.type === '0'">
<template #content>
<ai-wrapper>
<ai-info-item label="参与人数" :value="search1.total"></ai-info-item>
</ai-wrapper>
<ai-table
:tableData="tableData1"
:col-configs="colConfigs1"
:total="search1.total"
:current.sync="search1.current"
:size.sync="search1.size"
@getList="getList1">
</ai-table>
</template>
</ai-card>
<ai-card title="报名记录" v-if="info.type === '1'">
<template #content>
<ai-wrapper>
<ai-info-item label="参与人数" :value="search1.total"></ai-info-item>
</ai-wrapper>
<ai-table
:tableData="tableData1"
:col-configs="colConfigs2"
:total="search1.total"
:current.sync="search1.current"
:size.sync="search1.size"
@getList="getList1">
</ai-table>
</template>
</ai-card>
</template>
</ai-detail>
</template>
<script>
import AMapLoader from '@amap/amap-jsapi-loader'
export default {
props: {
instance: Function,
dict: Object,
params: Object,
},
data () {
return {
id: '',
info: {},
mapDetail: null,
map: null,
search1: {
total: 0,
current: 1,
size: 10
},
tableData1: [],
colConfigs1: [
{prop: 'realName', label: '姓名', align: 'center' },
{prop: 'phone', label: '联系方式', align: 'center' },
{prop: 'areaName', label: '所属地区', align: 'center' },
{prop: 'intoClockTime', label: '进场打卡时间', align: 'center' },
{prop: 'exitClockTime', label: '离场打卡时间', align: 'center' }
],
colConfigs2: [
{prop: 'realName', label: '姓名', align: 'center' },
{prop: 'phone', label: '联系方式', align: 'center' },
{prop: 'areaName', label: '所属地区', align: 'center' },
{prop: 'enrollClockTime', label: '报名时间', align: 'center' }
]
}
},
created () {
this.id = this.params.id
this.$dict.load('tfx_activityStatus').then(() => {
this.getDetail()
})
this.getList1()
},
methods: {
cancel (isRefresh) {
this.$emit('change', {
type: 'List',
isRefresh: !!isRefresh
})
},
getList1 () {
this.instance.post(`/app/appintegraltask/clockList?taskId=${this.params.id}`,null, {
params: {
...this.search1,
}
}).then(res=> {
if(res?.data) {
this.tableData1 = res.data.records
this.search1.total = res.data.total
}
})
},
getMap(lng,lat,address) {
AMapLoader.load({
key: '54a02a43d9828a8f9cd4f26fe281e74e',
version: '2.0',
plugins: ['AMap.PlaceSearch', 'AMap.AutoComplete', 'AMap.Geocoder'],
}).then((AMap) => {
this.mapDetail = new AMap.Map(document.getElementById("mapDetail"), {
resizeEnable: true,
zooms: [6, 20],
zoom: 11,
center:[lng,lat],
})
let marker = new AMap.Marker({
position: new AMap.LngLat(lng,lat),
title: address
})
this.mapDetail.add(marker);
})
},
update() {
this.isEdit = true
this.getDetail()
},
getDetail() {
this.instance.post(`/app/appintegraltask/queryDetailById?id=${this.params.id}`).then((res) => {
if(res.data) {
this.info = res.data
this.getMap(this.info.lng, this.info.lat, this.info.address)
}
})
}
}
}
</script>
<style lang="scss" scope>
.activitiesAdd {
height: 100%;
:deep( .amap-logo ){
display: none!important;
}
:deep( .amap-copyright ){
display: none!important;
}
:deep( .el-date-editor .el-input ){
width: 100%;
}
.amap-container {
height: 380px;
}
}
</style>

View File

@@ -0,0 +1,223 @@
<template>
<ai-list class="activitiesList">
<ai-title
slot="title"
title="活动管理"
isShowBottomBorder
isShowArea
:hideLevel="$store.state.user.info.areaList.length - 1"
v-model="search.areaId"
:instance="instance"
@change="search.current = 1, getList()">
</ai-title>
<template #content>
<ai-search-bar bottomBorder>
<template #left>
<el-button size="small" type="primary" icon="iconfont iconAdd" @click="toAdd('')" >创建活动</el-button>
<el-date-picker
v-model="search.beginDate"
type="date"
size="small"
value-format="yyyy-MM-dd"
placeholder="选择开始日期"
@change="search.current = 1, getList()">
</el-date-picker>
<el-date-picker
v-model="search.endDate"
type="date"
size="small"
value-format="yyyy-MM-dd"
placeholder="选择结束日期"
@change="search.current = 1, getList()">
</el-date-picker>
<ai-select
v-model="search.status"
clearable
placeholder="活动状态"
:selectList="dict.getDict('fdIntegralTaskStatus')"
@change="search.current = 1, getList()">
</ai-select>
</template>
<template #right>
<el-input
v-model="search.title"
size="small"
placeholder="活动名称/创建人"
clearable
v-throttle="() => {getList()}"
@clear="search.title = '', getList()"
suffix-icon="iconfont iconSearch">
</el-input>
</template>
</ai-search-bar>
<ai-table
:tableData="tableData"
:total="search.total"
:current.sync="search.current"
:size.sync="search.size"
@getList="getList"
:col-configs="colConfigs"
:dict="dict">
<el-table-column slot="qrcode" width="200px" label="二维码" align="center">
<template slot-scope="{ row }">
<div class="qrcode">
<el-button type="text" @click="qrcode(row.qrCode, row.id)">{{ row.qrCode ? '预览' : '生成' }}</el-button>
</div>
</template>
</el-table-column>
<el-table-column slot="options" label="操作" fixed="right" align="center" width="120px">
<template slot-scope="{ row }">
<div class="table-options">
<el-button type="text" @click.native="toDetail(row.id)">详情</el-button>
<el-button type="text" :disabled="row.status ==2" @click.native="stopBtn(row.id)">结束</el-button>
<!-- <el-button type="text" @click.native="handleDelete(row.id)">删除</el-button> -->
</div>
</template>
</el-table-column>
</ai-table>
<div class="qrCode" v-viewer="{movable: true}" v-show="false">
<img :src="img">
</div>
</template>
</ai-list>
</template>
<script>
export default {
props: {
instance: Function,
dict: Object
},
data () {
return {
search: {
current: 1,
size: 10,
total: 0,
title: '',
areaId: '',
status: '',
beginDate: '',
endDate: ''
},
tableData: [],
img: '',
isLoading: false,
}
},
created () {
this.search.areaId = this.$store.state.user.info.areaId
this.$dict.load('fdIntegralTaskStatus').then(()=> {
this.getList()
})
},
computed: {
colConfigs() {
return [
{ prop: "title", label: "活动名称", align: "left" },
{ prop: "areaName", label: "活动地区", align: "center" },
{ prop: "createUserName", label: "创建人", align: "center" },
{
prop: "intoBegintime",
label: "开始结束时间",
align: "center",
width: "400px",
render: (h, {row}) => h('p',
{
textAlign: 'center'
},
row.exitEndtime ? `${row.intoBegintime}${row.exitEndtime}` : row.intoBegintime)
},
{ prop: "status", label: "活动状态", align: "center", dict:"fdIntegralTaskStatus" },
{ slot: "qrcode" },
{ slot: "options", },
]
}
},
methods: {
getList() {
this.instance.post(`/app/appintegraltask/list`,null, {
params: {
...this.search,
}
}).then(res=> {
if(res?.data) {
this.tableData = res.data.records
this.search.total = res.data.total
}
})
},
toDetail (id) {
this.$emit('change', {
type: 'Detail',
params: {
id: id || '',
}
})
},
toAdd(id) {
this.$emit('change', {
type: 'Add',
params: {
id: id || '',
}
})
},
qrcode (qrcode, id) {
if (!qrcode) {
this.isLoading = true
this.instance.post(`/app/appintegraltask/generateQrCode?id=${id}&width=400&height=400`).then(res => {
if (res.code == 0) {
this.$message.success('二维码生成成功!')
this.getList()
}
this.isLoading = false
})
} else {
this.img = qrcode
this.$nextTick(() => {
setTimeout(() => {
const viewer = this.$el.querySelector('.qrCode').$viewer
viewer.view()
}, 600)
})
}
},
handleDelete (id) {
this.$confirm('确定删除该活动?').then(() => {
this.instance.post(`/app/appintegraltask/delete?ids=${id}`).then(res=>{
if(res.code == 0) {
this.$message.success('删除成功!')
this.getList()
}
})
})
},
stopBtn (id) {
this.$confirm('确定要结束该活动吗?').then(() => {
this.instance.post(`/app/appintegraltask/stop?id=${id}`).then(res=>{
if(res.code == 0) {
this.$message.success('结束成功!')
this.getList()
}
})
})
}
}
}
</script>
<style lang="scss" scoped>
.activitiesList {
height: 100%;
}
</style>