更新代码
This commit is contained in:
parent
1faedc0334
commit
1aad791aa2
@ -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
|
||||
})
|
||||
}
|
||||
|
||||
@ -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() {
|
||||
|
||||
@ -11,6 +11,12 @@ import {getBaseSupplierList} from "@/api/repair/supplier";
|
||||
|
||||
export default {
|
||||
name: "SupplierChoose",
|
||||
props: {
|
||||
value: {
|
||||
type: Object,
|
||||
defaultValue: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
supplierSelected: undefined,
|
||||
@ -19,8 +25,15 @@ export default {
|
||||
},
|
||||
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() {
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
@ -117,6 +117,7 @@ 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",
|
||||
@ -155,7 +156,8 @@ export default {
|
||||
soStatus: null,
|
||||
corpId: null,
|
||||
userId: null,
|
||||
userName: null
|
||||
userName: null,
|
||||
soType: this.soByType ? "01" : "02"
|
||||
},
|
||||
showSearch: true,
|
||||
list: [],
|
||||
@ -163,9 +165,24 @@ 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() {
|
||||
this.resetForm('queryForm')
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,6 +95,7 @@ export default {
|
||||
},
|
||||
watch: {
|
||||
partList(val) {
|
||||
if (val && val.length > 0) {
|
||||
const data = val[val.length - 1]
|
||||
const newData = {
|
||||
...data,
|
||||
@ -92,6 +105,10 @@ export default {
|
||||
newPrice: data.price,
|
||||
}
|
||||
this.list.push(newData)
|
||||
}else {
|
||||
this.list = []
|
||||
this.refreshTable()
|
||||
}
|
||||
},
|
||||
list: {
|
||||
handler(newVal, oldVal) {
|
||||
@ -133,9 +150,9 @@ export default {
|
||||
row[column.property + "isShow"] = true
|
||||
//refreshTable是table数据改动时,刷新table的
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user