From 38e2fca3f8713a19b201a0c858fde4912469d2fe Mon Sep 17 00:00:00 2001 From: Leo_Ding <2405260743@qq.com> Date: Thu, 19 Jun 2025 11:01:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=9B=E8=81=98=E5=B2=97=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../companyNews/components/EditDialog.vue | 89 ++++++++++--------- src/views/dynamic/companyNews/index.vue | 2 +- 2 files changed, 50 insertions(+), 41 deletions(-) diff --git a/src/views/dynamic/companyNews/components/EditDialog.vue b/src/views/dynamic/companyNews/components/EditDialog.vue index 6c17ab2..5c218ca 100644 --- a/src/views/dynamic/companyNews/components/EditDialog.vue +++ b/src/views/dynamic/companyNews/components/EditDialog.vue @@ -19,6 +19,12 @@ + + + + + + - + @@ -55,12 +61,13 @@ const cancelText = ref(t('button.cancel')) const okText = ref(t('button.confirm')) const rolesValue = ref([]) const roles = ref([]) -const imgUrl=ref('') +const imgUrl = ref('') formRules.value = { title: { required: true, message: '请输入标题' }, content: { required: true, message: '请输入内容' }, link: { required: true, message: '请输入链接' }, status: [{ required: true, message: '请选择状态', trigger: 'change' }], + pushAt: [{ required: true, message: '请选择发布日期', trigger: 'change' }], // imgUrl: [{ required: true, message: '请上传图片', trigger: 'change' }], } @@ -72,8 +79,8 @@ formRules.value = { const handleChange = (value) => { rolesValue.value = value } -const imgChange=(value)=>{ - formData.value.img=value +const imgChange = (value) => { + formData.value.img = value } /** * 新建 @@ -100,49 +107,51 @@ async function handleEdit(record = {}) { hideModal() return } - formData.value = {...data} - imgUrl.value=config('http.apiBasic')+data.img + formData.value = { ...data } + formData.value.pushAt=dayjs(data.pushAt) + console.log(formData.value) + imgUrl.value = config('http.apiBasic') + data.img } /** * 确定 */ function handleOk() { - if(!formData.value.img) return message.error('请上传图片'); + if (!formData.value.img) return message.error('请上传图片'); formRef.value.validateFields().then(async (values) => { - console.log(values) - try { - showLoading() - const params = { - ...values, - img:formData.value.img, - pushAt:dayjs().format('YYYY-MM-DD'), - type:'news' - } - let result = null - console.log(modal.value.type) - switch (modal.value.type) { - case 'create': - result = await apis.dynamic.createDynamic(params).catch(() => { - throw new Error() - }) - break - case 'edit': - result = await apis.dynamic.updateItem(formData.value.id, params).catch(() => { - throw new Error() - }) - break - } - hideLoading() - if (config('http.code.success') === result?.success) { - hideModal() - emit('ok') - } - } catch (error) { - console.log(error) - hideLoading() + console.log(values) + try { + showLoading() + const params = { + ...values, + img: formData.value.img, + pushAt:dayjs(formData.value.pushAt).format("YYYY-MM-DD"), + type: 'news' } - }) + let result = null + console.log(modal.value.type) + switch (modal.value.type) { + case 'create': + result = await apis.dynamic.createDynamic(params).catch(() => { + throw new Error() + }) + break + case 'edit': + result = await apis.dynamic.updateItem(formData.value.id, params).catch(() => { + throw new Error() + }) + break + } + hideLoading() + if (config('http.code.success') === result?.success) { + hideModal() + emit('ok') + } + } catch (error) { + console.log(error) + hideLoading() + } + }) .catch((e) => { console.log(e) hideLoading() @@ -180,7 +189,7 @@ function formatArr(data, type = '') { * 取消 */ function handleCancel() { - imgUrl.value='' + imgUrl.value = '' hideModal() } diff --git a/src/views/dynamic/companyNews/index.vue b/src/views/dynamic/companyNews/index.vue index 8c9ed62..2daf6f9 100644 --- a/src/views/dynamic/companyNews/index.vue +++ b/src/views/dynamic/companyNews/index.vue @@ -106,7 +106,7 @@ const { t } = useI18n() // 解构出t方法 const columns = [ { title: '图片', dataIndex: 'img', width: 100, align: 'center' }, { title: '标题', dataIndex: 'title', key: 'title' }, - { title: '内容', dataIndex: 'content', key: 'content' }, + { title: '简介', dataIndex: 'content', key: 'content' }, { title: '状态', dataIndex: 'status', width: 120, align: 'center' }, { title: '发布日期', dataIndex: 'pushAt', width: 120, align: 'center' }, { title: '链接', dataIndex: 'link', align: 'center' },