优化代码

main
GaoF 2024-11-11 09:29:24 +08:00
parent e77c661274
commit bb62d787c1
25 changed files with 1234 additions and 141 deletions

View File

@ -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 })
}
// 根据页面类型加载表单数据

View File

@ -72,9 +72,9 @@
<a-form-item label="面包屑">
<a-switch :checked="breadcrumbOpen" @change="toggleState('breadcrumbOpen')" />
</a-form-item>
<a-form-item label="多标签">
<!-- <a-form-item label="多标签">
<a-switch :checked="layoutTagsOpen" @change="toggleState('layoutTagsOpen')" />
</a-form-item>
</a-form-item>-->
<a-form-item label="折叠菜单" v-if="!menuIsCollapseDisabled">
<a-switch
:checked="menuIsCollapse"

View File

@ -38,7 +38,7 @@ export const globalStore = defineStore('global', () => {
// 侧边菜单是否排他展开
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'))
// 是否开启固定宽度(顶栏菜单)

View File

@ -1,11 +1,13 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<a-page-header style="padding: 10px; font-size: 20px">
<template #extra>
<a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmitForm"></a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormBack">退</a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormAdd"></a-button>
<a-button @click="handleBack('/basicData/brand')">退</a-button>
</template>
</a-page-header>
<a-button
<!-- <a-button
type="primary"
@click="
navigateTo('/brand/counterfeiting', {
@ -14,16 +16,29 @@
"
>
防伪页面
</a-button>
</a-button>-->
<a-card :bordered="false" title="品牌">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="brandFormItems"
:model="formData"
:rules="formRules"
ref="formRef1"
/>
<a-descriptions bordered :column="3" v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in brandViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card :bordered="false" class="mt-4" style="height: 100%">
@ -51,13 +66,20 @@
import officialAccountApi from '@/api/base/wx/officialAccountApi'
import useFormHandler from '@/hook/useFormHandler'
import { useRoute } from 'vue-router'
import { brandFormItems, formRules } from '@/views/productionBusiness/basicData/brand/formFields/detailFields'
import {
brandFormItems,
brandViewFormItems,
formRules
} from '@/views/productionBusiness/basicData/brand/formFields/detailFields'
import { useNavigation } from '@/hook/useNavigation'
import router from '@/router'
import tool from '@/utils/tool'
const { navigateTo } = useNavigation()
const route = useRoute()
const formRef1 = ref(null)
let extendData = ref([])
let detailData = ref([])
let { formData, formRefs, inform, extendFormData, onSubmit, handleBack, fetchData, getExtendField } = useFormHandler(
brandFormItems,
@ -69,7 +91,7 @@
onMounted(async () => {
formRefs.value = [formRef1.value]
await fetchData(route.query.type)
detailData.value = await fetchData(route.query.type)
officialAccountApi
.officialAccountList({
@ -115,8 +137,17 @@
delete domainFormRules['domainName' + (index + 1)]
}*/
const onSubmitForm = async () => {
await onSubmit({ ...formData })
const onSubmitFormBack = async () => {
await onSubmit({ ...formData, id: detailData.value?.id }, '/basicData/brand')
}
const onSubmitFormAdd = () => {
onSubmit({ ...formData, id: detailData.value?.id, isEnable: true }).then(() => {
//
router.replace({ path: route.path, query: { type: route.type } }).then(() => {
router.go(0) //
})
})
}
let activeKey = ref('1')

View File

@ -86,3 +86,44 @@ export const brandFormItems = reactive([
}
}
])
export const brandViewFormItems = reactive([
{
label: '名称:',
name: 'name',
span: 6
},
{
label: '编码:',
name: 'number',
span: 1
},
{
label: '简称:',
name: 'shortName',
span: 1,
},
{
label: '所属企业:',
name: 'company',
span: 1
},
{
label: '公众号:',
name: 'officialAccountId',
span: 1
},
{
label: '启用状态:',
name: 'enabledState',
type: 'dict',
span: 1,
attrs: {
options: 'COMMON_STATUS'
}
},
{
label: '备注:',
name: 'remarks',
span: 6
}
])

View File

@ -1,12 +1,15 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<a-page-header style="padding: 10px; font-size: 20px">
<template #extra>
<a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmitForm"></a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormBack">退</a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormAdd"></a-button>
<a-button @click="handleBack('/basicData/client')">退</a-button>
</template>
</a-page-header>
<a-card :bordered="false" title="客户">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="clientFormItems"
:model="formData"
@ -46,21 +49,46 @@
</a-select>
</template>
</DynamicForm>
<a-descriptions bordered :column="3" v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in clientViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card :bordered="false" class="mt-4">
<a-tabs v-model:activeKey="activeKey">
<a-tab-pane key="1" tab="联系信息">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="baseFormItems"
:model="formData"
:rules="formRules"
ref="formRef2"
/>
<a-descriptions bordered :column="3" v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in baseViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-tab-pane>
<a-tab-pane key="2" tab="销售区域管理" force-render>
<a-space>
<a-space v-if="route.query.type !== 'SEARCH'">
<a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="addRow"></a-button>
<xn-batch-delete
v-if="hasPerm('customerBatchDelete')"
@ -69,6 +97,7 @@
/>
</a-space>
<a-table
v-if="route.query.type !== 'SEARCH'"
class="mt-4"
ref="tableRef"
:dataSource="dataSource"
@ -119,6 +148,14 @@
</template>
</template>
</a-table>
<a-table v-else class="mt-4" ref="tableRef" :dataSource="dataSource" :columns="columns" row-key="id">
<template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'index'">
{{ index + 1 }}
</template>
</template>
</a-table>
</a-tab-pane>
<a-tab-pane key="3" tab="操作信息" v-if="route.query.type !== 'ADD'">
<OperationalInformation :detailData="detailData" :colSpan="6"></OperationalInformation>
@ -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

View File

@ -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
}
]

View File

@ -1,51 +1,86 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<a-page-header style="padding: 10px; font-size: 20px">
<template #extra>
<a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmitForm"></a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormBack">退</a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormAdd"></a-button>
<a-button @click="handleBack('/basicData/materiel')">退</a-button>
</template>
</a-page-header>
<a-card :bordered="false" title="物料">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="materialFormItems"
:model="formData"
:rules="formRules"
ref="formRef1"
/>
<a-descriptions bordered :column="2" colon v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in materialViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card :bordered="false" class="mt-4" style="height: 100%">
<a-tabs v-model:activeKey="activeKey">
<a-tab-pane key="1" tab="基本信息" forceRender>
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="baseFormItems"
:model="formData"
:rules="formRules"
ref="formRef2"
/>
<a-descriptions bordered v-else>
<a-descriptions-item :label="item.label" v-for="(item, index) in baseFormViewItems" :key="index">
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-tab-pane>
<a-tab-pane key="2" tab="价格体系" forceRender>
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="priceFormItems"
:model="formData"
:rules="formRules"
ref="formRef4"
/>
<a-descriptions bordered v-else>
<a-descriptions-item :label="item.label" v-for="(item, index) in priceViewFormItems" :key="index">
<span v-if="!item.type">{{ detailData[item.name]?.toFixed(2) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-tab-pane>
<a-tab-pane key="3" tab="单位信息" forceRender>
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="unitFormItems"
:model="formData"
:rules="formRules"
ref="formRef3"
/>
<a-descriptions bordered v-else :column="4">
<a-descriptions-item :label="item.label" v-for="(item, index) in unitViewFormItems" :key="index">
<span v-if="!item.type">{{ detailData[item.name] }}</span>
</a-descriptions-item>
</a-descriptions>
</a-tab-pane>
<a-tab-pane key="4" tab="包装关系" forceRender>
<a-table :dataSource="dataSource" :columns="columns" :pagination="false">
<a-table v-if="route.query.type !== 'SEARCH'" :dataSource="dataSource" :columns="columns" :pagination="false">
<template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'index'">
{{ index + 1 }}
@ -94,6 +129,19 @@
</template>
</template>
</a-table>
<a-table v-else :dataSource="dataSource" :columns="columns" :pagination="false">
<template #bodyCell="{ column, record, index }">
<template v-if="column.dataIndex === 'index'">
{{ index + 1 }}
</template>
<template v-if="column.dataIndex === 'enabledState'">
{{ tool.dictTypeData('COMMON_STATUS', record[column.dataIndex]) }}
</template>
<template v-if="column.dataIndex === 'unitId'">
{{ record.unitName }}
</template>
</template>
</a-table>
</a-tab-pane>
<a-tab-pane key="5" tab="商品推广" forceRender>
<a-form :model="productFormData" class="w-1/3" layout="vertical">
@ -142,7 +190,7 @@
<OperationalInformation :detailData="inform" :colSpan="6"></OperationalInformation>
</a-tab-pane>
<template #rightExtra v-if="activeKey === '4'">
<a-button @click="handleCompute"></a-button>
<a-button v-if="route.query.type !== 'SEARCH'" @click="handleCompute"></a-button>
</template>
</a-tabs>
</a-card>
@ -154,7 +202,7 @@
import useFormHandler from '@/hook/useFormHandler'
import tool from '@/utils/tool'
import { useRoute } from 'vue-router'
import router from '@/router'
import materialApi from '@/api/base/material/materialApi'
import materialCategoryApi from '@/api/base/material/materialCategoryApi'
import { message } from 'ant-design-vue'
@ -165,8 +213,13 @@
materialFormItems,
unitFormItems,
priceFormItems,
formRules
formRules,
materialViewFormItems,
baseFormViewItems,
priceViewFormItems,
unitViewFormItems
} from '@/views/productionBusiness/basicData/materiel/formFields/detailFields'
import { useRoute } from 'vue-router'
const route = useRoute()
const formRef1 = ref(null)
@ -175,6 +228,7 @@
const formRef4 = ref(null)
let dataSource = ref([])
let detailData = ref([])
let unitOptions = reactive([])
let productFormData = ref({
promoteEnabledState: 'ENABLE'
@ -186,9 +240,8 @@
unitFormItems[0].attrs.onChange = handleChangeUnitGroup
fetchData(route.query.type).then(async (res) => {
console.log(res, 'res')
console.log(formData, 'formData')
if (res) {
detailData.value = res
productFormData.value.promoteEnabledState = res.promoteEnabledState
productFormData.value.promoteUrl = res.promoteUrl
const packageData = await materialApi.materialPackageData({
@ -298,20 +351,40 @@
})
//
dataSource.value[0].unitId = resFilter[0].id
dataSource.value[0].unitId = resFilter[0]?.id
dataSource.value[0].productQty = null
dataSource.value[0].unitRate = resFilter[0].rate
})
}
const onSubmitForm = () => {
console.log(dataSource.value, 'dataSource.value')
const onSubmitFormBack = () => {
onSubmit(
{
isDeep: true,
...formData,
...productFormData.value,
id: detailData.value?.id,
extJson: JSON.stringify(extendFormData.value) || '',
materialPackageList: dataSource.value
},
'/basicData/materiel'
)
}
const onSubmitFormAdd = () => {
onSubmit({
isDeep: true,
...formData,
...productFormData.value,
id: detailData.value?.id,
isEnable: true,
extJson: JSON.stringify(extendFormData.value) || '',
materialPackageList: dataSource.value
}).then(() => {
//
router.replace({ path: route.path, query: { type: route.type } }).then(() => {
router.go(0) //
})
})
}
@ -485,7 +558,7 @@
}
const { formData, formRefs, inform, extendFormData, onSubmit, handleBack, fetchData, getExtendField } =
useFormHandler([...materialFormItems, ...baseFormItems,...priceFormItems, ...unitFormItems], {
useFormHandler([...materialFormItems, ...baseFormItems, ...priceFormItems, ...unitFormItems], {
submitForm: materialApi.materialSubmitForm,
getDetail: materialApi.materialDetail
})

View File

@ -93,6 +93,52 @@ export const materialFormItems = [
defaultValue: 'ENABLE'
}
]
export const materialViewFormItems = [
{
label: '编码:',
name: 'number',
span: 1
},
{
label: '名称:',
name: 'name',
span: 1
},
{
label: '简称:',
name: 'shortName',
span: 1
},
{
label: '别名:',
name: 'alias',
span: 1
},
{
label: '规格型号:',
name: 'specification',
span: 1
},
{
label: '包装比例:',
name: 'packageProportion',
span: 1
},
{
label: '助记码:',
name: 'mnemonicCode',
span: 1
},
{
label: '可用状态:',
name: 'enabledState',
span: 1,
type: 'dict',
attrs: {
options: 'COMMON_STATUS'
}
}
]
export const baseFormItems = reactive([
{
@ -216,6 +262,72 @@ export const baseFormItems = reactive([
}
}
])
export const baseFormViewItems = reactive([
{
label: '物料类型:',
name: 'categoryName',
span: 1
},
{
label: '品牌:',
name: 'brandName',
span: 1
},
{
label: '最高库存:',
name: 'maxInventory',
span: 1
},
{
label: '最低库存:',
name: 'minInventory',
span: 1
},
{
label: '保质期:',
name: 'shelfLife',
span: 1
},
// {
// label: '统一零售价:',
// name: 'retailPrice',
// type: 'a-input-number',
// span: 6,
// attrs: {
// placeholder: '请输入统一零售价',
// allowClear: true
// }
// },
{
label: '商品条形码:',
name: 'barcode',
span: 1
},
{
label: '保质期单位:',
name: 'shelfLifeUnit',
span: 1
},
{
label: '最大包装数量:',
name: 'maxPackageQuantity',
span: 1
},
{
label: '批次管理:',
name: 'batchManage',
span: 1,
type: 'dict',
attrs: {
options: 'COMMON_STATUS'
}
},
{
label: '备注:',
name: 'remarks',
span: 6
}
])
export const unitFormItems = reactive([
{
@ -331,6 +443,43 @@ export const unitFormItems = reactive([
}
}
])
export const unitViewFormItems = reactive([
{
label: '单位组:',
name: 'unitGroupName',
span: 1
},
{
label: '基本单位:',
name: 'baseUnitName',
span: 1
},
{
label: '采购单位:',
name: 'purchaseUnitName',
span: 1
},
{
label: '分销单位:',
name: 'distrUnitName',
span: 1
},
{
label: '生产单位:',
name: 'produceUnitName',
span: 1
},
{
label: '销售单位:',
name: 'saleUnitName',
span: 1
},
{
label: '库存单位:',
name: 'storeUnitName',
span: 1
}
])
export const priceFormItems = [
{
@ -364,3 +513,20 @@ export const priceFormItems = [
}
}
]
export const priceViewFormItems = [
{
label: '生产价格:',
name: 'producePrice',
span: 1
},
{
label: '采购价格:',
name: 'purchasePrice',
span: 1
},
{
label: '统一零售价:',
name: 'retailPrice',
span: 1
}
]

View File

@ -1,30 +1,58 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<a-page-header style="padding: 10px; font-size: 20px">
<template #extra>
<a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmit"></a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormBack">退</a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormAdd"></a-button>
<a-button @click="handleBack('/basicData/publicAccount')">退</a-button>
</template>
</a-page-header>
<a-card :bordered="false" title="公众号">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="officialAccountFormItems"
:model="formData"
:rules="formRules"
ref="formRef1"
/>
<a-descriptions bordered :column="3" v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in officialAccountViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card :bordered="false" class="mt-4" style="height: 100%">
<a-tabs v-model:activeKey="activeKey">
<a-tab-pane key="1" tab="基本信息" forceRender>
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="basicInfoFormItems"
:model="formData"
:rules="formRules"
ref="formRef2"
/>
<a-descriptions bordered :column="2" v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in basicInfoViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-tab-pane>
<a-tab-pane key="2" tab="扩展字段" forceRender v-if="extendData.length > 0">
<DynamicForm
@ -50,9 +78,13 @@
import {
basicInfoFormItems,
officialAccountFormItems,
formRules
formRules,
officialAccountViewFormItems,
basicInfoViewFormItems
} from '@/views/productionBusiness/basicData/publicAccount/formFields/detailFields'
import { useRoute } from 'vue-router'
import router from '@/router'
import tool from '@/utils/tool'
const route = useRoute()
const formRef1 = ref(null)
@ -61,6 +93,19 @@
let activeKey = ref('1')
let extendData = ref([])
const onSubmitFormBack = async () => {
await onSubmit({ ...formData, id: detailData.value?.id }, '/basicData/publicAccount')
}
const onSubmitFormAdd = () => {
onSubmit({ ...formData, id: detailData.value?.id, isEnable: true }).then(() => {
//
router.replace({ path: route.path, query: { type: route.type } }).then(() => {
router.go(0) //
})
})
}
const { formData, formRefs, inform, extendFormData, onSubmit, handleBack, fetchData, getExtendField } =
useFormHandler([...officialAccountFormItems, ...basicInfoFormItems], {
submitForm: officialAccountApi.officialAccountSubmitForm,

View File

@ -52,6 +52,36 @@ export const officialAccountFormItems = [
}
}
]
export const officialAccountViewFormItems = [
{
label: '类型:',
name: 'type',
span: 1,
type: 'dict',
attrs: {
options: 'OFFICIAL_ACCOUNT_TYPE'
}
},
{
label: '名称:',
name: 'name',
span: 1
},
{
label: '可用状态:',
name: 'enabledState',
span: 1,
type: 'dict',
attrs: {
options: 'COMMON_STATUS'
}
},
{
label: '备注:',
name: 'remarks',
span: 1
}
]
export const basicInfoFormItems = [
{
@ -72,7 +102,7 @@ export const basicInfoFormItems = [
allowClear: true
}
},
{
/*{
label: '字符串编码格式:',
name: 'encodingFormat',
type: 'a-input',
@ -80,7 +110,7 @@ export const basicInfoFormItems = [
placeholder: '请输入字符串编码格式',
allowClear: true
}
},
},*/
{
label: '校验码:',
name: 'token',
@ -100,3 +130,30 @@ export const basicInfoFormItems = [
}
}
]
export const basicInfoViewFormItems = [
{
label: 'AppID',
name: 'appid',
span: 1
},
{
label: 'AppSecret',
name: 'secret',
span: 1
},
// {
// label: '字符串编码格式:',
// name: 'encodingFormat',
// span: 1
// },
{
label: '校验码:',
name: 'token',
span: 1
},
{
label: '签名方式:',
name: 'aesKey',
span: 1
}
]

View File

@ -1,30 +1,58 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<a-page-header style="padding: 10px; font-size: 20px">
<template #extra>
<a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmitForm"></a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormBack">退</a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormAdd"></a-button>
<a-button @click="handleBack('/basicData/stash')">退</a-button>
</template>
</a-page-header>
<a-card :bordered="false" title="仓库">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="officialAccountFormItems"
:model="formData"
:rules="formRules"
ref="formRef1"
/>
<a-descriptions bordered v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in officialAccountViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card :bordered="false" class="mt-4" style="height: 100%">
<a-tabs v-model:activeKey="activeKey">
<a-tab-pane key="1" tab="基本信息">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="baseFormItems"
:model="formData"
:rules="formRules"
ref="formRef2"
/>
<a-descriptions bordered :column="2" colon v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in baseFormViewItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-tab-pane>
<a-tab-pane key="2" tab="扩展字段" forceRender v-if="extendData.length > 0">
<DynamicForm
@ -63,8 +91,12 @@
import {
baseFormItems,
officialAccountFormItems,
formRules
formRules,
officialAccountViewFormItems,
baseFormViewItems
} from '@/views/productionBusiness/basicData/stash/formFields/detailFields'
import tool from '@/utils/tool'
import router from '@/router'
const route = useRoute()
const userSelectorPlusProRef = ref(null)
@ -104,6 +136,7 @@
const formRef1 = ref(null)
const formRef2 = ref(null)
let detailData = ref({})
const { inform, formData, extendFormData, formRefs, onSubmit, handleBack, fetchData, getExtendField } =
useFormHandler([...officialAccountFormItems, ...baseFormItems], {
@ -111,11 +144,30 @@
getDetail: sysStoreApi.sysStoreDetail
})
const onSubmitForm = () => {
const onSubmitFormBack = () => {
onSubmit(
{
isDeep: true,
...formData,
id: detailData.value?.id,
extJson: JSON.stringify(extendFormData.value) || ''
},
'/basicData/stash'
)
}
const onSubmitFormAdd = () => {
onSubmit({
isDeep: true,
...formData,
id: detailData.value?.id,
isEnable: true,
extJson: JSON.stringify(extendFormData.value) || ''
}).then(() => {
//
router.replace({ path: route.path, query: { type: route.type } }).then(() => {
router.go(0) //
})
})
}
@ -125,10 +177,13 @@
if (res) {
formData.manageUserId = res.manageUserId
}
baseFormItems[0].attrs.onClick = handleManageUser
detailData.value = res || {}
})
const sysStoreTreeList = await sysStoreApi.sysStoreTree()
baseFormItems[0].attrs.onClick = handleManageUser
officialAccountFormItems.forEach((item) => {
if (item.name === 'parentId') {

View File

@ -83,6 +83,51 @@ export const officialAccountFormItems = reactive([
}
}
])
export const officialAccountViewFormItems = reactive([
{
label: '编码:',
name: 'number',
span: 1
},
{
label: '名称:',
name: 'name',
span: 1
},
{
label: '仓库条码:',
name: 'barcode',
span: 1
},
{
label: '可用状态:',
name: 'enabledState',
type: 'dict',
span: 1,
attrs: {
options: 'COMMON_STATUS'
}
},
{
label: '库存管理方式:',
name: 'manageMode',
span: 1,
type: 'dict',
attrs: {
options: 'STORE_MANAGE_MODE'
}
},
{
label: '上游仓库:',
name: 'parentId',
span: 1
},
{
label: '备注:',
name: 'remarks',
span: 1
}
])
export const baseFormItems = [
{
@ -92,7 +137,7 @@ export const baseFormItems = [
span: 6,
attrs: {
placeholder: '请选择管理员',
readonly: true
readonly: true,
}
},
{
@ -125,6 +170,29 @@ export const baseFormItems = [
}
]
export const baseFormViewItems = [
{
label: '管理员:',
name: 'manageUserName',
span: 1
},
{
label: '手机:',
name: 'phone',
span: 1
},
{
label: '固话:',
name: 'tel',
span: 1
},
{
label: '地址:',
name: 'address',
span: 6
}
]
export const formRules = {
name: [required('请输入名称')],
type: [required('请输入类型')],

View File

@ -1,12 +1,15 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<template #extra>
<a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmitForm"></a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormBack">退</a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormAdd"></a-button>
<a-button @back="handleBack('/basicData/supplier')">退</a-button>
</template>
</a-page-header>
<a-card :bordered="false" title="供应商">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="formItems"
:model="formData"
@ -46,18 +49,37 @@
</a-select>
</template>
</DynamicForm>
<a-descriptions bordered :column="3" v-else>
<a-descriptions-item :span="item.span" :label="item.label" v-for="(item, index) in viewFormItems" :key="index">
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card :bordered="false" class="mt-4">
<a-tabs v-model:activeKey="activeKey">
<a-tab-pane key="1" tab="联系信息">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="baseFormItems"
:model="formData"
:rules="formRules"
ref="formRef2"
/>
<a-descriptions bordered :column="3" v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in baseFormViewItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-tab-pane>
<a-tab-pane key="2" tab="扩展字段" force-render> </a-tab-pane>
<a-tab-pane key="3" tab="操作信息" v-if="route.query.type !== 'ADD'">
@ -78,11 +100,15 @@
import {
formItems,
baseFormItems,
formRules
formRules,
viewFormItems,
baseFormViewItems
} from '@/views/productionBusiness/basicData/supplier/formFields/detailFields'
import tool from '@/utils/tool'
import router from '@/router'
const route = useRoute()
let detailData = reactive({})
let detailData = ref({})
//
let cityOptionsCity = ref([])
@ -111,10 +137,28 @@
getDetail: supplierApi.supplierDetail
})
const onSubmitForm = () => {
const onSubmitFormBack = () => {
onSubmit(
{
isDeep: true,
...formData,
id: detailData.value?.id
},
'/basicData/supplier'
)
}
const onSubmitFormAdd = () => {
onSubmit({
isDeep: true,
...formData
...formData,
id: detailData.value?.id,
isEnable: true
}).then(() => {
//
router.replace({ path: route.path, query: { type: route.type } }).then(() => {
router.go(0) //
})
})
}
@ -124,6 +168,8 @@
if (res) {
getCityOptions()
}
detailData.value = res || {}
})
//

View File

@ -132,6 +132,67 @@ export const formItems = reactive([
}
}
])
export const viewFormItems = reactive([
{
label: '编码:',
name: 'number',
span: 1
},
{
label: '名称:',
name: 'name',
span: 1
},
{
label: '简称:',
name: 'shortName',
span: 1
},
{
label: '可用状态:',
name: 'enabledState',
span: 1,
type: 'dict',
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',
span: 1,
},
{
label: '备注:',
name: 'remarks',
span: 1,
}
])
export const baseFormItems = [
{
@ -211,3 +272,45 @@ export const baseFormItems = [
}
}
]
export const baseFormViewItems = [
{
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
}
]

View File

@ -56,10 +56,7 @@
<template #icon><plus-outlined /></template>
新增
</a-button>
<xn-batch-delete
:selectedRowKeys="selectedRowKeys"
@batchDelete="deleteBatchRecords"
/>
<xn-batch-delete :selectedRowKeys="selectedRowKeys" @batchDelete="deleteBatchRecords" />
</a-space>
</template>
<template #bodyCell="{ column, record }">
@ -72,7 +69,6 @@
</template>
<template v-if="column.dataIndex === 'action'">
<a-space>
<a-tooltip title="查看">
<a
@click="
navigateTo('/basicData/supplier/detail', {
@ -80,35 +76,51 @@
id: record.id
})
"
v-if="hasPerm('supplierEdit')"
v-if="hasPerm('customerEdit')"
>
<EyeOutlined />
<!-- 查看-->
查看
</a>
</a-tooltip>
<a-divider type="vertical" v-if="hasPerm(['supplierEdit', 'supplierDelete'], 'and')" />
<a-tooltip title="编辑">
<a
<a-divider type="vertical" v-if="hasPerm(['customerEdit', 'customerDelete'], 'and')" />
<a-dropdown>
<a class="ant-dropdown-link" @click.prevent>
更多
<DownOutlined />
</a>
<template #overlay>
<a-menu>
<a-menu-item>
<a-button
type="link"
size="small"
@click="
navigateTo('/basicData/supplier/detail', {
type: 'EDIT',
id: record.id
})
"
v-if="hasPerm('supplierEdit')"
v-if="hasPerm('sysUnitEdit')"
>
<FormOutlined />
<!-- 编辑-->
</a>
</a-tooltip>
<a-divider type="vertical" v-if="hasPerm(['supplierEdit', 'supplierDelete'], 'and')" />
<a-popconfirm title="确定要删除吗?" @confirm="deleteRecord(record)">
<a-button type="link" danger size="small" v-if="hasPerm('supplierDelete')">
<DeleteOutlined />
编辑
</a-button>
</a-popconfirm>
</a-menu-item>
<a-menu-item>
<a-button
type="link"
danger
size="small"
v-if="hasPerm('materialDelete')"
@click="deleteRecord(record)"
>
<DeleteOutlined />
删除
</a-button>
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-space>
</template>
</template>
@ -146,7 +158,7 @@
delete: supplierApi.supplierDelete
},
tableColumns,
['customerEdit', 'customerDelete']
['sysBrandEdit', 'sysBrandDelete']
)
const dynamicTreeRef = ref(null)

View File

@ -99,6 +99,7 @@
<OperationalInformation :detailData="detailData" v-if="pageType !== 'ADD'" :colSpan="12"></OperationalInformation>
</a-form>
<template #footer>
<a-button style="margin-right: 8px" @click="onClose"></a-button>
<a-button v-if="pageType !== 'SEARCH'" type="primary" @click="onSubmit" :loading="submitLoading"></a-button>

View File

@ -1,18 +1,33 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack('/basicData/unit')">
<a-page-header style="padding: 10px; font-size: 20px">
<template #extra>
<a-button key="1" type="primary" @click="onSubmitForm"></a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormBack">退</a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormAdd"></a-button>
<a-button @click="handleBack('/basicData/unit')">退</a-button>
</template>
</a-page-header>
<a-card :bordered="false" title="单位信息">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="unitFormItems"
:model="formData"
:rules="formRules"
ref="formRef1"
/>
<a-descriptions bordered :column="2" colon v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in unitViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card
@ -25,7 +40,7 @@
<a-tab-pane key="1" tab="操作信息" forceRender v-if="route.query.type !== 'ADD'">
<OperationalInformation :detailData="inform" :colSpan="6"></OperationalInformation>
</a-tab-pane>
<a-tab-pane key="2" tab="扩展字段" forceRender v-if="extendData.length > 0">
<!-- <a-tab-pane key="2" tab="扩展字段" forceRender v-if="extendData.length > 0">
<DynamicForm
:allDisabled="route.query.type === 'SEARCH'"
:formItems="extendData"
@ -34,7 +49,7 @@
v-if="extendData.length > 0"
/>
<a-empty v-else />
</a-tab-pane>
</a-tab-pane>-->
</a-tabs>
</a-card>
</template>
@ -44,17 +59,22 @@
import useFormHandler from '@/hook/useFormHandler'
import { useRoute } from 'vue-router'
import unitApi from '@/api/base/unit/unitApi'
import { formRules, unitFormItems } from '@/views/productionBusiness/basicData/unit/formFields/detailFields'
import {
formRules,
unitFormItems,
unitViewFormItems
} from '@/views/productionBusiness/basicData/unit/formFields/detailFields'
import tool from '../../../../../utils/tool'
const route = useRoute()
const formRef1 = ref()
let activeKey = ref('1')
let extendData = ref([])
let detailData = ref({})
onMounted(async () => {
formRefs.value = [formRef1.value]
await fetchData(route.query.type)
detailData.value = await fetchData(route.query.type)
//
const unitGroupsList = await unitGroupsApi.sysUnitGroupList({
enabledState: 'ENABLE'
@ -70,16 +90,46 @@
extendData.value = await getExtendField('MATERIAL')
})
const onSubmitForm = () => {
onSubmit({
const onSubmitFormBack = () => {
onSubmit(
{
isDeep: true,
...formData,
id: detailData.value?.id,
extJson: JSON.stringify(extendFormData.value) || ''
},
'/basicData/unit'
)
}
const onSubmitFormAdd = () => {
onSubmit({
isEnable: true,
isDeep: true,
...formData,
id: detailData.value?.id,
extJson: JSON.stringify(extendFormData.value) || ''
}).then(() => {
//
initializeFormData()
//
if (detailData.value?.id) {
detailData.value.id = ''
}
})
}
const { formData, formRefs, inform, extendFormData, onSubmit, handleBack, fetchData, getExtendField } =
useFormHandler([...unitFormItems], {
const {
formData,
formRefs,
inform,
extendFormData,
onSubmit,
handleBack,
fetchData,
getExtendField,
initializeFormData
} = useFormHandler([...unitFormItems], {
submitForm: unitApi.sysUnitSubmitForm,
getDetail: unitApi.sysUnitDetail
})

View File

@ -83,6 +83,44 @@ export const unitFormItems = reactive([
}
])
export const unitViewFormItems = reactive([
{
label: '名称:',
name: 'name',
span: 1
},
{
label: '编码:',
name: 'number',
span: 1
},
{
label: '单位组:',
name: 'unitGroupName',
span: 1,
defaultValue: ''
},
{
label: '换算率:',
name: 'rate',
span: 1
},
{
label: '是否基本单位:',
name: 'isBase',
span: 1,
type: 'dict',
attrs: {
options: 'YES_NO'
}
},
{
label: '备注:',
name: 'remarks',
span: 2
}
])
export const formRules = {
unitGroupId: [required('请选择单位')],
name: [required('请输入名称')],

View File

@ -60,7 +60,6 @@
import { unitFormItems, formRules } from '@/views/productionBusiness/productionCenter/report/formFields/detailFields'
import { detailColumns, modalColumns } from '@/views/productionBusiness/productionCenter/report/columns/detailColumns'
import { cloneDeep } from 'lodash-es'
import produceReportDetailApi from '@/api/production/produceTask/produceReportDetailApi'
import inventoryInboundApi from '@/api/inventory/inventoryInboundApi'
const route = useRoute()
@ -119,7 +118,7 @@
inventoryInboundApi
.inventoryInboundBarcodeTree({
docsDetailId: record.id,
docsId: record.inboundId
docsId: record.inboundId,
})
.then((res) => {
scanTableList.value = res
@ -135,7 +134,7 @@
.produceReportTreeChildrenList({
docsDetailId: recordTable.id,
docsId: record.docsId,
parentBarcode: record.barcode
parentBarcodeList: record.barcode
})
.then((res) => {
record.children = res

View File

@ -1,18 +1,27 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<a-page-header style="padding: 10px; font-size: 20px">
<template #extra>
<!-- <a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmitForm"></a-button>-->
<a-button @click="handleBack('/report/index')">退</a-button>
</template>
</a-page-header>
<a-card :bordered="false" title="品牌">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="unitFormItems"
:model="formData"
:rules="formRules"
ref="formRef1"
/>
<a-descriptions bordered :column="3" colon v-else>
<a-descriptions-item :label="item.label" v-for="(item, index) in unitViewFormItems" :key="index">
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card :bordered="false" class="mt-4" style="height: 100%">
@ -55,19 +64,19 @@
<script setup>
import produceReportApi from '@/api/production/produceTask/produceReportApi'
import producePackageBarcodeApi from '@/api/production/produceTask/producePackageBarcodeApi'
import useFormHandler from '@/hook/useFormHandler'
import { useRoute } from 'vue-router'
import { unitFormItems, formRules } from '@/views/productionBusiness/productionCenter/report/formFields/detailFields'
import { unitFormItems, formRules,unitViewFormItems } from '@/views/productionBusiness/productionCenter/report/formFields/detailFields'
import { detailColumns, modalColumns } from '@/views/productionBusiness/productionCenter/report/columns/detailColumns'
import { cloneDeep } from 'lodash-es'
import produceReportDetailApi from '@/api/production/produceTask/produceReportDetailApi'
import tool from '@/utils/tool'
const route = useRoute()
const formRef1 = ref(null)
const tableRef = ref(null)
let extendData = ref([])
let searchFormState = ref({})
let detailData = ref({})
let { formData, formRefs, inform, handleBack, fetchData, getExtendField } = useFormHandler(unitFormItems, {
getDetail: produceReportApi.produceReportDetail
@ -75,25 +84,10 @@
let detailDataSource = ref([])
const options = {
alert: {
show: true,
clear: () => {
selectedRowKeys.value = []
}
},
rowSelection: {
onChange: (selectedRowKey, selectedRows) => {
selectedRowKeys.value = selectedRowKey
}
},
toolConfig: { refresh: true, height: true, columnSetting: true, striped: false }
}
onMounted(async () => {
formRefs.value = [formRef1.value]
const detailData = await fetchData(route.query.type)
searchFormState.value.reportId = detailData.id
detailData.value = await fetchData(route.query.type)
searchFormState.value.reportId = detailData.value?.id
// tableRef.value.refresh(true)
await loadData()
extendData.value = await getExtendField('MATERIAL')
@ -135,14 +129,13 @@
.produceReportTreeChildrenList({
docsDetailId: recordTable.id,
docsId: record.docsId,
parentBarcode: record.barcode
parentBarcodeList: record.barcode
})
.then((res) => {
record.children = res
record.children &&
record.children.forEach((item) => {
if (item.subAmount && item.subAmount > 0)
item.children = []
if (item.subAmount && item.subAmount > 0) item.children = []
})
})
}

View File

@ -65,5 +65,51 @@ export const unitFormItems = reactive([
}
}
])
export const unitViewFormItems = reactive([
{
label: '单号:',
name: 'billNumber',
span: 1
},
{
label: '业务日期:',
name: 'businessDate',
span: 1
},
{
label: '状态:',
name: 'state',
span: 1,
attrs: {
options: 'PRODUCE_REPORT_STATE'
}
},
{
label: '类型:',
name: 'produceType',
span: 1,
attrs: {
options: 'PRODUCE_TYPE'
}
},
{
label: '生产线:',
name: 'productionLineName',
span: 1
},
{
name: ' ',
span: 1
},
{
label: '备注:',
name: 'remarks',
span: 24,
attrs: {
placeholder: '请输入备注',
allowClear: true
}
}
])
export const formRules = {}

View File

@ -15,12 +15,11 @@
bordered
:row-key="(record) => record.id"
:tool-config="options.toolConfig"
:row-selection="options.rowSelection"
:scroll="{
x: 100
}"
>
<template #operator>
<!-- <template #operator>
<a-space>
<a-button
type="primary"
@ -40,7 +39,7 @@
@batchDelete="deleteBatchRecords"
/>
</a-space>
</template>
</template>-->
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'state'">
{{ $TOOL.dictTypeData('PRODUCE_REPORT_STATE', record.state || '') }}

View File

@ -1,12 +1,15 @@
<template>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<a-page-header style="padding: 10px; font-size: 20px">
<template #extra>
<a-button v-if="route.query.type !== 'SEARCH'" key="1" type="primary" @click="onSubmitForm"></a-button>
<!-- <a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormBack">退</a-button>
<a-button v-if="route.query.type !== 'SEARCH'" type="primary" @click="onSubmitFormAdd"></a-button>-->
<a-button @click="handleBack('/task/index')">退</a-button>
</template>
</a-page-header>
<a-card :bordered="false" title="基本信息">
<DynamicForm
v-if="route.query.type !== 'SEARCH'"
:allDisabled="route.query.type === 'SEARCH'"
:formItems="basicInfoFormItems"
:model="formData"
@ -48,6 +51,18 @@
></a-input>
</template>
</DynamicForm>
<a-descriptions bordered :column="3" colon v-else>
<a-descriptions-item
:span="item.span"
:label="item.label"
v-for="(item, index) in basicInfoViewFormItems"
:key="index"
>
<span v-if="!item.type">{{ detailData[item.name] }}</span>
<span v-if="item.type === 'dict'">{{ tool.dictTypeData(item.attrs.options, detailData[item.name]) }}</span>
</a-descriptions-item>
</a-descriptions>
</a-card>
<a-card
@ -82,11 +97,16 @@
import { required } from '@/utils/formRules'
import produceTaskApi from '@/api/production/produceTask/produceTaskApi'
import useFormHandler from '@/hook/useFormHandler'
import { basicInfoFormItems } from '@/views/productionBusiness/productionCenter/task/formItems'
import {
basicInfoFormItems,
basicInfoViewFormItems
} from '@/views/productionBusiness/productionCenter/task/formItems'
import { useRoute } from 'vue-router'
import MaterielSelectorPlus from '@/components/Selector/materielSelectorPlus.vue'
import unitApi from '@/api/base/unit/unitApi'
import LineSelectorPlus from '@/components/Selector/lineSelectorPlus.vue'
import router from '@/router'
import tool from '@/utils/tool'
const route = useRoute()
const formRules = {
@ -102,6 +122,7 @@
const formRef1 = ref(null)
let activeKey = ref('2')
let extendData = ref([])
let detailData = ref({})
const { formData, formRefs, inform, extendFormData, onSubmit, handleBack, fetchData, getExtendField } =
useFormHandler([...basicInfoFormItems], {
@ -113,6 +134,7 @@
formRefs.value = [formRef1.value]
fetchData(route.query.type).then((res) => {
if (res) {
detailData.value = res
formData.productNumber = res.productNumber //
formData.productId = res.productId // id
formData.produceUnitId = res.produceUnitId // id
@ -134,10 +156,28 @@
extendData.value = await getExtendField('MATERIAL')
})
const onSubmitForm = () => {
const onSubmitFormBack = () => {
onSubmit(
{
isDeep: true,
...formData,
id: detailData.value?.id
},
'/task/index'
)
}
const onSubmitFormAdd = () => {
onSubmit({
isDeep: true,
...formData
...formData,
id: detailData.value?.id,
isEnable: true
}).then(() => {
//
router.replace({ path: route.path, query: { type: route.type } }).then(() => {
router.go(0) //
})
})
}

View File

@ -111,3 +111,57 @@ export const basicInfoFormItems = [
}
}
]
export const basicInfoViewFormItems = [
{
label: '单据号:',
name: 'billNumber',
},
{
label: '计划开工日期:',
name: 'producePlanDate',
},
{
label: '生产类型:',
name: 'produceType',
type: 'dict',
attrs: {
options: 'PRODUCE_TYPE'
}
},
{
label: '产品(物料)',
name: 'productName',
span: 1
},
{
label: '批次:',
name: 'batchNumber',
span: 1
},
{
label: '计划生产数量:',
name: 'producePlanAmount',
span: 1
},
{
label: '生产单位:', // 采购单位
name: 'produceUnitName',
span: 1
},
{
label: '基本单位:',
name: 'baseUnitName',
span: 1
},
{
label: '生产线:',
name: 'productionLineName',
span: 1
},
{
label: '备注:',
name: 'remarks',
span: 1,
}
]