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

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' 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 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" :row-class-name="getRowClass"
@selection-change="handleSelect" @selection-change="handleSelect"
:key="tableKey" :key="tableKey"
ref="tableRef"
> >
<el-table-column type="selection" width="80" align="center"/> <el-table-column type="selection" width="80" align="center"/>
<el-table-column label="名称" align="center" prop="waresName" :show-overflow-tooltip="true"/> <el-table-column label="名称" align="center" prop="waresName" :show-overflow-tooltip="true"/>
@ -108,94 +109,110 @@
</el-dialog> </el-dialog>
<el-dialog title="采购单" :visible.sync="inStockDialog" width="80%" v-dialogDrag append-to-body> <el-dialog title="采购单" :visible.sync="inStockDialog" width="80%" v-dialogDrag append-to-body>
<el-table <el-descriptions class="margin-top" title="车辆信息" :column="3" border>
:data="partList" <el-descriptions-item>
:stripe="true" <template slot="label">
: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> </template>
</el-table-column> {{carInfo.licenseNumber}}
<el-table-column label="商品名称" align="center" prop="name" width="200"/> </el-descriptions-item>
<el-table-column label="规格" align="center" width="180" prop="model"> <el-descriptions-item>
<div class="item" slot-scope="scope"> <template slot="label">
<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>
</template> </template>
</el-table-column> {{carInfo.carBrand}}
</el-table> </el-descriptions-item>
<el-row :gutter="1" style="margin-top: 1rem"> <el-descriptions-item>
<el-col :span="24"> <template slot="label">
<el-input v-model="remark" placeholder="备注"/> 型号
</el-col> </template>
</el-row> {{carInfo.carModel}}
<div slot="footer" class="dialog-footer"> </el-descriptions-item>
<el-button type="primary" @click="handleSubmit">确定</el-button> </el-descriptions>
</div> <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> </el-dialog>
<TicketWaresShow ref="ticketWaresShow" :user-role="'repair_warehouse'" @success="getList" :type="false"/> <TicketWaresShow ref="ticketWaresShow" :user-role="'repair_warehouse'" @success="getList" :type="false"/>
@ -203,7 +220,7 @@
</template> </template>
<script> <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 {listTwItem} from "@/api/repair/tickets/TWItem";
import {createUniqueCodeByHead} from "@/utils/createUniqueCode"; import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
import {parseTime} from "@/utils/ruoyi"; 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 {createRepairSo} from "@/api/repair/stockOperate/stockOperate";
import {getUserProfile} from "@/api/system/user"; 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 {getCarBrand} from "@/api/base/carbrand";
export default { export default {
name: "WaresItem", name: "WaresItem",
@ -235,6 +254,7 @@ export default {
items: [], items: [],
dialogLoading: false, dialogLoading: false,
selections: [], selections: [],
selectionIds: [],
formData: {}, formData: {},
inStockDialog: false, inStockDialog: false,
partList: [], partList: [],
@ -242,11 +262,13 @@ export default {
// cell // cell
clickCellMap: {}, clickCellMap: {},
// //
editProp: ['warehouse', 'count', 'newPrice', 'remark', 'code', 'waresCount', 'model', 'unit'], editProp: ['warehouse', 'count', 'newPrice', 'remark', 'code', 'waresCount', 'wares.model', 'unit'],
remark: null, remark: null,
tableKey: 0, tableKey: 0,
query: null, query: null,
twId: null, twId: null,
carInfo: {},
ticketId: null,
} }
}, },
mounted() { mounted() {
@ -258,7 +280,19 @@ export default {
twId: this.twId, twId: this.twId,
query: this.query 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() { resetByQuery() {
this.query = null this.query = null
@ -303,16 +337,19 @@ export default {
}, },
// truefalse // truefalse
async handleCreate() { async handleCreate() {
this.inStockDialog = true try {
this.partList = [...this.selections.map(item => { const carRes = await getCusAndCarById(this.ticketId)
return { this.carInfo = carRes.data.carInfo
...item.wares, if (this.carInfo.carBrand){
count: item.waresCount, const brandRes = await getCarBrand(this.carInfo.carBrand)
newPrice: item.wares.purPrice, this.carInfo.carBrand = brandRes.data.brandName
totalPrice: item.waresCount * item.wares.purPrice
} }
})] const ids = this.selections.map(item => item.id)
this.dialogVisible = false const res = await getByIds(ids)
this.partList = Object.entries(res.data)
this.inStockDialog = true
this.dialogVisible = false
}catch{}
}, },
async getList() { async getList() {
try { try {
@ -342,16 +379,8 @@ export default {
this.dialogVisible = true this.dialogVisible = true
const data = {twId: row.id} const data = {twId: row.id}
this.twId = row.id this.twId = row.id
this.ticketId = row.ticketId
this.getTwitemList(data) 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) { async getTwitemList(data) {
try { try {
@ -375,6 +404,9 @@ export default {
}, },
handleSelect(row) { handleSelect(row) {
this.selections = row this.selections = row
if (row && row.length > 0){
this.selectionIds = row.map(item => item.id);
}
}, },
// //
getSummaries(param) { getSummaries(param) {