JNBusiness/ruoyi-ui/src/views/redBook/productSelect.vue

1035 lines
43 KiB
Vue

<template>
<div class="app-container">
<el-form label-width="80px" :model="form">
<el-row :gutter="5">
<el-col :span="10">
<el-input style="width:30%" size="mini" v-model="queryParams.name_0" placeholder="型号 模糊查询"></el-input>
<el-input style="width:30%;margin-left: 5px;" size="mini" v-model="queryParams.model" placeholder="规格 模糊查询"></el-input>
<el-button style="float: right;" size="mini" type="primary" icon="el-icon-search" @click="handleSearchClick">搜索</el-button>
</el-col>
<el-col :span="14">
<el-button style="float: right;margin-left: 5px;" size="mini" type="success" icon="el-icon-document" @click="handleMadeQuotClick" :disabled="selectedResultData.length==0 || madeQuotDis">生成报价单</el-button>
<el-button style="float: right;margin-left: 5px;" size="mini" type="warning" icon="el-icon-folder" @click="handleSaveClick" :disabled="selectedResultData.length==0">保存</el-button>
<el-button style="float: right;margin-left: 5px;" size="mini" icon="el-icon-refresh" @click="handleRefreshClick">清空信息</el-button>
<el-button style="float: right;" size="mini" type="info" plain icon="el-icon-upload2" @click="handleImport">导入</el-button>
<el-button style="float: right;margin-left: 5px;" size="mini" type="primary" icon="el-icon-document" @click="handleMadeXjQuotClick" :disabled="selectedResultData.length==0 || madeQuotDis">生成询价单</el-button>
</el-col>
</el-row>
<splitpanes class="default-theme mt5" split="vertical">
<pane :size="60">
<el-card id="scroll" class="box-card scrollable" :style="{'overflow': 'auto','max-height': scrollableHeight,'height': scrollableHeight}">
<div style="min-width: 700px">
<el-form-item label="目录:" class="customer-form-item">
<el-row>
<el-col :span="6" v-for="(item, index) in modelList" :key="index">
<el-link :underline="false" class="block" :style="selectedModelTag==item.name_0?'color:#ffba00;font-weight: bold;':'color:#1890ff;'" @click="selModelTag(item)">{{item.name_0}}</el-link>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="备注:" v-if="showRemarkList">
<el-col :span="24">
<div class="text-content">
<div v-if="expandedIndex === id">
<el-button type="text" style="float: right" @click="toggleText(-1)">收起</el-button>
<div v-for="(item, index) in remarkList" :key="index" style="line-height: 25px">
{{index+1}}、{{item.remark_0}}
</div>
</div>
<div v-else>
<el-button type="text" style="float: right" @click="toggleText(id)">更多</el-button>
<div class="text-preview">
<div v-for="(item, index) in remarkList" :key="index" style="line-height: 25px">
{{index+1}}、{{item.remark_0}}
</div>
</div>
</div>
</div>
</el-col>
</el-form-item>
<el-form-item label="型号:" v-if="showXinghList" class="customer-form-item">
<el-col :span="6" v-for="(item, index) in xinghList" :key="index">
<el-link :underline="false" class="block" :style="selectedXinghTag==item.name_0?'color:#ffba00;font-weight: bold;':'color:#1890ff;'" @click="selXinghTag(item)">{{item.name_0}}</el-link>
</el-col>
</el-form-item>
<el-form-item label="子类:" v-if="showZlList" class="customer-form-item">
<el-col :span="6" v-for="(item, index) in zlList" :key="index">
<el-link :underline="false" class="block" size="mini" :style="selectedZlTag==item.name_0?'color:#ffba00;font-weight: bold;':'color:#1890ff;'" @click="selZlTag(item)">{{item.name_0}}</el-link>
</el-col>
</el-form-item>
<el-form-item label="衍生型号:" v-if="showYsxhList" class="customer-form-item">
<el-col :span="6" v-for="(item, index) in ysxhList" :key="index">
<el-link :underline="false" class="block" :style="selectedYsxhTag==item.name_0?'color:#ffba00;font-weight: bold;':'color:#1890ff;'" @click="selYsxhTag(item)">{{item.name_0}}</el-link>
</el-col>
</el-form-item>
<el-form-item label="截面:" v-if="showJmList" class="customer-form-item">
<el-col :span="3" v-for="(item, index) in jmList" :key="index">
<el-link :underline="false" class="block" :style="selectedJmTag==item.section?'color:#ffba00;font-weight: bold;':'color:#1890ff;'" @click="selJmTag(item)">{{item.section}}</el-link>
</el-col>
</el-form-item>
</div>
<el-table width="100%" style="min-width:800px" v-loading="searchResultLoading" ref="searchResultTable" :data="searchResultPagedData" @row-dblclick="handleRowDblclick">
<el-table-column label="版本uid" align="center" prop="uid_0" v-if="false"/>
<el-table-column label="产品型号" align="center" prop="name_0"/>
<el-table-column label="型号" align="center" prop="model" v-if="false"/>
<el-table-column label="规格" align="center" prop="spec" v-if="false"/>
<el-table-column label="电压" align="center" prop="voltage"/>
<el-table-column label="红本价(元)" align="center" prop="price"/>
<el-table-column label="单位" align="center" prop="stu"/>
</el-table>
<pagination
v-show="searchResultTotal>0"
:total="searchResultTotal"
:page.sync="searchResultCurrentPage"
:limit.sync="searchResultPageSize"
@size-change="handleSearchResultSizeChange"
@current-change="handleSearchResultCurrentChange"
:layout="'total, prev, pager, next'"
/>
</el-card>
</pane>
<pane>
<el-card id="scroll" class="box-card scrollable" :style="{'overflow': 'auto','max-height': scrollableHeight,'height': scrollableHeight}">
<div style="min-width: 650px">
<el-form ref="form" :model="form" label-width="100px">
<el-row :gutter="8">
<el-col :span="12">
<el-form-item label="询价单位" prop="quotCustomer" style="margin-bottom: 10px;">
<el-input v-model="form.quotCustomer" placeholder="请输入询价单位" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="项目名称" prop="quotProject" style="margin-bottom: 10px;">
<el-input v-model="form.quotProject" placeholder="请输入项目名称"/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="8">
<el-col :span="8">
<el-form-item label="联系人" prop="quotLxr" style="margin-bottom: 10px;">
<el-input v-model="form.quotLxr" placeholder="请输入联系人" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="联系电话" prop="quotLxrdh" style="margin-bottom: 10px;">
<el-input v-model="form.quotLxrdh" placeholder="请输入联系电话"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="总价" style="margin-bottom: 10px;">
<el-input class="totalPrice-input" v-model="sumSelectedResultData"/>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="8">
<el-col :span="24">
<el-form-item label="总金额" prop="totalPrice" v-if="false">
<el-input v-model="form.totalPrice"/>
</el-form-item>
<el-form-item label="设置折扣率" label-width="100px" style="margin-bottom: 10px;">
<el-input style="width:65px" v-model="perc" size="small" @blur="changeData" @keyup.enter.native="changeData"></el-input>
<el-input style="width:65px;margin-left: 5px" v-model="perc2" size="small" @blur="changeData" @keyup.enter.native="changeData"></el-input>
<!--总价:<span style="color:red;font-size: 15px">{{sumSelectedResultData}} 元</span>-->
<el-select v-model="form.rbDateUid" style="width: 235px;margin-left: 5px" :disabled="selectedResultData.length==0">
<el-option
v-for="item in versionList"
:key="item.value"
:label="item.label"
:value="item.value"
@click.native="selectRbDate(item.value)"/>
</el-select>
<el-button style="float: right;" size="mini" type="info" plain icon="el-icon-upload2" @click="handleExport">导出</el-button>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
<!--
<p v-if="isColumn1ValuesEqual">存在与当前调价版本不一致的产品,请选择调价日期批量刷新</p>
-->
<el-table v-loading="selectedResultLoading" width="100%;" :height="tableHeight" :cell-style="cellStyle" :row-class-name="selectedResultIndex" style="margin-top:5px" ref="selectedResultTable" :data="selectedResultData">
<el-table-column label="" align="center" prop="index" width="50"/>
<el-table-column label="操作" align="center" width="60" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="text" @click="handleDeleteClick(scope.$index)">删除</el-button>
</template>
</el-table-column>
<el-table-column label="版本uid" align="center" prop="uid_0" v-if="false"/>
<el-table-column label="产品型号" align="center" prop="name_0" width="200"/>
<el-table-column label="型号" align="center" prop="name_1" v-if="false"/>
<el-table-column label="规格" align="center" prop="spec" v-if="false"/>
<el-table-column label="电压" align="center" prop="voltage"/>
<el-table-column label="红本价(元)" align="center" prop="price"/>
<el-table-column label="单位" align="center" prop="stu" />
<!--<el-table-column label="单位" align="center" prop="stu">
<template slot-scope="scope">
<el-select v-model="scope.row.stu" @change="selectTypeChange(scope.row)">
<el-option label="KM" value="KM"/>
<el-option label="M" value="M"/>
<el-option label="只" value="只"/>
</el-select>
</template>
</el-table-column>-->
<el-table-column label="一次折扣" align="center" prop="per">
<template slot-scope="scope">
<el-input v-model="scope.row.per" @blur="changeRowData" @keyup.enter.native="changeRowData"/>
</template>
</el-table-column>
<el-table-column label="二次折扣" align="center" prop="per2">
<template slot-scope="scope">
<el-input v-model="scope.row.per2" @blur="changeRowData" @keyup.enter.native="changeRowData"/>
</template>
</el-table-column>
<el-table-column label="单价" align="center" prop="setPrice"/>
<el-table-column label="数量调整" align="center" prop="count">
<template slot-scope="scope">
<el-input v-model="scope.row.count" @blur="changeRowData" @keyup.enter.native="changeRowData"/>
</template>
</el-table-column>
<el-table-column label="总价" align="center" prop="allPrice"/>
</el-table>
<!--<pagination
v-show="selectedResultTotal>0"
:total="selectedResultTotal"
:page.sync="selectedResultCurrentPage"
:page-sizes="[10,20,30,40]"
:limit.sync="selectedResultPageSize"
@size-change="handleSelectedResultSizeChange"
@current-change="handleSelectedResultCurrentChange"
/>-->
</el-card>
</pane>
</splitpanes>
</el-form>
<!-- 产品导入对话框 -->
<el-dialog :title="productUpload.title" :visible.sync="productUpload.open" width="400px" append-to-body>
<el-upload
ref="productUpload"
:limit="1"
accept=".xlsx, .xls"
:headers="productUpload.headers"
:action="productUpload.url"
:disabled="productUpload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:data="{'rbUid':this.form.rbDateUid}"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<span>仅允许导入xls、xlsx格式文件。</span>
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
</div>
</el-upload>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="productUpload.open = false"> </el-button>
</div>
</el-dialog>
</div>
</template>
<style>
/* 修改边框样式 */
.customer-form-item .el-form-item__content {
border: 1px solid #46a6ff63; /* 更改为蓝色边框 */
border-radius: 4px; /* 圆角 */
padding: 5px; /* 内边距 */
}
/* 设置间距 */
.block {
margin-left: 20px;
display: inline-block;
}
/* 设置行距 */
.el-form-item--medium .el-form-item__content {
line-height: 25px;
}
/*卡片内容滚动条设置*/
.scrollable::-webkit-scrollbar {
display: none; /* 对于Webkit浏览器 */
}
/*备注内容设置*/
.text-content .text-preview {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
/* 控制显示的行数 */
}
/*总价输入框设置*/
.totalPrice-input .el-input__inner {
color: red;
}
</style>
<script>
import {toDecimal, productList,versionList,getQuotDetail,productRemarkList,productXinghList,judgeparent,productZlList,productYsxhListCheck,productYsxhList,productJmListCheck,productJmList,searchData,handleSearchData,saveQuot, madeQuot, madeXjQuot, updateSelectedResultData} from "@/api/redBook/redBook";
import { getToken } from "@/utils/auth";
export default {
name: "productSelect",
data() {
return {
//内容高度
scrollableHeight:null,
//已选结果表格高度
tableHeight:null,
//备注内容设置
expandedIndex: -1, // 默认没有展开的文本,设置为-1
id: 1,
//查询参数
queryParams: {},
//选中的目录tag
selectedModelTag:"",
selectedModelUid:"",
//选中的型号tag
selectedXinghTag:"",
selectedXinghUid:"",
//选中的子类tag
selectedZlTag:"",
selectedZlUid:"",
//选中的衍生型号tag
selectedYsxhTag:"",
selectedYsxhUid:"",
//选中的截面tag
selectedJmTag:"",
//目录
modelList: [],
//备注信息
showRemarkList: false,
remarkList: [],
//型号
showXinghList: false,
xinghList: [],
//子类
showZlList: false,
ZlList: [],
//衍生型号
showYsxhList: false,
ysxhList: [],
//截面
showJmList: false,
jmList: [],
/**==============查询结果========================= */
// 遮罩层
searchResultLoading: false,
// 查询结果数据
searchResultTotal: 0,
searchResultCurrentPage: 1,
searchResultPageSize: 10,
searchResultData: [],
errSlIndex: [],//保存/导出时校验数量格式,错误索引
errPercIndex: [],//保存/导出时校验一次折扣格式,错误索引
errPerc2Index: [],//保存/导出时校验二次折扣格式,错误索引
/**==============已选择结果========================= */
selectedResultLoading: false,
//已选择的数据
selectedResultTotal: 0,
selectedResultCurrentPage: 1,
selectedResultPageSize: 10,
selectedResultData: [],
// 产品表格数据导入参数
productUpload: {
// 是否显示弹出层(用户导入)
open: false,
// 弹出层标题(用户导入)
title: "",
// 是否禁用上传
isUploading: false,
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: process.env.VUE_APP_BASE_API + "/redBook/redBook/importData2"
},
//折扣率 初始值
perc: 0.8,
perc2: '',
//表单
form: {totalPrice: ''},
//调价日期
versionList: [], // 调价版本数据列表
madeQuotDis: false, // 选择调价版本时禁用
hasNotMatch: true // 所选结果数据中存在与当前所选调价版本不一致的数据
}
},
created() {
this.productList();
this.getVersionList();
const param = this.$route.query;
if (param.quotId !== undefined && param.quotId !== null) {
const row = {'quotId':param.quotId}
this.handleQuotInfo(row);
}
},
mounted(){
/*设置内容高度*/
this.scrollableHeight = (window.innerHeight - 160) + 'px';
/*设置已选择结果表格高度*/
this.tableHeight = (window.innerHeight - 340) + 'px';
},
methods: {
/** 查看报价单转报价操作 */
handleQuotInfo(row) {
const quotId = row.quotId;
getQuotDetail(quotId).then(response => {
this.form = response.data;
this.selectedResultData = response.data.selectedResultData;
console.log(this.selectedResultData)
})
},
//备注内容设置 展开 || 收起文本
toggleText(id) {
if (this.expandedIndex === id) {
this.expandedIndex = -1;
} else {
this.expandedIndex = id;
}
},
//目录选择
selModelTag(item) {
this.expandedIndex = -1;//备注内容收起
this.showRemarkList = false,//备注内容清空隐藏
this.remarkList = [],
this.selectedXinghTag = '';//清空选中的型号
this.showXinghList = false,
this.xinghList = [],
this.selectedZlTag = '';//清空选中的子类
this.showZlList = false,
this.ZlList = [],
this.selectedYsxhTag = '';//清空选中的衍生型号
this.showYsxhList = false,
this.ysxhList = [],
this.selectedJmTag = '';//清空选中的截面
this.showJmList = false,
this.jmList = [],
this.searchResultCurrentPage = 1,//清空结果列表数据
this.searchResultPageSize = 10,
this.searchResultData = [],
this.selectedModelTag = item.name_0;//设置选中的目录
//显示备注信息
this.productRemarkList(item.uid_0)
//显示型号信息
this.productXinghList(item.uid_0)
},
//获取目录
productList() {
productList().then(response => {
this.modelList = response;
});
},
//获取备注信息
productRemarkList(sid) {
this.params = {uid_0: sid}
productRemarkList(this.params).then(response => {
this.remarkList = response;
this.showRemarkList = this.remarkList.length > 0 ? true : false
});
},
//获取型号
productXinghList(sid) {
this.params = {uid_0: sid}
productXinghList(this.params).then(response => {
this.xinghList = response;
this.showXinghList = this.xinghList.length > 0 ? true : false
});
},
//型号选择
selXinghTag(item) {
this.selectedZlTag = '';//清空选中的子类
this.showZlList = false,
this.ZlList = [],
this.selectedYsxhTag = '';//清空选中的衍生型号
this.showYsxhList = false,
this.ysxhList = [],
this.selectedJmTag = '';//清空选中的截面
this.showJmList = false,
this.jmList = [],
this.searchResultCurrentPage = 1,//清空结果列表数据
this.searchResultPageSize = 10,
this.searchResultData = [],
this.selectedXinghUid = item.uid_0 //设置选中的型号uid
this.selectedXinghTag = item.name_0;//设置选中的型号名称
//判断是否为父节点,如果有说明下面还有子类显示,如果没有则直接显示衍生型号
this.judgeparent(item)
},
//判断是否为父节点,如果有说明下面还有子类显示,如果没有则直接显示衍生型号
judgeparent(item) {
this.params = {uid_0: item.uid_0}
judgeparent(this.params).then(response => {
if (response) {//存在子类
this.productZlList(item.uid_0)
} else {//不存在子类,则继续判断是否存在衍生型号
this.productYsxhListCheck(item.uid_0, item.name_0)
}
});
},
//获取子类
productZlList(sid) {
this.params = {uid_0: sid}
productZlList(this.params).then(response => {
this.zlList = response;
this.showZlList = this.zlList.length > 0 ? true : false
});
},
//判断是否存在衍生型号
productYsxhListCheck(sid, name) {
this.params = {uid_0: sid}
productYsxhListCheck(this.params).then(response => {
if (response) {//存在衍生型号
this.productYsxhList(sid, name)
} else {
this.selectedYsxhUid = sid;
this.selectedYsxhTag = name;
//检查是否存在截面
this.productJmListCheck(sid, name)
}
});
},
//获取衍生型号
productYsxhList(sid, name) {
this.params = {uid_0: sid, name_0: name}
productYsxhList(this.params).then(response => {
this.ysxhList = response;
this.showYsxhList = this.ysxhList.length > 0 ? true : false
});
},
//子类选择
selZlTag(item) {
this.selectedYsxhTag = '';//清空选中的衍生型号
this.showYsxhList = false,
this.ysxhList = [],
this.selectedJmTag = '';//清空选中的截面
this.showJmList = false,
this.jmList = [],
this.searchResultCurrentPage = 1,//清空结果列表数据
this.searchResultPageSize = 10,
this.searchResultData = [],
this.selectedZlTag = item.name_0;
this.productYsxhListCheck(item.uid_0, item.name_0)
},
//衍生型号选择
selYsxhTag(item) {
this.selectedJmTag = '';//清空选中的截面
this.selectedYsxhUid = item.uid_0;
this.showJmList = false,
this.jmList = [],
this.searchResultCurrentPage = 1,//清空结果列表数据
this.searchResultPageSize = 10,
this.searchResultData = [],
this.selectedYsxhTag = item.name_0;
this.productJmListCheck(item.uid_0, item.name_0)
},
//判断是否存在截面
productJmListCheck(sid, name) {
this.params = {uid_0: sid}
productJmListCheck(this.params).then(response => {
if (response) {//存在截面
this.productJmList(sid, name)
} else {
this.selectedYsxhTag = this.selectedXinghTag;
this.searchData(this.selectedXinghUid)
}
});
},
//获取截面
productJmList(sid, name) {
this.params = {uid_0: sid, name_0: name}
productJmList(this.params).then(response => {
this.jmList = response;
this.showJmList = this.jmList.length > 0 ? true : false
});
},
//截面选择
selJmTag(item) {
this.selectedJmTag = item.section;
this.searchResultCurrentPage = 1,//清空结果列表数据
this.searchResultPageSize = 10,
this.searchResultData = [],
this.searchResultLoading = true;
this.searchData(this.selectedYsxhUid, item.section)
},
//查询结果数据
searchData(sid, section) {
this.params = {uid_0: sid, section: section, name_0: this.selectedYsxhTag}
searchData(this.params).then(response => {
this.searchResultData = response;
this.searchResultTotal = this.searchResultData.length;
this.searchResultCurrentPage = 1;
this.searchResultLoading = false;
});
},
//双击查询结果事件
handleRowDblclick(row, event, column) {
const uid_0 = row.uid_0;
const name_0 = row.name_0;
const model = row.model;
const spec = row.spec;
const voltage = row.voltage;
const price = row.price;
const stu = row.stu;
const per = this.perc;
const per2 = this.perc2;
const count = '1';
const setPrice = toDecimal(price * (per?per:1) * (per2?per2:1));
const allPrice = toDecimal(count * price * (per?per:1) * (per2?per2:1));
const rowDate = {
uid_0: uid_0.toString(),
name_0: name_0,
name_1: model,
spec: spec,
voltage: voltage,
price: price,
stu: stu,
per: per,
per2: per2,
setPrice: setPrice,
count: count,
allPrice: allPrice
}
this.selectedResultData.push(rowDate)
//自动跳转当前页
/*this.selectedResultTotal = this.selectedResultData.length;
const page = Math.ceil(this.selectedResultTotal / this.selectedResultPageSize);
this.handleSelectedResultCurrentChange(page)*/
this.$nextTick(() => {
this.$refs.selectedResultTable.bodyWrapper.scrollTop = this.$refs.selectedResultTable.bodyWrapper.scrollHeight;
})
},
/** 已选结果数据序号 */
selectedResultIndex({ row, rowIndex }) {
row.index = rowIndex + 1;
},
/** 已选结果数据里存在所选调价版本不一致的数据 */
cellStyle({ row, columnIndex }){
if(row.uid_0 != this.form.rbDateUid){
return {'background-color':'#ff494959'}
}
if(!row.stu && (columnIndex == 2 || columnIndex == 3)){
return 'color:red'
}
},
//删除已选结果数据
handleDeleteClick(index) {
this.selectedResultData.splice(index, 1)
this.selectedResultTotal = this.selectedResultData.length;
},
/** 切换每页显示条数--查询结果 */
handleSearchResultSizeChange(val) {
this.searchResultPageSize = val;
this.searchResultCurrentPage = 1;
},
/** 页码选择--查询结果 */
handleSearchResultCurrentChange(val) {
this.searchResultCurrentPage = val;
},
/** 切换每页显示条数--已选择结果 */
/*handleSelectedResultSizeChange(val) {
this.selectedResultPageSize = val;
this.selectedResultCurrentPage = 1;
},*/
/** 页码选择--已选择结果 */
/*handleSelectedResultCurrentChange(val) {
this.selectedResultCurrentPage = val;
},*/
//手动查询产品
handleSearchClick() {
if (this.queryParams.name_0 || this.queryParams.model) {
this.searchResultCurrentPage = 1,
this.searchResultPageSize = 10,
this.searchResultData = [],
this.searchResultLoading = true;
handleSearchData(this.queryParams).then(response => {
this.searchResultData = response;
this.searchResultTotal = this.searchResultData.length;
this.searchResultCurrentPage = 1;
this.searchResultLoading = false;
});
} else {
this.$message.warning("请输入查询条件!");
return;
}
},
//一次折扣率变化时触发
changeData() {
// 校验折扣率格式
const pattern = /^\d+(\.\d+)?$/;
if(this.perc) {
if (!pattern.test(this.perc)) {
this.$message.warning("折扣率格式错误!");
return;
}
}
if(this.perc2) {
if (!pattern.test(this.perc2)) {
this.$message.warning("折扣率格式错误!");
return;
}
}
// 遍历表格数据进行计算
this.selectedResultData.forEach((row, index) => {
// 进行其他计算
this.$set(this.selectedResultData, index, {
...row,
per: this.perc,
per2: this.perc2,
setPrice: toDecimal(row.price * (this.perc?this.perc:1) * (this.perc2?this.perc2:1)),
allPrice: toDecimal(row.count * row.price * (this.perc?this.perc:1) * (this.perc2?this.perc2:1)),
});
})
},
// 行内数据监听
changeRowData() {
// 遍历表格数据进行计算
this.selectedResultData.forEach((row, index) => {
// 进行其他计算
this.$set(this.selectedResultData, index, {
...row,
setPrice: toDecimal(row.price * (row.per?row.per:1) * (row.per2?row.per2:1)),
allPrice: toDecimal(row.count * row.price * (row.per?row.per:1) * (row.per2?row.per2:1)),
});
})
},
// 刷新
handleRefreshClick() {
this.form.quotCustomer = '';
this.form.quotProject = '';
this.form.quotLxr = '';
this.form.quotLxrdh = '';
this.perc = '0.8';
this.perc2 = '';
this.form.rbDateUid = this.versionList[0].value
this.selectedResultData = [];
//this.resetForm("form");
},
// 报价单保存修改
handleSaveClick() {
let flag = this.checkSlZk();
if(flag){
if(!this.isColumn1ValuesEqual){
this.$modal.msgError("存在与当前调价版本不一致的产品,请选择调价日期批量刷新");
return;
}
const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0);
this.form.totalPrice = toDecimal(allPrice);
this.form.selectedResultData = this.selectedResultData;
saveQuot(this.form).then(response => {
if(this.form.quot_id){
this.$modal.msgSuccess("修改报价单成功,单号:"+response.data.quotCode);
}else{
this.$modal.msgSuccess("保存报价单成功,单号:"+response.data.quotCode);
}
})
}
},
// 报价单生成
handleMadeQuotClick() {
let flag = this.checkSlZk();
if(flag){
if(!this.isColumn1ValuesEqual){
this.$modal.msgError("存在与当前调价版本不一致的产品,请选择调价日期批量刷新");
return;
}
this.form.selectedResultData = this.selectedResultData;
madeQuot(this.form).then(response => {
this.$modal.msgSuccess("生成报价单成功");
// 处理返回的文件流
const content = response;
const blob = new Blob([content]);
const fileName = "RB_BJD_"+this.getTodayCourse()+".xls";
if ("download" in document.createElement("a")) {
// 非IE下载
const elink = document.createElement("a");
elink.download = fileName;
elink.style.display = "none";
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href); // 释放URL 对象
document.body.removeChild(elink);
}else {
// IE10+下载
navigator.msSaveBlob(blob, fileName);
}
});
}
},
// 生成询价单
handleMadeXjQuotClick() {
let flag = this.checkSlZk();
if(flag){
this.madeQuotDis = true;
this.form.selectedResultData = this.selectedResultData;
madeXjQuot(this.form).then(response => {
this.$modal.msgSuccess("生成询价单成功,单号:"+response.data.quotCode);
this.madeQuotDis = false;
});
}
},
/** 产品数据导入按钮操作 */
handleImport() {
this.productUpload.title = "产品数据导入";
this.productUpload.open = true;
},
/** 下载模板操作 */
importTemplate() {
this.download('redBook/redBook/importTemplate2', {
}, `product_template_${new Date().getTime()}.xlsx`)
},
// 文件上传中处理
handleFileUploadProgress(event, file, fileList) {
this.productUpload.isUploading = true;
this.madeQuotDis = true;
this.selectedResultLoading = true;
},
// 文件上传成功处理
handleFileSuccess(response, file, fileList) {
if(response.code == 200){
this.$message.success("产品数据导入成功!");
this.selectedResultData = this.selectedResultData.concat(response.data)
this.changeData();
}else{
this.$message.error(response.msg);
}
this.$refs.productUpload.clearFiles();
this.productUpload.open = false;
this.productUpload.isUploading = false;
this.madeQuotDis = false;
this.selectedResultLoading = false;
},
// 提交上传文件
submitFileForm() {
this.$refs.productUpload.submit();
},
// 导出明细
handleExport(){
let flag = this.checkSlZk();
if(flag){
const fileName = "RB_BJD_"+this.getTodayCourse();
this.download('redBook/redBook/exportProduct', {
selectedResultData: JSON.stringify(this.selectedResultData)
}, fileName +".xlsx")
}
},
//获取调价日期
getVersionList(){
versionList(this.queryParams).then(response => {
this.versionList = response.versionList;
this.form.rbDateUid = this.versionList[0].value
});
},
//选择调价日期
async selectRbDate(uid) {
this.selectedResultData.forEach((row, index) => {
this.$set(this.selectedResultData, index, {
...row,
uid_0: uid // 重新设置为所选版本uid
});
});
this.madeQuotDis = true;
this.selectedResultLoading = true;
//更新已选结果数据-单价、金额
updateSelectedResultData(this.selectedResultData).then(response => {
for (let i = 0; i < this.selectedResultData.length; i++) {
for (let j = 0; j < response.data.length; j++) {
// 检查型号、规格、电压等级是否相等
if (
this.selectedResultData[i].name_0 === response.data[j].name_0
) {
this.selectedResultData[i].price = response.data[j].price;
const setPrice = toDecimal(this.selectedResultData[i].price * (this.selectedResultData[i].per?this.selectedResultData[i].per:1) * (this.selectedResultData[i].per2?this.selectedResultData[i].per2:1));
const allPrice = toDecimal(this.selectedResultData[i].count * this.selectedResultData[i].price * (this.selectedResultData[i].per?this.selectedResultData[i].per:1) * (this.selectedResultData[i].per2?this.selectedResultData[i].per2:1));
this.selectedResultData[i].setPrice = setPrice;
this.selectedResultData[i].allPrice = allPrice;
}
}
}
this.madeQuotDis = false;
this.selectedResultLoading = false;
});
},
// 获取当前时间
getTodayCourse(){
const myDate = new Date();
//获取当前年
const year = myDate.getFullYear();
//获取当前月
const month = myDate.getMonth() + 1;
//获取当前日
const date = myDate.getDate();
const h = myDate.getHours(); //获取当前小时数(0-23)
const m = myDate.getMinutes(); //获取当前分钟数(0-59)
const s = myDate.getSeconds();
return year + '-' + this.p(month) + "-" + this.p(date) + " " + this.p(h) + ':' + this.p(m) + ":" + this.p(s)
},
p(s) {
return s < 10 ? '0' + s : s;
},
// 校验明细行中-数量、一次折扣、二次折扣格式
checkSlZk(){
let flag = true;
this.errSlIndex = [];
this.errPercIndex = [];
this.errPerc2Index = [];
let errMsg = "";
const label = /^(\+)?\d+(\.\d+)?$/;
let reg = new RegExp(label);
this.selectedResultData.forEach((row, index) => {
//数量
let sl = row.count;
sl = String(sl).trim();
if(sl){
if (!reg.test(sl)) {
this.errSlIndex.push(index+1);
}
}
//一次折扣
let perc = row.per;
perc = String(perc).trim();
if(perc){
if (!reg.test(perc)) {
this.errPercIndex.push(index+1);
}
}
//二次折扣
let perc2 = row.per2;
perc2 = String(perc2).trim();
if(perc2){
if (!reg.test(perc2)) {
this.errPerc2Index.push(index+1);
}
}
});
if(this.errPercIndex.length!=0){
flag = false;
errMsg = "第"+this.errPercIndex.join(",")+"行报价产品明细【一次折扣】格式错误";
this.$modal.msgError(errMsg);
return flag;
}
if(this.errPerc2Index.length!=0){
flag = false;
errMsg = "第"+this.errPerc2Index.join(",")+"行报价产品明细【二次折扣】格式错误";
this.$modal.msgError(errMsg);
return flag;
}
if(this.errSlIndex.length!=0){
flag = false;
errMsg = "第"+this.errSlIndex.join(",")+"行报价产品明细【数量调整】格式错误";
this.$modal.msgError(errMsg);
return flag;
}
return flag;
}
},
updated(){
// 监听数据变化时,滚动条保持在底部
let div = document.getElementById("scroll")
div.scrollTop = div.scrollHeight
},
computed: {
// 计算出当前页的查询结果数据列表
searchResultPagedData() {
const startIndex = (this.searchResultCurrentPage - 1) * this.searchResultPageSize;
const endIndex = startIndex + this.searchResultPageSize;
return this.searchResultData.slice(startIndex, endIndex);
},
// 计算出当前页的已选择结果数据列表
/*selectedResultPagedData() {
console.log(this.selectedResultData)
const startIndex = (this.selectedResultCurrentPage - 1) * this.selectedResultPageSize;
const endIndex = startIndex + this.selectedResultPageSize;
return this.selectedResultData.slice(startIndex, endIndex);
},*/
// 判断已选数据是否调价版本一致
isColumn1ValuesEqual() {
if(this.selectedResultData.length > 0){
const uid_0 = this.selectedResultData[0].uid_0;//版本uid
console.log(this.selectedResultData)
return this.selectedResultData.every(row => row.uid_0 === uid_0);
}else{
return false;
}
},
// 已选择结果数据汇总
sumSelectedResultData() {
const allPrice = this.selectedResultData.reduce((sum, row) => sum + parseFloat(row.allPrice), 0);
return toDecimal(allPrice);
},
},
}
</script>
<style scoped>
</style>