选择配件生成采购单展示的数据、展示修改为折叠框

This commit is contained in:
xiaofajia 2024-11-18 19:32:55 +08:00
parent c36226d14c
commit 8c1c1f6e60
3 changed files with 155 additions and 107 deletions

View File

@ -80,3 +80,11 @@ export function getById(id){
method: 'get'
})
}
// 根据选择的配件生成采购单需要的数据
export function getByIds(ids){
return request({
url: preUrl + "/getByIds?ids=" + ids,
method: 'get'
})
}

View File

@ -192,3 +192,11 @@ export function overOrder(data){
data
})
}
// 根据工单ID查客户和车辆信息
export function getCusAndCarById(id){
return request({
url: preUrl + "/getCusAndCarById?id=" + id,
method: 'get'
})
}

View File

@ -71,6 +71,7 @@
:row-class-name="getRowClass"
@selection-change="handleSelect"
:key="tableKey"
ref="tableRef"
>
<el-table-column type="selection" width="80" align="center"/>
<el-table-column label="名称" align="center" prop="waresName" :show-overflow-tooltip="true"/>
@ -108,94 +109,110 @@
</el-dialog>
<el-dialog title="采购单" :visible.sync="inStockDialog" width="80%" v-dialogDrag append-to-body>
<el-table
:data="partList"
:stripe="true"
:show-overflow-tooltip="true"
show-summary
:summary-method="getSummaries"
@cell-mouse-enter="handleCellEnter"
@cell-mouse-leave="handleCellLeave"
@cell-click="handleCellClick"
>
<el-table-column label="序号" align="center">
<template scope="scope">
<span>{{ scope.$index + 1 }}</span>
<el-descriptions class="margin-top" title="车辆信息" :column="3" border>
<el-descriptions-item>
<template slot="label">
车牌号
</template>
</el-table-column>
<el-table-column label="商品名称" align="center" prop="name" width="200"/>
<el-table-column label="规格" align="center" width="180" prop="model">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.model"
placeholder="请输入规格"></el-input>
<span class="item__txt">{{ scope.row.model }}</span>
</div>
</el-table-column>
<el-table-column label="商品编码" align="center" width="180" prop="code">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.code"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.code }}</span>
</div>
</el-table-column>
<el-table-column label="仓库" align="center" width="150" prop="warehouse">
<div class="item" slot-scope="scope">
<WarehouseChoose @input-blur="save(scope.row)" class="item__input" v-model="scope.row.ware"
@change="changeWare(scope.row)"/>
<span class="item__txt">{{ scope.row.warehouseName }}</span>
</div>
</el-table-column>
<el-table-column label="库存" align="center" width="150" prop="stock"/>
<el-table-column label="单位" align="center" width="150" prop="unit">
<div class="item" slot-scope="scope">
<el-select class="item__input" v-model="scope.row.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.unit"/>
</span>
</div>
</el-table-column>
<el-table-column label="数量" align="center" width="150" prop="count">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.count"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.count }}</span>
</div>
</el-table-column>
<el-table-column label="上次进价" align="center" width="150" prop="purPrice"/>
<el-table-column label="采购单价" align="center" width="150" prop="newPrice">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.newPrice"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.newPrice }}</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"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.remark }}</span>
</div>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="150">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-delete" @click="deleteItem(scope.$index)"
>删除
</el-button>
{{carInfo.licenseNumber}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
品牌
</template>
</el-table-column>
</el-table>
<el-row :gutter="1" style="margin-top: 1rem">
<el-col :span="24">
<el-input v-model="remark" placeholder="备注"/>
</el-col>
</el-row>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="handleSubmit">确定</el-button>
</div>
{{carInfo.carBrand}}
</el-descriptions-item>
<el-descriptions-item>
<template slot="label">
型号
</template>
{{carInfo.carModel}}
</el-descriptions-item>
</el-descriptions>
<el-collapse>
<el-collapse-item v-for="[key, value] in partList" :title="key">
<el-table
:data="value"
:stripe="true"
:show-overflow-tooltip="true"
show-summary
:summary-method="getSummaries"
@cell-mouse-enter="handleCellEnter"
@cell-mouse-leave="handleCellLeave"
@cell-click="handleCellClick"
>
<el-table-column label="序号" align="center">
<template scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="商品名称" align="center" prop="waresName" width="200"/>
<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.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"
@change="changeWare(scope.row)"/>
<span class="item__txt">{{ scope.row.wares.warehouseName }}</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="waresCount">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.waresCount"
placeholder="请输入内容"></el-input>
<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">
<div class="item" slot-scope="scope">
<el-input @blur="save(scope.row)" class="item__input" v-model="scope.row.wares.newPrice"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.wares.newPrice }}</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"
placeholder="请输入内容"></el-input>
<span class="item__txt">{{ scope.row.remark }}</span>
</div>
</el-table-column>
<el-table-column label="操作" fixed="right" align="center" width="150">
<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>
</el-dialog>
<TicketWaresShow ref="ticketWaresShow" :user-role="'repair_warehouse'" @success="getList" :type="false"/>
@ -203,7 +220,7 @@
</template>
<script>
import {getPage, pass, passBackTicketWares} from "@/api/repair/tickets/TicketWares";
import {getPage, pass, passBackTicketWares, getByIds} from "@/api/repair/tickets/TicketWares";
import {listTwItem} from "@/api/repair/tickets/TWItem";
import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
import {parseTime} from "@/utils/ruoyi";
@ -212,6 +229,8 @@ import WarehouseChoose from "@/views/repair/Components/WarehouseChoose.vue";
import {createRepairSo} from "@/api/repair/stockOperate/stockOperate";
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";
export default {
name: "WaresItem",
@ -235,6 +254,7 @@ export default {
items: [],
dialogLoading: false,
selections: [],
selectionIds: [],
formData: {},
inStockDialog: false,
partList: [],
@ -242,11 +262,13 @@ export default {
// cell
clickCellMap: {},
//
editProp: ['warehouse', 'count', 'newPrice', 'remark', 'code', 'waresCount', 'model', 'unit'],
editProp: ['warehouse', 'count', 'newPrice', 'remark', 'code', 'waresCount', 'wares.model', 'unit'],
remark: null,
tableKey: 0,
query: null,
twId: null,
carInfo: {},
ticketId: null,
}
},
mounted() {
@ -258,7 +280,19 @@ export default {
twId: this.twId,
query: this.query
}
this.getTwitemList(data)
this.getTwitemList(data).then(() => {
this.setSelectedRows();
})
},
setSelectedRows() {
this.$nextTick(() => {
this.$refs.tableRef.clearSelection(); //
this.items.forEach(row => {
if (this.selectionIds.includes(row.id)) {
this.$refs.tableRef.toggleRowSelection(row, true); //
}
});
});
},
resetByQuery() {
this.query = null
@ -303,16 +337,19 @@ export default {
},
// truefalse
async handleCreate() {
this.inStockDialog = true
this.partList = [...this.selections.map(item => {
return {
...item.wares,
count: item.waresCount,
newPrice: item.wares.purPrice,
totalPrice: item.waresCount * item.wares.purPrice
try {
const carRes = await getCusAndCarById(this.ticketId)
this.carInfo = carRes.data.carInfo
if (this.carInfo.carBrand){
const brandRes = await getCarBrand(this.carInfo.carBrand)
this.carInfo.carBrand = brandRes.data.brandName
}
})]
this.dialogVisible = false
const ids = this.selections.map(item => item.id)
const res = await getByIds(ids)
this.partList = Object.entries(res.data)
this.inStockDialog = true
this.dialogVisible = false
}catch{}
},
async getList() {
try {
@ -342,16 +379,8 @@ export default {
this.dialogVisible = true
const data = {twId: row.id}
this.twId = row.id
this.ticketId = row.ticketId
this.getTwitemList(data)
// const res = await listTwItem(data)
// this.items = res.data
// this.items = this.items.filter(item => item.waresStatus === '1')
// this.items.forEach(item => {
// const count = item.waresAlreadyCount ? parseInt(item.waresCount) - parseInt(item.waresAlreadyCount) : item.waresCount
// item.waresCount = this.type ? count : item.waresAlreadyCount
// item.isStock = this.type ? count <= item.wares.stock : true
// })
// this.items = this.items.filter(item => this.type ? item.waresCount > 0 : item.waresAlreadyCount > 0)
},
async getTwitemList(data) {
try {
@ -375,6 +404,9 @@ export default {
},
handleSelect(row) {
this.selections = row
if (row && row.length > 0){
this.selectionIds = row.map(item => item.id);
}
},
//
getSummaries(param) {