Merge branch 'develop' of https://e.coding.net/ctcdevteam/hberp/hberp into develop

This commit is contained in:
shijing 2022-02-24 08:36:35 +08:00
commit d5d5799b92
13 changed files with 769 additions and 381 deletions

View File

@ -28,6 +28,15 @@ export function deleteCustomer(id, data) {
data
})
}
export function getCustomer(id) {
return request({
url: `/sam/customer/${id}/`,
method: 'get',
})
}
//合同
export function getContractList(query) {
return request({
@ -170,4 +179,27 @@ export function saleAudit(id) {
})
}
//返回装箱文件
export function gePack(id) {
return request({
url: `/sam/sale_product/${id}/pack/`,
method: 'get'
})
}
//打包装箱文件确认
export function subPack(id, data) {
return request({
url: `/sam/sale_product/${id}/pack/`,
method: 'POST',
data
})
}
///未装箱备注
export function notPackremark(id, data) {
return request({
url: `/sam/sale_product/${id}/remark/`,
method: 'POST',
data
})
}

View File

@ -70,6 +70,12 @@
<el-table-column align="center" label="操作" width="220px">
<template slot-scope="scope">
<el-link
v-if="scope.row.type==2"
type="primary"
@click="handlePack(scope)"
>装箱</el-link
>
<el-link
v-if="checkPermission(['warehouse_update'])"
type="primary"
@click="handleDetail(scope)"
@ -494,6 +500,11 @@ export default {
console.error(err);
});
},
//装箱
handlePack(scope)
{
this.$router.push({name: "salesdetail", params: { id: scope.row.sale }, })
}
},
};
</script>

View File

@ -32,6 +32,9 @@
scope.row.not_work_remark
}}</template>
</el-table-column>
<el-table-column align="center" label="打卡时间">
<template slot-scope="scope">{{ scope.row.last_check_time }}</template>
</el-table-column>
<el-table-column align="header-center" label="部门">
<template v-if="scope.row.dept_" slot-scope="scope">{{
@ -135,9 +138,9 @@
<el-col :span="12">
<el-calendar v-model="value">
<template slot="dateCell" slot-scope="{ date, data }">
<p>
<p >
{{ data.day.split("-").slice(1).join("-") }}<br />
{{ dealMyDate(data.day) }}
{{ dealMyDate(data.day) }}
</p>
</template>
</el-calendar>
@ -219,7 +222,7 @@ export default {
checkPermission,
//今日到岗
getList() {
this.listQuery.fields = "number,name,is_atwork,dept_,id,not_work_remark";
this.listQuery.fields = "number,name,is_atwork,dept_,id,not_work_remark,last_check_time";
getEmployeeList(this.listQuery).then((response) => {
if (response.data) {
this.userList = response.data;

View File

@ -2,85 +2,114 @@
<div class="app-container">
<el-card>
<div>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
>新增销售记录</el-button
>
<el-input
v-model="listQuery.search"
placeholder="客户名称"
style="width: 300px"
class="filter-item"
@keyup.enter.native="handleFilter"
/>
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
@click="handleFilter"
>搜索</el-button
>
<el-button
class="filter-item"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>重置</el-button
>
</div>
<el-button type="primary" icon="el-icon-plus" @click="handleCreate"
>新增销售发货</el-button
>
<el-input
v-model="listQuery.search"
placeholder="客户名称"
style="width: 300px"
class="filter-item"
@keyup.enter.native="handleFilter"
/>
<el-button
class="filter-item"
type="primary"
icon="el-icon-search"
@click="handleFilter"
>搜索</el-button
>
<el-button
class="filter-item"
type="primary"
icon="el-icon-refresh-left"
@click="resetFilter"
>重置</el-button
>
</div>
</el-card>
<el-card >
<el-card>
<el-table
:data="saleList.results"
border
border
fit
stripe
highlight-current-row
height="100"
v-el-height-adaptive-table="{bottomOffset: 42}"
v-el-height-adaptive-table="{ bottomOffset: 42 }"
>
<el-table-column type="index" width="50" />
<el-table-column label="产品名称" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.product">{{ scope.row.product_.name }}</template>
<el-table-column label="产品名称" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.product">{{
scope.row.product_.name
}}</template>
</el-table-column>
<el-table-column label="产品型号" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.product">{{ scope.row.product_.specification }}</template>
<el-table-column label="产品型号" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.product">{{
scope.row.product_.specification
}}</template>
</el-table-column>
<el-table-column label="客户名称" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.customer">{{ scope.row.customer_.name }}</template>
<el-table-column label="客户名称" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.customer">{{
scope.row.customer_.name
}}</template>
</el-table-column>
<el-table-column label="订单编号" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.order">{{ scope.row.order_.number }}</template>
</el-table-column>
<el-table-column label="合同名称" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.order_">{{ scope.row.order_.contract_.name }}</template>
<el-table-column label="订单编号" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.order">{{
scope.row.order_.number
}}</template>
</el-table-column>
<el-table-column label="是否审核" >
<template slot-scope="scope" > <el-tag v-if="scope.row.is_audited == false"></el-tag>
<el-tag v-else></el-tag></template>
<el-table-column label="合同名称" show-overflow-tooltip>
<template slot-scope="scope" v-if="scope.row.order_">{{
scope.row.order_.contract_.name
}}</template>
</el-table-column>
<el-table-column>
<el-table-column label="预计发货时间">
<template slot-scope="scope">{{ scope.row.edelivery_date }}</template>
</el-table-column>
<el-table-column label="预计发货数量">
<template slot-scope="scope">{{ scope.row.count }}</template>
</el-table-column>
<el-table-column label="实际发货数量">
<template slot-scope="scope">{{ scope.row.count_real }}</template>
</el-table-column>
<el-table-column label="是否审核">
<template slot-scope="scope">
<el-link
<el-tag v-if="scope.row.is_audited == false"></el-tag>
<el-tag v-else></el-tag></template
>
</el-table-column>
<el-table-column label="收货人">
<template slot-scope="scope">{{ scope.row.receiver }}</template>
</el-table-column>
<el-table-column label="收货人电话">
<template slot-scope="scope">{{ scope.row.receiver_phone }}</template>
</el-table-column>
<el-table-column label="收货人地址" show-overflow-tooltip>
<template slot-scope="scope">{{
scope.row.receiver_address
}}</template>
</el-table-column>
<el-table-column label="操作" fixed="right">
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_delete'])"
type="primary"
type="primary"
@click="handleDetail(scope)"
>详情</el-link
>
<el-link
v-if="scope.row.is_audited==false"
type="primary"
<el-link
v-if="scope.row.is_audited == false"
type="primary"
@click="handleAudit(scope)"
>审核</el-link
>
<el-link
v-if="scope.row.is_audited==false"
v-if="scope.row.is_audited == false"
type="danger"
@click="handleDelete(scope)"
>删除</el-link
@ -100,98 +129,151 @@
:visible.sync="dialogVisible"
:close-on-click-modal="false"
width="60%"
:title="dialogType === 'edit' ? '编辑销售信息' : '新增销售信息'"
:title="dialogType === 'edit' ? '编辑销售发货' : '新增销售发货'"
>
<el-form
ref="Form"
:model="sale"
label-width="80px"
label-width="100px"
label-position="right"
>
<el-form-item label="关联订单" prop="name">
<el-select style="width: 100%" v-model="sale.order" @change="selectorder" placeholder="请选择">
<el-option
v-for="item in orderoptions"
:key="item.id"
:label="item.number"
:value="item.id">
</el-option>
<el-select
style="width: 100%"
v-model="sale.order"
@change="selectorder"
placeholder="请选择"
>
<el-option
v-for="item in orderoptions"
:key="item.id"
:label="item.number"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="关联客户" prop="customer">
<el-select style="width: 100%" v-model="sale.customer" placeholder="请选择">
<el-option
v-for="item in customeroptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
<el-form-item label="关联客户" prop="customer">
<el-select
style="width: 100%"
v-model="sale.customer"
@change="selectcustomer"
placeholder="请选择"
>
<el-option
v-for="item in customeroptions"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="所需产品" prop="product">
<el-select style="width: 100%" v-model="sale.product" @change="selectproduct" placeholder="请选择">
<el-option
v-for="item in materialoptions"
:key="item.id"
:label="item.name"
:value="item.id">
</el-option>
</el-form-item>
<el-form-item label="关联合同" prop="contract">
<el-input v-model="sale.contract" placeholder="关联合同" />
</el-form-item>
<el-form-item label="所需产品" prop="product">
<el-select
style="width: 100%"
v-model="sale.product"
@change="selectproduct"
placeholder="请选择"
>
<el-option
v-for="item in materialoptions"
:key="item.id"
:label="item.name"
:value="item.id"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="选择产品" prop="iproducts">
<el-table
:data="iproductoptions"
border
fit
stripe
highlight-current-row
ref="multipleTable"
>
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column type="index" width="50" />
<el-table-column label="成品编号">
<template slot-scope="scope">{{ scope.row.number }}</template>
</el-table-column>
</el-form-item>
<el-table-column label="成品批次">
<template slot-scope="scope">{{ scope.row.batch }}</template>
</el-table-column>
<el-table-column label="成品名称">
<template slot-scope="scope">{{ scope.row.material_.name }}</template>
</el-table-column>
<el-table-column label="所在仓库">
<template slot-scope="scope">{{ scope.row.warehouse_.name }}</template>
</el-table-column>
<el-table-column label="是否已军检">
<template slot-scope="scope">
<el-form-item label="选择产品" prop="iproducts">
<el-table
:data="iproductoptions"
border
fit
stripe
highlight-current-row
ref="multipleTable"
height="200"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column type="index" width="50" />
<el-table-column label="成品编号">
<template slot-scope="scope">{{ scope.row.number }}</template>
</el-table-column>
<el-tag v-if="scope.row.is_mtested == false">未军检</el-tag>
<el-tag v-else>已军检</el-tag></template>
<el-table-column label="成品批次">
<template slot-scope="scope">{{ scope.row.batch }}</template>
</el-table-column>
<el-table-column label="成品名称">
<template slot-scope="scope">{{
scope.row.material_.name
}}</template>
</el-table-column>
</el-table-column>
</el-table>
</el-form-item>
<el-table-column label="所在仓库">
<template slot-scope="scope">{{
scope.row.warehouse_.name
}}</template>
</el-table-column>
<el-table-column label="是否已军检">
<template slot-scope="scope">
<el-tag v-if="scope.row.is_mtested == false">未军检</el-tag>
<el-tag v-else>已军检</el-tag></template
>
</el-table-column>
</el-table>
</el-form-item>
<el-form-item label="预计发货时间" prop="edelivery_date">
<el-date-picker
v-model="sale.edelivery_date"
type="date"
placeholder="选择日期"
value-format="yyyy-MM-dd"
style="width: 100%"
>
</el-date-picker>
</el-form-item>
<el-form-item label="运输方式" prop="trans_mode">
<el-select
style="width: 100%"
v-model="sale.trans_mode"
placeholder="请选择"
>
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="收货人" prop="receiver">
<el-input v-model="sale.receiver" placeholder="收货人" />
</el-form-item>
<el-form-item label="联系电话" prop="receiver_phone">
<el-input
v-model="sale.receiver_phone"
placeholder="收货人联系电话"
/>
</el-form-item>
<el-form-item label="收货地址" prop="receiver_address">
<el-input v-model="sale.receiver_address" placeholder="收货地址" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="sale.remark" placeholder="备注" />
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="confirm('Form')">确认</el-button>
@ -200,132 +282,177 @@
</div>
</template>
<script>
import { createSale,getOrderList,getCustomerList,getSaleList,getOrder,deleteSale,getSale,saleAudit} from "@/api/sam";
import {
createSale,
getOrderList,
getCustomerList,
getSaleList,
getOrder,
deleteSale,
getSale,
saleAudit,
getCustomer
} from "@/api/sam";
import checkPermission from "@/utils/permission";
import { getMaterialList } from "@/api/mtm";
import { getiproductList,} from "@/api/inm";
import { getiproductList } from "@/api/inm";
import { genTree } from "@/utils";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
const defaulteSale = {
order:null,
customer:null,
product:null
order: null,
customer: null,
contract:"",
product: null,
edelivery_date: "",
trans_mode: null,
receiver: "",
receiver_phone: "",
receiver_address: "",
remark: "",
};
export default {
components: { Pagination },
data() {
return {
sale: defaulteSale,
saleList: {
saleList: {
count: 0,
},
listQuery: {
page: 1,
page_size: 20,
},
iproducts:[],
orderoptions:[],
customeroptions:[],
materialoptions:[],
iproductoptions:[],
iproducts: [],
orderoptions: [],
customeroptions: [],
materialoptions: [],
iproductoptions: [],
dialogVisible: false,
dialogType: "new",
options: [
{
value: 10,
label: "铁路快运",
},
{
value: 20,
label: "铁路慢运",
},
{
value: 30,
label: "铁路整车",
},
{
value: 40,
label: "汽车运输",
},
{
value: 50,
label: "空运",
},
],
};
},
computed: {},
watch: {},
created() {
this.getList();
this.getCustomerLists();
// this.getproductList();
this.getOrderLists();
this.getMaterialList();
this.getCustomerLists();
// this.getproductList();
this.getOrderLists();
this.getMaterialList();
},
methods: {
checkPermission,
//关联订单
getOrderLists() {
getOrderList({page:0}).then((response) => {
getOrderList({ page: 0 }).then((response) => {
if (response.data) {
this.orderoptions = response.data;
}
});
},
//选择订单变化
selectorder(selval)
{
selectorder(selval) {
getOrder(selval).then((response) => {
if (response.data) {
this.sale.customer = response.data.customer;
this.sale.product = response.data.product;
getiproductList({page:0,to_order:response.data.id}).then((response) => {
this.sale.product = response.data.product;
this.sale.contract = response.data.contract_.name;
this.sale.receiver = response.data.customer_.contact;
this.sale.receiver_phone = response.data.customer_.contact_phone;
this.sale.receiver_address = response.data.customer_.address;
getiproductList({
page: 0,
to_order: response.data.id,
state: 10,
}).then((response) => {
if (response.data) {
this.iproductoptions = response.data;
}
});
}
});
},
selectcustomer(selval)
{
getCustomer(selval).then((response) => {
if (response.data) {
this.iproductoptions=response.data;
this.sale.receiver = response.data.contact;
this.sale.receiver_phone = response.data.contact_phone;
this.sale.receiver_address = response.data.address;
}
});
}
});
},
getList() {
getSaleList(this.listQuery).then((response) => {
if (response.data) {
this.saleList = response.data;
}
});
},
//关联客户
getCustomerLists() {
getCustomerList({page:0,}).then((response) => {
this.customeroptions = response.data;
//关联客户
getCustomerLists() {
getCustomerList({ page: 0 }).then((response) => {
this.customeroptions = response.data;
});
},
//选择产品
getMaterialList()
{
getMaterialList({type:1,page:0}).then((response) => {
getMaterialList() {
getMaterialList({ type: 1, page: 0 }).then((response) => {
if (response.data) {
this.materialoptions = response.data;
}
});
},
//成品
// getproductList() {
// getiproductList({page:0,material__type:1}).then((response) => {
// if (response.data) {
// this.iproductoptions=response.data;
// }
// });
// },
//根据选择的产品弹出对应库里的产品
selectproduct(){
getiproductList({page:0,material__type:1,material:this.sale.product}).then((response) => {
if (response.data) {
this.iproductoptions=response.data;
}
});
},
},
//成品
// getproductList() {
// getiproductList({page:0,material__type:1}).then((response) => {
// if (response.data) {
// this.iproductoptions=response.data;
// }
// });
// },
//根据选择的产品弹出对应库里的产品
selectproduct() {
getiproductList({
page: 0,
material__type: 1,
material: this.sale.product,
}).then((response) => {
if (response.data) {
this.iproductoptions = response.data;
}
});
},
handleFilter() {
this.listQuery.page = 1;
@ -335,20 +462,20 @@ selectproduct(){
this.listQuery = {
page: 1,
page_size: 20,
}
};
this.getList();
},
handleCreate() {
this.sale = Object.assign({}, defaulteSale);
this.dialogType = "new";
this.dialogVisible = true;
this.iproducts=[];
this.iproducts = [];
this.$nextTick(() => {
this.$refs["Form"].resetFields();
this.iproductoptions=[];
this.iproductoptions = [];
});
},
handleEdit(scope) {
this.sale = Object.assign({}, scope.row); // copy obj
console.log(this.sale);
@ -373,7 +500,7 @@ selectproduct(){
console.error(err);
});
},
async confirm(form) {
this.$refs[form].validate((valid) => {
if (valid) {
@ -387,21 +514,15 @@ selectproduct(){
}
});
} else {
this.$refs.multipleTable.selection.forEach((item) => {
this.iproducts.push(
item.id
);
});
this.$refs.multipleTable.selection.forEach((item) => {
this.iproducts.push(item.id);
});
this.sale.iproducts=this.iproducts;
this.sale.iproducts = this.iproducts;
createSale(this.sale).then((res) => {
if (res.code >= 200) {
this.getList();
this.dialogVisible = false;
this.dialogVisible = false;
this.$message.success("成功");
}
});
@ -413,32 +534,27 @@ selectproduct(){
},
//销售详情
handleDetail(scope){
this.$router.push({name: "salesdetail", params: { id: scope.row.id }, })
handleDetail(scope) {
this.$router.push({ name: "salesdetail", params: { id: scope.row.id } });
},
//审核
handleAudit(scope){
saleAudit(scope.row.id).then((res) => {
handleAudit(scope) {
saleAudit(scope.row.id).then((res) => {
if (res.code >= 200) {
this.$message.success("审核成功成功");
this.getList();
}
this.$message.success("审核成功成功");
this.getList();
}
});
}
},
},
};
</script>
<style scoped>
.trdiv >>> .el-transfer-panel{
width:350px;
.trdiv >>> .el-transfer-panel {
width: 350px;
}
.trdiv >>> .el-transfer__buttons{
width:110px
.trdiv >>> .el-transfer__buttons {
width: 110px;
}
</style>

View File

@ -1,131 +1,257 @@
<template>
<div class="app-container">
<el-card style="margin-top: 2px">
<el-descriptions title="基本信息" direction="vertical" :column="8" border>
<el-descriptions-item label="客户名称" v-if="salesdetail.customer"> {{salesdetail.customer_.name}}</el-descriptions-item>
<el-descriptions-item label="产品名称" v-if="salesdetail.product"> {{salesdetail.product_.name}}</el-descriptions-item>
<el-descriptions-item label="产品型号" :span="2" v-if="salesdetail.product"> {{salesdetail.product_.specification}}</el-descriptions-item>
<el-descriptions-item label="订单编号" v-if="salesdetail.order"> {{salesdetail.order_.number}} </el-descriptions-item>
<el-descriptions-item label="合同名称" v-if="salesdetail.order"> {{salesdetail.order_.contract_.name}}</el-descriptions-item>
</el-descriptions>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>关联产品信息</span>
</div>
<el-table
ref="singleTable"
:data="saleproduct"
highlight-current-row
style="width: 100%">
<el-table-column type="index" width="50" />
<el-table-column label="产品编号" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.number }}</template>
</el-table-column>
<el-table-column label="产品名称" show-overflow-tooltip>
<template slot-scope="scope" >{{ scope.row.iproduct_.material_.name }}</template>
</el-table-column>
<el-table-column label="批次" >
<template slot-scope="scope" >{{ scope.row.iproduct_.batch }}</template>
</el-table-column>
<el-table-column label="仓库">
<template slot-scope="scope">{{ scope.row.iproduct_.warehouse_.name }}</template>
</el-table-column>
<el-table-column label="是否已军检">
<template slot-scope="scope">
<el-tag v-if="scope.row.is_mtested == false">未军检</el-tag>
<el-tag v-else>已军检</el-tag></template>
</el-table-column>
<el-table-column label="军检">
<template slot-scope="scope">
<el-tag v-if="scope.row.is_mtestok == false">不合格</el-tag>
<el-tag v-else>合格</el-tag></template>
</el-table-column>
<el-table-column
align="center"
label="操作"
width="220px"
<el-descriptions-item label="客户名称" v-if="salesdetail.customer">
{{ salesdetail.customer_.name }}</el-descriptions-item
>
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_delete'])"
type="danger"
@click="handleDelete(scope)"
>删除</el-link
<el-descriptions-item label="产品名称" v-if="salesdetail.product">
{{ salesdetail.product_.name }}</el-descriptions-item
>
<el-descriptions-item
label="产品型号"
:span="2"
v-if="salesdetail.product"
>
{{ salesdetail.product_.specification }}</el-descriptions-item
>
<el-descriptions-item label="订单编号" v-if="salesdetail.order">
{{ salesdetail.order_.number }}
</el-descriptions-item>
<el-descriptions-item label="合同名称" v-if="salesdetail.order">
{{ salesdetail.order_.contract_.name }}</el-descriptions-item
>
</el-descriptions>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>关联产品信息</span>
</div>
<el-table
ref="singleTable"
:data="saleproduct"
highlight-current-row
style="width: 100%"
>
<el-table-column type="index" width="50" />
<el-table-column label="产品编号" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.number }}</template>
</el-table-column>
<el-table-column label="产品名称" show-overflow-tooltip>
<template slot-scope="scope">{{
scope.row.iproduct_.material_.name
}}</template>
</el-table-column>
<el-table-column label="批次">
<template slot-scope="scope">{{
scope.row.iproduct_.batch
}}</template>
</el-table-column>
<el-table-column label="仓库">
<template slot-scope="scope">{{
scope.row.iproduct_.warehouse_.name
}}</template>
</el-table-column>
<el-table-column label="是否已军检">
<template slot-scope="scope">
<el-tag v-if="scope.row.is_mtested == false">未军检</el-tag>
<el-tag v-else>已军检</el-tag></template
>
</template>
</el-table-column>
</el-table>
</el-card>
</el-card>
</el-table-column>
<el-table-column label="军检">
<template slot-scope="scope">
<el-tag v-if="scope.row.is_mtestok == false">不合格</el-tag>
<el-tag v-else>合格</el-tag></template
>
</el-table-column>
<el-table-column label="装箱单号" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.packnum }}</template>
</el-table-column>
<el-table-column label="未装箱说明" show-overflow-tooltip>
<template slot-scope="scope">{{ scope.row.remark }}</template>
</el-table-column>
<el-table-column align="center" label="操作" width="220px">
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_delete'])"
type="primary"
@click="handlePack(scope)"
>装箱</el-link
>
<el-link
v-if="checkPermission(['warehouse_delete'])"
type="primary"
@click="handleNotPack(scope)"
>备注</el-link
>
<el-link
v-if="checkPermission(['warehouse_delete'])"
type="danger"
@click="handleDelete(scope)"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
<el-dialog
:visible.sync="dialogVisible"
:close-on-click-modal="false"
width="60%"
:title="dialogType === 'edit' ? '编辑装箱单' : '新增装箱单'"
>
<el-form
ref="Form"
:model="packData"
label-width="100px"
label-position="right"
>
<el-form-item label="装箱单号" prop="packnum">
<el-input v-model="packData.packnum" placeholder="装箱单号" />
</el-form-item>
<el-form-item label="装箱文件确认" prop="iproducts">
<el-table
:data="packlist"
border
fit
stripe
highlight-current-row
ref="multipleTable"
height="300"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column type="index" width="50" label="序号" />
<el-table-column label="名称">
<template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column>
<el-table-column label="单位">
<template slot-scope="scope">{{ scope.row.unit }}</template>
</el-table-column>
<el-table-column label="数量">
<template slot-scope="scope">
<el-form :model="scope.row">
<el-form-item size="mini">
<el-input-number
v-model="scope.row.count"
:min="0"
:value="0"
></el-input-number>
</el-form-item>
</el-form>
</template>
</el-table-column>
<el-table-column label="库存数量">
<template slot-scope="scope" v-if="scope.row.material_">{{
scope.row.material_.count
}}</template>
</el-table-column>
<el-table-column label="安全库存数量">
<template slot-scope="scope" v-if="scope.row.material_">{{
scope.row.material_.count_safe
}}</template>
</el-table-column>
</el-table>
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisible = false"
>取消</el-button
>
<el-button type="primary" @click="submitPack">确认</el-button>
</div>
</el-dialog>
<el-dialog
:visible.sync="dialogVisibles"
:close-on-click-modal="false"
width="60%"
title="未装箱备注"
>
<el-form
ref="Form"
:model="notpackData"
label-width="100px"
label-position="right"
>
<el-form-item label="备注" prop="remark">
<el-input v-model="notpackData.remark" placeholder="未装箱备注" />
</el-form-item>
</el-form>
<div style="text-align: right">
<el-button type="danger" @click="dialogVisibles = false"
>取消</el-button
>
<el-button type="primary" @click="submitnotPack">确认</el-button>
</div>
</el-dialog>
</el-card>
</el-card>
</div>
</template>
<script>
import {getSale,getSaleproductList,deleteSaleproduct} from "@/api/sam";
import {
getSale,
getSaleproductList,
deleteSaleproduct,
gePack,
subPack,
notPackremark,
} from "@/api/sam";
import checkPermission from "@/utils/permission";
import { genTree } from "@/utils";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
const defaultepackData = {
packnum: ""
}
export default {
components: { Pagination },
data() {
return {
salesdetail:"",
saleproduct:"",
salesdetail: "",
saleproduct: "",
packlist: [],
dialogVisible: false,
dialogVisibles:false,
packData:defaultepackData,
notpackData:{remark:""},
detail: [],
saleproductId: null,
saleProductid:null,
dialogType: "new",
};
},
computed: {},
watch: {},
created() {
this.id = this.$route.params.id;
this.id = this.$route.params.id;
this.getList();
this.getSaleproductLists();
},
methods: {
checkPermission,
//详情
getList() {
getSale(this.id).then((response) => {
if (response.data) {
this.salesdetail = response.data;
}
});
},
getSaleproductLists()
{
getSaleproductList({sale:this.id,page:0}).then((response) => {
getSaleproductLists() {
getSaleproductList({ sale: this.id, page: 0 }).then((response) => {
if (response.data) {
this.saleproduct = response.data;
}
});
},
handleDelete(scope) {
handleDelete(scope) {
this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
@ -140,7 +266,58 @@ export default {
console.error(err);
});
},
//装箱操作
handlePack(scope) {
this.packData = Object.assign({}, scope.row);
this.dialogType = "new";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate();
});
gePack(scope.row.id).then((response) => {
if (response.data) {
this.packlist = response.data.detail;
}
});
this.saleproductId = scope.row.id;
},
submitPack() {
this.$refs.multipleTable.selection.forEach((item) => {
this.detail.push({
id: item.id,
count: item.count,
});
});
console.log( this.detail);
this.packData.detail = this.detail;
subPack(this.saleproductId, this.packData).then((res) => {
if (res.code >= 200) {
this.getSaleproductLists();
this.dialogVisible = false;
this.$message.success("成功");
}
});
},
//未装箱备注
handleNotPack(scope)
{
this.dialogVisibles=true;
this.saleProductid=scope.row.id;
}
,
submitnotPack()
{
notPackremark(this.saleProductid, this.notpackData).then((res) => {
if (res.code >= 200) {
this.getSaleproductLists();
this.dialogVisible = false;
this.$message.success("成功");
}
});
}
},
};
</script>

View File

@ -30,7 +30,7 @@ class HRMService:
update_all_user_facedata_cache()
try:
results = face_recognition.compare_faces(face_datas,
unknown_face_encoding, tolerance=0.5)
unknown_face_encoding, tolerance=0.48)
except:
return None, '人脸匹配失败'
for index, value in enumerate(results):

View File

@ -29,4 +29,4 @@ class IProductFilterSet(DynamicFieldsFilterMixin, filters.FilterSet):
class Meta:
model = IProduct
fields = ['material', 'warehouse', 'batch', 'order', 'material__type', 'update_time_start', 'update_time_end',
'to_order', 'need_to_order']
'to_order', 'need_to_order', 'state']

View File

@ -95,6 +95,13 @@ class FIFOItemCreateSerializer(serializers.ModelSerializer):
if fifo.pu_order is not None:
raise ValidationError('非采购订单')
return super().create(validated_data)
def validate_batch(self, value):
if value == '':
return value
elif len(value) > 6:
return value
raise ValidationError('批次号错误')
class FIFOItemUpdateSerializer(serializers.ModelSerializer):
class Meta:
@ -122,6 +129,13 @@ class FIFODetailInPurSerializer(serializers.ModelSerializer):
class Meta:
model = FIFOItem
fields = ['material', 'count', 'batch', 'details', 'warehouse']
def validate_batch(self, value):
if value == '':
return value
elif len(value) > 6:
return value
raise ValidationError('批次号错误')
class MaterialBatchQuerySerializer(serializers.Serializer):

View File

@ -1,5 +1,10 @@
from itertools import count
from rest_framework.exceptions import ValidationError
from apps.inm.models import FIFOItemProduct, IProduct, Inventory, MaterialBatch, FIFO, FIFOItem
from apps.inm.models import FIFOItemProduct, IProduct, Inventory, MaterialBatch, FIFO, FIFOItem, WareHouse
from apps.mtm.models import Material
from apps.sam.models import SalePack, SaleProduct
from django.db.models import Count
from django.db.models.aggregates import Sum
class InmService:
@classmethod
@ -53,18 +58,19 @@ class InmService:
o1 = Inventory.objects.get(material=material, warehouse=warehouse)
temp_count = o1.count - i.count
if temp_count < 0:
raise ValidationError('库存不足,操作失败')
raise ValidationError('仓库库存不足,操作失败')
o1.count = temp_count
o1.save()
print(i.batch)
o2 = MaterialBatch.objects.get(material=material, warehouse=warehouse, batch=i.batch)
temp_count = o2.count - i.count
if temp_count < 0:
raise ValidationError('库存不足,操作失败')
raise ValidationError('批次库存不足,操作失败')
o2.count = temp_count
o2.save()
temp_count = material.count - i.count
if temp_count < 0:
raise ValidationError('库存不足,操作失败')
raise ValidationError('物料库存不足,操作失败')
material.count = temp_count
material.save()
@ -72,4 +78,64 @@ class InmService:
if instance.type == FIFO.FIFO_TYPE_DO_OUT:
# 生产领料的情况直接从IProduct中删除
numbers = FIFOItemProduct.objects.filter(fifoitem=i).values_list('number', flat=True)
IProduct.objects.filter(number__in=numbers).delete()
IProduct.objects.filter(number__in=numbers).delete()
# 销售的话已经处理了
# elif instance.type == FIFO.FIFO_TYPE_SALE_OUT:
# ips = FIFOItemProduct.objects.filter(fifoitem=i).values_list('iproduct', flat=True)
# IProduct.objects.filter(id__in=ips).update(state=IProduct.SALED)
@classmethod
def sale_out_audit(cls, fifo:FIFO):
sale = fifo.sale
saleps = SaleProduct.objects.filter(sale=sale, packnum__isnull=True, remark__isnull=True)
if saleps.exists():
raise ValidationError('存在未装箱的产品')
# 创建出库条目
ips = IProduct.objects.filter(sale_iproduct__sale=sale,
sale_iproduct__packnum__isnull=False)
ips.update(state=IProduct.SALED)
items = ips.values('warehouse', 'material', 'batch').annotate(total=Count('id'))
for i in items:
warehouse = WareHouse.objects.get(id=i['warehouse'])
material = Material.objects.get(id=i['material'])
fifoitem = FIFOItem()
fifoitem.need_test = False
fifoitem.warehouse = warehouse
fifoitem.material = material
fifoitem.count = i['total']
fifoitem.batch = i['batch']
fifoitem.fifo = fifo
fifoitem.save()
items_p = ips.filter(warehouse=warehouse, batch=i['batch'])
ipxs = []
for i in items_p:
# 创建出库明细半成品
ip = {}
ip['fifoitem'] = fifoitem
ip['number'] = i.number
ip['material'] = i.material
ip['iproduct'] = i
ipxs.append(FIFOItemProduct(**ip))
FIFOItemProduct.objects.bulk_create(ipxs)
# 装箱附件处理
# ml = SalePack.objects.filter(sale_product__iproduct = ips
# ).values('packitem__material').annotate(count=Sum('count'))
# for i in ml:
# material = Material.objects.get(id=i['material'])
# 更新动态产品表情况
from apps.wpm.models import WProduct
WProduct.objects.filter(id__in=ips.values_list('wproduct', flat=True)).update(
act_state=WProduct.WPR_ACT_STATE_SELLED)
# 变更销售记录实际发货数
sale.count_real = ips.count()
sale.save()
# 变更订单状态
order = sale.order
if order:
order.delivered_count = IProduct.objects.filter(sale_iproduct__sale__order=order
, sale_iproduct__packnum__isnull=False).count()
order.save()

View File

@ -184,24 +184,27 @@ class FIFOViewSet(ListModelMixin, DestroyModelMixin, GenericViewSet):
return Response()
@action(methods=['post'], detail=True, perms_map={'post': 'fifo_audit'}, serializer_class=serializers.Serializer)
@transaction.atomic
def audit(self, request, pk=None):
"""
审核通过
"""
obj = self.get_object()
if not FIFOItem.objects.filter(fifo=obj).exists():
raise ValidationError('出入库条目为空')
for i in FIFOItem.objects.filter(fifo=obj, need_test=True):
if not i.is_testok:
raise APIException('未检验通过, 不可审核')
if obj.is_audited:
raise APIException('该入库记录已审核通过')
with transaction.atomic():
obj.is_audited = True
obj.auditor = request.user
obj.inout_date = timezone.now() # 也是审核日期
obj.save()
InmService.update_inm(obj) # 更新库存
raise APIException('该入库记录已审核通过')
if obj.type == FIFO.FIFO_TYPE_SALE_OUT: # 如果是销售提货,需额外处理
InmService.sale_out_audit(obj)
else:
if not FIFOItem.objects.filter(fifo=obj).exists():
raise ValidationError('出入库条目为空')
for i in FIFOItem.objects.filter(fifo=obj, need_test=True):
if not i.is_testok:
raise APIException('未检验通过, 不可审核')
obj.is_audited = True
obj.auditor = request.user
obj.inout_date = timezone.now() # 也是审核日期
obj.save()
InmService.update_inm(obj) # 更新库存
return Response()

View File

@ -21,7 +21,7 @@ class CustomerCreateUpdateSerializer(serializers.ModelSerializer):
class CustomerSimpleSerializer(serializers.ModelSerializer):
class Meta:
model = Customer
fields = ['id', 'name']
fields = ['id', 'name', 'address', 'contact', 'contact_phone']
class ContractSerializer(serializers.ModelSerializer):
customer_ = CustomerSimpleSerializer(source='customer', read_only=True)

View File

@ -89,10 +89,11 @@ class SPackItemCreateSerializer(serializers.Serializer):
class SaleProductPackSerializer(serializers.ModelSerializer):
detail = SPackItemCreateSerializer(many=True)
packnum = serializers.CharField(min_length=6)
class Meta:
model = SaleProduct
fields = ['packnum', 'detail', 'remark']
class SRemarkItemCreateSerializer(serializers.Serializer):
remark = serializers.CharField()
remark = serializers.CharField(min_length=6)

View File

@ -42,7 +42,8 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
if obj.is_audited:
raise exceptions.APIException('该销售记录已审核,不可删除')
obj.delete()
IProduct.objects.filter(sale_iproduct__sale=obj).update()
IProduct.objects.filter(sale_iproduct__sale=obj).update(state=IProduct.SALE_OK)
return Response()
def create(self, request, *args, **kwargs):
data = request.data
@ -89,46 +90,10 @@ class SaleViewSet(CreateUpdateModelAMixin, ListModelMixin, RetrieveModelMixin, C
fifo.create_by = request.user
fifo.number = 'CK' + ranstr(7)
fifo.save()
# 创建出库条目
# ips = IProduct.objects.filter(sale_iproduct__sale=obj)
# items = ips.values('warehouse', 'material', 'batch').annotate(total=Count('id'))
# for i in items:
# warehouse = WareHouse.objects.get(id=i['warehouse'])
# material = Material.objects.get(id=i['material'])
# fifoitem = FIFOItem()
# fifoitem.need_test = False
# fifoitem.warehouse = warehouse
# fifoitem.material = material
# fifoitem.count = i['total']
# fifoitem.batch = i['batch']
# fifoitem.fifo = fifo
# fifoitem.save()
# items_p = ips.filter(warehouse=warehouse, batch=i['batch'])
# ipxs = []
# for i in items_p:
# # 创建出库明细半成品
# ip = {}
# ip['fifoitem'] = fifoitem
# ip['number'] = i.number
# ip['material'] = i.material
# ip['iproduct'] = i
# ipxs.append(FIFOItemProduct(**ip))
# FIFOItemProduct.objects.bulk_create(ipxs)
# 更新动态产品表情况
# from apps.wpm.models import WProduct
# WProduct.objects.filter(iproduct_wproduct__sale_iproduct__sale=obj).update(
# act_state=WProduct.WPR_ACT_STATE_SELLED)
# 更新库存
# InmService.update_inm(fifo)
# 变更销售提货审核状态
obj.is_audited = True
obj.save()
# 变更订单状态
# if obj.order:
# order = obj.order
# order.delivered_count = order.delivered_count + obj.count
# order.save()
return Response()