Commit 2a31a6d9 authored by 何远江's avatar 何远江

添加复制功能,解析列表添加查询条件

parent dcc27a62
import type { Recordable } from '@/types/global' import type { Recordable } from '@/types/global'
import { ElMessage } from 'element-plus'
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
type StoreState = { type StoreState = {
fileInfo: Recordable fileInfo: Recordable,
copyFileId: undefined | string
} }
export const useCommentExcel = defineStore('CommentExcel', { export const useCommentExcel = defineStore('CommentExcel', {
state: (): StoreState => ({ state: (): StoreState => ({
fileInfo: {} fileInfo: {},
copyFileId: undefined
}), }),
getters: { getters: {
getFileInfo(): Recordable { getFileInfo(): Recordable {
return this.fileInfo return this.fileInfo
},
isSameFile(): boolean {
return this.fileInfo?.orderFileId === this.copyFileId
},
isSameVarFile(): boolean {
return this.fileInfo?.varFileId === this.copyFileId
} }
}, },
actions: { actions: {
setFileInfo(data: any) { setFileInfo(data: any) {
this.fileInfo = data this.fileInfo = data
},
setCopyFileId() {
if (!this.fileInfo?.orderFileId || this.fileInfo?.varFileId) {
return ElMessage('请选择正确的复制对象!')
}
this.copyFileId = this.fileInfo?.orderFileId || this.fileInfo?.varFileId
} }
} }
}) })
...@@ -94,6 +94,15 @@ ...@@ -94,6 +94,15 @@
</div> </div>
<el-button type="primary" size="small" @click="toRun">执行解析</el-button> <el-button type="primary" size="small" @click="toRun">执行解析</el-button>
<el-button type="primary" size="small" @click="copy">复制</el-button>
<el-button
v-if="commentExcelStore.copyFileId"
:loading="pasteLoading"
type="primary"
size="small"
@click="pasteConfig"
>引入</el-button
>
</div> </div>
</el-scrollbar> </el-scrollbar>
...@@ -227,6 +236,7 @@ import { ...@@ -227,6 +236,7 @@ import {
} from '@/constants/excelConfig' } from '@/constants/excelConfig'
import { flatten, cloneDeep } from 'lodash-es' import { flatten, cloneDeep } from 'lodash-es'
import { useCommentExcel } from '@/stores/commentExcel' import { useCommentExcel } from '@/stores/commentExcel'
import { useExcelChangeStore } from '@/stores/excel'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { isFunction } from '@/utils/is' import { isFunction } from '@/utils/is'
import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import { ElLoading, ElMessage, ElMessageBox } from 'element-plus'
...@@ -237,7 +247,8 @@ import { ...@@ -237,7 +247,8 @@ import {
getExcelAreaByFileId, getExcelAreaByFileId,
getExcelConnectByFileId, getExcelConnectByFileId,
removeExcelArea, removeExcelArea,
removeExcelAreaConnect removeExcelAreaConnect,
addExcelArea
} from '@/api/excel' } from '@/api/excel'
import type { Recordable } from '@/types/global' import type { Recordable } from '@/types/global'
import { filterRunData, getRangetxt, setRangeBackground } from '@/utils/excel' import { filterRunData, getRangetxt, setRangeBackground } from '@/utils/excel'
...@@ -245,6 +256,7 @@ import type { VxeTableInstance } from 'vxe-table' ...@@ -245,6 +256,7 @@ import type { VxeTableInstance } from 'vxe-table'
import EditArea from '../EditArea/EditArea.vue' import EditArea from '../EditArea/EditArea.vue'
import { deleteExcelProdFileConfByIds, getExcelProdFileConfPage } from '@/api/product' import { deleteExcelProdFileConfByIds, getExcelProdFileConfPage } from '@/api/product'
const pasteLoading = ref(false)
const connectVisible = ref(false) const connectVisible = ref(false)
const showProdCompare = ref(false) const showProdCompare = ref(false)
const xTableConnect = ref<VxeTableInstance>() const xTableConnect = ref<VxeTableInstance>()
...@@ -257,8 +269,9 @@ const compareParams = reactive({ ...@@ -257,8 +269,9 @@ const compareParams = reactive({
customerId: '' customerId: ''
}) })
const luckysheet = (window as any).luckysheet const luckysheet = (window as any).luckysheet
const excelChangeStore = useExcelChangeStore()
const commentExcelStore = useCommentExcel() const commentExcelStore = useCommentExcel()
const { getFileInfo } = storeToRefs(commentExcelStore) const { getFileInfo, isSameFile } = storeToRefs(commentExcelStore)
const connectList = ref<any[]>([]) const connectList = ref<any[]>([])
const chooseVisible = ref(false) const chooseVisible = ref(false)
const editVisible = ref(false) const editVisible = ref(false)
...@@ -742,6 +755,56 @@ const toDelete = async (row) => { ...@@ -742,6 +755,56 @@ const toDelete = async (row) => {
} }
} }
/**
* 复制
*/
const copy = () => {
if (areaList.value?.length) {
commentExcelStore.setCopyFileId()
}
ElMessage('该文件还未设置标注信息!')
}
/**
* 引入复制的配置
*/
const pasteConfig = async () => {
// 是否是当前文件
if (isSameFile.value) {
return ElMessage('请在其他文件引入!')
}
pasteLoading.value = true
try {
// 1、获取复制文件id
const { data } = await getExcelAreaByFileId(commentExcelStore.copyFileId as string)
// 2、去除id
data.result.forEach((item) => {
item.fileId = commentExcelStore.fileInfo.orderFileId
delete item.excelAreaId
})
// 3、自动保存
await addExcelArea(data.result)
// 4、刷新
ElMessage({
type:'success',
message: '引入成功!重新加载...',
})
// 5、刷新当前页 or 刷新当前excel
setTimeout(() => {
window.location.reload();
}, 1500);
} catch {
ElMessage.error('引入失败!')
}
pasteLoading.value = false
}
onMounted(() => { onMounted(() => {
loadExcel() loadExcel()
getCompareList() getCompareList()
......
...@@ -12,6 +12,16 @@ ...@@ -12,6 +12,16 @@
</template> </template>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="创建时间">
<el-date-picker v-model="queryParams.createTime" type="date" value-format="YYYY-MM-DD" placeholder="选择创建时间"></el-date-picker>
</el-form-item>
<el-form-item label="创建人">
<el-input v-model="queryParams.createby_dict" placeholder="">
<template #append>
<el-button :icon="MoreFilled" @click="visibleUserModal = true"></el-button>
</template>
</el-input>
</el-form-item>
<el-form-item> <el-form-item>
<el-button type="default" @click="onReset">重置</el-button> <el-button type="default" @click="onReset">重置</el-button>
...@@ -36,7 +46,7 @@ ...@@ -36,7 +46,7 @@
:data="tableData" :data="tableData"
> >
<vxe-column type="checkbox" width="50"></vxe-column> <vxe-column type="checkbox" width="50"></vxe-column>
<vxe-column field="fileId_dictText" title="文件名称"> <vxe-column field="fileId_dictText" title="文件名称" minWidth="300">
<template #default="{ row }"> <template #default="{ row }">
<el-link target="_blank" :href="'/preview-excel?fileId=' + row.fileId">{{ <el-link target="_blank" :href="'/preview-excel?fileId=' + row.fileId">{{
row.fileId_dictText row.fileId_dictText
...@@ -45,6 +55,7 @@ ...@@ -45,6 +55,7 @@
</vxe-column> </vxe-column>
<vxe-column field="status_dictText" title="订单状态" width="120"></vxe-column> <vxe-column field="status_dictText" title="订单状态" width="120"></vxe-column>
<vxe-column field="createTime" title="创建时间" width="180"></vxe-column> <vxe-column field="createTime" title="创建时间" width="180"></vxe-column>
<vxe-column field="createby_dict" title="创建人" width="180"></vxe-column>
<vxe-column field="action" title="操作" width="140"> <vxe-column field="action" title="操作" width="140">
<template #default="{ row }"> <template #default="{ row }">
<el-link style="font-size: 12px" type="primary" @click="toDetail(row)">查看</el-link> <el-link style="font-size: 12px" type="primary" @click="toDetail(row)">查看</el-link>
...@@ -202,6 +213,8 @@ ...@@ -202,6 +213,8 @@
</vxe-modal> </vxe-modal>
<CustomerModal v-model:visible="visible" @confirm="confirmCustomer" /> <CustomerModal v-model:visible="visible" @confirm="confirmCustomer" />
<UserModal v-model:visible="visibleUserModal" @confirm="confirmUser" />
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
...@@ -236,8 +249,10 @@ import { storeToRefs } from 'pinia' ...@@ -236,8 +249,10 @@ import { storeToRefs } from 'pinia'
import { saveAs } from 'file-saver' 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'
const visible = ref(false) const visible = ref(false)
const visibleUserModal = ref(false)
const uploadRef = ref<UploadInstance>() const uploadRef = ref<UploadInstance>()
const importFormInstance = ref<FormInstance>() const importFormInstance = ref<FormInstance>()
const loading = ref(false) const loading = ref(false)
...@@ -247,6 +262,9 @@ const { getAllMapConfigs } = storeToRefs(excelChangeStore) ...@@ -247,6 +262,9 @@ const { getAllMapConfigs } = storeToRefs(excelChangeStore)
/**查询参数 */ /**查询参数 */
const queryParams = reactive({ const queryParams = reactive({
status: '', status: '',
createTime: '',
createBy: '',
createby_dict: '',
currentPage: 1, currentPage: 1,
pageSize: 10, pageSize: 10,
total: 0, total: 0,
...@@ -506,6 +524,14 @@ const submitImport = async () => { ...@@ -506,6 +524,14 @@ const submitImport = async () => {
} }
} }
const confirmUser = (list: any) => {
const [user] = list
if (user) {
queryParams.createBy = user.userId
queryParams.createby_dict = user.nickName
}
}
const onReset = () => { const onReset = () => {
queryParams.status = '' queryParams.status = ''
} }
......
...@@ -94,6 +94,15 @@ ...@@ -94,6 +94,15 @@
</div> </div>
<el-button type="primary" size="small" @click="toRun">执行解析</el-button> <el-button type="primary" size="small" @click="toRun">执行解析</el-button>
<el-button type="primary" size="small" @click="copy">复制</el-button>
<el-button
v-if="commentExcelStore.copyFileId"
:loading="pasteLoading"
type="primary"
size="small"
@click="pasteConfig"
>引入</el-button
>
</div> </div>
</el-scrollbar> </el-scrollbar>
...@@ -237,7 +246,8 @@ import { ...@@ -237,7 +246,8 @@ import {
getExcelAreaByFileId, getExcelAreaByFileId,
getExcelConnectByFileId, getExcelConnectByFileId,
removeExcelArea, removeExcelArea,
removeExcelAreaConnect removeExcelAreaConnect,
addExcelArea
} from '@/api/varExcel' } from '@/api/varExcel'
import type { Recordable } from '@/types/global' import type { Recordable } from '@/types/global'
import { filterRunData2, getRangetxt, setRangeBackground } from '@/utils/excel' import { filterRunData2, getRangetxt, setRangeBackground } from '@/utils/excel'
...@@ -245,6 +255,7 @@ import type { VxeTableInstance } from 'vxe-table' ...@@ -245,6 +255,7 @@ import type { VxeTableInstance } from 'vxe-table'
import EditArea from '../EditArea/EditArea.vue' import EditArea from '../EditArea/EditArea.vue'
import { deleteExcelProdFileConfByIds, getExcelProdFileConfPage } from '@/api/product' import { deleteExcelProdFileConfByIds, getExcelProdFileConfPage } from '@/api/product'
const pasteLoading = ref(false);
const connectVisible = ref(false) const connectVisible = ref(false)
const showProdCompare = ref(false) const showProdCompare = ref(false)
const xTableConnect = ref<VxeTableInstance>() const xTableConnect = ref<VxeTableInstance>()
...@@ -258,7 +269,7 @@ const compareParams = reactive({ ...@@ -258,7 +269,7 @@ const compareParams = reactive({
}) })
const luckysheet = (window as any).luckysheet const luckysheet = (window as any).luckysheet
const commentExcelStore = useCommentExcel() const commentExcelStore = useCommentExcel()
const { getFileInfo } = storeToRefs(commentExcelStore) const { getFileInfo, isSameVarFile } = storeToRefs(commentExcelStore)
const connectList = ref<any[]>([]) const connectList = ref<any[]>([])
const chooseVisible = ref(false) const chooseVisible = ref(false)
const editVisible = ref(false) const editVisible = ref(false)
...@@ -742,6 +753,56 @@ const toDelete = async (row) => { ...@@ -742,6 +753,56 @@ const toDelete = async (row) => {
} }
} }
/**
* 复制
*/
const copy = () => {
if (areaList.value?.length) {
commentExcelStore.setCopyFileId()
}
ElMessage('该文件还未设置标注信息!')
}
/**
* 引入复制的配置
*/
const pasteConfig = async () => {
// 是否是当前文件
if (isSameVarFile.value) {
return ElMessage('请在其他文件引入!')
}
pasteLoading.value = true
try {
// 1、获取复制文件id
const { data } = await getExcelAreaByFileId(commentExcelStore.copyFileId as string)
// 2、去除id
data.result.forEach((item) => {
item.fileId = commentExcelStore.fileInfo.varFileId
delete item.varAreaId
})
// 3、自动保存
await addExcelArea(data.result)
// 4、刷新
ElMessage({
type:'success',
message: '引入成功!重新加载...',
})
// 5、刷新当前页 or 刷新当前excel
setTimeout(() => {
window.location.reload();
}, 1500);
} catch {
ElMessage.error('引入失败!')
}
pasteLoading.value = false
}
onMounted(() => { onMounted(() => {
loadExcel() loadExcel()
getCompareList() getCompareList()
......
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