generated from Leo_Ding/web-template
信息登记功能
This commit is contained in:
parent
e91f27049d
commit
a6f6435da9
18
src/apis/modules/vote.js
Normal file
18
src/apis/modules/vote.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
/**
|
||||||
|
* 区域模块接口
|
||||||
|
*/
|
||||||
|
import request from '@/utils/request'
|
||||||
|
// 获取项目列表
|
||||||
|
export const getElectionList = (params) => request.basic.get('/api/v1/election-registrations', params)
|
||||||
|
// 获取单挑数据
|
||||||
|
export const getItem = (id) => request.basic.get(`/api/v1/activities/${id}`)
|
||||||
|
// 添加条目
|
||||||
|
export const createProject = (params) => request.basic.post('/api/v1/activities', params)
|
||||||
|
// 更新role
|
||||||
|
export const updateItem = (id, params) => request.basic.put(`/api/v1/activities/${id}`, params)
|
||||||
|
// 删除数据
|
||||||
|
export const delItem = (id) => request.basic.delete(`/api/v1/activities/${id}`)
|
||||||
|
//获取活动报名列表
|
||||||
|
export const getActivityList = (params) => request.basic.get('/api/v1/activity-registers', params)
|
||||||
|
// 导出文件
|
||||||
|
export const exportFile = (params) => request.basic.get('/api/v1/election-registrations/export', params, { responseType: 'blob' })
|
||||||
@ -51,5 +51,6 @@ export default {
|
|||||||
customer:'用户管理',
|
customer:'用户管理',
|
||||||
aiHelper:'AI助手',
|
aiHelper:'AI助手',
|
||||||
abbreviation:'活动报名',
|
abbreviation:'活动报名',
|
||||||
orderArea:'工单区域管理'
|
orderArea:'工单区域管理',
|
||||||
|
vote:'信息登记'
|
||||||
}
|
}
|
||||||
|
|||||||
@ -249,4 +249,16 @@ export default [
|
|||||||
permission: '*',
|
permission: '*',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'vote/index',
|
||||||
|
name: 'vote',
|
||||||
|
component: 'pages/vote/index.vue',
|
||||||
|
meta: {
|
||||||
|
icon: 'icon-huodongliebiao-copy',
|
||||||
|
title: '信息登记',
|
||||||
|
isMenu: true,
|
||||||
|
keepAlive: true,
|
||||||
|
permission: '*',
|
||||||
|
},
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -18,22 +18,38 @@
|
|||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'报名截止时间'" name="endSignupAt">
|
<a-form-item :label="'报名截止时间'" name="endSignupAt">
|
||||||
<a-date-picker v-model:value="formData.endSignupAt" placeholder="请输入报名截止时间"
|
<a-date-picker
|
||||||
style="width: 100%;" />
|
v-model:value="formData.endSignupAt"
|
||||||
|
placeholder="请输入报名截止时间"
|
||||||
|
style="width: 100%;"
|
||||||
|
show-time
|
||||||
|
:format="displayFormat"
|
||||||
|
:value-format="valueFormat"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
|
|
||||||
<a-form-item label="活动开始时间" name="startAt">
|
<a-form-item label="活动开始时间" name="startAt">
|
||||||
<a-date-picker v-model:value="formData.startAt" placeholder="请选择活动开始时间"
|
<a-date-picker
|
||||||
style="width: 100%;" />
|
v-model:value="formData.startAt"
|
||||||
|
placeholder="请选择活动开始时间"
|
||||||
|
style="width: 100%;"
|
||||||
|
show-time
|
||||||
|
:format="displayFormat"
|
||||||
|
:value-format="valueFormat"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
|
|
||||||
<a-form-item label="活动结束时间" name="endAt">
|
<a-form-item label="活动结束时间" name="endAt">
|
||||||
<a-date-picker v-model:value="formData.endAt" placeholder="请选择活动结束时间"
|
<a-date-picker
|
||||||
style="width: 100%;" />
|
v-model:value="formData.endAt"
|
||||||
|
placeholder="请选择活动结束时间"
|
||||||
|
style="width: 100%;"
|
||||||
|
show-time
|
||||||
|
:format="displayFormat"
|
||||||
|
:value-format="valueFormat"
|
||||||
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-form-item :label="'活动报名人数'" name="maxSignupNum">
|
<a-form-item :label="'活动报名人数'" name="maxSignupNum">
|
||||||
@ -41,7 +57,6 @@
|
|||||||
style="width: 100%" />
|
style="width: 100%" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
|
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'状态'" name="status">
|
<a-form-item :label="'状态'" name="status">
|
||||||
<a-radio-group v-model:value="formData.status" :options="activatyStatus.getAll()"
|
<a-radio-group v-model:value="formData.status" :options="activatyStatus.getAll()"
|
||||||
@ -74,30 +89,43 @@ import { useForm, useModal, useSpining } from '@/hooks'
|
|||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
import utc from 'dayjs/plugin/utc'
|
||||||
|
import timezone from 'dayjs/plugin/timezone'
|
||||||
import GxUpload from '@/components/GxUpload/index.vue'
|
import GxUpload from '@/components/GxUpload/index.vue'
|
||||||
import { spliceUrl } from "@/utils/util"
|
import { spliceUrl } from "@/utils/util"
|
||||||
import { activatyStatus } from '@/enums/index'
|
import { activatyStatus } from '@/enums/index'
|
||||||
|
|
||||||
|
// 扩展dayjs的时区功能
|
||||||
|
dayjs.extend(utc)
|
||||||
|
dayjs.extend(timezone)
|
||||||
|
|
||||||
const emit = defineEmits(['ok'])
|
const emit = defineEmits(['ok'])
|
||||||
const { t } = useI18n() // 解构出t方法
|
const { t } = useI18n()
|
||||||
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||||
const { spining, showSpining, hideSpining } = useSpining()
|
const { spining, showSpining, hideSpining } = useSpining()
|
||||||
const cancelText = ref(t('button.cancel'))
|
const cancelText = ref(t('button.cancel'))
|
||||||
const okText = ref(t('button.confirm'))
|
const okText = ref(t('button.confirm'))
|
||||||
const fileList = ref([])
|
const fileList = ref([])
|
||||||
|
|
||||||
|
// 显示格式 - 用户界面展示的格式
|
||||||
|
const displayFormat = 'YYYY-MM-DD HH:mm:ss'
|
||||||
|
// 值格式 - 传给后台的格式,符合2006-01-02T15:04:05Z07:00
|
||||||
|
const valueFormat = 'YYYY-MM-DDTHH:mm:ssZ'
|
||||||
|
|
||||||
formRules.value = {
|
formRules.value = {
|
||||||
title: [{ required: true, message: '请输入活动名称' }],
|
title: [{ required: true, message: '请输入活动名称' }],
|
||||||
openAt: [{ required: true, message: '请输入活动时间' }],
|
openAt: [{ required: true, message: '请输入活动时间' }],
|
||||||
cover: [{ required: false, message: '请上传图片', trigger: 'change' }],
|
cover: [{ required: false, message: '请上传图片', trigger: 'change' }],
|
||||||
images: [{ required: false, message: '请上传图片', trigger: 'change' }],
|
images: [{ required: false, message: '请上传图片', trigger: 'change' }],
|
||||||
endSignupAt: [{ required: true, message: '请选择报名截止时间', trigger: 'change' }],
|
endSignupAt: [{ required: true, message: '请选择报名截止时间', trigger: 'change' }],
|
||||||
startAt: [{ required: true, message: '请选择报名开始时间', trigger: 'change' }],
|
startAt: [{ required: true, message: '请选择活动开始时间', trigger: 'change' }],
|
||||||
endAt: [{ required: true, message: '请选择报名结束时间', trigger: 'change' }],
|
endAt: [{ required: true, message: '请选择活动结束时间', trigger: 'change' }],
|
||||||
activityContent: [{ required: true, message: '请输入活动内容' }]
|
activityContent: [{ required: true, message: '请输入活动内容' }]
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(() => {
|
||||||
|
// Initialize if needed
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,7 +136,6 @@ function handleCreate() {
|
|||||||
type: 'create',
|
type: 'create',
|
||||||
title: '新增活动',
|
title: '新增活动',
|
||||||
})
|
})
|
||||||
// initData()
|
|
||||||
formData.value.status = 1
|
formData.value.status = 1
|
||||||
formData.value.maxSignupNum = 0
|
formData.value.maxSignupNum = 0
|
||||||
}
|
}
|
||||||
@ -129,9 +156,18 @@ async function handleEdit(record = {}) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
hideSpining()
|
hideSpining()
|
||||||
formData.value = { ...data }
|
|
||||||
|
// 转换后端时间格式为组件需要的格式
|
||||||
|
formData.value = {
|
||||||
|
...data,
|
||||||
|
// 确保时间格式正确解析
|
||||||
|
endSignupAt: data.endSignupAt ? dayjs(data.endSignupAt) : null,
|
||||||
|
startAt: data.startAt ? dayjs(data.startAt) : null,
|
||||||
|
endAt: data.endAt ? dayjs(data.endAt) : null
|
||||||
|
}
|
||||||
|
|
||||||
if (data.images && data.images.length > 0) {
|
if (data.images && data.images.length > 0) {
|
||||||
formData.value.images = data.images.map(item => config('http.apiBasic') + item)
|
formData.value.images = data.images.map( item => config('http.apiBasic') + item)
|
||||||
} else {
|
} else {
|
||||||
formData.value.images = []
|
formData.value.images = []
|
||||||
}
|
}
|
||||||
@ -144,11 +180,8 @@ async function handleEdit(record = {}) {
|
|||||||
message.error({ content: error.message })
|
message.error({ content: error.message })
|
||||||
hideSpining()
|
hideSpining()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
const uploadSuccess = (data) => {
|
|
||||||
fileList.value.push(data)
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 确定
|
* 确定
|
||||||
*/
|
*/
|
||||||
@ -156,14 +189,27 @@ function handleOk() {
|
|||||||
formRef.value.validateFields().then(async (values) => {
|
formRef.value.validateFields().then(async (values) => {
|
||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
|
|
||||||
|
// 处理时间格式,确保符合要求
|
||||||
|
const formatTime = (timeStr) => {
|
||||||
|
if (!timeStr) return null;
|
||||||
|
// 确保时间字符串正确转换为所需格式
|
||||||
|
return dayjs(timeStr).format(valueFormat);
|
||||||
|
};
|
||||||
|
|
||||||
const params = {
|
const params = {
|
||||||
...values,
|
...values,
|
||||||
maxSignupNum: parseInt(values.maxSignupNum) || 0,
|
maxSignupNum: parseInt(values.maxSignupNum) || 0,
|
||||||
cover: formData.value.cover ? spliceUrl(formData.value.cover[0]) : '',
|
cover: formData.value.cover ? spliceUrl(formData.value.cover[0]) : '',
|
||||||
images: formData.value.images ? formData.value.images.map(item => spliceUrl(item)) : [],
|
images: formData.value.images ? formData.value.images.map(item => spliceUrl(item)) : [],
|
||||||
signupNum: formData.value.signupNum || 0,
|
signupNum: formData.value.signupNum || 0,
|
||||||
status: 1
|
status: 1,
|
||||||
|
// 使用格式化后的时间
|
||||||
|
endSignupAt: formatTime(values.endSignupAt),
|
||||||
|
startAt: formatTime(values.startAt),
|
||||||
|
endAt: formatTime(values.endAt)
|
||||||
}
|
}
|
||||||
|
|
||||||
let result = null
|
let result = null
|
||||||
switch (modal.value.type) {
|
switch (modal.value.type) {
|
||||||
case 'create':
|
case 'create':
|
||||||
@ -172,7 +218,7 @@ function handleOk() {
|
|||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'edit':
|
case 'edit':
|
||||||
result = await apis.activity.updateItem(formData.value.id, params).catch(() => {
|
result = await apis.activity.updateItem(formData.value.id, params).catch((error) => {
|
||||||
throw new Error(error)
|
throw new Error(error)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
@ -192,7 +238,6 @@ function handleOk() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 取消
|
* 取消
|
||||||
*/
|
*/
|
||||||
@ -200,13 +245,6 @@ function handleCancel() {
|
|||||||
formData.value.areaId = 1
|
formData.value.areaId = 1
|
||||||
hideModal()
|
hideModal()
|
||||||
}
|
}
|
||||||
const onRangeChange = (value, dateString) => {
|
|
||||||
console.log('value', value)
|
|
||||||
console.log('Formatted Selected Time: ', dateString);
|
|
||||||
formData.value.startAt = dayjs(dateString[0])
|
|
||||||
formData.value.endAt = dayjs(dateString[1])
|
|
||||||
console.log(formData.value)
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭后
|
* 关闭后
|
||||||
|
|||||||
251
src/views/pages/vote/components/EditDialog.vue
Normal file
251
src/views/pages/vote/components/EditDialog.vue
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
<template>
|
||||||
|
<a-modal :open="modal.open" :title="modal.title" :width="640" :confirm-loading="modal.confirmLoading"
|
||||||
|
:after-close="onAfterClose" :cancel-text="cancelText" :ok-text="okText" @ok="handleOk" @cancel="handleCancel">
|
||||||
|
<a-spin :spinning="spining">
|
||||||
|
<a-form ref="formRef" :model="formData" :rules="formRules">
|
||||||
|
<a-card class="mb-8-2">
|
||||||
|
<a-tabs v-model:activeKey="activeKey">
|
||||||
|
<a-tab-pane key="1" tab="基本信息">
|
||||||
|
<a-row :gutter="12">
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'产品分类'" name="typeId">
|
||||||
|
<a-select ref="select" v-model:value="formData.typeId" style="width: 100%">
|
||||||
|
<a-select-option v-for="item in typeList" :value="item.value">{{
|
||||||
|
item.label }}</a-select-option>
|
||||||
|
</a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'产品排序'" name="sequence">
|
||||||
|
<a-input-number :placeholder="'请输入排序'" v-model:value="formData.sequence"
|
||||||
|
style="width: 100%;"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'门店名称'" name="storeName">
|
||||||
|
<a-input :placeholder="'请输入门店名称'" v-model:value="formData.storeName"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'营业时间'" name="openAt">
|
||||||
|
<a-input :placeholder="'请输入营业时间'" v-model:value="formData.openAt"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'联系电话'" name="openAt">
|
||||||
|
<a-input :placeholder="'请输入联系电话'" v-model:value="formData.concatPhone"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'标签'" name="labels">
|
||||||
|
<a-select v-model:value="formData.labels" mode="tags" style="width: 100%"
|
||||||
|
placeholder="输入标签然后回车"></a-select>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'状态'" name="status">
|
||||||
|
<a-radio-group v-model:value="formData.status" :options="storeStatus.getAll()"
|
||||||
|
disabled></a-radio-group>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'店铺描述'" name="content">
|
||||||
|
<a-textarea :placeholder="'请输入店铺描述'" v-model:value="formData.content"
|
||||||
|
:auto-size="{ minRows: 2, maxRows: 5 }"></a-textarea>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item :label="'店铺封面'" name="storeCover">
|
||||||
|
<gx-upload v-model="formData.storeCover" accept-types=".jpg,.png,.webp"
|
||||||
|
:fileNumber="1" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item :label="'详情图片'" name="imgs">
|
||||||
|
<gx-upload v-model="formData.img" accept-types=".jpg,.png,.webp"
|
||||||
|
:fileNumber="10" />
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-tab-pane>
|
||||||
|
<a-tab-pane key="2" tab="位置信息">
|
||||||
|
<a-row :gutter="12">
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item :label="'经度'" name="longitude">
|
||||||
|
<a-input :placeholder="'请输入经度'" v-model:value="formData.longitude"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="12">
|
||||||
|
<a-form-item :label="'纬度'" name="latitude">
|
||||||
|
<a-input :placeholder="'请输入纬度'" v-model:value="formData.latitude"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'详细地址'" name="storeAddress">
|
||||||
|
<a-input :placeholder="'请输入详细地址'"
|
||||||
|
v-model:value="formData.storeAddress"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<gx-map @handleGetLng="handleGetLng" />
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-tab-pane>
|
||||||
|
</a-tabs>
|
||||||
|
|
||||||
|
|
||||||
|
</a-card>
|
||||||
|
</a-form>
|
||||||
|
</a-spin>
|
||||||
|
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { cloneDeep } from 'lodash-es'
|
||||||
|
import { ref, onBeforeMount } from 'vue'
|
||||||
|
import { config } from '@/config'
|
||||||
|
import apis from '@/apis'
|
||||||
|
import { useForm, useModal, useSpining } from '@/hooks'
|
||||||
|
import { message } from 'ant-design-vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { storeStatus } from '@/enums/index.js'
|
||||||
|
import { spliceUrl } from '@/utils/util'
|
||||||
|
import { init } from 'echarts'
|
||||||
|
const areaFormRef = ref()
|
||||||
|
const emit = defineEmits(['ok'])
|
||||||
|
const { t } = useI18n() // 解构出t方法
|
||||||
|
const { modal, showModal, hideModal, showLoading, hideLoading } = useModal()
|
||||||
|
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||||
|
const { spining, showSpining, hideSpining } = useSpining()
|
||||||
|
const cancelText = ref(t('button.cancel'))
|
||||||
|
const okText = ref(t('button.confirm'))
|
||||||
|
const typeList = ref([])
|
||||||
|
const searchValue = ref('')
|
||||||
|
const activeKey = ref('1')
|
||||||
|
formRules.value = {
|
||||||
|
typeId: [{ required: true, message: '请选择产品类别名称', trigger: 'change' }],
|
||||||
|
sequence: { required: true, message: '请输入排序' },
|
||||||
|
storeName: { required: true, message: '请输入门店名称' },
|
||||||
|
longitude: { required: true, message: '请输入经度' },
|
||||||
|
latitude: { required: true, message: '请输入纬度' },
|
||||||
|
storeAddress: { required: true, message: '请输入门店地址' },
|
||||||
|
status: { required: true, message: '请选择状态', trigger: 'change' }
|
||||||
|
}
|
||||||
|
const initData = async () => {
|
||||||
|
try {
|
||||||
|
showSpining()
|
||||||
|
const { data, success } = await apis.serverType.getDataList({ pageSize: 99, current: 1 })
|
||||||
|
if (success) {
|
||||||
|
typeList.value = data.map(item => ({ value: item.id, label: item.label }))
|
||||||
|
hideSpining()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideSpining()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 新建
|
||||||
|
*/
|
||||||
|
function handleCreate() {
|
||||||
|
showModal({
|
||||||
|
type: 'create',
|
||||||
|
title: '新增',
|
||||||
|
})
|
||||||
|
initData()
|
||||||
|
formData.value.status = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*/
|
||||||
|
async function handleEdit(record = {}) {
|
||||||
|
showModal({
|
||||||
|
type: 'edit',
|
||||||
|
title: '编辑',
|
||||||
|
})
|
||||||
|
const { data, success } = await apis.serverList.getMenu(record.id).catch()
|
||||||
|
if (!success) {
|
||||||
|
hideModal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formData.value = { ...data }
|
||||||
|
formData.value.storeCover = data.storeCover ? [config('http.apiBasic') + data.storeCover] : []
|
||||||
|
formData.value.img = data.imgs?.map(url => config('http.apiBasic') + url) || []
|
||||||
|
initData()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 确定
|
||||||
|
*/
|
||||||
|
function handleOk() {
|
||||||
|
formRef.value.validateFields().then(async (values) => {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
console.log(formData.value)
|
||||||
|
const params = {
|
||||||
|
...values,
|
||||||
|
storeCover: formData.value.storeCover ? spliceUrl(formData.value.storeCover[0]) : '',
|
||||||
|
imgs: formData.value.img?.map(url => spliceUrl(url)) || [],
|
||||||
|
latitude: parseFloat(formData.value.latitude),
|
||||||
|
longitude: parseFloat(formData.value.longitude),
|
||||||
|
status: 1
|
||||||
|
}
|
||||||
|
console.log("====",params)
|
||||||
|
let result = null
|
||||||
|
switch (modal.value.type) {
|
||||||
|
case 'create':
|
||||||
|
result = await apis.serverList.createMenu(params).catch((error) => {
|
||||||
|
throw new Error(error)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'edit':
|
||||||
|
result = await apis.serverList.updateMenu(formData.value.id, params).catch(() => {
|
||||||
|
throw new Error(error)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
}
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === result?.success) {
|
||||||
|
hideModal()
|
||||||
|
emit('ok')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error({ content: error.message })
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e)
|
||||||
|
hideLoading()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const handleGetLng = (obj = {}) => {
|
||||||
|
formData.value.longitude = obj.lng
|
||||||
|
formData.value.latitude = obj.lat
|
||||||
|
formData.value.storeAddress = obj.address
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消
|
||||||
|
*/
|
||||||
|
function handleCancel() {
|
||||||
|
hideModal()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭后
|
||||||
|
*/
|
||||||
|
function onAfterClose() {
|
||||||
|
resetForm()
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
|
||||||
|
defineExpose({
|
||||||
|
handleCreate,
|
||||||
|
handleEdit,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
288
src/views/pages/vote/index.vue
Normal file
288
src/views/pages/vote/index.vue
Normal file
@ -0,0 +1,288 @@
|
|||||||
|
<template>
|
||||||
|
<x-search-bar class="mb-24-2">
|
||||||
|
<template #default="{ gutter, colSpan }">
|
||||||
|
<a-form :model="searchFormData" layout="inline">
|
||||||
|
<a-row :gutter="gutter">
|
||||||
|
<a-col v-bind="colSpan">
|
||||||
|
<a-form-item label="用户名" name="name">
|
||||||
|
<a-input placeholder="请输入用户名" v-model:value="searchFormData.name"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col v-bind="colSpan">
|
||||||
|
<a-form-item label="联系电话" name="phone">
|
||||||
|
<a-input placeholder="请输入联系电话" v-model:value="searchFormData.phone"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col v-bind="colSpan">
|
||||||
|
<a-form-item label="身份证号" name="iDCard">
|
||||||
|
<a-input placeholder="请输入身份证号" v-model:value="searchFormData.iDCard"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col v-bind="colSpan">
|
||||||
|
<a-form-item label="住址" name="address">
|
||||||
|
<a-input placeholder="请输入住址" v-model:value="searchFormData.address"></a-input>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
|
<a-col class="align-right" v-bind="colSpan">
|
||||||
|
<a-space>
|
||||||
|
<a-button @click="handleExport">导出文件</a-button>
|
||||||
|
<a-button @click="handleResetSearch">{{ $t('button.reset') }}</a-button>
|
||||||
|
<a-button ghost type="primary" @click="handleSearch">
|
||||||
|
{{ $t('button.search') }}
|
||||||
|
</a-button>
|
||||||
|
</a-space>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
</a-form>
|
||||||
|
</template>
|
||||||
|
</x-search-bar>
|
||||||
|
<a-row :gutter="8" :wrap="false">
|
||||||
|
<a-col flex="auto">
|
||||||
|
<a-card type="flex">
|
||||||
|
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||||
|
:pagination="paginationState" @change="onTableChange">
|
||||||
|
<template #bodyCell="{ column, record }">
|
||||||
|
<template v-if="'createdAt' === column.dataIndex">
|
||||||
|
{{ dayjs(record.createdAt).format('YYYY-MM-DD') }}
|
||||||
|
</template>
|
||||||
|
<template v-if="'ActivityCover' === column.dataIndex">
|
||||||
|
<a-image :width="60"
|
||||||
|
:src="record.ActivityCover ? config('http.apiBasic') + record.ActivityCover : errImg" />
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
|
</a-table>
|
||||||
|
</a-card>
|
||||||
|
</a-col>
|
||||||
|
</a-row>
|
||||||
|
<a-modal v-model:open="open" :title="'审核'" @ok="handleClick">
|
||||||
|
<a-card class="mb-8-2">
|
||||||
|
|
||||||
|
<a-form-item label="审核" name="">
|
||||||
|
<a-radio-group v-model:value="auditStatus">
|
||||||
|
<a-radio :value="2">通过</a-radio>
|
||||||
|
<a-radio :value="99">不通过</a-radio>
|
||||||
|
</a-radio-group>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
<a-form-item label="备注" name="">
|
||||||
|
<a-textarea :placeholder="'请输入审核备注'" v-model:value="remark"
|
||||||
|
:auto-size="{ minRows: 2, maxRows: 5 }"></a-textarea>
|
||||||
|
</a-form-item>
|
||||||
|
|
||||||
|
</a-card>
|
||||||
|
</a-modal>
|
||||||
|
<a-modal v-model:open="imgOpen" :title="'图片/视频'" @ok="imgOpen = false">
|
||||||
|
<a-card class="mb-8-2">
|
||||||
|
<a-form-item :label="'图片'" name="images">
|
||||||
|
<template v-if="currentInfo.images && currentInfo.images.length > 0">
|
||||||
|
<a-image-preview-group>
|
||||||
|
<a-image v-for="item in currentInfo.images" :width="200"
|
||||||
|
:src="config('http.apiBasic') + item" />
|
||||||
|
</a-image-preview-group>
|
||||||
|
</template>
|
||||||
|
<template v-else>暂无</template>
|
||||||
|
|
||||||
|
</a-form-item>
|
||||||
|
<a-form-item label="视频" name="video">
|
||||||
|
<template v-if="currentInfo.videos && currentInfo.videos.length > 0">
|
||||||
|
<video width="320" height="240" controls>
|
||||||
|
<source v-for="item in currentInfo.videos" :src="config('http.apiBasic') + item">
|
||||||
|
</video>
|
||||||
|
</template>
|
||||||
|
<template>暂无</template>
|
||||||
|
</a-form-item>
|
||||||
|
</a-card>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { message, Modal } from 'ant-design-vue'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
import apis from '@/apis'
|
||||||
|
import { config } from '@/config'
|
||||||
|
import { usePagination } from '@/hooks'
|
||||||
|
import dayjs from 'dayjs'
|
||||||
|
import EditDialog from './components/EditDialog.vue'
|
||||||
|
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { orderStatus } from '@/enums/index.js'
|
||||||
|
import { status } from 'nprogress'
|
||||||
|
defineOptions({
|
||||||
|
name: 'orderList',
|
||||||
|
})
|
||||||
|
const { t } = useI18n() // 解构出t方法
|
||||||
|
const columns = [
|
||||||
|
{ title: '用户名', dataIndex: 'name' },
|
||||||
|
{ title: '身份证号', dataIndex: 'iDCard' },
|
||||||
|
{ title: '联系电话', dataIndex: 'phone' },
|
||||||
|
{ title: '联系地址', dataIndex: 'address', width: 300 },
|
||||||
|
{ title: '报名时间', dataIndex: 'createdAt', width: 300 },
|
||||||
|
|
||||||
|
]
|
||||||
|
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } = usePagination()
|
||||||
|
const remark = ref('')
|
||||||
|
const currentInfo = ref({})
|
||||||
|
const auditStatus = ref(2)
|
||||||
|
const editDialogRef = ref()
|
||||||
|
const open = ref(false)
|
||||||
|
const imgOpen = ref(false)
|
||||||
|
const activityList = ref([])
|
||||||
|
|
||||||
|
getPageList()
|
||||||
|
getActiveList()
|
||||||
|
/**
|
||||||
|
* 获取活动报名列表
|
||||||
|
* @returns {Promise<void>}
|
||||||
|
*/
|
||||||
|
async function getPageList() {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
const { pageSize, current } = paginationState
|
||||||
|
const { success, data, total } = await apis.vote
|
||||||
|
.getElectionList({
|
||||||
|
pageSize,
|
||||||
|
current: current,
|
||||||
|
...searchFormData.value,
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
listData.value = data.map(item => ({
|
||||||
|
...item,
|
||||||
|
key: item.value,
|
||||||
|
}))
|
||||||
|
paginationState.total = total
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 获取活动列表
|
||||||
|
async function getActiveList() {
|
||||||
|
try {
|
||||||
|
showLoading()
|
||||||
|
const { success, data } = await apis.activity
|
||||||
|
.getProjectList({
|
||||||
|
pageSize: 99,
|
||||||
|
current: 1,
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
hideLoading()
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
activityList.value = data.map(item => ({ id: item.id, title: item.title }))
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 下载文件
|
||||||
|
*/
|
||||||
|
async function handleExport() {
|
||||||
|
try {
|
||||||
|
const response = await apis.vote.exportFile()
|
||||||
|
console.log(response)
|
||||||
|
const url = window.URL.createObjectURL(new Blob([response]))
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.href = url
|
||||||
|
link.setAttribute('download', '报名表.xlsx') // 设置下载文件名
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click()
|
||||||
|
document.body.removeChild(link)
|
||||||
|
window.URL.revokeObjectURL(url)
|
||||||
|
} catch (error) {
|
||||||
|
// message.error('导出失败:' + (error.message || '未知错误'))
|
||||||
|
// console.error('导出文件出错:', error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const handleClick = async () => {
|
||||||
|
try {
|
||||||
|
const params = {
|
||||||
|
...currentInfo.value,
|
||||||
|
status: auditStatus.value,
|
||||||
|
remark: remark.value
|
||||||
|
}
|
||||||
|
const result = await apis.orderList.updateMenu(currentInfo.value.id, params).catch(() => {
|
||||||
|
throw new Error(error)
|
||||||
|
})
|
||||||
|
if (config('http.code.success') === result?.success) {
|
||||||
|
message.success('已审核')
|
||||||
|
open.value = false
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error({ content: error.message })
|
||||||
|
hideLoading()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 删除
|
||||||
|
*/
|
||||||
|
function handleDelete(value) {
|
||||||
|
Modal.confirm({
|
||||||
|
title: '确定撤销该工单吗',
|
||||||
|
content: t('button.confirm'),
|
||||||
|
okText: t('button.confirm'),
|
||||||
|
onOk: () => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
; (async () => {
|
||||||
|
try {
|
||||||
|
const params = {
|
||||||
|
...value,
|
||||||
|
status: 98
|
||||||
|
}
|
||||||
|
console.log(params)
|
||||||
|
const { success } = await apis.orderList.updateMenu(value.id, params).catch(() => {
|
||||||
|
throw new Error()
|
||||||
|
})
|
||||||
|
if (config('http.code.success') === success) {
|
||||||
|
resolve()
|
||||||
|
message.success('撤销成功')
|
||||||
|
await getPageList()
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
reject()
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*/
|
||||||
|
function onTableChange({ current, pageSize }) {
|
||||||
|
paginationState.current = current
|
||||||
|
paginationState.pageSize = pageSize
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 搜索
|
||||||
|
*/
|
||||||
|
function handleSearch() {
|
||||||
|
resetPagination()
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 重置
|
||||||
|
*/
|
||||||
|
function handleResetSearch() {
|
||||||
|
searchFormData.value = {}
|
||||||
|
resetPagination()
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 编辑完成
|
||||||
|
*/
|
||||||
|
async function onOk() {
|
||||||
|
await getPageList()
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
@ -96,7 +96,8 @@ defineOptions({
|
|||||||
const { t } = useI18n() // 解构出t方法
|
const { t } = useI18n() // 解构出t方法
|
||||||
const columns = [
|
const columns = [
|
||||||
// { title: '用户名称', dataIndex: 'customerName', width: 100 },
|
// { title: '用户名称', dataIndex: 'customerName', width: 100 },
|
||||||
{ title: '工单分类', dataIndex: 'label', width: 100 },
|
{ title: '工单分类', dataIndex: 'orderType', width: 100 },
|
||||||
|
{ title: '工单区域', dataIndex: 'orderAreaName', width: 150 },
|
||||||
// { title: '工单标题', dataIndex: 'content', ellipsis: true },
|
// { title: '工单标题', dataIndex: 'content', ellipsis: true },
|
||||||
{ title: '工单内容', dataIndex: 'title', ellipsis: true, width: 200 },
|
{ title: '工单内容', dataIndex: 'title', ellipsis: true, width: 200 },
|
||||||
{ title: '图片/视频', dataIndex: 'url', width: 100, align: 'center' },
|
{ title: '图片/视频', dataIndex: 'url', width: 100, align: 'center' },
|
||||||
@ -218,10 +219,9 @@ function handleDelete(value) {
|
|||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
...value,
|
...value,
|
||||||
status: 98
|
|
||||||
}
|
}
|
||||||
console.log(params)
|
console.log(params)
|
||||||
const { success } = await apis.orderList.updateMenu(value.id, params).catch(() => {
|
const { success } = await apis.orderList.delMenu(value.id, params).catch(() => {
|
||||||
throw new Error()
|
throw new Error()
|
||||||
})
|
})
|
||||||
if (config('http.code.success') === success) {
|
if (config('http.code.success') === success) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user