diff --git a/src/api/business/index.js b/src/api/business/index.js index 467d2c65..8b7c1b67 100644 --- a/src/api/business/index.js +++ b/src/api/business/index.js @@ -123,6 +123,14 @@ export function getEquipmentThreeTypes(query) { }) } +// 业务单号 +export function getCode() { + return request({ + url: '/material/leaseTask/getCode', + method: 'get', + }) +} + // 结算记录查询-列表 export function getSltRecord(query) { return request({ diff --git a/src/api/ma/base.js b/src/api/ma/base.js index cf154e8a..c61a11cd 100644 --- a/src/api/ma/base.js +++ b/src/api/ma/base.js @@ -186,6 +186,14 @@ export function getEquipmentThreeType(query) { }) } +// 物资名称-tree-3 +export function getEquipmentThreeTypeThree() { + return request({ + url: '/material/leaseTask/equipmentThreeType', + method: 'get', + }) +} + // 规格型号-select export function getMaTypeOpt(data) { return request({ diff --git a/src/views/business/businessHandling/index.vue b/src/views/business/businessHandling/index.vue index 6e49d8b3..627443dd 100644 --- a/src/views/business/businessHandling/index.vue +++ b/src/views/business/businessHandling/index.vue @@ -53,6 +53,26 @@ + + + + + + - + @@ -184,22 +204,61 @@ - - {{ isEdit ? '保存' : '发起申请' }} + + {{ isEdit ? '提交' : '发起申请' }} + + 新增条目 + 领料记录查看 + + + 导出工具器清单 + + - - + + + + + + @@ -251,8 +356,10 @@ import { getListsByConfigId, addLeaseTask, editLeaseTask, - getLeaseTaskDetail + getLeaseTaskDetail, + getCode } from '@/api/business/index' +import { getEquipmentThreeTypeThree, getMaTypeOpt } from '@/api/ma/base' import Treeselect from '@riophae/vue-treeselect' import '@riophae/vue-treeselect/dist/vue-treeselect.css' @@ -303,10 +410,17 @@ export default { maForm: { unitId: undefined, projectId: undefined, - arrivalTime: '', - applyCode: '', // 采购申请编号 + code: '', // 采购申请编号 + supplierTime: '', // 供货时间 + supplierPlace: '', // 供货地点 bmFileInfos: [] // 附件 }, + pickerOptions: { + disabledDate(time) { + // 禁用今天之前的日期 + return time.getTime() < Date.now() - 86400000 // 86400000 是一天的毫秒数 + } + }, // 表单参数 form: {}, defaultProps: { @@ -344,10 +458,17 @@ export default { trigger: 'blur' } ], - applyCode: [ + supplierTime: [ { required: true, - message: '请输入采购申请编号', + message: '请选择供货时间', + trigger: 'blur' + } + ], + supplierPlace: [ + { + required: true, + message: '请输入供货地点', trigger: 'blur' } ], @@ -359,6 +480,20 @@ export default { } ] }, + maTypeList: [], // 类型名称 + // 规格型号 + typeList: [], + dialogVisible: false, // 弹框 + // 弹框表单 + dialogForm: {}, + // 弹框表头 + dialogColumns: [ + { label: '类型名称', prop: 'maTypeName' }, + { label: '规格型号', prop: 'typeName' }, + { label: '计量单位', prop: 'unitName' }, + { label: '预领数量', prop: 'preNum' }, + { label: '备注', prop: 'remark' } + ], deviceTypeTreeProps: { children: 'children', label: 'typeName', @@ -408,6 +543,7 @@ export default { } }, created() { + // getCode() if (this.$route.query.type == 'edit') { this.isEdit = true this.isDetail = false @@ -430,6 +566,7 @@ export default { this.projectInfoList() //单位工程下拉选 this.equipmentType() //机具类型下拉选 this.getStandardConfigList() // 标准配置下拉选 + this.getMaTypeNameOpt() // 类型名称下拉选 if (this.isEdit || this.isDetail) { console.log('isEdit', this.isEdit) this.getTaskInfo() @@ -438,6 +575,64 @@ export default { console.log(this.$route.query, 'this.$route.query') }, methods: { + // 获取类型名称-tree + async getMaTypeNameOpt() { + try { + const res = await getEquipmentThreeTypeThree() + console.log('🚀 ~ getEquipmentThreeTypeThree ~ res:', res) + const filterData = (data, level = 1) => { + return data.map(item => { + if (level < 3 && item.children && item.children.length) { + item.children = filterData(item.children, level + 1) + } else { + delete item.children + } + return item + }) + } + this.maTypeList = filterData(res.data) + console.log('🚀 ~ this.maTypeList:', this.maTypeList) + } catch (error) { + console.log('🚀 ~ error:', error) + } + }, + // 获取规格型号 + async getTypeList(row, typeIds) { + // console.log('🚀 ~ getTypeList ~ row:', row) + // console.log('🚀 ~ getTypeList ~ typeId:', typeIds[typeIds.length - 1]) + // 递归循环 获取类型名称 + const filterData = data => { + data.forEach(item => { + if (item.typeId === typeIds[typeIds.length - 1]) { + row.maTypeName = item.typeName + } else { + if (item.children && item.children.length) { + filterData(item.children) + } + } + }) + } + filterData(this.maTypeList) + console.log('🚀 ~ getTypeList ~ maType:', row) + row.typeId = '' + row.unitName = '' + try { + const res = await getMaTypeOpt({ typeId: typeIds[typeIds.length - 1] }) + // console.log('🚀 ~ getMaTypeOpt ~ res:', res) + this.typeList = res.data + } catch (error) { + console.log('🚀 ~ error:', error) + } + }, + // + changeTypeName(row, val) { + // console.log('🚀 ~ changeTypeName ~ row:', row) + // console.log('🚀 ~ changeTypeName ~ val:', val) + const type = this.typeList.find(item => item.typeId === val) + // console.log('🚀 ~ changeTypeName ~ type:', type) + row.unitName = type.unitName + row.typeName = type.name + }, // 获取标准配置 async getStandardConfigList() { try { @@ -464,6 +659,8 @@ export default { } }, uniteChange(val) { + // console.log('🚀 ~ uniteChange ~ val:', val) + this.maForm.unitName = val.name if (val.typeKey == 'fbs') { this.isFileFbs = true this.rules['bmFileInfos'][0].required = true @@ -479,6 +676,7 @@ export default { }, 500) }, projectChange(val) { + this.maForm.projectName = val.name setTimeout(() => { // projectId: this.maForm.projectId getListUnite({}).then(response => { @@ -601,10 +799,12 @@ export default { type: 'warning' }) this.tempDeviceType = this.tempDeviceType.filter(id => id !== lastSelected) - } else if (typeData.storageNum <= 0) { - this.$message.error('所选物资规格类型暂时无库存,无法申请!') - this.tempDeviceType = this.tempDeviceType.filter(id => id !== lastSelected) - } else { + } + // else if (typeData.storageNum <= 0) { + // this.$message.error('所选物资规格类型暂时无库存,无法申请!') + // this.tempDeviceType = this.tempDeviceType.filter(id => id !== lastSelected) + // } + else { // 将新项添加到数组开头,实现倒序 this.equipmentList.unshift({ ...typeData, @@ -662,6 +862,20 @@ export default { }, // 多选框选中数据 handleSelectionChange() {}, + + // 新增条目 + addColumns() { + // 头部新增一天空数据 + this.equipmentList.push({ + isManual: 1, + maTypeIds: [], + maTypeName: '', + typeId: '', + typeName: '', + preNum: 0, + remark: '' + }) + }, /** 保存按钮操作 */ handleSave() { // console.log(this.equipmentList) @@ -674,71 +888,81 @@ export default { this.$message.error(`第 ${i + 1} 行的 ${'预领数量必须大于0'} `) return } - if (this.equipmentList[i].preNum > this.equipmentList[i].storageNum) { - this.$message.error(`第 ${i + 1} 行的 ${'预领数量不可大于库存量'} `) - return - } + // if (this.equipmentList[i].preNum > this.equipmentList[i].storageNum) { + // this.$message.error(`第 ${i + 1} 行的 ${'预领数量不可大于库存量'} `) + // return + // } } - await getAgreement({ - unitId: this.maForm.unitId, - projectId: this.maForm.projectId - }).then(response => { - this.agreementId = response.data.agreementId - this.maForm.agreementId = this.agreementId - }) - await this.$modal - .confirm('是否确认保存当前页面') - .then(async () => { - if (this.isEdit) { - try { - const res = await editLeaseTask({ - leaseApplyDetailsList: this.equipmentList, - leaseApplyInfo: this.maForm - }) - if (res.code === 200) { - this.$modal.msgSuccess('编辑成功') - // 关闭页面 - this.$tab.closePage() - } - this.loading = false - } catch (error) { - console.log('🚀 ~ error:', error) - this.loading = false - } - } else if (!this.isEdit) { - console.log('新增') - console.log(this.equipmentList) - this.loading = true - try { - const res = await addLeaseTask({ - leaseApplyDetailsList: this.equipmentList, - leaseApplyInfo: this.maForm - }) - if (res.code === 200) { - this.$modal.msgSuccess('新增成功') - this.$refs['maForm'].resetFields() - this.equipmentList = [] - } - this.loading = false - } catch (error) { - console.log('🚀 ~ error:', error) - this.loading = false - } - } - }) - .catch(() => {}) + // 获取业务单号 + const res = await getCode() + console.log('🚀 ~ handleSave ~ res:', res) + if (res.code === 200) { + this.maForm.code = res.data.taskCode + } + // 打开弹框 + this.dialogVisible = true } }) } else { this.$modal.msgError('请先添加类型规格') } }, + // 确认 + async handleConfirm(type) { + await getAgreement({ + unitId: this.maForm.unitId, + projectId: this.maForm.projectId + }).then(response => { + this.agreementId = response.data.agreementId + this.maForm.agreementId = this.agreementId + }) + await this.$modal + .confirm(type == 0 ? '是否确认提交' : '是否确认保存') + .then(async () => { + const params = { + leaseApplyDetailsList: this.equipmentList, + leaseApplyInfo: this.maForm, + statusFlag: type + } + if (this.isEdit) { + try { + const res = await editLeaseTask(params) + if (res.code === 200) { + this.$modal.msgSuccess('操作成功') + // 关闭页面 + this.$tab.closePage() + } + this.loading = false + } catch (error) { + console.log('🚀 ~ error:', error) + this.loading = false + } + } else if (!this.isEdit) { + console.log('新增') + console.log(this.equipmentList) + try { + const res = await addLeaseTask(params) + if (res.code === 200) { + this.$modal.msgSuccess('操作成功') + this.$refs['maForm'].resetFields() + this.equipmentList = [] + // 关闭弹框 + this.dialogVisible = false + } + } catch (error) { + console.log('🚀 ~ error:', error) + } + } + }) + .catch(() => {}) + }, /** 删除按钮操作 */ - handleDelete(row) { + handleDelete(index, row) { + console.log('🚀 ~ handleDelete ~ row:', row) this.$modal .confirm('是否确认删除所选择的数据项?') .then(() => { - this.equipmentList = this.equipmentList.filter(item => item.typeId !== row.typeId) + this.equipmentList.splice(index, 1) // 更新实际存储的选中值 this.deviceType = this.equipmentList.map(item => item.typeId) }) @@ -784,7 +1008,7 @@ export default { } }) this.maForm.bmFileInfos = fileList - console.log('🚀 ~ handleChangeBusinessList ~ this.bmFileInfos:', this.bmFileInfos) + // console.log('🚀 ~ handleChangeBusinessList ~ this.bmFileInfos:', this.bmFileInfos) // 手动触发表单验证 this.$refs.maForm.validateField('bmFileInfos') }, @@ -931,6 +1155,18 @@ export default { if (optionDom) { optionDom.scrollIntoView({ block: 'center', behavior: 'smooth' }) } + }, + // 导出数据 + handleExport() { + try { + let fileName = `工器具清单_${new Date().getTime()}.xLsx` + let url = '/material/leaseTask/export' + const params = { ...this.queryParams } + console.log('🚀 ~ 导出 ~ params:', params) + this.download(url, params, fileName) + } catch (error) { + console.log('导出数据失败', error) + } } }, // 添加组件销毁时的清理 diff --git a/src/views/business/businessHandlingRecord/index.vue b/src/views/business/businessHandlingRecord/index.vue index cf7772fa..6aae8086 100644 --- a/src/views/business/businessHandlingRecord/index.vue +++ b/src/views/business/businessHandlingRecord/index.vue @@ -72,6 +72,7 @@ 已完成 + 待提交 @@ -79,7 +80,7 @@