From 259c9fafbbacfc40e67007443ef01d215b960c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=A3=9A?= <849005670@qq.com> Date: Tue, 25 Jan 2022 17:11:40 +0800 Subject: [PATCH 1/2] =?UTF-8?q?key=E5=AE=A1=E6=89=B9=E6=92=A4=E9=94=80?= =?UTF-8?q?=E7=BC=96=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/api.js | 10 +- src/pages/exchangecode/add/add.js | 15 +- src/pages/plan/key/edit.js | 313 ++++++++++++++++++++++-------- 3 files changed, 244 insertions(+), 94 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index e8838d4c..f9a57ddc 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -316,7 +316,7 @@ export const startOrStopPlan = (id, params) => { //创建key批次信息 export const addKeysBatchInfo = (id, params) => { - return req('post', baseurl + "/plan/" + id + "/keys", params) + return req('post', "http://192.168.6.165:8080" + "/plan/" + id + "/keys", params) } @@ -904,12 +904,14 @@ export const planCancel= (id) => { } //key审批 -export const keyApproval =(plan_id,key_id) => { - return req('post',baseurl + "/plan/"+plan_id+"/keys/"+key_id+"/approval") +export const keyApproval =(plan_id,key_id,data) => { + return req('post',"http://192.168.6.165:8080" + "/plan/"+plan_id+"/keys/"+key_id+"/approval",data) } - +export const keyEditApproval =(key_id,data) => { + return req('post',"http://192.168.6.165:8080" + "/keys/"+key_id+"/approval",data) +} // logout退出登录 diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index 234f2e32..c14e5051 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -545,19 +545,20 @@ export default class acclist extends React.Component{ let id = sessionStorage.getItem("key_plan_id") addKeysBatchInfo(id,data).then((res)=>{ handelResponse(res,(req,msg)=>{ - + keyApproval(id,req.key_batch_id,data).then((res)=>{ + handelResponse(res,(req,msg)=>{ + + Notify.success("成功发起审批"); setTimeout(()=>{ this.props.history.push('/home/key-list/'); },2000) - // keyApproval(id,req.id).then((res)=>{ - // handelResponse(res,(req,msg)=>{ - // },(err)=>{ - // Notify.error(err); - // }) - // }) + },(err)=>{ + Notify.error(err); + }) + }) },(err)=>{ Notify.error(err); diff --git a/src/pages/plan/key/edit.js b/src/pages/plan/key/edit.js index d802b761..f771fd4a 100644 --- a/src/pages/plan/key/edit.js +++ b/src/pages/plan/key/edit.js @@ -6,7 +6,7 @@ import Ipt from "../../../components/input/main" import Form from "../../../components/form/main" import FormItem from "../../../components/form-item/main" import Grid from "../../../components/gird/main.js" -import {addPlanStep,getApprovalsInfo,handelResponse,getPlanList,addKeysBatchInfo,getKeyBatchDetail,getReseller,putKeyBatchDetail,uploadImg,terminateApprovals,getApprovalsStatus,approvals +import {addPlanStep,getApprovalsInfo,handelResponse,getPlanList,addKeysBatchInfo,getKeyBatchDetail,getReseller,putKeyBatchDetail,uploadImg,keyApproval,keyEditApproval,terminateApprovals,getApprovalsStatus,approvals } from "../../../assets/api.js" import Productform from "../product/add" import Bus from "../../../assets/eventBus.js" @@ -69,7 +69,9 @@ export default class acclist extends React.Component{ reseller:null, payment_direction:["对私账户","对公账户","预付款扣除"], recall_visible:false, - timer:3 + timer:3, + plan_id:0, + key_status:-1 } } @@ -100,13 +102,18 @@ export default class acclist extends React.Component{ this.setState({isCancel:true}) } - // if(req.status == 1) - // { - // this.setState({isEdit:false}) - // } - // else{ - // this.setState({isEdit:true}) - // } + console.log("key的状态",req.status) + + if(req.status == 1) + { + this.setState({isEdit:false}) + } + else{ + this.setState({isEdit:true}) + } + this.setState({key_status:req.status}) + + this.setState({plan_id:req.plan_id}) this.setState({pagetitle:"编辑key"}) req.code_batch = req.code_batch ? req.code_batch : [] @@ -131,21 +138,22 @@ export default class acclist extends React.Component{ getApprovalsInfo(approval_id).then((res)=>{ handelResponse(res,(req,msg)=>{ - for(let i = 0;i < req.code_batch.length;i++) - { - let code_batch = req.code_batch[i]; - let range = [] - for(let j = 0;j < code_batch.product.length;j++) - { - let product = code_batch.product[j]; - range.push(product.product_name) - } - req.code_batch[i].disabled = false - req.code_batch[i].checked = false - code_batch.range = range.toString(); - temp.push(req.code_batch[i]) - } + for(let i = 0;i < req.code_batch.length;i++) + { + let code_batch = req.code_batch[i]; + let range = [] + for(let j = 0;j < code_batch.product.length;j++) + { + let product = code_batch.product[j]; + range.push(product.product_name) + } + req.code_batch[i].disabled = false + req.code_batch[i].checked = false + code_batch.range = range.toString(); + temp.push(req.code_batch[i]) + } + if(req.payment_direction) { console.log(req.payment_direction) @@ -512,14 +520,19 @@ export default class acclist extends React.Component{ } onSubmit(){ - this.setState({audit_visible:true}) } onConfirm(){ + let selection = this.refs.bindObj.getSelectData() + let formdata = selection.filter((item)=>{ + return !item.hasOwnProperty("disabled") || item.disabled == false + }) if(this.state.isEdit) { + + this.setState({audit_visible:false}) let approval_id = sessionStorage.getItem("approval_id") if(approval_id > 0) @@ -555,7 +568,10 @@ export default class acclist extends React.Component{ "receive_email":this.state.reseller.contact_email[0], "payment_direction":this.state.payment_direction[this.state.paytype - 1], } - putKeyBatchDetail(id,data).then((res)=>{ + + + + keyEditApproval(id,data).then((res)=>{ handelResponse(res,(req,msg)=>{ Notify.success("成功发起审批"); setTimeout(()=>{ @@ -572,65 +588,201 @@ export default class acclist extends React.Component{ }) } else{ - let selection = this.refs.bindObj.getSelectData() - console.log("选中对象") - console.log(selection) - let formdata = selection.filter((item)=>{ - return !item.hasOwnProperty("disabled") || item.disabled == false - }) + - let id = sessionStorage.getItem("keybatch_id") - let data = { - code_batch:formdata, - "reseller_id":this.state.reseller.id, - "reseller_name":this.state.reseller.name, - "company_name":this.state.reseller.company_name, - "receive_email":this.state.reseller.contact_email[0], - "payment_direction":this.state.payment_direction[this.state.paytype - 1], + if(this.state.key_status != 1) + { + let id = sessionStorage.getItem("keybatch_id") + let data = { + code_batch:formdata, + "reseller_id":this.state.reseller.id, + "reseller_name":this.state.reseller.name, + "company_name":this.state.reseller.company_name, + "receive_email":this.state.reseller.contact_email[0], + "payment_direction":this.state.payment_direction[this.state.paytype - 1], + } + + console.log("key批次id",id) + + keyEditApproval(id,data).then((res)=>{ + handelResponse(res,(req,msg)=>{ + Notify.success("成功发起审批"); + setTimeout(()=>{ + window.history.back() + },1000); + },(err)=>{ + Notify.error(err) + }) + }) } - putKeyBatchDetail(id,data).then((res)=>{ - handelResponse(res,(req,msg)=>{ - Notify.success("成功发起审批"); - setTimeout(()=>{ - window.history.back() - },1000); - },(err)=>{ - Notify.error(err) - }) - }) + else{ + let data = { + batch_name : this.state.model.batch_name, + style:this.state.model.style, + quantity:this.state.model.quantity, + bind_object:this.state.checkedList, + allow_repetition:this.state.model.allow_repetition, + allow_loss:this.state.model.allow_loss, + merge_stock:this.state.model.merge_stock, + code_batch:formdata, + "reseller_id":this.state.reseller.id, + "reseller_name":this.state.reseller.name, + "company_name":this.state.reseller.company_name, + "receive_email":this.state.reseller.contact_email[0], + "payment_direction":this.state.payment_direction[this.state.paytype - 1], + } + + let id = sessionStorage.getItem("keybatch_id") + putKeyBatchDetail(id,data).then((res)=>{ + handelResponse(res,(req,msg)=>{ + keyApproval(this.state.plan_id,id,data).then((res)=>{ + handelResponse(res,(req,msg)=>{ + Notify.success("成功发起审批"); + setTimeout(()=>{ + this.props.history.push('/home/key-list/'); + },2000) + + + },(err)=>{ + Notify.error(err); + }) + }) + + + + },(err)=>{ + Notify.error(err) + }) + }) + + + + } + + + // putKeyBatchDetail(id,data).then((res)=>{ + // handelResponse(res,(req,msg)=>{ + // Notify.success("成功发起审批"); + // setTimeout(()=>{ + // window.history.back() + // },1000); + // },(err)=>{ + // Notify.error(err) + // }) + // }) + + // keyApproval(this.state.plan_id,id,data).then((res)=>{ + // handelResponse(res,(req,msg)=>{ + + + // Notify.success("成功发起审批"); + // setTimeout(()=>{ + // this.props.history.push('/home/key-list/'); + // },2000) + + + // },(err)=>{ + // Notify.error(err); + // }) + // }) + + + + } } else{ - if(this.refs.form1.validator()) - { - let data = {}; - data.batch_name = this.state.model.batch_name; - data.style = this.state.model.style; - data.quantity = this.state.model.quantity; - data.bind_object = this.state.checkedList; - data.allow_repetition = this.state.model.allow_repetition; - data.allow_loss = this.state.model.allow_loss; - data.merge_stock = this.state.model.merge_stock; - data.code_batch = this.refs.bindObj.getSelectData(); - if(data.code_batch.length == 0) - { - Notify.error("请绑定对象") - return + let data = { + batch_name : this.state.model.batch_name, + style:this.state.model.style, + quantity:this.state.model.quantity, + bind_object:this.state.checkedList, + allow_repetition:this.state.model.allow_repetition, + allow_loss:this.state.model.allow_loss, + merge_stock:this.state.model.merge_stock, + code_batch:formdata, + "reseller_id":this.state.reseller.id, + "reseller_name":this.state.reseller.name, + "company_name":this.state.reseller.company_name, + "receive_email":this.state.reseller.contact_email[0], + "payment_direction":this.state.payment_direction[this.state.paytype - 1], + } + + let id = sessionStorage.getItem("keybatch_id") + let approval_id = sessionStorage.getItem("approval_id") + + getApprovalsStatus(approval_id).then((res)=>{ + handelResponse(res,(req,msg)=>{ + if(req.status == 0) + { + this.setState({recall_visible:true}) + } + if(req.status == 1) + { + this.setState({audit_visible:true}) + + } + if(req.status == 2 || req.status == 3){ + putKeyBatchDetail(id,data).then((res)=>{ + handelResponse(res,(req,msg)=>{ + keyApproval(this.state.plan_id,id,data).then((res)=>{ + handelResponse(res,(req,msg)=>{ + Notify.success("成功发起审批"); + setTimeout(()=>{ + this.props.history.push('/home/key-list/'); + },2000) + + + },(err)=>{ + Notify.error(err); + }) + }) + + + },(err)=>{ + Notify.error(err) + }) + }) + } + },(err)=>{ + Notify.error(err) + }) + }) + + } - - let id = sessionStorage.getItem("key_plan_id") - addKeysBatchInfo(id,data).then((res)=>{ - handelResponse(res,(req,msg)=>{ - Notify.success("成功发起审批"); - setTimeout(()=>{ - window.history.back() - },1000); - },(err)=>{ - }) - }) - } - } + + // if(this.refs.form1.validator()) + // { + // let data = {}; + // data.batch_name = this.state.model.batch_name; + // data.style = this.state.model.style; + // data.quantity = this.state.model.quantity; + // data.bind_object = this.state.checkedList; + // data.allow_repetition = this.state.model.allow_repetition; + // data.allow_loss = this.state.model.allow_loss; + // data.merge_stock = this.state.model.merge_stock; + // data.code_batch = this.refs.bindObj.getSelectData(); + // if(data.code_batch.length == 0) + // { + // Notify.error("请绑定对象") + // return + // } + + // let id = sessionStorage.getItem("key_plan_id") + // addKeysBatchInfo(id,data).then((res)=>{ + // handelResponse(res,(req,msg)=>{ + // Notify.success("成功发起审批"); + // setTimeout(()=>{ + // window.history.back() + // },1000); + // },(err)=>{ + // }) + // }) + + // } + //} } onBindNum(e,row){ @@ -882,12 +1034,7 @@ export default class acclist extends React.Component{ ]; //校验规则 const rules = { - - quantity: [ - { type: "required", message: "请输入key数量"}, - { type: "regExp", message: "请输入正整数",reg:"^([1-9][0-9]*){1,3}$"}, - - ], + bind_object: [ { type: "required", message: "请选择绑定类型"}, ], From 7a5584b611e8e4ef393256369dfb19576888f64b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=A3=9A?= <849005670@qq.com> Date: Tue, 25 Jan 2022 17:44:59 +0800 Subject: [PATCH 2/2] Update api.js --- src/assets/api.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/assets/api.js b/src/assets/api.js index f9a57ddc..70ec9e6c 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -345,7 +345,7 @@ export const getKeyBatchDetail = (id, params) => { //更新key批次详细信息 export const putKeyBatchDetail = (id, params) => { - return req('put', baseurl + "/keys/" + id, params) + return req('put', "http://192.168.6.165:8080" + "/keys/" + id, params) } //发送key批次压缩包和压缩包密码 export const planSend = (id, params) => { @@ -847,28 +847,28 @@ export const getThemeType= () => { //key码列表 export const getkeyDetailList= (id,data) => { - return req('get', baseurl + "/key/"+id,data) + return req('get', "http://192.168.6.165:8080" + "/key/"+id,data) } //提交审核 export const approvals= (id,data) => { - return req('post', baseurl + "/plan/"+id+"/approvals",data) + return req('post', "http://192.168.6.165:8080" + "/plan/"+id+"/approvals",data) } export const getApprovalsInfo= (id,data) => { - return req('get', baseurl + "/approvals/"+id+"/market_approval_data",data) + return req('get', "http://192.168.6.165:8080" + "/approvals/"+id+"/market_approval_data",data) } export const terminateApprovals= (id,data) => { - return req('put', baseurl + "/approvals/"+id+"/terminate",data) + return req('put', "http://192.168.6.165:8080" + "/approvals/"+id+"/terminate",data) } export const getApprovalsStatus= (id,data) => { - return req('get', baseurl + "/approvals/"+id+"/status") + return req('get', "http://192.168.6.165:8080" + "/approvals/"+id+"/status") } //作废