入库管理

This commit is contained in:
bb_pan 2025-12-23 17:52:01 +08:00
parent df25270f48
commit 10c6840eb9
8 changed files with 2995 additions and 21 deletions

View File

@ -265,3 +265,30 @@ export const getEquipmentPropertyTypeApi = (typeId) => {
method: 'GET',
})
}
// 入库申请/审核-列表
export const getWarehousingListApi = (data) => {
return request({
url: '/material-mall/warehousing/list',
method: 'GET',
params: data
})
}
// 入库申请-暂存
export const addWarehousingApi = (data) => {
return request({
url: '/material-mall/warehousing/add',
method: 'POST',
data
})
}
// 入库申请-暂存更新
export const updateWarehousingApi = (data) => {
return request({
url: '/material-mall/warehousing/updateById',
method: 'POST',
data
})
}

View File

@ -17,7 +17,7 @@
: variables.menuLightColor
"
:unique-opened="true"
active-text-color="#fff"
active-text-color="#00a288"
:collapse-transition="false"
mode="vertical"
>
@ -134,6 +134,6 @@ export default {
color: inherit !important;
}
::v-deep .el-menu-item.is-active {
background-color: #EA7F31 !important;
background-color: #FFFFFFCC !important;
}
</style>

View File

@ -0,0 +1,138 @@
<template>
<div class="app-container">
<GoBack :title="'入库申请'" @goBack="goBack" />
<el-tabs v-model="activeName" @tab-click="handleClick" :before-leave="beforeClick">
<el-tab-pane label="装备" name="equip"></el-tab-pane>
<el-tab-pane label="数量工具" name="toolNum"></el-tab-pane>
<el-tab-pane label="编码工具" name="toolCode"></el-tab-pane>
</el-tabs>
<component ref="componentRef" :is="isShowComponent" @isSubmit="isSubmit" />
</div>
</template>
<script>
import GoBack from '@/components/GoBack'
import EquipmentAdd from '@/views/stockManagement/entryApply/components/EquipmentAdd'
import AddNum from '@/views/stockManagement/entryApply/components/AddNum'
import AddCode from '@/views/stockManagement/entryApply/components/AddCode'
export default {
name: 'ApplyDetails',
components: {
GoBack,
EquipmentAdd,
AddNum,
AddCode,
},
data() {
return {
isShowComponent: 'EquipmentAdd',
activeName: 'equip',
}
},
created() {
let title = '新增'
const routerParams = this.$route.query
if (routerParams.isEdit) {
title = '编辑'
}
const obj = Object.assign({}, this.$route, { title })
this.$tab.updatePage(obj)
},
methods: {
goBack() {
this.$router.push({ path: '/stockManagement/entryApply' }).then(() => {
this.$tab.closePage({ path: '/stockManagement/entryApply/apply' })
})
},
beforeClick(activeName, oldActiveName) {
console.log('🚀 ~ oldActiveName:', oldActiveName)
console.log('🚀 ~ activeName:', activeName)
// this.$refs.componentRef
console.log('🚀 ~ this.$refs.componentRef:', this.$refs.componentRef)
// tab
if (activeName === oldActiveName) return true
let isEmpty = false
let allHasOrderId = false
if (oldActiveName == 'equip') {
const tableList = this.$refs.componentRef.tableData || []
isEmpty = tableList.length === 0
allHasOrderId = tableList.every((item) => !!item.orderId)
} else if (oldActiveName == 'toolNum') {
const tableList = this.$refs.componentRef.dialogList || []
isEmpty = tableList.length === 0
allHasOrderId = tableList.every((item) => !!item.applyId)
} else if (oldActiveName == 'toolCode') {
const tableList = this.$refs.componentRef.dialogList || []
isEmpty = tableList.length === 0
allHasOrderId = tableList.every((item) => !!item.applyId)
}
console.log('🚀 ~ isEmpty:', isEmpty)
console.log('🚀 ~ allHasOrderId:', allHasOrderId)
if (isEmpty || allHasOrderId) {
if (activeName == 'equip') {
this.isShowComponent = 'EquipmentAdd'
} else if (activeName == 'toolNum') {
this.isShowComponent = 'AddNum'
} else if (activeName == 'toolCode') {
this.isShowComponent = 'AddCode'
}
return true
}
return this.confirmLeave().then(async (res) => {
console.log('🚀 ~ res-确定保存:', res)
console.log('🚀 ~ 确定保存-->>>:')
if (!res) {
if (activeName == 'equip') {
this.isShowComponent = 'EquipmentAdd'
} else if (activeName == 'toolNum') {
this.isShowComponent = 'AddNum'
} else if (activeName == 'toolCode') {
this.isShowComponent = 'AddCode'
}
return
}
if (oldActiveName == 'equip') {
//
// this.$refs.componentRef.submit()
} else if (oldActiveName == 'toolNum') {
} else if (oldActiveName == 'code') {
}
})
},
confirmLeave(message = '是否暂存已添加的装备?', title = '提示') {
return new Promise((resolve, reject) => {
this.$confirm(message, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
console.log('用户点击「确定」')
resolve(true)
})
.catch(() => {
console.log('用户点击「取消」')
resolve(false)
})
})
},
handleClick(tab, event) {
console.log('🚀 ~ tab, event:', tab.index)
// if (tab.index == 0) {
// this.isShowComponent = 'EquipmentAdd'
// } else if (tab.index == 1) {
// this.isShowComponent = 'AddNum'
// } else if (tab.index == 2) {
// this.isShowComponent = 'AddCode'
// }
},
isSubmit(val) {
console.log('🚀 ~ val:', val)
},
},
}
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,653 @@
<template>
<div>
<el-card style="margin-bottom: 20px">
<el-form
ref="dialogForm"
:model="dialogForm"
:rules="rules"
size="small"
inline
@submit.native.prevent
style="height: 32px"
>
<el-form-item label="规格型号">
<el-cascader
v-model="typeIdList"
:options="options"
:props="{ value: 'typeId', label: 'typeName' }"
clearable
@change="handleChange"
style="width: 240px"
/>
</el-form-item>
<!-- 厂家 -->
<el-form-item label="生产厂家" prop="supplierId">
<div>
<i
class="el-icon-circle-plus-outline"
style="color: #13ce66; margin-right: 5px; cursor: pointer"
@click="openAddress"
/>
<el-select v-model="dialogForm.supplierId" placeholder="请选择厂家" clearable style="width: 240px">
<el-option
v-for="item in manufacturerSelect"
:key="item.id"
:label="item.label"
:value="item.id"
></el-option>
</el-select>
</div>
</el-form-item>
<!-- 出厂日期 -->
<el-form-item label="出厂日期" prop="productionDate">
<el-date-picker
v-model="dialogForm.productionDate"
type="date"
clearable
placeholder="选择出厂日期"
value-format="yyyy-MM-dd"
style="width: 240px"
/>
</el-form-item>
<!-- 申请数量 -->
<el-form-item label="申请数量" prop="applyNum">
<el-input-number
v-model="dialogForm.applyNum"
:min="1"
:max="9999"
:controls="false"
placeholder="请输入申请数量"
style="width: 240px"
/>
</el-form-item>
<el-form-item style="float: right">
<el-button type="primary" icon="el-icon-plus" :disabled="typeIdList.length == 0" @click="handleAdd"
>点击填充</el-button
>
</el-form-item>
</el-form>
</el-card>
<el-card v-loading="isLoading">
<el-row :gutter="10" class="mb8" justify="end">
<el-col :span="24" style="display: flex; justify-content: flex-end">
<el-button type="primary" :disabled="dialogList.length == 0" @click="submit">暂存</el-button>
</el-col>
</el-row>
<el-table :data="dialogList" border stripe highlight-current-row height="546" style="width: 100%">
<el-table-column type="index" width="55" label="序号" align="center" />
<el-table-column
v-for="(column, index) in dialogColumns"
:width="column.width"
:show-overflow-tooltip="!column.unShowTooltip"
:key="index"
:label="column.label"
:prop="column.prop"
align="center"
>
<!-- 插槽 -->
<template #header>
<span>
<span v-if="column.required" style="color: red">*</span>
{{ column.label }}
</span>
</template>
<template v-slot="{ row }">
<el-select
v-if="column.prop == 'supplierId'"
v-model="row.supplierId"
placeholder="请选择厂家"
style="width: 150px"
>
<el-option
v-for="item in manufacturerSelect"
:key="item.id"
:label="item.label"
:value="item.id"
></el-option>
</el-select>
<el-date-picker
v-else-if="column.prop == 'productionDate'"
v-model="row.productionDate"
type="date"
clearable
placeholder="选择出厂日期"
value-format="yyyy-MM-dd"
style="width: 150px"
/>
<el-input
v-else-if="column.prop == 'originCost'"
v-model="row.originCost"
placeholder="请输入"
maxlength="9999"
@input="handlePriceInput(row)"
style="width: 120px"
/>
<el-input
v-else-if="column.prop == 'identifyCode'"
v-model="row.identifyCode"
placeholder="请输入"
maxlength="999"
style="width: 120px"
/>
<span v-else-if="column.prop == 'fileList'">
<span style="color: #00a288; cursor: pointer" @click="handleFileListUpload(row)">报告管理</span>
</span>
<!-- 其他列默认显示文本 -->
<span v-else>{{ row[column.prop] }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="{ row, $index }">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete($index)" style="color: red"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 上传 -->
<el-dialog :title="uploadTitle" :visible.sync="uploadVisible" width="40%">
<FileUpload
v-model="fileList"
:value="fileList"
:limit="3"
:fileSize="10"
:fileType="['jpg', 'png', 'pdf']"
@input="handleFileList"
/>
<span slot="footer" class="dialog-footer">
<el-button @click="uploadVisible = false"> </el-button>
</span>
</el-dialog>
<!-- 查看 -->
<el-dialog :title="viewTitle" :visible.sync="viewVisible" width="40%">
<el-table :data="viewList" fit highlight-current-row style="width: 100%" height="546">
<el-table-column type="index" width="55" label="序号" align="center" />
<el-table-column label="附件名称" prop="fileName" align="center">
<!-- 插槽 -->
<template v-slot="{ row }">
<span style="color: #00a288; cursor: pointer" @click="handleFile(row)">{{ row.fileName }}</span>
</template>
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="viewVisible = false"> </el-button>
</span>
</el-dialog>
<!-- 地址 -->
<el-dialog title="新增" v-if="showHouse" :visible.sync="showHouse" width="55%" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="135px">
<el-row>
<el-col :span="12">
<el-form-item label="统一社会信用代码" prop="supplierCode">
<el-input v-model="form.supplierCode" placeholder="请输入统一社会信用代码" maxlength="64" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="厂家名称" prop="supplierName">
<el-input v-model="form.supplierName" placeholder="请输入厂家名称" maxlength="128" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="联系人" prop="contactPerson">
<el-input v-model="form.contactPerson" placeholder="请输入联系人" maxlength="64" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="联系电话" prop="contactPhone">
<el-input v-model="form.contactPhone" placeholder="请输入联系电话" maxlength="11" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="厂家地址" prop="address">
<el-input v-model="form.address" placeholder="请输入厂家地址" maxlength="255" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="资质/执照编号" prop="qualification">
<el-input v-model="form.qualification" placeholder="请输入资质信息或执照编号" maxlength="255" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="状态" prop="status">
<el-select v-model="form.status" placeholder="请选择状态" style="width: 100%">
<el-option label="启用" :value="1" />
<el-option label="停用" :value="0" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注" prop="remark">
<el-input
type="textarea"
:rows="6"
placeholder="请输入备注"
v-model="form.remark"
maxlength="255"
show-word-limit
>
</el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="showHouse = false"> </el-button>
</div>
</el-dialog>
<!-- 报告管理 -->
<el-dialog title="报告管理" :visible.sync="openReport" width="900px" append-to-body>
<el-table :data="fileDataList" width="100%" height="350px">
<el-table-column label="序号" type="index" width="55" align="center" />
<el-table-column label="报告类型" align="center" prop="dictLabel" :show-overflow-tooltip="true">
<template v-slot="{ row }">
<span v-if="row.type == 2 || row.type == 3">
<span style="color: red">*</span>
{{ row.dictLabel }}
</span>
<span v-else>{{ row.dictLabel }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" width="100">
<template slot-scope="{ row, $index }">
<div style="display: flex; align-items: center; justify-content: center">
<el-button size="mini" type="text" @click="handleFileUpload(currentRow, row.type)">上传</el-button>
<el-button
v-if="
(row.type == 2 && currentRow.certificates.length > 0) ||
(row.type == 3 && currentRow.inspectionReports.length > 0) ||
(row.type == 4 && currentRow.purchaseInvoices.length > 0)
"
size="mini"
type="text"
@click="handleView(currentRow, row.type)"
>
查看
</el-button>
</div>
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
</template>
<script>
import { getTreeSelectApi, addApplyCodeApi, addToolApi } from '@/api/toolsManage'
import { getManufacturerSelectApi } from '@/api/EquipmentLedger'
import { addFacturer } from '@/api/ma/supplier'
import { addWarehousingApi, updateWarehousingApi } from '@/api/EquipmentEntryApply'
import FileUpload from '@/components/FileImageUpload'
export default {
components: { FileUpload },
data() {
return {
isLoading: false,
dialogTitle: '新增编码工具',
dialogVisible: false,
dialogForm: {
applyId: null,
typeId: null,
supplierId: null,
supplierName: null,
productionDate: null,
applyNum: 1,
},
rules: {
applyNum: [{ required: true, message: '请输入申请数量', trigger: 'blur' }],
},
typeIdList: [],
dialogColumns: [
{ label: '工具专业', prop: 'fourthParentName' },
{ label: '施工类型', prop: 'greatGrandparentName' },
{ label: '工具类型', prop: 'grandparentTypeName' },
{ label: '工具名称', prop: 'parentTypeName' },
{ label: '规格型号', prop: 'typeName' },
{ label: '计量单位', prop: 'unitName' },
{ label: '生产厂家', prop: 'supplierId', width: 180, required: true },
{ label: '出厂日期', prop: 'productionDate', width: 180, required: true },
{ label: '资产原值(万元)', prop: 'originCost', width: 150, required: true },
{ label: '原始编码', prop: 'identifyCode', width: 150, required: true },
{ label: '相关配套资料', prop: 'fileList', width: 150, required: true },
// { label: '', prop: 'certificates', width: 100, required: true },
// { label: '', prop: 'inspectionReports', width: 100, required: true },
// { label: '', prop: 'purchaseInvoices', width: 100 },
],
openReport: false,
fileDataList: [
{ dictLabel: '合格证', type: '2' },
{ dictLabel: '检测证书', type: '3' },
{ dictLabel: '采购发票', type: '4' },
],
dialogList: [],
options: [],
activeLabels: [],
lastNode: null,
manufacturerSelect: [],
certificates: [], //
inspectionReports: [], //
purchaseInvoices: [], //
uploadType: '',
currentRow: null,
uploadTitle: '',
uploadVisible: false,
fileList: [],
viewVisible: false,
viewTitle: '',
viewList: [],
showHouse: false,
form: {},
//
rules: {
supplierCode: [{ required: true, message: '统一社会信用代码不能为空', trigger: 'blur' }],
supplierName: [{ required: true, message: '厂家名称不能为空', trigger: 'blur' }],
contactPhone: [
{ required: false, message: '请输入联系电话', trigger: 'blur' },
{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: '请输入正确的手机号码', trigger: 'blur' },
],
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
},
}
},
created() {
const applyId = this.$route.query.applyId || ''
this.openDialog(applyId)
},
methods: {
openDialog(applyId) {
this.dialogForm.applyId = applyId
this.dialogForm.supplierId = null
this.dialogForm.productionDate = null
this.dialogForm.applyNum = 1
this.typeIdList = []
this.dialogList = []
this.dialogVisible = true
this.getTreeSelect()
this.getManufacturerSelect()
if (applyId) {
this.getList()
}
},
async getList() {
try {
} catch (error) {
console.log('🚀 ~ error:', error)
}
},
async getTreeSelect() {
try {
const res = await getTreeSelectApi({ manageType: 0 })
this.options = res.data
this.handleTree(this.options)
} catch (error) {}
},
handleTree(tree) {
for (const node of tree) {
if (node.level === '5') {
// children
delete node.children
} else if (node.children && node.children.length > 0) {
//
this.handleTree(node.children)
}
}
},
handleChange(val) {
this.dialogForm.typeId = val ? val[val.length - 1] : ''
this.activeLabels = this.getLabelsFromValuePath(val, this.options)
this.lastNode = this.findNodeById(this.options, val[val.length - 1])
console.log('选中的 labels:', this.activeLabels)
},
getLabelsFromValuePath(valuePath, options) {
let labels = []
let currentLevel = options
for (const val of valuePath) {
const node = currentLevel.find((item) => item.typeId === val)
if (node) {
labels.push(node.typeName)
currentLevel = node.children || []
} else {
break
}
}
return labels
},
findNodeById(tree, id) {
for (const node of tree) {
if (node.typeId === id) return node //
if (node.children) {
const result = this.findNodeById(node.children, id)
if (result) return result //
}
}
return null //
},
handleAdd() {
const typeId = this.typeIdList[this.typeIdList.length - 1]
for (let i = 0; i < this.dialogForm.applyNum; i++) {
this.dialogList.unshift({
applyId: this.dialogForm.applyId,
typeId,
fourthParentName: this.activeLabels[0],
greatGrandparentName: this.activeLabels[1],
grandparentTypeName: this.activeLabels[2],
parentTypeName: this.activeLabels[3],
typeName: this.activeLabels[4],
unitName: this.lastNode.unitName,
applyNum: 1,
supplierId: this.dialogForm.supplierId,
supplierName: this.dialogForm.supplierName,
productionDate: this.dialogForm.productionDate,
originCost: null,
identifyCode: null,
certificates: [], //
inspectionReports: [], //
purchaseInvoices: [], //
})
}
},
handleDelete(index) {
this.dialogList.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!',
})
},
//
async getManufacturerSelect() {
try {
const res = await getManufacturerSelectApi()
this.manufacturerSelect = res.data
} catch (error) {}
},
//
async submit() {
try {
// this.dialogList
for (let i = 0; i < this.dialogList.length; i++) {
const item = this.dialogList[i]
if (!item.supplierId) {
this.$message.error(`${i + 1}行厂家不能为空`)
return
}
if (!item.productionDate) {
this.$message.error(`${i + 1}行出厂日期不能为空`)
return
}
if (!item.originCost) {
this.$message.error(`${i + 1}行资产原值不能为空`)
return
}
if (!item.identifyCode) {
this.$message.error(`${i + 1}行原始编码不能为空`)
return
}
if (item.certificates.length == 0) {
this.$message.error(`${i + 1}行合格证不能为空`)
return
}
if (item.inspectionReports.length == 0) {
this.$message.error(`${i + 1}行检测证书不能为空`)
return
}
// if (item.purchaseInvoices.length == 0) {
// this.$message.error(`${i + 1}`)
// return
// }
}
this.isLoading = true
this.dialogForm.applyId = this.$route.query.applyId || ''
if (!this.dialogForm.applyId) {
const res = await addApplyCodeApi()
this.dialogForm.applyId = res.data.id
//
this.$router.replace({
query: {
applyId: res.data.id,
},
})
this.dialogList.forEach((item) => {
item.applyId = res.data.id
})
}
const orderId = this.$route.query.orderId || ''
const isEdit = this.$route.query.isEdit || ''
const id = this.$route.query.id || ''
if (isEdit && id) {
await updateWarehousingApi({ orderId, applyId: this.dialogForm.applyId })
} else {
await addToolApi(this.dialogList)
await addWarehousingApi({ orderId, applyId: this.dialogForm.applyId })
}
this.$message({
type: 'success',
message: '操作成功!',
})
this.dialogVisible = false
// this.$emit('getList', { applyId: this.dialogForm.applyId })
} catch (error) {
} finally {
this.isLoading = false
}
},
openAddress() {
this.showHouse = true
},
submitForm() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
addFacturer(this.form).then((response) => {
this.$modal.msgSuccess('新增成功')
this.showHouse = false
this.getManufacturerSelect()
})
}
})
},
handlePriceInput(row) {
let val = String(row.originCost ?? '')
// 1 .
val = val.replace(/[^\d.]/g, '')
// 2
const dotIndex = val.indexOf('.')
if (dotIndex !== -1) {
val = val.slice(0, dotIndex + 1) + val.slice(dotIndex + 1).replace(/\./g, '')
}
row.originCost = val
},
handleFile(row) {
//
window.open(row.fileUrl, '_blank')
},
//
handleView(row, type) {
if (type == 2) {
this.viewTitle = '合格证'
this.viewList = row.certificates || []
} else if (type == 3) {
this.viewTitle = '检测证书'
this.viewList = row.inspectionReports || []
} else if (type == 4) {
this.viewTitle = '采购发票'
this.viewList = row.purchaseInvoices || []
}
this.viewVisible = true
},
handleFileListUpload(row) {
this.currentRow = row
this.openReport = true
},
//
handleFileUpload(row, type) {
this.uploadType = type
// this.currentRow = row
if (type == 2) {
this.uploadTitle = '合格证'
this.fileList = this.currentRow.fileList2
} else if (type == 3) {
this.uploadTitle = '定期检验报告'
this.fileList = this.currentRow.fileList3
} else if (type == 4) {
this.uploadTitle = '采购发票'
this.fileList = this.currentRow.fileList4
}
this.uploadVisible = true
},
handleFileList(file) {
if (this.uploadType == 2) {
this.currentRow.fileList2 = file
if (!file) {
this.currentRow.certificates = []
return
}
this.currentRow.certificates = this.formatFileList(file)
} else if (this.uploadType == 3) {
this.currentRow.fileList3 = file
if (!file) {
this.currentRow.inspectionReports = []
return
}
this.currentRow.inspectionReports = this.formatFileList(file)
} else if (this.uploadType == 4) {
this.currentRow.fileList4 = file
if (!file) {
this.currentRow.purchaseInvoices = []
return
}
this.currentRow.purchaseInvoices = this.formatFileList(file)
}
},
formatFileList(file) {
const arr = file.split(',')
return arr.map((item) => {
const parts = item.split('/')
return {
fileName: parts[parts.length - 1],
fileUrl: item,
}
})
},
},
}
</script>
<style lang="scss" scoped></style>

View File

@ -0,0 +1,434 @@
<template>
<div>
<el-card style="margin-bottom: 20px">
<el-form ref="dialogForm" :model="dialogForm" size="small" inline @submit.native.prevent style="height: 32px">
<el-form-item label="规格型号">
<el-cascader
v-model="typeIdList"
:options="options"
:props="{ value: 'typeId', label: 'typeName', checkStrictly: false }"
clearable
@change="handleChange"
style="width: 240px"
/>
</el-form-item>
<!-- 移除原来的点击填充按钮 -->
</el-form>
</el-card>
<el-card v-loading="isLoading">
<el-row :gutter="10" class="mb8" justify="end">
<el-col :span="24" style="display: flex; justify-content: flex-end">
<el-button type="primary" :disabled="dialogList.length == 0" @click="submit">暂存</el-button>
</el-col>
</el-row>
<el-table :data="dialogList" border stripe highlight-current-row height="546" style="width: 100%">
<el-table-column type="index" width="55" label="序号" align="center" />
<el-table-column
v-for="(column, index) in dialogColumns"
:width="column.width"
:show-overflow-tooltip="!column.unShowTooltip"
:key="index"
:label="column.label"
:prop="column.prop"
align="center"
>
<!-- 合并插槽逻辑 v-if + v-else-if 区分不同列的输入框 -->
<template v-slot="{ row }">
<!-- 申请数量输入框 -->
<el-input-number
v-if="column.prop == 'applyNum'"
v-model="row.applyNum"
:min="1"
:max="9999"
:precision="0"
:controls="false"
style="width: 120px"
/>
<!-- 单价输入框 -->
<el-input-number
v-else-if="column.prop == 'originCost'"
v-model="row.originCost"
:min="0"
:max="999999.99"
:precision="2"
:controls="false"
style="width: 120px"
/>
<span v-else-if="column.prop == 'fileList'">
<span style="color: #00a288; cursor: pointer" @click="handleFileListUpload(row)">报告管理</span>
</span>
<!-- 其他列默认显示文本 -->
<span v-else>{{ row[column.prop] }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center">
<template slot-scope="{ row, $index }">
<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(index)" style="color: red"
>删除</el-button
>
</template>
</el-table-column>
</el-table>
</el-card>
<!-- 上传 -->
<el-dialog :title="uploadTitle" :visible.sync="uploadVisible" width="40%">
<FileUpload
v-model="fileList"
:value="fileList"
:limit="3"
:fileSize="10"
:fileType="['jpg', 'png', 'pdf']"
@input="handleFileList"
/>
<span slot="footer" class="dialog-footer">
<el-button @click="uploadVisible = false"> </el-button>
</span>
</el-dialog>
<!-- 查看 -->
<el-dialog :title="viewTitle" :visible.sync="viewVisible" width="40%">
<el-table :data="viewList" fit highlight-current-row style="width: 100%" height="546">
<el-table-column type="index" width="55" label="序号" align="center" />
<el-table-column label="附件名称" prop="fileName" align="center">
<!-- 插槽 -->
<template v-slot="{ row }">
<span style="color: #00a288; cursor: pointer" @click="handleFile(row)">{{ row.fileName }}</span>
</template>
</el-table-column>
</el-table>
<span slot="footer" class="dialog-footer">
<el-button @click="viewVisible = false"> </el-button>
</span>
</el-dialog>
<!-- 报告管理 -->
<el-dialog title="报告管理" :visible.sync="openReport" width="900px" append-to-body>
<el-table :data="fileDataList" width="100%" height="350px">
<el-table-column label="序号" type="index" width="55" align="center" />
<el-table-column label="报告类型" align="center" prop="dictLabel" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" width="100">
<template slot-scope="{ row, $index }">
<div style="display: flex; align-items: center; justify-content: center">
<el-button size="mini" type="text" @click="handleFileUpload(currentRow, row.type)">上传</el-button>
<el-button
v-if="
(row.type == 2 && currentRow.certificates.length > 0) ||
(row.type == 3 && currentRow.inspectionReports.length > 0) ||
(row.type == 4 && currentRow.purchaseInvoices.length > 0)
"
size="mini"
type="text"
@click="handleView(currentRow, row.type)"
>
查看
</el-button>
</div>
</template>
</el-table-column>
</el-table>
</el-dialog>
</div>
</template>
<script>
import { getTreeSelectApi, addApplyCodeApi, addToolApi } from '@/api/toolsManage'
import { addWarehousingApi, updateWarehousingApi } from '@/api/EquipmentEntryApply'
import FileUpload from '@/components/FileImageUpload'
export default {
components: { FileUpload },
data() {
return {
isLoading: false,
dialogTitle: '新增数量工具',
dialogVisible: false,
dialogForm: {
applyId: null,
typeId: null,
},
typeIdList: [],
dialogColumns: [
{ label: '工具专业', prop: 'fourthParentName' },
{ label: '施工类型', prop: 'greatGrandparentName' },
{ label: '工具类型', prop: 'grandparentTypeName' },
{ label: '工具名称', prop: 'parentTypeName' },
{ label: '规格型号', prop: 'typeName' },
{ label: '计量单位', prop: 'unitName' },
{ label: '单价', prop: 'originCost', width: 150 },
{ label: '申请数量', prop: 'applyNum', width: 150 },
{ label: '相关配套资料', prop: 'fileList', width: 150, required: true },
// { label: '', prop: 'certificates' },
// { label: '', prop: 'inspectionReports' },
// { label: '', prop: 'purchaseInvoices' },
],
dialogList: [],
openReport: false,
fileDataList: [
{ dictLabel: '合格证', type: '2' },
{ dictLabel: '检测证书', type: '3' },
{ dictLabel: '采购发票', type: '4' },
],
options: [],
activeLabels: [],
lastNode: null,
certificates: [], //
inspectionReports: [], //
purchaseInvoices: [], //
uploadType: '',
currentRow: null,
uploadTitle: '',
uploadVisible: false,
fileList: [],
viewVisible: false,
viewTitle: '',
viewList: [],
}
},
created() {
const applyId = this.$route.query.applyId || ''
this.openDialog(applyId)
},
methods: {
openDialog(applyId) {
console.log('🚀 ~ applyId:', applyId)
this.dialogForm.applyId = applyId
this.typeIdList = []
this.dialogList = []
this.dialogVisible = true
this.getTreeSelect()
if (applyId) {
this.getList()
}
},
async getList() {
try {
} catch (error) {
console.log('🚀 ~ error:', error)
}
},
async getTreeSelect() {
try {
const res = await getTreeSelectApi({ manageType: 1 })
console.log('🚀 ~ res:', res)
this.options = res.data
this.handleTree(this.options)
} catch (error) {
console.log('🚀 ~ error:', error)
}
},
handleTree(tree) {
for (const node of tree) {
if (node.level === '5') {
// children
delete node.children
} else if (node.children && node.children.length > 0) {
//
this.handleTree(node.children)
}
}
},
handleChange(val) {
console.log('🚀 ~ 选中的节点ID路径:', val)
// 1.
if (!val || val.length === 0) {
this.dialogForm.typeId = ''
this.activeLabels = []
this.lastNode = null
return
}
// 2.
this.dialogForm.typeId = val[val.length - 1]
this.activeLabels = this.getLabelsFromValuePath(val, this.options)
this.lastNode = this.findNodeById(this.options, this.dialogForm.typeId)
// 3. level=5
if (this.lastNode?.level === '5') {
this.autoAddToTable()
}
},
// handleAdd
autoAddToTable() {
const typeId = this.dialogForm.typeId
//
if (this.dialogList.some((item) => item.typeId === typeId)) {
this.$message({
type: 'warning',
message: '该工具已添加,请勿重复选择!',
})
return
}
//
const originCost = this.lastNode?.originCost || 0
this.dialogList.unshift({
applyId: this.dialogForm.applyId,
typeId,
fourthParentName: this.activeLabels[0] || '',
greatGrandparentName: this.activeLabels[1] || '',
grandparentTypeName: this.activeLabels[2] || '',
parentTypeName: this.activeLabels[3] || '',
typeName: this.activeLabels[4] || '',
unitName: this.lastNode.unitName || '',
originCost,
applyNum: 1,
certificates: [], //
inspectionReports: [], //
purchaseInvoices: [], //
})
this.$message({
type: 'success',
message: '工具已添加到列表!',
duration: 1500, //
})
},
getLabelsFromValuePath(valuePath, options) {
let labels = []
let currentLevel = options
for (const val of valuePath) {
const node = currentLevel.find((item) => item.typeId === val)
if (node) {
labels.push(node.typeName)
currentLevel = node.children || []
} else {
break
}
}
return labels
},
findNodeById(tree, id) {
for (const node of tree) {
if (node.typeId === id) return node //
if (node.children) {
const result = this.findNodeById(node.children, id)
if (result) return result //
}
}
return null //
},
handleDelete(index) {
this.dialogList.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!',
})
},
async submit() {
try {
this.isLoading = true
this.dialogForm.applyId = this.$route.query.applyId || ''
if (!this.dialogForm.applyId) {
const res = await addApplyCodeApi()
console.log('🚀 ~ res:', res)
this.dialogForm.applyId = res.data.id
//
this.$router.replace({
query: {
applyId: res.data.id,
},
})
this.dialogList.forEach((item) => {
item.applyId = res.data.id
})
}
const orderId = this.$route.query.orderId || ''
const isEdit = this.$route.query.isEdit || ''
const id = this.$route.query.id || ''
if (isEdit && id) {
await updateWarehousingApi({ orderId, applyId: this.dialogForm.applyId })
} else {
await addToolApi(this.dialogList)
await addWarehousingApi({ orderId, applyId: this.dialogForm.applyId })
}
this.$message({
type: 'success',
message: '操作成功!',
})
this.dialogVisible = false
} catch (error) {
console.log('🚀 ~ error:', error)
} finally {
this.isLoading = false
}
},
handleFile(row) {
//
window.open(row.fileUrl, '_blank')
},
//
handleView(row, type) {
if (type == 2) {
this.viewTitle = '合格证'
this.viewList = row.certificates || []
} else if (type == 3) {
this.viewTitle = '检测证书'
this.viewList = row.inspectionReports || []
} else if (type == 4) {
this.viewTitle = '采购发票'
this.viewList = row.purchaseInvoices || []
}
this.viewVisible = true
},
handleFileListUpload(row) {
this.currentRow = row
this.openReport = true
},
//
handleFileUpload(row, type) {
this.uploadType = type
// this.currentRow = row
if (type == 2) {
this.uploadTitle = '合格证'
this.fileList = this.currentRow.fileList2
} else if (type == 3) {
this.uploadTitle = '定期检验报告'
this.fileList = this.currentRow.fileList3
} else if (type == 4) {
this.uploadTitle = '采购发票'
this.fileList = this.currentRow.fileList4
}
this.uploadVisible = true
},
handleFileList(file) {
console.log('🚀 ~ file:', file)
if (this.uploadType == 2) {
this.currentRow.fileList2 = file
if (!file) {
this.currentRow.certificates = []
return
}
this.currentRow.certificates = this.formatFileList(file)
} else if (this.uploadType == 3) {
this.currentRow.fileList3 = file
if (!file) {
this.currentRow.inspectionReports = []
return
}
this.currentRow.inspectionReports = this.formatFileList(file)
} else if (this.uploadType == 4) {
this.currentRow.fileList4 = file
if (!file) {
this.currentRow.purchaseInvoices = []
return
}
this.currentRow.purchaseInvoices = this.formatFileList(file)
}
},
formatFileList(file) {
const arr = file.split(',')
return arr.map((item) => {
const parts = item.split('/')
return {
fileName: parts[parts.length - 1],
fileUrl: item,
}
})
},
},
}
</script>
<style lang="scss" scoped></style>

File diff suppressed because it is too large Load Diff

View File

@ -81,11 +81,20 @@
:prop="column.prop"
align="center"
>
<template v-slot="{ row }">
<span v-if="column.prop == 'status'">
<el-tag v-if="row.status == 0" size="small" type="info">草稿</el-tag>
<el-tag v-if="row.status == 1" size="small" type="warning">待审批</el-tag>
<el-tag v-if="row.status == 2" size="small" type="success">审批通过</el-tag>
<el-tag v-if="row.status == 3" size="small" type="danger">驳回</el-tag>
</span>
<span v-else>{{ row[column.prop] }}</span>
</template>
</el-table-column>
<!-- 操作 -->
<el-table-column label="操作" align="center" width="150">
<template slot-scope="{ row }">
<el-button type="text" size="mini" @click="handleEdit">编辑</el-button>
<template v-slot="{ row }">
<el-button type="text" size="mini" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" style="color: red" size="mini" @click="handleDelete">删除</el-button>
<el-button type="text" size="mini" @click="submit">提交</el-button>
</template>
@ -104,6 +113,8 @@
</template>
<script>
import { getWarehousingListApi } from '@/api/EquipmentEntryApply'
export default {
name: 'EntryApply',
data() {
@ -125,16 +136,17 @@ export default {
{ label: '录入单号', prop: 'code' },
{ label: '装备数量', prop: 'equipNum' },
{ label: '工具数量', prop: 'toolNum' },
{ label: '申请人', prop: 'applyName' },
{ label: '申请时间', prop: 'applyTime' },
{ label: '申请人', prop: 'createUser' },
{ label: '申请时间', prop: 'createTime' },
{ label: '审批状态', prop: 'status' },
],
//
tableList: [{ code: 1 }, { code: 1 }, { code: 1 }],
tableList: [],
statusList: [
{ label: '草稿', value: '1' },
{ label: '驳回', value: '2' },
{ label: '审批中', value: '3' },
{ label: '草稿', value: '0' },
{ label: '待审批', value: '1' },
{ label: '审批通过', value: '2' },
{ label: '驳回', value: '3' },
],
selectedRowKeys: [],
}
@ -167,10 +179,10 @@ export default {
}
delete params.timeRange
console.log('🚀 ~ getList ~ params:', params)
// const res = await (params)
// console.log('🚀 ~ ~ res:', res)
// this.tableList = res.data.rows || []
// this.total = res.data.total || 0
const res = await getWarehousingListApi(params)
console.log('🚀 ~ 获取列表 ~ res:', res)
this.tableList = res.rows || []
this.total = res.total || 0
} catch (error) {
console.log('🚀 ~ 获取列表 ~ error:', error)
this.tableList = []
@ -184,9 +196,28 @@ export default {
this.selectedRowKeys = val.map((item) => item.id)
},
//
handleAdd() {},
handleAdd() {
this.$router.push({
path: '/stockManagement/entryApply/apply',
query: { isAddVisible: false, isApprovalVisible: false },
}).then(() => {
this.$tab.closePage({ path: '/stockManagement/entryApply' })
})
},
//
handleEdit() {},
handleEdit(row) {
this.$router.push({
path: '/stockManagement/entryApply/apply',
query: {
id: row.id,
orderId: row.orderId,
applyId: row.applyId,
isAddVisible: false,
isApprovalVisible: false,
isEdit: true,
},
})
},
//
async handleDelete() {
//

View File

@ -81,10 +81,20 @@
:prop="column.prop"
align="center"
>
<template v-slot="{ row }">
<span v-if="column.prop == 'status'">
<el-tag v-if="row.status == 0" size="small" type="info">草稿</el-tag>
<el-tag v-if="row.status == 1" size="small" type="warning">待审批</el-tag>
<el-tag v-if="row.status == 2" size="small" type="success">审批通过</el-tag>
<el-tag v-if="row.status == 3" size="small" type="danger">驳回</el-tag>
</span>
<span v-else>{{ row[column.prop] }}</span>
</template>
</el-table-column>
<!-- 操作 -->
<el-table-column label="操作" align="center" width="150">
<template slot-scope="{ row }">
<el-button type="text" size="mini" @click="handleView">查看</el-button>
<el-button type="text" size="mini" @click="submit">审核</el-button>
<el-button type="text" style="color: red" size="mini" @click="handleReject">驳回</el-button>
</template>
@ -103,6 +113,8 @@
</template>
<script>
import { getWarehousingListApi } from '@/api/EquipmentEntryApply'
export default {
name: 'InventoryAudit',
data() {
@ -131,7 +143,7 @@ export default {
{ label: '装备/工具名称', prop: 'name' },
],
//
tableList: [{ code: 1 }, { code: 1 }, { code: 1 }],
tableList: [{ status: 1 }, { status: 2 }, { status: 3 }, { status: 0 }],
typeList: [
{ label: '设备', value: '1' },
{ label: '全部工具', value: '2' },
@ -169,10 +181,10 @@ export default {
}
delete params.timeRange
console.log('🚀 ~ getList ~ params:', params)
// const res = await (params)
// console.log('🚀 ~ ~ res:', res)
// this.tableList = res.data.rows || []
// this.total = res.data.total || 0
const res = await getWarehousingListApi(params)
console.log('🚀 ~ 获取列表 ~ res:', res)
this.tableList = res.rows || []
this.total = res.total || 0
} catch (error) {
console.log('🚀 ~ 获取列表 ~ error:', error)
this.tableList = []
@ -197,6 +209,7 @@ export default {
}
})
},
handleView(row) {},
//
async submit() {
//