更新代码

This commit is contained in:
xiao-fajia 2024-09-14 18:27:01 +08:00
parent 1faedc0334
commit 1aad791aa2
7 changed files with 185 additions and 68 deletions

View File

@ -2,6 +2,7 @@ import request from '@/utils/request'
const preUrl = "/repair/so" const preUrl = "/repair/so"
// 采购单\领料单 新增
export function createRepairSo(data){ export function createRepairSo(data){
return request({ return request({
url: preUrl + "/create", url: preUrl + "/create",
@ -9,3 +10,11 @@ export function createRepairSo(data){
data data
}) })
} }
export function getRepairSoPage(params){
return request({
url: preUrl + "/page",
method: "get",
params
})
}

View File

@ -10,6 +10,12 @@ import {getStaffList} from "@/api/company/staff";
export default { export default {
name: "StaffChoose", name: "StaffChoose",
props:{
value: {
type: Object,
defaultValue: null
}
},
data() { data() {
return { return {
staffList: [], staffList: [],
@ -19,7 +25,14 @@ export default {
watch:{ watch:{
staffSelected(val) { staffSelected(val) {
const staff = this.staffList.find(item => item.id === val); const staff = this.staffList.find(item => item.id === val);
this.$emit("selected", staff); this.$emit("input", staff);
},
value(newVal){
if (newVal){
this.staffSelected = newVal.id
}else {
this.staffSelected = null
}
} }
}, },
mounted() { mounted() {

View File

@ -11,6 +11,12 @@ import {getBaseSupplierList} from "@/api/repair/supplier";
export default { export default {
name: "SupplierChoose", name: "SupplierChoose",
props: {
value: {
type: Object,
defaultValue: null
}
},
data() { data() {
return { return {
supplierSelected: undefined, supplierSelected: undefined,
@ -19,8 +25,15 @@ export default {
}, },
watch: { watch: {
supplierSelected(val) { supplierSelected(val) {
const supplier = this.supplierList.find(item => item.id === val); const supplier = this.supplierList.find(item => item.id === val)
this.$emit("selected", supplier); this.$emit("input", supplier);
},
value(newVal) {
if (newVal) {
this.supplierSelected = newVal.id
} else {
this.supplierSelected = null
}
} }
}, },
mounted() { mounted() {

View File

@ -51,7 +51,8 @@ export default {
return JSON.parse(JSON.stringify(result)) return JSON.parse(JSON.stringify(result))
}, },
handleNodeClick(node){ handleNodeClick(node){
this.$emit("selected", node) this.$emit("input", node.name)
this.$emit("change")
this.warehouseSelected = node.name this.warehouseSelected = node.name
this.$refs.selectTree.blur() this.$refs.selectTree.blur()
} }

View File

@ -117,6 +117,7 @@ import SupplierChoose from "@/views/repair/Components/SupplierChoose.vue";
import CorpChoose from "@/views/repair/Components/CorpChoose.vue"; import CorpChoose from "@/views/repair/Components/CorpChoose.vue";
import StaffChoose from "@/views/repair/Components/StaffChoose.vue"; import StaffChoose from "@/views/repair/Components/StaffChoose.vue";
import {DICT_TYPE} from "@/utils/dict"; import {DICT_TYPE} from "@/utils/dict";
import {getRepairSoPage} from "@/api/repair/stockOperate/stockOperate";
export default { export default {
name: "SoIndex", name: "SoIndex",
@ -155,7 +156,8 @@ export default {
soStatus: null, soStatus: null,
corpId: null, corpId: null,
userId: null, userId: null,
userName: null userName: null,
soType: this.soByType ? "01" : "02"
}, },
showSearch: true, showSearch: true,
list: [], list: [],
@ -163,9 +165,24 @@ export default {
total: 0 total: 0
} }
}, },
mounted() {
this.pageSo();
},
methods: { methods: {
//
async pageSo() {
try {
this.loading = true
const res = await getRepairSoPage(this.queryParams)
this.list = res.data.records
this.total = res.data.total
}finally {
this.loading = false
}
},
// //
handleQuery(){}, handleQuery() {
},
// //
resetQuery() { resetQuery() {
this.resetForm('queryForm') this.resetForm('queryForm')

View File

@ -4,8 +4,8 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="24"> <el-col :span="24">
<!-- 供应商 组件 --> <!-- 供应商 组件 -->
<el-form-item v-if="soByType" label="供应商" prop="supplierId"> <el-form-item v-if="soByType" label="供应商" prop="supplier">
<SupplierChoose @selected="getSupplier"/> <SupplierChoose v-model="formData.supplier"/>
</el-form-item> </el-form-item>
<!-- 日期 内嵌 --> <!-- 日期 内嵌 -->
<el-form-item label="日期" prop="soTime"> <el-form-item label="日期" prop="soTime">
@ -20,8 +20,8 @@
<el-input disabled v-model="formData.soNo" style="width: 20rem"/> <el-input disabled v-model="formData.soNo" style="width: 20rem"/>
</el-form-item> </el-form-item>
<!-- 采购员/领料人 组件 --> <!-- 采购员/领料人 组件 -->
<el-form-item :label="staffRole" prop="userId"> <el-form-item :label="staffRole" prop="user">
<StaffChoose @selected="getStaff"/> <StaffChoose v-model="formData.user"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -54,7 +54,7 @@
<!-- 按钮操作 --> <!-- 按钮操作 -->
<el-col :span="6" style="text-align: right"> <el-col :span="6" style="text-align: right">
<el-button v-if="soByType" type="danger" @click="handleSubmit">结算</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" @click="handleSubmit">确定</el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
@ -89,12 +89,10 @@ export default {
return { return {
formData: { formData: {
soNo: null, soNo: null,
supplierId: null, supplier: null,
supplierName: null,
soTime: Date.now(), soTime: Date.now(),
userId: null, user: null,
userName: null, goodsList: [],
partList: [],
totalPrice: null, totalPrice: null,
soType: this.soByType ? "01" : "02", soType: this.soByType ? "01" : "02",
purchaseType: "01", purchaseType: "01",
@ -107,8 +105,7 @@ export default {
} }
}, },
mounted() { mounted() {
this.formData.soNo = createUniqueCodeByHead(this.soByType ? "CG" : "LL") this.init()
this.staffRole = this.soByType ? this.staffRole : "领料人"
}, },
methods: { methods: {
// //
@ -142,11 +139,61 @@ export default {
tableData(data){ tableData(data){
this.formData.totalPrice = data.reduce((x, y) => {return x + y.totalPrice}, 0) 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.itemCount = data.reduce((x, y) => {return x + y.count}, 0)
this.formData.partList = data this.formData.goodsList = data.map(item => {
return {
goodsId: item.id,
goodsType: "0",
wareId: "0",
goodsCount: item.count,
goodsPrice: item.newPrice,
remark: item.remark
}
})
}, },
//
async handleSubmit(){ async handleSubmit(){
const res = await createRepairSo(this.formData) try {
console.log(res) this.createInit()
await createRepairSo(this.formData)
this.$modal.msgSuccess("新增成功")
this.init()
}catch{
}
},
//
init(){
this.formData = {
soNo: null,
supplier: null,
soTime: Date.now(),
user: null,
goodsList: [],
totalPrice: null,
soType: this.soByType ? "01" : "02",
purchaseType: "01",
itemCount: 0,
soStatus: this.soByType ? "01" : "04",
remark: null,
}
this.formData.soNo = createUniqueCodeByHead(this.soByType ? "CG" : "LL")
this.staffRole = this.soByType ? this.staffRole : "领料人"
this.partList = []
},
//
createInit(){
const data = this.formData
this.formData = {
...data,
userId: data.user.id,
userName: data.user.name,
}
if (this.soByType){
this.formData = {
...data,
supplierId: data.supplier.id,
supplierName: data.supplier.name
}
}
} }
} }
} }

View File

@ -16,7 +16,16 @@
<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" prop="model"/> <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="180" prop="code"/>
<el-table-column label="仓库" align="center" width="150" prop="warehouse"/> <el-table-column label="仓库" align="center" width="150" prop="warehouse">
<template slot-scope="scope">
<WarehouseChoose v-if="scope.row[scope.column.property + 'isShow'] && soByType"
:ref="scope.column.property"
v-model="scope.row.warehouse"
@change="alterData(scope.row,scope.column)"
/>
<span v-else>{{ scope.row.warehouse }}</span>
</template>
</el-table-column>
<el-table-column label="库存" align="center" width="150" prop="stock"/> <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="unit"/>
<el-table-column label="数量" align="center" width="150" prop="count"> <el-table-column label="数量" align="center" width="150" prop="count">
@ -31,7 +40,7 @@
<el-table-column :label="soByType ? '上次进价' : '成本'" align="center" width="150" prop="price"/> <el-table-column :label="soByType ? '上次进价' : '成本'" align="center" width="150" prop="price"/>
<el-table-column v-if="soByType" label="采购单价" align="center" width="150" prop="newPrice"> <el-table-column v-if="soByType" label="采购单价" align="center" width="150" prop="newPrice">
<template slot-scope="scope"> <template slot-scope="scope">
<el-input v-if="scope.row[scope.column.property + 'isShow']" <el-input v-if="scope.row[scope.column.property + 'isShow'] && soByType"
:ref="scope.column.property" :ref="scope.column.property"
v-model="scope.row.newPrice" v-model="scope.row.newPrice"
@blur="alterData(scope.row,scope.column)"></el-input> @blur="alterData(scope.row,scope.column)"></el-input>
@ -59,8 +68,11 @@
</template> </template>
<script> <script>
import WarehouseChoose from "@/views/repair/Components/WarehouseChoose.vue";
export default { export default {
name: "SoTable", name: "SoTable",
components: {WarehouseChoose},
props: { props: {
soByType: { soByType: {
type: Boolean, type: Boolean,
@ -83,6 +95,7 @@ export default {
}, },
watch: { watch: {
partList(val) { partList(val) {
if (val && val.length > 0) {
const data = val[val.length - 1] const data = val[val.length - 1]
const newData = { const newData = {
...data, ...data,
@ -92,6 +105,10 @@ export default {
newPrice: data.price, newPrice: data.price,
} }
this.list.push(newData) this.list.push(newData)
}else {
this.list = []
this.refreshTable()
}
}, },
list: { list: {
handler(newVal, oldVal) { handler(newVal, oldVal) {
@ -133,9 +150,9 @@ export default {
row[column.property + "isShow"] = true row[column.property + "isShow"] = true
//refreshTabletabletable //refreshTabletabletable
this.refreshTable() this.refreshTable()
this.$nextTick(() => { // this.$nextTick(() => {
this.$refs[column.property] && this.$refs[column.property].focus() // this.$refs[column.property] && this.$refs[column.property].focus()
}) // })
}, },
alterData(row, column) { alterData(row, column) {
row[column.property + "isShow"] = false row[column.property + "isShow"] = false