更新代码

This commit is contained in:
xiao-fajia 2024-09-14 11:33:58 +08:00
parent 81f23067b0
commit 1faedc0334
4 changed files with 201 additions and 34 deletions

View File

@ -1 +1,11 @@
import request from '@/utils/request'
const preUrl = "/repair/so"
export function createRepairSo(data){
return request({
url: preUrl + "/create",
method: "post",
data
})
}

View File

@ -2,17 +2,17 @@
<el-select v-model="partSelected" ref="selectTable" clearable style="width: 45rem">
<el-option style="display: none" v-for="part in partList" :key="part.id" :label="part.name" :value="part.id"/>
<el-table :data="partList" style="width: 100%" @row-click="handleSelectionChange">
<el-table-column label="序号" align="center">
<el-table-column label="序号" align="center" width="80">
<template scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="商品名称" prop="name" />
<el-table-column label="规格" prop="name" />
<el-table-column label="商品编码" prop="name" />
<el-table-column label="可用库存" prop="name" />
<el-table-column label="成本" prop="name" />
<el-table-column label="仓库" prop="name" />
<el-table-column label="商品名称" prop="name" width="120"/>
<el-table-column label="规格" prop="model" width="120"/>
<el-table-column label="商品编码" prop="code" width="120"/>
<el-table-column label="可用库存" prop="stock" width="80"/>
<el-table-column label="成本" prop="price" width="80"/>
<el-table-column label="仓库" prop="warehouse" width="80"/>
</el-table>
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
/>
@ -26,8 +26,48 @@ export default {
return{
partSelected: null,
partList: [
{id: 1, name: '张胜男', age:20, gender: 1},
{id: 2, name: '张胜妇', age:20, gender: 1}
{
id: 1,
tenantId: 1,
barCode: "12344564632463",
code: "12312312",
name: "测试1",
model: "12321",
price: "100",
type: "不知道",
unit: "个",
warehouse: "d1",
miniStock: 100,
maxStock: 100,
stock: 20,
img: '',
attribute: "123213123",
corpId: 1,
coverImage: '',
carModel: "大车",
remark: "没有",
},
{
id: 2,
tenantId: 1,
barCode: "12344564632463",
code: "12312312",
name: "测试2",
model: "12321",
price: "10",
type: "不知道",
unit: "个",
warehouse: "d2",
miniStock: 10,
maxStock: 10,
stock: 5,
img: '',
attribute: "123213123",
corpId: 1,
coverImage: '',
carModel: "大车",
remark: "没有",
}
],
queryParams:{
pageNo: 1,

View File

@ -36,19 +36,24 @@
<!-- 商品表格 组件 -->
<el-row :gutter="20">
<el-col :span="24">
<SoTable :part-list="partList" :so-by-type="soByType" @deleteItem="deleteItem"/>
<SoTable @tableData="tableData" :part-list="partList" :so-by-type="soByType" @deleteItem="deleteItem"/>
</el-col>
</el-row>
<el-row :gutter="2" style="margin-top: 1rem">
<el-row :gutter="4" style="margin-top: 1rem">
<el-col :span="6">
<el-form-item label="应付金额" prop="totalPrice">
<el-input disabled v-model="formData.totalPrice"/>
</el-form-item>
</el-col>
<!-- 备注 -->
<el-col :span="12">
<el-form-item label="备注">
<el-input style="width: 45rem"/>
<el-form-item label="备注" prop="remark">
<el-input style="width: 40rem" v-model="formData.remark"/>
</el-form-item>
</el-col>
<!-- 按钮操作 -->
<el-col :span="12" style="text-align: right">
<el-button v-if="soByType" type="danger">结算</el-button>
<el-col :span="6" style="text-align: right">
<el-button v-if="soByType" type="danger" @click="handleSubmit">结算</el-button>
<el-button v-else type="primary">确定</el-button>
</el-col>
</el-row>
@ -63,6 +68,7 @@ import PartChoose from "@/views/repair/Components/PartChoose.vue";
import SoTable from "@/views/repair/stockOperate/Components/SoTable.vue";
import SupplierChoose from "@/views/repair/Components/SupplierChoose.vue";
import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
import {createRepairSo} from "@/api/repair/stockOperate/stockOperate";
export default {
name: "SoInfo",
@ -77,7 +83,7 @@ export default {
type: Boolean,
defaultValue: true,
required: true
}
},
},
data() {
return {
@ -88,7 +94,13 @@ export default {
soTime: Date.now(),
userId: null,
userName: null,
partList: []
partList: [],
totalPrice: null,
soType: this.soByType ? "01" : "02",
purchaseType: "01",
itemCount: 0,
soStatus: this.soByType ? "01" : "04",
remark: null,
},
staffRole: "采购员",
partList: [],
@ -106,7 +118,8 @@ export default {
},
//
getSupplier(data) {
console.log(data)
this.formData.supplierId = data.id
this.formData.supplierName = data.name
},
//
async getPart(data) {
@ -124,6 +137,16 @@ export default {
//
deleteItem(index) {
this.partList.splice(index, 1)
},
//
tableData(data){
this.formData.totalPrice = data.reduce((x, y) => {return x + y.totalPrice}, 0)
this.formData.itemCount = data.reduce((x, y) => {return x + y.count}, 0)
this.formData.partList = data
},
async handleSubmit(){
const res = await createRepairSo(this.formData)
console.log(res)
}
}
}

View File

@ -1,21 +1,53 @@
<template>
<el-table v-loading="loading" :data="partList" :stripe="true" :show-overflow-tooltip="true">
<el-table v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
show-summary
:summary-method="getSummaries"
:key="randomKey"
@cell-dblclick="editData"
>
<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"/>
<el-table-column label="商品编码" align="center" width="180"/>
<el-table-column label="仓库" align="center" width="150"/>
<el-table-column label="库存" align="center" width="150" />
<el-table-column label="单位" align="center" width="150"/>
<el-table-column label="数量" align="center" width="150"/>
<el-table-column :label="soByType ? '上次进价' : '成本'" align="center" width="150"/>
<el-table-column v-if="soByType" label="采购进价" align="center" width="150"/>
<el-table-column :label="soByType ? '采购金额' : '合计'" align="center" width="150"/>
<el-table-column label="备注" align="center" width="180"/>
<el-table-column label="规格" align="center" width="180" prop="model"/>
<el-table-column label="商品编码" align="center" width="180" prop="code"/>
<el-table-column label="仓库" align="center" width="150" prop="warehouse"/>
<el-table-column label="库存" align="center" width="150" prop="stock"/>
<el-table-column label="单位" align="center" width="150" prop="unit"/>
<el-table-column label="数量" align="center" width="150" prop="count">
<template slot-scope="scope">
<el-input v-if="scope.row[scope.column.property + 'isShow']"
:ref="scope.column.property"
v-model="scope.row.count"
@blur="alterData(scope.row,scope.column)"></el-input>
<span v-else>{{ scope.row.count }}</span>
</template>
</el-table-column>
<el-table-column :label="soByType ? '上次进价' : '成本'" align="center" width="150" prop="price"/>
<el-table-column v-if="soByType" label="采购单价" align="center" width="150" prop="newPrice">
<template slot-scope="scope">
<el-input v-if="scope.row[scope.column.property + 'isShow']"
:ref="scope.column.property"
v-model="scope.row.newPrice"
@blur="alterData(scope.row,scope.column)"></el-input>
<span v-else>{{ scope.row.newPrice }}</span>
</template>
</el-table-column>
<el-table-column :label="soByType ? '采购金额' : '合计'" align="center" width="150" prop="totalPrice"/>
<el-table-column label="备注" align="center" width="180" prop="remark">
<template slot-scope="scope">
<el-input v-if="scope.row[scope.column.property + 'isShow']"
:ref="scope.column.property"
v-model="scope.row.remark"
@blur="alterData(scope.row,scope.column)"></el-input>
<span v-else>{{ scope.row.remark }}</span>
</template>
</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)"
@ -29,13 +61,13 @@
<script>
export default {
name: "SoTable",
props:{
soByType:{
props: {
soByType: {
type: Boolean,
defaultValue: true,
required: true
},
partList:{
partList: {
type: Array,
defaultValue: false,
required: true
@ -45,13 +77,75 @@ export default {
return {
loading: false,
list: [],
includeColumn: ['count', 'totalPrice'],
randomKey: Math.random(),
}
},
watch: {
partList(val) {
const data = val[val.length - 1]
const newData = {
...data,
count: 1,
totalPrice: data.price * 1,
remark: '',
newPrice: data.price,
}
this.list.push(newData)
},
list: {
handler(newVal, oldVal) {
this.$emit("tableData", newVal)
},
deep: true
}
},
methods: {
//
deleteItem(index){
deleteItem(index) {
this.$emit("deleteItem", index)
}
},
//
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
},
editData(row, column) {
row[column.property + "isShow"] = true
//refreshTabletabletable
this.refreshTable()
this.$nextTick(() => {
this.$refs[column.property] && this.$refs[column.property].focus()
})
},
alterData(row, column) {
row[column.property + "isShow"] = false
const data = this.list.find(item => item.id === row.id)
data.totalPrice = data.newPrice * data.count
this.refreshTable()
},
refreshTable() {
this.randomKey = Math.random()
},
}
}
</script>