Browse Source

排班信息增加导入功能

java8
赵宏斌 6 months ago
parent
commit
805a7c2e66
  1. 4
      src/api/scheduling/scheduling.js
  2. 18
      src/views/modules/scheduling/scheduling.vue
  3. 181
      src/views/modules/scheduling/schedulingUpload.vue

4
src/api/scheduling/scheduling.js

@ -15,5 +15,7 @@ export const saveSchedulingHeader = data => createAPI(`/scheduling/Scheduling1/s
export const querySaveSchedulingRecord = data => createAPI(`/scheduling/Scheduling1/querySaveSchedulingRecord`,'post',data) export const querySaveSchedulingRecord = data => createAPI(`/scheduling/Scheduling1/querySaveSchedulingRecord`,'post',data)
//删除子表数据 //删除子表数据
export const deleteSchedulingRecord = data => createAPI(`/scheduling/Scheduling1/deleteSchedulingRecord`,'post',data) export const deleteSchedulingRecord = data => createAPI(`/scheduling/Scheduling1/deleteSchedulingRecord`,'post',data)
//删除子表数据
//更新子表数据
export const editSaveSchedulingRecord = data => createAPI(`/scheduling/Scheduling1/editSaveSchedulingRecord`,'post',data) export const editSaveSchedulingRecord = data => createAPI(`/scheduling/Scheduling1/editSaveSchedulingRecord`,'post',data)
//排班信息导入
export const uploadSchedulingExcel = data => createAPI(`/scheduling/Scheduling1/uploadSchedulingExcel`,'post',data)

18
src/views/modules/scheduling/scheduling.vue

@ -26,9 +26,13 @@ import {
deleteSchedulingRecord, deleteSchedulingRecord,
editSaveSchedulingRecord editSaveSchedulingRecord
} from "../../../api/scheduling/scheduling"; } from "../../../api/scheduling/scheduling";
import schedulingUpload from "../scheduling/schedulingUpload.vue";
export default { export default {
name: "scheduling", name: "scheduling",
components: {
schedulingUpload
},
data(){ data(){
return{ return{
span:3, span:3,
@ -541,6 +545,17 @@ export default {
this.saveSchedulingFlag = true; this.saveSchedulingFlag = true;
this.recordAddPeoPleFlag = false this.recordAddPeoPleFlag = false
}, },
schedulingUpload(){
let currentData = {
flag: 'template',
createBy: this.$store.state.user.name,
site: this.$store.state.user.site,
}
//
this.$nextTick(() => {
this.$refs.schedulingUpload.init(currentData)
})
},
async saveHeaderFunction(){ async saveHeaderFunction(){
if (this.saveData.insertType == null || this.saveData.insertType === ''){ if (this.saveData.insertType == null || this.saveData.insertType === ''){
@ -776,6 +791,7 @@ export default {
<el-form-item label=" "> <el-form-item label=" ">
<el-button type="primary" @click="handleQuery">查询</el-button> <el-button type="primary" @click="handleQuery">查询</el-button>
<el-button type="primary" @click="saveScheduling">新增</el-button> <el-button type="primary" @click="saveScheduling">新增</el-button>
<el-button type="primary" @click="schedulingUpload">导入</el-button>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -1136,6 +1152,8 @@ export default {
</span> </span>
</el-dialog> </el-dialog>
<schedulingUpload ref="schedulingUpload" @refreshPageTables="handleQuery" v-drag></schedulingUpload>
</div> </div>
</template> </template>

181
src/views/modules/scheduling/schedulingUpload.vue

@ -0,0 +1,181 @@
<template>
<div class="customer-css">
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" width="390px" style="height: 520px;" class="customer-dialog">
<el-form :inline="true" label-position="top" label-width="80px">
<el-button type="primary" @click="downloadFile()">下载文件模板</el-button>
<el-form-item label="BU">
<el-select v-model="bu" placeholder="请选择" style="width: 295px">
<el-option
v-for = "i in userBuList"
:key = "i.buNo"
:label = "i.sitename"
:value = "i.buNo">
<span style="float: left;width: 100px">{{ i.sitename }}</span>
<span style="float: right; color: #8492a6;white-space:nowrap;overflow:hidden;text-overflow:ellipsis; font-size: 11px;width: 60px">
{{ i.buDesc }}
</span>
</el-option>
</el-select>
</el-form-item>
<el-row>
<el-col :span="24">
<el-upload class="customer-upload" drag action="javascript:void(0);" ref="uploadFile" :limit="1" accept=".xlsx,.xls"
:before-upload="beforeUploadHandle" :on-change="onChange" :auto-upload="false" style="text-align: left;">
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处<em>点击上传</em></div>
</el-upload>
</el-col>
</el-row>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="saveUploadFile()">保存</el-button>
<el-button type="primary" @click="closeDialog">关闭</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import {
uploadExcel, //
uploadTemplateExcel, //
uploadPartAttributeExcel, //
uploadFamilyAttributeExcel, //
queryFileId, // ID
getSiteAndBuByUserName
} from "@/api/qc/qc.js"
import {
uploadSchedulingExcel
} from "../../../api/scheduling/scheduling";
import { downLoadObjectFile } from '@/api/eam/eam_object_list.js'
import axios from 'axios'
import Vue from 'vue'
export default {
data() {
return {
titleCon: '文件导入',
visible: false,
fileList: [],
userBuList: [],
bu: '',
pageData: {
flag: '',
createBy: '',
site: ''
},
}
},
created(){
this.getSiteAndBu()
},
methods: {
// bu
getSiteAndBu () {
let tempData = {
username: this.$store.state.user.name,
}
getSiteAndBuByUserName(tempData).then(({data}) => {
if (data.code === 0) {
this.userBuList = data.rows
}
})
},
//
init(currentRow) {
//
this.pageData = JSON.parse(JSON.stringify(currentRow))
//
this.visible = true;
},
//
beforeUploadHandle(file) {
let extName = file[0].name.substring(file[0].name.lastIndexOf('.')).toLowerCase()
if (!(extName === '.xlsx' || extName === '.xls')) {
this.$message.error('数据导入失败,请选择正确的xlsx模板文件')
return false
}
},
/*选择上传文件时*/
onChange(file){
this.fileList.push(file);
},
/*关闭modal*/
closeDialog(){
this.fileList = [];
//
this.$emit('refreshPageTables');
//
this.visible = false;
},
/*保修当前的数据*/
saveUploadFile(){
if (this.bu==''||this.bu == null){
this.$message.warning("请选择BU!");
return false;
}
/*判断文件是否上传*/
if(null == this.fileList || 0 == this.fileList.length){
this.$message.error("请先上传文件!");
return false;
}
const formData = new FormData();
formData.append("file", this.fileList[0].raw);
formData.append("bu", this.bu);
uploadSchedulingExcel(formData).then(({data}) => {
if (data.code === 0) {
this.$message.success(data.msg);
//
this.$refs.uploadFile.clearFiles();
//
this.closeDialog();
} else {
this.$message.error(data.msg);
}
})
},
//
async downloadFile(){
let file = {
id: 0,
fileName: ''
}
let tempData = {
orderRef1: 'scheduling',
orderRef2: 'schedulingFile'
}
await queryFileId(tempData).then(({data}) => {
if (data && data.code === 0) {
file.id = data.data.id
file.fileName = data.data.fileName
this.$message.success(file)
} else {
this.$alert(data.msg, '错误', {
confirmButtonText: '确定'
})
}
})
await downLoadObjectFile(file).then(({data}) => {
//
const blob = new Blob([data], {type: "application/octet-stream"})
//
const fileName = file.fileName
// a
const linkNode = document.createElement('a')
// adownload
linkNode.download = fileName
linkNode.style.display = 'none'
// Blob URL
linkNode.href = URL.createObjectURL(blob)
document.body.appendChild(linkNode)
//
linkNode.click()
// URL
URL.revokeObjectURL(linkNode.href)
document.body.removeChild(linkNode)
})
}
}
}
</script>
<style scoped lang="scss">
</style>
Loading…
Cancel
Save