新增模板

This commit is contained in:
red-deng-deng 2021-11-22 19:03:16 +08:00
parent bbfdd35fd4
commit 5209fc5c01
6 changed files with 140 additions and 78 deletions

View File

@ -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)
}
//获取落地页下拉菜单

View File

@ -20,7 +20,7 @@ export default class adduserinfo extends React.Component{
uploadimgFile:'',//分销商头像files
email_nums:1,
disabled:false,
defaultFileList:[],//默认回显头像
defaultFileList:[{src:'',}],//默认回显头像
model:{ //数据模型不可少
name:'',
account:'',

View File

@ -543,7 +543,7 @@ export default class acclist extends React.Component{
return(
<div id="addkey" class="addkey">
<div id="addkey" className="addkey">
<Card style={{ width:'98%',height:"auto" ,"margin":"10px auto"}} title={this.state.pagetitle}>
<Form model={this.state.model} rules={rules} ref="form1">

View File

@ -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:"",

View File

@ -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 (
<div>
<p>{item.name}</p>
<p>进度{item.percent}%</p>
<div>
{item.status === FILE_UPLOAD_STATUS.failed && <Button onClick={() => onRetry(item)}>重试</Button>}
<Button type="primary" onClick={() => onDelete(item)}>删除</Button>
</div>
</div>
)
};
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:""
}
}
}
onUploadChange(e){
title:"",
scope:"",//归属账号
client:"",
},
client:[],
file:'',
headImg:''//上传图片的地址
}
onUpload(e){
}
//上传图片
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('请先选择图片!');
}
onUploadError(){
}
//上传文件
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,49 +146,48 @@ export default class acclist extends React.Component{
},
];
return(
<div class="customize">
<div className="customize">
<Card type="nested" title="定制化模板" className="customize-card">
<Form model={this.state.model} rules={rules} ref="form1">
<FormItem labelname="标题" prop="name" >
<Ipt onChange={(e)=>{
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'}/>
</FormItem>
<FormItem labelname="文件上传" prop="zip">
<Upload
multiple
className="zent-upload-demo-pic"
maxSize={2 * 1024 * 1024}
maxAmount={1}
tips="文件不超过 2M"
onChange={this.onUploadChange}
maxSize={10 * 1024 * 1024}
tips="单个文件不超过 10M"
onChange={(e)=>this.onUploadFileChange(e)}
onUpload={this.onUpload}
onError={this.onUploadError}
customUploadItem={CustomItem}
sortable
/>
</FormItem>
<FormItem labelname="截图上传" prop="picurl">
<ImageUpload
className="zent-image-upload-demo"
maxSize={5 * 1024 * 1024}
tips="建议尺寸 640*640图片不超过 5M"
maxSize={1* 1024 * 1024}
tips="建议尺寸 375*667图片不超过1Mb"
maxAmount={1}
multiple
sortable
tips="建议尺寸 640*640图片不超过 5M"
onChange={this.onUploadChange}
onChange={(e)=>{this.onUploadChange(e)}}
onUpload={this.onUpload}
onError={this.onUploadError}
/>
</FormItem>
<FormItem labelname="归属账号" prop="account" id="account">
<Select options={options} placeholder="选择一项" width={515} value={this.state.model.account} />
<FormItem labelname="归属账号" prop="scope" id="scope">
<Select options={options} onChange={(e)=>{this.onscopeChange(e)}} placeholder="选择一项" width={515} value={this.state.model.scope} />
</FormItem>
<FormItem labelname="页面类型" prop="pagetype" id="pagetype">
<Select options={options} placeholder="选择一项" width={515} value={this.state.model.pagetype} />
<FormItem labelname="页面类型" prop="client" id="client">
<Select options={this.state.client} onChange={(e)=>{this.onclientChange(e)}} placeholder="选择一项" width={515} value={this.state.model.client} />
</FormItem>
</Form>
<div className="btn-group">

View File

@ -486,7 +486,7 @@ export default class station extends React.Component{
addipt.className=disbtn+" newitem";
addipt.innerHTML=`
<input placeholder=请输入新增${place} onKeydown={window["mystation"].sureFn(event,this,'${place}')} />
<p><span class="del" onClick={window["mystation"].saveFn(this,'${place}')}>取消</span><span class="operation" onClick={window["mystation"].editFn(this,'${place}')}></span></p>
<p><span className="del" onClick={window["mystation"].saveFn(this,'${place}')}>取消</span><span className="operation" onClick={window["mystation"].editFn(this,'${place}')}></span></p>
`;
nextDom.appendChild(addipt);
if(disbtn=='companyBtn'){