基础资料模块

main
GaoF 2024-07-27 19:59:19 +08:00
parent 741484fdd4
commit 3d5aed578c
13 changed files with 17138 additions and 321 deletions

View File

@ -24,5 +24,9 @@ export default {
// 获取公众号详情 // 获取公众号详情
officialAccountDetail(data) { officialAccountDetail(data) {
return request('detail', data, 'get') return request('detail', data, 'get')
},
// 获取公众号详情
officialAccountList(data) {
return request('list', data, 'get')
} }
} }

View File

@ -590,7 +590,7 @@
props.rowSelection.selectedRows = selectedRows props.rowSelection.selectedRows = selectedRows
// eslint-disable-next-line vue/no-mutating-props // eslint-disable-next-line vue/no-mutating-props
props.rowSelection.selectedRowKeys = selectedRowKeys props.rowSelection.selectedRowKeys = selectedRowKeys
props.rowSelection.onChange(selectedRowKeys, selectedRows) // props.rowSelection.onChange(selectedRowKeys, selectedRows)
getTableProps() getTableProps()
} }
const list = data.needTotalList const list = data.needTotalList

View File

@ -58,6 +58,8 @@ export default function useFormHandler(formItems, api) {
formData[key] = res[key] formData[key] = res[key]
} }
} }
return res
} catch (error) { } catch (error) {
console.error('API request failed:', error) console.error('API request failed:', error)
} }

File diff suppressed because it is too large Load Diff

View File

@ -15,7 +15,7 @@
/> />
</a-card> </a-card>
<!-- <a-card :bordered="false" title="域名" class="mt-4"> <!-- <a-card :bordered="false" title="域名" class="mt-4">
<a-button @click="handleAddDomain"></a-button> <a-button @click="handleAddDomain"></a-button>
<a-form class="mt-8" :model="domainFormData" :rules="domainFormRules" ref="domainFormRef"> <a-form class="mt-8" :model="domainFormData" :rules="domainFormRules" ref="domainFormRef">
<a-row v-for="(item, index) in domainFormItems" :key="item.value" :gutter="12"> <a-row v-for="(item, index) in domainFormItems" :key="item.value" :gutter="12">
@ -38,6 +38,7 @@
import useFormHandler from '@/hook/useFormHandler' import useFormHandler from '@/hook/useFormHandler'
import tool from '@/utils/tool' import tool from '@/utils/tool'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
import officialAccountApi from '@/api/base/wx/officialAccountApi'
const route = useRoute() const route = useRoute()
const formRules = { const formRules = {
@ -47,7 +48,7 @@
secret: [required('请输入AppSecret')] secret: [required('请输入AppSecret')]
} }
const brandFormItems = [ const brandFormItems = reactive([
{ {
label: '名称:', label: '名称:',
name: 'name', name: 'name',
@ -91,11 +92,16 @@
{ {
label: '公众号:', label: '公众号:',
name: 'officialAccountId', name: 'officialAccountId',
type: 'a-input', type: 'a-select',
span: 6, span: 6,
attrs: { attrs: {
placeholder: '请输入公众号', placeholder: '请输入公众号',
allowClear: true options: [],
fieldNames: {
children: 'children',
label: 'name',
value: 'id'
}
} }
}, },
{ {
@ -119,7 +125,7 @@
allowClear: true allowClear: true
} }
} }
] ])
const formRef1 = ref(null) const formRef1 = ref(null)
@ -131,6 +137,18 @@
onMounted(async () => { onMounted(async () => {
formRefs.value = [formRef1.value] formRefs.value = [formRef1.value]
await fetchData(route.query.type) await fetchData(route.query.type)
officialAccountApi
.officialAccountList({
enabledState: 'ENABLE'
})
.then((res) => {
brandFormItems.forEach((item) => {
if (item.name === 'officialAccountId') {
item.attrs.options = res
}
})
})
}) })
// //

View File

@ -6,105 +6,38 @@
:destroy-on-close="true" :destroy-on-close="true"
@close="onClose" @close="onClose"
> >
<a-form ref="formRef" :model="formData" :rules="formRules" layout="horizontal"> <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :span="12"> <a-col :span="24">
<a-form-item label="名称:" name="name"> <a-form-item label="名称:" name="name">
<a-input v-model:value="formData.name" placeholder="请输入名称" allow-clear /> <a-input v-model:value="formData.name" placeholder="请输入名称" allow-clear />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="24">
<a-form-item label="编码:" name="number"> <a-form-item label="编码:" name="number">
<a-input v-model:value="formData.number" placeholder="请输入编码" allow-clear /> <a-input v-model:value="formData.number" placeholder="请输入编码" allow-clear />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="24">
<a-form-item label="简称:" name="shortName"> <a-form-item label="上级:" name="parentId">
<a-input v-model:value="formData.shortName" placeholder="请输入简称" allow-clear /> <a-tree-select
v-model:value="formData.parentId"
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
:tree-data="parentTreeData"
placeholder="请选择上级仓库"
:fieldNames="{
children: 'children',
label: 'name',
value: 'id'
}"
>
</a-tree-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="24">
<a-form-item label="客户分类ID" name="categoryId"> <a-form-item label="排序码:" name="sortCode">
<a-input v-model:value="formData.categoryId" placeholder="请输入客户分类ID" allow-clear /> <a-input v-model:value="formData.sortCode" placeholder="请输入排序码" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="品牌:" name="brandId">
<a-input v-model:value="formData.brandId" placeholder="请输入品牌" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="省:" name="province">
<a-input v-model:value="formData.province" placeholder="请输入省" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="市:" name="city">
<a-input v-model:value="formData.city" placeholder="请输入市" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="县:" name="county">
<a-input v-model:value="formData.county" placeholder="请输入县" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="详细地址 " name="address">
<a-input v-model:value="formData.address" placeholder="请输入详细地址 " allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="启用状态:" name="enabledState">
<a-radio-group
v-model:value="formData.enabledState"
placeholder="请选择启用状态"
:options="enabledStateOptions"
/>
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="联系人:" name="contacts">
<a-input v-model:value="formData.contacts" placeholder="请输入联系人" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="手机:" name="phone">
<a-input v-model:value="formData.phone" placeholder="请输入手机" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="固话:" name="tel">
<a-input v-model:value="formData.tel" placeholder="请输入固话" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="传真:" name="fax">
<a-input v-model:value="formData.fax" placeholder="请输入传真" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="电子邮箱:" name="email">
<a-input v-model:value="formData.email" placeholder="请输入电子邮箱" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="qq" name="qq">
<a-input v-model:value="formData.qq" placeholder="请输入qq" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="微信号:" name="wechat">
<a-input v-model:value="formData.wechat" placeholder="请输入微信号" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="联系地址:" name="contactAddress">
<a-input v-model:value="formData.contactAddress" placeholder="请输入联系地址" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="扩展信息:" name="extJson">
<a-input v-model:value="formData.extJson" placeholder="请输入扩展信息" allow-clear />
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@ -126,7 +59,9 @@
const emit = defineEmits({ successful: null }) const emit = defineEmits({ successful: null })
const formRef = ref() const formRef = ref()
// //
const formData = ref({}) const formData = ref({
sortCode: '99'
})
const submitLoading = ref(false) const submitLoading = ref(false)
const enabledStateOptions = ref([]) const enabledStateOptions = ref([])
@ -138,6 +73,17 @@
formData.value = Object.assign({}, recordData) formData.value = Object.assign({}, recordData)
} }
enabledStateOptions.value = tool.dictList('COMMON_STATUS') enabledStateOptions.value = tool.dictList('COMMON_STATUS')
customerCategoryApi.customerCategoryTree().then(res => {
parentTreeData.value = [
{
id: 0,
parentId: '0',
name: '顶级',
children: res ? res : []
}
]
})
} }
// //
const onClose = () => { const onClose = () => {
@ -146,14 +92,17 @@
visible.value = false visible.value = false
} }
// //
const formRules = {} const formRules = {
name: [required('请输入名称')],
parentId: [required('请选择上级')],
}
// //
const onSubmit = () => { const onSubmit = () => {
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
submitLoading.value = true submitLoading.value = true
const formDataParam = cloneDeep(formData.value) const formDataParam = cloneDeep(formData.value)
customerCategoryApi customerCategoryApi
.customerSubmitForm(formDataParam, formDataParam.id) .customerCategorySubmitForm(formDataParam, formDataParam.id)
.then(() => { .then(() => {
onClose() onClose()
emit('successful') emit('successful')
@ -163,6 +112,8 @@
}) })
}) })
} }
let parentTreeData = ref([])
// //
defineExpose({ defineExpose({
onOpen onOpen

View File

@ -5,10 +5,10 @@
</template> </template>
</a-page-header> </a-page-header>
<a-card :bordered="false" title="仓库"> <a-card :bordered="false" title="客户">
<DynamicForm <DynamicForm
:allDisabled="route.query.type === 'SEARCH'" :allDisabled="route.query.type === 'SEARCH'"
:formItems="officialAccountFormItems" :formItems="clientFormItems"
:model="formData" :model="formData"
:rules="formRules" :rules="formRules"
ref="formRef1" ref="formRef1"
@ -23,7 +23,7 @@
:formItems="baseFormItems" :formItems="baseFormItems"
:model="formData" :model="formData"
:rules="formRules" :rules="formRules"
ref="formRef1" ref="formRef2"
/> />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="销售区域管理" force-render> <a-tab-pane key="2" tab="销售区域管理" force-render>
@ -33,14 +33,18 @@
</a-card> </a-card>
</template> </template>
<script setup> <script setup name="clientDetail">
import { required } from '@/utils/formRules' import { required } from '@/utils/formRules'
import officialAccountApi from '@/api/base/wx/officialAccountApi' import sysBrandApi from '@/api/base/brand/sysBrandApi'
import customerCategoryApi from '@/api/base/customer/customerCategoryApi'
import customerApi from '@/api/base/customer/customerApi'
import useFormHandler from '@/hook/useFormHandler' import useFormHandler from '@/hook/useFormHandler'
import tool from '@/utils/tool' import tool from '@/utils/tool'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
const route = useRoute() const route = useRoute()
import DynamicTable from '@/components/DynamicTable/index.vue' import DynamicTable from '@/components/DynamicTable/index.vue'
import cityOptions from '@/utils/cityOptions'
const formRules = { const formRules = {
name: [required('请输入名称')], name: [required('请输入名称')],
@ -49,12 +53,19 @@
secret: [required('请输入AppSecret')] secret: [required('请输入AppSecret')]
} }
const officialAccountFormItems = [ //
const onCascaderChange = (value) => {
formData.province = value[0] && value[0]
formData.city = value[1] && value[1]
formData.county = value[2] && value[2]
}
const clientFormItems = reactive([
{ {
label: '编码:', label: '编码:',
name: 'number', name: 'number',
type: 'a-select', type: 'a-input',
span: 6, span: 8,
attrs: { attrs: {
placeholder: '请选择类型', placeholder: '请选择类型',
options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') options: tool.dictList('OFFICIAL_ACCOUNT_TYPE')
@ -64,7 +75,7 @@
label: '名称:', label: '名称:',
name: 'name', name: 'name',
type: 'a-input', type: 'a-input',
span: 6, span: 8,
rules: [required('请输入名称')], rules: [required('请输入名称')],
attrs: { attrs: {
placeholder: '请输入名称', placeholder: '请输入名称',
@ -72,11 +83,10 @@
} }
}, },
{ {
label: '仓库条码', label: '简称',
name: 'name', name: 'shortName',
type: 'a-input', type: 'a-input',
span: 6, span: 8,
rules: [required('请输入名称')],
attrs: { attrs: {
placeholder: '请输入名称', placeholder: '请输入名称',
allowClear: true allowClear: true
@ -86,7 +96,7 @@
label: '可用状态:', label: '可用状态:',
name: 'enabledState', name: 'enabledState',
type: 'a-select', type: 'a-select',
span: 6, span: 8,
attrs: { attrs: {
placeholder: '请选择可用状态', placeholder: '请选择可用状态',
options: tool.dictList('COMMON_STATUS') options: tool.dictList('COMMON_STATUS')
@ -94,14 +104,60 @@
defaultValue: 'ENABLE' defaultValue: 'ENABLE'
}, },
{ {
label: '库存管理方式', label: '品牌',
name: 'name', name: 'brandId',
type: 'a-input', type: 'a-select',
span: 6, span: 8,
rules: [required('请输入名称')], rules: [required('请选择品牌')],
attrs: { attrs: {
placeholder: '请输入名称', placeholder: '请选择品牌',
allowClear: true options: tool.dictList('COMMON_STATUS'),
fieldNames: {
label: 'name',
value: 'id'
}
}
},
{
label: '客户分类:',
name: 'categoryId',
type: 'a-tree-select',
span: 8,
rules: [required('请选择客户分类')],
attrs: {
placeholder: '请选择客户分类',
allowClear: true,
fieldNames: {
children: 'children',
label: 'name',
value: 'id'
}
}
},
{
label: '详细地址:',
name: 'provinceName',
type: 'a-cascader',
span: 8,
rules: [required('请选择详细地址')],
attrs: {
placeholder: '请选择详细地址',
options: cityOptions,
onChange: onCascaderChange
}
},
{
name: 'address',
type: 'a-textarea',
span: 24,
attrs: {
placeholder: '请输入详细地址',
allowClear: true,
fieldNames: {
children: 'children',
label: 'name',
value: 'id'
}
} }
}, },
{ {
@ -114,44 +170,80 @@
allowClear: true allowClear: true
} }
} }
] ])
const baseFormItems = [ const baseFormItems = [
{ {
label: '管理员', label: '联系人',
name: 'number', name: 'contacts',
type: 'a-select', type: 'a-input',
span: 6, span: 6,
attrs: { attrs: {
placeholder: '请选择类型', placeholder: '请选择类型'
options: tool.dictList('OFFICIAL_ACCOUNT_TYPE')
} }
}, },
{ {
label: '手机:', label: '手机:',
name: 'number', name: 'phone',
type: 'a-select', type: 'a-input',
span: 6, span: 6,
attrs: { attrs: {
placeholder: '请选择类型', placeholder: '请选择类型'
options: tool.dictList('OFFICIAL_ACCOUNT_TYPE')
} }
}, },
{ {
label: '固话:', label: '固话:',
name: 'number', name: 'tel',
type: 'a-select', type: 'a-input',
span: 6, span: 6,
attrs: { attrs: {
placeholder: '请选择类型', placeholder: '请选择类型'
options: tool.dictList('OFFICIAL_ACCOUNT_TYPE')
} }
}, },
{ {
label: '地址:', label: '传真:',
name: 'remarks', name: 'fax',
type: 'a-textarea', type: 'a-input',
span: 24, span: 6,
attrs: {
placeholder: '请选择类型'
}
},
{
label: '电子邮箱:',
name: 'email',
type: 'a-input',
span: 6,
attrs: {
placeholder: '请输入备注',
allowClear: true
}
},
{
label: 'QQ',
name: 'qq',
type: 'a-input',
span: 6,
attrs: {
placeholder: '请输入备注',
allowClear: true
}
},
{
label: '微信:',
name: 'wechat',
type: 'a-input',
span: 6,
attrs: {
placeholder: '请输入备注',
allowClear: true
}
},
{
label: '联系地址:',
name: 'contactAddress',
type: 'a-input',
span: 6,
attrs: { attrs: {
placeholder: '请输入备注', placeholder: '请输入备注',
allowClear: true allowClear: true
@ -163,16 +255,45 @@
const formRef2 = ref(null) const formRef2 = ref(null)
const { state, formData, submitLoading, formRefs, onSubmit, handleBack, fetchData } = useFormHandler( const { state, formData, submitLoading, formRefs, onSubmit, handleBack, fetchData } = useFormHandler(
[...officialAccountFormItems, ...baseFormItems], [...clientFormItems, ...baseFormItems],
{ {
submitForm: officialAccountApi.officialAccountSubmitForm, submitForm: customerApi.customerSubmitForm,
getDetail: officialAccountApi.officialAccountDetail getDetail: customerApi.customerDetail
} }
) )
onMounted(() => { onMounted(async () => {
formRefs.value = [formRef1.value, formRef2.value] formRefs.value = [formRef1.value, formRef2.value]
fetchData(route.query.type) fetchData(route.query.type).then((res) => {
formData.provinceName = [res.province, res.city, res.county]
})
//
sysBrandApi
.sysBrandList({
enabledState: 'ENABLE'
})
.then((res) => {
clientFormItems.forEach((item) => {
if (item.name === 'brandId') {
item.attrs.options = res
}
})
})
//
customerCategoryApi
.customerCategoryTree({
enabledState: 'ENABLE'
})
.then((res) => {
clientFormItems.forEach((item) => {
if (item.name === 'categoryId') {
item.attrs.treeData = res
}
})
})
}) })
let activeKey = ref('1') let activeKey = ref('1')

View File

@ -33,19 +33,19 @@
<component class="icons" :is="item.icon"></component> <component class="icons" :is="item.icon"></component>
</a-tooltip> </a-tooltip>
<!-- 修改 --> <!-- 修改 -->
<a-tooltip :title="item.title" class="s-tool-item" v-if="item.name === 'edit'"> <a-tooltip :title="item.title" class="s-tool-item" v-if="item.name === 'edit'" @click="handleEditTree">
<component class="icons" :is="item.icon"></component> <component class="icons" :is="item.icon"></component>
</a-tooltip> </a-tooltip>
<!-- 删除 --> <!-- 删除 -->
<a-tooltip :title="item.title" class="s-tool-item" v-if="item.name === 'delete'"> <a-tooltip :title="item.title" class="s-tool-item" v-if="item.name === 'delete'" @click="handleDelTree">
<a-popconfirm title="确认删除?" ok-text="Yes" cancel-text="No"> <a-popconfirm title="确认删除?" ok-text="Yes" cancel-text="No">
<component class="icons" :is="item.icon"></component> <component class="icons" :is="item.icon"></component>
</a-popconfirm> </a-popconfirm>
</a-tooltip> </a-tooltip>
<!-- 刷新 --> <!-- 刷新 -->
<a-tooltip :title="item.title" class="s-tool-item" v-if="item.name === 'refresh'"> <!-- <a-tooltip :title="item.title" class="s-tool-item" v-if="item.name === 'refresh'">
<component class="icons" :is="item.icon"></component> <component class="icons" :is="item.icon"></component>
</a-tooltip> </a-tooltip>-->
</span> </span>
</div> </div>
</div> </div>
@ -55,6 +55,13 @@
v-model:selectedKeys="selectedKeys" v-model:selectedKeys="selectedKeys"
multiple multiple
:tree-data="treeData" :tree-data="treeData"
:selectedKeys="treeSelectedKeys"
:fieldNames="{
children: 'children',
title: 'name',
key: 'id'
}"
@select="handleTreeClick"
></a-directory-tree> ></a-directory-tree>
</a-col> </a-col>
<a-col :span="18"> <a-col :span="18">
@ -135,7 +142,7 @@
</s-table> </s-table>
</a-col> </a-col>
</a-row> </a-row>
<CustomerCategoryForm ref="CustomerCategoryFormRef"></CustomerCategoryForm> <CustomerCategoryForm ref="CustomerCategoryFormRef" @successful="successful"></CustomerCategoryForm>
</a-card> </a-card>
</template> </template>
@ -144,6 +151,7 @@
import customerCategoryApi from '@/api/base/customer/customerCategoryApi' import customerCategoryApi from '@/api/base/customer/customerCategoryApi'
import { useTableManagement } from '@/hook/useTableManagement' import { useTableManagement } from '@/hook/useTableManagement'
import CustomerCategoryForm from '@/views/basicData/client/detail/CustomerCategoryForm.vue' import CustomerCategoryForm from '@/views/basicData/client/detail/CustomerCategoryForm.vue'
import { message } from 'ant-design-vue'
const clientColumn = [ const clientColumn = [
{ {
@ -157,27 +165,20 @@
}, },
{ {
title: '名称', title: '名称',
dataIndex: 'type', dataIndex: 'name',
align: 'center', align: 'center',
resizable: true, resizable: true,
width: 100 width: 100
}, },
{ {
title: '分类', title: '分类',
dataIndex: 'name', dataIndex: 'type',
sorter: (a, b) => a.address.length - b.address.length, sorter: (a, b) => a.address.length - b.address.length,
sortDirections: ['descend', 'ascend'], sortDirections: ['descend', 'ascend'],
align: 'center', align: 'center',
resizable: true, resizable: true,
width: 100 width: 100
}, },
{
title: '年龄',
dataIndex: 'enabledState',
align: 'center',
resizable: true,
width: 100
},
{ {
title: '可用状态', title: '可用状态',
dataIndex: 'enabledState', dataIndex: 'enabledState',
@ -244,16 +245,55 @@
// //
const expandedKeys = ref(['0-0', '0-1']) const expandedKeys = ref(['0-0', '0-1'])
const selectedKeys = ref([]) const selectedKeys = ref([])
const treeData = [] const treeData = ref([])
const CustomerCategoryFormRef = ref(null) const CustomerCategoryFormRef = ref(null)
let treeRow = {}
let treeSelectedKeys = ref([])
const handleTreeClick = (selectedKeys, event) => {
treeRow = event.node
tableRef.value.refresh()
searchFormState.value.categoryId = selectedKeys[0]
treeSelectedKeys.value = selectedKeys
}
const handleAddTree = () => { const handleAddTree = () => {
CustomerCategoryFormRef.value.onOpen() CustomerCategoryFormRef.value.onOpen()
} }
const handleEditTree = () => {
if (!treeRow.id) return message.error('!请选择要编辑的数据')
CustomerCategoryFormRef.value.onOpen(treeRow)
}
const handleDelTree = () => {
if (!treeRow.id) return message.error('!请选择要编辑的数据')
customerCategoryApi.customerCategoryDelete([{ id: treeRow.id }]).then((res) => {
treeSelectedKeys.value = []
searchFormState.value.categoryId = null
treeRow = {}
tableRef.value.refresh()
customerCategoryApi.customerCategoryTree().then((res) => {
treeData.value = res
})
})
}
const successful = () => {
treeSelectedKeys.value = []
searchFormState.value.categoryId = null
treeRow = {}
tableRef.value.refresh()
customerCategoryApi.customerCategoryTree().then((res) => {
treeData.value = res
})
}
onMounted(() => { onMounted(() => {
customerCategoryApi.customerCategoryTree().then((res) => { customerCategoryApi.customerCategoryTree().then((res) => {
console.log(res) treeData.value = res
}) })
}) })
</script> </script>

View File

@ -23,24 +23,24 @@
:formItems="baseFormItems" :formItems="baseFormItems"
:model="formData" :model="formData"
:rules="formRules" :rules="formRules"
ref="formRef1" ref="formRef2"
/> />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="2" tab="上游仓库系统" force-render> <a-tab-pane key="2" tab="上游仓库系统" force-render>
<DynamicTable :initialData="data" :columns="columns" rowKey="id"></DynamicTable> <!-- <DynamicTable :initialData="data" :columns="columns" rowKey="id"></DynamicTable>-->
</a-tab-pane> </a-tab-pane>
</a-tabs> </a-tabs>
</a-card> </a-card>
</template> </template>
<script setup> <script setup name="stashDetail">
import { required } from '@/utils/formRules' import { required } from '@/utils/formRules'
import officialAccountApi from '@/api/base/wx/officialAccountApi' import sysStoreApi from '@/api/base/store/sysStoreApi'
import useFormHandler from '@/hook/useFormHandler' import useFormHandler from '@/hook/useFormHandler'
import tool from '@/utils/tool' import tool from '@/utils/tool'
import { useRoute } from 'vue-router' import { useRoute } from 'vue-router'
const route = useRoute() const route = useRoute()
import DynamicTable from '@/components/DynamicTable/index.vue'; import DynamicTable from '@/components/DynamicTable/index.vue'
const formRules = { const formRules = {
name: [required('请输入名称')], name: [required('请输入名称')],
@ -53,11 +53,10 @@
{ {
label: '编码:', label: '编码:',
name: 'number', name: 'number',
type: 'a-select', type: 'a-input',
span: 6, span: 6,
attrs: { attrs: {
placeholder: '请选择类型', placeholder: '请选择编码'
options: tool.dictList('OFFICIAL_ACCOUNT_TYPE')
} }
}, },
{ {
@ -73,12 +72,12 @@
}, },
{ {
label: '仓库条码:', label: '仓库条码:',
name: 'name', name: 'barcode',
type: 'a-input', type: 'a-input',
span: 6, span: 6,
rules: [required('请输入名称')], rules: [required('请输入仓库条码')],
attrs: { attrs: {
placeholder: '请输入名称', placeholder: '请输入仓库条码',
allowClear: true allowClear: true
} }
}, },
@ -95,14 +94,15 @@
}, },
{ {
label: '库存管理方式:', label: '库存管理方式:',
name: 'name', name: 'manageMode',
type: 'a-input', type: 'a-select',
span: 6, span: 6,
rules: [required('请输入名称')], rules: [required('请选择库存管理方式')],
attrs: { attrs: {
placeholder: '请输入名称', placeholder: '请选择库存管理方式',
allowClear: true options: tool.dictList('STORE_MANAGE_MODE')
} },
defaultValue: ''
}, },
{ {
label: '备注:', label: '备注:',
@ -119,55 +119,52 @@
const baseFormItems = [ const baseFormItems = [
{ {
label: '管理员:', label: '管理员:',
name: 'number', name: 'manageUserId',
type: 'a-select', type: 'a-select',
span: 6, span: 6,
attrs: { attrs: {
placeholder: '请选择类型', placeholder: '请选择管理员',
options: tool.dictList('OFFICIAL_ACCOUNT_TYPE') options: tool.dictList('OFFICIAL_ACCOUNT_TYPE')
} }
}, },
{ {
label: '手机:', label: '手机:',
name: 'number', name: 'phone',
type: 'a-select', type: 'a-input',
span: 6, span: 6,
attrs: { attrs: {
placeholder: '请选择类型', placeholder: '请输入手机'
options: tool.dictList('OFFICIAL_ACCOUNT_TYPE')
} }
}, },
{ {
label: '固话:', label: '固话:',
name: 'number', name: 'tel',
type: 'a-select', type: 'a-input',
span: 6, span: 6,
attrs: { attrs: {
placeholder: '请选择类型', placeholder: '请选择固话'
options: tool.dictList('OFFICIAL_ACCOUNT_TYPE')
} }
}, },
{ {
label: '地址:', label: '地址:',
name: 'remarks', name: 'address',
type: 'a-textarea', type: 'a-textarea',
span: 24, span: 24,
attrs: { attrs: {
placeholder: '请输入备注', placeholder: '请输入地址',
allowClear: true allowClear: true
} }
} }
] ]
const formRef1 = ref(null) const formRef1 = ref(null)
const formRef2 = ref(null) const formRef2 = ref(null)
const { state, formData, submitLoading, formRefs, onSubmit, handleBack, fetchData } = useFormHandler( const { state, formData, submitLoading, formRefs, onSubmit, handleBack, fetchData } = useFormHandler(
[...officialAccountFormItems, ...baseFormItems], [...officialAccountFormItems, ...baseFormItems],
{ {
submitForm: officialAccountApi.officialAccountSubmitForm, submitForm: sysStoreApi.sysStoreSubmitForm,
getDetail: officialAccountApi.officialAccountDetail getDetail: sysStoreApi.sysStoreDetail
} }
) )

View File

@ -6,36 +6,67 @@
:destroy-on-close="true" :destroy-on-close="true"
@close="onClose" @close="onClose"
> >
<a-form ref="formRef" :model="formData" :rules="formRules" layout="horizontal"> <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
<a-row :gutter="16"> <a-row :gutter="16">
<a-col :span="12"> <a-col :span="24">
<a-form-item label="名称:" name="name">
<a-input v-model:value="formData.name" placeholder="请输入名称" allow-clear />
</a-form-item>
</a-col>
<a-col :span="12">
<a-form-item label="编码:" name="number"> <a-form-item label="编码:" name="number">
<a-input v-model:value="formData.number" placeholder="请输入编码" allow-clear /> <a-input v-model:value="formData.number" placeholder="请输入编码" allow-clear />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="24">
<a-form-item label="仓库:" name="storeId"> <a-form-item label="类型:" name="type">
<a-input v-model:value="formData.storeId" placeholder="请输入仓库id" allow-clear /> <a-select
v-model:value="formData.type"
placeholder="请选择组织类型"
:options="typeOptions"
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="24">
<a-form-item label="厂家名称:" name="manufacturer"> <a-form-item label="工厂名称:" name="name">
<a-input v-model:value="formData.name" placeholder="请输入工厂名称" allow-clear />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="仓库:" name="storeId">
<a-tree-select <a-tree-select
v-model:value="formData.manufacturer" v-model:value="formData.storeId"
style="width: 100%" style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }" :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
:tree-data="treeData" :tree-data="treeData"
placeholder="Please select" placeholder="请选择仓库名称"
:fieldNames="{
children: 'children',
label: 'name',
value: 'id'
}"
> >
</a-tree-select> </a-tree-select>
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="12"> <a-col :span="24">
<a-form-item label="上级仓库:" name="parentId" v-if="formData.type !== 'FACTORY'">
<a-tree-select
v-model:value="formData.parentId"
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
:tree-data="parentTreeData"
placeholder="请选择上级仓库"
:fieldNames="{
children: 'children',
label: 'name',
value: 'id'
}"
>
</a-tree-select>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="厂家名称:" name="manufacturer" v-if="formData.type === 'FACTORY'">
<a-input v-model:value="formData.manufacturer" placeholder="请输入仓库id" allow-clear />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="启用状态:" name="enabledState"> <a-form-item label="启用状态:" name="enabledState">
<a-select <a-select
v-model:value="formData.enabledState" v-model:value="formData.enabledState"
@ -64,7 +95,10 @@
const emit = defineEmits({ successful: null }) const emit = defineEmits({ successful: null })
const formRef = ref() const formRef = ref()
// //
const formData = ref({}) const formData = ref({
type: 'FACTORY',
enabledState: 'ENABLE'
})
const submitLoading = ref(false) const submitLoading = ref(false)
const typeOptions = ref([]) const typeOptions = ref([])
const enabledStateOptions = ref([]) const enabledStateOptions = ref([])
@ -76,11 +110,15 @@
let recordData = cloneDeep(record) let recordData = cloneDeep(record)
formData.value = Object.assign({}, recordData) formData.value = Object.assign({}, recordData)
} }
typeOptions.value = tool.dictList('GENDER') typeOptions.value = tool.dictList('PRODUCTION_ORGANIZATION_TYPE')
enabledStateOptions.value = tool.dictList('COMMON_STATUS') enabledStateOptions.value = tool.dictList('COMMON_STATUS')
sysStoreApi.sysStoreTree().then(res => { sysStoreApi.sysStoreTree().then((res) => {
console.log(res) treeData.value = res || []
})
productionOrganizationApi.productionOrganizationTree().then((res) => {
parentTreeData.value = res
}) })
} }
// //
@ -90,7 +128,11 @@
visible.value = false visible.value = false
} }
// //
const formRules = {} const formRules = {
name: [required('请输入名称')],
type: [required('请输入类型')],
parentId: [required('请选择上级仓库')],
}
// //
const onSubmit = () => { const onSubmit = () => {
formRef.value.validate().then(() => { formRef.value.validate().then(() => {
@ -108,32 +150,8 @@
}) })
} }
const treeData = [ let treeData = ref([])
{ let parentTreeData = ref([])
title: 'Node1',
value: '0-0',
key: '0-0',
children: [
{
value: '0-0-1',
key: '0-0-1',
slots: {
title: 'title'
}
},
{
title: 'Child Node2',
value: '0-0-2',
key: '0-0-2'
}
]
},
{
title: 'Node2',
value: '0-1',
key: '0-1'
}
]
// //
defineExpose({ defineExpose({
onOpen onOpen

View File

@ -21,6 +21,21 @@
</a-card> </a-card>
<a-card :bordered="false" class="mt-4"> <a-card :bordered="false" class="mt-4">
<a-row :gutter="24">
<a-col :span="4">
<a-directory-tree
v-model:expandedKeys="expandedKeys"
v-model:selectedKeys="selectedKeys"
multiple
:fieldNames="{
children: 'children',
title: 'name',
key: 'id'
}"
:tree-data="treeData"
></a-directory-tree>
</a-col>
<a-col :span="20">
<s-table <s-table
ref="tableRef" ref="tableRef"
:columns="columns" :columns="columns"
@ -55,7 +70,7 @@
/> />
</template> </template>
<template v-if="column.dataIndex === 'type'"> <template v-if="column.dataIndex === 'type'">
{{ $TOOL.dictTypeData('OFFICIAL_ACCOUNT_TYPE', record.type) }} {{ $TOOL.dictTypeData('PRODUCTION_ORGANIZATION_TYPE', record.type) }}
</template> </template>
<template v-if="column.dataIndex === 'action'"> <template v-if="column.dataIndex === 'action'">
<a-space> <a-space>
@ -79,6 +94,8 @@
</template> </template>
</template> </template>
</s-table> </s-table>
</a-col>
</a-row>
</a-card> </a-card>
<TissueForm ref="TissueFormRef"></TissueForm> <TissueForm ref="TissueFormRef"></TissueForm>
@ -156,4 +173,16 @@
) )
const TissueFormRef = ref(null) const TissueFormRef = ref(null)
//
const expandedKeys = ref(['0-0', '0-1'])
const selectedKeys = ref([])
let treeData = ref([])
onMounted(() => {
productionOrganizationApi.productionOrganizationTree().then((res) => {
console.log(res)
treeData.value = res
})
})
</script> </script>

View File

@ -3,9 +3,6 @@
<template #extra> <template #extra>
<a-button key="1" type="primary" @click="onSubmit"></a-button> <a-button key="1" type="primary" @click="onSubmit"></a-button>
</template> </template>
<template #title>
<span style="font-size: 18px">新增</span>
</template>
</a-page-header> </a-page-header>
<a-card :bordered="false" title="基本信息"> <a-card :bordered="false" title="基本信息">
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical"> <a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">

View File

@ -8,8 +8,8 @@
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
<a-form-item label="状态" name="state"> <a-form-item label="状态" name="enabledState">
<a-select v-model:value="searchFormState.state" placeholder="请选择状态" :options="stateOptions" /> <a-select v-model:value="searchFormState.enabledState" placeholder="请选择状态" :options="stateOptions" />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6"> <a-col :span="6">
@ -26,13 +26,8 @@
/> />
</a-form-item> </a-form-item>
</a-col> </a-col>
<a-col :span="6" v-show="advanced">
<a-form-item label="单位组id" name="unitGroupId">
<a-input v-model:value="searchFormState.unitGroupId" placeholder="请输入单位组id" />
</a-form-item>
</a-col>
<a-col :span="6"> <a-col :span="6">
<a-button type="primary" @click="tableRef.refresh()"></a-button> <a-button type="primary" @click="unitTableRef.refresh()"></a-button>
<a-button style="margin: 0 8px" @click="reset"></a-button> <a-button style="margin: 0 8px" @click="reset"></a-button>
<a @click="toggleAdvanced" style="margin-left: 8px"> <a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }} {{ advanced ? '收起' : '展开' }}
@ -56,23 +51,21 @@
@plusRowData="handlePlusRowData" @plusRowData="handlePlusRowData"
@editRowData="handleEditRowData" @editRowData="handleEditRowData"
@deleteRowData="handleDeleteRowData" @deleteRowData="handleDeleteRowData"
:rowSelection="{ :rowSelection="unitGroupRowSelection"
type: 'radio',
onChange: unitGroupOnChange
}"
> >
<template #operator class="table-operator"> <template #operator class="table-operator">
<span>单位组</span> <span>单位组</span>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'enabledState'"> <template v-if="column.dataIndex === 'enabledState'">
<a-switch <!-- <a-switch
checkedValue="ENABLE" checkedValue="ENABLE"
unCheckedValue="DISABLED" unCheckedValue="DISABLED"
checked-children="启用" checked-children="启用"
un-checked-children="停用" un-checked-children="停用"
v-model:checked="record.enabledState" v-model:checked="record.enabledState"
/> />-->
{{ $TOOL.dictTypeData('COMMON_STATUS', record.enabledState) }}
</template> </template>
</template> </template>
</s-table> </s-table>
@ -111,13 +104,14 @@
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'enabledState'"> <template v-if="column.dataIndex === 'enabledState'">
<a-switch <!-- <a-switch
checkedValue="ENABLE" checkedValue="ENABLE"
unCheckedValue="DISABLED" unCheckedValue="DISABLED"
checked-children="启用" checked-children="启用"
un-checked-children="停用" un-checked-children="停用"
v-model:checked="record.enabledState" v-model:checked="record.enabledState"
/> />-->
{{ $TOOL.dictTypeData('COMMON_STATUS', record.enabledState) }}
</template> </template>
<template v-if="column.dataIndex === 'isBase'"> <template v-if="column.dataIndex === 'isBase'">
{{ $TOOL.dictTypeData('YES_NO', record.isBase) }} {{ $TOOL.dictTypeData('YES_NO', record.isBase) }}
@ -233,7 +227,7 @@
// //
const reset = () => { const reset = () => {
searchFormRef.value.resetFields() searchFormRef.value.resetFields()
tableRef.value.refresh(true) unitTableRef.value.refresh(true)
} }
// //
const deleteSysUnit = (record) => { const deleteSysUnit = (record) => {
@ -243,13 +237,13 @@
} }
] ]
sysUnitApi.sysUnitDelete(params).then(() => { sysUnitApi.sysUnitDelete(params).then(() => {
tableRef.value.refresh(true) unitTableRef.value.refresh(true)
}) })
} }
// //
const deleteBatchSysUnit = (params) => { const deleteBatchSysUnit = (params) => {
sysUnitApi.sysUnitDelete(params).then(() => { sysUnitApi.sysUnitDelete(params).then(() => {
tableRef.value.clearRefreshSelected() unitTableRef.value.clearRefreshSelected()
}) })
} }
const stateOptions = tool.dictList('COMMON_STATUS') const stateOptions = tool.dictList('COMMON_STATUS')
@ -260,7 +254,19 @@
// //
let unitGroupRecord = '' let unitGroupRecord = ''
let unitGroupSelectedRowKeys = ref([])
const unitGroupRowSelection = {
type: 'radio',
onChange: (selectedRowKey, selectedRows) => {
unitGroupRecord = selectedRows[0]
searchFormState.value.unitGroupId = selectedRowKey[0]
unitTableRef.value.refresh()
unitGroupSelectedRowKeys.value = selectedRowKey
}
}
const handlePlusRowData = () => { const handlePlusRowData = () => {
unitGroupRecord = ''
unitGroupTableRef.value.clearSelected()
UnitGroupFormRef.value.onOpen() UnitGroupFormRef.value.onOpen()
} }
@ -278,17 +284,16 @@
} }
]) ])
.then(() => { .then(() => {
searchFormState.value.unitGroupId = ''
unitGroupTableRef.value.clearSelected()
unitGroupTableRef.value.refresh() unitGroupTableRef.value.refresh()
}) })
} }
const successful = () => { const successful = () => {
searchFormState.value.unitGroupId = ''
unitGroupTableRef.value.refresh() unitGroupTableRef.value.refresh()
} unitGroupRecord = ''
unitGroupTableRef.value.clearSelected()
const unitGroupOnChange = (value, selectedOptions) => {
unitGroupRecord = selectedOptions[0]
searchFormState.value.unitGroupId = value[0]
unitTableRef.value.refresh()
} }
</script> </script>