Commit c223e890 authored by 何远江's avatar 何远江

优化关联

parent 234b9841
...@@ -571,8 +571,10 @@ const confirmConnect = () => { ...@@ -571,8 +571,10 @@ const confirmConnect = () => {
addConnect(list) addConnect(list)
} }
const addConnect = async (list: any) => { const addConnect = async (list: any) => {
const connectFiled = []
const beConnectFiled = []
list.forEach((item: any) => { list.forEach((item: any) => {
currentConnectInfo.connectFiled.push({ connectFiled.push({
title: item.title, title: item.title,
sheet: item.sheet, sheet: item.sheet,
row: item.row, row: item.row,
...@@ -584,7 +586,7 @@ const addConnect = async (list: any) => { ...@@ -584,7 +586,7 @@ const addConnect = async (list: any) => {
script: item.script script: item.script
}) })
currentConnectInfo.beConnectFiled.push({ beConnectFiled.push({
title: item.betitle, title: item.betitle,
sheet: item.besheet, sheet: item.besheet,
row: item.berow, row: item.berow,
...@@ -596,6 +598,8 @@ const addConnect = async (list: any) => { ...@@ -596,6 +598,8 @@ const addConnect = async (list: any) => {
script: item.bescript script: item.bescript
}) })
}) })
currentConnectInfo.beConnectFiled = beConnectFiled
currentConnectInfo.connectFiled = connectFiled
currentConnectInfo.fileId = getFileInfo.value.orderFileId currentConnectInfo.fileId = getFileInfo.value.orderFileId
const { data } = await addExcelAreaConnect(currentConnectInfo) const { data } = await addExcelAreaConnect(currentConnectInfo)
...@@ -606,8 +610,10 @@ const addConnect = async (list: any) => { ...@@ -606,8 +610,10 @@ const addConnect = async (list: any) => {
} }
ElMessage.success('添加成功!') ElMessage.success('添加成功!')
connectVisible.value = false connectVisible.value = false
// 添加成功,重新获取数据
queryConnectList()
// 添加成功 手动更新页面数据 // 添加成功 手动更新页面数据
connectList.value.push(data.result) // connectList.value.push(data.result)
} }
const chooseConnect = (row: any) => { const chooseConnect = (row: any) => {
currentConnectInfo.excelAreaId = row.excelAreaId currentConnectInfo.excelAreaId = row.excelAreaId
...@@ -628,14 +634,21 @@ const beConnectSelectOptions = computed( ...@@ -628,14 +634,21 @@ const beConnectSelectOptions = computed(
) )
watch(connectVisible, (val) => { watch(connectVisible, (val) => {
if (val) { if (val) {
// 编辑重新复制 const titles = areaList.value.find((v: any) => v.excelAreaId == currentConnectInfo.excelAreaId)
?.excelAreaTitle
connectConfigData.value = titles.map((item: any) => {
// 全部列,并且匹配已经绑定的列
if (currentConnectInfo.excelAreaConnectId) { if (currentConnectInfo.excelAreaConnectId) {
// 按照顺序来赋值connectFiled -> beConnectFiled // 按照顺序来赋值connectFiled -> beConnectFiled
const connectFiled = cachConnectEditInfo.value?.connectFiled || [] const connectFiled = cachConnectEditInfo.value?.connectFiled || []
const beConnectFiled = cachConnectEditInfo.value?.beConnectFiled const beConnectFiled = cachConnectEditInfo.value?.beConnectFiled
connectConfigData.value = connectFiled.map((item, i) => {
const beConnectFiledItem = beConnectFiled[i] const index = connectFiled.findIndex(
console.log(beConnectFiledItem, '----') (v) => v.row == item.row && v.colum == item.colum && v.title == item.title
)
if (index > -1) {
const beConnectFiledItem = beConnectFiled[index]
return { return {
title: item.title, title: item.title,
sheet: item.sheet, sheet: item.sheet,
...@@ -656,13 +669,8 @@ watch(connectVisible, (val) => { ...@@ -656,13 +669,8 @@ watch(connectVisible, (val) => {
benumTitle: beConnectFiledItem.numTitle, benumTitle: beConnectFiledItem.numTitle,
beonly: beConnectFiledItem.only beonly: beConnectFiledItem.only
} }
}) }
} else { }
const titles = areaList.value.find(
(v: any) => v.excelAreaId == currentConnectInfo.excelAreaId
)?.excelAreaTitle
connectConfigData.value = titles.map((item: any) => {
return { return {
title: item.title, title: item.title,
sheet: item.sheet, sheet: item.sheet,
...@@ -682,7 +690,6 @@ watch(connectVisible, (val) => { ...@@ -682,7 +690,6 @@ watch(connectVisible, (val) => {
} }
}) })
} }
}
}) })
const onHideSettingConnect = () => { const onHideSettingConnect = () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment