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
|
||||
|
||||
# api
|
||||
VITE_API_BASIC=https://api.hailin-keji.com
|
||||
#VITE_API_BASIC=http://10.10.1.6:8060
|
||||
# VITE_API_BASIC=https://api.hailin-keji.com
|
||||
VITE_API_BASIC=http://10.10.1.6:8060
|
||||
VITE_API_HTTP=/api/v1/
|
||||
# storage
|
||||
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>
|
||||
<x-search-bar class="mb-8-2">
|
||||
<template #default="{ gutter, colSpan }">
|
||||
<a-form-item :label="'零容忍'" name="reportContent">
|
||||
<a-textarea :placeholder="'请输入零容忍内容'" v-model:value="reportContent"></a-textarea>
|
||||
</a-form-item>
|
||||
<a-form-item :label="'零容忍图片'" name="reportImage">
|
||||
<!-- <x-upload-image v-model="reportImage" @imgChange="imgChange" />-->
|
||||
<gx-upload v-model="reportImage" :fileNumber="1" />
|
||||
<p class="hint">750*500px,图片大小不超过150kb</p>
|
||||
</a-form-item>
|
||||
<a-form-item :label="'举报邮箱'" name="email">
|
||||
<a-input :placeholder="'请输入举报邮箱'" v-model:value="email"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item :label="'经度'" name="lat">
|
||||
<a-input-number :placeholder="'请输入经度'" v-model:value="lat"></a-input-number>
|
||||
</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 ref="formRef" :model="formData" :rules="formRules">
|
||||
<a-form-item :label="'标题'" name="title">
|
||||
<a-textarea :placeholder="'请输入标题'" v-model:value="formData.title"></a-textarea>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<a-button
|
||||
type="dashed"
|
||||
block
|
||||
@click="addSocialMedia">新增社交媒体
|
||||
</a-button>
|
||||
<a-form-item :label="'封面'" name="cover">
|
||||
<gx-upload v-model="formData.cover" :fileNumber="1" />
|
||||
<p class="hint">750*500px,图片大小不超过150kb</p>
|
||||
</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>
|
||||
<a-form-item :label="'内容'" name="content">
|
||||
<x-editor v-model="formData.content" placeholder="请输入内容"></x-editor>
|
||||
</a-form-item>
|
||||
<a-button @click="handleSearch" style="margin-top: 20px">保存</a-button>
|
||||
</a-form>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
</template>
|
||||
<script setup>
|
||||
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 { usePagination } from '@/hooks'
|
||||
import { useI18n } from 'vue-i18n'
|
||||
import { spliceUrl } from '@/utils/util'
|
||||
import { getWebData,updateWebData} from '@/apis/modules/webSite'
|
||||
import XSearchBar from '@/components/SearchBar/SearchBar.vue'
|
||||
import GxUpload from '@/components/GxUpload/index.vue' // 获取声明接口
|
||||
const { formRecord, formData, formRef, formRules, resetForm } = useForm()
|
||||
import { config } from '@/config'
|
||||
import { getCompanies } from '@/apis/modules/companies'
|
||||
defineOptions({
|
||||
name: 'contactUs',
|
||||
})
|
||||
const { t } = useI18n()
|
||||
const { showLoading, hideLoading } = usePagination()
|
||||
const affirm = ref(null)
|
||||
const id = ref(null)
|
||||
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
|
||||
formRules.value = {
|
||||
title: { required: true, message: '请输入标题' },
|
||||
content: { required: true, message: '请输入内容' },
|
||||
cover: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
}
|
||||
const { showLoading, hideLoading } = useModal()
|
||||
const reportImage = ref(null)
|
||||
const socialMedia = ref([{ name: '', image: '', link: '' }])
|
||||
onMounted(() => {
|
||||
getPageList()
|
||||
})
|
||||
// 页面加载时获取声明内容
|
||||
getPageList()
|
||||
|
||||
/**
|
||||
* 获取声明内容
|
||||
*/
|
||||
async function getPageList() {
|
||||
try {
|
||||
showLoading()
|
||||
const res = await getCompanies() // 假设返回格式为 { data: { affirm: '内容' } }
|
||||
if (res?.data) {
|
||||
id.value = res.data.id
|
||||
affirm.value = res.data.affirm
|
||||
reportContent.value = res.data.reportContent
|
||||
reportImage.value = [config('http.apiBasic')+res.data.reportImage]
|
||||
email.value = res.data.email
|
||||
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]})) : []
|
||||
const { data, success } = await apis.companyInfo.getDataList()
|
||||
if (success) {
|
||||
formData.value = {
|
||||
id: data.id,
|
||||
title: data.title,
|
||||
cover: data.cover ? [config('http.apiBasic') + data.cover] : [],
|
||||
content: data.content
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('获取声明内容失败')
|
||||
@ -132,77 +67,30 @@ async function getPageList() {
|
||||
* 提交声明内容
|
||||
*/
|
||||
async function handleSearch() {
|
||||
try {
|
||||
showLoading()
|
||||
// 转换 socialMedia.image 为字符串
|
||||
// const formattedSocialMedia = Array.isArray(socialMedia.value)
|
||||
// ? socialMedia.value.map(item => ({
|
||||
// ...item,
|
||||
// image: Array.isArray(item.image) ? item.image[0] : item.image
|
||||
// }))
|
||||
// : []
|
||||
const formattedSocialMedia = Array.isArray(socialMedia?.value)
|
||||
? socialMedia.value.map(item => {
|
||||
const imageRaw = Array.isArray(item?.image)
|
||||
? item.image[0]
|
||||
: item?.image;
|
||||
formRef.value.validateFields().then(async (values) => {
|
||||
try {
|
||||
showLoading()
|
||||
const params = {
|
||||
id:formData.value.id,
|
||||
title: formData.value.title,
|
||||
cover: formData.value.cover ? spliceUrl(formData.value.cover[0]) : '',
|
||||
content: formData.value.content
|
||||
}
|
||||
const { success } = await apis.companyInfo.updateItem(formData.value.id, params)
|
||||
if (success) {
|
||||
message.success('保存成功')
|
||||
getPageList()
|
||||
}
|
||||
} catch (e) {
|
||||
message.error('保存失败,请重试')
|
||||
} finally {
|
||||
hideLoading()
|
||||
}
|
||||
})
|
||||
|
||||
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('保存成功')
|
||||
} catch (e) {
|
||||
message.error('保存失败,请重试')
|
||||
} finally {
|
||||
hideLoading()
|
||||
}
|
||||
}
|
||||
|
||||
function addSocialMedia() {
|
||||
socialMedia.value.push({ name: '', image: '', link: '' })
|
||||
}
|
||||
|
||||
function removeSocialMedia(index) {
|
||||
socialMedia.value.splice(index, 1)
|
||||
}
|
||||
</script>
|
||||
|
||||
<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-tab-pane>
|
||||
<a-tab-pane key="4" tab="标准感官">
|
||||
<x-editor v-model="formData.imageLabel" />
|
||||
</a-tab-pane>
|
||||
</a-tabs>
|
||||
|
||||
</a-card>
|
||||
@ -203,6 +206,7 @@ function handleCreate() {
|
||||
images: [''],
|
||||
sequence: null,
|
||||
status: 'enabled',
|
||||
imageLabel:''
|
||||
}
|
||||
initData()
|
||||
}
|
||||
@ -280,6 +284,7 @@ function handleOk() {
|
||||
}],
|
||||
feature: formData.value.feature,
|
||||
images: formData.value.mainImage ? formData.value.mainImage.map(item => spliceUrl(item)) : [''],
|
||||
imageLabel:formData.value.imageLabel
|
||||
}
|
||||
console.log(params)
|
||||
let result = null
|
||||
|
||||
@ -19,7 +19,11 @@
|
||||
<a-input :placeholder="'请输入产品分类名称'" v-model:value="formData.label"></a-input>
|
||||
</a-form-item>
|
||||
</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-card>
|
||||
</a-form>
|
||||
@ -46,16 +50,16 @@ 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([])
|
||||
const treeData = ref([])
|
||||
formRules.value = {
|
||||
label: { required: true, message: '请输入产品类别名称' },
|
||||
sequence:{required: true, message: '请输入排序'}
|
||||
}
|
||||
|
||||
|
||||
const initData = async () => {
|
||||
const { success, data, total } = await apis.categorys
|
||||
.getDataList({
|
||||
pageSize:99,
|
||||
pageSize: 99,
|
||||
page: 1,
|
||||
})
|
||||
.catch(() => {
|
||||
@ -79,7 +83,23 @@ function handleCreate() {
|
||||
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()
|
||||
const params = {
|
||||
...values,
|
||||
parentID:formData.value.parentID?formData.value.parentID:0
|
||||
parentID: formData.value.parentID ? formData.value.parentID : 0
|
||||
}
|
||||
let result = null
|
||||
switch (modal.value.type) {
|
||||
@ -99,7 +119,7 @@ function handleOk() {
|
||||
})
|
||||
break
|
||||
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)
|
||||
})
|
||||
break
|
||||
@ -138,6 +158,7 @@ function onAfterClose() {
|
||||
|
||||
defineExpose({
|
||||
handleCreate,
|
||||
handleEdit,
|
||||
})
|
||||
|
||||
|
||||
|
||||
@ -19,8 +19,11 @@
|
||||
</template>
|
||||
|
||||
<template v-if="'action' === column.key">
|
||||
|
||||
<x-action-button @click="handleDelete(record.value)">
|
||||
<x-action-button @click="$refs.editDialogRef.handleEdit(record)">
|
||||
<a-tooltip>
|
||||
<template #title>编辑分类</template>
|
||||
<edit-outlined /> </a-tooltip></x-action-button>
|
||||
<x-action-button @click="handleDelete(record)">
|
||||
<a-tooltip>
|
||||
<template #title>{{ $t('pages.system.delete') }}</template>
|
||||
<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 { delProductsItem, getProductsList } from '@/apis/modules/products'
|
||||
defineOptions({
|
||||
name: 'productClassify',
|
||||
name: 'productType',
|
||||
})
|
||||
const { t } = useI18n() // 解构出t方法
|
||||
const columns = [
|
||||
{ title: '分类名称', dataIndex: 'label' },
|
||||
{ title: '分类排序', dataIndex: 'sequence' },
|
||||
// { title: '状态', dataIndex: 'status', width: 120, align: 'center' },
|
||||
{ title: t('button.action'), key: 'action', fixed: 'right', width: 100, align: 'center' },
|
||||
]
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item :label="'人物简介'">
|
||||
<!-- <a-form-item :label="'人物简介'">
|
||||
<a-select
|
||||
v-model:value="formData.rank"
|
||||
mode="tags"
|
||||
@ -29,6 +29,9 @@
|
||||
:token-separators="[',']"
|
||||
style="width: 100%;"
|
||||
/>
|
||||
</a-form-item> -->
|
||||
<a-form-item :label="'人物简介'" name="rank">
|
||||
<x-editor v-model="formData.rank"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
@ -77,7 +80,7 @@ const roles = ref([])
|
||||
const img = ref('')
|
||||
formRules.value = {
|
||||
name: { required: true, message: '请输入名称' },
|
||||
rank: { required: true, message: '请输入人物简介' },
|
||||
rank: { required: false, message: '请输入人物简介' },
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
sequence: [{ required: true, message: '请选择顺序', trigger: 'change' }],
|
||||
img: [{ required: true, message: '请上传图片', trigger: 'change' }],
|
||||
@ -110,7 +113,7 @@ async function handleEdit(record = {}) {
|
||||
showModal({
|
||||
type: 'edit',
|
||||
// 80对应about
|
||||
title: t('pages.system.user.edit'),
|
||||
title: '编辑',
|
||||
})
|
||||
const { data, success } = await apis.team.getMenu(record.id).catch()
|
||||
if (!success) {
|
||||
@ -138,7 +141,7 @@ function handleOk() {
|
||||
rank: formData.value.rank,
|
||||
}
|
||||
let result = null
|
||||
console.log(modal.value.type)
|
||||
console.log(params)
|
||||
switch (modal.value.type) {
|
||||
case 'create':
|
||||
result = await apis.team.createMenu(params).catch(() => {
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
</a-button>
|
||||
</x-action-bar>
|
||||
<a-table :columns="columns" :data-source="listData" bordered="true" :loading="loading"
|
||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||
:pagination="paginationState" :scroll="{ x: 1000 }" @change="onTableChange">
|
||||
<template #bodyCell="{ column, record }">
|
||||
<template v-if="'img' === column.dataIndex">
|
||||
<!-- <a-image :width="60" :src="record.img || $imageErr.imgErr" />-->
|
||||
@ -54,23 +54,22 @@
|
||||
<span>{{ record.name }}</span>
|
||||
</a-tooltip>
|
||||
</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'">
|
||||
<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>
|
||||
<a-tag
|
||||
v-for="(item, index) in record.rank"
|
||||
:key="index"
|
||||
color="blue"
|
||||
>
|
||||
<a-tag v-for="(item, index) in record.rank" :key="index" color="blue">
|
||||
{{ item }}
|
||||
</a-tag>
|
||||
</div>
|
||||
</template>
|
||||
</template> -->
|
||||
|
||||
|
||||
<template v-if="column.dataIndex === 'area'">
|
||||
@ -146,7 +145,7 @@ async function getPageList() {
|
||||
const { success, data, total } = await apis.team
|
||||
.getDataList({
|
||||
pageSize,
|
||||
current:current,
|
||||
current: current,
|
||||
...searchFormData.value,
|
||||
})
|
||||
.catch(() => {
|
||||
|
||||
@ -63,7 +63,9 @@
|
||||
</a-form-item>
|
||||
|
||||
</template>
|
||||
<a-form-item :label="'网站声明'">
|
||||
<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>
|
||||
</template>
|
||||
</x-search-bar>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user