generated from Leo_Ding/web-template
Compare commits
No commits in common. "96999caa3bebf44266933c86329c6a24db24349a" and "f72a65b86d7ff6537e41307f9644fcdff7b4be1c" have entirely different histories.
96999caa3b
...
f72a65b86d
@ -18,38 +18,22 @@
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'报名截止时间'" name="endSignupAt">
|
||||
<a-date-picker
|
||||
v-model:value="formData.endSignupAt"
|
||||
placeholder="请输入报名截止时间"
|
||||
style="width: 100%;"
|
||||
show-time
|
||||
:format="displayFormat"
|
||||
:value-format="valueFormat"
|
||||
/>
|
||||
<a-date-picker v-model:value="formData.endSignupAt" placeholder="请输入报名截止时间"
|
||||
style="width: 100%;" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
|
||||
<a-form-item label="活动开始时间" name="startAt">
|
||||
<a-date-picker
|
||||
v-model:value="formData.startAt"
|
||||
placeholder="请选择活动开始时间"
|
||||
style="width: 100%;"
|
||||
show-time
|
||||
:format="displayFormat"
|
||||
:value-format="valueFormat"
|
||||
/>
|
||||
<a-date-picker v-model:value="formData.startAt" placeholder="请选择活动开始时间"
|
||||
style="width: 100%;" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
|
||||
<a-form-item label="活动结束时间" name="endAt">
|
||||
<a-date-picker
|
||||
v-model:value="formData.endAt"
|
||||
placeholder="请选择活动结束时间"
|
||||
style="width: 100%;"
|
||||
show-time
|
||||
:format="displayFormat"
|
||||
:value-format="valueFormat"
|
||||
/>
|
||||
<a-date-picker v-model:value="formData.endAt" placeholder="请选择活动结束时间"
|
||||
style="width: 100%;" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-form-item :label="'活动报名人数'" name="maxSignupNum">
|
||||
@ -57,6 +41,7 @@
|
||||
style="width: 100%" />
|
||||
</a-form-item>
|
||||
|
||||
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'状态'" name="status">
|
||||
<a-radio-group v-model:value="formData.status" :options="activatyStatus.getAll()"
|
||||
@ -89,43 +74,30 @@ import { useForm, useModal, useSpining } from '@/hooks'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import dayjs from 'dayjs'
|
||||
import utc from 'dayjs/plugin/utc'
|
||||
import timezone from 'dayjs/plugin/timezone'
|
||||
import GxUpload from '@/components/GxUpload/index.vue'
|
||||
import { spliceUrl } from "@/utils/util"
|
||||
import { activatyStatus } from '@/enums/index'
|
||||
|
||||
// 扩展dayjs的时区功能
|
||||
dayjs.extend(utc)
|
||||
dayjs.extend(timezone)
|
||||
|
||||
const emit = defineEmits(['ok'])
|
||||
const { t } = useI18n()
|
||||
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 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 = {
|
||||
title: [{ required: true, message: '请输入活动名称' }],
|
||||
openAt: [{ required: true, message: '请输入活动时间' }],
|
||||
cover: [{ required: false, message: '请上传图片', trigger: 'change' }],
|
||||
images: [{ required: false, message: '请上传图片', trigger: 'change' }],
|
||||
endSignupAt: [{ required: true, message: '请选择报名截止时间', trigger: 'change' }],
|
||||
startAt: [{ required: true, message: '请选择活动开始时间', trigger: 'change' }],
|
||||
endAt: [{ required: true, message: '请选择活动结束时间', trigger: 'change' }],
|
||||
startAt: [{ required: true, message: '请选择报名开始时间', trigger: 'change' }],
|
||||
endAt: [{ required: true, message: '请选择报名结束时间', trigger: 'change' }],
|
||||
activityContent: [{ required: true, message: '请输入活动内容' }]
|
||||
}
|
||||
|
||||
onBeforeMount(() => {
|
||||
// Initialize if needed
|
||||
|
||||
})
|
||||
|
||||
/**
|
||||
@ -136,6 +108,7 @@ function handleCreate() {
|
||||
type: 'create',
|
||||
title: '新增活动',
|
||||
})
|
||||
// initData()
|
||||
formData.value.status = 1
|
||||
formData.value.maxSignupNum = 0
|
||||
}
|
||||
@ -156,18 +129,9 @@ async function handleEdit(record = {}) {
|
||||
return
|
||||
}
|
||||
hideSpining()
|
||||
|
||||
// 转换后端时间格式为组件需要的格式
|
||||
formData.value = {
|
||||
...data,
|
||||
// 确保时间格式正确解析
|
||||
endSignupAt: data.endSignupAt ? dayjs(data.endSignupAt) : null,
|
||||
startAt: data.startAt ? dayjs(data.startAt) : null,
|
||||
endAt: data.endAt ? dayjs(data.endAt) : null
|
||||
}
|
||||
|
||||
formData.value = { ...data }
|
||||
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 {
|
||||
formData.value.images = []
|
||||
}
|
||||
@ -180,8 +144,11 @@ async function handleEdit(record = {}) {
|
||||
message.error({ content: error.message })
|
||||
hideSpining()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
const uploadSuccess = (data) => {
|
||||
fileList.value.push(data)
|
||||
}
|
||||
/**
|
||||
* 确定
|
||||
*/
|
||||
@ -189,23 +156,13 @@ function handleOk() {
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
|
||||
// 处理时间格式,确保符合要求
|
||||
const formatTime = (timeStr) => {
|
||||
if (!timeStr) return null;
|
||||
// 确保时间字符串正确转换为所需格式
|
||||
return dayjs(timeStr).format(valueFormat);
|
||||
};
|
||||
|
||||
const params = {
|
||||
...values,
|
||||
maxSignupNum: parseInt(values.maxSignupNum) || 0,
|
||||
cover: formData.value.cover ? spliceUrl(formData.value.cover[0]) : '',
|
||||
images: formData.value.images ? formData.value.images.map(item => spliceUrl(item)) : [],
|
||||
signupNum: formData.value.signupNum || 0,
|
||||
status: 1
|
||||
}
|
||||
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
@ -214,7 +171,7 @@ function handleOk() {
|
||||
})
|
||||
break
|
||||
case 'edit':
|
||||
result = await apis.activity.updateItem(formData.value.id, params).catch((error) => {
|
||||
result = await apis.activity.updateItem(formData.value.id, params).catch(() => {
|
||||
throw new Error(error)
|
||||
})
|
||||
break
|
||||
@ -229,11 +186,12 @@ function handleOk() {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
hideLoading()
|
||||
})
|
||||
.catch((e) => {
|
||||
hideLoading()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 取消
|
||||
*/
|
||||
@ -241,6 +199,13 @@ function handleCancel() {
|
||||
formData.value.areaId = 1
|
||||
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)
|
||||
};
|
||||
|
||||
/**
|
||||
* 关闭后
|
||||
|
||||
@ -1,251 +0,0 @@
|
||||
<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>
|
||||
@ -96,8 +96,7 @@ defineOptions({
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
// { title: '用户名称', dataIndex: 'customerName', width: 100 },
|
||||
{ title: '工单分类', dataIndex: 'orderType', width: 100 },
|
||||
{ title: '工单区域', dataIndex: 'orderAreaName', width: 150 },
|
||||
{ title: '工单分类', dataIndex: 'label', width: 100 },
|
||||
// { title: '工单标题', dataIndex: 'content', ellipsis: true },
|
||||
{ title: '工单内容', dataIndex: 'title', ellipsis: true, width: 200 },
|
||||
{ title: '图片/视频', dataIndex: 'url', width: 100, align: 'center' },
|
||||
@ -219,9 +218,10 @@ function handleDelete(value) {
|
||||
try {
|
||||
const params = {
|
||||
...value,
|
||||
status: 98
|
||||
}
|
||||
console.log(params)
|
||||
const { success } = await apis.orderList.delMenu(value.id, params).catch(() => {
|
||||
const { success } = await apis.orderList.updateMenu(value.id, params).catch(() => {
|
||||
throw new Error()
|
||||
})
|
||||
if (config('http.code.success') === success) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user