<template>

    <div class="srm-page srm-form">
<el-row :gutter="24">
<el-form ref="form" :model="rtBuzPriProject" label-width="100px" size="mini">
<el-col :span="8">
<el-form-item prop="project_code" label="项目编码:">
<span>{{upDateLoad.project_code}}</span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="project_code" label="项目名称:" >
<span>{{upDateLoad.project_name}}</span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="project_code" label="采购组织:" >
<span>{{upDateLoad.dept_name}}</span>
</el-form-item>
</el-col> <el-col :span="8">
<el-form-item prop="add_user" label="发布人:">
<span>{{upDateLoad.user_name}}</span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="add_user" label="发布日期:">
<span>{{upDateLoad.apply_end_date}}</span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="add_user" label="销售结算价:">
<span>{{upDateLoad.sale_balance_price}}</span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="add_user" label="降幅比例标准(%):">
<span>{{upDateLoad.scale_standard}}</span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="add_user" label="报价截止时间:" >
<span>{{upDateLoad.award_price_valid_end_time}}</span>
</el-form-item> </el-col>
<el-col :span="8">
<el-form-item prop="add_user" label="提交比价时间:">
<span>{{upDateLoad.award_price_valid_start_time}}</span>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item prop="add_user" label="实际降幅比例(%):">
<span>{{upDateLoad.sjjfbl}}</span>
</el-form-item>
</el-col>
</el-form>
</el-row>
<el-row v-if="!readOnly" >
<el-col :span="4" style="padding-top: 15px;border: 0;">
<h3>比价分析表</h3>
</el-col>
<el-col :span="20" class="tr" style="border: 0;">
<!-- <el-button type="success" size="mini" @click="uniqueDataFun()">demo</el-button>-->
<el-button type="success" size="mini" v-show="isShow" @click="setQuota()">配额设置</el-button>
<el-button type="warning" size="mini" v-show="!isShow" @click="cancelQuota()">取消</el-button>
<el-upload action :show-file-list="false" :http-request="uoloadTempelate"
style="display: inline-block;">
<el-button size="mini" type="primary">导入比价分析</el-button>
</el-upload>
<el-button type="primary" size="mini" @click="exportData">导出比价分析</el-button>
<el-button type="danger" v-show="$utils.obj.havePermission(indexUrl + '/update')" size="mini"
@click='js_closeMater'>关闭物料
</el-button>
</el-col>
</el-row> <i-table
@on-selection-change="selectChange"
ref="iTable"
style="margin-top: 10px"
:row-class-name="rowClassName"
:stripe="true"
size="small"
:border="true"
:loading="loading"
:columns="columns"
:data="tableData1.slice((currentPage-1)*pageSize,currentPage*pageSize)"
:show-summary="showSmallSum"
:summary-method="handleSummary"
>
</i-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="currentPage"
:page-sizes="[15, 30, 50, 100]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="currentTotal">
>
</el-pagination>
<el-row class="srm-border" style="text-align: right">
<el-button v-show="$utils.obj.havePermission('/buz/rtBuzSupQuote/update1')==true && buzStatus" v-if="!readOnly" type="primary"
size="mini" @click="js_save">
保存
</el-button>
<el-button @click="$emit('closeParentDialog')" size="mini">
返回
</el-button>
</el-row>
<add-part
:pid="pid"
ref="add"
@closeDialog="closeDialog"
v-if="addVisible"
:selects="selects"
:url="indexUrl"
:indexName="indexName">
</add-part>
</div>
</template> <script>
import tableMixin from '@/mixin/tableMixin';
import addPart from './inviteProduct/add';
export default {
mixins: [tableMixin],
name: "rtBuzSupQuote",
arr: '',
props: {
pid: {},
pri_project_id: {},
buz_status:{},
readOnly: {
type: Boolean,
default: false
}
},
components: {addPart},
data() {
return {
pageSize:15,
currentPage: 1,
currentTotal: 0,
historyData: [],
ajaxHistoryData:[],
isShow: true,
upDateLoad: {},
inputVal: '',
buzStatus: this.buz_status==22?true:false,
params: {
pri_project_id: this.pid
},
requestList: ['rtBuzPriProject'],
fileList: [],
rtBuzPriProject: {},
columns: [],
indexName: 'rtBuzSupQuotes',
indexUrl: '/buz/rtBuzSupQuote/',
upLoadUrl: '/buz/rtBuzPriProject/updateLoad',
colseParams: [],
totalData: [],
seletedData: [],
uniqueData: [],
savedData: [],
materialUnique: [],
suplierNameArr: [],
lastData: [],
tableData1: [],
showSmallSum:true,
showSum:false,
totalRow: 0,
strVal: '',
hide: 'hide'
}
},
mounted() {
this.upDateLoadFun();
},
methods: {
handleListApproveHistory(){
// 保存取到的所有数据
this.tableData1 = this.lastData;
this.currentTotal = this.tableData1.length;
// 初始化显示,小于每页显示条数,全显,大于每页显示条数,取前每页条数显示
if(this.currentTotal < this.pageSize){
this.showSum = true;
}else{
this.showSum = false;
}
},
handleSizeChange(val) {
this.pageSize = val;
if(val * this.pageSize>= this.lastData.length){
this.showSum = true;
}else{
this.showSum = false;
}
},
handleCurrentChange(val) {
this.currentPage = val;
if(val * this.pageSize>= this.lastData.length){
this.showSum = true;
}else{
this.showSum = false;
}
}, getDataList() {
this.loading = true;
this.$http({
method: 'post',
url: this.indexUrl,
data: {
params: this.params,
pageSize: this.pageSize,
pageNumber: this.pageNumber,
sum_data: true
}
}).then((response) => {
let uniqueData = JSON.parse(JSON.stringify(response.data.data.rtBuzSupQuotes))
this.totalData = JSON.parse(JSON.stringify(response.data.data.rtBuzSupQuotes))
let suppliers = this.suplierNameArr = this.uniqueSupplier(this.totalData, 'supplier_name');
let materialUnique = this.unique(uniqueData, 'pri_bid_id');
this.lastData = this.mergeData(this.totalData, materialUnique, suppliers);
this.afterGetDataListDemo();
this.handleListApproveHistory();
}).finally(() => {
this.loading = false
})
},
// 获取唯一的供应商
uniqueSupplier(arr, name) {
let backArr = new Set()
arr.forEach((item) => {
backArr.add(item[name])
})
return [...backArr]
},
//去掉指定元素
uniquespecifiedElm(arr, delArr) {
arr.forEach((item, index) => {
for (let key in item) {
if (item.hasOwnProperty(key)) { //判断是否是对象自身的属性,而不包含继承自原型链上的属性
if (delArr.indexOf(key) != -1) {
delete arr[index][key];
}
}
}
}); }, //放入供应商合并数据;
mergeData(totalArr, afterData, suppliers) { //totalArr总数据,afterData去除重复材料后并且去除不要字段的数据;
afterData.forEach((item, index) => {
totalArr.forEach((j) => {
if (item.pri_bid_id === j.pri_bid_id) {
let pos = suppliers.indexOf(j.supplier_name);
if (pos != '-1') {
afterData[index]['first_price' + pos] = j.first_price;
afterData[index]['last_price' + pos] = j.last_price;
afterData[index]['award_percent' + pos] = j.award_percent?j.award_percent:0; //修改一次,乘以100;
afterData[index]['promit_delivery_date' + pos] = j.promit_delivery_date; //修改一次,乘以100;
}
}
});
});
return afterData;
}, handleSummary({columns}) {
const sums = {};
let show = this.showSum;
columns.forEach((column, index) => {
const key = column.key;
if (index === 1) {
if(show){
sums[key] = {
key,
value: '全部总报价'
};
}else{
sums[key] = {
key,
value: '当前页小计'
};
} return;
}
let _start = ( this.currentPage - 1 ) * this.pageSize;
let _end = this.currentPage * this.pageSize;
let slicetableData = JSON.parse(JSON.stringify(this.lastData)).slice(_start,_end);
let values ='';
if(show){
values = this.lastData.map(item => Number(item[key]*item.qty_probid));
}else{
values = slicetableData.map(item => Number(item[key]*item.qty_probid)); } if (!values.every(value => isNaN(value))) {
const v = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
let colArr = [];
for (let i = 7; i < 100; i += 4) {
colArr.push(i, i + 1);
}
if (colArr.indexOf(index) != -1) {
sums[key] = {
key,
value: v + ''
};
} else {
sums[key] = {
key,
value: ''
};
}
} else {
sums[key] = {
key,
value: ''
};
}
});
return sums;
}, paramInit() {
},
init(row) {
this.row = row || {};
this.pid = row ? row.id : '',
this.pri_project_id = row ? row.id : '',
this.visible = true;
},
upDateLoadFun() {
this.loading = true;
this.$http({
method: 'post',
url: this.upLoadUrl,
data: {
id: this.pid,
}
}).then((response) => {
this.upDateLoad = response.data.data.rtBuzPriProject;
}).finally(() => {
this.loading = false;
})
},
afterGetDataListDemo() {
let columns_add = [
{type: 'selection', width: 60, align: 'center', 'title': ''},
{key: 'add_org', 'title': '采购组织', width: 100},
{key: 'material_code', 'title': '物料', width: 100},
{key: 'material_name', 'title': '物料名称', width: 100},
{key: 'material_desc', 'title': '物料描述', width: 200},
{key: 'qty_probid', 'title': '预计采购数量', width: 100},
{key: 'previous_price', 'title': '上期最低报价/元', width: 150, 'align': 'center'},
];
let preBididArr=[];
this.lastData.forEach((item) => {
preBididArr.push(item.pri_bid_id);
this.suplierNameArr.forEach((m, indexSec) => {
// if (m) {
columns_add.push({
resizable: true,
title: m,
align: 'center',
key: m,
children: [{
title: '初次报价',
width: 100,
key: 'first_price' + indexSec,
}, {
title: '最终报价',
width: 100,
key: 'last_price' + indexSec,
}, {
title: '回复交期',
width: 120,
key: 'promit_delivery_date' + indexSec,
},
{
title: '配额',
width: 150,
key: 'award_percent' + indexSec,
render: (h, params) => {
if (params.row) {
let posIndex = preBididArr.indexOf(params.row.pri_bid_id);
return h('div', [
h('Input', {
domProps: {
type: 'number',
step: "1",
value: this.lastData[posIndex]['award_percent' + indexSec]?this.lastData[posIndex]['award_percent' + indexSec]:0,
min: "0",
max: "100",
},
class: this.hide,
on: {
"blur":(value)=>{
if(value.srcElement.value==''){
value.srcElement.value= 0;
this.lastData[posIndex]['award_percent' + indexSec] = 0;
}else{
this.lastData[posIndex]['award_percent' + indexSec] = value.srcElement.value;
}
}, },
},
),
h('div', this.lastData[posIndex]['award_percent' + indexSec])
]);
} else {
return h('div', '-');
} }
}]
});
//}
}); }); columns_add = this.unique(columns_add, 'title');
this.columns = columns_add;
},
getIndex(arr, str) {
let num = -1;
for (let i = 0; i < arr.length; i++) {
if (arr[i] === str) {
num = i
}
}
return num
},
//求和
sum(arr) {
return eval(arr.join("+"));
},
setQuota() {
this.isShow = !this.isShow;
this.hide = '';
},
cancelQuota() {
this.isShow = !this.isShow;
this.hide = 'hide';
}, //去重代码1
unique(arr, par) {
const res = new Map();
return arr.filter((arr) => !res.has(arr[par]) && res.set(arr[par], 1));
}, //导出
exportData() {
this.$refs.iTable.exportCsv({filename: "Data"});
},
//导入
uoloadTempelate(e) {
let file = e.file;
let formData = new FormData();
formData.append("file", file); // 'file' 可变 相当于 input 表单的name 属性
formData.append("name", file.name);
formData.append("type", file.type);
formData.append("size", file.size);
formData.append("lastModifiedDate", file.lastModifiedDate);
this.$http({
method: "post",
url: "/base/ctBaseFile/saveFile50",
data: formData
}).then(response => {
if (response.data.code === 200) {
this.$http({
method: "post",
url: "/buz/rtBuzPriBid/saveBidFromImport",
data: {
file_id: response.data.data.ctBaseFile.id,
project_id: this.pid
}
}).then(response => {
if (response.data.code === 200) {
this.$message.success("上传成功");
this.getDataList();
}
});
}
});
},
//关闭物料
selectChange(row) {
this.seletedData = [];
if (row.length > 0) {
this.totalData.forEach((item) => {
if (row[0].pri_bid_id == item.pri_bid_id) {
this.colseParams.push({'id': item.id, 'buz_status': 2});
this.seletedData.push(item);
}
})
} },
//保存
js_save() {
let flag = 1;
this.lastData.forEach((item, index) => {
let awardArr = [];
delete this.lastData[index]['award_percent'];
for(let k in this.lastData[index]) {
if( k.indexOf('award_percent')> -1 ){
if(this.lastData[index][k]!=''){
awardArr.push(this.lastData[index][k]);
}else{
awardArr.push(0);
}
}
}
if( eval(awardArr.join("+"))>100){
flag+=1;
return false;
}else if( eval(awardArr.join("+"))<100){
flag+=1;
return false;
}
}); if(flag==1){
this.loading = true;
this.cancelQuota();
this.lastData.forEach((item) => {
let count = -1;
this.totalData.forEach((m,n) => {
if (item.pri_bid_id === m.pri_bid_id && item.supplier_name != null) {
count += 1;
this.totalData[n]['award_percent'] = Number(item['award_percent' + count]);
}
});
});
this.$http({
method: 'post',
url: '/buz/rtBuzSupQuote/update1',
data: {
rtBuzSupQuotes: this.totalData
}
}).then((response) => {
if (response.data.code === 200) {
this.$message.success('保存成功');
this.hide = 'hide';
//this.handleSizeChange(this.page);
}
}).finally(() => {
this.loading = false;
})
}else{
this.$message({
type: 'warning',
message: '配额总值必须等于100'
});
}
}, js_closeMater() {
this.loading = true;
this.$http({
method: 'post',
url: '/buz/rtBuzSupQuote/update/',
data: {rtBuzSupQuotes: this.colseParams},
}).then((response) => {
if (response.data.code == 200) {
alert('成功!');
}
}).finally(() => {
this.loading = false;
})
},
},
}
</script> <style scoped>
</style>

vue iView table中render渲染的更多相关文章

  1. iview table行render渲染不同的组件

    table不同的行,相同的列渲染不同的组件,如图1:第一行渲染selece,第二行渲染input render:(h,params)=>{ if(params.index === 0){ //以 ...

  2. Vue.js 2.x render 渲染函数 & JSX

    Vue.js 2.x render 渲染函数 & JSX Vue绝大多数情况下使用template创建 HTML.但是比如一些重复性比较高的场景,需要运用 JavaScript 的完全编程能力 ...

  3. iview table中的render函数使用

    1.表格列数据内容过多可以用以下两个属性解决: ellipsis:"true', tooltip:true 使每个列的内容如果过多的话变为省略号 2.table中的render函数(实现根据 ...

  4. VUE -- iview table 组件 中使用 upload组件 上传组件 on render 事件不会触发问题

    碰到的问题是: upload 组件在 on中写的监听事件不会被触发 在 props 中来监听:==>

  5. vue iview组件表格 render函数的使用

    如果要在标签中加入属性,例如img 中src属性 a标签中href属性 此时需要用到 attrs 来加入而不是props { title: '操作', key: 'action', align: 'c ...

  6. iview table的render()函数的用法

    语法:render:(h,params)=>{} render:(h,params) => { return h(" 定义的元素 ",{ 元素的性质 }," ...

  7. iview table的render()函数基本的用法

    render:(h,params) => { return h(" 定义的元素 ",{ 元素的性质 }," 元素的内容"/[元素的内容]) }

  8. iview table中使用Poptip

    h('Poptip', { props: { confirm: true, // 'ok-text':"yes", // 'cancel-text':"no", ...

  9. iview table 实现在数据中自定义标识

    做了一个商旅订票的项目,在详情中有一个因公超标在表格中用一个“超”字显示的需求.后台框架用的iview+vue,也就是在iview Table中改变.在iview的框架中改变东西首先要想到的是ivie ...

随机推荐

  1. LInux下编译发生的libc相关错误

    在某主机上编译程序,发生有找不到libc的问题,自己写了个简单的hello world程序,编译也失败,报错如下: # gcc -o 1 1.c /usr/bin/ld: skipping incom ...

  2. oralce 减少访问数据库的次数

    当执行每条SQL语句时, ORACLE在内部执行了许多工作: 解析SQL语句, 估算索引的利用率, 绑定变量 , 读数据块等等. 由此可见, 减少访问数据库的次数 , 就能实际上减少ORACLE的工作 ...

  3. [Pytorch]基于混和精度的模型加速

    这篇博客是在pytorch中基于apex使用混合精度加速的一个偏工程的描述,原理层面的解释并不是这篇博客的目的,不过在参考部分提供了非常有价值的资料,可以进一步研究. 一个关键原则:“仅仅在权重更新的 ...

  4. H3C ISDN网络构成

  5. SuperSocket命令和命令加载器

    关键字: 命令, 命令加载器, 多命令程序集 命令 (Command) SuperSocket 中的命令设计出来是为了处理来自客户端的请求的, 它在业务逻辑处理之中起到了很重要的作用. 命令类必须实现 ...

  6. 智课雅思词汇---九、mon是什么意思

    智课雅思词汇---九.mon是什么意思 一.总结 一句话总结:词根:mon(min) = to warn, to advise, to remind 1.mit是什么意思? 词根:-mitt-, -m ...

  7. POJ 1321 深搜dfs

    思路其实挺简单的,为什么我想不到呢!!! 原因分析:(1)题目还是做少了 (2)做题目的时候在放音乐 (3)最近脑袋都不愿意想思路总是想一些无用的 改进:(1)以后做题目坚决不开音乐,QQ直接挂隐身 ...

  8. [转]vue - 前置工作 - 目录功能介绍

    一个DEMOS的完整目录(由于GWF问题,我就不一一打开网站一个个去搜索并且解释了)可以去关注:https://www.cnblogs.com/ye-hcj build build.js(本文来自ht ...

  9. java Scanner(简单文本扫描器)

    Scanner(File source)  构造一个新的 Scanner,它生成的值是从指定文件扫描的. 备注:实现了Iterable接口   package june6D; import java. ...

  10. jquery ajax请求步骤

    $.ajax({ type: "GET", url: "/alink-hq/checkCode", data: { "mobile": ph ...