generated from Leo_Ding/web-template
7月4日迭代
This commit is contained in:
parent
66f7e74b8e
commit
f91b1537b6
4
.env.dev
4
.env.dev
@ -12,8 +12,8 @@ VITE_ROUTER_BASE=/
|
|||||||
VITE_ROUTER_HISTORY=hash
|
VITE_ROUTER_HISTORY=hash
|
||||||
|
|
||||||
# api
|
# api
|
||||||
VITE_API_BASIC=https://api.hailin-keji.com
|
# VITE_API_BASIC=https://api.hailin-keji.com
|
||||||
#VITE_API_BASIC=http://10.10.1.6:8060
|
VITE_API_BASIC=http://10.10.1.6:8060
|
||||||
VITE_API_HTTP=/api/v1/
|
VITE_API_HTTP=/api/v1/
|
||||||
# storage
|
# storage
|
||||||
VITE_STORAGE_NAMESPACE = gin-admin_local_
|
VITE_STORAGE_NAMESPACE = gin-admin_local_
|
||||||
|
|||||||
10
src/apis/modules/companyInfo.js
Normal file
10
src/apis/modules/companyInfo.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* 海邻动态接口
|
||||||
|
*/
|
||||||
|
import request from '@/utils/request'
|
||||||
|
// 获取公司动态列表
|
||||||
|
export const getDataList = () => request.basic.get('/api/v1/companies')
|
||||||
|
|
||||||
|
// 更新动态
|
||||||
|
export const updateItem = (id, params) => request.basic.put(`/api/v1/companies/${id}`, params)
|
||||||
|
|
||||||
@ -1,126 +1,61 @@
|
|||||||
<template>
|
<template>
|
||||||
<x-search-bar class="mb-8-2">
|
<x-search-bar class="mb-8-2">
|
||||||
<template #default="{ gutter, colSpan }">
|
<template #default="{ gutter, colSpan }">
|
||||||
<a-form-item :label="'零容忍'" name="reportContent">
|
<a-form ref="formRef" :model="formData" :rules="formRules">
|
||||||
<a-textarea :placeholder="'请输入零容忍内容'" v-model:value="reportContent"></a-textarea>
|
<a-form-item :label="'标题'" name="title">
|
||||||
|
<a-textarea :placeholder="'请输入标题'" v-model:value="formData.title"></a-textarea>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="'零容忍图片'" name="reportImage">
|
<a-form-item :label="'封面'" name="cover">
|
||||||
<!-- <x-upload-image v-model="reportImage" @imgChange="imgChange" />-->
|
<gx-upload v-model="formData.cover" :fileNumber="1" />
|
||||||
<gx-upload v-model="reportImage" :fileNumber="1" />
|
|
||||||
<p class="hint">750*500px,图片大小不超过150kb</p>
|
<p class="hint">750*500px,图片大小不超过150kb</p>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="'举报邮箱'" name="email">
|
<a-form-item :label="'内容'" name="content">
|
||||||
<a-input :placeholder="'请输入举报邮箱'" v-model:value="email"></a-input>
|
<x-editor v-model="formData.content" placeholder="请输入内容"></x-editor>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
<a-form-item :label="'经度'" name="lat">
|
<a-button @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
||||||
<a-input-number :placeholder="'请输入经度'" v-model:value="lat"></a-input-number>
|
</a-form>
|
||||||
</a-form-item>
|
|
||||||
<a-form-item :label="'纬度'" name="lon">
|
|
||||||
<a-input-number :placeholder="'请输入经度'" v-model:value="lon"></a-input-number>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item :label="'地址'" name="address">
|
|
||||||
<a-input :placeholder="'请输入地址'" v-model:value="address"></a-input>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item :label="'电话'" name="phone">
|
|
||||||
<a-input :placeholder="'请输入电话'" v-model:value="phone"></a-input>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item :label="'编码'" name="reportNum">
|
|
||||||
<a-input :placeholder="'请输入编码'" v-model:value="reportNum"></a-input>
|
|
||||||
</a-form-item>
|
|
||||||
<template v-if="Array.isArray(socialMedia)">
|
|
||||||
<a-form-item
|
|
||||||
v-for="(itemImg, index) in socialMedia"
|
|
||||||
:key="index"
|
|
||||||
:label="itemImg.name || `社交媒体${index + 1}`">
|
|
||||||
<a-input
|
|
||||||
class="inputPhone"
|
|
||||||
v-model:value="itemImg.name"
|
|
||||||
placeholder="请输入图片名称"
|
|
||||||
/>
|
|
||||||
<gx-upload
|
|
||||||
v-model="itemImg.image"
|
|
||||||
:fileNumber="1"
|
|
||||||
/>
|
|
||||||
<p class="hint">106*106px,图片大小不超过50kb</p>
|
|
||||||
<a-input
|
|
||||||
class="inputPhone"
|
|
||||||
v-model:value="itemImg.link"
|
|
||||||
placeholder="请输入跳转链接"
|
|
||||||
/>
|
|
||||||
<a-button
|
|
||||||
danger
|
|
||||||
@click="removeSocialMedia(index)"
|
|
||||||
size="small"
|
|
||||||
style="margin-bottom: 20px">删除
|
|
||||||
</a-button>
|
|
||||||
</a-form-item>
|
|
||||||
<a-form-item>
|
|
||||||
<a-button
|
|
||||||
type="dashed"
|
|
||||||
block
|
|
||||||
@click="addSocialMedia">新增社交媒体
|
|
||||||
</a-button>
|
|
||||||
</a-form-item>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
<x-editor :modelValue="affirm" @update:modelValue="affirm = $event" placeholder="请输入声明内容"></x-editor>
|
|
||||||
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
|
||||||
</template>
|
</template>
|
||||||
</x-search-bar>
|
</x-search-bar>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import { message } from 'ant-design-vue'
|
import { message } from 'ant-design-vue'
|
||||||
import { ref } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
|
import { useForm, useModal } from '@/hooks'
|
||||||
import apis from '@/apis' // 假设这里包含 saveAffirm 接口
|
import apis from '@/apis' // 假设这里包含 saveAffirm 接口
|
||||||
import { usePagination } from '@/hooks'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import { spliceUrl } from '@/utils/util'
|
import { spliceUrl } from '@/utils/util'
|
||||||
import { getWebData,updateWebData} from '@/apis/modules/webSite'
|
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||||
import XSearchBar from '@/components/SearchBar/SearchBar.vue'
|
|
||||||
import GxUpload from '@/components/GxUpload/index.vue' // 获取声明接口
|
|
||||||
import { config } from '@/config'
|
import { config } from '@/config'
|
||||||
import { getCompanies } from '@/apis/modules/companies'
|
import { getCompanies } from '@/apis/modules/companies'
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'contactUs',
|
name: 'contactUs',
|
||||||
})
|
})
|
||||||
const { t } = useI18n()
|
formRules.value = {
|
||||||
const { showLoading, hideLoading } = usePagination()
|
title: { required: true, message: '请输入标题' },
|
||||||
const affirm = ref(null)
|
content: { required: true, message: '请输入内容' },
|
||||||
const id = ref(null)
|
cover: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||||
const reportContent = ref(null)
|
|
||||||
const reportImage = ref(null)
|
|
||||||
const email = ref(null)
|
|
||||||
const lat = ref(null)
|
|
||||||
const lon = ref(null)
|
|
||||||
const address = ref(null)
|
|
||||||
const phone = ref(null)
|
|
||||||
const reportNum = ref(null)
|
|
||||||
const socialMedia = ref([{ name: '', image: '', link: '' }])
|
|
||||||
const imgChange = (index, value) => {
|
|
||||||
socialMedia.value[index].image = value
|
|
||||||
reportImage.value = value
|
|
||||||
}
|
}
|
||||||
|
const { showLoading, hideLoading } = useModal()
|
||||||
|
const reportImage = ref(null)
|
||||||
|
const socialMedia = ref([{ name: '', image: '', link: '' }])
|
||||||
|
onMounted(() => {
|
||||||
|
getPageList()
|
||||||
|
})
|
||||||
// 页面加载时获取声明内容
|
// 页面加载时获取声明内容
|
||||||
getPageList()
|
|
||||||
/**
|
/**
|
||||||
* 获取声明内容
|
* 获取声明内容
|
||||||
*/
|
*/
|
||||||
async function getPageList() {
|
async function getPageList() {
|
||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
const res = await getCompanies() // 假设返回格式为 { data: { affirm: '内容' } }
|
const { data, success } = await apis.companyInfo.getDataList()
|
||||||
if (res?.data) {
|
if (success) {
|
||||||
id.value = res.data.id
|
formData.value = {
|
||||||
affirm.value = res.data.affirm
|
id: data.id,
|
||||||
reportContent.value = res.data.reportContent
|
title: data.title,
|
||||||
reportImage.value = [config('http.apiBasic')+res.data.reportImage]
|
cover: data.cover ? [config('http.apiBasic') + data.cover] : [],
|
||||||
email.value = res.data.email
|
content: data.content
|
||||||
lat.value = res.data.lat
|
}
|
||||||
lon.value = res.data.lon
|
|
||||||
address.value = res.data.address
|
|
||||||
phone.value = res.data.phone
|
|
||||||
reportNum.value = res.data.reportNum
|
|
||||||
socialMedia.value = Array.isArray(res.data.socialMedia) ? res.data.socialMedia.map(item=>({link:item.link,name:item.name,image:[config('http.apiBasic')+item.image]})) : []
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error('获取声明内容失败')
|
message.error('获取声明内容失败')
|
||||||
@ -132,77 +67,30 @@ async function getPageList() {
|
|||||||
* 提交声明内容
|
* 提交声明内容
|
||||||
*/
|
*/
|
||||||
async function handleSearch() {
|
async function handleSearch() {
|
||||||
|
formRef.value.validateFields().then(async (values) => {
|
||||||
try {
|
try {
|
||||||
showLoading()
|
showLoading()
|
||||||
// 转换 socialMedia.image 为字符串
|
const params = {
|
||||||
// const formattedSocialMedia = Array.isArray(socialMedia.value)
|
id:formData.value.id,
|
||||||
// ? socialMedia.value.map(item => ({
|
title: formData.value.title,
|
||||||
// ...item,
|
cover: formData.value.cover ? spliceUrl(formData.value.cover[0]) : '',
|
||||||
// image: Array.isArray(item.image) ? item.image[0] : item.image
|
content: formData.value.content
|
||||||
// }))
|
}
|
||||||
// : []
|
const { success } = await apis.companyInfo.updateItem(formData.value.id, params)
|
||||||
const formattedSocialMedia = Array.isArray(socialMedia?.value)
|
if (success) {
|
||||||
? socialMedia.value.map(item => {
|
|
||||||
const imageRaw = Array.isArray(item?.image)
|
|
||||||
? item.image[0]
|
|
||||||
: item?.image;
|
|
||||||
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
image: spliceUrl(imageRaw)
|
|
||||||
};
|
|
||||||
})
|
|
||||||
: [];
|
|
||||||
|
|
||||||
const reportImageRaw = Array.isArray(reportImage?.value)
|
|
||||||
? reportImage.value[0]
|
|
||||||
: reportImage?.value;
|
|
||||||
const reportImageFormatted = {
|
|
||||||
reportImage: spliceUrl(reportImageRaw)};
|
|
||||||
|
|
||||||
await apis.webSite.updateWebData(id.value, {
|
|
||||||
affirm: affirm.value,
|
|
||||||
reportContent: reportContent.value,
|
|
||||||
reportImage: reportImageFormatted.reportImage,
|
|
||||||
//reportImage:Array.isArray(reportImage.value) ? reportImage.value[0] : reportImage.value,
|
|
||||||
email: email.value,
|
|
||||||
lat: lat.value,
|
|
||||||
lon: lon.value,
|
|
||||||
address: address.value,
|
|
||||||
phone: phone.value,
|
|
||||||
reportNum: reportNum.value,
|
|
||||||
socialMedia: formattedSocialMedia,
|
|
||||||
})
|
|
||||||
// await apis.webSite.updateWebData(id.value, {
|
|
||||||
// affirm: affirm.value,
|
|
||||||
// reportContent: reportContent.value,
|
|
||||||
//
|
|
||||||
// reportImage: reportImage.value,
|
|
||||||
//
|
|
||||||
// email: email.value,
|
|
||||||
// lat: lat.value,
|
|
||||||
// lon: lon.value,
|
|
||||||
// address: address.value,
|
|
||||||
// phone: phone.value,
|
|
||||||
// reportNum: reportNum.value,
|
|
||||||
//
|
|
||||||
// socialMedia: socialMedia.value,
|
|
||||||
// })
|
|
||||||
message.success('保存成功')
|
message.success('保存成功')
|
||||||
|
getPageList()
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error('保存失败,请重试')
|
message.error('保存失败,请重试')
|
||||||
} finally {
|
} finally {
|
||||||
hideLoading()
|
hideLoading()
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addSocialMedia() {
|
|
||||||
socialMedia.value.push({ name: '', image: '', link: '' })
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeSocialMedia(index) {
|
|
||||||
socialMedia.value.splice(index, 1)
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
|
|||||||
@ -1,146 +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-row :gutter="12">
|
|
||||||
<a-col :span="24">
|
|
||||||
<a-form-item :label="'父级分类'" name="parentID">
|
|
||||||
<a-tree-select v-model:value="formData.parentID" show-search style="width: 100%"
|
|
||||||
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" placeholder="请选择"
|
|
||||||
allow-clear tree-default-expand-all :tree-data="treeData"
|
|
||||||
tree-node-filter-prop="label">
|
|
||||||
</a-tree-select>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
<a-col :span="24">
|
|
||||||
<a-form-item :label="'产品分类'" name="label">
|
|
||||||
<a-input :placeholder="'请输入产品分类名称'" v-model:value="formData.label"></a-input>
|
|
||||||
</a-form-item>
|
|
||||||
</a-col>
|
|
||||||
|
|
||||||
</a-row>
|
|
||||||
</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 { spliceUrl } from '@/utils/util'
|
|
||||||
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 treeData=ref([])
|
|
||||||
formRules.value = {
|
|
||||||
label: { required: true, message: '请输入产品类别名称' },
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const initData = async () => {
|
|
||||||
const { success, data, total } = await apis.categorys
|
|
||||||
.getDataList({
|
|
||||||
pageSize:99,
|
|
||||||
page: 1,
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
if (config('http.code.success') === success) {
|
|
||||||
treeData.value = data.map(item => ({
|
|
||||||
...item
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 新建
|
|
||||||
*/
|
|
||||||
function handleCreate() {
|
|
||||||
showModal({
|
|
||||||
type: 'create',
|
|
||||||
title: '产品分类',
|
|
||||||
})
|
|
||||||
// 初始化所有字段
|
|
||||||
initData()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 确定
|
|
||||||
*/
|
|
||||||
function handleOk() {
|
|
||||||
formRef.value.validateFields().then(async (values) => {
|
|
||||||
try {
|
|
||||||
showLoading()
|
|
||||||
const params = {
|
|
||||||
...values,
|
|
||||||
parentID:formData.value.parentID?formData.value.parentID:0
|
|
||||||
}
|
|
||||||
let result = null
|
|
||||||
switch (modal.value.type) {
|
|
||||||
case 'create':
|
|
||||||
result = await apis.categorys.createProductsItem(params).catch((error) => {
|
|
||||||
throw new Error(error)
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case 'edit':
|
|
||||||
result = await apis.products.updateProductsItem(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()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 取消
|
|
||||||
*/
|
|
||||||
function handleCancel() {
|
|
||||||
hideModal()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 关闭后
|
|
||||||
*/
|
|
||||||
function onAfterClose() {
|
|
||||||
resetForm()
|
|
||||||
hideLoading()
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
handleCreate,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="less" scoped></style>
|
|
||||||
@ -1,154 +0,0 @@
|
|||||||
<template>
|
|
||||||
<a-row :gutter="8" :wrap="false">
|
|
||||||
<a-col flex="auto">
|
|
||||||
<a-card type="flex">
|
|
||||||
<x-action-bar class="mb-8-2">
|
|
||||||
<a-button type="primary" @click="$refs.editDialogRef.handleCreate()">
|
|
||||||
<template #icon>
|
|
||||||
<plus-outlined></plus-outlined>
|
|
||||||
</template>
|
|
||||||
新增分类
|
|
||||||
</a-button>
|
|
||||||
</x-action-bar>
|
|
||||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
|
||||||
:pagination="paginationState" @change="onTableChange">
|
|
||||||
<template #bodyCell="{ column, record }">
|
|
||||||
<template v-if="'status' === column.dataIndex">
|
|
||||||
<a-tag v-if="record.status === 'enabled'" :color="'green'">启用</a-tag>
|
|
||||||
<a-tag v-if="record.status === 'disabled'" :color="'red'">停用</a-tag>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<template v-if="'action' === column.key">
|
|
||||||
|
|
||||||
<x-action-button @click="handleDelete(record.value)">
|
|
||||||
<a-tooltip>
|
|
||||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
|
||||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</a-table>
|
|
||||||
</a-card>
|
|
||||||
</a-col>
|
|
||||||
</a-row>
|
|
||||||
|
|
||||||
<edit-dialog ref="editDialogRef" @ok="onOk"></edit-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { message, Modal } from 'ant-design-vue'
|
|
||||||
import { ref } from 'vue'
|
|
||||||
import apis from '@/apis'
|
|
||||||
import { formatUtcDateTime } from '@/utils/util'
|
|
||||||
import { config } from '@/config'
|
|
||||||
import { statusUserTypeEnum } from '@/enums/system'
|
|
||||||
import { usePagination } from '@/hooks'
|
|
||||||
|
|
||||||
import EditDialog from './components/EditDialog.vue'
|
|
||||||
import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vue'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import { delProductsItem, getProductsList } from '@/apis/modules/products'
|
|
||||||
defineOptions({
|
|
||||||
name: 'productType',
|
|
||||||
})
|
|
||||||
const { t } = useI18n() // 解构出t方法
|
|
||||||
const columns = [
|
|
||||||
{ title: '分类名称', dataIndex: 'label' },
|
|
||||||
// { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
|
||||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
|
||||||
]
|
|
||||||
const { listData, loading, showLoading, hideLoading, paginationState, resetPagination, searchFormData } =
|
|
||||||
usePagination()
|
|
||||||
|
|
||||||
const editDialogRef = ref()
|
|
||||||
getPageList()
|
|
||||||
/**
|
|
||||||
* 获取用户列表
|
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
|
||||||
async function getPageList() {
|
|
||||||
try {
|
|
||||||
showLoading()
|
|
||||||
const { pageSize, current } = paginationState
|
|
||||||
const { success, data, total } = await apis.categorys
|
|
||||||
.getDataList({
|
|
||||||
pageSize,
|
|
||||||
current:current,
|
|
||||||
})
|
|
||||||
.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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除
|
|
||||||
*/
|
|
||||||
function handleDelete(value) {
|
|
||||||
Modal.confirm({
|
|
||||||
title: '确定删除该分类吗',
|
|
||||||
content: t('button.confirm'),
|
|
||||||
okText: t('button.confirm'),
|
|
||||||
onOk: () => {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
; (async () => {
|
|
||||||
try {
|
|
||||||
const { success } = await apis.categorys.delProductsItem(value).catch(() => {
|
|
||||||
throw new Error()
|
|
||||||
})
|
|
||||||
if (config('http.code.success') === success) {
|
|
||||||
resolve()
|
|
||||||
message.success(t('component.message.success.delete'))
|
|
||||||
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>
|
|
||||||
@ -100,6 +100,9 @@
|
|||||||
|
|
||||||
</a-col>
|
</a-col>
|
||||||
</a-tab-pane>
|
</a-tab-pane>
|
||||||
|
<a-tab-pane key="4" tab="标准感官">
|
||||||
|
<x-editor v-model="formData.imageLabel" />
|
||||||
|
</a-tab-pane>
|
||||||
</a-tabs>
|
</a-tabs>
|
||||||
|
|
||||||
</a-card>
|
</a-card>
|
||||||
@ -203,6 +206,7 @@ function handleCreate() {
|
|||||||
images: [''],
|
images: [''],
|
||||||
sequence: null,
|
sequence: null,
|
||||||
status: 'enabled',
|
status: 'enabled',
|
||||||
|
imageLabel:''
|
||||||
}
|
}
|
||||||
initData()
|
initData()
|
||||||
}
|
}
|
||||||
@ -280,6 +284,7 @@ function handleOk() {
|
|||||||
}],
|
}],
|
||||||
feature: formData.value.feature,
|
feature: formData.value.feature,
|
||||||
images: formData.value.mainImage ? formData.value.mainImage.map(item => spliceUrl(item)) : [''],
|
images: formData.value.mainImage ? formData.value.mainImage.map(item => spliceUrl(item)) : [''],
|
||||||
|
imageLabel:formData.value.imageLabel
|
||||||
}
|
}
|
||||||
console.log(params)
|
console.log(params)
|
||||||
let result = null
|
let result = null
|
||||||
|
|||||||
@ -19,7 +19,11 @@
|
|||||||
<a-input :placeholder="'请输入产品分类名称'" v-model:value="formData.label"></a-input>
|
<a-input :placeholder="'请输入产品分类名称'" v-model:value="formData.label"></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
|
<a-col :span="24">
|
||||||
|
<a-form-item :label="'产品排序'" name="sequence">
|
||||||
|
<a-input-number :placeholder="'请输入排序'" v-model:value="formData.sequence"></a-input-number>
|
||||||
|
</a-form-item>
|
||||||
|
</a-col>
|
||||||
</a-row>
|
</a-row>
|
||||||
</a-card>
|
</a-card>
|
||||||
</a-form>
|
</a-form>
|
||||||
@ -46,16 +50,16 @@ 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 treeData=ref([])
|
const treeData = ref([])
|
||||||
formRules.value = {
|
formRules.value = {
|
||||||
label: { required: true, message: '请输入产品类别名称' },
|
label: { required: true, message: '请输入产品类别名称' },
|
||||||
|
sequence:{required: true, message: '请输入排序'}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const initData = async () => {
|
const initData = async () => {
|
||||||
const { success, data, total } = await apis.categorys
|
const { success, data, total } = await apis.categorys
|
||||||
.getDataList({
|
.getDataList({
|
||||||
pageSize:99,
|
pageSize: 99,
|
||||||
page: 1,
|
page: 1,
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
@ -79,7 +83,23 @@ function handleCreate() {
|
|||||||
initData()
|
initData()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑
|
||||||
|
*/
|
||||||
|
async function handleEdit(record = {}) {
|
||||||
|
initData()
|
||||||
|
console.log(record)
|
||||||
|
showModal({
|
||||||
|
type: 'edit',
|
||||||
|
title: '编辑分类',
|
||||||
|
})
|
||||||
|
const { data, success } = await apis.categorys.getItem(record.value).catch()
|
||||||
|
if (!success) {
|
||||||
|
hideModal()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
formData.value = { ...data }
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 确定
|
* 确定
|
||||||
*/
|
*/
|
||||||
@ -89,7 +109,7 @@ function handleOk() {
|
|||||||
showLoading()
|
showLoading()
|
||||||
const params = {
|
const params = {
|
||||||
...values,
|
...values,
|
||||||
parentID:formData.value.parentID?formData.value.parentID:0
|
parentID: formData.value.parentID ? formData.value.parentID : 0
|
||||||
}
|
}
|
||||||
let result = null
|
let result = null
|
||||||
switch (modal.value.type) {
|
switch (modal.value.type) {
|
||||||
@ -99,7 +119,7 @@ function handleOk() {
|
|||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'edit':
|
case 'edit':
|
||||||
result = await apis.products.updateProductsItem(formData.value.id, params).catch(() => {
|
result = await apis.categorys.updateProductsItem(formData.value.id, params).catch(() => {
|
||||||
throw new Error(error)
|
throw new Error(error)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
@ -138,6 +158,7 @@ function onAfterClose() {
|
|||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
handleCreate,
|
handleCreate,
|
||||||
|
handleEdit,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -19,8 +19,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template v-if="'action' === column.key">
|
<template v-if="'action' === column.key">
|
||||||
|
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||||
<x-action-button @click="handleDelete(record.value)">
|
<a-tooltip>
|
||||||
|
<template #title>编辑分类</template>
|
||||||
|
<edit-outlined /> </a-tooltip></x-action-button>
|
||||||
|
<x-action-button @click="handleDelete(record)">
|
||||||
<a-tooltip>
|
<a-tooltip>
|
||||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||||
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
<delete-outlined style="color: #ff4d4f" /> </a-tooltip></x-action-button>
|
||||||
@ -48,11 +51,12 @@ import { PlusOutlined, EditOutlined, DeleteOutlined } from '@ant-design/icons-vu
|
|||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { delProductsItem, getProductsList } from '@/apis/modules/products'
|
import { delProductsItem, getProductsList } from '@/apis/modules/products'
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'productClassify',
|
name: 'productType',
|
||||||
})
|
})
|
||||||
const { t } = useI18n() // 解构出t方法
|
const { t } = useI18n() // 解构出t方法
|
||||||
const columns = [
|
const columns = [
|
||||||
{ title: '分类名称', dataIndex: 'label' },
|
{ title: '分类名称', dataIndex: 'label' },
|
||||||
|
{ title: '分类排序', dataIndex: 'sequence' },
|
||||||
// { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
// { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||||
]
|
]
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item :label="'人物简介'">
|
<!-- <a-form-item :label="'人物简介'">
|
||||||
<a-select
|
<a-select
|
||||||
v-model:value="formData.rank"
|
v-model:value="formData.rank"
|
||||||
mode="tags"
|
mode="tags"
|
||||||
@ -29,6 +29,9 @@
|
|||||||
:token-separators="[',']"
|
:token-separators="[',']"
|
||||||
style="width: 100%;"
|
style="width: 100%;"
|
||||||
/>
|
/>
|
||||||
|
</a-form-item> -->
|
||||||
|
<a-form-item :label="'人物简介'" name="rank">
|
||||||
|
<x-editor v-model="formData.rank"/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
@ -77,7 +80,7 @@ const roles = ref([])
|
|||||||
const img = ref('')
|
const img = ref('')
|
||||||
formRules.value = {
|
formRules.value = {
|
||||||
name: { required: true, message: '请输入名称' },
|
name: { required: true, message: '请输入名称' },
|
||||||
rank: { required: true, message: '请输入人物简介' },
|
rank: { required: false, message: '请输入人物简介' },
|
||||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||||
@ -110,7 +113,7 @@ async function handleEdit(record = {}) {
|
|||||||
showModal({
|
showModal({
|
||||||
type: 'edit',
|
type: 'edit',
|
||||||
// 80对应about
|
// 80对应about
|
||||||
title: t('pages.system.user.edit'),
|
title: '编辑',
|
||||||
})
|
})
|
||||||
const { data, success } = await apis.team.getMenu(record.id).catch()
|
const { data, success } = await apis.team.getMenu(record.id).catch()
|
||||||
if (!success) {
|
if (!success) {
|
||||||
@ -138,7 +141,7 @@ function handleOk() {
|
|||||||
rank: formData.value.rank,
|
rank: formData.value.rank,
|
||||||
}
|
}
|
||||||
let result = null
|
let result = null
|
||||||
console.log(modal.value.type)
|
console.log(params)
|
||||||
switch (modal.value.type) {
|
switch (modal.value.type) {
|
||||||
case 'create':
|
case 'create':
|
||||||
result = await apis.team.createMenu(params).catch(() => {
|
result = await apis.team.createMenu(params).catch(() => {
|
||||||
|
|||||||
@ -54,23 +54,22 @@
|
|||||||
<span>{{ record.name }}</span>
|
<span>{{ record.name }}</span>
|
||||||
</a-tooltip>
|
</a-tooltip>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- <template v-if="column.dataIndex === 'rank'">-->
|
|
||||||
<!-- <a-tooltip :title="record.rank">-->
|
|
||||||
<!-- <span>{{ record.rank }}</span>-->
|
|
||||||
<!-- </a-tooltip>-->
|
|
||||||
<!-- </template>-->
|
|
||||||
<template v-if="column.dataIndex === 'rank'">
|
<template v-if="column.dataIndex === 'rank'">
|
||||||
|
<p v-html="record.rank"></p>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<!-- <template v-if="column.dataIndex === 'rank'">-->
|
||||||
|
<!-- <a-tooltip :title="record.rank">-->
|
||||||
|
<!-- <span>{{ record.rank }}</span>-->
|
||||||
|
<!-- </a-tooltip>-->
|
||||||
|
<!-- </template>-->
|
||||||
|
<!-- <template v-if="column.dataIndex === 'rank'">
|
||||||
<div>
|
<div>
|
||||||
<a-tag
|
<a-tag v-for="(item, index) in record.rank" :key="index" color="blue">
|
||||||
v-for="(item, index) in record.rank"
|
|
||||||
:key="index"
|
|
||||||
color="blue"
|
|
||||||
>
|
|
||||||
{{ item }}
|
{{ item }}
|
||||||
</a-tag>
|
</a-tag>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template> -->
|
||||||
|
|
||||||
|
|
||||||
<template v-if="column.dataIndex === 'area'">
|
<template v-if="column.dataIndex === 'area'">
|
||||||
@ -146,7 +145,7 @@ async function getPageList() {
|
|||||||
const { success, data, total } = await apis.team
|
const { success, data, total } = await apis.team
|
||||||
.getDataList({
|
.getDataList({
|
||||||
pageSize,
|
pageSize,
|
||||||
current:current,
|
current: current,
|
||||||
...searchFormData.value,
|
...searchFormData.value,
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
|
|||||||
@ -63,7 +63,9 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
<a-form-item :label="'网站声明'">
|
||||||
<x-editor :modelValue="affirm" @update:modelValue="affirm = $event" placeholder="请输入声明内容"></x-editor>
|
<x-editor :modelValue="affirm" @update:modelValue="affirm = $event" placeholder="请输入声明内容"></x-editor>
|
||||||
|
</a-form-item>
|
||||||
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
<a-button ghost type="primary" @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
||||||
</template>
|
</template>
|
||||||
</x-search-bar>
|
</x-search-bar>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user