diff --git a/src/assets/api.js b/src/assets/api.js index 74e25203..e3c357cf 100644 --- a/src/assets/api.js +++ b/src/assets/api.js @@ -394,6 +394,10 @@ export const delMenu = (id) => { return req('delete', baseurl + "/auth/menu/"+id) } +//添加定制化模板 +export const postThemecustom= (data) => { + return upload('post', baseurl + "/plan/theme/custom",data) +} //获取落地页下拉菜单 diff --git a/src/pages/distributor/adddistributorinfo/adddistributorinfo.js b/src/pages/distributor/adddistributorinfo/adddistributorinfo.js index c1e1a36e..210fc9d6 100644 --- a/src/pages/distributor/adddistributorinfo/adddistributorinfo.js +++ b/src/pages/distributor/adddistributorinfo/adddistributorinfo.js @@ -20,7 +20,7 @@ export default class adduserinfo extends React.Component{ uploadimgFile:'',//分销商头像files email_nums:1, disabled:false, - defaultFileList:[],//默认回显头像 + defaultFileList:[{src:'',}],//默认回显头像 model:{ //数据模型不可少 name:'', account:'', diff --git a/src/pages/exchangecode/add/add.js b/src/pages/exchangecode/add/add.js index d937427c..9f89e6ef 100644 --- a/src/pages/exchangecode/add/add.js +++ b/src/pages/exchangecode/add/add.js @@ -543,7 +543,7 @@ export default class acclist extends React.Component{ return( -
+
diff --git a/src/pages/system/account/add/adduserinfo/adduserinfo.js b/src/pages/system/account/add/adduserinfo/adduserinfo.js index d2d14d5a..f3364b5f 100644 --- a/src/pages/system/account/add/adduserinfo/adduserinfo.js +++ b/src/pages/system/account/add/adduserinfo/adduserinfo.js @@ -12,7 +12,6 @@ import {handelResponse,uploadImg,putAddAcc,getCompany,getDepartment,getRole,post export default class adduserinfo extends React.Component{ constructor(props){ super(props) - console.log(props); this.state={ model:{ //数据模型不可少 user_name:"", diff --git a/src/pages/system/customize/main.js b/src/pages/system/customize/main.js index 4cda906d..86fcc437 100644 --- a/src/pages/system/customize/main.js +++ b/src/pages/system/customize/main.js @@ -2,69 +2,129 @@ import ReactDOM from 'react-dom'; import React, { Component } from 'react'; import { HashRouter as Router, Route, Link } from "react-router-dom"; import "./main.less" -import {Switch ,Icon ,Sweetalert, Notify,Dialog,Button,Card,Select,Upload,ImageUpload} from 'zent'; +import {Select,Button,ImageUpload ,Upload,Card,onUpload,Sweetalert,Notify} from "zent" import Ipt from "../../../components/input/main" import Form from "../../../components/form/main" import FormItem from "../../../components/form-item/main" - - -const FILE_UPLOAD_STATUS = Upload.FILE_UPLOAD_STATUS; - -const CustomItem = props => { - const { item, i18n, onRetry, onDelete } = props; - return ( -
-

{item.name}

-

进度:{item.percent}%

-
- {item.status === FILE_UPLOAD_STATUS.failed && } - -
-
- ) -}; - - +import {uploadImg,handelResponse,postThemecustom} from "../../../assets/api.js" +import _ from "lodash" export default class acclist extends React.Component{ constructor(props){ super(props) this.state={ model:{ //数据模型不可少 - name:"", - zip:"", - picurl:"", - account:"", - pagetype:"" - } + title:"", + scope:"",//归属账号 + client:"", + + }, + client:[], + file:'', + headImg:''//上传图片的地址 } - } - onUploadChange(e){ - - } - onUpload(e){ - - } - onUploadError(){ - } + //上传图片 + onUploadChange(files){ + let _self=this; + if(files&&files.length>0){ + let formdata= new FormData(); + formdata.append("file",files[0].file) + formdata.append("path"," plan_theme") + uploadImg(formdata).then((res)=>{ + handelResponse(res,(req,msg)=>{ + _self.setState({headImg:req.path}) + Notify.clear(); + Notify.success(msg); + },(err)=>{ + + }) + }).catch(err=>{ + }); + }else{ + Notify.clear(); + Notify.warn('请先选择图片!'); + } + } + //上传文件 + onUploadFileChange = files => { + this.setState({file:files[0].file}); + }; + + + onUploadError = (type, data) => { + if (type === 'overMaxAmount') { + Notify.error(`最多可上传 ${data.maxAmount} 个文件`); + } else if (type === 'overMaxSize') { + Notify.error(`文件大小不能超过 ${data.formattedMaxSize}`); + } + }; +//提交 onNextStep(){ - this.refs.form1.validator(); + let _self=this; + let addflag=this.refs.form1.validator(); + if(addflag){ + if(!this.state.headImg||!this.state.file){ + Notify.clear(); + Notify.warn('请先上传文件图片'); + }else{ + let fd=new FormData(); + let data=_.cloneDeep(this.state.model); + fd.append('thumb',this.state.headImg); + fd.append('file',this.state.file); + fd.append('client',data.client.key); + fd.append('scope',data.scope.key); + fd.append('title',data.title); + postThemecustom(fd).then((res)=>{ + handelResponse(res,(req,msg)=>{ + Notify.clear(); + Notify.success(msg); + },(err)=>{ + + }) + }).catch(err=>{ + }); + } + } } onCancel(){ window.history.back(); } + //归属账号 + onscopeChange(e){ + let model2 = this.state.model + model2.scope = e; + this.setState({ + model:model2 + }); + } + onclientChange(e){ + let model2 = this.state.model + model2.client = e; + this.setState({ + model:model2 + }); + } + componentWillMount(){ + let enmuStatus=JSON.parse(sessionStorage.getItem('enmu')); + let enumobj=enmuStatus.theme_client_type.code; + let type=[]; + for(let i in enumobj){ + type.push({key:i,text:enumobj[i]}) + } + this.setState({client:type}); + } render(){ //校验规则 const rules = { name: [ { type: "required", message: "请输入标题"}, - ], - zip: [ - { type: "required", message: "请选择文件"}, - ], - picurl: [ - { type: "required", message: "请上传截图"}, - ], + ], + client:[ + { type: "required", message: "请选择页面类型"}, + ], + scope:[ + { type: "required", message: "请选择归属账号"}, + ] } const options = [ { @@ -86,52 +146,51 @@ export default class acclist extends React.Component{ }, ]; return( -
+
{ let model2 = this.state.model; - model2.name = e; + model2.title = e; this.setState({model:model2}) - }} value={this.state.model.name} placeholder={"请输入"} labelWidth={'0px'} maxLength={32} height={'36px'} width={'520px'} alignment={'left'}/> + }} onClearItem={(e)=>{ + let model2 = this.state.model; + model2.title = ""; + this.setState({model:model2}) + }} value={this.state.model.title} placeholder={"请输入"} labelWidth={'0px'} maxLength={32} height={'36px'} width={'520px'} alignment={'left'}/> - + this.onUploadFileChange(e)} + onUpload={this.onUpload} + onError={this.onUploadError} + sortable + /> - + {this.onUploadChange(e)}} + onUpload={this.onUpload} + /> - - {this.onscopeChange(e)}} placeholder="选择一项" width={515} value={this.state.model.scope} /> - - {this.onclientChange(e)}} placeholder="选择一项" width={515} value={this.state.model.client} /> -
+
diff --git a/src/pages/system/station/main.js b/src/pages/system/station/main.js index e53c952b..b9b430d3 100644 --- a/src/pages/system/station/main.js +++ b/src/pages/system/station/main.js @@ -486,7 +486,7 @@ export default class station extends React.Component{ addipt.className=disbtn+" newitem"; addipt.innerHTML=` -

取消保存

+

取消保存

`; nextDom.appendChild(addipt); if(disbtn=='companyBtn'){