From 7a717c6b5eceb2869085535f19ad8ea1b5f34a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E6=A3=9A?= <849005670@qq.com> Date: Thu, 2 Dec 2021 15:49:55 +0800 Subject: [PATCH] Update main.js --- src/pages/exchangepage/edittemplate/main.js | 49 ++++++++++++++++----- 1 file changed, 38 insertions(+), 11 deletions(-) diff --git a/src/pages/exchangepage/edittemplate/main.js b/src/pages/exchangepage/edittemplate/main.js index 27e392fc..2244fb61 100644 --- a/src/pages/exchangepage/edittemplate/main.js +++ b/src/pages/exchangepage/edittemplate/main.js @@ -81,13 +81,6 @@ export default class edittemplate extends React.Component{ { myInfo = JSON.parse(myInfo) - - if(myInfo.creator == 0) - { - this.setState({isSystemModel:true}) - } - - let model = { id:myInfo.id, images:myInfo.images.length == 3 ? myInfo.images : this.state.model.images , @@ -98,6 +91,14 @@ export default class edittemplate extends React.Component{ title:myInfo.title, thumb:myInfo.thumb } + if(myInfo.creator == 0) + { + this.setState({isSystemModel:true}) + model.sort = myInfo.sort; + } + + + if(myInfo.href) { @@ -151,8 +152,12 @@ export default class edittemplate extends React.Component{ Notify.error("没上传缩略图") return; } - - + + var re = new RegExp("^([1-9][0-9]*){1,3}$"); + if (!re.test(this.state.model.sort)) { + Notify.error("权重请输入正整数") + return; + } let formdata = { "title": this.state.model.title, @@ -203,7 +208,7 @@ export default class edittemplate extends React.Component{ if(this.state.isSystemModel) { - + formdata.sort = this.state.model.sort; putSystemTemplate(this.state.model.id,formdata).then((res)=>{ handelResponse(res,(req,msg)=>{ Notify.success("保存成功") @@ -411,7 +416,11 @@ export default class edittemplate extends React.Component{ const rules = { title: [ { type: "required", message: "请输入营销计划名称"}, - ] + ], + level:[ + { type: "required", message: "请输入权重"}, + { type: "regExp", message: "请输入正整数",reg:"^([1-9][0-9]*){1,3}$"}, + ] } @@ -593,6 +602,24 @@ export default class edittemplate extends React.Component{ {this.state.model.button_color} + + { + this.state.isSystemModel ? ( + + { + let model2 = this.state.model; + model2.sort = e; + this.setState({model:model2}) + }} + onClearItem={(e)=>{ + let model2 = this.state.model; + model2.sort = ""; + this.setState({model:model2}) + }} + value={this.state.model.sort} placeholder={"请输入"} labelWidth={'0px'} maxLength={3} height={'36px'} width={'250px'} alignment={'left'}/> + ) : null + + } { this.state.isExchangePage ? (