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

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

View File

@ -114,19 +114,19 @@
<template slot="label">
车牌号
</template>
{{carInfo.licenseNumber}}
{{ carInfo.licenseNumber }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
品牌
</template>
{{carInfo.carBrand}}
{{ carInfo.carBrand }}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
型号
</template>
{{carInfo.carModel}}
{{ carInfo.carModel }}
</el-descriptions-item>
</el-descriptions>
<el-collapse>
@ -154,6 +154,24 @@
<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"
@ -165,14 +183,15 @@
<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.warehouseName }}</span>
<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"
<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">
@ -187,15 +206,21 @@
<span class="item__txt">{{ scope.row.waresCount }}</span>
</div>
</el-table-column>
<el-table-column label="上次进价" align="center" width="150" prop="wares.purPrice"/>
<el-table-column label="采购单价" align="center" width="150" prop="wares.newPrice">
<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.newPrice"
<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.newPrice }}</span>
<span class="item__txt">{{ scope.row.wares.purPrice }}</span>
</div>
</el-table-column>
<el-table-column label="采购金额" align="center" width="150" prop="totalPrice"/>
<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" width="150" prop="totalPrice"/>
<el-table-column label="备注" align="center" width="180" prop="remark">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.remark"
@ -213,6 +238,10 @@
</el-table>
</el-collapse-item>
</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>
<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 {getCusAndCarById} from "@/api/repair/tickets/Tickets";
import {getCarBrand} from "@/api/base/carbrand";
import {listGoods} from "@/views/partner/api/workOrder";
import {getBaseTypeList} from "@/api/base/type";
export default {
name: "WaresItem",
@ -258,24 +289,64 @@ export default {
formData: {},
inStockDialog: false,
partList: [],
includeColumn: ['count', 'totalPrice'],
includeColumn: ['waresCount', 'totalPrice'],
// cell
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,
tableKey: 0,
query: null,
twId: null,
carInfo: {},
ticketId: null,
serverSelected: undefined,
expandOnClickNode: true,
serverList: [],
treeProps:{
label: "name",
children: "children"
},
typeMap: null,
}
},
mounted() {
this.getList()
},
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 = {
twId: this.twId,
query: this.query
@ -340,16 +411,23 @@ export default {
try {
const carRes = await getCusAndCarById(this.ticketId)
this.carInfo = carRes.data.carInfo
if (this.carInfo.carBrand){
if (this.carInfo.carBrand) {
const brandRes = await getCarBrand(this.carInfo.carBrand)
this.carInfo.carBrand = brandRes.data.brandName
}
const ids = this.selections.map(item => item.id)
const res = await getByIds(ids)
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.dialogVisible = false
}catch{}
} catch {
}
},
async getList() {
try {
@ -372,6 +450,7 @@ export default {
this.handleQuery()
},
handleDispose(row) {
this.listServer()
this.formData = {}
this.formData = {
...row
@ -404,7 +483,7 @@ export default {
},
handleSelect(row) {
this.selections = row
if (row && row.length > 0){
if (row && row.length > 0) {
this.selectionIds = row.map(item => item.id);
}
},
@ -483,7 +562,13 @@ export default {
this.$modal.msgWarning("退料数量不能超过领取数量")
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
// cell
this.clickCellMap[id].forEach(cell => {
@ -494,11 +579,11 @@ export default {
this.tableKey++
},
changeWare(row) {
if (row.ware) {
row['wareId'] = row.ware.id
row['warehouse'] = row.ware.id
row['warehouseName'] = row.ware.name
}
// if (row.wares.ware) {
// row['wareId'] = row.ware.id
// row['warehouse'] = row.ware.id
// row['warehouseName'] = row.ware.name
// }
},
//
deleteItem(index) {
@ -523,6 +608,7 @@ export default {
},
//
async createInit() {
const values = this.partList.map(([key, value]) => value).reduce((acc, value) => acc.concat(value))
const res = await getUserProfile()
this.formData = {}
this.formData = {
@ -532,24 +618,30 @@ export default {
userId: res.data.id,
userName: res.data.nickname,
soTime: parseTime(Date.now(), '{y}-{m}-{d}'),
itemCount: this.partList.length,
totalPrice: this.partList.reduce((x, y) => {
itemCount: values.length,
totalPrice: values.reduce((x, y) => {
return x + y.totalPrice
}, 0),
soStatus: "02",
remark: this.remark,
}
this.formData.goodsList = [...this.partList.map(item => {
this.formData.goodsList = [...values.map(item => {
return {
soiType: '01',
goodsId: item.id,
goodsId: item.wares.id,
goodsType: '0',
wareId: item?.wareId,
goodsCount: item.count,
goodsPrice: item.newPrice,
wareId: item.wares?.ware?.id,
goodsCount: item.waresCount,
goodsPrice: item.wares.price,
remark: item.remark
}
})]
this.formData.waresList = [...values.map(item => {
if (item.wares.ware){
item.wares.warehouse = item.wares.ware.id
}
return item.wares
})]
},
validateNull() {
const flag = this.partList.map(item => {