申请转采购

This commit is contained in:
xiaofajia 2024-10-17 12:10:33 +08:00
parent 2d70581fff
commit d79160ac53
3 changed files with 273 additions and 7 deletions

View File

@ -164,7 +164,7 @@ export default {
this.loading = false
},
getWareHoseName(value){
return this.warehouseList.find(item => item.id === value).name
return this.warehouseList?.find(item => item.id === value)?.name
}
}
}

View File

@ -161,7 +161,7 @@ export default {
},
getWareHoseName(value){
if (!(this.warehouseList && this.warehouseList.length > 0)) return ''
return this.warehouseList.find(item => item.id === value).name
return this.warehouseList.find(item => item.id === value)?.name
}
}
}

View File

@ -59,6 +59,85 @@
<el-button type="primary" @click="handleCreate(true)">全部生成采购单</el-button>
</div>
</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>
</template>
</el-table-column>
<el-table-column label="商品名称" align="center" prop="name" width="200"/>
<el-table-column label="规格" align="center" width="180" prop="model"/>
<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">
<template slot-scope="scope">
<dict-tag :type="DICT_TYPE.REPAIR_UNIT" v-model="scope.row.unit"/>
</template>
</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>
</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="danger" @click="handleSubmit">结算</el-button>
</div>
</el-dialog>
</div>
</template>
@ -67,9 +146,14 @@ import {getPage, pass} from "@/api/repair/tickets/TicketWares";
import {listTwItem} from "@/api/repair/tickets/TWItem";
import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
import {parseTime} from "@/utils/ruoyi";
import SoTable from "@/views/repair/stockOperate/Components/SoTable.vue";
import WarehouseChoose from "@/views/repair/Components/WarehouseChoose.vue";
import {createRepairSo} from "@/api/repair/stockOperate/stockOperate";
import {getUserProfile} from "@/api/system/user";
export default {
name: "WaresItem",
components: {WarehouseChoose, SoTable},
props:{
type: Boolean,
},
@ -89,7 +173,15 @@ export default {
items:[],
dialogLoading: false,
selections:[],
formData:{}
formData:{},
inStockDialog: false,
partList: [],
includeColumn: ['count', 'totalPrice'],
// cell
clickCellMap: {},
//
editProp: ['warehouse', 'count', 'newPrice', 'remark', 'code'],
remark: null,
}
},
mounted() {
@ -145,13 +237,29 @@ export default {
this.dialogVisible = false
}
},
// todo truefalse
// truefalse
async handleCreate(flag){
this.inStockDialog = true
if (flag){
this.partList = [...this.items.map(item => {
return {
...item.wares,
count: item.waresCount,
newPrice: item.wares.purPrice,
totalPrice: item.waresCount * item.wares.purPrice
}
})]
}else {
this.partList = [...this.selections.map(item => {
return {
...item.wares,
count: item.waresCount,
newPrice: item.wares.price,
totalPrice: item.waresCount * item.wares.price
}
})]
}
this.dialogVisible = false
},
async getList(){
try {
@ -206,7 +314,133 @@ export default {
},
handleSelect(row){
this.selections = row
}
},
//
getSummaries(param) {
const {columns, data} = param
const sums = []
columns.forEach((column, index) => {
if (index === 0) {
sums[index] = '合计';
return;
}
const values = data.map(item => Number(item[column.property]));
if (this.includeColumn.includes(column.property)) {
sums[index] = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[index];
}
});
return sums
},
/** 鼠标移入cell */
handleCellEnter(row, column, cell, event) {
const property = column.property
if (this.editProp.includes(property)) {
cell.querySelector('.item__txt').classList.add('item__txt--hover')
}
},
/** 鼠标移出cell */
handleCellLeave(row, column, cell, event) {
const property = column.property
if (this.editProp.includes(property)) {
cell.querySelector('.item__txt').classList.remove('item__txt--hover')
}
},
/** 点击cell */
handleCellClick(row, column, cell, event) {
const property = column.property
if (this.editProp.includes(property)) {
// cell
this.saveCellClick(row, cell)
cell.querySelector('.item__txt').style.display = 'none'
cell.querySelector('.item__input').style.display = 'inline'
cell.querySelector('input').focus()
}
},
/** 取消编辑状态 */
cancelEditable(cell) {
cell.querySelector('.item__txt').style.display = 'inline'
cell.querySelector('.item__input').style.display = 'none'
},
/** 保存进入编辑的cell */
saveCellClick(row, cell) {
const id = row.id
if (this.clickCellMap[id] !== undefined) {
if (!this.clickCellMap[id].includes(cell)) {
this.clickCellMap[id].push(cell)
}
} else {
this.clickCellMap[id] = [cell]
}
},
/** 保存数据 */
save(row) {
//
row.totalPrice = row.count * row.newPrice
const id = row.id
// cell
this.clickCellMap[id].forEach(cell => {
this.cancelEditable(cell)
})
this.clickCellMap[id] = []
},
changeWare(row) {
if (row.ware) {
row['wareId'] = row.ware.id
row['warehouse'] = row.ware.id
row['warehouseName'] = row.ware.name
}
},
//
deleteItem(index) {
this.partList.splice(index, 1)
},
//
async handleSubmit(){
try {
await this.createInit()
await createRepairSo(this.formData)
this.inStockDialog = false
this.$modal.msgSuccess("新增成功")
await this.getList()
}catch{
}
},
//
async createInit(){
const res = await getUserProfile()
this.formData = {}
this.formData = {
soType: '01',
purchaseType: '01',
soNo: createUniqueCodeByHead("CG"),
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) => {return x + y.totalPrice}, 0),
soStatus: "03",
remark: this.remark,
}
this.formData.goodsList = [...this.partList.map(item => {
return {
soiType: '01',
goodsId: item.id,
goodsType: '0',
wareId: item?.wareId,
goodsCount: item.count,
goodsPrice: item.newPrice,
remark: item.remark
}
})]
},
}
}
</script>
@ -215,4 +449,36 @@ export default {
::v-deep .el-table .stock td{
background-color: #ff0000 !important; /* 红色背景 */
}
.item {
.item__input {
display: none;
width: 100px;
/* 调整elementUI中样式 如果不需要调整请忽略 */
.el-input__inner {
height: 24px !important;
}
/* 调整elementUI中样式 如果不需要调整请忽略 */
.el-input__suffix {
i {
font-size: 12px !important;
line-height: 26px !important;
}
}
}
.item__txt {
box-sizing: border-box;
border: 1px solid transparent;
width: 100px;
line-height: 24px;
padding: 0 8px;
}
.item__txt--hover {
border: 1px solid #dddddd;
border-radius: 4px;
cursor: text;
}
}
</style>