采购单,每个商品可以录入 进货价、收价、分类、计量单位,非必填,显示时按分类进行分组展示,可以按分类进行展开收起

This commit is contained in:
xiaofajia 2024-11-19 15:24:32 +08:00
parent 8c1c1f6e60
commit fb7d3e496f

View File

@ -114,105 +114,134 @@
<template slot="label"> <template slot="label">
车牌号 车牌号
</template> </template>
{{carInfo.licenseNumber}} {{ carInfo.licenseNumber }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template slot="label"> <template slot="label">
品牌 品牌
</template> </template>
{{carInfo.carBrand}} {{ carInfo.carBrand }}
</el-descriptions-item> </el-descriptions-item>
<el-descriptions-item> <el-descriptions-item>
<template slot="label"> <template slot="label">
型号 型号
</template> </template>
{{carInfo.carModel}} {{ carInfo.carModel }}
</el-descriptions-item> </el-descriptions-item>
</el-descriptions> </el-descriptions>
<el-collapse> <el-collapse>
<el-collapse-item v-for="[key, value] in partList" :title="key"> <el-collapse-item v-for="[key, value] in partList" :title="key">
<el-table <el-table
:data="value" :data="value"
:stripe="true" :stripe="true"
:show-overflow-tooltip="true" :show-overflow-tooltip="true"
show-summary show-summary
:summary-method="getSummaries" :summary-method="getSummaries"
@cell-mouse-enter="handleCellEnter" @cell-mouse-enter="handleCellEnter"
@cell-mouse-leave="handleCellLeave" @cell-mouse-leave="handleCellLeave"
@cell-click="handleCellClick" @cell-click="handleCellClick"
> >
<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="waresName" width="200"/> <el-table-column label="商品名称" align="center" prop="waresName" width="200"/>
<el-table-column label="规格" align="center" width="180" prop="wares.model"> <el-table-column label="规格" align="center" width="180" prop="wares.model">
<div class="item" slot-scope="scope"> <div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.model" <el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.model"
placeholder="请输入规格"></el-input> placeholder="请输入规格"></el-input>
<span class="item__txt">{{ scope.row.wares.model }}</span> <span class="item__txt">{{ scope.row.wares.model }}</span>
</div> </div>
</el-table-column> </el-table-column>
<el-table-column label="商品编码" align="center" width="180" prop="wares.code"> <el-table-column label="分类" align="center" width="180" prop="wares.type">
<div class="item" slot-scope="scope"> <div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.code" <el-select class="item__input" clearable ref="selectTree" v-model="scope.row.wares.type" @change="save(scope.row)">
placeholder="请输入内容"></el-input> <el-option v-for="server in optionData(serverList)"
<span class="item__txt">{{ scope.row.wares.code }}</span> :key="server.value"
</div> :label="server.label"
</el-table-column> :value="server.value" style="display: none"/>
<el-table-column label="仓库" align="center" width="150" prop="wares.warehouse"> <el-tree class="item__input" ref="selectedTree"
<div class="item" slot-scope="scope"> :data="serverList"
<WarehouseChoose @input-blur="save(scope.row)" class="item__input" v-model="scope.row.wares.ware" :props="treeProps"
@change="changeWare(scope.row)"/> highlight-current
<span class="item__txt">{{ scope.row.wares.warehouseName }}</span> @node-click="handleNodeClick($event, scope.row)"
</div> :expand-on-click-node="expandOnClickNode"
</el-table-column> default-expand-all />
<el-table-column label="库存" align="center" width="150" prop="wares.stock"/> </el-select>
<el-table-column label="单位" align="center" width="150" prop="wares.unit"> <span class="item__txt">{{ getTypeById(scope.row.wares.type) }}</span>
<div class="item" slot-scope="scope"> </div>
<el-select class="item__input" v-model="scope.row.wares.unit" @blur="save(scope.row)"> </el-table-column>
<el-option v-for="dict in getDictDatasToType(DICT_TYPE.REPAIR_UNIT)" :key="dict.value" :label="dict.label" <el-table-column label="商品编码" align="center" width="180" prop="wares.code">
:value="dict.value"/> <div class="item" slot-scope="scope">
</el-select> <el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.code"
<span class="item__txt"> 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"
@change="changeWare(scope.row)"/>
<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"/> <dict-tag :type="DICT_TYPE.REPAIR_UNIT" v-model="scope.row.wares.unit"/>
</span> </span>
</div> </div>
</el-table-column> </el-table-column>
<el-table-column label="数量" align="center" width="150" prop="waresCount"> <el-table-column label="数量" align="center" width="150" prop="waresCount">
<div class="item" slot-scope="scope"> <div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.waresCount" <el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.waresCount"
placeholder="请输入内容"></el-input> placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.waresCount }}</span> <span class="item__txt">{{ scope.row.waresCount }}</span>
</div> </div>
</el-table-column> </el-table-column>
<el-table-column label="上次进价" align="center" width="150" prop="wares.purPrice"/> <el-table-column label="进价" align="center" width="150" prop="wares.purPrice">
<el-table-column label="采购单价" align="center" width="150" prop="wares.newPrice"> <div class="item" slot-scope="scope">
<div class="item" slot-scope="scope"> <el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.purPrice"
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.newPrice" placeholder="请输入内容"></el-input>
placeholder="请输入内容"></el-input> <span class="item__txt">{{ scope.row.wares.purPrice }}</span>
<span class="item__txt">{{ scope.row.wares.newPrice }}</span> </div>
</div> </el-table-column>
</el-table-column> <el-table-column label="售价" align="center" width="150" prop="wares.price">
<el-table-column label="采购金额" align="center" width="150" prop="totalPrice"/> <div class="item" slot-scope="scope">
<el-table-column label="备注" align="center" width="180" prop="remark"> <el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.price"
<div class="item" slot-scope="scope"> placeholder="请输入内容"></el-input>
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.remark" <span class="item__txt">{{ scope.row.wares.price }}</span>
placeholder="请输入内容"></el-input> </div>
<span class="item__txt">{{ scope.row.remark }}</span> </el-table-column>
</div> <el-table-column label="总金额" align="center" width="150" prop="totalPrice"/>
</el-table-column> <el-table-column label="备注" align="center" width="180" prop="remark">
<el-table-column label="操作" fixed="right" align="center" width="150"> <div class="item" slot-scope="scope">
<template v-slot="scope"> <el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.remark"
<el-button size="mini" type="text" icon="el-icon-delete" @click="deleteItem(scope.$index)" placeholder="请输入内容"></el-input>
>删除 <span class="item__txt">{{ scope.row.remark }}</span>
</el-button> </div>
</template> </el-table-column>
</el-table-column> <el-table-column label="操作" fixed="right" align="center" width="150">
</el-table> <template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="deleteItem(scope.$index)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-collapse-item> </el-collapse-item>
</el-collapse> </el-collapse>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSubmit">保存</el-button>
<el-button @click="inStockDialog = false">取消</el-button>
</div>
</el-dialog> </el-dialog>
<TicketWaresShow ref="ticketWaresShow" :user-role="'repair_warehouse'" @success="getList" :type="false"/> <TicketWaresShow ref="ticketWaresShow" :user-role="'repair_warehouse'" @success="getList" :type="false"/>
@ -231,6 +260,8 @@ import {getUserProfile} from "@/api/system/user";
import TicketWaresShow from "@/views/repair/tickets/Components/TicketWaresShow.vue"; import TicketWaresShow from "@/views/repair/tickets/Components/TicketWaresShow.vue";
import {getCusAndCarById} from "@/api/repair/tickets/Tickets"; import {getCusAndCarById} from "@/api/repair/tickets/Tickets";
import {getCarBrand} from "@/api/base/carbrand"; import {getCarBrand} from "@/api/base/carbrand";
import {listGoods} from "@/views/partner/api/workOrder";
import {getBaseTypeList} from "@/api/base/type";
export default { export default {
name: "WaresItem", name: "WaresItem",
@ -258,24 +289,64 @@ export default {
formData: {}, formData: {},
inStockDialog: false, inStockDialog: false,
partList: [], partList: [],
includeColumn: ['count', 'totalPrice'], includeColumn: ['waresCount', 'totalPrice'],
// cell // cell
clickCellMap: {}, clickCellMap: {},
// //
editProp: ['warehouse', 'count', 'newPrice', 'remark', 'code', 'waresCount', 'wares.model', 'unit'], editProp: ['wares.warehouse', 'wares.type', 'waresCount', 'wares.purPrice', 'wares.price', 'remark', 'wares.code', 'waresCount', 'wares.model', 'wares.unit'],
remark: null, remark: null,
tableKey: 0, tableKey: 0,
query: null, query: null,
twId: null, twId: null,
carInfo: {}, carInfo: {},
ticketId: null, ticketId: null,
serverSelected: undefined,
expandOnClickNode: true,
serverList: [],
treeProps:{
label: "name",
children: "children"
},
typeMap: null,
} }
}, },
mounted() { mounted() {
this.getList() this.getList()
}, },
methods: { methods: {
searchByQuery(){ 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() {
const data = { const data = {
twId: this.twId, twId: this.twId,
query: this.query query: this.query
@ -340,16 +411,23 @@ export default {
try { try {
const carRes = await getCusAndCarById(this.ticketId) const carRes = await getCusAndCarById(this.ticketId)
this.carInfo = carRes.data.carInfo this.carInfo = carRes.data.carInfo
if (this.carInfo.carBrand){ if (this.carInfo.carBrand) {
const brandRes = await getCarBrand(this.carInfo.carBrand) const brandRes = await getCarBrand(this.carInfo.carBrand)
this.carInfo.carBrand = brandRes.data.brandName this.carInfo.carBrand = brandRes.data.brandName
} }
const ids = this.selections.map(item => item.id) const ids = this.selections.map(item => item.id)
const res = await getByIds(ids) const res = await getByIds(ids)
this.partList = Object.entries(res.data) this.partList = Object.entries(res.data)
const values = this.partList.map(([key, value]) => value)
values.forEach(item => {
item.forEach(i => {
i.totalPrice = i.waresCount * i.wares.price
})
})
this.inStockDialog = true this.inStockDialog = true
this.dialogVisible = false this.dialogVisible = false
}catch{} } catch {
}
}, },
async getList() { async getList() {
try { try {
@ -372,6 +450,7 @@ export default {
this.handleQuery() this.handleQuery()
}, },
handleDispose(row) { handleDispose(row) {
this.listServer()
this.formData = {} this.formData = {}
this.formData = { this.formData = {
...row ...row
@ -404,7 +483,7 @@ export default {
}, },
handleSelect(row) { handleSelect(row) {
this.selections = row this.selections = row
if (row && row.length > 0){ if (row && row.length > 0) {
this.selectionIds = row.map(item => item.id); this.selectionIds = row.map(item => item.id);
} }
}, },
@ -483,7 +562,13 @@ export default {
this.$modal.msgWarning("退料数量不能超过领取数量") this.$modal.msgWarning("退料数量不能超过领取数量")
row.waresCount = row.waresAlreadyCount row.waresCount = row.waresAlreadyCount
} }
row.totalPrice = row.count * row.newPrice this.partList.forEach(([key, value]) => {
const flag = value.findIndex(f => f.id === row.id)
if (flag !== -1){
row.totalPrice = row.waresCount * row.wares.price
this.$set(value, flag, row)
}
})
const id = row.id const id = row.id
// cell // cell
this.clickCellMap[id].forEach(cell => { this.clickCellMap[id].forEach(cell => {
@ -494,11 +579,11 @@ export default {
this.tableKey++ this.tableKey++
}, },
changeWare(row) { changeWare(row) {
if (row.ware) { // if (row.wares.ware) {
row['wareId'] = row.ware.id // row['wareId'] = row.ware.id
row['warehouse'] = row.ware.id // row['warehouse'] = row.ware.id
row['warehouseName'] = row.ware.name // row['warehouseName'] = row.ware.name
} // }
}, },
// //
deleteItem(index) { deleteItem(index) {
@ -523,6 +608,7 @@ export default {
}, },
// //
async createInit() { async createInit() {
const values = this.partList.map(([key, value]) => value).reduce((acc, value) => acc.concat(value))
const res = await getUserProfile() const res = await getUserProfile()
this.formData = {} this.formData = {}
this.formData = { this.formData = {
@ -532,24 +618,30 @@ export default {
userId: res.data.id, userId: res.data.id,
userName: res.data.nickname, userName: res.data.nickname,
soTime: parseTime(Date.now(), '{y}-{m}-{d}'), soTime: parseTime(Date.now(), '{y}-{m}-{d}'),
itemCount: this.partList.length, itemCount: values.length,
totalPrice: this.partList.reduce((x, y) => { totalPrice: values.reduce((x, y) => {
return x + y.totalPrice return x + y.totalPrice
}, 0), }, 0),
soStatus: "02", soStatus: "02",
remark: this.remark, remark: this.remark,
} }
this.formData.goodsList = [...this.partList.map(item => { this.formData.goodsList = [...values.map(item => {
return { return {
soiType: '01', soiType: '01',
goodsId: item.id, goodsId: item.wares.id,
goodsType: '0', goodsType: '0',
wareId: item?.wareId, wareId: item.wares?.ware?.id,
goodsCount: item.count, goodsCount: item.waresCount,
goodsPrice: item.newPrice, goodsPrice: item.wares.price,
remark: item.remark remark: item.remark
} }
})] })]
this.formData.waresList = [...values.map(item => {
if (item.wares.ware){
item.wares.warehouse = item.wares.ware.id
}
return item.wares
})]
}, },
validateNull() { validateNull() {
const flag = this.partList.map(item => { const flag = this.partList.map(item => {