Merge branch 'master' of http://42.192.7.176:3000/suojin/smartpark_durable_front
commit
d79944ca03
12 changed files with 53 additions and 1502 deletions
@ -1,709 +0,0 @@ |
|||||||
<template> |
|
||||||
<div> |
|
||||||
<el-dialog :close-on-click-modal="false" :title="inDialogTiltle" :visible.sync="inDialogVisible" |
|
||||||
:append-to-body="true" width="70%" @close="handleCloseDetail" fullscreen> |
|
||||||
<!-- 基本信息 --> |
|
||||||
<el-form :model="sizeForm" ref="dynamicValidateForm" label-width="100px" class="demo-dynamic"> |
|
||||||
<div class="form-title"> 基本信息</div> |
|
||||||
<el-row> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="仓库名称"> |
|
||||||
<el-input v-model="sizeForm.warehouseName" :disabled="true"></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="入库单号" v-if="sizeForm.option == 1"> |
|
||||||
<el-input v-model="sizeForm.orderNo" disabled></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="入库时间"> |
|
||||||
<el-date-picker v-model="sizeForm.inDate" format="yyyy-MM-dd" value-format="yyyy-MM-dd" type="date" |
|
||||||
placeholder="选择日期" style="width: 100%;" disabled> |
|
||||||
</el-date-picker> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="事由"> |
|
||||||
<el-input v-model="sizeForm.reason" :disabled="inDialogType != 'add'"></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="物资类型"> |
|
||||||
<el-select v-model="sizeForm.materialType" placeholder="请选择" style="width: 100%;" |
|
||||||
:disabled="inDialogType != 'add'"> |
|
||||||
<el-option label="办公物资" value="1"></el-option> |
|
||||||
<el-option label="其他物资" value="2"></el-option> |
|
||||||
</el-select> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item prop="source" label="来源"> |
|
||||||
<el-select v-model="sizeForm.source" placeholder="请选择" style="width: 100%;" |
|
||||||
:disabled="inDialogType != 'add'"> |
|
||||||
<el-option label="采购申请" value="cg"></el-option> |
|
||||||
<el-option label="其他来源" value="qt"></el-option> |
|
||||||
</el-select> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="选项"> |
|
||||||
<el-radio-group v-model="sizeForm.option" @change="radioChange()" :disabled="inDialogType != 'add'"> |
|
||||||
<el-radio :label="1">批量选择</el-radio> |
|
||||||
<el-radio :label="2">单项选择</el-radio> |
|
||||||
</el-radio-group> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12" v-if="sizeForm.option == 1"> |
|
||||||
<el-form-item label="采购单名称"> |
|
||||||
<el-input v-model="sizeForm.quarterName" disabled></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
</el-row> |
|
||||||
<div class="form-title">{{ inDate }}</div> |
|
||||||
<el-button type="primary" size="mini" style="margin-bottom: 18px;" @click="inTableAdd()" |
|
||||||
v-if="!allDisabled && sizeForm.option == 2">新增</el-button> |
|
||||||
<!-- 批量选择 --> |
|
||||||
<el-table :data="sizeForm.inTableData" border style="width: 100%" v-show="sizeForm.option == 1"> |
|
||||||
<el-table-column prop="materialCode" label="物资编码"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="materialName" label="物资名称"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="model" label="规格"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unit" label="单位"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="type" label="类别"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
<el-select v-model="scope.row.type" placeholder="请选择" style="width: 100%;" |
|
||||||
:disabled="inDialogType != 'add'" @change="handleTypeChange(scope.row)"> |
|
||||||
<el-option label="耐用品" value="NY"></el-option> |
|
||||||
<el-option label="易耗品" value="YH"></el-option> |
|
||||||
</el-select> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="requiredQuantity" label="计划采购数量" v-if="sizeForm.option == 1"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.requiredQuantity || 0 }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="inboundQuantity" label="已入库数量" v-if="sizeForm.option == 1"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.inboundQuantity || 0 }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="theInboundQuantity" label="本次入库数量"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
<el-input-number size="mini" v-model="scope.row.theInboundQuantity" :min="1" style="width: 100%;" |
|
||||||
@change="syncInboundQuantity(scope.row)"></el-input-number> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
</el-table-column> |
|
||||||
</el-table> |
|
||||||
<!-- 单项选择 --> |
|
||||||
<el-table :data="sizeForm.singleData" border style="width: 100%" v-show="sizeForm.option == 2"> |
|
||||||
<el-table-column prop="materialCode" label="物资编码"></el-table-column> |
|
||||||
<el-table-column prop="materialName" label="物资名称"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
<el-select v-model="scope.row.materialId" placeholder="请选择物资名称" style="width: 100%;" |
|
||||||
@change="handleMaterialChange(scope.row)"> |
|
||||||
<el-option v-for="item in materials" :key="item.materialId" :label="item.materialName" |
|
||||||
:value="item.materialId"> |
|
||||||
</el-option> |
|
||||||
</el-select> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="model" label="物资规格"></el-table-column> |
|
||||||
<el-table-column prop="type" label="类别 "> |
|
||||||
<template slot-scope="scope"> |
|
||||||
<el-select v-model="scope.row.type" placeholder="请选择" style="width: 100%;" |
|
||||||
:disabled="inDialogType != 'add'" @change="handleTypeChange(scope.row)"> |
|
||||||
<el-option label="耐用品" value="NY"></el-option> |
|
||||||
<el-option label="易耗品" value="YH"></el-option> |
|
||||||
</el-select> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unit" label="单位"></el-table-column> |
|
||||||
<el-table-column prop="requiredQuantity" label="计划采购数量" v-if="sizeForm.option == 1"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.requiredQuantity || 0 }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="inboundQuantity" label="已入库数量" v-if="sizeForm.option == 1"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="theInboundQuantity" label="本次入库数量"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
<el-input-number size="mini" v-model="scope.row.theInboundQuantity" :min="1" style="width: 100%;" |
|
||||||
@change="syncInboundQuantity(scope.row)"></el-input-number> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
<el-input-number size="mini" v-model="scope.row.unitPrice" :min="0" style="width: 100%;" |
|
||||||
@change="syncUnitPrice(scope.row)"></el-input-number> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table> |
|
||||||
<!-- 入库账目表格 --> |
|
||||||
<div class="form-title" v-if="inDialogType !== 'details'">入库账目表格:</div> |
|
||||||
<!-- 批量选择 --> |
|
||||||
<el-table :data="sizeForm.inTableData" border style="width: 100%" v-show="sizeForm.option == 1 && inDialogType !== 'details'"> |
|
||||||
<el-table-column prop="date" label="当前库存"> |
|
||||||
<el-table-column prop="materialCode" label="物资编码"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="materialName" label="物资名称"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="model" label="规格"> |
|
||||||
</el-table-column> |
|
||||||
<!-- <el-table-column prop="type" label="类别"> |
|
||||||
</el-table-column> --> |
|
||||||
<el-table-column prop="unit" label="单位"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="type" label="类别"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.type === "NY" ? "耐用品" : (scope.row.type === "YH" ? "易耗品" : "") }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="inboundQuantity" label="数量"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库信息"> |
|
||||||
<el-table-column prop="theInboundQuantity" label="数量"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库后库存"> |
|
||||||
<el-table-column label="数量"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ Number(scope.row.inboundQuantity || 0) + Number(scope.row.theInboundQuantity || 0) }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库信息"> |
|
||||||
<el-table-column label="入库人"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.userInfoVO ? scope.row.userInfoVO.name : sizeForm.userInfoVO.name }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="inDate" label="入库时间" width="150"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ inDate }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
|
|
||||||
</el-table> |
|
||||||
<!-- 单项选择 --> |
|
||||||
<el-table :data="sizeForm.singleData" border style="width: 100%" v-show="sizeForm.option == 2 && inDialogType !== 'details'"> |
|
||||||
<el-table-column prop="date" label="当前库存"> |
|
||||||
<el-table-column prop="materialCode" label="物资编码"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="materialName" label="物资名称"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="model" label="规格"></el-table-column> |
|
||||||
<el-table-column prop="type" label="类别"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.type === "NY" ? "耐用品" : (scope.row.type === "YH" ? "易耗品" : "") }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unit" label="单位"></el-table-column> |
|
||||||
<el-table-column prop="inboundQuantity" label="数量"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.unitPrice || 0 }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库信息"> |
|
||||||
<el-table-column prop="theInboundQuantity" label="数量"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.unitPrice }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库后库存"> |
|
||||||
<el-table-column label="数量"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ Number(scope.row.inboundQuantity || 0) + Number(scope.row.theInboundQuantity || 0) }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.unitPrice || 0 }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库信息"> |
|
||||||
<el-table-column label="入库人"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.userInfoVO ? scope.row.userInfoVO.name : sizeForm.userInfoVO.name }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="inDate" label="入库时间" width="150"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ inDate }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
</el-table> |
|
||||||
</el-form> |
|
||||||
<span slot="footer" class="dialog-footer" v-if="!allDisabled"> |
|
||||||
<el-button @click="handleCloseDetail()">取 消</el-button> |
|
||||||
<!-- <el-button type="primary" @click="save()">暂存</el-button> --> |
|
||||||
<el-button type="primary" @click="submit(1)">暂存</el-button> |
|
||||||
<el-button type="primary" @click="submit(2)">提交</el-button> |
|
||||||
</span> |
|
||||||
</el-dialog> |
|
||||||
|
|
||||||
<!-- 批量出库 选择 --> |
|
||||||
<el-dialog :close-on-click-modal="false" title="选择数据来源" :visible.sync="inBatchDialogVisible" :append-to-body="true" |
|
||||||
width="40%" @close="handleBatchClose" @open="getBatchOptions"> |
|
||||||
<el-select v-model="batchType" placeholder="请选择数据来源" style="width: 100%;"> |
|
||||||
<el-option v-for="item in batchOptions" :key="item.ids" :label="item.quarterName" :value="item.ids"> |
|
||||||
</el-option> |
|
||||||
</el-select> |
|
||||||
<span slot="footer" class="dialog-footer"> |
|
||||||
<el-button @click="handleBatchClose()">取 消</el-button> |
|
||||||
<el-button type="primary" @click="batchSubmit()">确 定</el-button> |
|
||||||
</span> |
|
||||||
</el-dialog> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
<script> |
|
||||||
import { getAllQuarter, getPurchasesByIds, getMaterialList, getDetailList, submitData, editList } from "@/api/firstOrder/inbound"; |
|
||||||
export default { |
|
||||||
props: { |
|
||||||
repairVisible: { |
|
||||||
type: Boolean, |
|
||||||
default: false |
|
||||||
}, |
|
||||||
inDialogTiltle: { |
|
||||||
type: String, |
|
||||||
default: '' |
|
||||||
}, |
|
||||||
inDialogType: { |
|
||||||
type: String, |
|
||||||
default: '' |
|
||||||
}, |
|
||||||
type: { |
|
||||||
type: String, |
|
||||||
default: '' |
|
||||||
}, |
|
||||||
id: { |
|
||||||
type: Number, |
|
||||||
default: 0 |
|
||||||
} |
|
||||||
}, |
|
||||||
data() { |
|
||||||
return { |
|
||||||
inDialogVisible: false, |
|
||||||
sizeForm: { |
|
||||||
orderNo: '',//入库单号 |
|
||||||
// applyNmae: 'user1',//审批人 |
|
||||||
// submitName: '',//填报人 |
|
||||||
warehouseName: '',//仓库名称 |
|
||||||
reason: '',//事由 |
|
||||||
inDate: '',//入库日期 |
|
||||||
inAccountsTableData: [],//总计 |
|
||||||
inTableData: [], //批量选择的数据 |
|
||||||
singleData: [], //单条选择 |
|
||||||
option: 2,//入库类型 |
|
||||||
materialType: '1',//物资类型 |
|
||||||
source: 'cg', //来源 |
|
||||||
status: '',//状态 |
|
||||||
purchaseEneInfo: '',//采购单信息 |
|
||||||
userInfoVO: { |
|
||||||
userId: "用户ID", |
|
||||||
name: "用户名称" |
|
||||||
}, |
|
||||||
ldOnePutStorageDetailVOList: [],//入库明细 |
|
||||||
}, |
|
||||||
inTableData: [], |
|
||||||
// singleData: {}, |
|
||||||
inBatchDialogVisible: false,//选择采购单的数据 |
|
||||||
batchType: '',//批量选择类型 |
|
||||||
materialsType: '', |
|
||||||
allDisabled: false, |
|
||||||
} |
|
||||||
}, |
|
||||||
computed: { |
|
||||||
inDate() { |
|
||||||
const now = new Date() |
|
||||||
const year = now.getFullYear(); |
|
||||||
const month = String(now.getMonth() + 1).padStart(2, '0'); |
|
||||||
const day = String(now.getDate()).padStart(2, '0'); |
|
||||||
return `${year}年${month}月${day}日`; |
|
||||||
} |
|
||||||
}, |
|
||||||
mounted() { |
|
||||||
this.inDialogVisible = this.repairVisible |
|
||||||
if (this.inDialogType == 'add') { |
|
||||||
this.addInit() |
|
||||||
} else { |
|
||||||
this.inInit() |
|
||||||
} |
|
||||||
if (this.inDialogType == 'details') { |
|
||||||
this.allDisabled = true |
|
||||||
} |
|
||||||
this.getBatchOptions() |
|
||||||
this.getMaterialList() |
|
||||||
}, |
|
||||||
methods: { |
|
||||||
//本次入库数量 |
|
||||||
syncInboundQuantity(row) { |
|
||||||
row.theInboundQuantity = Number(row.theInboundQuantity); |
|
||||||
}, |
|
||||||
//单价 |
|
||||||
syncUnitPrice(row) { |
|
||||||
row.unitPrice = Number(row.unitPrice); |
|
||||||
}, |
|
||||||
//批量选择采购单数据来源 |
|
||||||
async getBatchOptions() { |
|
||||||
this.loading = true |
|
||||||
try { |
|
||||||
const res = await getAllQuarter(); |
|
||||||
this.batchOptions = res.data.result |
|
||||||
} catch (error) { |
|
||||||
this.$message.error("获取数据来源失败,请重试"); |
|
||||||
} finally { |
|
||||||
this.loading = false; |
|
||||||
} |
|
||||||
}, |
|
||||||
//获取单条选择的物资名称列表 |
|
||||||
async getMaterialList() { |
|
||||||
this.loading = true |
|
||||||
try { |
|
||||||
const res = await getMaterialList(); |
|
||||||
this.materials = res.data.result |
|
||||||
} catch (error) { |
|
||||||
this.$message.error("获取数据来源失败,请重试"); |
|
||||||
} finally { |
|
||||||
this.loading = false; |
|
||||||
} |
|
||||||
}, |
|
||||||
// inInit() { |
|
||||||
// // const randomNum = Math.floor(Math.random() * 100000000) + 1; |
|
||||||
// // this.sizeForm.orderNo = String(randomNum).padStart(8, '0') |
|
||||||
// // this.sizeForm.applyNmae = '审批人一' |
|
||||||
// // this.sizeForm.submitName = '填报人一' |
|
||||||
// // this.sizeForm.option = 1 |
|
||||||
// // this.sizeForm.warehouseName = '仓库一' |
|
||||||
// // this.sizeForm.reason = '入库' |
|
||||||
// // this.sizeForm.materialType = '1' |
|
||||||
// // this.sizeForm.inDate = new Date()//入库时间 |
|
||||||
// // // 确保singleData是数组 |
|
||||||
// // if (!Array.isArray(this.sizeForm.singleData)) { |
|
||||||
// // this.sizeForm.singleData = []; |
|
||||||
// // } |
|
||||||
// }, |
|
||||||
async inInit () { |
|
||||||
if(this.inDialogType == 'details' || this.inDialogType == 'edit') { |
|
||||||
const res = await editList(this.id) |
|
||||||
console.log(res,'res修改和详情回显的数据') |
|
||||||
this.sizeForm.inTableData = res.data.result.ldOnePutStorageDetailList |
|
||||||
console.log(this.sizeForm.inTableData,'this.sizeForm.inTableData') |
|
||||||
// this.sizeForm.option = res.data.result.ldOnePutStorage.options |
|
||||||
// console.log(this.sizeForm.option,'this.sizeForm.option') |
|
||||||
// if(this.sizeForm.option == 1) { |
|
||||||
// this.sizeForm.inTableData = res.data.result.ldOnePutStorageDetailList |
|
||||||
// } else if(this.sizeForm.option == 2) { |
|
||||||
// this.sizeForm.singleData = res.data.result.ldOnePutStorageDetailList |
|
||||||
// } |
|
||||||
// console.log(this.sizeForm.inTableData,'inTableData修改和详情回显的数据1') |
|
||||||
// console.log(this.sizeForm.singleData,'singleData修改和详情回显的数据2') |
|
||||||
this.sizeForm.purchaseEneInfo =res.data.result.ldOnePutStorage.purchaseEneInfo |
|
||||||
this.sizeForm.orderNo = res.data.result.ldOnePutStorage.orderNo |
|
||||||
this.sizeForm.inDate =res.data.result.ldOnePutStorage.inDate |
|
||||||
this.sizeForm.source =res.data.result.ldOnePutStorage.source |
|
||||||
this.sizeForm.reason = res.data.result.ldOnePutStorage.reason |
|
||||||
this.sizeForm.materialType = res.data.result.ldOnePutStorage.materialType |
|
||||||
this.sizeForm.status = res.data.result.ldOnePutStorage.status |
|
||||||
this.sizeForm.inOperatorId= res.data.result.ldOnePutStorage.status |
|
||||||
this.sizeForm.status = res.data.result.ldOnePutStorage.status |
|
||||||
this.sizeForm.option = res.data.result.ldOnePutStorage.options |
|
||||||
this.sizeForm.warehouseName = res.data.result.ldOnePutStorage.warehouseName |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
}, |
|
||||||
addInit() { |
|
||||||
// 生成入库单号 |
|
||||||
const randomNum = Math.floor(Math.random() * 100000000) + 1; |
|
||||||
this.sizeForm.orderNo = String(randomNum).padStart(8, '0');//入库单号 |
|
||||||
this.sizeForm.inDate = new Date()//入库时间 |
|
||||||
if (this.type == '一级库') { |
|
||||||
this.sizeForm.warehouseName = '仓库一' |
|
||||||
} |
|
||||||
}, |
|
||||||
//取消操作 |
|
||||||
handleCloseDetail() { |
|
||||||
this.inDialogVisible = false |
|
||||||
this.$emit('handleCloseDetail') |
|
||||||
}, |
|
||||||
async inTableAdd() { |
|
||||||
if (this.sizeForm.option == 1) { |
|
||||||
this.sizeForm.inTableData.push({ |
|
||||||
unit: '', |
|
||||||
model: '', |
|
||||||
// str3: '', |
|
||||||
// str4: '', |
|
||||||
// str5: '', |
|
||||||
// str6: '', |
|
||||||
// str7: 0, |
|
||||||
// str8: '', |
|
||||||
// str9: '', |
|
||||||
name: '', |
|
||||||
status: '',// |
|
||||||
materialId: '', |
|
||||||
materialName: '', |
|
||||||
theInboundQuantity: 1, |
|
||||||
unitPrice: 0, |
|
||||||
}) |
|
||||||
} else { |
|
||||||
// 确保singleData是数组 |
|
||||||
if (!Array.isArray(this.sizeForm.singleData)) { |
|
||||||
this.sizeForm.singleData = []; |
|
||||||
} |
|
||||||
|
|
||||||
const newRow = { |
|
||||||
unit: '', |
|
||||||
model: '', |
|
||||||
// str3: '', |
|
||||||
// str4: '', |
|
||||||
// str5: '', |
|
||||||
// str6: '', |
|
||||||
// str7: 0, |
|
||||||
// str8: '', |
|
||||||
// str9: '', |
|
||||||
name: '', |
|
||||||
status: '',// |
|
||||||
materialId: '', |
|
||||||
materialName: '', |
|
||||||
theInboundQuantity: 1, |
|
||||||
unitPrice: 0, |
|
||||||
}; |
|
||||||
this.sizeForm.singleData.push(newRow); |
|
||||||
} |
|
||||||
}, |
|
||||||
|
|
||||||
// 采购单选择确定 |
|
||||||
async batchSubmit() { |
|
||||||
if (!this.batchType) { |
|
||||||
this.$message.warning("请选择数据来源") |
|
||||||
return |
|
||||||
} |
|
||||||
const selectedOption = this.batchOptions.find(option => option.ids === this.batchType); |
|
||||||
if (!selectedOption) { |
|
||||||
this.$message.error("未找到对应的采购单信息"); |
|
||||||
return |
|
||||||
} |
|
||||||
this.sizeForm.quarterName = selectedOption.quarterName |
|
||||||
this.sizeForm.purchaseEneInfo = selectedOption |
|
||||||
this.loading = true |
|
||||||
const res = await getPurchasesByIds(this.batchType); |
|
||||||
console.log("res", res) |
|
||||||
if (res.data.success) { |
|
||||||
this.sizeForm.inTableData = res.data.result; |
|
||||||
this.$message.success("数据获取成功"); |
|
||||||
this.inBatchDialogVisible = false; |
|
||||||
} else { |
|
||||||
this.$message.error(res.data.message || "获取数据失败"); |
|
||||||
} |
|
||||||
this.loading = false; |
|
||||||
}, |
|
||||||
// 采购单选择弹框关闭 |
|
||||||
handleBatchClose() { |
|
||||||
this.inBatchDialogVisible = false |
|
||||||
}, |
|
||||||
// 处理物资选择变化 |
|
||||||
async handleMaterialChange(row) { |
|
||||||
if (!row.materialId) { |
|
||||||
this.$message.warning("请选择物资名称"); |
|
||||||
return |
|
||||||
} |
|
||||||
const res = await getDetailList({ id: row.materialId }) |
|
||||||
console.log("res1", res) |
|
||||||
if (res.data.success) { |
|
||||||
if (!Array.isArray(this.sizeForm.singleData)) { |
|
||||||
this.sizeForm.singleData = []; |
|
||||||
} |
|
||||||
const materialData = res.data.result; |
|
||||||
const index = this.sizeForm.singleData.findIndex(item => item === row); |
|
||||||
if (index !== -1) { |
|
||||||
this.$set(this.sizeForm.singleData, index, { ...row, ...materialData }); |
|
||||||
} else { |
|
||||||
this.sizeForm.singleData.push({ ...row, ...materialData }); |
|
||||||
} |
|
||||||
|
|
||||||
console.log("更新后的singleData:", this.sizeForm.singleData); |
|
||||||
} else { |
|
||||||
this.$message.error(res.data.message || "获取物资信息失败"); |
|
||||||
} |
|
||||||
}, |
|
||||||
// 提交 |
|
||||||
async submit(index) { |
|
||||||
if (!this.sizeForm.warehouseName) { |
|
||||||
this.$message.error("仓库名称不能为空"); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
if (!this.sizeForm.inDate) { |
|
||||||
this.$message.error("入库时间不能为空"); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
if (!this.sizeForm.reason) { |
|
||||||
this.$message.error("事由不能为空"); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
if (!this.sizeForm.materialType) { |
|
||||||
this.$message.error("请选择物资类型"); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
if (!this.sizeForm.source) { |
|
||||||
this.$message.error("请选择来源"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (this.sizeForm.option === 1) { |
|
||||||
if (!this.sizeForm.quarterName) { |
|
||||||
this.$message.error("请选择采购单名称"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (!this.sizeForm.inTableData || this.sizeForm.inTableData.length === 0) { |
|
||||||
this.$message.error("请添加批量选择数据"); |
|
||||||
return; |
|
||||||
} |
|
||||||
// 验证表格中的必填项 |
|
||||||
for (const row of this.sizeForm.inTableData) { |
|
||||||
if (!row.materialId) { |
|
||||||
this.$message.error("物资ID不能为空"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (!row.materialName) { |
|
||||||
this.$message.error("物资名称不能为空"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (!row.theInboundQuantity || row.theInboundQuantity <= 0) { |
|
||||||
this.$message.error("本次入库数量必须大于0"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (row.unitPrice === undefined || row.unitPrice < 0) { |
|
||||||
this.$message.error("单价不能为负数"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (!row.type) { |
|
||||||
this.$message.error("请选择类别"); |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
// 单项选择验证 |
|
||||||
else if (this.sizeForm.option === 2) { |
|
||||||
if (!this.sizeForm.singleData || this.sizeForm.singleData.length === 0) { |
|
||||||
this.$message.error("请添加单项选择数据"); |
|
||||||
return; |
|
||||||
} |
|
||||||
// 验证表格中的必填项 |
|
||||||
for (const row of this.sizeForm.singleData) { |
|
||||||
if (!row.materialId) { |
|
||||||
this.$message.error("请选择物资名称"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (!row.materialName) { |
|
||||||
this.$message.error("物资名称不能为空"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (!row.theInboundQuantity || row.theInboundQuantity <= 0) { |
|
||||||
this.$message.error("本次入库数量必须大于0"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (row.unitPrice === undefined || row.unitPrice <= 0) { |
|
||||||
this.$message.error("单价不能为负数"); |
|
||||||
return; |
|
||||||
} |
|
||||||
if (!row.type) { |
|
||||||
this.$message.error("请选择类别"); |
|
||||||
return; |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
// status == 1 暂存 ,2提交 |
|
||||||
this.sizeForm.status = index |
|
||||||
if (this.sizeForm.option == 1) { |
|
||||||
this.sizeForm.singleData = [] |
|
||||||
this.sizeForm.ldOnePutStorageDetailVOList = this.sizeForm.inTableData |
|
||||||
} else if (this.sizeForm.option == 2) { |
|
||||||
this.sizeForm.inTableData = [] |
|
||||||
this.sizeForm.ldOnePutStorageDetailVOList = this.sizeForm.singleData |
|
||||||
} |
|
||||||
console.log('1', this.sizeForm.inAccountsTableData) |
|
||||||
console.log("提交数据前", this.sizeForm) |
|
||||||
const res = await submitData(this.sizeForm) |
|
||||||
console.log("提交数据后", res) |
|
||||||
if (res.data.success) { |
|
||||||
this.$message({ |
|
||||||
type: "success", |
|
||||||
message: "提交成功" |
|
||||||
}); |
|
||||||
// 提交成功后通知父组件更新页面 |
|
||||||
this.$emit('submitSuccess'); |
|
||||||
this.handleCloseDetail(); |
|
||||||
} else { |
|
||||||
this.$message.error(res.data.message || "提交失败"); |
|
||||||
} |
|
||||||
}, |
|
||||||
|
|
||||||
// 选项选择,批量选择1 单条选择2 |
|
||||||
radioChange() { |
|
||||||
this.sizeForm.inTableData = [] |
|
||||||
this.sizeForm.singleData = [] |
|
||||||
if (this.sizeForm.option == 1) { |
|
||||||
this.inBatchDialogVisible = true |
|
||||||
} |
|
||||||
}, |
|
||||||
// type类别选择变更 |
|
||||||
handleTypeChange(row) { |
|
||||||
if (row.type === 'YH') { |
|
||||||
// 检查单价是否大于600 |
|
||||||
if (Number(row.unitPrice) > 600) { |
|
||||||
this.$confirm('单价大于600元,确定要选择为易耗品吗?', '提示', { |
|
||||||
confirmButtonText: '确定', |
|
||||||
cancelButtonText: '取消', |
|
||||||
type: 'warning' |
|
||||||
}).then(() => { |
|
||||||
return; |
|
||||||
}).catch(() => { |
|
||||||
row.type = 'NY' |
|
||||||
this.$message({ |
|
||||||
type: 'info', |
|
||||||
message: '请重新选择类型' |
|
||||||
}); |
|
||||||
}); |
|
||||||
} |
|
||||||
} |
|
||||||
}, |
|
||||||
} |
|
||||||
|
|
||||||
} |
|
||||||
</script> |
|
||||||
<style lang="scss" scoped> |
|
||||||
.form-title { |
|
||||||
font-size: 16px; |
|
||||||
font-weight: 600; |
|
||||||
padding: 18px 0; |
|
||||||
} |
|
||||||
</style> |
|
||||||
@ -1,459 +0,0 @@ |
|||||||
<template> |
|
||||||
<div> |
|
||||||
<el-dialog :close-on-click-modal="false" :title="inDialogTiltle" :visible.sync="inDialogVisible" |
|
||||||
:append-to-body="true" width="70%" @close="handleCloseDetail" fullscreen> |
|
||||||
<!-- 基本信息 --> |
|
||||||
<el-form :model="sizeForm" ref="dynamicValidateForm" label-width="100px" class="demo-dynamic"> |
|
||||||
<div class="form-title"> 基本信息</div> |
|
||||||
<el-row> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="仓库名称"> |
|
||||||
<el-input v-model="sizeForm.warehouseName" :disabled="true"></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="入库单号" v-if="sizeForm.option == 1"> |
|
||||||
<el-input v-model="sizeForm.orderNo" disabled></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="入库时间"> |
|
||||||
<el-date-picker v-model="sizeForm.inDate" type="date" placeholder="选择日期" style="width: 100%;" disabled> |
|
||||||
</el-date-picker> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="事由"> |
|
||||||
<el-input v-model="sizeForm.reason" :disabled="inDialogType != 'add'"></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="物资类型"> |
|
||||||
<el-select v-model="sizeForm.materialType" placeholder="请选择" style="width: 100%;" |
|
||||||
:disabled="inDialogType != 'add'"> |
|
||||||
<el-option label="耐用品" value="1"></el-option> |
|
||||||
<el-option label="易耗品" value="2"></el-option> |
|
||||||
</el-select> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<!-- <el-col :span="12"> |
|
||||||
<el-form-item label="填报人"> |
|
||||||
<el-input v-model="sizeForm.submitName" :disabled="inDialogType != 'add'"></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> --> |
|
||||||
<!-- <el-col :span="12"> |
|
||||||
<el-form-item label="审批人"> |
|
||||||
<el-input v-model="sizeForm.applyNmae" disabled></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> --> |
|
||||||
<el-col :span="12"> |
|
||||||
<el-form-item label="选项"> |
|
||||||
<el-radio-group v-model="sizeForm.option" @change="radioChange()" :disabled="inDialogType != 'add'"> |
|
||||||
<el-radio :label="1" :disabled="sizeForm.type == 2">批量选择</el-radio> |
|
||||||
<el-radio :label="2">单项选择</el-radio> |
|
||||||
</el-radio-group> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
<el-col :span="12" v-if="sizeForm.option == 1"> |
|
||||||
<el-form-item label="采购单名称"> |
|
||||||
<el-input v-model="sizeForm.quarterName" disabled></el-input> |
|
||||||
</el-form-item> |
|
||||||
</el-col> |
|
||||||
</el-row> |
|
||||||
<div class="form-title">{{ inDate }}</div> |
|
||||||
<el-button type="primary" size="mini" style="margin-bottom: 18px;" @click="inTableAdd()" |
|
||||||
v-if="!allDisabled && sizeForm.option == 2">新增</el-button> |
|
||||||
<el-table :data="sizeForm.inTableData" border style="width: 100%"> |
|
||||||
<el-table-column prop="materialId" label="物资ID"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="materialName" label="名称" v-if="sizeForm.option == 1"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="materialName" label="名称" v-if="sizeForm.option == 2"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
<el-select v-model="scope.row.materialId" placeholder="请选择物资名称" style="width: 100%;" |
|
||||||
@change="handleMaterialChange(scope.row)" |
|
||||||
> |
|
||||||
<el-option v-for="item in materials" :key="item.materialId" :label="item.materialName" |
|
||||||
:value="item.materialId"> |
|
||||||
</el-option> |
|
||||||
</el-select> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="model" label="规格"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="type" label="类别"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unit" label="单位"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="requiredQuantity" label="计划采购数量" v-if="sizeForm.option == 1" > |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.requiredQuantity || 0 }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="inboundQuantity" label="已入库数量" v-if="sizeForm.option == 1"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="theInboundQuantity" label="本次入库数量"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
<el-input-number size="mini" v-model="scope.row.theInboundQuantity" :min="1" style="width: 100%;" |
|
||||||
@change="syncInboundQuantity(scope.row)"></el-input-number> |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
</el-table-column> |
|
||||||
</el-table> |
|
||||||
<!-- 入库账目表格 --> |
|
||||||
<div class="form-title">入库账目表格:</div> |
|
||||||
<el-table :data="sizeForm.inTableData" border style="width: 100%"> |
|
||||||
<el-table-column prop="date" label="当前库存"> |
|
||||||
<el-table-column prop="materialId" label="物资ID"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="materialName" label="名称"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="model" label="规格"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="type" label="类别"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unit" label="单位"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="inboundQuantity" label="数量"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库信息"> |
|
||||||
<el-table-column prop="theInboundQuantity" label="数量"> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库后库存"> |
|
||||||
<el-table-column label="数量"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ Number(scope.row.inboundQuantity || 0) + Number(scope.row.theInboundQuantity || 0) }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="unitPrice" label="单价"> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="date" label="入库信息"> |
|
||||||
<el-table-column label="入库人"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ scope.row.userInfoVO ? scope.row.userInfoVO.name : (sizeForm.submitName || '') }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
<el-table-column prop="inDate" label="入库时间" width="150"> |
|
||||||
<template slot-scope="scope"> |
|
||||||
{{ inDate }} |
|
||||||
</template> |
|
||||||
</el-table-column> |
|
||||||
</el-table-column> |
|
||||||
|
|
||||||
|
|
||||||
</el-table> |
|
||||||
</el-form> |
|
||||||
<span slot="footer" class="dialog-footer" v-if="!allDisabled"> |
|
||||||
<el-button @click="handleCloseDetail()">取 消</el-button> |
|
||||||
<el-button type="primary" @click="save()">暂存</el-button> |
|
||||||
<el-button type="primary" @click="submit()">提交</el-button> |
|
||||||
</span> |
|
||||||
</el-dialog> |
|
||||||
|
|
||||||
<!-- 批量出库 选择 --> |
|
||||||
<el-dialog :close-on-click-modal="false" title="选择数据来源" :visible.sync="inBatchDialogVisible" :append-to-body="true" |
|
||||||
width="40%" @close="handleBatchClose" @open="getBatchOptions"> |
|
||||||
<el-select v-model="batchType" placeholder="请选择数据来源" style="width: 100%;"> |
|
||||||
<el-option v-for="item in batchOptions" :key="item.ids" :label="item.quarterName" :value="item.ids"> |
|
||||||
</el-option> |
|
||||||
</el-select> |
|
||||||
<span slot="footer" class="dialog-footer"> |
|
||||||
<el-button @click="handleBatchClose()">取 消</el-button> |
|
||||||
<el-button type="primary" @click="batchSubmit()">确 定</el-button> |
|
||||||
</span> |
|
||||||
</el-dialog> |
|
||||||
</div> |
|
||||||
</template> |
|
||||||
<script> |
|
||||||
import { getAllQuarter, getPurchasesByIds, getMaterialList, getDetailList } from "@/api/firstOrder/inbound"; |
|
||||||
export default { |
|
||||||
props: { |
|
||||||
repairVisible: { |
|
||||||
type: Boolean, |
|
||||||
default: false |
|
||||||
}, |
|
||||||
inDialogTiltle: { |
|
||||||
type: String, |
|
||||||
default: '' |
|
||||||
}, |
|
||||||
inDialogType: { |
|
||||||
type: String, |
|
||||||
default: '' |
|
||||||
}, |
|
||||||
type: { |
|
||||||
type: String, |
|
||||||
default: '' |
|
||||||
} |
|
||||||
}, |
|
||||||
data() { |
|
||||||
return { |
|
||||||
inDialogVisible: false, |
|
||||||
sizeForm: { |
|
||||||
orderNo: '',//入库单号 |
|
||||||
applyNmae: '',//审批人 |
|
||||||
submitName: '',//填报人 |
|
||||||
warehouseName: '',//仓库名称 |
|
||||||
reason: '',//事由 |
|
||||||
inAccountsTableData: [],//总计 |
|
||||||
inTableData: [], |
|
||||||
}, |
|
||||||
inTableData: [], |
|
||||||
inBatchDialogVisible: false,//选择采购单的数据 |
|
||||||
batchType: '',//批量选择类型 |
|
||||||
materialsType: '', |
|
||||||
allDisabled: false, |
|
||||||
userInfoVO: { |
|
||||||
userId: "用户ID", |
|
||||||
name: "用户名称" |
|
||||||
} |
|
||||||
} |
|
||||||
}, |
|
||||||
computed: { |
|
||||||
inDate() { |
|
||||||
const now = new Date(); |
|
||||||
const year = now.getFullYear(); |
|
||||||
const month = String(now.getMonth() + 1).padStart(2, '0'); |
|
||||||
const day = String(now.getDate()).padStart(2, '0'); |
|
||||||
return `${year}年${month}月${day}日`; |
|
||||||
} |
|
||||||
}, |
|
||||||
mounted() { |
|
||||||
this.inDialogVisible = this.repairVisible |
|
||||||
if (this.inDialogType == 'add') { |
|
||||||
this.addInit() |
|
||||||
} else { |
|
||||||
this.inInit() |
|
||||||
} |
|
||||||
if (this.inDialogType == 'details') { |
|
||||||
this.allDisabled = true |
|
||||||
} |
|
||||||
this.getBatchOptions() |
|
||||||
this.getMaterialList() |
|
||||||
}, |
|
||||||
methods: { |
|
||||||
syncInboundQuantity(row) { |
|
||||||
row.theInboundQuantity = Number(row.theInboundQuantity); |
|
||||||
}, |
|
||||||
async getBatchOptions() { |
|
||||||
this.loading = true |
|
||||||
try { |
|
||||||
const res = await getAllQuarter(); |
|
||||||
this.batchOptions = res.data.result |
|
||||||
|
|
||||||
} catch (error) { |
|
||||||
this.$message.error("获取数据来源失败,请重试"); |
|
||||||
console.error("下拉选项请求失败:", error); |
|
||||||
} finally { |
|
||||||
this.loading = false; |
|
||||||
} |
|
||||||
}, |
|
||||||
async getMaterialList() { |
|
||||||
this.loading = true |
|
||||||
try { |
|
||||||
const res = await getMaterialList(); |
|
||||||
this.materials = res.data.result |
|
||||||
console.log(this.materials, '获99来源') |
|
||||||
|
|
||||||
} catch (error) { |
|
||||||
this.$message.error("获取数据来源失败,请重试"); |
|
||||||
console.error("下拉选项请求失败:", error); |
|
||||||
} finally { |
|
||||||
this.loading = false; |
|
||||||
} |
|
||||||
}, |
|
||||||
inInit() { |
|
||||||
const randomNum = Math.floor(Math.random() * 100000000) + 1; |
|
||||||
this.sizeForm.orderNo = String(randomNum).padStart(8, '0');//入库单号 |
|
||||||
this.sizeForm.applyNmae = '审批人一' |
|
||||||
this.sizeForm.submitName = '填报人一' |
|
||||||
this.sizeForm.option = 1 |
|
||||||
this.sizeForm.warehouseName = '仓库一' |
|
||||||
this.sizeForm.reason = '入库' |
|
||||||
this.sizeForm.materialType = '1' |
|
||||||
this.sizeForm.inDate = new Date()//入库时间 |
|
||||||
|
|
||||||
// this.sizeForm.inTableData.push({ |
|
||||||
// str1: '000001', |
|
||||||
// str2: '物品1', |
|
||||||
// str3: '规格1', |
|
||||||
// type: '类别1', |
|
||||||
// unit: '单位1', |
|
||||||
// str6: '11', |
|
||||||
// str7: '22', |
|
||||||
// str8: '3', |
|
||||||
// str9: '部门一', |
|
||||||
// name: '审批人', |
|
||||||
// status: '1',// |
|
||||||
// }) |
|
||||||
}, |
|
||||||
addInit() { |
|
||||||
// 生成入库单号 |
|
||||||
const randomNum = Math.floor(Math.random() * 100000000) + 1; |
|
||||||
this.sizeForm.orderNo = String(randomNum).padStart(8, '0');//入库单号 |
|
||||||
this.sizeForm.inDate = new Date()//入库时间 |
|
||||||
if (this.type == '一级库') { |
|
||||||
this.sizeForm.warehouseName = '仓库一' |
|
||||||
} |
|
||||||
}, |
|
||||||
handleCloseDetail() { |
|
||||||
this.inDialogVisible = false |
|
||||||
this.$emit('handleCloseDetail') |
|
||||||
}, |
|
||||||
async inTableAdd() { |
|
||||||
this.sizeForm.inTableData.push({ |
|
||||||
unit: '', |
|
||||||
model: '', |
|
||||||
str3: '', |
|
||||||
str4: '', |
|
||||||
str5: '', |
|
||||||
str6: '', |
|
||||||
str7: 0, |
|
||||||
str8: '', |
|
||||||
str9: '', |
|
||||||
name: '', |
|
||||||
status: '',// |
|
||||||
materialId: '', |
|
||||||
materialName: '', |
|
||||||
}) |
|
||||||
}, |
|
||||||
// 点击入库 |
|
||||||
putIn(row) { |
|
||||||
row.status = 0 |
|
||||||
// 更改总表的数据 |
|
||||||
this.sizeForm.inAccountsTableData.push({ |
|
||||||
str1: "000001", |
|
||||||
str2: "物品1", |
|
||||||
str3: "规格1", |
|
||||||
str4: "类别1", |
|
||||||
str5: "单位1", |
|
||||||
str6: "12", |
|
||||||
str7: "3", |
|
||||||
str8: row.str7, |
|
||||||
str9: "3", |
|
||||||
str10: row.str7 + 12, |
|
||||||
str11: "3", |
|
||||||
str12: "审批人1", |
|
||||||
str13: "2025-04-05", |
|
||||||
}) |
|
||||||
}, |
|
||||||
// 采购单选择弹框关闭 |
|
||||||
handleBatchClose() { |
|
||||||
this.inBatchDialogVisible = false |
|
||||||
}, |
|
||||||
// 采购单选择确定 |
|
||||||
async batchSubmit() { |
|
||||||
if (!this.batchType) { |
|
||||||
this.$message.warning("请选择数据来源") |
|
||||||
return |
|
||||||
} |
|
||||||
const selectedOption = this.batchOptions.find(option => option.ids === this.batchType); |
|
||||||
if (!selectedOption) { |
|
||||||
this.$message.error("未找到对应的采购单信息"); |
|
||||||
return |
|
||||||
} |
|
||||||
this.sizeForm.quarterName = selectedOption.quarterName |
|
||||||
this.loading = true |
|
||||||
const res = await getPurchasesByIds(this.batchType); |
|
||||||
console.log("res", res) |
|
||||||
if (res.data.success) { |
|
||||||
this.sizeForm.inTableData = res.data.result; |
|
||||||
this.$message.success("数据获取成功"); |
|
||||||
this.inBatchDialogVisible = false; |
|
||||||
} else { |
|
||||||
this.$message.error(res.data.message || "获取数据失败"); |
|
||||||
} |
|
||||||
this.loading = false; |
|
||||||
}, |
|
||||||
// 处理物资选择变化 |
|
||||||
async handleMaterialChange(row) { |
|
||||||
console.log(row, "row",row.materialId) |
|
||||||
if (!row.materialId) { |
|
||||||
this.$message.warning("请选择物资名称"); |
|
||||||
return |
|
||||||
} |
|
||||||
try { |
|
||||||
const res = await getDetailList({ |
|
||||||
id: row.materialId |
|
||||||
}) |
|
||||||
console.log("res1", res) |
|
||||||
if (res.data.success) { |
|
||||||
this.sizeForm.inTableData = res.data.result; |
|
||||||
console.log("this.sizeForm.inTableData", this.sizeForm.inTableData) |
|
||||||
} else { |
|
||||||
this.$message.error(res.data.message || "获取物资信息失败"); |
|
||||||
} |
|
||||||
} catch (error) { |
|
||||||
this.$message.error("请求失败,请重试"); |
|
||||||
console.error("获取物资信息错误:", error); |
|
||||||
} |
|
||||||
}, |
|
||||||
changeName(index) { |
|
||||||
console.log(9999, index) |
|
||||||
this.sizeForm.inTableData.forEach((item, i) => { |
|
||||||
if (i == index) { |
|
||||||
item.str1 = '000001' |
|
||||||
item.str2 = '物资1' |
|
||||||
item.str3 = '规格1' |
|
||||||
item.str4 = '类别1' |
|
||||||
item.str5 = '单位1' |
|
||||||
item.str6 = '11' |
|
||||||
item.str7 = 22 |
|
||||||
item.str8 = '3' |
|
||||||
item.str9 = '部门一' |
|
||||||
item.name = '审批人' |
|
||||||
item.status = '1' |
|
||||||
this.$set(item, 'str7', 22) |
|
||||||
} |
|
||||||
}) |
|
||||||
console.log(888888, this.sizeForm.inTableData) |
|
||||||
}, |
|
||||||
// 保存 暂存 |
|
||||||
save() { |
|
||||||
this.$message({ |
|
||||||
type: "success", |
|
||||||
message: "保存成功" |
|
||||||
}); |
|
||||||
this.handleCloseDetail() |
|
||||||
}, |
|
||||||
// 提交 |
|
||||||
submit() { |
|
||||||
// status ==1 展示入库 |
|
||||||
let flag = this.sizeForm.inTableData.some(item => item.status == 1) |
|
||||||
if (flag) { |
|
||||||
this.$message({ |
|
||||||
type: "warning", |
|
||||||
message: "" |
|
||||||
}); |
|
||||||
return false |
|
||||||
} |
|
||||||
this.$message({ |
|
||||||
type: "success", |
|
||||||
message: "提交成功" |
|
||||||
}); |
|
||||||
// this.handleCloseDetail() |
|
||||||
}, |
|
||||||
// 选项选择 |
|
||||||
radioChange(val) { |
|
||||||
this.sizeForm.inTableData = [] |
|
||||||
if (this.sizeForm.option == 1) { |
|
||||||
this.inBatchDialogVisible = true |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
</script> |
|
||||||
<style lang="scss" scoped> |
|
||||||
.form-title { |
|
||||||
font-size: 16px; |
|
||||||
font-weight: 600; |
|
||||||
padding: 18px 0; |
|
||||||
} |
|
||||||
</style> |
|
||||||
@ -1,262 +0,0 @@ |
|||||||
<template> |
|
||||||
<el-dialog :close-on-click-modal="false" :title="categoryDialogTitle" :visible.sync="categoryVisible" |
|
||||||
:append-to-body="true" width="70%" @close="handleCloseDetail" fullscreen> |
|
||||||
<el-tabs v-model="transactionType" @tab-click="handleTabClick"> |
|
||||||
<el-tab-pane label="易耗品" name="YH"></el-tab-pane> |
|
||||||
<el-tab-pane label="耐用品" name="NY"></el-tab-pane> |
|
||||||
</el-tabs> |
|
||||||
<avue-crud :option="option" :table-loading="loading" :data="data" ref="crud" v-model="form" :page.sync="page" |
|
||||||
:permission="permissionList" @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset" |
|
||||||
@selection-change="selectionChange" @current-change="currentChange" @size-change="sizeChange" |
|
||||||
@refresh-change="refreshChange" @on-load="onLoad" @row-change="handleRowChange"> |
|
||||||
</avue-crud> |
|
||||||
<div slot="footer" class="dialog-footer"> |
|
||||||
<el-button @click="handleCancel">取消</el-button> |
|
||||||
<el-button type="primary" @click="handleConfirm">确定</el-button> |
|
||||||
</div> |
|
||||||
</el-dialog> |
|
||||||
</template> |
|
||||||
<script> |
|
||||||
import { getList } from "@/api/secondOrder/list.js"; |
|
||||||
import { getList as fetchDurableApi } from "@/api/materials/expend"; |
|
||||||
|
|
||||||
export default { |
|
||||||
props: { |
|
||||||
categoryVisible: { |
|
||||||
type: Boolean, |
|
||||||
default: false |
|
||||||
}, |
|
||||||
categoryDialogTitle: { |
|
||||||
type: String, |
|
||||||
default: '' |
|
||||||
}, |
|
||||||
departmentId: { |
|
||||||
type: String, |
|
||||||
default: '' |
|
||||||
}, |
|
||||||
selectionData: { |
|
||||||
type: Object, |
|
||||||
default: [] |
|
||||||
} |
|
||||||
}, |
|
||||||
data() { |
|
||||||
return { |
|
||||||
form: {}, |
|
||||||
selectionList: [], |
|
||||||
newselection: [], |
|
||||||
query: {}, |
|
||||||
loading: true, |
|
||||||
page: { |
|
||||||
pageSize: 10, |
|
||||||
currentPage: 1, |
|
||||||
total: 0, |
|
||||||
}, |
|
||||||
option: { |
|
||||||
reserveSelection: true, |
|
||||||
calcHeight: 30, |
|
||||||
tip: false, |
|
||||||
searchShow: true, |
|
||||||
searchMenuSpan: 18, |
|
||||||
border: true, |
|
||||||
index: true, |
|
||||||
selection: true, |
|
||||||
viewBtn: true, |
|
||||||
dialogClickModal: false, |
|
||||||
menu: false, |
|
||||||
addBtn: false, |
|
||||||
printBtn: false, |
|
||||||
refreshBtn: false, |
|
||||||
gridBtn: false, |
|
||||||
gridBackgroundImage: false, |
|
||||||
gridSpan: false, |
|
||||||
filterBtn: false, |
|
||||||
columnBtn: false, |
|
||||||
menuAlign: "left", |
|
||||||
searchMenuPosition: "right", |
|
||||||
menuWidth: 80, |
|
||||||
selectable: (row, index) => row.num !== 0, |
|
||||||
column: [ |
|
||||||
{ |
|
||||||
label: "存货编号", |
|
||||||
prop: "materialCode", |
|
||||||
headerAlign: "center", |
|
||||||
align: "center", |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "存货名称", |
|
||||||
prop: "materialName", |
|
||||||
search: true, |
|
||||||
headerAlign: "center", |
|
||||||
align: "left", |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "规格型号", |
|
||||||
prop: "model", |
|
||||||
headerAlign: "center", |
|
||||||
align: "left", |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "类别", |
|
||||||
prop: "type", |
|
||||||
search: false, |
|
||||||
type: "select", |
|
||||||
headerAlign: "center", |
|
||||||
align: "center", |
|
||||||
value: "NY", |
|
||||||
disabled: true, |
|
||||||
dicData: [ |
|
||||||
{ |
|
||||||
label: "易耗品", |
|
||||||
value: "YH", |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "耐用品", |
|
||||||
value: "NY", |
|
||||||
}, |
|
||||||
], |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "计量单位", |
|
||||||
prop: "unit", |
|
||||||
headerAlign: "center", |
|
||||||
align: "center", |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "数量", |
|
||||||
prop: "num", |
|
||||||
headerAlign: "center", |
|
||||||
align: "center", |
|
||||||
}, |
|
||||||
{ |
|
||||||
label: "单价", |
|
||||||
prop: "unitPrice", |
|
||||||
headerAlign: "center", |
|
||||||
align: "center", |
|
||||||
formatter: (row, column) => { |
|
||||||
const value = row.unitPrice; |
|
||||||
if (value === null || value === undefined || value === "") { |
|
||||||
return "-"; |
|
||||||
} |
|
||||||
return value; |
|
||||||
} |
|
||||||
}, |
|
||||||
], |
|
||||||
}, |
|
||||||
data: [], |
|
||||||
dialogLogVisible: false, |
|
||||||
transactionType: "YH", |
|
||||||
tableData: [], |
|
||||||
ckTable: [], |
|
||||||
rkTable: [], |
|
||||||
currentRow: null, |
|
||||||
allSelectedList: [], |
|
||||||
isUpdatingSelection: false, |
|
||||||
} |
|
||||||
}, |
|
||||||
mounted() { |
|
||||||
this.onLoad(this.page); |
|
||||||
}, |
|
||||||
methods: { |
|
||||||
//清空搜索 |
|
||||||
searchReset() { |
|
||||||
this.query = {}; |
|
||||||
this.onLoad(this.page); |
|
||||||
}, |
|
||||||
searchChange(params, done) { |
|
||||||
this.query = params; |
|
||||||
this.page.currentPage = 1; |
|
||||||
this.onLoad(this.page, params); |
|
||||||
done(); |
|
||||||
}, |
|
||||||
|
|
||||||
//勾选选中 |
|
||||||
selectionChange(selection) { |
|
||||||
console.log(this.selectionData, '---selectionData') |
|
||||||
const currentPageIds = this.selectionData.map(item => item.id) |
|
||||||
let arr = selection.filter(item => !currentPageIds.includes(item.id)) //未选择的数据 |
|
||||||
const selectionWithTwoInventoryId = arr.map(item => ({ |
|
||||||
...item, |
|
||||||
twoInventoryId: item.id |
|
||||||
})) |
|
||||||
this.allSelectedList.push(...selectionWithTwoInventoryId); |
|
||||||
this.allSelectedList = this.uniqueById(this.allSelectedList); |
|
||||||
}, |
|
||||||
//去重 |
|
||||||
uniqueById(arr) { |
|
||||||
const uniqueObj = {}; |
|
||||||
arr.forEach(item => { |
|
||||||
if (item.id && !uniqueObj[item.id]) { |
|
||||||
uniqueObj[item.id] = item; |
|
||||||
} |
|
||||||
}); |
|
||||||
return Object.values(uniqueObj); |
|
||||||
}, |
|
||||||
//点击确定 |
|
||||||
handleConfirm() { |
|
||||||
const uniqueList = this.uniqueById(this.allSelectedList); |
|
||||||
this.$emit("confirm", uniqueList); |
|
||||||
}, |
|
||||||
handleCloseDetail() { |
|
||||||
this.$emit('handleCloseDetail') |
|
||||||
}, |
|
||||||
selectionClear() { |
|
||||||
this.allSelectedList = [] |
|
||||||
if (this.$refs.crud) { |
|
||||||
this.$refs.crud.toggleSelection() |
|
||||||
} |
|
||||||
}, |
|
||||||
currentChange(currentPage) { |
|
||||||
this.page.currentPage = currentPage; |
|
||||||
this.onLoad(this.page, this.query); |
|
||||||
}, |
|
||||||
|
|
||||||
sizeChange(pageSize) { |
|
||||||
this.page.pageSize = pageSize; |
|
||||||
this.onLoad(this.page, this.query); |
|
||||||
}, |
|
||||||
refreshChange() { |
|
||||||
this.onLoad(this.page, this.query); |
|
||||||
}, |
|
||||||
handleTabClick() { |
|
||||||
this.page.currentPage = 1; |
|
||||||
this.onLoad(this.page); |
|
||||||
}, |
|
||||||
|
|
||||||
onLoad(page, params = {}) { |
|
||||||
this.loading = true; |
|
||||||
const requestParams = Object.assign({}, params, this.query, { |
|
||||||
num: 0, |
|
||||||
departmentId: this.departmentId |
|
||||||
}); |
|
||||||
const apiPromise = this.transactionType === "YH" |
|
||||||
? getList(page.currentPage, page.pageSize, requestParams) |
|
||||||
: fetchDurableApi(page.currentPage, page.pageSize, requestParams); |
|
||||||
apiPromise.then((res) => { |
|
||||||
this.data = res.data.result.list; |
|
||||||
this.page.total = res.data.result.total; |
|
||||||
}).catch(error => { |
|
||||||
this.$message.error('加载数据失败: ' + error.message); |
|
||||||
}).finally(() => { |
|
||||||
this.loading = false; |
|
||||||
}); |
|
||||||
}, |
|
||||||
handleCancel() { |
|
||||||
this.categoryVisible = false |
|
||||||
} |
|
||||||
}, |
|
||||||
} |
|
||||||
</script> |
|
||||||
<style lang="scss" scoped> |
|
||||||
::v-deep.el-dialog__footer { |
|
||||||
position: fixed !important; |
|
||||||
bottom: 0 !important; |
|
||||||
right: 0 !important; |
|
||||||
} |
|
||||||
|
|
||||||
::v-deep.dialog-content { |
|
||||||
max-height: calc(100vh - 200px); |
|
||||||
overflow-y: auto; |
|
||||||
padding-right: 10px; |
|
||||||
overflow-x: hidden; |
|
||||||
} |
|
||||||
</style> |
|
||||||
Loading…
Reference in new issue