入库单自动把采购单的字段显示出来,并且可以修改,非必填,需要有搜索功能。显示时按分类进行分组展示,可以按分类进行展开收起

This commit is contained in:
xiaofajia 2024-11-19 19:22:52 +08:00
parent fb7d3e496f
commit 3da6b6dd36
3 changed files with 268 additions and 92 deletions

View File

@ -26,3 +26,11 @@ export function getRepairSoiBySoId(soId){
method: 'get' method: 'get'
}) })
} }
// 根据主表的ID得到子表的所有数据按类型区分的map支持条件查询
export function getMapBySoIdAndQuery(id, query){
return request({
url: preUrl + "/getMapBySoIdAndQuery?id=" + id + "&query=" + query,
method: 'get'
})
}

View File

@ -42,41 +42,41 @@
</el-form> </el-form>
<!-- 操作 --> <!-- 操作 -->
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<!-- <el-col :span="1.5">--> <!-- <el-col :span="1.5">-->
<!-- <el-button type="primary" plain icon="el-icon-download" size="mini"--> <!-- <el-button type="primary" plain icon="el-icon-download" size="mini"-->
<!-- >导出--> <!-- >导出-->
<!-- </el-button>--> <!-- </el-button>-->
<!-- </el-col>--> <!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch"></right-toolbar> <right-toolbar :showSearch.sync="showSearch"></right-toolbar>
</el-row> </el-row>
<!-- 急件 --> <!-- 急件 -->
<!-- <el-table v-if="goodsYes" v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">--> <!-- <el-table v-if="goodsYes" v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">-->
<!-- <el-table-column label="序号" align="center">--> <!-- <el-table-column label="序号" align="center">-->
<!-- <template scope="scope">--> <!-- <template scope="scope">-->
<!-- <span>{{ scope.$index + 1 }}</span>--> <!-- <span>{{ scope.$index + 1 }}</span>-->
<!-- </template>--> <!-- </template>-->
<!-- </el-table-column>--> <!-- </el-table-column>-->
<!-- <el-table-column label="单号" align="center" prop="soId" width="200"/>--> <!-- <el-table-column label="单号" align="center" prop="soId" width="200"/>-->
<!-- <el-table-column label="商品名称" align="center" width="180" prop="name"/>--> <!-- <el-table-column label="商品名称" align="center" width="180" prop="name"/>-->
<!-- <el-table-column label="规格" align="center" width="180" prop="name"/>--> <!-- <el-table-column label="规格" align="center" width="180" prop="name"/>-->
<!-- <el-table-column label="商品编码" align="center" width="180" prop="name"/>--> <!-- <el-table-column label="商品编码" align="center" width="180" prop="name"/>-->
<!-- <el-table-column label="所属分类" align="center" width="150" prop="name"/>--> <!-- <el-table-column label="所属分类" align="center" width="150" prop="name"/>-->
<!-- <el-table-column label="数量" align="center" width="150" prop="name"/>--> <!-- <el-table-column label="数量" align="center" width="150" prop="name"/>-->
<!-- <el-table-column label="单位" align="center" width="150" prop="name"/>--> <!-- <el-table-column label="单位" align="center" width="150" prop="name"/>-->
<!-- <el-table-column label="成本" align="center" width="150" prop="name"/>--> <!-- <el-table-column label="成本" align="center" width="150" prop="name"/>-->
<!-- <el-table-column label="供应商" align="center" width="180" prop="name"/>--> <!-- <el-table-column label="供应商" align="center" width="180" prop="name"/>-->
<!-- <el-table-column label="仓库" align="center" width="150" prop="name"/>--> <!-- <el-table-column label="仓库" align="center" width="150" prop="name"/>-->
<!-- <el-table-column label="状态" align="center" width="150" prop="name"/>--> <!-- <el-table-column label="状态" align="center" width="150" prop="name"/>-->
<!-- <el-table-column label="时间" align="center" width="150" prop="name"/>--> <!-- <el-table-column label="时间" align="center" width="150" prop="name"/>-->
<!-- <el-table-column label="门店" align="center" width="180" prop="name"/>--> <!-- <el-table-column label="门店" align="center" width="180" prop="name"/>-->
<!-- <el-table-column label="操作" align="center" width="180" fixed="right">--> <!-- <el-table-column label="操作" align="center" width="180" fixed="right">-->
<!-- <template v-slot="scope">--> <!-- <template v-slot="scope">-->
<!-- <el-button size="mini" type="text" icon="el-icon-edit"--> <!-- <el-button size="mini" type="text" icon="el-icon-edit"-->
<!-- >审核--> <!-- >审核-->
<!-- </el-button>--> <!-- </el-button>-->
<!-- </template>--> <!-- </template>-->
<!-- </el-table-column>--> <!-- </el-table-column>-->
<!-- </el-table>--> <!-- </el-table>-->
<!-- 采购/领料 --> <!-- 采购/领料 -->
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true"> <el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
@ -88,9 +88,11 @@
<el-table-column label="单号" align="center" prop="soNo" width="200"/> <el-table-column label="单号" align="center" prop="soNo" width="200"/>
<el-table-column label="数量" align="center" prop="itemCount" width="150"/> <el-table-column label="数量" align="center" prop="itemCount" width="150"/>
<el-table-column label="金额" align="center" prop="totalPrice" width="150"/> <el-table-column label="金额" align="center" prop="totalPrice" width="150"/>
<el-table-column :label="soByType ? '采购员' : !isBack ? '领料人' : '退料人'" align="center" prop="userName" width="150"/> <el-table-column :label="soByType ? '采购员' : !isBack ? '领料人' : '退料人'" align="center" prop="userName"
width="150"/>
<el-table-column v-if="soByType" label="供应商" align="center" prop="supplierName" width="200"/> <el-table-column v-if="soByType" label="供应商" align="center" prop="supplierName" width="200"/>
<el-table-column :label="soByType ? '入库时间' : !isBack ? '领料时间' : '退料时间'" align="center" prop="soTime" width="150"/> <el-table-column :label="soByType ? '入库时间' : !isBack ? '领料时间' : '退料时间'" align="center" prop="soTime"
width="150"/>
<el-table-column label="登记时间" align="center" prop="createTime" width="150"> <el-table-column label="登记时间" align="center" prop="createTime" width="150">
<template slot-scope="scope"> <template slot-scope="scope">
{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }} {{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}
@ -108,7 +110,8 @@
<el-button size="mini" type="text" icon="el-icon-view" @click="handleShow(scope.row)" <el-button size="mini" type="text" icon="el-icon-view" @click="handleShow(scope.row)"
>查看 >查看
</el-button> </el-button>
<el-button @click="handleInWares(scope.row)" v-if="scope.row.soStatus === '02'" size="mini" type="text" icon="el-icon-edit-outline" <el-button @click="handleInWares(scope.row)" v-if="scope.row.soStatus === '02'" size="mini" type="text"
icon="el-icon-edit-outline"
>入库 >入库
</el-button> </el-button>
<el-button size="mini" type="text" icon="el-icon-close" @click="handleVoidSo(scope.row)" <el-button size="mini" type="text" icon="el-icon-close" @click="handleVoidSo(scope.row)"
@ -118,33 +121,111 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<!-- 分页 --> <!-- 分页 -->
<pagination @pagination="pageSo" style="margin-bottom: 3rem" v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" <pagination @pagination="pageSo" style="margin-bottom: 3rem" v-show="total > 0" :total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
/> />
<SoShow :so-by-type="soByType" :is-back="isBack" ref="soShow" /> <SoShow :so-by-type="soByType" :is-back="isBack" ref="soShow"/>
<el-dialog title="入库" :visible.sync="dialogVisible" width="80%" v-dialogDrag append-to-body> <el-dialog title="入库" :visible.sync="dialogVisible" width="80%" v-dialogDrag append-to-body>
<el-table v-loading="inLoading" :data="inItems" :stripe="true" :show-overflow-tooltip="true" <el-form :inline="true">
@selection-change="selectRow" <el-form-item label="关键字">
@cell-mouse-enter="handleCellEnter" <el-input v-model="inItemsQuery" placeholder="名称、规格、编码"/>
@cell-mouse-leave="handleCellLeave" </el-form-item>
@cell-click="handleCellClick" <el-form-item>
:key="tableKey" <el-button type="primary" icon="el-icon-search" @click="searchByQuery">搜索</el-button>
> <el-button icon="el-icon-refresh" @click=resetByQuery>重置</el-button>
<el-table-column type="selection" width="55" align="center"/> </el-form-item>
<el-table-column label="商品名称" align="center" prop="repairWares.name" /> </el-form>
<el-table-column label="商品编码" align="center" prop="repairWares.code" width="180" /> <el-collapse>
<el-table-column label="条形码" align="center" prop="repairWares.barCode" width="180" /> <el-collapse-item v-for="([key, value], index) in inItems" :title="key">
<el-table-column label="规格" align="center" prop="repairWares.model" width="180" /> <el-table v-loading="inLoading" :ref="`tableRef_${index}`" :data="value" :stripe="true"
<el-table-column label="采购数量" align="center" prop="goodsCount" width="150" /> :show-overflow-tooltip="true"
<el-table-column label="入库数量" align="center" prop="inCount" width="150"> @selection-change="selectRow"
<div class="item" slot-scope="scope"> @cell-mouse-enter="handleCellEnter"
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.inCount"/> @cell-mouse-leave="handleCellLeave"
<span class="item__txt">{{ scope.row.inCount }}</span> @cell-click="handleCellClick"
</div> >
</el-table-column> <el-table-column type="selection" width="55" align="center"/>
</el-table> <el-table-column label="商品名称" align="center" prop="wares.name"/>
<el-table-column label="规格" align="center" width="180" prop="wares.model">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.model"
placeholder="请输入规格"></el-input>
<span class="item__txt">{{ scope.row.wares.model }}</span>
</div>
</el-table-column>
<el-table-column label="分类" align="center" width="180" prop="wares.type">
<div class="item" slot-scope="scope">
<el-select class="item__input" clearable ref="selectTree" v-model="scope.row.wares.type"
@change="save(scope.row)">
<el-option v-for="server in optionData(serverList)"
:key="server.value"
:label="server.label"
:value="server.value" style="display: none"/>
<el-tree class="item__input" ref="selectedTree"
:data="serverList"
:props="treeProps"
highlight-current
@node-click="handleNodeClick($event, scope.row)"
:expand-on-click-node="expandOnClickNode"
default-expand-all/>
</el-select>
<span class="item__txt">{{ getTypeById(scope.row.wares.type) }}</span>
</div>
</el-table-column>
<el-table-column label="商品编码" align="center" width="180" prop="wares.code">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.code"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.wares.code }}</span>
</div>
</el-table-column>
<el-table-column label="仓库" align="center" width="150" prop="wares.warehouse">
<div class="item" slot-scope="scope">
<WarehouseChoose @input-blur="save(scope.row)" class="item__input" v-model="scope.row.wares.ware"
/>
<span class="item__txt">{{ scope.row.wares?.ware?.name }}</span>
</div>
</el-table-column>
<el-table-column label="库存" align="center" width="150" prop="wares.stock"/>
<el-table-column label="单位" align="center" width="150" prop="wares.unit">
<div class="item" slot-scope="scope">
<el-select class="item__input" v-model="scope.row.wares.unit" @blur="save(scope.row)">
<el-option v-for="dict in getDictDatasToType(DICT_TYPE.REPAIR_UNIT)" :key="dict.value"
:label="dict.label"
:value="dict.value"/>
</el-select>
<span class="item__txt">
<dict-tag :type="DICT_TYPE.REPAIR_UNIT" v-model="scope.row.wares.unit"/>
</span>
</div>
</el-table-column>
<el-table-column label="进价" align="center" width="150" prop="wares.purPrice">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.purPrice"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.wares.purPrice }}</span>
</div>
</el-table-column>
<el-table-column label="售价" align="center" width="150" prop="wares.price">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.price"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.wares.price }}</span>
</div>
</el-table-column>
<el-table-column label="采购数量" align="center" prop="goodsCount" width="150"/>
<el-table-column label="入库数量" align="center" prop="inCount" width="150">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.inCount"/>
<span class="item__txt">{{ scope.row.inCount }}</span>
</div>
</el-table-column>
</el-table>
</el-collapse-item>
</el-collapse>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button type="primary" :disabled="selectRows.length === 0" @click="doInWares">确定</el-button> <el-button type="primary" :disabled="selectRows.length === 0" @click="doInWares">确定</el-button>
<el-button @click="dialogVisible = false">取消</el-button> <el-button @click="dialogVisible = false">取消</el-button>
@ -161,8 +242,10 @@ import StaffChoose from "@/views/repair/Components/StaffChoose.vue";
import {DICT_TYPE} from "@/utils/dict"; import {DICT_TYPE} from "@/utils/dict";
import {getRepairSoPage, voidSo, getRepairSoById, inWare} from "@/api/repair/stockOperate/stockOperate"; import {getRepairSoPage, voidSo, getRepairSoById, inWare} from "@/api/repair/stockOperate/stockOperate";
import SoShow from "@/views/repair/stockOperate/Components/SoSow.vue"; import SoShow from "@/views/repair/stockOperate/Components/SoSow.vue";
import {getRepairSoiByIds} from "@/api/repair/stockOperate/stockOperateItem"; import {getRepairSoiByIds, getMapBySoIdAndQuery} from "@/api/repair/stockOperate/stockOperateItem";
import {createUniqueCodeByHead} from "@/utils/createUniqueCode"; import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
import WarehouseChoose from "@/views/repair/Components/WarehouseChoose.vue";
import {getBaseTypeList} from "@/api/base/type";
export default { export default {
name: "SoIndex", name: "SoIndex",
@ -173,6 +256,7 @@ export default {
} }
}, },
components: { components: {
WarehouseChoose,
SoShow, SoShow,
StaffChoose, StaffChoose,
SupplierChoose, SupplierChoose,
@ -189,7 +273,7 @@ export default {
defaultValue: false, defaultValue: false,
required: false required: false
}, },
isBack:{ isBack: {
type: Boolean type: Boolean
} }
}, },
@ -235,38 +319,108 @@ export default {
total: 0, total: 0,
dialogVisible: false, dialogVisible: false,
inItems: [], inItems: [],
inItemsQuery: null,
inLoading: false, inLoading: false,
selectRows: [], selectRows: [],
inWaresFormData:{ inWaresFormData: {
id: null, id: null,
soiList: [], soiList: [],
soNo: null soNo: null
}, },
editProp: ['inCount'], editProp: ['inCount', 'wares.model', 'wares.type', 'wares.code', 'wares.warehouse', 'wares.unit', 'wares.purPrice', 'wares.price'],
clickCellMap: {}, clickCellMap: {},
tableKey: 0 tableKey: 0,
soId: null,
expandOnClickNode: true,
serverList: [],
treeProps: {
label: "name",
children: "children"
},
typeMap: null,
selectRowIds: []
} }
}, },
mounted() { mounted() {
this.pageSo(); this.pageSo();
}, },
methods: { methods: {
setSelectedRows() {
this.$nextTick(() => {
Object.keys(this.$refs).forEach(key => {
if (key.startsWith('tableRef_')) {
const tableRef = this.$refs[key];
if (tableRef[0]){
tableRef[0].clearSelection(); //
this.inItems.forEach(([key, value]) => {
value.forEach(item => {
if (this.selectRowIds.includes(item.id)) {
tableRef[0].toggleRowSelection(item, true);
}
});
});
}
}
});
});
},
getDictDatasToType(type) {
return this.getDictDatas(type)
},
getTypeById(id) {
return this.typeMap.get(id)
},
async listServer() {
if (!this.serverList || this.serverList.length === 0) {
const res = await getBaseTypeList({type: "02"})
this.serverList = this.handleTree(res.data, 'id', 'parentId', "children", "0")
this.typeMap = new Map()
this.extractNodesToMap(this.serverList, this.typeMap)
}
},
extractNodesToMap(nodes, map) {
nodes.forEach(node => {
map.set(node.id, node.name);
if (node.children && node.children.length > 0) {
this.extractNodesToMap(node.children, map);
}
});
},
handleNodeClick(data, scopeRow) {
scopeRow.wares.type = data.id;
this.save(scopeRow)
},
optionData(array, result = []) {
array.forEach(item => {
result.push({label: item.name, value: item.id})
if (item.children && item.children.length !== 0) {
this.optionData(item.children, result)
}
})
return JSON.parse(JSON.stringify(result))
},
searchByQuery() {
this.getSoiList().then(() => {
this.setSelectedRows()
})
},
resetByQuery() {
this.inItemsQuery = null
this.searchByQuery()
},
// //
async pageSo() { async pageSo() {
this.queryParams.soType = null this.queryParams.soType = null
this.queryParams.purchaseType = null this.queryParams.purchaseType = null
if (this.soByType && this.goodsYes){ if (this.soByType && this.goodsYes) {
this.queryParams.soType = "03" this.queryParams.soType = "03"
this.queryParams.purchaseType = "02" this.queryParams.purchaseType = "02"
} } else if (this.soByType && !this.goodsYes) {
else if (this.soByType && !this.goodsYes){
this.queryParams.soType = "01" this.queryParams.soType = "01"
this.queryParams.purchaseType = "01" this.queryParams.purchaseType = "01"
} } else if (!this.soByType && !this.isBack) {
else if (!this.soByType && !this.isBack){
this.queryParams.soType = "02" this.queryParams.soType = "02"
} } else if (this.isBack) {
else if (this.isBack){
this.queryParams.soType = '04' this.queryParams.soType = '04'
} }
try { try {
@ -274,7 +428,7 @@ export default {
const res = await getRepairSoPage(this.queryParams) const res = await getRepairSoPage(this.queryParams)
this.list = res.data.records this.list = res.data.records
this.total = res.data.total this.total = res.data.total
}finally { } finally {
this.loading = false this.loading = false
} }
}, },
@ -321,49 +475,64 @@ export default {
} }
}, },
// //
async handleShow(row){ async handleShow(row) {
const res = await getRepairSoById(row.id) const res = await getRepairSoById(row.id)
await this.$refs.soShow.open(res.data) await this.$refs.soShow.open(res.data)
}, },
// //
async handleInWares(row){ async handleInWares(row) {
await this.listServer()
this.soId = row.id
this.inWaresFormData = { this.inWaresFormData = {
id: null, id: null,
soiList: [] soiList: []
} }
this.inWaresFormData['id'] = row.id this.inWaresFormData['id'] = row.id
await this.getSoiList()
},
async getSoiList() {
try { try {
this.dialogVisible = true this.dialogVisible = true
this.inLoading = true this.inLoading = true
const resRow = await getRepairSoById(row.id) const res = await getMapBySoIdAndQuery(this.soId, this.inItemsQuery)
const ids = resRow.data.goodsList.map(item => item.id) this.inItems = Object.entries(res.data)
const res = await getRepairSoiByIds(ids) this.inItems = this.inItems.filter(([key, value]) => {
this.inItems = res.data const newValue = value.filter(item => item.inCount !== item.goodsCount)
this.inItems = this.inItems.filter(item => item.inCount !== item.goodsCount) return newValue && newValue.length > 0
this.inItems = [...this.inItems.map(item => { })
return { this.inItems.forEach(([key, value]) => {
...item, value.forEach(item => {
goodsCount: item.goodsCount - item?.inCount | 0, item.goodsCount = item.goodsCount - item?.inCount | 0
inCount: item.goodsCount - item?.inCount | 0 item.inCount = item.goodsCount - item?.inCount | 0
} })
})] })
}finally { } finally {
this.inLoading = false this.inLoading = false
} }
}, },
selectRow(val){ selectRow(val) {
this.selectRows = val this.selectRows = val
if (val && val.length > 0) {
this.selectRowIds = val.map(item => item.id)
}
}, },
async doInWares(){ async doInWares() {
try { try {
this.inWaresFormData.soiList = this.selectRows this.inWaresFormData.soiList = this.selectRows
this.inWaresFormData.waresList = this.selectRows.map(item => {
if (item.wares.ware){
item.wares.warehouse = item.wares.ware.id
}
return item.wares
})
this.inWaresFormData.soNo = createUniqueCodeByHead("RC") this.inWaresFormData.soNo = createUniqueCodeByHead("RC")
this.inLoading = true this.inLoading = true
await inWare(this.inWaresFormData) await inWare(this.inWaresFormData)
this.dialogVisible = false this.dialogVisible = false
this.$modal.msgSuccess("入库成功") this.$modal.msgSuccess("入库成功")
await this.pageSo() await this.pageSo()
}catch{} } catch {
}
}, },
/** 鼠标移入cell */ /** 鼠标移入cell */
handleCellEnter(row, column, cell, event) { handleCellEnter(row, column, cell, event) {
@ -416,8 +585,8 @@ export default {
this.cancelEditable(cell) this.cancelEditable(cell)
}) })
this.clickCellMap[id] = [] this.clickCellMap[id] = []
this.tableKey++ // this.tableKey++
this.selectRows = [] // this.selectRows = []
}, },
} }
} }

View File

@ -300,7 +300,6 @@ export default {
twId: null, twId: null,
carInfo: {}, carInfo: {},
ticketId: null, ticketId: null,
serverSelected: undefined,
expandOnClickNode: true, expandOnClickNode: true,
serverList: [], serverList: [],
treeProps:{ treeProps:{