/**
* @author jh
* @desc 编辑字段页面组件
*
*/
import React from "react";
import {inject, observer} from 'mobx-react';
import {toJS} from 'mobx';
import {WeaSwitch} from 'comsMobx';
import {Button, Row, Modal} from 'antd';
import {
WeaTools,
WeaDialog,
WeaCollect,
WeaRichText,
WeaFormItem,
WeaRightMenu,
WeaMoreButton,
WeaSearchGroup,
WeaLocaleProvider,
WeaAlertPage,
} from 'ecCom';
import {RichTextTitle} from "./RichTextTitle";
import isRegExp from 'lodash/isRegExp';
const getLabel = WeaLocaleProvider.getLabel;
@observer
export class UserPhraseEdit extends React.Component {
constructor(props) {
super(props);
this.getDialogBtns.bind(this);
this.state = {
isRequired: 'required',
showCollect: false,
}
}
render() {
const {store,visiable,setVisiable} = this.props;
const {
// visiable,
onCancelEdit,
form,
success,
conditions,
richTextOnChange,
phraseDescValue
} = store;
const formParams = form.getFormParams();
const {isRequired, showCollect} = this.state;
let conditionGroup = [];
let extentsConfig = [];
this.initExtentsConfig(extentsConfig);
if(success == -1){
conditionGroup.push(
}
iconSize = {120}
paddingTop ={'15%'}
>
对不起,您暂时没有权限 !
);
}else if(success == 0){
conditionGroup.push(
}
iconSize = {120}
paddingTop ={'15%'}
>
发生异常,请刷新重新或联系管理员
)
}else{
form.isFormInit && conditions && conditions.map((g, index) => {
index == 0 ? conditionGroup.push(
{
g.items && g.items.map((item) => {
if(item.domkey[0] === 'dsporder'){
item.regExp = /^(-{0,1}|(-{0,1}[0-9]{1,}[.]?[0-9]*))$/;
}
return (
)
})
}
)
:
conditionGroup.push(
}
showGroup={g.defaultshow}
>
)
});
}
return (
{
onCancelEdit();
setVisiable(false);
}}
buttons={this.getDialogBtns()}
style={{width: 800, height: 600}}
draggable={true}
>
{conditionGroup}
{/*收藏*/}
this.setState({showCollect: false})}
submitBack={data => console.log('onOk: ', data)}
/>
);
}
buttonBtnChange(name = '', ids = '', list = [], type = '',addfileid=''){
let returnInfo = [];
if(name === 'Upload'){
if(type === 'image'){
list.map(item => {
const imglink = `/weaver/weaver.file.FileDownload?fileid=${item.fileid}`;
returnInfo.push(`
`);
});
this.refs.WeaRichText.insertHTML(returnInfo.join(''));
}
}
return ' ';
}
/**
* 保存
*/
doSave() {
const {isRequired} = this.state;
if (isRequired == 'required') {
Modal.warning({title:getLabel(131329,'信息确认'),okText: getLabel(33703, '确认'), content: getLabel(384146, '必要信息不完整,红色*为必填项')});
return;
}
const {store, saveCallBack} = this.props;
const {form} = store;
const formParams = form.getFormParams();
const {groupid = '', dsporder = 0} =formParams;
if(groupid == '1' && dsporder < 0) {
Modal.warning({title:getLabel(131329,'信息确认'),okText: getLabel(33703, '确认'), content: getLabel(385772, '显示顺序不能为负数!')});
return;
}
store.onSave(saveCallBack);//weaworkflow_userdefault_store.getConditionInfo
}
/**
* 富文本编辑器输入onChange事件
* @param desc
*/
onChange(desc = '') {
const {store} = this.props;
const {richTextOnChange} = store;
richTextOnChange(desc);
this.setState({
isRequired: desc === '' ? 'required' : ''
});
}
/**
* 富文本编辑器配置参数
* @returns {{height: number, toolbar: string, toolbar_Full: *[]}}
*/
getCkConfig() {
return {
height: 240,
removePlugins:'resize',
toolbar: [{name: 'document', items: ['Source']},
{name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike',]},
{name: 'styles', items: ['Font', 'FontSize']},
{name: 'colors', items: ['TextColor', 'BGColor']},
{
name: 'paragraph',
items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock']
},
{name: 'links', items: ['Link', 'Unlink']},
{name: 'tools', items: ['Maximize']},
{name: 'insert', items: ['Table', '-', 'Undo', 'Redo']}]
};
}
getDialogBtns() {
const {store} = this.props;
return [
(
),
()
];
}
initExtentsConfig(extentsConfig) {
extentsConfig.push({
name: 'Upload',
type: 'image',
show:
,
uploadUrl: '/api/doc/upload/uploadFile',
category: 'all',
limitType: 'jpg,gif,png',
title: getLabel(20001, '上传图片'),
needLoading: false
});
}
getMoreBtns() {
return [{
key: "save",
icon: ,
content: getLabel(30986, '保存'),
onClick: () => {
this.doSave();
}
}, {
key: "coll",
icon: ,
content: getLabel(28111, '收藏'),
onClick: () => {
this.setState({
showCollect: true,
});
}
}
];
}
}