新购模板下载和导入
This commit is contained in:
parent
870920f3b4
commit
16a6e7897b
|
|
@ -58,7 +58,23 @@
|
||||||
<el-form-item label="协议号" prop="agreementCode">
|
<el-form-item label="协议号" prop="agreementCode">
|
||||||
<el-input maxlength="50" v-model="queryParams.agreementCode" disabled style="width: 240px"></el-input>
|
<el-input maxlength="50" v-model="queryParams.agreementCode" disabled style="width: 240px"></el-input>
|
||||||
</el-form-item>
|
</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
|
<el-cascader
|
||||||
filterable
|
filterable
|
||||||
collapse-tags
|
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-option v-for="item in typeListDev" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item> -->
|
||||||
<el-form-item label="成套设备" prop="agreementCode">
|
<el-form-item label="成套设备" prop="agreementCode">
|
||||||
<el-select
|
<el-select
|
||||||
clearable
|
clearable
|
||||||
|
|
@ -486,8 +502,11 @@ export default {
|
||||||
|
|
||||||
// 设备 树显示 配置
|
// 设备 树显示 配置
|
||||||
deviceTypeTreeProps: {
|
deviceTypeTreeProps: {
|
||||||
// multiple: true,
|
children: 'children',
|
||||||
|
label: 'label',
|
||||||
|
// multiple: false,
|
||||||
value: 'id',
|
value: 'id',
|
||||||
|
multiple: true,
|
||||||
},
|
},
|
||||||
// 选中的设备类型
|
// 选中的设备类型
|
||||||
deviceType: [],
|
deviceType: [],
|
||||||
|
|
@ -530,16 +549,16 @@ export default {
|
||||||
wholeTypeItemsList: [],
|
wholeTypeItemsList: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
this.GetUserInfo()
|
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.GetDeviceTypeTree()
|
||||||
// this.getList();
|
// this.getList();
|
||||||
|
|
@ -556,16 +575,24 @@ export default {
|
||||||
this.taskId = this.viewTaskId
|
this.taskId = this.viewTaskId
|
||||||
|
|
||||||
if (this.taskId) {
|
if (this.taskId) {
|
||||||
Promise.all([this.GetTaskDetail(this.taskId), this.GetDeviceTypeTree()]).then(() => {
|
console.log("xxxxxxxxxxxxxxxxxxxxx")
|
||||||
let selectList = []
|
// Promise.all([this.GetTaskDetail(this.taskId), this.GetDeviceTypeTree()]).then(() => {
|
||||||
this.leaseApplyDetails.forEach((e) => {
|
// let selectList = []
|
||||||
selectList.push(this.getParentsById(this.deviceTypeTree, e.typeId))
|
// this.leaseApplyDetails.forEach((e) => {
|
||||||
})
|
// selectList.push(this.getParentsById(this.deviceTypeTree, e.typeId))
|
||||||
this.$nextTick(() => {
|
// })
|
||||||
this.deviceType = selectList
|
// console.log("222222222222",selectList)
|
||||||
this.propsKey++
|
// this.$nextTick(() => {
|
||||||
})
|
// this.deviceType = selectList
|
||||||
|
// this.propsKey++
|
||||||
|
|
||||||
|
// })
|
||||||
|
// console.log("1111111111111",this.deviceType)
|
||||||
|
// })
|
||||||
|
await this.GetDeviceTypeTree().then(() => {
|
||||||
|
this.GetTaskDetail(this.taskId)
|
||||||
})
|
})
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
this.GetDeviceTypeTree()
|
this.GetDeviceTypeTree()
|
||||||
}
|
}
|
||||||
|
|
@ -612,7 +639,7 @@ export default {
|
||||||
// 获取 设备树结构数据
|
// 获取 设备树结构数据
|
||||||
async GetDeviceTypeTree() {
|
async GetDeviceTypeTree() {
|
||||||
const params = {
|
const params = {
|
||||||
level: 3,
|
level: 4,
|
||||||
}
|
}
|
||||||
getDeviceTypeTree(params).then((res) => {
|
getDeviceTypeTree(params).then((res) => {
|
||||||
this.deviceTypeTree = res.data
|
this.deviceTypeTree = res.data
|
||||||
|
|
@ -706,6 +733,12 @@ export default {
|
||||||
this.leaseApplyDetails = data.leaseApplyDetails.map((item) => {
|
this.leaseApplyDetails = data.leaseApplyDetails.map((item) => {
|
||||||
return this.handelEchoData(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) {
|
if (data.ctLeaseApplyDetails) {
|
||||||
this.getCtFileList(data.ctLeaseApplyDetails)
|
this.getCtFileList(data.ctLeaseApplyDetails)
|
||||||
|
|
@ -987,12 +1020,12 @@ export default {
|
||||||
},
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
// this.deviceType.forEach((e, index) => {
|
this.deviceType.forEach((e, index) => {
|
||||||
// if (e[3] === row.typeId) {
|
if (e[3] === row.typeId) {
|
||||||
// this.deviceType.splice(index, 1)
|
this.deviceType.splice(index, 1)
|
||||||
// this.propsKey++
|
this.propsKey++
|
||||||
// }
|
}
|
||||||
// })
|
})
|
||||||
this.leaseApplyDetails.splice(row.index, 1)
|
this.leaseApplyDetails.splice(row.index, 1)
|
||||||
},
|
},
|
||||||
/** 导出按钮操作 */
|
/** 导出按钮操作 */
|
||||||
|
|
@ -1012,51 +1045,76 @@ export default {
|
||||||
},
|
},
|
||||||
/////// 设备类型树 切换
|
/////// 设备类型树 切换
|
||||||
deviceTypeChange(val) {
|
deviceTypeChange(val) {
|
||||||
console.log('🚀 ~ deviceTypeChange ~ val:', val)
|
|
||||||
this.queryParams.typeId = ''
|
this.queryParams.typeId = ''
|
||||||
this.typeListDev = []
|
this.typeListDev = []
|
||||||
// console.log('🚀 ~ deviceTypeChange ~ val:', val)
|
|
||||||
this.$nextTick(() => {
|
// this.$nextTick(() => {
|
||||||
const deviceTypeList = this.$refs.deviceTypeCascader.getCheckedNodes()
|
const deviceTypeList = this.$refs.deviceTypeCascader.getCheckedNodes()
|
||||||
console.log('🚀 ~ deviceTypeChange ~ deviceTypeList:', deviceTypeList[0])
|
// this.selectParams = {
|
||||||
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])
|
|
||||||
})
|
|
||||||
|
|
||||||
// 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,
|
// createBy: this.user.name,
|
||||||
// typeId: id,
|
// companyId: deviceTypeList[0].data.companyId,
|
||||||
// num,
|
// // num: deviceTypeList[0].data.num,
|
||||||
// companyId,
|
// typeCn: deviceTypeList[0].data.label,
|
||||||
// unitCn: unitName,
|
// }
|
||||||
// typeCn: deviceTypeList[z].pathLabels[2],
|
// console.log('🚀 ~ deviceTypeChange ~ this.selectParams:', this.selectParams)
|
||||||
// guigeCn: deviceTypeList[z].pathLabels[3],
|
// this.getMaTypeDataByIdFun(val[val.length - 1])
|
||||||
// })
|
// })
|
||||||
// }
|
let tempList = []
|
||||||
// }
|
if (val.length > 0) {
|
||||||
// }
|
const items = val.map((e) => {
|
||||||
// }
|
return e[3]
|
||||||
// console.log('🚀 ~ deviceTypeChange ~ this.leaseApplyDetails:', this.leaseApplyDetails)
|
})
|
||||||
// } else {
|
for (let i in items) {
|
||||||
// this.leaseApplyDetails = []
|
for (let z in deviceTypeList) {
|
||||||
// }
|
if (items[i]===deviceTypeList[z].data.id) {
|
||||||
|
let { num, companyId, id, unitName } = deviceTypeList[z].data
|
||||||
|
|
||||||
|
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) {
|
handelTableItemData(node) {
|
||||||
|
|
@ -1156,27 +1214,27 @@ export default {
|
||||||
console.log('🚀 ~ getMaTypeDataByIdFun ~ res:', res)
|
console.log('🚀 ~ getMaTypeDataByIdFun ~ res:', res)
|
||||||
},
|
},
|
||||||
// 选择规格型号
|
// 选择规格型号
|
||||||
changeType(e) {
|
// changeType(e) {
|
||||||
// console.log('🚀 ~ changeType ~ e:', e)
|
// // console.log('🚀 ~ changeType ~ e:', e)
|
||||||
if (!e) return
|
// if (!e) return
|
||||||
// 获取选中的规格型号
|
// // 获取选中的规格型号
|
||||||
const selectType = this.typeListDev.find((item) => item.id == e)
|
// const selectType = this.typeListDev.find((item) => item.id == e)
|
||||||
console.log('🚀 ~ changeType ~ selectType:', selectType)
|
// console.log('🚀 ~ changeType ~ selectType:', selectType)
|
||||||
this.selectParams.typeId = selectType.id
|
// this.selectParams.typeId = selectType.id
|
||||||
this.selectParams.guigeCn = selectType.name
|
// this.selectParams.guigeCn = selectType.name
|
||||||
this.selectParams.unitCn = selectType.unit
|
// this.selectParams.unitCn = selectType.unit
|
||||||
this.selectParams.num = selectType.num
|
// this.selectParams.num = selectType.num
|
||||||
console.log('🚀 ~ changeType ~ this.selectParams:', this.selectParams)
|
// console.log('🚀 ~ changeType ~ this.selectParams:', this.selectParams)
|
||||||
// 判断是否重复
|
// // 判断是否重复
|
||||||
const isRepeat = this.leaseApplyDetails.find((item) => item.typeId == selectType.id)
|
// const isRepeat = this.leaseApplyDetails.find((item) => item.typeId == selectType.id)
|
||||||
// console.log('🚀 ~ changeType ~ isRepeat:', isRepeat)
|
// // console.log('🚀 ~ changeType ~ isRepeat:', isRepeat)
|
||||||
if (isRepeat) {
|
// if (isRepeat) {
|
||||||
this.$message.error('当前设备已添加,不可重复添加!')
|
// this.$message.error('当前设备已添加,不可重复添加!')
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
this.leaseApplyDetails.unshift({ ...this.selectParams })
|
// this.leaseApplyDetails.unshift({ ...this.selectParams })
|
||||||
console.log('🚀 ~ changeType ~ this.leaseApplyDetails:', this.leaseApplyDetails)
|
// console.log('🚀 ~ changeType ~ this.leaseApplyDetails:', this.leaseApplyDetails)
|
||||||
},
|
// },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -159,10 +159,10 @@
|
||||||
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleSave">保存</el-button>
|
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleSave">保存</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<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>
|
||||||
<el-col :span="1.5">
|
<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-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
|
|
@ -295,6 +295,31 @@
|
||||||
<el-button @click="fileUploadDialog = false">取 消</el-button>
|
<el-button @click="fileUploadDialog = false">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
@ -330,7 +355,10 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
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: {
|
aform: {
|
||||||
checkUrl: '',
|
checkUrl: '',
|
||||||
checkUrlName: '',
|
checkUrlName: '',
|
||||||
|
|
@ -456,6 +484,7 @@ export default {
|
||||||
propsKey: 1000,
|
propsKey: 1000,
|
||||||
fileUploadDialog: false,
|
fileUploadDialog: false,
|
||||||
currentIndex: 0,
|
currentIndex: 0,
|
||||||
|
dialogUpload: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -877,6 +906,58 @@ export default {
|
||||||
item.purveyorId = val
|
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>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue