基础资料模块

main
GaoF 2024-07-26 21:11:03 +08:00
parent f5678a4988
commit 11e6f17532
17 changed files with 230 additions and 482 deletions

View File

@ -10,7 +10,7 @@ const request = (url, ...arg) => baseRequest(`/base/brand/` + url, ...arg)
**/
export default {
// 获取品牌分页
sysBrandPage(data) {
page(data) {
return request('page', data, 'get')
},
// 获取品牌列表

View File

@ -1,32 +0,0 @@
import { baseRequest } from '@/utils/request'
const request = (url, ...arg) => baseRequest(`/base/material/` + url, ...arg)
/**
* 物料Api接口管理器
*
* @author Luck
* @date 2024/07/24 19:54
**/
export default {
// 获取物料分页
materialPage(data) {
return request('page', data, 'get')
},
// 获取物料 -- 物料包装数据
materialPackageData(data) {
return request('/package/data', data, 'get')
},
// 提交物料表单 edit为true时为编辑默认为新增
materialSubmitForm(data, edit = false) {
return request(edit ? 'edit' : 'add', data)
},
// 删除物料
materialDelete(data) {
return request('delete', data)
},
// 获取物料详情
materialDetail(data) {
return request('detail', data, 'get')
}
}

View File

@ -1,32 +0,0 @@
import { baseRequest } from '@/utils/request'
const request = (url, ...arg) => baseRequest(`/base/materialCategory/` + url, ...arg)
/**
* 物料分类Api接口管理器
*
* @author Luck
* @date 2024/07/24 19:35
**/
export default {
// 获取物料分类分页
materialCategoryPage(data) {
return request('page', data, 'get')
},
// 获取物料分类 树结构
materialCategoryTree(data) {
return request('tree', data, 'get')
},
// 提交物料分类表单 edit为true时为编辑默认为新增
materialCategorySubmitForm(data, edit = false) {
return request(edit ? 'edit' : 'add', data)
},
// 删除物料分类
materialCategoryDelete(data) {
return request('delete', data)
},
// 获取物料分类详情
materialCategoryDetail(data) {
return request('detail', data, 'get')
}
}

View File

@ -1,48 +0,0 @@
import { baseRequest } from '@/utils/request'
const request = (url, ...arg) => baseRequest(`/base/store/` + url, ...arg)
/**
* 仓库Api接口管理器
*
* @author Luck
* @date 2024/07/24 19:32
**/
export default {
// 获取仓库分页
sysStorePage(data) {
return request('page', data, 'get')
},
// 获取仓库 树结构
sysStoreTree(data) {
return request('tree', data, 'get')
},
// 提交仓库表单 edit为true时为编辑默认为新增
sysStoreSubmitForm(data, edit = false) {
return request(edit ? 'edit' : 'add', data)
},
// 删除仓库
sysStoreDelete(data) {
return request('delete', data)
},
// 获取仓库详情
sysStoreDetail(data) {
return request('detail', data, 'get')
},
// 获取仓库 树选择器
sysStoreSelector(data, isTop = false) {
let res = this.sysStoreTree(data);
if(isTop){
res = [
{
id: 0,
parentId: '-1',
name: '顶级',
children: res ? res : []
}
]
}
return res;
},
}

View File

@ -6,11 +6,11 @@ const request = (url, ...arg) => baseRequest(`/wx/officialaccount/` + url, ...ar
* 公众号Api接口管理器
*
* @author Luck
* @date 2024/07/24 20:01
* @date 2024/07/25 11:03
**/
export default {
// 获取公众号分页
officialAccountPage(data) {
page(data) {
return request('page', data, 'get')
},
// 提交公众号表单 edit为true时为编辑默认为新增

View File

@ -1,28 +0,0 @@
import { baseRequest } from '@/utils/request'
const request = (url, ...arg) => baseRequest(`/base/sysunit/` + url, ...arg)
/**
* 单位Api接口管理器
*
* @author Luck
* @date 2024/07/23 11:36
**/
export default {
// 获取单位分页
sysUnitPage(data) {
return request('page', data, 'get')
},
// 提交单位表单 edit为true时为编辑默认为新增
sysUnitSubmitForm(data, edit = false) {
return request(edit ? 'edit' : 'add', data)
},
// 删除单位
sysUnitDelete(data) {
return request('delete', data)
},
// 获取单位详情
sysUnitDetail(data) {
return request('detail', data, 'get')
}
}

View File

@ -1,49 +0,0 @@
<template>
<xn-form-container
:title="formData.id ? '编辑单位组' : '增加单位组'"
:width="700"
:visible="visible"
:destroy-on-close="true"
@close="onClose"
>
<dynamic-form></dynamic-form>
<template #footer>
<a-button style="margin-right: 8px" @click="onClose"></a-button>
<a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
</template>
</xn-form-container>
</template>
<script setup>
// const props = defineProps({})
// const emit = defineEmits()
const submitLoading = ref(false)
//
const onClose = () => {}
//
const onSubmit = () => {}
//
onMounted(() => {
console.log('Component mounted')
// TODO: Add your onMounted code here
})
onUpdated(() => {
console.log('Component updated')
// TODO: Add your onUpdated code here
})
onUnmounted(() => {
console.log('Component unmounted')
// TODO: Add your onUnmounted code here
})
// watch(() => {}, () => {})
</script>
<style scoped></style>

View File

@ -1,15 +1,9 @@
<template>
<a-form ref="formRef" :model="formData" :rules="formRules" layout="horizontal">
<a-form :model="model" :rules="rules" layout="vertical" ref="formRef">
<a-row :gutter="16">
<a-col v-for="field in fields" :key="field.name" :span="12" v-show="!field.advanced || advanced">
<a-form-item :label="field.label" :name="field.name">
<component
:is="getComponent(field.type)"
v-model:value="formData[field.name]"
v-bind="field.options"
:placeholder="field.placeholder"
:allow-clear="field.allowClear"
/>
<a-col :span="col.span || 24" v-for="(item, index) in formItems" :key="index">
<a-form-item :label="item.label" :name="item.name" :rules="item.rules">
<component :is="item.type" v-model:value="model[item.name]" v-bind="item.attrs" />
</a-form-item>
</a-col>
</a-row>
@ -17,60 +11,35 @@
</template>
<script setup>
//
import { ref, watch } from 'vue'
const props = defineProps({
fields: {
formItems: {
type: Array,
required: true
},
formData: {
model: {
type: Object,
required: true
},
formRules: {
rules: {
type: Object,
default: () => ({})
},
col: {
type: Object,
default: () => ({ span: 8 })
}
})
const emit = defineEmits(['submit', 'reset'])
const formRef = ref()
//
const formRef = ref(null)
//
const advanced = ref(false)
//
const toggleAdvanced = () => {
advanced.value = !advanced.value
}
//
const onSubmit = () => {
formRef.value.validate((valid) => {
if (valid) {
emit('submit', formData)
} else {
console.log('表单验证失败')
}
})
}
//
const onReset = () => {
formRef.value.resetFields()
emit('reset')
}
//
const getComponent = (type) => {
const componentMap = {
input: 'a-input',
select: 'a-select',
radio: 'a-radio-group',
switch: 'a-switch'
}
return componentMap[type] || 'a-input'
}
// Expose validate method
defineExpose({
validate: () => formRef.value.validate()
})
</script>
<style scoped>
/* Add your styles here */
</style>

View File

@ -1,98 +0,0 @@
<!-- DynamicForm.vue -->
<template>
<a-card :bordered="false">
<a-form ref="searchFormRef" name="advanced_search" :model="formState" class="ant-advanced-search-form">
<a-row :gutter="24">
<a-col v-for="(field, index) in fields" :key="index" :span="6" v-show="!field.advanced || advanced">
<a-form-item :label="field.label" :name="field.name">
<component
:is="getComponent(field)"
v-model:value="formState[field.name]"
:placeholder="field.placeholder"
:options="field.options"
/>
</a-form-item>
</a-col>
<a-col :span="6">
<a-button type="primary" @click="onSearch"></a-button>
<a-button style="margin: 0 8px" @click="reset"></a-button>
<a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }}
<component :is="advanced ? 'up-outlined' : 'down-outlined'" />
</a>
</a-col>
</a-row>
</a-form>
</a-card>
</template>
<script setup>
import { ref, defineProps, defineEmits, onMounted, onUpdated, onUnmounted, watch } from 'vue'
const props = defineProps({
fields: {
type: Array,
required: true,
default: () => []
}
})
const emit = defineEmits(['update:modelValue', 'search'])
const searchFormRef = ref(null)
const formState = ref({})
const advanced = ref(false)
const reset = () => {
formState.value = { ...props.modelValue }
emit('update:modelValue', formState.value)
}
const onSearch = () => {
emit('search', formState.value)
}
const toggleAdvanced = () => {
advanced.value = !advanced.value
}
const getComponent = (field) => {
switch (field.type) {
case 'input':
return 'a-input'
case 'select':
return 'a-select'
default:
return 'a-input'
}
}
//
onMounted(() => {
console.log('Component mounted')
})
onUpdated(() => {
console.log('Component updated')
})
onUnmounted(() => {
console.log('Component unmounted')
})
const extractNamesAsObject = (fields) => {
return fields.reduce((acc, field) => {
acc[field.name] = field // field.name field
return acc
}, {})
}
watch(
() => props.fields,
(newVal) => {
formState.value = { ...extractNamesAsObject(newVal) }
}
)
</script>
<style scoped></style>

View File

@ -118,8 +118,8 @@
typeof props.alert === 'boolean' && props.alert
? clearSelected()
: props.alert.clear && typeof props.alert.clear === 'function'
? props.alert.clear()
: null
? props.alert.clear()
: null
)
"
>
@ -140,6 +140,7 @@
emit('expand', expanded, record)
}
"
@resizeColumn="handleResizeColumn"
:rowClassName="
(record, index) => (data.localSettings.rowClassNameSwitch ? ((index + 1) % 2 == 0 ? 'odd' : '') : null)
"
@ -283,6 +284,11 @@
}
)
//
const handleResizeColumn = (w, col) => {
col.width = w
}
// props
const renderTableProps = ref([])
//
@ -569,7 +575,7 @@
size: data.customSize, // sizea-tablecompSize
columns: data.columnsSetting.filter((value) => value.checked === undefined || value.checked),
...data.localSettings,
scroll: {x: 100, y: 1000}
scroll: { x: 100 }
}
// undefined null tableprops
renderTableProps.value = Object.entries(renderProps).reduce((x, [y, z]) => (z == null ? x : ((x[y] = z), x)), {})
@ -638,20 +644,7 @@
})
onMounted(() => {
init()
window.addEventListener('resize', () => {
console.log('屏幕发生变换')
})
})
onBeforeUnmount(() => {
window.removeEventListener('resize', () => {
console.log('屏幕发生变换')
});
});
</script>
<style lang="less" scoped>
.s-table-tool {

View File

0
src/store/search.js 100755 → 100644
View File

View File

@ -9,6 +9,7 @@
* 6.若您的项目无法满足以上几点需要更多功能代码获取Snowy商业授权许可请在官网购买授权地址为 https://www.xiaonuo.vip
*/
export default (error) => {
console.log(error)
// 过滤HTTP请求错误
if (error.code) {
return false

View File

@ -1,10 +0,0 @@
export const unitGroupColumns = [
{
title: '名称',
dataIndex: 'name'
},
{
title: '状态',
dataIndex: 'state'
},
]

View File

@ -1,29 +1,102 @@
<template>
<div></div>
<a-page-header style="padding: 10px; font-size: 20px" @back="handleBack">
<template #extra>
<a-button key="1" type="primary" @click="onSubmit"></a-button>
</template>
<template #title>
<span style="font-size: 18px">新增</span>
</template>
</a-page-header>
<a-card :bordered="false" title="基本信息">
<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical">
<a-row :gutter="16">
<a-col :span="6">
<a-form-item label="单位组:" name="name">
<a-input v-model:value="formData.name" placeholder="请输入名称" allow-clear />
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="编码:" name="number">
<a-input v-model:value="formData.number" placeholder="请输入编码" allow-clear />
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="名称:" name="name">
<a-input v-model:value="formData.name" placeholder="请输入名称" allow-clear />
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="可用状态:" name="code">
<a-select
v-model:value="formData.code"
placeholder="请选择可用状态"
:options="tool.dictList('COMMON_STATUS')"
/>
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="换算率:" name="rate">
<a-input v-model:value="formData.rate" placeholder="请输入换算率" allow-clear />
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="是否基本单位:" name="isBase">
<a-select
v-model:value="formData.code"
placeholder="请选择是否基本单位"
:options="tool.dictList('COMMON_STATUS')"
/>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="备注:" name="remarks">
<a-textarea v-model:value="formData.remarks" placeholder="请输入备注" allow-clear />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-card>
</template>
<script setup>
// const props = defineProps({})
<script setup name="sysUnitForm">
import tool from '@/utils/tool'
import { cloneDeep } from 'lodash-es'
import { required } from '@/utils/formRules'
import useTabs from '@/utils/useTabs'
import router from '@/router'
//
const visible = ref(false)
const emit = defineEmits({ successful: null })
const formRef = ref()
//
const formData = ref({})
const submitLoading = ref(false)
const stateOptions = ref([])
const isBaseOptions = ref([])
// const emit = defineEmits()
//
onMounted(() => {
console.log('Component mounted')
// TODO: Add your onMounted code here
})
onUpdated(() => {
console.log('Component updated')
// TODO: Add your onUpdated code here
})
onUnmounted(() => {
console.log('Component unmounted')
// TODO: Add your onUnmounted code here
})
// watch(() => {}, () => {})
//
const formRules = {
name: [required('请输入名称')],
unitGroupId: [required('请输入单位组id')]
}
//
const onSubmit = () => {
formRef.value.validate().then(() => {
submitLoading.value = true
const formDataParam = cloneDeep(formData.value)
sysUnitApi
.sysUnitSubmitForm(formDataParam, formDataParam.id)
.then(() => {
emit('successful')
})
.finally(() => {
submitLoading.value = false
})
})
}
//
const handleBack = () => {
router.go(-1)
useTabs.close()
}
</script>
<style scoped></style>

View File

@ -1,26 +0,0 @@
export const SearchFields = [
{ label: '名称', name: 'name', type: 'input', placeholder: '请输入名称' },
{
label: '状态',
name: 'state',
type: 'select',
placeholder: '请选择状态',
options: [
{ label: 'Active', value: 'active' },
{ label: 'Inactive', value: 'inactive' }
]
},
{ label: '编码', name: 'number', type: 'input', placeholder: '请输入编码' },
{
label: '是否基本单位',
name: 'isBase',
type: 'select',
placeholder: '请选择是否基本单位',
options: [
{ label: '是', value: true },
{ label: '否', value: false }
],
advanced: true
},
{ label: '单位组id', name: 'unitGroupId', type: 'input', placeholder: '请输入单位组id', advanced: true }
]

View File

@ -1,50 +1,98 @@
<template>
<search-form :fields="SearchFields" @search="handleSearch" @rest="reset"></search-form>
<a-card :bordered="false">
<a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
<a-row :gutter="24">
<a-col :span="6">
<a-form-item label="名称" name="name">
<a-input v-model:value="searchFormState.name" placeholder="请输入名称" />
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="状态" name="state">
<a-select v-model:value="searchFormState.state" placeholder="请选择状态" :options="stateOptions" />
</a-form-item>
</a-col>
<a-col :span="6">
<a-form-item label="编码" name="number">
<a-input v-model:value="searchFormState.number" placeholder="请输入编码" />
</a-form-item>
</a-col>
<a-col :span="6" v-show="advanced">
<a-form-item label="是否基本单位" name="isBase">
<a-select
v-model:value="searchFormState.isBase"
placeholder="请选择是否基本单位"
:options="isBaseOptions"
/>
</a-form-item>
</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-button type="primary" @click="tableRef.refresh()"></a-button>
<a-button style="margin: 0 8px" @click="reset"></a-button>
<a @click="toggleAdvanced" style="margin-left: 8px">
{{ advanced ? '收起' : '展开' }}
<component :is="advanced ? 'up-outlined' : 'down-outlined'" />
</a>
</a-col>
</a-row>
</a-form>
</a-card>
<a-card class="mt-4">
<a-card class="mt-4" :border="false">
<a-row :gutter="20">
<a-col :span="8">
<s-table
:alert="false"
ref="unitTableRef"
:columns="unitGroupColumns"
:data="loadData"
:data="loadGroupsData"
bordered
:row-key="(record) => record.id"
:tool-config="{
plus: true,
edit: true,
delete: true,
refresh: true,
height: true,
columnSetting: true,
striped: false
}"
:tool-config="unitGroupToolConfig"
:row-selection="options.rowSelection"
@plusRowData="handlePlusRowData"
@editRowData="handleEditRowData"
@deleteRowData="handleDeleteRowData"
>
<template #operator class="table-operator">
<a-space>
<span>单位组</span>
</a-space>
<span>单位组</span>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.dataIndex === 'state'">
{{ $TOOL.dictTypeData('COMMON_STATUS', record.state) }}
</template>
<template v-if="column.dataIndex === 'isBase'">
{{ $TOOL.dictTypeData('YES_NO', record.isBase) }}
</template>
</template>
</s-table>
</a-col>
<a-col :span="16">
<s-table
ref="tableRef"
:columns="columns"
ref="unitGroupTableRef"
:columns="unitColumns"
:data="loadData"
:alert="options.alert.show"
bordered
:row-key="(record) => record.id"
:tool-config="toolConfig"
:tool-config="unitToolConfig"
:row-selection="options.rowSelection"
>
<template #operator class="table-operator">
<a-space>
<a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('sysUnitAdd')">
<a-button
type="primary"
@click="
navigateTo('/basicData/unit/detail', {
type: 'ADD'
})
"
v-if="hasPerm('sysUnitAdd')"
>
<template #icon><plus-outlined /></template>
新增
</a-button>
@ -76,66 +124,47 @@
</a-col>
</a-row>
</a-card>
<!-- <Form ref="formRef" @successful="tableRef.refresh()" />-->
<unit-group-form ref="UnitGroupFormRef"></unit-group-form>
</template>
<script setup name="sysunit">
import tool from '@/utils/tool'
import { cloneDeep } from 'lodash-es'
import sysUnitApi from '@/api/baseData/unit/unitApi'
import { unitGroupColumns } from '@/views/basicData/unit/columns/unitGroupColumns'
import { SearchFields } from '@/views/basicData/unit/formData/SearchForm'
import { useNavigation } from '@/hook/useNavigation'
import { unitColumns, unitGroupColumns } from '@/views/basicData/unit/columns/unitColumns'
import UnitGroupForm from '@/views/basicData/unit/detail/UnitGroupForm.vue'
// import Form from './form.vue'
import sysUnitApi from '@/api/base/unit/unitApi'
import sysUnitGroupsApi from '@/api/base/unit/unitGroupsApi'
const searchFormState = ref({})
const searchFormRef = ref()
const tableRef = ref()
const formRef = ref()
const toolConfig = {
const UnitGroupFormRef = ref()
const unitTableRef = ref()
const unitToolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
const unitGroupTableRef = ref()
const unitGroupToolConfig = {
refresh: true,
height: true,
columnSetting: true,
striped: false
striped: false,
plus: true,
edit: true,
delete: true
}
//
const advanced = ref(false)
const toggleAdvanced = () => {
advanced.value = !advanced.value
}
const columns = [
{
title: '名称',
dataIndex: 'name'
},
{
title: '状态',
dataIndex: 'state'
},
{
title: '编码',
dataIndex: 'number'
},
{
title: '换算率',
dataIndex: 'rate'
},
{
title: '是否基本单位',
dataIndex: 'isBase'
},
{
title: '精度',
dataIndex: 'precision'
},
{
title: '单位组id',
dataIndex: 'unitGroupId'
}
]
//
if (hasPerm(['sysUnitEdit', 'sysUnitDelete'])) {
columns.push({
unitColumns.push({
title: '操作',
dataIndex: 'action',
align: 'center',
fixed: 'right',
width: 150
})
}
@ -162,8 +191,11 @@
})
}
//
const handleSearch = () => {}
const loadGroupsData = (parameter) => {
return sysUnitGroupsApi.sysUnitGroupPage(Object.assign(parameter)).then((data) => {
return data
})
}
//
const reset = () => {
searchFormRef.value.resetFields()
@ -189,13 +221,16 @@
const stateOptions = tool.dictList('COMMON_STATUS')
const isBaseOptions = tool.dictList('YES_NO')
// //
//
const { navigateTo } = useNavigation()
//
const handlePlusRowData = () => {
formRef.value.onOpen()
UnitGroupFormRef.value.onOpen()
}
const handleEditRowData = () => {
formRef.value.onOpen()
UnitGroupFormRef.value.onOpen()
}
const handleDeleteRowData = () => {}