Commit 870072ef authored by 何远江's avatar 何远江

添加复制引入

parent 8a72c861
import { computed, reactive, toRefs } from 'vue'
import { ElMessage } from 'element-plus'
export function useOrderChangeCopy(api, beforePaste) {
const state = reactive({
// 复制信息
copyInfo: []
})
// 是否复制
const isCopying = computed(() => !!state.copyInfo.length)
// 复制
const handleCopy = (info) => {
if (!info?.length) {
return ElMessage.warning('没有可以复制的配置!')
}
state.copyInfo = JSON.parse(JSON.stringify(info))
ElMessage.success('复制成功!')
}
return {
...toRefs(state),
isCopying,
handleCopy,
}
}
...@@ -13,7 +13,12 @@ ...@@ -13,7 +13,12 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="创建时间"> <el-form-item label="创建时间">
<el-date-picker v-model="queryParams.createTime" type='daterange' value-format="YYYY-MM-DD" placeholder="选择创建时间"></el-date-picker> <el-date-picker
v-model="queryParams.createTime"
type="daterange"
value-format="YYYY-MM-DD"
placeholder="选择创建时间"
></el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="创建人"> <el-form-item label="创建人">
<el-input v-model="queryParams.createby_dict" placeholder=""> <el-input v-model="queryParams.createby_dict" placeholder="">
...@@ -126,7 +131,7 @@ ...@@ -126,7 +131,7 @@
</template> --> </template> -->
<!-- 转换下使用 --> <!-- 转换下使用 -->
<template > <template>
<vxe-colgroup v-for="item in tableTitle" :key="item" :title="item"> <vxe-colgroup v-for="item in tableTitle" :key="item" :title="item">
<vxe-column :title="item" :field="item" width="200"> <vxe-column :title="item" :field="item" width="200">
<template #header> <template #header>
...@@ -135,7 +140,7 @@ ...@@ -135,7 +140,7 @@
<span>{{ cf.orderFiled.fliedTitle }}</span> <span>{{ cf.orderFiled.fliedTitle }}</span>
</template> </template>
<!-- <span>{{ allMapConfigs[item]?.orderFiled.fliedTitle || '' }}</span> --> <!-- <span>{{ allMapConfigs[item]?.orderFiled.fliedTitle || '' }}</span> -->
<el-icon ><Setting /></el-icon> <el-icon><Setting /></el-icon>
</div> </div>
</template> </template>
</vxe-column> </vxe-column>
...@@ -164,10 +169,10 @@ ...@@ -164,10 +169,10 @@
</el-popover> </el-popover>
<template #footer> <template #footer>
<el-button type="primary" @click="onCopy">复制</el-button>
<el-button type="primary" v-if="isCopying" @click="onPaste">引入</el-button>
<!-- <el-button @click="confirmChange" v-if="currentRow.status == 'un_convert'">确认转换</el-button> --> <!-- <el-button @click="confirmChange" v-if="currentRow.status == 'un_convert'">确认转换</el-button> -->
<el-button @click="saveOrderField" type="primary" <el-button @click="saveOrderField" type="primary">保存</el-button>
>保存</el-button
>
</template> </template>
</vxe-modal> </vxe-modal>
...@@ -214,7 +219,6 @@ ...@@ -214,7 +219,6 @@
<CustomerModal v-model:visible="visible" @confirm="confirmCustomer" /> <CustomerModal v-model:visible="visible" @confirm="confirmCustomer" />
<UserModal v-model:visible="visibleUserModal" @confirm="confirmUser" /> <UserModal v-model:visible="visibleUserModal" @confirm="confirmUser" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
...@@ -250,6 +254,7 @@ import { saveAs } from 'file-saver' ...@@ -250,6 +254,7 @@ import { saveAs } from 'file-saver'
import { uploadFile } from '@/api/excel' import { uploadFile } from '@/api/excel'
import CustomerModal from '@/components/CustomerModal/CustomerModal.vue' import CustomerModal from '@/components/CustomerModal/CustomerModal.vue'
import UserModal from '@/components/UserModal/UserModal.vue' import UserModal from '@/components/UserModal/UserModal.vue'
import { useOrderChangeCopy } from '@/hooks/useOrderChangeCopy'
const visible = ref(false) const visible = ref(false)
const visibleUserModal = ref(false) const visibleUserModal = ref(false)
...@@ -259,6 +264,7 @@ const loading = ref(false) ...@@ -259,6 +264,7 @@ const loading = ref(false)
const importVisible = ref(false) const importVisible = ref(false)
const excelChangeStore = useExcelChangeStore() const excelChangeStore = useExcelChangeStore()
const { getAllMapConfigs } = storeToRefs(excelChangeStore) const { getAllMapConfigs } = storeToRefs(excelChangeStore)
const { copyInfo, isCopying, handleCopy } = useOrderChangeCopy()
/**查询参数 */ /**查询参数 */
const queryParams = reactive({ const queryParams = reactive({
status: '', status: '',
...@@ -445,7 +451,7 @@ const toDetail = async (row: any) => { ...@@ -445,7 +451,7 @@ const toDetail = async (row: any) => {
configs[item.title] = item configs[item.title] = item
}) })
// 排除通过循环不显示的column // 排除通过循环不显示的column
const excludeTitles = ['sortNum', '数据区', 'expendData','sheet页'] const excludeTitles = ['sortNum', '数据区', 'expendData', 'sheet页']
detailTable.value = res detailTable.value = res
tableTitle.value = titles.filter((v) => !excludeTitles.includes(v)) tableTitle.value = titles.filter((v) => !excludeTitles.includes(v))
detailVisible.value = true detailVisible.value = true
...@@ -532,6 +538,26 @@ const confirmUser = (list: any) => { ...@@ -532,6 +538,26 @@ const confirmUser = (list: any) => {
} }
} }
const onCopy = () => {
const confs = Object.values(getAllMapConfigs.value).filter(
(v) => v.title !== '' && !!v.orderFiledConfs.length
)
handleCopy(confs)
}
const onPaste = () => {
// 将复制的配置信息,一条一条设置
copyInfo.forEach((item: any) => {
item.templateFileId = currentRow.templateFileId
item.excelOrderFiledConfId = ''
excelChangeStore.setSingleFieldMap(item)
})
// 自动保存
saveOrderField()
}
const onReset = () => { const onReset = () => {
queryParams.status = '' queryParams.status = ''
} }
......
...@@ -30,42 +30,21 @@ ...@@ -30,42 +30,21 @@
:data="tableData" :data="tableData"
> >
<vxe-column type="checkbox" width="50"></vxe-column> <vxe-column type="checkbox" width="50"></vxe-column>
<vxe-column <vxe-column field="customerId_dictText" title="客户" width="300"></vxe-column>
field="customerId_dictText" <vxe-column field="productCode_dictText" title="产品" width="300"></vxe-column>
title="客户" <vxe-column field="status_dictText" title="订单状态" width="120"></vxe-column>
width="300" <vxe-column field="createTime" title="创建时间" width="160"></vxe-column>
></vxe-column>
<vxe-column
field="productCode_dictText"
title="产品"
width="300"
></vxe-column>
<vxe-column
field="status_dictText"
title="订单状态"
width="120"
></vxe-column>
<vxe-column field="createTime" title="创建时间"></vxe-column>
<vxe-column field="action" title="操作" width="200"> <vxe-column field="action" title="操作" width="200">
<template #default="{ row }"> <template #default="{ row }">
<el-link <el-link style="font-size: 12px" type="primary" @click="toDetail(row)">查看</el-link>
style="font-size: 12px" <el-link class="ml-1" style="font-size: 12px" type="primary" @click="confirmChange(row)"
type="primary"
@click="toDetail(row)"
>查看</el-link
>
<el-link
class="ml-1"
style="font-size: 12px"
type="primary"
@click="confirmChange(row)"
>转换</el-link >转换</el-link
> >
<el-link <el-link
class="ml-1" class="ml-1"
style="font-size: 12px" style="font-size: 12px"
type="primary" type="primary"
@click="showDetail(row,'old')" @click="showDetail(row, 'old')"
>转换前</el-link >转换前</el-link
> >
<el-link <el-link
...@@ -86,26 +65,13 @@ ...@@ -86,26 +65,13 @@
v-model:page-size="queryParams.pageSize" v-model:page-size="queryParams.pageSize"
:total="queryParams.total" :total="queryParams.total"
@page-change="onQuery" @page-change="onQuery"
:layouts="[ :layouts="['PrevPage', 'JumpNumber', 'NextPage', 'Sizes', 'FullJump', 'Total']"
'PrevPage',
'JumpNumber',
'NextPage',
'Sizes',
'FullJump',
'Total',
]"
> >
</vxe-pager> </vxe-pager>
</div> </div>
</div> </div>
<vxe-modal <vxe-modal v-model="detailVisible" title="解析详情" width="80%" show-footer @hide="detailHide">
v-model="detailVisible"
title="解析详情"
width="80%"
show-footer
@hide="detailHide"
>
<vxe-table <vxe-table
border border
size="mini" size="mini"
...@@ -118,10 +84,10 @@ ...@@ -118,10 +84,10 @@
<template #default="{ row }">{{ row.sortNum }}</template> <template #default="{ row }">{{ row.sortNum }}</template>
</vxe-column> </vxe-column>
<vxe-column title="sheet页" width="120" key="sheet页"> <vxe-column title="sheet页" width="120" key="sheet页">
<template #default="{ row }">{{ row["sheet页"] }}</template> <template #default="{ row }">{{ row['sheet页'] }}</template>
</vxe-column> </vxe-column>
<vxe-column title="数据区" width="120" key="数据区"> <vxe-column title="数据区" width="120" key="数据区">
<template #default="{ row }">{{ row["数据区"] }}</template> <template #default="{ row }">{{ row['数据区'] }}</template>
</vxe-column> </vxe-column>
<!-- 查看状态下直接显示 --> <!-- 查看状态下直接显示 -->
...@@ -174,6 +140,8 @@ ...@@ -174,6 +140,8 @@
</el-popover> </el-popover>
<template #footer> <template #footer>
<el-button type="primary" @click="onCopy">复制</el-button>
<el-button type="primary" v-if="isCopying" @click="onPaste">引入</el-button>
<!-- <el-button @click="confirmChange" v-if="currentRow.status == 'un_convert'">确认转换</el-button> --> <!-- <el-button @click="confirmChange" v-if="currentRow.status == 'un_convert'">确认转换</el-button> -->
<el-button @click="saveOrderField" type="primary">保存</el-button> <el-button @click="saveOrderField" type="primary">保存</el-button>
</template> </template>
...@@ -182,9 +150,9 @@ ...@@ -182,9 +150,9 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { onMounted, reactive, ref, watch, nextTick } from "vue"; import { onMounted, reactive, ref, watch, nextTick } from 'vue'
import { Setting, MoreFilled } from "@element-plus/icons-vue"; import { Setting, MoreFilled } from '@element-plus/icons-vue'
import { cloneDeep } from "lodash-es"; import { cloneDeep } from 'lodash-es'
import { import {
apiVarTemplatePage, apiVarTemplatePage,
apiVarTemplateGetVars, apiVarTemplateGetVars,
...@@ -192,105 +160,104 @@ import { ...@@ -192,105 +160,104 @@ import {
apiVarTemplateGetConf, apiVarTemplateGetConf,
apiVarTemplateConvert, apiVarTemplateConvert,
apiVarTemplateSaveConf, apiVarTemplateSaveConf,
getVarSpecList, getVarSpecList
} from "@/api/var"; } from '@/api/var'
import { import { ElMessage, ElMessageBox } from 'element-plus'
ElMessage, import type { VxeTableInstance } from 'vxe-table'
ElMessageBox, import type { Recordable } from '@/types/global'
} from "element-plus"; import { filterRunData2 } from '@/utils/excel'
import type { VxeTableInstance } from "vxe-table"; import { apiDictList } from '@/api/common'
import type { Recordable } from "@/types/global"; import ConfigForm from './components/ConfigForm1.vue'
import { filterRunData2 } from "@/utils/excel"; import { useVariableExcelChangeStore } from '@/stores/excel'
import { apiDictList } from "@/api/common"; import { storeToRefs } from 'pinia'
import ConfigForm from "./components/ConfigForm1.vue";
import { useVariableExcelChangeStore } from "@/stores/excel";
import { storeToRefs } from "pinia";
import TemplateVariable from './components/TemplateVariable.vue' import TemplateVariable from './components/TemplateVariable.vue'
import { useOrderChangeCopy } from '@/hooks/useOrderChangeCopy'
const visible = ref(false)
const loading = ref(false)
const importVisible = ref(false)
const excelChangeStore = useVariableExcelChangeStore()
const { getAllMapConfigs } = storeToRefs(excelChangeStore)
const { copyInfo, isCopying, handleCopy } = useOrderChangeCopy()
const visible = ref(false);
const loading = ref(false);
const importVisible = ref(false);
const excelChangeStore = useVariableExcelChangeStore();
const { getAllMapConfigs } = storeToRefs(excelChangeStore);
/**查询参数 */ /**查询参数 */
const queryParams = reactive({ const queryParams = reactive({
status: "", status: '',
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
column: "createTime", column: 'createTime',
order: "desc", order: 'desc'
}); })
const currentColConf = reactive({ const currentColConf = reactive({
excelOrderFiledConfId: "", excelOrderFiledConfId: '',
title: "", title: '',
filedConfs: [], filedConfs: [],
templateFileId: "", templateFileId: ''
}); })
const currentConfigTitle = ref(""); const currentConfigTitle = ref('')
const xTable = ref<VxeTableInstance>(); const xTable = ref<VxeTableInstance>()
const tableData = ref([]); const tableData = ref([])
/**当前选择行 */ /**当前选择行 */
const currentRow = reactive<Recordable>({}); const currentRow = reactive<Recordable>({})
/**弹窗显示 */ /**弹窗显示 */
const detailVisible = ref(false); const detailVisible = ref(false)
/**详情表格数据 */ /**详情表格数据 */
const detailTable = ref<Recordable[]>([]); const detailTable = ref<Recordable[]>([])
/**表格title */ /**表格title */
const tableTitle = ref<string[]>([]); const tableTitle = ref<string[]>([])
const statusOptions = ref([]); const statusOptions = ref([])
const queryDict = async (code: string) => { const queryDict = async (code: string) => {
const { data } = await apiDictList({ const { data } = await apiDictList({
dictCodes: code, dictCodes: code
}); })
statusOptions.value = data.result[code]; statusOptions.value = data.result[code]
}; }
const popoverRef = ref(); const popoverRef = ref()
const buttonRef = ref(); const buttonRef = ref()
const popoverVisible = ref(false); const popoverVisible = ref(false)
const showPopover = (e: any, title: string) => { const showPopover = (e: any, title: string) => {
// if (currentRow.status != "un_convert") { // if (currentRow.status != "un_convert") {
// return; // return;
// } // }
buttonRef.value = e.target; buttonRef.value = e.target
// 设置标题 // 设置标题
currentConfigTitle.value = title; currentConfigTitle.value = title
const hasConf = !!getAllMapConfigs.value[title].filedConfs.length; const hasConf = !!getAllMapConfigs.value[title].filedConfs.length
console.log(getAllMapConfigs.value[title], "------"); console.log(getAllMapConfigs.value[title], '------')
const conf = hasConf const conf = hasConf
? getAllMapConfigs.value[title] ? getAllMapConfigs.value[title]
: { : {
excelOrderFiledConfId: "", excelOrderFiledConfId: '',
title, title,
filedConfs: [ filedConfs: [
{ {
mapField: "", mapField: '',
orderFiled: null, orderFiled: null,
scripts: [], scripts: []
}, }
], ],
templateFileId: currentRow.templateFileId, templateFileId: currentRow.templateFileId
}
}; Object.assign(currentColConf, conf)
Object.assign(currentColConf, conf);
// 打开popover // 打开popover
popoverVisible.value = true; popoverVisible.value = true
}; }
/**监听popover和modal显示状态。重置表单信息 */ /**监听popover和modal显示状态。重置表单信息 */
watch([detailVisible, popoverVisible], (val) => { watch([detailVisible, popoverVisible], (val) => {
// 关闭弹窗或者关闭popover // 关闭弹窗或者关闭popover
if (val.includes(false)) { if (val.includes(false)) {
// 解决关闭弹窗之后,popover未关闭情况 // 解决关闭弹窗之后,popover未关闭情况
popoverVisible.value = false; popoverVisible.value = false
} }
}); })
/** 确认字段映射及脚本的配置 */ /** 确认字段映射及脚本的配置 */
const confirmConfig = (configList: any) => { const confirmConfig = (configList: any) => {
...@@ -304,89 +271,88 @@ const confirmConfig = (configList: any) => { ...@@ -304,89 +271,88 @@ const confirmConfig = (configList: any) => {
item.orderFiled = { item.orderFiled = {
fliedTitle: item.mapField, fliedTitle: item.mapField,
filedName: item.mapField, filedName: item.mapField,
variable: true, variable: true
}; }
} }
return item; return item
}) })
.filter((v) => !!v.mapField) .filter((v) => !!v.mapField)
), )
}); })
// 关闭popover // 关闭popover
popoverVisible.value = false; popoverVisible.value = false
}; }
const detailHide = () => { const detailHide = () => {
// detailVisible.value = false; // detailVisible.value = false;
detailTable.value = []; detailTable.value = []
tableTitle.value = []; tableTitle.value = []
}; }
/**保存订单字段 */ /**保存订单字段 */
const saveOrderField = async () => { const saveOrderField = async () => {
const params = { const params = {
templateFileId: currentRow.templateFileId, templateFileId: currentRow.templateFileId,
confs: Object.values(getAllMapConfigs.value).filter( confs: Object.values(getAllMapConfigs.value).filter(
(v) => v.title !== "" && !!v.filedConfs.length (v) => v.title !== '' && !!v.filedConfs.length
), )
}; }
apiVarTemplateSaveConf(params).then(({ data }) => { apiVarTemplateSaveConf(params).then(({ data }) => {
if (data.code == 200) { if (data.code == 200) {
ElMessage.success(data.message || "保存成功!"); ElMessage.success(data.message || '保存成功!')
} else { } else {
ElMessage.error(data.message || "保存失败!"); ElMessage.error(data.message || '保存失败!')
} }
}); })
}; }
/** 确认订单转换 */ /** 确认订单转换 */
const confirmChange = async (row) => { const confirmChange = async (row) => {
await ElMessageBox.confirm("是否确认变量转换?", "提示", { await ElMessageBox.confirm('是否确认变量转换?', '提示', {
confirmButtonText: "转换", confirmButtonText: '转换',
cancelButtonText: "取消", cancelButtonText: '取消',
type: "warning", type: 'warning'
}); })
const { data } = await apiVarTemplateConvert(row.varTemplateDetailId); const { data } = await apiVarTemplateConvert(row.varTemplateDetailId)
if (data.code == 200) { if (data.code == 200) {
ElMessage.success(data.message || "转换成功!"); ElMessage.success(data.message || '转换成功!')
detailVisible.value = false; detailVisible.value = false
onQuery(); onQuery()
return; return
} }
ElMessage.error(data.message || "转换失败!"); ElMessage.error(data.message || '转换失败!')
}; }
const toDetail = async (row: any) => { const toDetail = async (row: any) => {
Object.assign(currentRow, row); Object.assign(currentRow, row)
const { data } = await apiVarTemplateGetVars(row.varTemplateDetailId); const { data } = await apiVarTemplateGetVars(row.varTemplateDetailId)
const { data: cdata } = await apiVarTemplateGetConf(row.varTemplateDetailId); const { data: cdata } = await apiVarTemplateGetConf(row.varTemplateDetailId)
const { data: specData } = await getVarSpecList(row.productCode) const { data: specData } = await getVarSpecList(row.productCode)
const { res, titles, configs } = filterRunData2(data.result, true); const { res, titles, configs } = filterRunData2(data.result, true)
excelChangeStore.setSpecList(specData.result) excelChangeStore.setSpecList(specData.result)
cdata.result?.forEach((item) => { cdata.result?.forEach((item) => {
Reflect.set(configs[item.title], "filedConfs", item.filedConfs); Reflect.set(configs[item.title], 'filedConfs', item.filedConfs)
}); })
// 排除通过循环不显示的column // 排除通过循环不显示的column
const excludeTitles = ["sortNum", "数据区", "expendData", "sheet页"]; const excludeTitles = ['sortNum', '数据区', 'expendData', 'sheet页']
detailTable.value = res; detailTable.value = res
tableTitle.value = titles.filter((v) => !excludeTitles.includes(v)); tableTitle.value = titles.filter((v) => !excludeTitles.includes(v))
nextTick(() => { nextTick(() => {
detailVisible.value = true; detailVisible.value = true
}); })
excludeTitles.forEach((key) => { excludeTitles.forEach((key) => {
Reflect.deleteProperty(configs, key); Reflect.deleteProperty(configs, key)
}); })
excelChangeStore.setAllMapConfigs(configs);
};
excelChangeStore.setAllMapConfigs(configs)
}
const tempVisible = ref(false) const tempVisible = ref(false)
const details = ref({ const details = ref({
...@@ -394,38 +360,57 @@ const details = ref({ ...@@ -394,38 +360,57 @@ const details = ref({
data: [], data: [],
titles: [] titles: []
}) })
const showDetail = async (row: any, type = "old") => { const showDetail = async (row: any, type = 'old') => {
const { data } = const { data } =
type == "old" type == 'old'
? await apiVarTemplateGetVars(row.varTemplateDetailId) ? await apiVarTemplateGetVars(row.varTemplateDetailId)
: await apiVarTemplateGetNewVars(row.varTemplateDetailId); : await apiVarTemplateGetNewVars(row.varTemplateDetailId)
const { res, titles, configs } = filterRunData2(data.result, true); const { res, titles, configs } = filterRunData2(data.result, true)
details.value.title = type == "old"? "转换前的变量" : "转换后变量"; details.value.title = type == 'old' ? '转换前的变量' : '转换后变量'
details.value.data = res details.value.data = res
details.value.titles = titles; details.value.titles = titles
tempVisible.value = true tempVisible.value = true
}; }
const onCopy = () => {
const confs = Object.values(getAllMapConfigs.value).filter(
(v) => v.title !== '' && !!v.filedConfs.length
)
handleCopy(confs)
}
const onPaste = () => {
// 将复制的配置信息,一条一条设置
copyInfo.forEach((item: any) => {
item.templateFileId = currentRow.templateFileId
item.varFiledConfId = ''
excelChangeStore.setSingleFieldMap(item)
})
// 自动保存
saveOrderField()
}
const onReset = () => { const onReset = () => {
queryParams.status = ""; queryParams.status = ''
}; }
const onQuery = async () => { const onQuery = async () => {
loading.value = true; loading.value = true
try { try {
const { data } = await apiVarTemplatePage(queryParams); const { data } = await apiVarTemplatePage(queryParams)
tableData.value = data.result.records; tableData.value = data.result.records
queryParams.total = +data.result.total; queryParams.total = +data.result.total
} catch {} } catch {}
loading.value = false; loading.value = false
}; }
onMounted(() => { onMounted(() => {
onQuery(); onQuery()
queryDict("excel_order_status"); queryDict('excel_order_status')
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.header-cell { .header-cell {
......
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