更新代码

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"
// 采购单\领料单 新增
export function createRepairSo(data){
return request({
url: preUrl + "/create",
@ -9,3 +10,11 @@ export function createRepairSo(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 {
name: "StaffChoose",
props:{
value: {
type: Object,
defaultValue: null
}
},
data() {
return {
staffList: [],
@ -19,7 +25,14 @@ export default {
watch:{
staffSelected(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() {

View File

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

View File

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

View File

@ -12,7 +12,7 @@
</el-date-picker>
</el-form-item>
<el-form-item v-if="soByType && !goodsYes" label="供应商" prop="supplierId">
<SupplierChoose />
<SupplierChoose/>
</el-form-item>
<el-form-item v-if="goodsYes" label="关键字" prop="soNo">
<el-input v-model="queryParams.soNo" style="width: 18rem" placeholder="请输入单号、商品名称或编码"/>
@ -25,7 +25,7 @@
<el-option v-for="item in getStatus"
:key="item.value"
:label="item.label"
:value="item.value" />
:value="item.value"/>
</el-select>
</el-form-item>
<el-form-item v-if="!soByType" label="领料人" prop="userId">
@ -55,19 +55,19 @@
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="单号" align="center" prop="soNo" width="180" />
<el-table-column label="商品名称" align="center" width="180" prop="name" />
<el-table-column label="规格" align="center" width="180" prop="name" />
<el-table-column label="商品编码" align="center" width="180" prop="name" />
<el-table-column label="所属分类" align="center" width="150" prop="name" />
<el-table-column label="数量" align="center" width="150" prop="name" />
<el-table-column label="单位" align="center" width="150" prop="name" />
<el-table-column label="成本" align="center" width="150" prop="name" />
<el-table-column label="供应商" align="center" width="180" prop="name" />
<el-table-column label="仓库" align="center" width="150" prop="name" />
<el-table-column label="状态" align="center" width="150" prop="name" />
<el-table-column label="时间" align="center" width="150" prop="name" />
<el-table-column label="门店" align="center" width="180" prop="name" />
<el-table-column label="单号" align="center" prop="soNo" width="180"/>
<el-table-column label="商品名称" align="center" width="180" prop="name"/>
<el-table-column label="规格" align="center" width="180" prop="name"/>
<el-table-column label="商品编码" align="center" width="180" prop="name"/>
<el-table-column label="所属分类" align="center" width="150" prop="name"/>
<el-table-column label="数量" align="center" width="150" prop="name"/>
<el-table-column label="单位" align="center" width="150" prop="name"/>
<el-table-column label="成本" align="center" width="150" prop="name"/>
<el-table-column label="供应商" align="center" width="180" prop="name"/>
<el-table-column label="仓库" align="center" width="150" prop="name"/>
<el-table-column label="状态" align="center" width="150" prop="name"/>
<el-table-column label="时间" align="center" width="150" prop="name"/>
<el-table-column label="门店" align="center" width="180" prop="name"/>
<el-table-column label="操作" align="center" width="180" fixed="right">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit"
@ -84,16 +84,16 @@
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<el-table-column label="单号" align="center" prop="soNo" width="180" />
<el-table-column label="数量" align="center" prop="itemCount" width="150" />
<el-table-column label="金额" align="center" prop="totalPrice" width="150" />
<el-table-column :label="soByType ? '采购员' : '领料人'" align="center" prop="userName" width="150" />
<el-table-column v-if="soByType" label="供应商" align="center" prop="supplierName" width="150" />
<el-table-column :label="soByType ? '入库时间' : '领料时间'" align="center" prop="soTime" width="150" />
<el-table-column label="登记时间" align="center" prop="createTime" width="150" />
<el-table-column label="门店" align="center" prop="corpName" width="180" />
<el-table-column v-if="soByType" label="状态" align="center" prop="soStatus" width="150" />
<el-table-column label="备注" align="center" prop="remark" width="180" />
<el-table-column label="单号" align="center" prop="soNo" width="180"/>
<el-table-column label="数量" align="center" prop="itemCount" width="150"/>
<el-table-column label="金额" align="center" prop="totalPrice" width="150"/>
<el-table-column :label="soByType ? '采购员' : '领料人'" align="center" prop="userName" width="150"/>
<el-table-column v-if="soByType" label="供应商" align="center" prop="supplierName" width="150"/>
<el-table-column :label="soByType ? '入库时间' : '领料时间'" align="center" prop="soTime" width="150"/>
<el-table-column label="登记时间" align="center" prop="createTime" width="150"/>
<el-table-column label="门店" align="center" prop="corpName" width="180"/>
<el-table-column v-if="soByType" label="状态" align="center" prop="soStatus" width="150"/>
<el-table-column label="备注" align="center" prop="remark" width="180"/>
<el-table-column label="操作" fixed="right" width="180" align="center">
<template v-slot="scope">
<el-button size="mini" type="text" icon="el-icon-edit"
@ -117,21 +117,22 @@ import SupplierChoose from "@/views/repair/Components/SupplierChoose.vue";
import CorpChoose from "@/views/repair/Components/CorpChoose.vue";
import StaffChoose from "@/views/repair/Components/StaffChoose.vue";
import {DICT_TYPE} from "@/utils/dict";
import {getRepairSoPage} from "@/api/repair/stockOperate/stockOperate";
export default {
name: "SoIndex",
computed: {
getStatus(){
getStatus() {
const data = this.getDictDatas(DICT_TYPE.REPAIR_SO_STATUS)
return data.filter(item => item.label.toString().indexOf("领料") === -1)
}
},
components:{
components: {
StaffChoose,
SupplierChoose,
CorpChoose
},
props:{
props: {
soByType: {
type: Boolean,
defaultValue: true,
@ -145,17 +146,18 @@ export default {
},
data() {
return {
queryParams:{
queryParams: {
pageNo: 1,
pageSize: 10,
searchTimeArray:[],
searchTimeArray: [],
soNo: null,
supplierId: null,
supplierName: null,
soStatus: null,
corpId: null,
userId: null,
userName: null
userName: null,
soType: this.soByType ? "01" : "02"
},
showSearch: true,
list: [],
@ -163,21 +165,36 @@ export default {
total: 0
}
},
mounted() {
this.pageSo();
},
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.handleQuery()
},
//
getStaff(data){
getStaff(data) {
this.queryParams.userId = data.id
this.queryParams.userName = data.name
},
//
getCompany(data){
getCompany(data) {
console.log(data)
}
}

View File

@ -4,8 +4,8 @@
<el-row :gutter="20">
<el-col :span="24">
<!-- 供应商 组件 -->
<el-form-item v-if="soByType" label="供应商" prop="supplierId">
<SupplierChoose @selected="getSupplier"/>
<el-form-item v-if="soByType" label="供应商" prop="supplier">
<SupplierChoose v-model="formData.supplier"/>
</el-form-item>
<!-- 日期 内嵌 -->
<el-form-item label="日期" prop="soTime">
@ -20,8 +20,8 @@
<el-input disabled v-model="formData.soNo" style="width: 20rem"/>
</el-form-item>
<!-- 采购员/领料人 组件 -->
<el-form-item :label="staffRole" prop="userId">
<StaffChoose @selected="getStaff"/>
<el-form-item :label="staffRole" prop="user">
<StaffChoose v-model="formData.user"/>
</el-form-item>
</el-col>
</el-row>
@ -54,7 +54,7 @@
<!-- 按钮操作 -->
<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-button v-else type="primary" @click="handleSubmit">确定</el-button>
</el-col>
</el-row>
</el-form>
@ -89,12 +89,10 @@ export default {
return {
formData: {
soNo: null,
supplierId: null,
supplierName: null,
supplier: null,
soTime: Date.now(),
userId: null,
userName: null,
partList: [],
user: null,
goodsList: [],
totalPrice: null,
soType: this.soByType ? "01" : "02",
purchaseType: "01",
@ -107,8 +105,7 @@ export default {
}
},
mounted() {
this.formData.soNo = createUniqueCodeByHead(this.soByType ? "CG" : "LL")
this.staffRole = this.soByType ? this.staffRole : "领料人"
this.init()
},
methods: {
//
@ -142,11 +139,61 @@ export default {
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
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(){
const res = await createRepairSo(this.formData)
console.log(res)
try {
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" 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="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="unit"/>
<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 v-if="soByType" label="采购单价" align="center" width="150" prop="newPrice">
<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"
v-model="scope.row.newPrice"
@blur="alterData(scope.row,scope.column)"></el-input>
@ -59,8 +68,11 @@
</template>
<script>
import WarehouseChoose from "@/views/repair/Components/WarehouseChoose.vue";
export default {
name: "SoTable",
components: {WarehouseChoose},
props: {
soByType: {
type: Boolean,
@ -83,15 +95,20 @@ export default {
},
watch: {
partList(val) {
const data = val[val.length - 1]
const newData = {
...data,
count: 1,
totalPrice: data.price * 1,
remark: '',
newPrice: data.price,
if (val && val.length > 0) {
const data = val[val.length - 1]
const newData = {
...data,
count: 1,
totalPrice: data.price * 1,
remark: '',
newPrice: data.price,
}
this.list.push(newData)
}else {
this.list = []
this.refreshTable()
}
this.list.push(newData)
},
list: {
handler(newVal, oldVal) {
@ -133,9 +150,9 @@ export default {
row[column.property + "isShow"] = true
//refreshTabletabletable
this.refreshTable()
this.$nextTick(() => {
this.$refs[column.property] && this.$refs[column.property].focus()
})
// this.$nextTick(() => {
// this.$refs[column.property] && this.$refs[column.property].focus()
// })
},
alterData(row, column) {
row[column.property + "isShow"] = false