From bb62d787c1bd37e86c717979f1807594c2076cad Mon Sep 17 00:00:00 2001 From: GaoF Date: Mon, 11 Nov 2024 09:29:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hook/useFormHandler.js | 14 +- src/layout/components/setting.vue | 4 +- src/store/global.js | 2 +- .../basicData/brand/detail/index.vue | 47 ++++- .../brand/formFields/detailFields.js | 41 +++++ .../basicData/client/detail/index.vue | 86 ++++++++- .../client/formFields/detailFields.js | 104 +++++++++++ .../basicData/materiel/detail/index.vue | 97 ++++++++-- .../materiel/formFields/detailFields.js | 166 ++++++++++++++++++ .../basicData/publicAccount/detail/index.vue | 51 +++++- .../publicAccount/formFields/detailFields.js | 61 ++++++- .../basicData/stash/detail/index.vue | 65 ++++++- .../stash/formFields/detailFields.js | 70 +++++++- .../basicData/supplier/detail/index.vue | 56 +++++- .../supplier/formFields/detailFields.js | 103 +++++++++++ .../basicData/supplier/index.vue | 92 +++++----- .../basicData/tissue/detail/TissueForm.vue | 1 + .../basicData/unit/detail/index.vue | 76 ++++++-- .../basicData/unit/formFields/detailFields.js | 38 ++++ .../inventory/inbound/detail/detail.vue | 5 +- .../productionCenter/report/detail/index.vue | 41 ++--- .../report/formFields/detailFields.js | 46 +++++ .../productionCenter/report/index.vue | 5 +- .../productionCenter/task/detail/index.vue | 50 +++++- .../productionCenter/task/formItems/index.js | 54 ++++++ 25 files changed, 1234 insertions(+), 141 deletions(-) diff --git a/src/hook/useFormHandler.js b/src/hook/useFormHandler.js index 739203f..5a5d191 100644 --- a/src/hook/useFormHandler.js +++ b/src/hook/useFormHandler.js @@ -2,6 +2,7 @@ import { useRoute, useRouter } from 'vue-router' import { cloneDeep } from 'lodash-es' import useTabs from '@/utils/useTabs' import extendFieldApi from '@/api/base/extendfield/extendFieldApi' +import router from '@/router' export default function useFormHandler(formItems, api, backRouter) { const state = reactive({ @@ -21,7 +22,6 @@ export default function useFormHandler(formItems, api, backRouter) { const formRefs = ref([]) const route = useRoute() - const router = useRouter() // 初始化表单数据 const initializeFormData = () => { @@ -31,13 +31,13 @@ export default function useFormHandler(formItems, api, backRouter) { } // 提交表单 - const onSubmit = async (params = {}) => { + const onSubmit = async (params = {}, backRouter) => { submitLoading.value = true try { await validateForms() const formDataParam = params.isDeep ? cloneDeep(params) : formData - const safeId = validateAndCleanId(route.query.id || params.id) + const safeId = validateAndCleanId(params.id) if (safeId) { formDataParam.id = safeId } @@ -46,7 +46,7 @@ export default function useFormHandler(formItems, api, backRouter) { if (params.isEnable) return res - handleBack() + handleBack(backRouter) } catch (error) { console.error('Validation or submission error:', error) throw error @@ -66,8 +66,10 @@ export default function useFormHandler(formItems, api, backRouter) { } // 返回并关闭当前标签页 - const handleBack = () => { - useTabs.close('', backRouter) + const handleBack = (backRouter) => { + console.log(backRouter, 'backRouter') + // useTabs.close('', backRouter) + router.replace({ path: backRouter }) } // 根据页面类型加载表单数据 diff --git a/src/layout/components/setting.vue b/src/layout/components/setting.vue index ea70ed8..4a3be46 100644 --- a/src/layout/components/setting.vue +++ b/src/layout/components/setting.vue @@ -72,9 +72,9 @@ - + { // 侧边菜单是否排他展开 const sideUniqueOpen = ref(getCacheConfig('SNOWY_SIDE_UNIQUE_OPEN')) // 多标签栏 - const layoutTagsOpen = ref(getCacheConfig('SNOWY_LAYOUT_TAGS_OPEN')) + const layoutTagsOpen = ref(getCacheConfig('SNOWY_LAYOUT_TAGS_CLOSE')) // 是否展示面包屑 const breadcrumbOpen = ref(getCacheConfig('SNOWY_BREADCRUMD_OPEN')) // 是否开启固定宽度(顶栏菜单) diff --git a/src/views/productionBusiness/basicData/brand/detail/index.vue b/src/views/productionBusiness/basicData/brand/detail/index.vue index 735298d..6d3b5eb 100644 --- a/src/views/productionBusiness/basicData/brand/detail/index.vue +++ b/src/views/productionBusiness/basicData/brand/detail/index.vue @@ -1,11 +1,13 @@ + + + + @@ -138,11 +175,15 @@ import { clientFormItems, baseFormItems, - formRules + formRules, + clientViewFormItems, + baseViewFormItems } from '@/views/productionBusiness/basicData/client/formFields/detailFields' + import router from '@/router' + import tool from '@/utils/tool' const route = useRoute() - let detailData = reactive({}) + let detailData = ref({}) // 级联选择 let cityOptionsCity = ref([]) @@ -174,7 +215,29 @@ } ) - const onSubmitForm = () => { + const onSubmitFormBack = () => { + const dataSourceList = dataSource.value.map((item) => { + return { + id: item.id || '', + customerId: item.customerId || '', + province: item.province || '', + city: item.city || '', + county: item.county || '', + remarks: item.remarks || '' + } + }) + onSubmit( + { + isDeep: true, + ...formData, + saleAreaList: dataSourceList, + id: detailData.value?.id + }, + '/basicData/client' + ) + } + + const onSubmitFormAdd = () => { const dataSourceList = dataSource.value.map((item) => { return { id: item.id || '', @@ -188,7 +251,14 @@ onSubmit({ isDeep: true, ...formData, - saleAreaList: dataSourceList + saleAreaList: dataSourceList, + id: detailData.value?.id, + isEnable: true + }).then(() => { + // 新增清空所有的表单数据 + router.replace({ path: route.path, query: { type: route.type } }).then(() => { + router.go(0) // 刷新页面 + }) }) } @@ -196,7 +266,7 @@ formRefs.value = [formRef1.value, formRef2.value] fetchData(route.query.type).then(async (res) => { if (res) { - detailData = res + detailData.value = res const list = await customerApi.customerSaleAreaList({ customerId: res.id diff --git a/src/views/productionBusiness/basicData/client/formFields/detailFields.js b/src/views/productionBusiness/basicData/client/formFields/detailFields.js index 87cd527..389685e 100644 --- a/src/views/productionBusiness/basicData/client/formFields/detailFields.js +++ b/src/views/productionBusiness/basicData/client/formFields/detailFields.js @@ -134,6 +134,68 @@ export const clientFormItems = reactive([ } } ]) +export const clientViewFormItems = reactive([ + { + label: '编码:', + name: 'number', + span: 1 + }, + { + label: '名称:', + name: 'name', + span: 1 + }, + { + label: '简称:', + name: 'shortName', + span: 1 + }, + { + label: '可用状态:', + name: 'enabledState', + type: 'dict', + span: 1, + attrs: { + options: 'COMMON_STATUS' + } + }, + { + label: '品牌:', + name: 'brandName', + span: 1 + }, + { + label: '客户分类:', + name: 'categoryName', + span: 1 + }, + { + label: '省:', + name: 'province', + span: 1 + }, + { + label: '市:', + name: 'city', + span: 1 + }, + { + label: '区:', + name: 'county', + span: 1 + }, + { + label: '地址:', + name: 'address', + type: 'a-textarea', + span: 3 + }, + { + label: '备注:', + name: 'remarks', + span: 3 + } +]) export const baseFormItems = [ { @@ -213,3 +275,45 @@ export const baseFormItems = [ } } ] +export const baseViewFormItems = [ + { + label: '联系人:', + name: 'contacts', + span: 1 + }, + { + label: '手机:', + name: 'phone', + span: 1 + }, + { + label: '固话:', + name: 'tel', + span: 1, + }, + { + label: '传真:', + name: 'fax', + span: 1, + }, + { + label: '电子邮箱:', + name: 'email', + span: 1 + }, + { + label: 'QQ:', + name: 'qq', + span: 1 + }, + { + label: '微信:', + name: 'wechat', + span: 1 + }, + { + label: '联系地址:', + name: 'contactAddress', + span: 1 + } +] diff --git a/src/views/productionBusiness/basicData/materiel/detail/index.vue b/src/views/productionBusiness/basicData/materiel/detail/index.vue index 7f0ac49..3d15afa 100644 --- a/src/views/productionBusiness/basicData/materiel/detail/index.vue +++ b/src/views/productionBusiness/basicData/materiel/detail/index.vue @@ -1,51 +1,86 @@