新购模板下载和导入
This commit is contained in:
parent
870920f3b4
commit
16a6e7897b
|
|
@ -58,7 +58,23 @@
|
|||
<el-form-item label="协议号" prop="agreementCode">
|
||||
<el-input maxlength="50" v-model="queryParams.agreementCode" disabled style="width: 240px"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型名称" prop="status">
|
||||
<el-form-item label="规格型号" prop="equipmentId">
|
||||
<el-cascader
|
||||
:key="propsKey"
|
||||
v-model="deviceType"
|
||||
:show-all-levels="false"
|
||||
:options="deviceTypeTree"
|
||||
:props="deviceTypeTreeProps"
|
||||
filterable
|
||||
collapse-tags
|
||||
style="width: 240px"
|
||||
placeholder="请选择规格型号"
|
||||
ref="deviceTypeCascader"
|
||||
popper-class="popper-select"
|
||||
@change="deviceTypeChange"
|
||||
></el-cascader>
|
||||
</el-form-item>
|
||||
<!-- <el-form-item label="类型名称" prop="status">
|
||||
<el-cascader
|
||||
filterable
|
||||
collapse-tags
|
||||
|
|
@ -85,7 +101,7 @@
|
|||
>
|
||||
<el-option v-for="item in typeListDev" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form-item> -->
|
||||
<el-form-item label="成套设备" prop="agreementCode">
|
||||
<el-select
|
||||
clearable
|
||||
|
|
@ -486,8 +502,11 @@ export default {
|
|||
|
||||
// 设备 树显示 配置
|
||||
deviceTypeTreeProps: {
|
||||
// multiple: true,
|
||||
value: 'id',
|
||||
children: 'children',
|
||||
label: 'label',
|
||||
// multiple: false,
|
||||
value: 'id',
|
||||
multiple: true,
|
||||
},
|
||||
// 选中的设备类型
|
||||
deviceType: [],
|
||||
|
|
@ -530,16 +549,16 @@ export default {
|
|||
wholeTypeItemsList: [],
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.GetUserInfo()
|
||||
async mounted() {
|
||||
await this.GetUserInfo()
|
||||
|
||||
this.GetUnitData()
|
||||
await this.GetUnitData()
|
||||
|
||||
this.GetProData()
|
||||
await this.GetProData()
|
||||
|
||||
this.getCostBearingFun()
|
||||
await this.getCostBearingFun()
|
||||
|
||||
this.getHoldingPoleSelListData()
|
||||
await this.getHoldingPoleSelListData()
|
||||
|
||||
// this.GetDeviceTypeTree()
|
||||
// this.getList();
|
||||
|
|
@ -556,16 +575,24 @@ export default {
|
|||
this.taskId = this.viewTaskId
|
||||
|
||||
if (this.taskId) {
|
||||
Promise.all([this.GetTaskDetail(this.taskId), this.GetDeviceTypeTree()]).then(() => {
|
||||
let selectList = []
|
||||
this.leaseApplyDetails.forEach((e) => {
|
||||
selectList.push(this.getParentsById(this.deviceTypeTree, e.typeId))
|
||||
})
|
||||
this.$nextTick(() => {
|
||||
this.deviceType = selectList
|
||||
this.propsKey++
|
||||
})
|
||||
console.log("xxxxxxxxxxxxxxxxxxxxx")
|
||||
// Promise.all([this.GetTaskDetail(this.taskId), this.GetDeviceTypeTree()]).then(() => {
|
||||
// let selectList = []
|
||||
// this.leaseApplyDetails.forEach((e) => {
|
||||
// selectList.push(this.getParentsById(this.deviceTypeTree, e.typeId))
|
||||
// })
|
||||
// console.log("222222222222",selectList)
|
||||
// this.$nextTick(() => {
|
||||
// this.deviceType = selectList
|
||||
// this.propsKey++
|
||||
|
||||
// })
|
||||
// console.log("1111111111111",this.deviceType)
|
||||
// })
|
||||
await this.GetDeviceTypeTree().then(() => {
|
||||
this.GetTaskDetail(this.taskId)
|
||||
})
|
||||
|
||||
} else {
|
||||
this.GetDeviceTypeTree()
|
||||
}
|
||||
|
|
@ -612,7 +639,7 @@ export default {
|
|||
// 获取 设备树结构数据
|
||||
async GetDeviceTypeTree() {
|
||||
const params = {
|
||||
level: 3,
|
||||
level: 4,
|
||||
}
|
||||
getDeviceTypeTree(params).then((res) => {
|
||||
this.deviceTypeTree = res.data
|
||||
|
|
@ -706,6 +733,12 @@ export default {
|
|||
this.leaseApplyDetails = data.leaseApplyDetails.map((item) => {
|
||||
return this.handelEchoData(item)
|
||||
})
|
||||
let selectList = []
|
||||
this.leaseApplyDetails.forEach((e) => {
|
||||
selectList.push(this.getParentsById(this.deviceTypeTree, e.typeId))
|
||||
})
|
||||
this.deviceType = selectList
|
||||
this.propsKey++
|
||||
|
||||
if (data.ctLeaseApplyDetails) {
|
||||
this.getCtFileList(data.ctLeaseApplyDetails)
|
||||
|
|
@ -987,12 +1020,12 @@ export default {
|
|||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
// this.deviceType.forEach((e, index) => {
|
||||
// if (e[3] === row.typeId) {
|
||||
// this.deviceType.splice(index, 1)
|
||||
// this.propsKey++
|
||||
// }
|
||||
// })
|
||||
this.deviceType.forEach((e, index) => {
|
||||
if (e[3] === row.typeId) {
|
||||
this.deviceType.splice(index, 1)
|
||||
this.propsKey++
|
||||
}
|
||||
})
|
||||
this.leaseApplyDetails.splice(row.index, 1)
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
|
|
@ -1012,51 +1045,76 @@ export default {
|
|||
},
|
||||
/////// 设备类型树 切换
|
||||
deviceTypeChange(val) {
|
||||
console.log('🚀 ~ deviceTypeChange ~ val:', val)
|
||||
this.queryParams.typeId = ''
|
||||
this.typeListDev = []
|
||||
// console.log('🚀 ~ deviceTypeChange ~ val:', val)
|
||||
this.$nextTick(() => {
|
||||
|
||||
// this.$nextTick(() => {
|
||||
const deviceTypeList = this.$refs.deviceTypeCascader.getCheckedNodes()
|
||||
console.log('🚀 ~ deviceTypeChange ~ deviceTypeList:', deviceTypeList[0])
|
||||
this.selectParams = {
|
||||
createBy: this.user.name,
|
||||
companyId: deviceTypeList[0].data.companyId,
|
||||
// num: deviceTypeList[0].data.num,
|
||||
typeCn: deviceTypeList[0].data.label,
|
||||
}
|
||||
console.log('🚀 ~ deviceTypeChange ~ this.selectParams:', this.selectParams)
|
||||
this.getMaTypeDataByIdFun(val[val.length - 1])
|
||||
})
|
||||
// this.selectParams = {
|
||||
// createBy: this.user.name,
|
||||
// companyId: deviceTypeList[0].data.companyId,
|
||||
// // num: deviceTypeList[0].data.num,
|
||||
// typeCn: deviceTypeList[0].data.label,
|
||||
// }
|
||||
// console.log('🚀 ~ deviceTypeChange ~ this.selectParams:', this.selectParams)
|
||||
// this.getMaTypeDataByIdFun(val[val.length - 1])
|
||||
// })
|
||||
let tempList = []
|
||||
if (val.length > 0) {
|
||||
const items = val.map((e) => {
|
||||
return e[3]
|
||||
})
|
||||
for (let i in items) {
|
||||
for (let z in deviceTypeList) {
|
||||
if (items[i]===deviceTypeList[z].data.id) {
|
||||
let { num, companyId, id, unitName } = deviceTypeList[z].data
|
||||
|
||||
// if (val.length > 0) {
|
||||
// const items = val.map((e) => {
|
||||
// return e[3]
|
||||
// })
|
||||
// for (let i in items) {
|
||||
// for (let z in deviceTypeList) {
|
||||
// if (deviceTypeList[z].data.id === items[i]) {
|
||||
// let { num, companyId, id, unitName } = deviceTypeList[z].data
|
||||
|
||||
// const isRepeat = this.leaseApplyDetails.some((e) => e.typeId === id)
|
||||
// if (!isRepeat) {
|
||||
// this.leaseApplyDetails.push({
|
||||
// createBy: this.user.name,
|
||||
// typeId: id,
|
||||
// num,
|
||||
// companyId,
|
||||
// unitCn: unitName,
|
||||
// typeCn: deviceTypeList[z].pathLabels[2],
|
||||
// guigeCn: deviceTypeList[z].pathLabels[3],
|
||||
// })
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// console.log('🚀 ~ deviceTypeChange ~ this.leaseApplyDetails:', this.leaseApplyDetails)
|
||||
// } else {
|
||||
// this.leaseApplyDetails = []
|
||||
// }
|
||||
const isRepeat = this.leaseApplyDetails.some((e) => e.typeId === id)
|
||||
if (!isRepeat) {
|
||||
this.leaseApplyDetails.unshift({
|
||||
createBy: this.user.name,
|
||||
typeId: id,
|
||||
num,
|
||||
companyId,
|
||||
unitCn: unitName,
|
||||
typeCn: deviceTypeList[z].pathLabels[2],
|
||||
guigeCn: deviceTypeList[z].pathLabels[3],
|
||||
})
|
||||
let obj = {
|
||||
createBy: this.user.name,
|
||||
typeId: id,
|
||||
num,
|
||||
companyId,
|
||||
unitCn: unitName,
|
||||
typeCn: deviceTypeList[z].pathLabels[2],
|
||||
guigeCn: deviceTypeList[z].pathLabels[3],
|
||||
}
|
||||
tempList.unshift(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const newDataListNew = [...this.leaseApplyDetails, ...tempList]
|
||||
const map = new Map()
|
||||
for (let item of newDataListNew) {
|
||||
if (!map.has(item.typeId)) {
|
||||
map.set(item.typeId, item)
|
||||
}
|
||||
}
|
||||
const newArray = [...map.values()]
|
||||
let newArray_array = []
|
||||
newArray.forEach((e) => {
|
||||
items.forEach((j) => {
|
||||
if (e.typeId==j) {
|
||||
newArray_array.push(e)
|
||||
}
|
||||
})
|
||||
})
|
||||
this.leaseApplyDetails = newArray_array
|
||||
} else {
|
||||
console.log("yyyyyyyyyyyyy")
|
||||
this.leaseApplyDetails = []
|
||||
}
|
||||
},
|
||||
//// 将数据处理成 表格中需要的数据
|
||||
handelTableItemData(node) {
|
||||
|
|
@ -1156,27 +1214,27 @@ export default {
|
|||
console.log('🚀 ~ getMaTypeDataByIdFun ~ res:', res)
|
||||
},
|
||||
// 选择规格型号
|
||||
changeType(e) {
|
||||
// console.log('🚀 ~ changeType ~ e:', e)
|
||||
if (!e) return
|
||||
// 获取选中的规格型号
|
||||
const selectType = this.typeListDev.find((item) => item.id == e)
|
||||
console.log('🚀 ~ changeType ~ selectType:', selectType)
|
||||
this.selectParams.typeId = selectType.id
|
||||
this.selectParams.guigeCn = selectType.name
|
||||
this.selectParams.unitCn = selectType.unit
|
||||
this.selectParams.num = selectType.num
|
||||
console.log('🚀 ~ changeType ~ this.selectParams:', this.selectParams)
|
||||
// 判断是否重复
|
||||
const isRepeat = this.leaseApplyDetails.find((item) => item.typeId == selectType.id)
|
||||
// console.log('🚀 ~ changeType ~ isRepeat:', isRepeat)
|
||||
if (isRepeat) {
|
||||
this.$message.error('当前设备已添加,不可重复添加!')
|
||||
return
|
||||
}
|
||||
this.leaseApplyDetails.unshift({ ...this.selectParams })
|
||||
console.log('🚀 ~ changeType ~ this.leaseApplyDetails:', this.leaseApplyDetails)
|
||||
},
|
||||
// changeType(e) {
|
||||
// // console.log('🚀 ~ changeType ~ e:', e)
|
||||
// if (!e) return
|
||||
// // 获取选中的规格型号
|
||||
// const selectType = this.typeListDev.find((item) => item.id == e)
|
||||
// console.log('🚀 ~ changeType ~ selectType:', selectType)
|
||||
// this.selectParams.typeId = selectType.id
|
||||
// this.selectParams.guigeCn = selectType.name
|
||||
// this.selectParams.unitCn = selectType.unit
|
||||
// this.selectParams.num = selectType.num
|
||||
// console.log('🚀 ~ changeType ~ this.selectParams:', this.selectParams)
|
||||
// // 判断是否重复
|
||||
// const isRepeat = this.leaseApplyDetails.find((item) => item.typeId == selectType.id)
|
||||
// // console.log('🚀 ~ changeType ~ isRepeat:', isRepeat)
|
||||
// if (isRepeat) {
|
||||
// this.$message.error('当前设备已添加,不可重复添加!')
|
||||
// return
|
||||
// }
|
||||
// this.leaseApplyDetails.unshift({ ...this.selectParams })
|
||||
// console.log('🚀 ~ changeType ~ this.leaseApplyDetails:', this.leaseApplyDetails)
|
||||
// },
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -159,10 +159,10 @@
|
|||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleSave">保存</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-download" size="mini" >模板下载</el-button>
|
||||
<el-button type="success" plain icon="el-icon-download" size="mini" @click="downloadModel">模板下载</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button type="success" plain icon="el-icon-upload2" size="mini" >模板上传</el-button>
|
||||
<el-button type="success" plain icon="el-icon-upload2" size="mini" @click="uploadModel">模板上传</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
|
|
@ -295,6 +295,31 @@
|
|||
<el-button @click="fileUploadDialog = false">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
title="模板上传"
|
||||
:visible.sync="dialogUpload"
|
||||
width="400px"
|
||||
append-to-body
|
||||
>
|
||||
<template >
|
||||
<el-upload
|
||||
class="upload-demo"
|
||||
drag
|
||||
:action="actionUrl"
|
||||
:headers="headers"
|
||||
:on-success="handleUploadSuccess"
|
||||
:accept="'.xlsx'"
|
||||
:before-upload="beforeUpload"
|
||||
:auto-upload="true"
|
||||
:show-file-list="false"
|
||||
>
|
||||
<i class="el-icon-upload"></i>
|
||||
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||
<div class="el-upload__tip" slot="tip">只能上传xlsx文件</div>
|
||||
</el-upload>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -330,7 +355,10 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
actionUrl: process.env.VUE_APP_BASE_API + '/system/sys/file/upload',
|
||||
actionUrl: process.env.VUE_APP_BASE_API + '/material/purchaseCheckInfo/importData',
|
||||
headers: {
|
||||
Authorization: 'Bearer ' + localStorage.getItem('token'),
|
||||
},
|
||||
aform: {
|
||||
checkUrl: '',
|
||||
checkUrlName: '',
|
||||
|
|
@ -456,6 +484,7 @@ export default {
|
|||
propsKey: 1000,
|
||||
fileUploadDialog: false,
|
||||
currentIndex: 0,
|
||||
dialogUpload: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -877,6 +906,58 @@ export default {
|
|||
item.purveyorId = val
|
||||
})
|
||||
},
|
||||
/** 模板下载 */
|
||||
downloadModel() {
|
||||
const params = {params:JSON.stringify(this.queryParams)}
|
||||
this.download(
|
||||
'material/purchaseCheckInfo/downLoadTypeModel',
|
||||
{...params,},
|
||||
`模板下载_${new Date().getTime()}.xlsx`,
|
||||
)
|
||||
|
||||
},
|
||||
uploadModel() {
|
||||
this.dialogUpload = true
|
||||
},
|
||||
beforeUpload(file) {
|
||||
const fileType = file.name.split('.').pop().toLowerCase();
|
||||
if (fileType!== 'xls' && fileType!== 'xlsx') {
|
||||
this.$message.error('只能上传 Excel 文件(.xls 或 .xlsx)');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
handleUploadSuccess(response, file, fileList) {
|
||||
if (response.code == 200) {
|
||||
this.$message.success('文件上传成功');
|
||||
this.dialogUpload = false; // 上传成功后关闭弹窗
|
||||
response.data.forEach((item) => {
|
||||
this.equipmentList.push({
|
||||
machineTypeName: item.typeName,
|
||||
specificationType: item.modelName,
|
||||
typeId: item.typeId,
|
||||
unitName: item.unitName,
|
||||
supplierId: this.queryParams.supplierId? this.queryParams.supplierId : '',
|
||||
createTime: null,
|
||||
productionTime: this.queryParams.productionTime? this.queryParams.productionTime : '',
|
||||
purchasePrice: 0,
|
||||
purchaseNum: '',
|
||||
purveyorId: this.queryParams.purveyorId? this.queryParams.purveyorId : '',
|
||||
checkUrl: '',
|
||||
checkUrlName: '',
|
||||
fileList: [],
|
||||
})
|
||||
// 获取新增项的层级路径
|
||||
const path = this.getParentsById(this.equipmentTypeList, item.typeId);
|
||||
if (path) {
|
||||
this.deviceType.push(path);
|
||||
}
|
||||
})
|
||||
|
||||
} else {
|
||||
this.$message.error('文件上传失败');
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in New Issue