代码更新:
1. 增加工作日历导入的功能。
This commit is contained in:
parent
18c7068b28
commit
9c9bdda7df
|
|
@ -54,6 +54,15 @@ const uploadExcelDbs = (data) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uploadExcelWorkDate = (data) => {
|
||||||
|
return request({
|
||||||
|
url: '/excel/uploadWorkDate',
|
||||||
|
method: 'post',
|
||||||
|
data: data,
|
||||||
|
timeout: 600000
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const uploadExcelOrders = (data) => {
|
const uploadExcelOrders = (data) => {
|
||||||
return request({
|
return request({
|
||||||
url: '/excel/uploadKateOrders',
|
url: '/excel/uploadKateOrders',
|
||||||
|
|
@ -199,5 +208,6 @@ export {
|
||||||
downloadWorkSummaryExcel,
|
downloadWorkSummaryExcel,
|
||||||
uploadExcelBaseGoods,
|
uploadExcelBaseGoods,
|
||||||
uploadExcelKanban,
|
uploadExcelKanban,
|
||||||
uploadWorkFlow
|
uploadWorkFlow,
|
||||||
|
uploadExcelWorkDate
|
||||||
}
|
}
|
||||||
98
src/excel/UploadExcelWorkDate.vue
Normal file
98
src/excel/UploadExcelWorkDate.vue
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
<template>
|
||||||
|
<el-upload ref="uploadRef" :on-preview="previewFile" :limit="1" :on-change="changeFile" :auto-upload="false"
|
||||||
|
:data="uploadForm.data">
|
||||||
|
<template #trigger>
|
||||||
|
<el-button type="primary">选取工作日历文件</el-button>
|
||||||
|
</template>
|
||||||
|
<el-button style="margin-left: 10px;" type="success" @click="uploadWorkDate">上传工作日历</el-button>
|
||||||
|
</el-upload>
|
||||||
|
</template>
|
||||||
|
<script setup>
|
||||||
|
import store from '@/store'
|
||||||
|
import { ref, reactive } from 'vue';
|
||||||
|
import { uploadExcelWorkDate } from '@/api/excel.js'
|
||||||
|
import { ElMessage } from 'element-plus'
|
||||||
|
import { errorBox } from '@/utils/myMessageBox';
|
||||||
|
import { sizeFormatter } from '@/utils/formatter.js'
|
||||||
|
import loading from '@/utils/loading.js'
|
||||||
|
import { getHashString } from '@/utils/hashUtils.js'
|
||||||
|
const file = ref()
|
||||||
|
var currentHash = ''
|
||||||
|
const uploadForm = reactive({
|
||||||
|
data: {
|
||||||
|
fileId: '',
|
||||||
|
name: '',
|
||||||
|
type: '',
|
||||||
|
size: null,
|
||||||
|
hash: '',
|
||||||
|
userName: store.getters.getUserName
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const changeFile = (uploadFile) => {
|
||||||
|
file.value = uploadFile
|
||||||
|
uploadForm.data = {
|
||||||
|
fileId: file.value.raw.uid,
|
||||||
|
name: file.value.raw.name,
|
||||||
|
type: file.value.raw.type,
|
||||||
|
size: sizeFormatter(file.value.raw.size),
|
||||||
|
hash: getHashString(uploadFile),
|
||||||
|
userName: store.getters.getUserName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const uploadRef = ref()
|
||||||
|
const uploadWorkDate = () => {
|
||||||
|
if (uploadForm == undefined || file.value == undefined) {
|
||||||
|
errorBox('请选择文件之后再上传')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (currentHash != '' && currentHash == uploadForm.data.hash) {
|
||||||
|
errorBox('请勿重复上传')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
currentHash = uploadForm.data.hash
|
||||||
|
const jsonStr = JSON.stringify(uploadForm.data);
|
||||||
|
const blob = new Blob([jsonStr], {
|
||||||
|
type: 'application/json'
|
||||||
|
});
|
||||||
|
let formData = new FormData();
|
||||||
|
// 这里很重要 file.value.raw才是真实的file文件,file.value只是一个Proxy代理对象
|
||||||
|
formData.append("obj", blob);
|
||||||
|
formData.append("file", file.value.raw);
|
||||||
|
loading.open('导入中...')
|
||||||
|
uploadExcelWorkDate(formData).then(res => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
|
if (res.data.code == 0) {
|
||||||
|
ElMessage({
|
||||||
|
message: '上传成功',
|
||||||
|
type: 'success',
|
||||||
|
})
|
||||||
|
clearFileInfos()
|
||||||
|
} else {
|
||||||
|
errorBox(res.data.message)
|
||||||
|
}
|
||||||
|
}).catch(err => {
|
||||||
|
loading.close()
|
||||||
|
currentHash = ''
|
||||||
|
console.log(err)
|
||||||
|
errorBox('上传错误')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const clearFileInfos = () => {
|
||||||
|
// 清空选择的文件项
|
||||||
|
uploadRef.value.clearFiles()
|
||||||
|
uploadForm.data = {
|
||||||
|
fileId: '',
|
||||||
|
name: '',
|
||||||
|
type: '',
|
||||||
|
size: null,
|
||||||
|
hash: '',
|
||||||
|
userName: store.getters.getUserName
|
||||||
|
}
|
||||||
|
file.value = undefined
|
||||||
|
}
|
||||||
|
const previewFile = () => {
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style scoped></style>
|
||||||
|
|
@ -9,8 +9,10 @@
|
||||||
<el-button type="warning" @click="reset()">重置</el-button>
|
<el-button type="warning" @click="reset()">重置</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-button style="background-color: #00CED1; color: #000;"
|
<el-button style="background-color: #00CED1; color: #000; width: 120px;"
|
||||||
@click="openUploadDialog()">导入</el-button>
|
@click="openUploadDialog(1)">导入DBS</el-button>
|
||||||
|
<el-button style="background-color: #32CD32; color: #000; width: 120px;"
|
||||||
|
@click="openUploadDialog(2)">导入工作日历</el-button>
|
||||||
</el-row>
|
</el-row>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
|
|
@ -123,6 +125,33 @@
|
||||||
<UploadExcelDbs></UploadExcelDbs>
|
<UploadExcelDbs></UploadExcelDbs>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<el-dialog v-model="uploadWorkDateDialogVisible" title="DBS" width="40%" draggable :show-close="true">
|
||||||
|
<fieldset class="title-area">
|
||||||
|
<legend>上次更新</legend>
|
||||||
|
<div style="padding: 5px;">
|
||||||
|
<div style="display: flex; margin-bottom: 10px;">
|
||||||
|
<div style="display: flex; width: 100%;">
|
||||||
|
<div style="width: 30%; align-content: center;">时间:</div>
|
||||||
|
<el-input v-model="uploadRecord.uploadTime" readonly />
|
||||||
|
</div>
|
||||||
|
<div style="display: flex; width: 100%; margin-left: 5px;">
|
||||||
|
<div style="width: 30%; align-content: center;">人员:</div>
|
||||||
|
<el-input v-model="uploadRecord.uploadUser" readonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div style="display: flex; width: 100%;">
|
||||||
|
<div style="width: 13%; align-content: center;">文件名:</div>
|
||||||
|
<el-input type="textarea" :rows="1" v-model="uploadRecord.fileName" :maxlength="-1"
|
||||||
|
:show-word-limit="false" :autosize="{ minRows: 1, maxRows: 4 }" readonly>
|
||||||
|
</el-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="title-area">
|
||||||
|
<legend>再次更新</legend>
|
||||||
|
<UploadExcelWorkDate></UploadExcelWorkDate>
|
||||||
|
</fieldset>
|
||||||
|
</el-dialog>
|
||||||
</el-config-provider>
|
</el-config-provider>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -136,6 +165,7 @@ import { errorBox } from '@/utils/myMessageBox.js'
|
||||||
import { ref, reactive } from 'vue'
|
import { ref, reactive } from 'vue'
|
||||||
import { dateFormatter, timeFormatter } from '@/utils/formatter.js'
|
import { dateFormatter, timeFormatter } from '@/utils/formatter.js'
|
||||||
import UploadExcelDbs from '@/excel/UploadExcelDbs.vue'
|
import UploadExcelDbs from '@/excel/UploadExcelDbs.vue'
|
||||||
|
import UploadExcelWorkDate from '@/excel/UploadExcelWorkDate.vue'
|
||||||
import { queryUploadRecord } from '@/api/excel.js'
|
import { queryUploadRecord } from '@/api/excel.js'
|
||||||
import { Search } from '@element-plus/icons-vue'
|
import { Search } from '@element-plus/icons-vue'
|
||||||
</script>
|
</script>
|
||||||
|
|
@ -161,7 +191,8 @@ export default {
|
||||||
dbsFormEntity: reactive({}),
|
dbsFormEntity: reactive({}),
|
||||||
labelPosition: 'top',
|
labelPosition: 'top',
|
||||||
dbsFormRef: ref(),
|
dbsFormRef: ref(),
|
||||||
rules: reactive({})
|
rules: reactive({}),
|
||||||
|
uploadWorkDateDialogVisible: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
|
@ -269,11 +300,11 @@ export default {
|
||||||
getCurrentRow(row) {
|
getCurrentRow(row) {
|
||||||
this.dbsId = row.dbsId
|
this.dbsId = row.dbsId
|
||||||
},
|
},
|
||||||
openUploadDialog() {
|
openUploadDialog(uploadType) {
|
||||||
// 请求上传记录
|
// 请求上传记录
|
||||||
const param = {
|
const param = {
|
||||||
userName: store.getters.getUserName,
|
userName: store.getters.getUserName,
|
||||||
fileDescription: 'DBS',
|
fileDescription: uploadType == 1 ? 'DBS' : 'WORK_DATE',
|
||||||
isAsc: false,
|
isAsc: false,
|
||||||
sortBy: 'upload_time'
|
sortBy: 'upload_time'
|
||||||
}
|
}
|
||||||
|
|
@ -299,7 +330,11 @@ export default {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
errorBox('发生异常')
|
errorBox('发生异常')
|
||||||
})
|
})
|
||||||
this.uploadDialogVisible = true
|
if (uploadType == 1) {
|
||||||
|
this.uploadDialogVisible = true
|
||||||
|
} else {
|
||||||
|
this.uploadWorkDateDialogVisible = true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user