Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qr-consistency-vue3
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘怀志
qr-consistency-vue3
Commits
26f939c1
Commit
26f939c1
authored
Apr 15, 2025
by
Mr.Tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增制造商、生产厂数据字典 及下拉菜单显示 搜索功能bug修复
parent
f3e65752
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
384 additions
and
35 deletions
+384
-35
businessunit.js
src/api/system/basicdata/businessunit.js
+44
-0
manufacturer.js
src/api/system/basicdata/manufacturer.js
+0
-6
factory.js
src/api/system/factory.js
+8
-0
index.vue
src/views/system/basicdata/businessunit/index.vue
+278
-0
index.vue
src/views/system/basicdata/manufacturer/index.vue
+54
-29
No files found.
src/api/system/basicdata/businessunit.js
0 → 100644
View file @
26f939c1
import
request
from
'@/utils/request'
// 查询事业部列表
export
function
listUnit
(
query
)
{
return
request
({
url
:
'/control/unit/list'
,
method
:
'get'
,
params
:
query
})
}
// 查询事业部详细
export
function
getUnit
(
id
)
{
return
request
({
url
:
'/control/unit/'
+
id
,
method
:
'get'
})
}
// 新增事业部
export
function
addUnit
(
data
)
{
return
request
({
url
:
'/control/unit'
,
method
:
'post'
,
data
:
data
})
}
// 修改事业部
export
function
updateUnit
(
data
)
{
return
request
({
url
:
'/control/unit'
,
method
:
'put'
,
data
:
data
})
}
// 删除事业部
export
function
delUnit
(
id
)
{
return
request
({
url
:
'/control/unit/'
+
id
,
method
:
'delete'
})
}
src/api/system/basicdata/manufacturer.js
View file @
26f939c1
...
...
@@ -42,9 +42,3 @@ export function delManufacturer(id) {
method
:
'delete'
})
}
export
function
getfactory
(){
return
request
({
url
:
'/control/manufacturer/factory'
,
method
:
'get'
})
}
src/api/system/factory.js
View file @
26f939c1
...
...
@@ -24,3 +24,11 @@ export function updateFactory(query) {
data
:
query
,
})
}
export
function
getAllFactoryName
(
query
)
{
return
request
({
url
:
'/control/systemFactory/getAllFactoryName'
,
method
:
'get'
,
data
:
query
,
})
}
src/views/system/basicdata/businessunit/index.vue
0 → 100644
View file @
26f939c1
<
template
>
<div
class=
"app-container"
>
<el-row
:gutter=
"10"
class=
"mb8"
>
<el-col
:span=
"1.5"
>
<el-button
type=
"primary"
plain
@
click=
"handleAdd"
v-hasPermi=
"['control:unit:add']"
>
新建
</el-button>
</el-col>
</el-row>
<el-table
v-loading=
"loading"
:data=
"unitList"
@
selection-change=
"handleSelectionChange"
border
>
<el-table-column
label=
"序号"
align=
"center"
width=
"80"
>
<template
#
default=
"scope"
>
{{
scope
.
$index
+
1
}}
</
template
>
</el-table-column>
<el-table-column
label=
"事业部"
align=
"center"
prop=
"businessUnitName"
width=
"100"
/>
<el-table-column
prop=
"manufacturingFactory"
label=
"制造工厂"
width=
"800"
>
<
template
#
default=
"{ row }"
>
{{
formatFactoryDisplay
(
row
.
manufacturingFactory
)
}}
</
template
>
</el-table-column>
<el-table-column
label=
"备注"
align=
"center"
prop=
"remark"
width=
"200"
/>
<el-table-column
label=
"更新时间"
align=
"center"
prop=
"updateTime"
width=
"200"
/>
<el-table-column
label=
"更新人"
align=
"center"
prop=
"updateName"
width=
"150"
/>
<el-table-column
label=
"操作"
align=
"center"
class-name=
"small-padding fixed-width"
>
<
template
#
default=
"scope"
>
<el-button
link
type=
"primary"
@
click=
"handleUpdate(scope.row)"
v-hasPermi=
"['control:unit:edit']"
>
编辑
</el-button>
<!--
<el-button
link
type=
"primary"
icon=
"Delete"
@
click=
"handleDelete(scope.row)"
v-hasPermi=
"['control:unit:remove']"
>
删除
</el-button>
-->
</
template
>
</el-table-column>
</el-table>
<pagination
v-show=
"total>0"
:total=
"total"
v-model:page=
"queryParams.pageNum"
v-model:limit=
"queryParams.pageSize"
@
pagination=
"getList"
/>
<!-- 添加或修改事业部对话框 -->
<el-dialog
:title=
"title"
v-model=
"open"
width=
"500px"
append-to-body
>
<el-form
ref=
"unitRef"
:model=
"form"
:rules=
"rules"
label-width=
"130px"
>
<el-form-item
label=
"事业部名称"
prop=
"businessUnitName"
>
<el-input
v-model=
"form.businessUnitName"
placeholder=
"请输入事业部名称"
/>
</el-form-item>
<el-form-item
label=
"制造工厂"
prop=
"manufacturingFactory"
>
<el-checkbox-group
v-model=
"selectedFactories"
>
<div
style=
"display: flex; flex-wrap: wrap;"
>
<div
v-for=
"(factory, index) in allFactories"
:key=
"index"
style=
"width: 33%; margin-bottom: 10px;"
>
<el-checkbox
:label=
"factory"
>
{{ factory }}
</el-checkbox>
</div>
</div>
</el-checkbox-group>
</el-form-item>
<el-form-item
label=
"备注"
prop=
"remark"
>
<el-input
v-model=
"form.remark"
placeholder=
"请输入备注"
/>
</el-form-item>
</el-form>
<
template
#
footer
>
<div
class=
"dialog-footer"
>
<el-button
type=
"primary"
@
click=
"submitForm"
>
确 定
</el-button>
<el-button
@
click=
"cancel"
>
取 消
</el-button>
</div>
</
template
>
</el-dialog>
</div>
</template>
<
script
setup
name=
"Unit"
>
import
{
listUnit
,
getUnit
,
delUnit
,
addUnit
,
updateUnit
}
from
"@/api/system/basicdata/businessunit"
;
import
{
getAllFactoryName
}
from
"@/api/system/factory"
;
import
{
formatFactories
}
from
'@/utils/factoryFormatter'
;
import
{
ref
,
toRefs
,
watch
}
from
'vue'
const
{
proxy
}
=
getCurrentInstance
();
const
unitList
=
ref
([]);
const
open
=
ref
(
false
);
const
loading
=
ref
(
true
);
const
showSearch
=
ref
(
true
);
const
ids
=
ref
([]);
const
single
=
ref
(
true
);
const
multiple
=
ref
(
true
);
const
total
=
ref
(
0
);
const
title
=
ref
(
""
);
const
formatFactoryDisplay
=
(
factoryJson
)
=>
{
return
formatFactories
(
factoryJson
);
};
// 选中的工厂列表
const
selectedFactories
=
ref
([]);
// 监听表单数据变化,初始化选中的工厂
const
data
=
reactive
({
form
:
{
businessUnitName
:
""
,
manufacturingFactory
:
{},
// 或 '{}'(根据后端需求)
remark
:
""
,
},
queryParams
:
{
pageNum
:
1
,
pageSize
:
10
,
businessUnitName
:
null
,
manufacturingFactory
:
null
},
rules
:
{
createBy
:
[
{
required
:
true
,
message
:
"创建人ID不能为空"
,
trigger
:
"blur"
}
],
createTime
:
[
{
required
:
true
,
message
:
"创建时间不能为空"
,
trigger
:
"blur"
}
],
updateBy
:
[
{
required
:
true
,
message
:
"更新人ID不能为空"
,
trigger
:
"blur"
}
],
updateTime
:
[
{
required
:
true
,
message
:
"更新时间不能为空"
,
trigger
:
"blur"
}
],
delFlag
:
[
{
required
:
true
,
message
:
"删除状态,0表示未删除,1表示已删除不能为空"
,
trigger
:
"blur"
}
],
businessUnitName
:
[
{
required
:
true
,
message
:
"事业部名称不能为空"
,
trigger
:
"blur"
}
],
manufacturingFactory
:
[
{
required
:
true
,
message
:
"所属制造工厂,以JSON数组形式存储不能为空"
,
trigger
:
"blur"
}
]
}
});
const
{
queryParams
,
form
,
rules
}
=
toRefs
(
data
);
// 所有可选的工厂列表
const
allFactories
=
ref
([])
// 获取工厂数据的方法
const
fetchFactories
=
async
()
=>
{
try
{
const
response
=
await
getAllFactoryName
()
// 提取factoryName字段
allFactories
.
value
=
response
.
data
.
map
(
item
=>
item
.
factoryName
)
}
catch
(
error
)
{
console
.
error
(
'获取工厂列表失败:'
,
error
)
}
}
watch
(()
=>
form
.
value
.
manufacturingFactory
,
(
newVal
)
=>
{
try
{
const
factoryObj
=
JSON
.
parse
(
newVal
||
'{}'
);
selectedFactories
.
value
=
Object
.
values
(
factoryObj
);
}
catch
(
e
)
{
selectedFactories
.
value
=
[];
}
},
{
immediate
:
true
});
// 监听选中的工厂变化,更新表单数据
watch
(
selectedFactories
,
(
newVal
)
=>
{
const
factoryObj
=
{};
newVal
.
forEach
((
item
,
index
)
=>
{
factoryObj
[
index
]
=
item
;
});
form
.
value
.
manufacturingFactory
=
JSON
.
stringify
(
factoryObj
);
},
{
deep
:
true
});
/** 查询事业部列表 */
function
getList
()
{
loading
.
value
=
true
;
listUnit
(
queryParams
.
value
).
then
(
response
=>
{
unitList
.
value
=
response
.
rows
;
total
.
value
=
response
.
total
;
loading
.
value
=
false
;
});
}
// 取消按钮
function
cancel
()
{
open
.
value
=
false
;
reset
();
}
// 表单重置
function
reset
()
{
form
.
value
=
{
id
:
null
,
createBy
:
null
,
createTime
:
null
,
updateBy
:
null
,
updateTime
:
null
,
remark
:
null
,
delFlag
:
null
,
businessUnitName
:
null
,
manufacturingFactory
:
null
};
proxy
.
resetForm
(
"unitRef"
);
}
/** 搜索按钮操作 */
function
handleQuery
()
{
queryParams
.
value
.
pageNum
=
1
;
getList
();
}
/** 重置按钮操作 */
function
resetQuery
()
{
proxy
.
resetForm
(
"queryRef"
);
handleQuery
();
}
// 多选框选中数据
function
handleSelectionChange
(
selection
)
{
ids
.
value
=
selection
.
map
(
item
=>
item
.
id
);
single
.
value
=
selection
.
length
!=
1
;
multiple
.
value
=
!
selection
.
length
;
}
/** 新增按钮操作 */
function
handleAdd
()
{
reset
();
open
.
value
=
true
;
title
.
value
=
"新增"
;
}
/** 修改按钮操作 */
function
handleUpdate
(
row
)
{
reset
();
const
_id
=
row
.
id
||
ids
.
value
getUnit
(
_id
).
then
(
response
=>
{
form
.
value
=
response
.
data
;
open
.
value
=
true
;
title
.
value
=
"修改事业部"
;
});
}
/** 提交按钮 */
function
submitForm
()
{
proxy
.
$refs
[
"unitRef"
].
validate
(
valid
=>
{
if
(
valid
)
{
if
(
form
.
value
.
id
!=
null
)
{
updateUnit
(
form
.
value
).
then
(
response
=>
{
proxy
.
$modal
.
msgSuccess
(
"修改成功"
);
open
.
value
=
false
;
getList
();
});
}
else
{
addUnit
(
form
.
value
).
then
(
response
=>
{
proxy
.
$modal
.
msgSuccess
(
"新增成功"
);
open
.
value
=
false
;
getList
();
});
}
}
});
}
/** 删除按钮操作 */
function
handleDelete
(
row
)
{
const
_ids
=
row
.
id
||
ids
.
value
;
proxy
.
$modal
.
confirm
(
'是否确认删除事业部编号为"'
+
_ids
+
'"的数据项?'
).
then
(
function
()
{
return
delUnit
(
_ids
);
}).
then
(()
=>
{
getList
();
proxy
.
$modal
.
msgSuccess
(
"删除成功"
);
}).
catch
(()
=>
{});
}
/** 导出按钮操作 */
function
handleExport
()
{
proxy
.
download
(
'control/unit/export'
,
{
...
queryParams
.
value
},
`unit_
${
new
Date
().
getTime
()}
.xlsx`
)
}
onMounted
(()
=>
{
fetchFactories
();
});
getList
();
</
script
>
src/views/system/basicdata/index.vue
→
src/views/system/basicdata/
manufacturer/
index.vue
View file @
26f939c1
...
...
@@ -11,20 +11,34 @@
/>
</el-form-item>
<el-form-item
label=
"制造商"
prop=
"manufacturer"
>
<el-
inpu
t
<el-
selec
t
v-model=
"queryParams.manufacturer"
placeholder=
"请选择"
clearable
@
keyup
.
enter=
"handleQuery"
/>
style=
"width: 240px"
>
<el-option
v-for=
"dict in sys_manufacture"
:key=
"dict.value"
:label=
"dict.label"
:value=
"dict.value"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"生产厂"
prop=
"productionFactory"
>
<el-
inpu
t
<el-
selec
t
v-model=
"queryParams.productionFactory"
placeholder=
"请选择"
clearable
@
keyup
.
enter=
"handleQuery"
/>
style=
"width: 320px"
>
<el-option
v-for=
"dict in production_factory"
:key=
"dict.value"
:label=
"dict.label"
:value=
"dict.value"
/>
</el-select>
</el-form-item>
<el-form-item
label=
"生产地址"
prop=
"productionAddress"
>
<el-input
...
...
@@ -65,7 +79,11 @@
@
selection-change=
"handleSelectionChange"
style=
"width: 100%"
>
<!-- 固定左侧列 -->
<el-table-column
label=
"序号"
align=
"center"
prop=
"id"
width=
"80"
fixed=
"left"
/>
<el-table-column
label=
"序号"
align=
"center"
width=
"80"
fixed=
"left"
>
<template
#
default=
"scope"
>
{{
scope
.
$index
+
1
}}
</
template
>
</el-table-column>
<el-table-column
label=
"工厂编号"
align=
"center"
prop=
"factoryCode"
width=
"180"
fixed=
"left"
/>
<el-table-column
label=
"制造商"
align=
"center"
prop=
"manufacturer"
width=
"210"
fixed=
"left"
/>
<el-table-column
label=
"生产厂"
align=
"center"
prop=
"productionFactory"
width=
"300"
fixed=
"left"
/>
...
...
@@ -81,7 +99,7 @@
<el-table-column
label=
"生产厂名称(英文)"
align=
"center"
prop=
"productionFactoryEn"
width=
"200"
/>
<el-table-column
label=
"生产地址(英文)"
align=
"center"
prop=
"productionAddressEn"
width=
"250"
/>
<el-table-column
label=
"更新时间"
align=
"center"
prop=
"updateTime"
width=
"180"
/>
<el-table-column
label=
"更新人"
align=
"center"
prop=
"update
By
"
width=
"120"
/>
<el-table-column
label=
"更新人"
align=
"center"
prop=
"update
Name
"
width=
"120"
/>
<!-- 固定右侧操作列 -->
<el-table-column
label=
"操作"
align=
"center"
class-name=
"small-padding fixed-width"
width=
"150"
fixed=
"right"
>
...
...
@@ -146,10 +164,13 @@
<
script
setup
name=
"Manufacturer"
>
import
{
reactive
,
ref
,
computed
,
watch
,
toRefs
}
from
'vue'
import
{
listManufacturer
,
getManufacturer
,
delManufacturer
,
addManufacturer
,
updateManufacturer
,
getfactory
}
from
"@/api/system/basicdata/manufacturer"
;
import
{
listManufacturer
,
getManufacturer
,
delManufacturer
,
addManufacturer
,
updateManufacturer
}
from
"@/api/system/basicdata/manufacturer"
;
import
{
getAllFactoryName
}
from
"@/api/system/factory"
;
import
{
formatFactories
}
from
'@/utils/factoryFormatter'
;
const
{
proxy
}
=
getCurrentInstance
();
const
{
sys_manufacture
,
production_factory
}
=
proxy
.
useDict
(
'sys_manufacture'
,
'production_factory'
)
const
manufacturerList
=
ref
([]);
const
open
=
ref
(
false
);
const
loading
=
ref
(
true
);
const
showSearch
=
ref
(
true
);
...
...
@@ -158,11 +179,8 @@ const single = ref(true);
const
multiple
=
ref
(
true
);
const
total
=
ref
(
0
);
const
title
=
ref
(
""
);
const
initialFactoryData
=
ref
({})
// 从API获取的初始数据
const
manufacturerList
=
ref
([
]);
const
currentManufacturer
=
ref
(
null
);
const
formatFactoryDisplay
=
(
factoryJson
)
=>
{
return
formatFactories
(
factoryJson
);
...
...
@@ -190,14 +208,14 @@ const data = reactive({
queryParams
:
{
pageNum
:
1
,
pageSize
:
10
,
factoryCode
:
undefined
,
// 或 ''
manufacturer
:
undefined
,
productionFactory
:
undefined
,
productionAddress
:
undefined
,
manufacturerEn
:
undefined
,
productionFactoryEn
:
undefined
,
productionAddressEn
:
undefined
,
manufacturingFactory
:
undefined
,
factoryCode
:
null
,
// 或 ''
manufacturer
:
null
,
productionFactory
:
null
,
productionAddress
:
null
,
manufacturerEn
:
null
,
productionFactoryEn
:
null
,
productionAddressEn
:
null
,
manufacturingFactory
:
null
,
},
// 验证规则(仅保留用户需输入的字段)
...
...
@@ -223,13 +241,18 @@ const data = reactive({
const
{
queryParams
,
form
,
rules
}
=
toRefs
(
data
);
// 所有可选的工厂列表
const
allFactories
=
ref
([
'整车二工厂'
,
'整车三工厂'
,
'整车四工厂'
,
'智造一工厂'
,
'智造二工厂'
,
'大连工厂'
,
'青岛工厂'
,
'鄂尔多斯工厂'
,
'开封工厂'
,
'城南工厂'
,
'城北工厂'
,
'齐河工厂'
,
'石家庄工厂'
]);
const
allFactories
=
ref
([])
// 获取工厂数据的方法
const
fetchFactories
=
async
()
=>
{
try
{
const
response
=
await
getAllFactoryName
()
// 提取factoryName字段
allFactories
.
value
=
response
.
data
.
map
(
item
=>
item
.
factoryName
)
}
catch
(
error
)
{
console
.
error
(
'获取工厂列表失败:'
,
error
)
}
}
watch
(()
=>
form
.
value
.
manufacturingFactory
,
(
newVal
)
=>
{
try
{
const
factoryObj
=
JSON
.
parse
(
newVal
||
'{}'
);
...
...
@@ -362,6 +385,8 @@ function handleExport() {
...
queryParams
.
value
},
`manufacturer_
${
new
Date
().
getTime
()}
.xlsx`
)
}
onMounted
(()
=>
{
fetchFactories
();
});
getList
();
</
script
>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment