var Paymentcomponent = { template:`
搜索
新增付款 合计:{{row.total_p}} 已付:{{row.paid}} 应付:{{row.rp}}
取 消 确 定
取 消 确 定
`, data(){ // 获取当前屏幕的分辨率 let screenW = window.screen.width; let screenH = window.innerHeight; console.log("screen width:",screenW); console.log("screen height:",screenH); return { tHeight:screenH-40-232, tableData: [], currentPage: 1, pagesize:50, recordTotal:0, code_v:'', name_v:'', supplier_v:'', row:'', dialogVisible:false, oper_type:0, rules: { p_id: [ { required: true, message: '产品编号不可为空', trigger: 'blur' } ], p_name: [ { required: true, message: '产品名称不可为空', trigger: 'blur' } ], payment_month: [ { required: true, message: '月份不可为空', trigger: 'blur' } ], payment: [ { required: true, message: '支付金额不可为空', trigger: 'blur' } ], }, multipleSelection: [], importdialogVisible:false, fileListUpload:[], importTableData:[], disabled:true, if_show_process:false, percent_len:0, interval:'', if_show_process1:false, begin_t_v:'', end_t_v:'', //payment_data:'', addplanVisible_1:false, maxid:-1, planform: { id:0, payment_month:'', payment:'', payment_user:'', }, plan_op_type:0, } }, mounted() { this.get_payment() }, methods: { delKpiplan(row){ var index =-1; for(var i=0;i -1) { this.$data.row.payment_data.splice(index, 1); } var total =0 for(var i=0;itotal){ this.$data.row.rp = (t-total).toString(); } }, show_updateplan_dialog(row){ this.$data.planform.payment_month=row.payment_month; this.$data.planform.payment=row.payment; this.$data.planform.payment_user=row.payment_user; this.$data.planform.id =row.id; this.$data.plan_op_type=2; this.$nextTick(() => { this.$refs['planform_1'].clearValidate() }); this.$data.addplanVisible_1=true; }, addkpiplan_1(){ this.$refs['planform_1'].validate((valid) => { if (valid) { if (this.$data.plan_op_type==1) { var obj ={ id:this.$data.maxid, payment_month:this.$data.planform.payment_month, payment:this.$data.planform.payment.toString(), payment_user:this.$data.planform.payment_user, } this.$data.row.payment_data.push(obj); this.$data.maxid+=1; console.log("id:",this.$data.maxid); } else if (this.$data.plan_op_type==2){ for(var i=0;itotal){ this.$data.row.rp = (t-total).toString(); } this.$data.addplanVisible_1 = false; } }); }, showAddkpiplan_1(){ this.$data.planform.payment_month=''; this.$data.planform.payment=''; this.$data.planform.payment_user=''; this.$data.plan_op_type=1; for (var i = 0; i < this.$data.row.payment_data.length; i++) { if(this.$data.row.payment_data[i].id >this.$data.maxid){ this.$data.maxid = this.$data.row.payment_data[i].id } } if(this.$data.maxid !=-1){ this.$data.maxid+=1; }else{ this.$data.maxid = 0; } this.$nextTick(() => { this.$refs['planform_1'].clearValidate() }); this.$data.addplanVisible_1=true; }, download_template(){ document.getElementById("bt_download").blur(); var downUrl = '/pp/download_file'+"?id="+"审批导入.csv"; downloadUrl("导入审批物料模版.csv",downUrl); }, input_change(value) { console.log(value); this.get_payment(); }, exportSap(){ document.getElementById("bt_export").blur(); var _this = this; var objs; axios.post('/u_ma/export_sap', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), p_id: _this.$data.p_id_v, p_name: _this.$data.p_name_v, }) .then(function (response) { console.log(response.data); var fileid = response.data.fileId; var downUrl = '/u_ma/download_file'+"?id="+fileid; downloadUrl("产品编码名称.csv",downUrl); }) .catch(function (error) { console.log(error); }); }, importData(){ document.getElementById("bt_import").blur(); if(this.$data.importTableData.length==0){ this.$message({ message: "请选择导入文件", type: "warning", duration: 1500 }); return; } this.$confirm('是否确认导入?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { var _this = this; _this.$data.percent_len=0; _this.$data.if_show_process1=true; _this.$data.interval= setInterval(()=>{ if(_this.$data.percent_len>=99){ clearInterval(_this.$data.interval); return; } if (_this.$data.percent_len<98){ _this.$data.percent_len+=2 } },20) axios.post('/pp/import_approve_m', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), data:this.$data.importTableData, }) .then(function (response) { let r = response.data.r; let s = "" let errType = "" if (r == 0) { let len = _this.$data.importTableData.length; errType = "success" s = "导入"+len+"条物料成功!"; _this.$data.percent_len=100; _this.$data.if_show_process1=false; } else if(r == 1) { errType = "error" s = "正在导入物料,请稍后!"; clearInterval(_this.$data.interval); } else{ errType = "error" s = "导入物料失败!"; clearInterval(_this.$data.interval); } console.log(s); _this.$message({ message: s, type: errType, duration: 3000 }); _this.$data.importdialogVisible=false; //更新页面 //_this.get_p(); }) .catch(function (error) { console.log(error); }); }).catch(() => { this.$message({ type: 'info', message: '已取消' }); return; }); }, handleChange(file, fileList) { document.getElementById("bt_upload").blur(); this.fileTemp = file.raw console.log("filetype:",this.fileTemp); if (this.fileTemp) { console.log("begin ...") console.log(this.fileTemp.type); if ((this.fileTemp.type == 'text/csv') || (this.fileTemp.type == '.csv') || (this.fileTemp.type == 'application/vnd.ms-excel')) { let _this = this//如果需要点击事件结束之后对DOM进行操作使用)_this.xx=xx进行操作 Papa.parse(_this.fileTemp, { encoding:'gb2312', complete (results) { console.log(results)//这个是csv文件的数据 let data = [] //遍历csv文件中的数据,存放到data中 方法不唯一,可自己更改 for (let i = 0; i < results.data.length; ++i) { if(i==0){ continue; } let obj = {} obj.supplier = results.data[i][0] if(obj.supplier==""|| obj.supplier==undefined){ continue; } obj.supplier_code = results.data[i][1] if(obj.supplier_code==""|| obj.supplier_code==undefined){ continue; } obj.pt = results.data[i][2] if(obj.pt==""|| obj.pt==undefined){ continue; } obj.code = results.data[i][3] if(obj.code==""|| obj.code==undefined){ continue; } obj.name = results.data[i][4] if(obj.name==""|| obj.name==undefined){ continue; } obj.spec = results.data[i][5] if(obj.spec==""|| obj.spec==undefined){ continue; } obj.unit = results.data[i][6] if(obj.unit==""|| obj.unit==undefined){ continue; } obj.price = results.data[i][7] if(obj.price==""|| obj.price==undefined){ continue; } obj.update_date = results.data[i][8] if(obj.update_date==""|| obj.update_date==undefined){ continue; } obj.pc = results.data[i][9] if(obj.pc==""|| obj.pc==undefined){ continue; } obj.vpoq = results.data[i][10] if(obj.vpoq==""|| obj.vpoq==undefined){ continue; } data.push(obj) } //data.splice(0, 1)//将数组第一位的表格名称去除 let num = 0 console.log('data', data) _this.$data.importTableData=data; } }) } else { this.$data.fileListUpload=[]; this.$message({ type: 'warning', message: '附件格式错误,请删除后重新上传!' }) } } else { this.$message({ type: 'warning', message: '请上传附件!' }) } }, importCsv(){ this.$data.fileListUpload=[]; this.$data.importTableData=[]; this.$data.importdialogVisible=true; }, importDialog_close(done){ done(); }, handleSelectionChange(val) { console.log("已选择"); console.log(val); this.multipleSelection = val; }, post_p(){ this.$data.dialogVisible = false; var _this = this; var objs; axios.post('/pp/update_payment', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), data: _this.$data.row, }) .then(function (response) { let r = response.data.r; let s = "" let errType = "" if (r == 0) { errType = "success" } else{ errType = "error" } if (r ==0) { s = "修改成功!"; } else{ s = "修改失败!"; } _this.$message({ message: s, type: errType, duration: 1500 }); //更新页面 _this.get_payment(); }) .catch(function (error) { console.log(error); }); }, del_p(){ var _this = this; axios.post('/u_ma/del_p', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), ids: _this.$data.multipleSelection, }) .then(function (response) { let r = response.data.r; let s = "" let errType = "" if (r == 0) { s = "删除产品信息成功!"; errType = "success" } else{ s = "删除产品信息失败!"; errType = "error" } _this.$message({ message: s, type: errType, duration: 1500 }); if (r ==0) { _this.get_p();//更新页面 } }) .catch(function (error) { console.log(error); }); }, add_p(){ document.getElementById("bt_add").blur(); this.$data.disabled=false; this.$data.oper_type = 1; this.$data.form = { id:'', p_id: '', p_name:'', }; this.$nextTick(() => { this.$refs['form_p'].clearValidate() }); this.$data.dialogVisible = true; }, update_p(info){ this.$data.disabled=true; this.$data.oper_type = 2; this.$data.row = { id:info.id, supplier:info.supplier, code:info.code, name:info.name, spec:info.spec, unit:info.unit, num:info.num, price:info.price, pt:info.pt, total_p:info.total_p, paid:info.paid, rp:info.rp, payment_data:[], pre_id:info.pre_id, }; for(var i=0;i { this.$refs['form_p'].clearValidate() }); this.$data.dialogVisible = true; }, get_payment(){ document.getElementById("bt_search").blur(); this.$data.currentPage=1; var _this = this; var objs; axios.post('/pp/get_payment', { opuser:localStorage.getItem("online_user"), opuser_uuid:localStorage.getItem("uuid"), index: this.$data.currentPage, count: this.$data.pagesize, code: this.$data.code_v, name:this.$data.name_v, supplier:this.$data.supplier_v, }) .then(function (response) { console.log(response.data); objs = response.data.data; rcnt = response.data.total; _this.$data.tableData = objs; _this.$data.recordTotal = rcnt; }) .catch(function (error) { console.log(error); }); }, handleSizeChange(val) { this.$data.pagesize = val; this.get_payment(); }, handleCurrentChange(val) { this.$data.currentPage = val; this.get_payment(); } } }