Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
topsun-baoshen-excel
Project
Project
Details
Activity
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
何远江
topsun-baoshen-excel
Commits
e9b8139a
Commit
e9b8139a
authored
Apr 01, 2024
by
何远江
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
改变变量字段选择的方式。修改为输入方式
parent
9d8b5d3a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
73 additions
and
68 deletions
+73
-68
excel.ts
src/stores/excel.ts
+18
-27
OrderChange.vue
src/views/order/orderChange/OrderChange.vue
+16
-2
ConfigFormItem.vue
src/views/order/orderChange/components/ConfigFormItem.vue
+39
-21
configForm.vue
src/views/order/orderChange/components/configForm.vue
+0
-18
No files found.
src/stores/excel.ts
View file @
e9b8139a
import
type
{
Recordable
}
from
'@/types/global'
import
{
defineStore
}
from
'pinia'
import
{
defineStore
}
from
'pinia'
type
StoreState
=
{
type
StoreState
=
{
...
@@ -89,55 +90,48 @@ export const useExcelStore = defineStore('excelStore', {
...
@@ -89,55 +90,48 @@ export const useExcelStore = defineStore('excelStore', {
}
}
})
})
type
ExcelChangeStore
=
{
allMapConfigs
:
Recordable
scriptList
:
Recordable
[]
orderFieldList
:
Recordable
[]
usedFieldList
:
Recordable
[]
}
export
const
useExcelChangeStore
=
defineStore
(
'excelChangeStore'
,
{
export
const
useExcelChangeStore
=
defineStore
(
'excelChangeStore'
,
{
state
:
()
=>
({
state
:
()
:
ExcelChangeStore
=>
({
allMapConfigs
:
{},
// 缓存当前这条数据的所有映射关系
allMapConfigs
:
{},
// 缓存当前这条数据的所有映射关系
scriptList
:
[],
// 脚本
scriptList
:
[],
// 脚本
orderFieldList
:
[],
// 订单字段
orderFieldList
:
[],
// 订单字段
variableField
:
[],
// 后端获取的变量字段
usedFieldList
:
[]
// 当前编辑column使用过的映射字段
usedFieldList
:
[]
// 当前编辑column使用过的映射字段
}),
}),
getters
:
{
getters
:
{
getAllMapConfigs
():
any
{
getAllMapConfigs
():
Recordable
{
return
this
.
allMapConfigs
return
this
.
allMapConfigs
},
},
getScriptList
():
any
{
getScriptList
():
any
{
return
this
.
scriptList
return
this
.
scriptList
},
},
getEffectConfigs
():
any
[]
{
getEffectConfigs
():
any
[]
{
// 获取已经使用的config,用于禁用已经选择过的映射字段
const
currenttitle
=
this
.
usedFieldList
[
0
]?.
title
||
''
const
currenttitle
=
this
.
usedFieldList
[
0
]?.
title
||
''
const
res
:
any
=
[...
this
.
usedFieldList
]
const
res
:
any
=
[...
this
.
usedFieldList
]
for
(
const
key
in
this
.
allMapConfigs
)
{
for
(
const
key
in
this
.
allMapConfigs
)
{
if
(
key
!=
currenttitle
)
{
if
(
key
!=
currenttitle
)
{
if
(
this
.
allMapConfigs
[
key
].
orderFiledConfs
.
length
)
{
if
(
this
.
allMapConfigs
[
key
].
orderFiledConfs
.
length
)
{
res
.
push
(...
this
.
allMapConfigs
[
key
].
orderFiledConfs
)
res
.
push
(...
this
.
allMapConfigs
[
key
].
orderFiledConfs
.
filter
((
item
)
=>
item
.
variable
)
)
}
}
}
}
}
}
return
res
.
map
((
item
)
=>
item
.
mapField
)
return
res
.
map
((
item
)
=>
item
.
mapField
)
},
},
getAllFields
():
any
{
getAllFields
():
any
{
return
[
return
this
.
orderFieldList
.
map
((
item
)
=>
{
{
label
:
'普通字段'
,
options
:
this
.
orderFieldList
.
map
((
item
)
=>
{
this
.
getEffectConfigs
.
includes
(
item
.
filedName
)
?
(
item
.
disabled
=
true
)
:
(
item
.
disabled
=
false
)
return
item
})
},
{
label
:
'变量字段'
,
options
:
this
.
variableField
.
map
((
item
)
=>
{
this
.
getEffectConfigs
.
includes
(
item
.
filedName
)
this
.
getEffectConfigs
.
includes
(
item
.
filedName
)
?
(
item
.
disabled
=
true
)
?
(
item
.
disabled
=
true
)
:
(
item
.
disabled
=
false
)
:
(
item
.
disabled
=
false
)
return
item
return
item
})
})
}
}
]
}
},
},
actions
:
{
actions
:
{
setAllMapConfigs
(
config
:
any
)
{
setAllMapConfigs
(
config
:
any
)
{
...
@@ -152,9 +146,6 @@ export const useExcelChangeStore = defineStore('excelChangeStore', {
...
@@ -152,9 +146,6 @@ export const useExcelChangeStore = defineStore('excelChangeStore', {
setOrderFieldList
(
list
:
any
)
{
setOrderFieldList
(
list
:
any
)
{
this
.
orderFieldList
=
list
this
.
orderFieldList
=
list
},
},
setVariableField
(
list
:
any
)
{
this
.
variableField
=
list
},
setUsedFieldList
(
list
:
any
)
{
setUsedFieldList
(
list
:
any
)
{
this
.
usedFieldList
=
list
this
.
usedFieldList
=
list
}
}
...
...
src/views/order/orderChange/OrderChange.vue
View file @
e9b8139a
...
@@ -237,7 +237,7 @@ const showPopover = (e: any, title: string) => {
...
@@ -237,7 +237,7 @@ const showPopover = (e: any, title: string) => {
orderFiledConfs
:
[
orderFiledConfs
:
[
{
{
mapField
:
''
,
mapField
:
''
,
orderFiled
:
{}
,
orderFiled
:
null
,
scripts
:
[]
scripts
:
[]
}
}
],
],
...
@@ -259,9 +259,23 @@ watch([detailVisible, popoverVisible], (val) => {
...
@@ -259,9 +259,23 @@ watch([detailVisible, popoverVisible], (val) => {
/** 确认字段映射及脚本的配置 */
/** 确认字段映射及脚本的配置 */
const
confirmConfig
=
(
configList
:
any
)
=>
{
const
confirmConfig
=
(
configList
:
any
)
=>
{
// 便利一下是否有变量字段
excelChangeStore
.
setSingleFieldMap
({
excelChangeStore
.
setSingleFieldMap
({
...
currentColConf
,
...
currentColConf
,
orderFiledConfs
:
cloneDeep
(
configList
.
filter
((
v
)
=>
!!
v
.
mapField
))
orderFiledConfs
:
cloneDeep
(
configList
.
map
((
item
)
=>
{
if
(
item
.
mapField
&&
item
?.
isVariable
)
{
item
.
orderFiled
=
{
fliedTitle
:
item
.
mapField
,
filedName
:
item
.
mapField
,
variable
:
true
}
}
return
item
})
.
filter
((
v
)
=>
!!
v
.
mapField
)
)
})
})
// 关闭popover
// 关闭popover
popoverVisible
.
value
=
false
popoverVisible
.
value
=
false
...
...
src/views/order/orderChange/components/ConfigFormItem.vue
View file @
e9b8139a
...
@@ -3,24 +3,31 @@
...
@@ -3,24 +3,31 @@
<el-col>
<el-col>
<el-form-item
label=
"对应字段"
prop=
"mapField"
>
<el-form-item
label=
"对应字段"
prop=
"mapField"
>
<el-select
<el-select
v-if=
"!isVariable"
v-model=
"item.mapField"
v-model=
"item.mapField"
style=
"width:
22
0px"
style=
"width:
16
0px"
filterable
filterable
placeholder=
"请选择"
placeholder=
"请选择"
@
change=
"mapFieldChange"
@
change=
"mapFieldChange"
clearable
clearable
>
>
<el-option-group
v-for=
"group in getAllFields"
:key=
"group.label"
:label=
"group.label"
>
<el-option
<el-option
v-for=
"item in group.option
s"
v-for=
"item in getAllField
s"
:key=
"item.filedName"
:key=
"item.filedName"
:label=
"item.fliedTitle"
:label=
"item.fliedTitle"
:value=
"item.filedName"
:value=
"item.filedName"
:disabled=
"!!item.disabled"
:disabled=
"!!item.disabled"
/>
/>
</el-option-group>
</el-select>
</el-select>
<el-button
v-if=
"props.index != 0"
circle
type=
"danger"
@
click=
"emits('remove', props.index)"
<el-input
v-else
v-model=
"item.mapField"
style=
"width: 160px"
/>
<el-checkbox
class=
"ml-1"
v-model=
"isVariable"
@
change=
"checkboxChange"
>
是变量
</el-checkbox>
<el-button
class=
"ml-1"
v-if=
"props.index != 0"
plain
circle
type=
"danger"
@
click=
"emits('remove', props.index)"
><el-icon><CircleClose
/></el-icon
><el-icon><CircleClose
/></el-icon
></el-button>
></el-button>
</el-form-item>
</el-form-item>
...
@@ -45,11 +52,11 @@
...
@@ -45,11 +52,11 @@
:label=
"item.srciptName"
:label=
"item.srciptName"
></el-option>
></el-option>
</el-select>
</el-select>
<span>
<span
class=
"ml-1"
>
<el-button
v-if=
"idx == 0"
@
click=
"addScript"
type=
"primary"
circle
<el-button
v-if=
"idx == 0"
@
click=
"addScript"
type=
"primary"
circle
><el-icon><Plus
/></el-icon
><el-icon><Plus
/></el-icon
></el-button>
></el-button>
<el-button
v-if=
"idx != 0"
@
click=
"removeScript(idx)"
type=
"danger"
circle
<el-button
v-if=
"idx != 0"
@
click=
"removeScript(idx)"
type=
"danger"
plain
circle
><el-icon><Minus
/></el-icon
><el-icon><Minus
/></el-icon
></el-button>
></el-button>
</span>
</span>
...
@@ -73,13 +80,15 @@
...
@@ -73,13 +80,15 @@
import
{
useExcelChangeStore
}
from
'@/stores/excel'
import
{
useExcelChangeStore
}
from
'@/stores/excel'
import
{
Plus
,
Minus
,
CircleClose
}
from
'@element-plus/icons-vue'
import
{
Plus
,
Minus
,
CircleClose
}
from
'@element-plus/icons-vue'
import
{
storeToRefs
}
from
'pinia'
import
{
storeToRefs
}
from
'pinia'
import
{
watch
}
from
'vue'
import
{
onMounted
,
ref
,
watch
}
from
'vue'
const
props
=
defineProps
<
{
item
?:
any
;
index
:
number
}
>
()
const
props
=
defineProps
<
{
item
?:
any
;
index
:
number
}
>
()
const
emits
=
defineEmits
([
'remove'
])
const
emits
=
defineEmits
([
'remove'
])
const
excelChangeStore
=
useExcelChangeStore
()
const
excelChangeStore
=
useExcelChangeStore
()
const
{
getAllFields
,
getScriptList
}
=
storeToRefs
(
excelChangeStore
)
const
{
getAllFields
,
getScriptList
}
=
storeToRefs
(
excelChangeStore
)
const
isVariable
=
ref
(
false
)
const
scriptChange
=
(
sitem
,
e
)
=>
{
const
scriptChange
=
(
sitem
,
e
)
=>
{
if
(
e
)
{
if
(
e
)
{
sitem
.
content
=
getScriptList
.
value
.
find
((
item
)
=>
item
.
srciptName
==
e
)?.
scriptContent
sitem
.
content
=
getScriptList
.
value
.
find
((
item
)
=>
item
.
srciptName
==
e
)?.
scriptContent
...
@@ -91,19 +100,23 @@ const scriptChange = (sitem, e) => {
...
@@ -91,19 +100,23 @@ const scriptChange = (sitem, e) => {
const
mapFieldChange
=
(
e
)
=>
{
const
mapFieldChange
=
(
e
)
=>
{
if
(
e
)
{
if
(
e
)
{
getAllFields
.
value
.
some
((
items
)
=>
{
getAllFields
.
value
.
some
((
items
)
=>
{
return
items
.
options
.
some
((
item
)
=>
{
if
(
items
.
filedName
==
e
)
{
if
(
item
.
filedName
==
e
)
{
props
.
item
.
orderFiled
=
items
props
.
item
.
orderFiled
=
item
return
true
return
true
}
}
return
false
return
false
})
})
})
}
else
{
}
else
{
props
.
item
.
orderFiled
=
null
props
.
item
.
orderFiled
=
null
}
}
}
}
const
checkboxChange
=
(
e
)
=>
{
// 设置一个属性
props
.
item
.
isVariable
=
isVariable
.
value
props
.
item
.
mapField
=
''
props
.
item
.
orderFiled
=
null
}
const
removeScript
=
(
index
:
number
)
=>
{
const
removeScript
=
(
index
:
number
)
=>
{
props
.
item
.
scripts
.
splice
(
index
,
1
)
props
.
item
.
scripts
.
splice
(
index
,
1
)
}
}
...
@@ -114,6 +127,11 @@ const addScript = () => {
...
@@ -114,6 +127,11 @@ const addScript = () => {
})
})
}
}
onMounted
(()
=>
{
console
.
log
(
'onmounted'
)
isVariable
.
value
=
!!
props
.
item
.
orderFiled
?.
variable
})
watch
(
watch
(
()
=>
props
.
item
.
mapField
,
()
=>
props
.
item
.
mapField
,
(
val
)
=>
{
(
val
)
=>
{
...
...
src/views/order/orderChange/components/configForm.vue
View file @
e9b8139a
...
@@ -32,14 +32,6 @@ const emits = defineEmits(['cancel', 'confirm'])
...
@@ -32,14 +32,6 @@ const emits = defineEmits(['cancel', 'confirm'])
const
excelChangeStore
=
useExcelChangeStore
()
const
excelChangeStore
=
useExcelChangeStore
()
const
configList
=
ref
<
Recordable
[]
>
([])
const
configList
=
ref
<
Recordable
[]
>
([])
const
getOrderVariableField
=
async
()
=>
{
const
{
data
}
=
await
getVariableField
(
props
.
currentRow
.
excelOrderId
)
if
(
data
.
code
!=
200
)
{
ElMessage
.
warning
(
data
.
message
)
}
excelChangeStore
.
setVariableField
(
data
.
result
||
[])
}
// 添加映射字段表单对象
// 添加映射字段表单对象
const
addFormItem
=
()
=>
{
const
addFormItem
=
()
=>
{
configList
.
value
.
push
({
configList
.
value
.
push
({
...
@@ -62,19 +54,10 @@ const getOrderFields = async () => {
...
@@ -62,19 +54,10 @@ const getOrderFields = async () => {
excelChangeStore
.
setOrderFieldList
(
data
.
result
)
excelChangeStore
.
setOrderFieldList
(
data
.
result
)
}
}
// 监听选中行变化
watch
(
()
=>
props
.
currentRow
.
excelOrderId
,
(
val
)
=>
{
getOrderVariableField
()
},
{
immediate
:
true
}
)
watch
(
watch
(
()
=>
props
.
currentConf
.
title
,
()
=>
props
.
currentConf
.
title
,
(
val
)
=>
{
(
val
)
=>
{
console
.
log
(
'watch--props.currentConf.title'
,
val
,
props
.
currentConf
)
configList
.
value
=
cloneDeep
(
props
.
currentConf
).
orderFiledConfs
.
map
((
item
,
i
)
=>
{
configList
.
value
=
cloneDeep
(
props
.
currentConf
).
orderFiledConfs
.
map
((
item
,
i
)
=>
{
item
.
time
=
Date
.
now
()
+
i
item
.
time
=
Date
.
now
()
+
i
return
item
return
item
...
@@ -88,7 +71,6 @@ watch(
...
@@ -88,7 +71,6 @@ watch(
watch
(
watch
(
configList
,
configList
,
(
val
)
=>
{
(
val
)
=>
{
console
.
log
(
'configList----'
,
val
)
excelChangeStore
.
setUsedFieldList
(
val
)
excelChangeStore
.
setUsedFieldList
(
val
)
},
},
{
deep
:
true
}
{
deep
:
true
}
...
...
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