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

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

View File

@ -154,6 +154,24 @@
<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.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"> <el-table-column label="商品编码" align="center" width="180" prop="wares.code">
<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-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.code"
@ -165,14 +183,15 @@
<div class="item" slot-scope="scope"> <div class="item" slot-scope="scope">
<WarehouseChoose @input-blur="save(scope.row)" class="item__input" v-model="scope.row.wares.ware" <WarehouseChoose @input-blur="save(scope.row)" class="item__input" v-model="scope.row.wares.ware"
@change="changeWare(scope.row)"/> @change="changeWare(scope.row)"/>
<span class="item__txt">{{ scope.row.wares.warehouseName }}</span> <span class="item__txt">{{ scope.row.wares?.ware?.name }}</span>
</div> </div>
</el-table-column> </el-table-column>
<el-table-column label="库存" align="center" width="150" prop="wares.stock"/> <el-table-column label="库存" align="center" width="150" prop="wares.stock"/>
<el-table-column label="单位" align="center" width="150" prop="wares.unit"> <el-table-column label="单位" align="center" width="150" prop="wares.unit">
<div class="item" slot-scope="scope"> <div class="item" slot-scope="scope">
<el-select class="item__input" v-model="scope.row.wares.unit" @blur="save(scope.row)"> <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"/> :value="dict.value"/>
</el-select> </el-select>
<span class="item__txt"> <span class="item__txt">
@ -187,15 +206,21 @@
<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.newPrice" <el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.purPrice"
placeholder="请输入内容"></el-input> placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.wares.newPrice }}</span> <span class="item__txt">{{ scope.row.wares.purPrice }}</span>
</div> </div>
</el-table-column> </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"> <el-table-column label="备注" align="center" width="180" prop="remark">
<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.remark" <el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.remark"
@ -213,6 +238,10 @@
</el-table> </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,23 +289,63 @@ 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: {
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() { searchByQuery() {
const data = { const data = {
twId: this.twId, twId: this.twId,
@ -347,9 +418,16 @@ export default {
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
@ -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 => {