更新代码
This commit is contained in:
parent
81f23067b0
commit
1faedc0334
@ -1 +1,11 @@
|
|||||||
import request from '@/utils/request'
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
const preUrl = "/repair/so"
|
||||||
|
|
||||||
|
export function createRepairSo(data){
|
||||||
|
return request({
|
||||||
|
url: preUrl + "/create",
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@ -2,17 +2,17 @@
|
|||||||
<el-select v-model="partSelected" ref="selectTable" clearable style="width: 45rem">
|
<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-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 :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">
|
<template scope="scope">
|
||||||
<span>{{ scope.$index + 1 }}</span>
|
<span>{{ scope.$index + 1 }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="商品名称" prop="name" />
|
<el-table-column label="商品名称" prop="name" width="120"/>
|
||||||
<el-table-column label="规格" prop="name" />
|
<el-table-column label="规格" prop="model" width="120"/>
|
||||||
<el-table-column label="商品编码" prop="name" />
|
<el-table-column label="商品编码" prop="code" width="120"/>
|
||||||
<el-table-column label="可用库存" prop="name" />
|
<el-table-column label="可用库存" prop="stock" width="80"/>
|
||||||
<el-table-column label="成本" prop="name" />
|
<el-table-column label="成本" prop="price" width="80"/>
|
||||||
<el-table-column label="仓库" prop="name" />
|
<el-table-column label="仓库" prop="warehouse" width="80"/>
|
||||||
</el-table>
|
</el-table>
|
||||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||||
/>
|
/>
|
||||||
@ -26,8 +26,48 @@ export default {
|
|||||||
return{
|
return{
|
||||||
partSelected: null,
|
partSelected: null,
|
||||||
partList: [
|
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:{
|
queryParams:{
|
||||||
pageNo: 1,
|
pageNo: 1,
|
||||||
|
|||||||
@ -36,19 +36,24 @@
|
|||||||
<!-- 商品表格 组件 -->
|
<!-- 商品表格 组件 -->
|
||||||
<el-row :gutter="20">
|
<el-row :gutter="20">
|
||||||
<el-col :span="24">
|
<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-col>
|
||||||
</el-row>
|
</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-col :span="12">
|
||||||
<el-form-item label="备注">
|
<el-form-item label="备注" prop="remark">
|
||||||
<el-input style="width: 45rem"/>
|
<el-input style="width: 40rem" v-model="formData.remark"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- 按钮操作 -->
|
<!-- 按钮操作 -->
|
||||||
<el-col :span="12" style="text-align: right">
|
<el-col :span="6" style="text-align: right">
|
||||||
<el-button v-if="soByType" type="danger">结算</el-button>
|
<el-button v-if="soByType" type="danger" @click="handleSubmit">结算</el-button>
|
||||||
<el-button v-else type="primary">确定</el-button>
|
<el-button v-else type="primary">确定</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -63,6 +68,7 @@ import PartChoose from "@/views/repair/Components/PartChoose.vue";
|
|||||||
import SoTable from "@/views/repair/stockOperate/Components/SoTable.vue";
|
import SoTable from "@/views/repair/stockOperate/Components/SoTable.vue";
|
||||||
import SupplierChoose from "@/views/repair/Components/SupplierChoose.vue";
|
import SupplierChoose from "@/views/repair/Components/SupplierChoose.vue";
|
||||||
import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
|
import {createUniqueCodeByHead} from "@/utils/createUniqueCode";
|
||||||
|
import {createRepairSo} from "@/api/repair/stockOperate/stockOperate";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "SoInfo",
|
name: "SoInfo",
|
||||||
@ -77,7 +83,7 @@ export default {
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
required: true
|
required: true
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -88,7 +94,13 @@ export default {
|
|||||||
soTime: Date.now(),
|
soTime: Date.now(),
|
||||||
userId: null,
|
userId: null,
|
||||||
userName: null,
|
userName: null,
|
||||||
partList: []
|
partList: [],
|
||||||
|
totalPrice: null,
|
||||||
|
soType: this.soByType ? "01" : "02",
|
||||||
|
purchaseType: "01",
|
||||||
|
itemCount: 0,
|
||||||
|
soStatus: this.soByType ? "01" : "04",
|
||||||
|
remark: null,
|
||||||
},
|
},
|
||||||
staffRole: "采购员",
|
staffRole: "采购员",
|
||||||
partList: [],
|
partList: [],
|
||||||
@ -106,7 +118,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 得到选择的供应商
|
// 得到选择的供应商
|
||||||
getSupplier(data) {
|
getSupplier(data) {
|
||||||
console.log(data)
|
this.formData.supplierId = data.id
|
||||||
|
this.formData.supplierName = data.name
|
||||||
},
|
},
|
||||||
// 得到选择的商品
|
// 得到选择的商品
|
||||||
async getPart(data) {
|
async getPart(data) {
|
||||||
@ -124,6 +137,16 @@ export default {
|
|||||||
// 删除数据
|
// 删除数据
|
||||||
deleteItem(index) {
|
deleteItem(index) {
|
||||||
this.partList.splice(index, 1)
|
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +1,53 @@
|
|||||||
<template>
|
<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">
|
<el-table-column label="序号" align="center">
|
||||||
<template scope="scope">
|
<template scope="scope">
|
||||||
<span>{{ scope.$index + 1 }}</span>
|
<span>{{ scope.$index + 1 }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="商品名称" align="center" prop="name" width="200"/>
|
<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" prop="model"/>
|
||||||
<el-table-column label="商品编码" align="center" width="180"/>
|
<el-table-column label="商品编码" align="center" width="180" prop="code"/>
|
||||||
<el-table-column label="仓库" align="center" width="150"/>
|
<el-table-column label="仓库" align="center" width="150" prop="warehouse"/>
|
||||||
<el-table-column label="库存" align="center" width="150" />
|
<el-table-column label="库存" align="center" width="150" prop="stock"/>
|
||||||
<el-table-column label="单位" align="center" width="150"/>
|
<el-table-column label="单位" align="center" width="150" prop="unit"/>
|
||||||
<el-table-column label="数量" align="center" width="150"/>
|
<el-table-column label="数量" align="center" width="150" prop="count">
|
||||||
<el-table-column :label="soByType ? '上次进价' : '成本'" align="center" width="150"/>
|
<template slot-scope="scope">
|
||||||
<el-table-column v-if="soByType" label="采购进价" align="center" width="150"/>
|
<el-input v-if="scope.row[scope.column.property + 'isShow']"
|
||||||
<el-table-column :label="soByType ? '采购金额' : '合计'" align="center" width="150"/>
|
:ref="scope.column.property"
|
||||||
<el-table-column label="备注" align="center" width="180"/>
|
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">
|
<el-table-column label="操作" fixed="right" align="center" width="150">
|
||||||
<template v-slot="scope">
|
<template v-slot="scope">
|
||||||
<el-button size="mini" type="text" icon="el-icon-delete" @click="deleteItem(scope.$index)"
|
<el-button size="mini" type="text" icon="el-icon-delete" @click="deleteItem(scope.$index)"
|
||||||
@ -29,13 +61,13 @@
|
|||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
name: "SoTable",
|
name: "SoTable",
|
||||||
props:{
|
props: {
|
||||||
soByType:{
|
soByType: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
defaultValue: true,
|
defaultValue: true,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
partList:{
|
partList: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
required: true
|
required: true
|
||||||
@ -45,13 +77,75 @@ export default {
|
|||||||
return {
|
return {
|
||||||
loading: false,
|
loading: false,
|
||||||
list: [],
|
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: {
|
methods: {
|
||||||
// 通知父组件,删除数据
|
// 通知父组件,删除数据
|
||||||
deleteItem(index){
|
deleteItem(index) {
|
||||||
this.$emit("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
|
||||||
|
//refreshTable是table数据改动时,刷新table的
|
||||||
|
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>
|
</script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user