This commit is contained in:
shilixia 2021-12-07 15:05:41 +08:00
parent bf3bbb0c3a
commit 447886c609
8 changed files with 703 additions and 4 deletions

View File

@ -73,6 +73,13 @@ export function createOrder(data) {
data
})
}
export function getOrder(id) {
return request({
url: `/sam/order/${id}/`,
method: 'get'
})
}
export function updateOrder(id, data) {
return request({
url: `/sam/order/${id}/`,
@ -93,4 +100,75 @@ export function getordertoplan() {
url: '/sam/order/toplan/',
method: 'get',
})
}
}
//销售记录列表
export function getSaleList(query) {
return request({
url: '/sam/sale/',
method: 'get',
params: query
})
}
//销售记录创建
export function createSale(data) {
return request({
url: '/sam/sale/',
method: 'post',
data
})
}
export function deleteSale(id, data) {
return request({
url: `/sam/sale/${id}/`,
method: 'delete',
data
})
}
export function getSale(id) {
return request({
url: `/sam/sale/${id}/`,
method: 'get'
})
}
//销售记录列表
export function getSaleproductList(query) {
return request({
url: '/sam/sale_product/',
method: 'get',
params: query
})
}
//删除销售记录关联产品
export function deleteSaleproduct(id, data) {
return request({
url: `/sam/sale_product/${id}/`,
method: 'delete',
data
})
}
//军检
export function saleMtest(id, data) {
return request({
url: `/sam/sale_product/${id}/mtest/`,
method: 'POST',
data
})
}
//审核
export function saleAudit(id) {
return request({
url: `/sam/sale/${id}/audit/`,
method: 'POST',
})
}

View File

@ -262,7 +262,7 @@ export const asyncRoutes = [
component: Layout,
redirect: '/sam/customer',
name: 'sam',
meta: { title: '合同管理', icon: 'example', perms: ['equipment_set'] },
meta: { title: '销售管理', icon: 'example', perms: ['equipment_set'] },
children: [
{
path: 'customer',
@ -284,6 +284,21 @@ export const asyncRoutes = [
component: () => import('@/views/sam/order'),
meta: { title: '订单信息', icon: 'example', perms: ['index_manage'] }
}
,
{
path: 'sales',
name: 'sales',
component: () => import('@/views/sam/sales'),
meta: { title: '销售信息', icon: 'example', perms: ['index_manage'] }
}
,
{
path: 'salesdetail/:id',
name: 'salesdetail',
component: () => import('@/views/sam/salesdetail'),
meta: { title: '销售详情', perms: ['vendor_manage'] },
hidden: true
}
]
}
,

View File

@ -49,7 +49,7 @@
</el-table-column>
<el-table-column label="操作人员">
<template slot-scope="scope">{{
<template slot-scope="scope" v-if="scope.row.create_by">{{
scope.row.create_by_.name
}}</template>
</el-table-column>

View File

@ -98,7 +98,6 @@
</el-card>
<el-dialog
:visible.sync="dialogVisible"
:close-on-click-modal="false"
:title="dialogType === 'edit' ? '编辑合同' : '新增合同'"
>
<el-form

View File

@ -63,6 +63,10 @@
<el-table-column label="交货日期" width="150" >
<template slot-scope="scope">{{ scope.row.delivery_date }}</template>
</el-table-column>
<el-table-column label="已交货数量" width="150" >
<template slot-scope="scope">{{ scope.row.delivered_count }}</template>
</el-table-column>
<el-table-column label="创建时间" width="160" >
<template slot-scope="scope">{{ scope.row.create_time }}</template>
</el-table-column>

View File

@ -0,0 +1,404 @@
<template>
<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-card>
<el-card style="margin-top: 2px">
<el-table
v-loading="listLoading"
:data="saleList.results"
border
fit
stripe
highlight-current-row
>
<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>
<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>
<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">{{ scope.row.order_.contract_.name }}</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>
<el-table-column>
<template slot-scope="scope">
<el-link
v-if="checkPermission(['warehouse_delete'])"
@click="handleDetail(scope)"
>详情</el-link
>
<el-link
v-if="scope.row.is_audited==false"
@click="handleAudit(scope)"
>审核</el-link
>
<el-link
v-if="scope.row.is_audited==false"
type="danger"
@click="handleDelete(scope)"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
<pagination
v-show="saleList.count > 0"
:total="saleList.count"
:page.sync="listQuery.page"
:limit.sync="listQuery.page_size"
@pagination="getList"
/>
</el-card>
<el-dialog
:visible.sync="dialogVisible"
:close-on-click-modal="false"
:title="dialogType === 'edit' ? '编辑销售信息' : '新增销售信息'"
>
<el-form
ref="Form"
:model="sale"
label-width="80px"
label-position="right"
:rules="rule1"
>
<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>
</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-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-select>
</el-form-item>
<el-form-item label="选择产品" prop="iproducts">
<div class="trdiv">
<el-transfer v-model="sale.iproducts" :data="iproductoptions" :titles="['未选产品', '已选产品']" right-check-change="change"></el-transfer>
</div>
</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>
</div>
</el-dialog>
</div>
</template>
<script>
import { createSale,getOrderList,getCustomerList,getSaleList,getOrder,deleteSale,getSale,saleAudit} from "@/api/sam";
import checkPermission from "@/utils/permission";
import { getMaterialList } from "@/api/mtm";
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
};
export default {
components: { Pagination },
data() {
return {
sale: defaulteSale,
saleList: {
count: 0,
},
listQuery: {
page: 1,
page_size: 20,
},
orderoptions:[],
customeroptions:[],
materialoptions:[],
iproductoptions:[],
dialogVisible: false,
dialogType: "new",
};
},
computed: {},
watch: {},
created() {
this.getList();
this.getCustomerLists();
this.getproductList();
this.getOrderLists();
this.getMaterialList();
},
methods: {
checkPermission,
//关联订单
getOrderLists() {
getOrderList({page:0}).then((response) => {
if (response.data) {
this.orderoptions = response.data;
}
});
},
//选择订单变化
selectorder(selval)
{
getOrder(selval).then((response) => {
if (response.data) {
this.sale.customer = response.data.customer;
this.sale.product = response.data.product;
this.iproductoptions=[];
getiproductList({material: this.sale.product,page:0}).then((response) => {
if (response.data) {
response.data.forEach((item) => {
this.iproductoptions.push({
label: item.material_.name,
key: item.id
})
});
}
});
}
});
},
getList() {
getSaleList(this.listQuery).then((response) => {
if (response.data) {
this.saleList = response.data;
}
});
},
//关联客户
getCustomerLists() {
getCustomerList({page:0,}).then((response) => {
this.customeroptions = response.data;
});
},
//选择产品
getMaterialList()
{
getMaterialList({type:1,page:0}).then((response) => {
if (response.data) {
this.materialoptions = response.data;
}
});
},
selectproduct(selval)
{
this.iproductoptions=[];
getiproductList({material:selval,page:0}).then((response) => {
if (response.data) {
response.data.forEach((item) => {
this.iproductoptions.push({
label: item.material_.name,
key: item.id
})
});
}
});
},
//成品
getproductList() {
this.iproductoptions=[],
getiproductList({page:0}).then((response) => {
if (response.data) {
response.data.forEach((item) => {
this.iproductoptions.push({
label: item.material_.name,
key: item.id
})
});
}
});
},
handleFilter() {
this.listQuery.page = 1;
this.getList();
},
resetFilter() {
this.listQuery = {
page: 1,
page_size: 20,
}
this.getList();
},
handleCreate() {
this.sale = Object.assign({}, defaulteSale);
this.dialogType = "new";
this.dialogVisible = true;
this.iproductoptions=[];
this.$nextTick(() => {
this.$refs["Form"].clearValidate();
});
},
handleEdit(scope) {
this.sale = Object.assign({}, scope.row); // copy obj
console.log(this.sale);
this.dialogType = "edit";
this.dialogVisible = true;
this.$nextTick(() => {
this.$refs["Form"].clearValidate();
});
},
handleDelete(scope) {
this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
})
.then(async () => {
await deleteSale(scope.row.id);
this.getList();
this.$message.success("成功");
})
.catch((err) => {
console.error(err);
});
},
async confirm(form) {
this.$refs[form].validate((valid) => {
if (valid) {
const isEdit = this.dialogType === "edit";
if (isEdit) {
updateContract(this.sale.id, this.sale).then((res) => {
if (res.code >= 200) {
this.getList();
this.dialogVisible = false;
this.$message.success("成功");
}
});
} else {
createSale(this.sale).then((res) => {
if (res.code >= 200) {
this.getList();
this.dialogVisible = false;
this.$message.success("成功");
}
});
}
} else {
return false;
}
});
},
//销售详情
handleDetail(scope){
this.$router.push({name: "salesdetail", params: { id: scope.row.id }, })
},
//审核
handleAudit(scope){
saleAudit(scope.row.id).then((res) => {
if (res.code >= 200) {
this.$message.success("审核成功成功");
this.getList();
}
});
}
},
};
</script>
<style scoped>
.trdiv >>> .el-transfer-panel{
width:250px;
}
</style>

View File

@ -0,0 +1,192 @@
<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"
>
<template slot-scope="scope">
<el-link
v-if="scope.row.is_mtested == false"
@click="handleMtest(scope)"
>军检</el-link
>
<el-link
v-if="checkPermission(['warehouse_delete'])"
type="danger"
@click="handleDelete(scope)"
>删除</el-link
>
</template>
</el-table-column>
</el-table>
</el-card>
<el-dialog
:visible.sync="dialogVisible"
:close-on-click-modal="false"
title="军检"
>
<el-form
ref="Form"
:model="mtest"
label-width="150px"
label-position="right"
>
<el-form-item label="军检是否合格">
<el-radio v-model="mtest.is_mtestok" label=True >合格</el-radio>
<el-radio v-model="mtest.is_mtestok" label=False >不合格</el-radio>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="mtest.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="smtconfirm('Form')">确认</el-button>
</div>
</el-dialog>
</el-card>
</div>
</template>
<script>
import {getSale,getSaleproductList,deleteSaleproduct,saleMtest} from "@/api/sam";
import checkPermission from "@/utils/permission";
import { genTree } from "@/utils";
import Pagination from "@/components/Pagination"; // secondary package based on el-pagination
export default {
components: { Pagination },
data() {
return {
mtest: {},
salesdetail:"",
saleproduct:"",
dialogVisible:false,
};
},
computed: {},
watch: {},
created() {
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) => {
if (response.data) {
this.saleproduct = response.data;
}
});
},
handleDelete(scope) {
this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
})
.then(async () => {
await deleteSaleproduct(scope.row.id);
this.getSaleproductLists();
this.$message.success("成功");
})
.catch((err) => {
console.error(err);
});
},
handleMtest(scope){
this.saleproduct=scope.row.id;
this.dialogVisible=true;
},
smtconfirm(){
saleMtest(this.saleproduct,this.mtest).then((res) => {
if (res.code >= 200) {
this.getSaleproductLists();
this.dialogVisible = false;
this.$message.success("成功");
}
});
}
},
};
</script>

View File

@ -3,6 +3,7 @@
<el-card>
<div slot="header" class="clearfix">
<span>基本信息</span>
<el-button style="float: right; padding: 3px 0" @click="readbook()" type="text">查看作业指导书</el-button>
</div>
<el-form
ref="form"
@ -629,6 +630,12 @@ export default {
},
methods: {
checkPermission,
//作业指导书
readbook(){
},
//是否使用边角料
getList() {
getoperation(this.id).then((response) => {