commit
173de38912
|
|
@ -7,6 +7,8 @@ import {
|
|||
* @param {Object} params [description]
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
export const getHasRight = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getHasRight`, 'GET', params)
|
||||
|
||||
export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getTabInfo`, 'GET', params)
|
||||
|
||||
export const getFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getFieldDefinedInfo`, 'GET', params)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
import { WeaTools } from 'ecCom'
|
||||
|
||||
//获取导入表单
|
||||
export const getImportForm = (params) => {
|
||||
return WeaTools.callApi(`/api/bs/hrmorganization/commonimport/getCommonForm`, 'GET', params);
|
||||
}
|
||||
|
||||
//导入文件提交
|
||||
export const saveImport = (params) => {
|
||||
return WeaTools.callApi(`/api/bs/hrmorganization/commonimport/saveCommonImport`, 'POST', params);
|
||||
}
|
||||
|
||||
//获取导入结果
|
||||
export const getImportResult = (params) => {
|
||||
return WeaTools.callApi(`/api/bs/hrmorganization/commonimport/getImportResult`, 'GET', params);
|
||||
}
|
||||
|
|
@ -67,7 +67,6 @@ class Home extends React.Component {
|
|||
<div style={{height:"100%"}}>
|
||||
<WeaPopoverHrm inDialog={true} ecId={`${this && this.props && this.props.ecId || ''}_WeaPopoverHrm@jp3tsb`} />
|
||||
<LogView ecId={`${this && this.props && this.props.ecId || ''}_LogView@mc1954`} {...this.state} onCancel={this.onCancel}/>
|
||||
{/* <WeaLogViewComp ecId={`${this && this.props && this.props.ecId || ''}_WeaLogViewComp@mc1954`} {...this.state} onCancel={this.onCancel}/> */}
|
||||
<WeaLocaleProvider ecId={`${this && this.props && this.props.ecId || ''}_WeaLocaleProvider@3on3aj`}>
|
||||
{this.props.children}
|
||||
</WeaLocaleProvider>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,240 @@
|
|||
import {
|
||||
WeaNewScroll,
|
||||
WeaSearchGroup,
|
||||
WeaMoreButton,
|
||||
WeaDialog
|
||||
} from 'ecCom'
|
||||
import {
|
||||
inject,
|
||||
observer,
|
||||
} from 'mobx-react'
|
||||
import {
|
||||
Spin,
|
||||
Button,
|
||||
Pagination,
|
||||
Steps,
|
||||
Upload,
|
||||
Icon,
|
||||
Row,
|
||||
Col,
|
||||
Progress
|
||||
} from 'antd'
|
||||
|
||||
import {
|
||||
WeaSwitch,
|
||||
WeaTableNew
|
||||
} from 'comsMobx'
|
||||
|
||||
import {
|
||||
i18n
|
||||
} from '../public/i18n';
|
||||
import { addContentPath } from '../util/index.js'
|
||||
|
||||
const Step = Steps.Step;
|
||||
const Dragger = Upload.Dragger;
|
||||
const WeaTable = WeaTableNew.WeaTable;
|
||||
|
||||
|
||||
@inject("importDialog")
|
||||
@observer
|
||||
export default class ImportDialog extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
width: 800,
|
||||
height: 600,
|
||||
title: '数据导入',
|
||||
}
|
||||
}
|
||||
|
||||
getCircle() {
|
||||
let style = {
|
||||
width: 20,
|
||||
height: 20,
|
||||
backgroundColor: '#D8D8D8',
|
||||
webkitBorderRadius: 10,
|
||||
mozBorderRadius: 10,
|
||||
msBorderRadius: 10,
|
||||
oBorderRadius: 10,
|
||||
borderRadius: 10,
|
||||
//paddingLeft: 6,
|
||||
textAlign: 'center',
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
getIllustration(val, url, index, link) {
|
||||
let p;
|
||||
if (index == 0) {
|
||||
p = (<p>{i18n.label.downLoadTemplete()}: <a href={addContentPath(url)}>{i18n.label.importTemplate()}</a></p>);
|
||||
} else {
|
||||
p = (<p><div dangerouslySetInnerHTML={{ __html: val }} /></p>);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
next() {
|
||||
const { importDialog } = this.props;
|
||||
let { current, steps } = importDialog;
|
||||
current = current + 1;
|
||||
if (current === steps.length) {
|
||||
current = 0;
|
||||
importDialog.init();
|
||||
}
|
||||
importDialog.current = current;
|
||||
current === steps.length - 1 && importDialog.startImport();
|
||||
}
|
||||
|
||||
getForm() {
|
||||
const {
|
||||
importDialog
|
||||
} = this.props;
|
||||
const {
|
||||
condition
|
||||
} = importDialog;
|
||||
let _arr = [];
|
||||
|
||||
condition.map((c, i) => {
|
||||
let arr = [];
|
||||
c.items.map((field, index) => {
|
||||
arr.push({
|
||||
com: (
|
||||
<div>
|
||||
<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@hz50xl@${index}`}>
|
||||
<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@fgfbrv@${index}`} span={1} offset={4} style={{ marginTop: 15 }}>
|
||||
<div style={this.getCircle()}>
|
||||
<div style={{ paddingTop: 2 }}>{index + 1}</div>
|
||||
</div>
|
||||
</Col>
|
||||
<Col ecId={`${this && this.props && this.props.ecId || ''}_Col@5rom81@${index}`} span={17} style={{ marginTop: 15 }}>
|
||||
{this.getIllustration(field.value, field.link, index, field)}
|
||||
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
),
|
||||
colSpan: 1
|
||||
})
|
||||
})
|
||||
_arr.push(<div><WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@bo47pp@${i}`} needTigger={true} title={c.title} showGroup={c.defaultshow} items={arr} col={1} /></div>)
|
||||
|
||||
});
|
||||
return _arr;
|
||||
}
|
||||
|
||||
setFileId(fileInfo) {
|
||||
const { importDialog } = this.props;
|
||||
fileInfo.file.response && importDialog.setExcelfile(fileInfo.file.response.data.fileid);
|
||||
importDialog.filelist = fileInfo.fileList;
|
||||
}
|
||||
|
||||
reRenderColumns(c) {
|
||||
c.forEach(item => {
|
||||
if (item.dataIndex == 'operatedetail') {
|
||||
item.render = function (text, record) {
|
||||
return <span style={{ color: '#FF0000' }}>{text}</span>
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
importDialog
|
||||
} = this.props, {
|
||||
importVisible,steps,current, pvisable, percent, failnum, succnum, importResultTip, importResultStore, importStatus, loading, date
|
||||
} = importDialog, {
|
||||
width,
|
||||
height,
|
||||
title
|
||||
} = this.state;
|
||||
|
||||
const buttons = [
|
||||
(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@jd6baw`} type="primary" onClick={() => this.next()}>{current === steps.length - 1 ? '导入完成' : '开始导入'}</Button>),
|
||||
];
|
||||
|
||||
|
||||
const props = {
|
||||
name: 'file',
|
||||
action: '/api/doc/upload/uploadFile',
|
||||
accept: '.xls,.xlsx',
|
||||
multiple:false
|
||||
|
||||
};
|
||||
|
||||
return (
|
||||
<WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@1txk5f`}
|
||||
title={title}
|
||||
icon="icon-coms-upload"
|
||||
iconBgcolor="#217346"
|
||||
visible={importVisible}
|
||||
closable={true}
|
||||
hasScroll={true}
|
||||
onCancel={() => importDialog.init()}
|
||||
buttons={buttons}
|
||||
style={{ width: width, height: height }}
|
||||
>
|
||||
<div style={{ marginTop: 24 }}>
|
||||
<Steps current={current}>
|
||||
{steps.map((s, i) => <Step key={i} title={s.title} description={s.description} />)}
|
||||
</Steps>
|
||||
</div>
|
||||
<div style={{ padding: 24 }}>
|
||||
{
|
||||
current == 0 && <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@2908z2`} ref="scrollBar">
|
||||
<Dragger
|
||||
{...props}
|
||||
onChange={
|
||||
(fileInfo) => {
|
||||
this.setFileId(fileInfo)
|
||||
}
|
||||
}
|
||||
>
|
||||
<div style={{ padding: '25px 0' }}>
|
||||
<p className="ant-upload-drag-icon">
|
||||
<Icon type="inbox" />
|
||||
</p>
|
||||
<p className="ant-upload-text">点击或将文件拖拽到此区域上传</p>
|
||||
<p className="ant-upload-hint">支持单个或批量上传,严禁上传公司内部资料及其他违禁文件</p>
|
||||
</div>
|
||||
</Dragger>
|
||||
{this.getForm()}
|
||||
</WeaNewScroll>
|
||||
}
|
||||
{
|
||||
current == 1 && <div>
|
||||
{
|
||||
importStatus == 'over' && <div className="hrm-import-result-icon" style={{ paddingTop: failnum == 0 ? 100 : 15 }}>
|
||||
<div style={{ width: 30, height: 30, borderRadius: 25, padding: 8, display: 'inline-block', backgroundColor: succnum > 0 ? '#54D3A2' : '#FF0000' }}>
|
||||
<Icon ecId={`${this && this.props && this.props.ecId || ''}_Icon@2fblod`} type={succnum > 0 ? 'check' : 'cross'} style={{ color: '#fff' }} />
|
||||
</div><span style={{ paddingLeft: 5 }}>{importResultTip}</span>
|
||||
</div>
|
||||
}
|
||||
{
|
||||
failnum > 0 &&
|
||||
<WeaTable ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@h7l6fo`}
|
||||
comsWeaTableStore={importResultStore}
|
||||
bordered
|
||||
needScroll={true}
|
||||
scroll={{ y: 330 }}
|
||||
getColumns={c => this.reRenderColumns(c)}
|
||||
/>
|
||||
}
|
||||
<WeaDialog
|
||||
title="导入进度"
|
||||
onCancel={() => importDialog.pvisable = false}
|
||||
visible={pvisable}
|
||||
style={{ width: 300, height: 50 }}
|
||||
>
|
||||
<div style={{ "padding": "15px" }}>
|
||||
<Progress percent={percent} strokeWidth={7} />
|
||||
</div>
|
||||
</WeaDialog>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
</WeaDialog>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ export default class FieldDefined extends Component {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="hrm_module_container fieldDef">
|
||||
hasRight && <div className="hrm_module_container fieldDef">
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import {
|
|||
import '../../style/common.less';
|
||||
|
||||
import NewAndEditDialog from '../NewAndEditDialog';
|
||||
import ImportDialog from '../ImportDialog';
|
||||
import { renderNoright } from '../../util';
|
||||
|
||||
|
||||
|
|
@ -42,6 +43,7 @@ const WeaTable = WeaTableNew.WeaTable;
|
|||
|
||||
|
||||
@inject('staff')
|
||||
@inject('importDialog')
|
||||
@observer
|
||||
export default class Staff extends React.Component {
|
||||
constructor(props) {
|
||||
|
|
@ -118,6 +120,16 @@ export default class Staff extends React.Component {
|
|||
staff.getForm();
|
||||
}
|
||||
|
||||
import() {
|
||||
const {
|
||||
importDialog
|
||||
} = this.props;
|
||||
importDialog.importVisible=true;
|
||||
importDialog.importModule='staff';
|
||||
importDialog.current = 0;
|
||||
importDialog.getImportForm();
|
||||
}
|
||||
|
||||
|
||||
log = () => {
|
||||
window.setLogViewProp({
|
||||
|
|
@ -221,14 +233,11 @@ export default class Staff extends React.Component {
|
|||
form2
|
||||
} = staff;
|
||||
staff.setStaffName(val);
|
||||
//!this.isEmptyObject(form2.getFormParams()) && staff.updateFields(val);
|
||||
}
|
||||
|
||||
reRenderColumns(columns) {
|
||||
let _this = this;
|
||||
// columns.forEach((c, index) => {
|
||||
|
||||
// })
|
||||
return columns;
|
||||
}
|
||||
|
||||
getTree = () => {
|
||||
|
|
@ -461,12 +470,13 @@ export default class Staff extends React.Component {
|
|||
render() {
|
||||
|
||||
const {
|
||||
staff
|
||||
staff,importDialog
|
||||
} = this.props;
|
||||
const {
|
||||
isPanelShow, form2, staffName, conditionNum, tableStore, nEdialogTitle, visible, condition,
|
||||
form, dialogLoading, isEdit, date, hasRight
|
||||
} = staff;
|
||||
const {importVisible} = importDialog;
|
||||
|
||||
if (hasRight === false) {
|
||||
return renderNoright();
|
||||
|
|
@ -529,6 +539,7 @@ export default class Staff extends React.Component {
|
|||
moduleName={"staff"}
|
||||
bindChangeEnvent={val => staff.updateConditions(val)}
|
||||
/>
|
||||
{importVisible && <ImportDialog ecId={`${this && this.props && this.props.ecId || ''}_ImportDialog@633i8k`} />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/**
|
||||
* @Author: 程亮
|
||||
* @Date: 2022-06-09 10:16:00
|
||||
* @LastEditTime: 2022-09-06 09:43:39
|
||||
* @LastEditTime: 2022-09-16 11:49:18
|
||||
* @Description:
|
||||
* @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js
|
||||
*/
|
||||
|
|
@ -672,7 +672,6 @@ export class FieldDefinedStore extends HrmBaseStore {
|
|||
* @param {String} key [tabKey]
|
||||
* @return {null}
|
||||
*/
|
||||
@observable hasRight = '';
|
||||
@action setActiveTab = (tabConfig, key) => {
|
||||
tabConfig.activeTabKey = key || tabConfig.tabs[0].viewCondition;
|
||||
const tabIndex = this.getTabIndex(this.tabConfig.tabs, key);
|
||||
|
|
@ -698,7 +697,6 @@ export class FieldDefinedStore extends HrmBaseStore {
|
|||
datas,
|
||||
selectedData
|
||||
} = this.convertData(res.data.data, 'fieldDef');
|
||||
this.hasRight = res.data.hasRight;
|
||||
this.encryptEnable = res.data.encryptEnable;
|
||||
this.tableEditConfig.fieldDef.datas = datas;
|
||||
this.tableEditConfig.fieldDef.columns = this.getColumns();
|
||||
|
|
@ -1377,11 +1375,25 @@ export class FieldDefinedStore extends HrmBaseStore {
|
|||
return this.selectedTreeNodeInfo && this.selectedTreeNodeInfo.domid == '-1';
|
||||
}
|
||||
|
||||
@observable hasRight = '';
|
||||
@action initResourceData = (module) => {
|
||||
this.selectedTreeNodeInfo = null;
|
||||
this.dropdownSelectedKey = '1';
|
||||
this.moduleName = module;
|
||||
this.treeConfig.treeExpandKeys.length = 0;
|
||||
api.getHasRight(this.moduleName).then(res => {
|
||||
if (res.code === 200) {
|
||||
this.hasRight = res.data.hasRight;
|
||||
res.data.hasRight && this.initPage();
|
||||
} else {
|
||||
message.error(res.msg);
|
||||
}
|
||||
}, error => { })
|
||||
|
||||
|
||||
}
|
||||
|
||||
initPage = () => {
|
||||
api.getTree(this.moduleName).then(res => {
|
||||
if (res.code === 200) {
|
||||
// this.containerInitFinished = {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,202 @@
|
|||
import {
|
||||
observable,
|
||||
action,
|
||||
computed
|
||||
} from 'mobx';
|
||||
import {
|
||||
WeaForm
|
||||
} from 'comsMobx';
|
||||
|
||||
import * as API from '../apis/importDialog';
|
||||
import * as Util from '../util/index';
|
||||
import {
|
||||
validate,
|
||||
getFormParamValue
|
||||
} from '../util'
|
||||
import {
|
||||
message,
|
||||
Modal,
|
||||
Button
|
||||
} from 'antd';
|
||||
import {
|
||||
WeaTableNew
|
||||
} from 'comsMobx'
|
||||
import * as mobx from 'mobx';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import {
|
||||
has
|
||||
} from 'lodash';
|
||||
const toJS = mobx.toJS;
|
||||
const {
|
||||
TableStore
|
||||
} = WeaTableNew;
|
||||
const confirm = Modal.confirm;
|
||||
import {
|
||||
i18n
|
||||
} from '../public/i18n';
|
||||
import {
|
||||
findIndex
|
||||
} from 'lodash';
|
||||
|
||||
export class ImportDialogStore {
|
||||
|
||||
@observable importVisible = false;
|
||||
@observable importModule = ''; //导入模块
|
||||
|
||||
|
||||
|
||||
/********************* importDialog *********************/
|
||||
|
||||
steps = [
|
||||
{ title: '上传文件'},
|
||||
{ title: '导入结果' }
|
||||
];
|
||||
|
||||
@observable importType = '';
|
||||
@observable current = 0;
|
||||
@observable buttonTitle = '';
|
||||
@observable pvisable = false;
|
||||
|
||||
|
||||
/********************* importContent *********************/
|
||||
@observable data = [];
|
||||
|
||||
|
||||
@observable condition = [];
|
||||
@observable filelist = []; //文件信息
|
||||
@observable excelfile = ''; //文件id
|
||||
@observable templetName = "导入模板";
|
||||
@observable percent = 0;
|
||||
@observable failnum = 0; //失败数量
|
||||
@observable succnum = 0; //成功数量
|
||||
@observable importResultTip = ''; //导入结果提示
|
||||
@observable importResultStore = new TableStore();
|
||||
@observable importStatus = 'importing'; //导入状态
|
||||
@observable loading = true;
|
||||
@observable date = '';
|
||||
@observable pId = '';//导入记录
|
||||
|
||||
interval
|
||||
|
||||
@action("获取导入表单") getImportForm() {
|
||||
|
||||
const params = {
|
||||
importModule: this.importModule,
|
||||
}
|
||||
API.getImportForm(params).then(res => {
|
||||
if (res.code == 200) {
|
||||
this.condition = res.data.condition;
|
||||
} else {
|
||||
message.warning(res.msg);
|
||||
}
|
||||
}, error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
}
|
||||
|
||||
@action("开始导入") startImport() {
|
||||
if(this.filelist.length == 0) {
|
||||
message.error("请上传需要导入的文件!")
|
||||
this.current = this.current - 1;
|
||||
return;
|
||||
}
|
||||
this.pvisable = true;
|
||||
//导入文件提交
|
||||
let params = {
|
||||
importModule: this.importModule,
|
||||
excelfile:this.excelfile
|
||||
}
|
||||
if (this.otherParams != null) {
|
||||
Object.assign(params, {
|
||||
otherParams: JSON.stringify(this.otherParams)
|
||||
})
|
||||
}
|
||||
this.doImport(params)
|
||||
this.interval = setInterval(() => this.getImportProcess(), 200);
|
||||
|
||||
}
|
||||
|
||||
@action("文件提交") doImport(params) {
|
||||
API.saveImport(params).then(res => {
|
||||
if(res.code == 200) {
|
||||
this.pId = res.data.pId;
|
||||
}else {
|
||||
clearInterval(this.interval);
|
||||
this.pvisable = false;
|
||||
message.error("文件导入失败")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
@action("获取导入进度") getImportProcess() {
|
||||
if(this.pId != '') {
|
||||
clearInterval(this.interval);
|
||||
this.percent = 100;
|
||||
const _this = this;
|
||||
setTimeout(function(){
|
||||
_this.pvisable = false;
|
||||
_this.getImportResult();
|
||||
},1000)
|
||||
}else {
|
||||
//调用导入进度api
|
||||
let max = 95;
|
||||
let min = this.percent;
|
||||
if(this.percent < max) {
|
||||
this.percent = Math.floor(Math.random() * (max - min)) + min;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@action("获取导入结果") getImportResult() {
|
||||
let params = {
|
||||
pId:this.pId
|
||||
}
|
||||
API.getImportResult(params).then((res) => {
|
||||
if (res.code == 200) {
|
||||
this.failnum = res.data.failnum;
|
||||
this.succnum = res.data.succnum;
|
||||
this.importStatus = res.data.importStatus;
|
||||
if (this.failnum > 0) {
|
||||
let info = i18n.label.importResourceResultInfo();
|
||||
info = info.replace('{rownum}', this.succnum + this.failnum).replace('{succnum}', this.succnum);
|
||||
this.importResultTip = info;
|
||||
this.importResultStore.getDatas(res.data.datas, 1);
|
||||
} else {
|
||||
let info = i18n.label.importResourceResultInfo1();
|
||||
info = info.replace('{rownum}', this.succnum);
|
||||
this.importResultTip = info;
|
||||
}
|
||||
} else {
|
||||
message.warning(res.msg);
|
||||
}
|
||||
}, error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
}
|
||||
|
||||
@action init(){
|
||||
this.filelist = [];
|
||||
this.excelfile = '';
|
||||
this.importVisible = false;
|
||||
this.percent = 0;
|
||||
this.failnum = 0;
|
||||
this.succnum = 0;
|
||||
this.importResultTip = '';
|
||||
this.importResultStore = new TableStore();
|
||||
this.importStatus = 'importing';
|
||||
this.data = [];
|
||||
this.condition = [];
|
||||
this.pId = '';
|
||||
}
|
||||
|
||||
|
||||
setExcelfile(field) {
|
||||
this.excelfile = field;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -22,8 +22,9 @@ import {DatasImportStore} from "./datasImport";
|
|||
import {HrmImportResource} from "./importresource";
|
||||
import {HrmImportCommon} from "./importCommon";
|
||||
import {HrmBasicDataImport} from "./import";
|
||||
import {newImportStore} from "./newImport";
|
||||
import {ResourceBasicInfoStore} from "./reserouseBasicInfo"
|
||||
import {NewImportStore} from "./newImport";
|
||||
import {ResourceBasicInfoStore} from "./reserouseBasicInfo";
|
||||
import {ImportDialogStore} from "./importDialog";
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
|
@ -51,6 +52,7 @@ module.exports = {
|
|||
hrmImportResource:new HrmImportResource(),
|
||||
hrmImportCommon:new HrmImportCommon(),
|
||||
hrmBasicDataImport:new HrmBasicDataImport(),
|
||||
newImport: new newImportStore(),
|
||||
newImport: new NewImportStore(),
|
||||
resourceBasicInfo: new ResourceBasicInfoStore(),
|
||||
importDialog: new ImportDialogStore()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import {
|
|||
findIndex
|
||||
} from 'lodash';
|
||||
|
||||
export class newImportStore {
|
||||
export class NewImportStore {
|
||||
|
||||
@observable hasRight = '';
|
||||
@action getHasRight(){
|
||||
|
|
|
|||
|
|
@ -0,0 +1,231 @@
|
|||
import { observable, action, toJS } from "mobx";
|
||||
import isEmpty from 'lodash/isEmpty'
|
||||
import { Modal, message } from "antd";
|
||||
import { i18n } from "../public/i18n";
|
||||
import forEach from 'lodash/forEach'
|
||||
import * as Api from '../apis/resourceCard'; // 引入API接口文件
|
||||
|
||||
|
||||
export class ResourceExtendStore {
|
||||
@observable form = new WeaForm();
|
||||
@observable tableInfo = []
|
||||
@observable conditions = [];
|
||||
@observable isEditor = false;
|
||||
@observable isNew = true;
|
||||
@observable loading = true;
|
||||
@observable tabInfo = [];
|
||||
@observable selectedKey = '0';
|
||||
@observable detailSelectedKey = '0';
|
||||
@observable topTab = [];
|
||||
@observable buttons = {};
|
||||
@observable id = ''; //人员id
|
||||
@observable date = '';
|
||||
@observable personalEditTables;
|
||||
@observable tabkey = '0'
|
||||
|
||||
|
||||
@observable selectedRowKeys = [];
|
||||
@observable selectedRows = [];
|
||||
|
||||
@action onRowSelect = (keys) => {
|
||||
this.setSelectedRowKeys(keys);
|
||||
}
|
||||
|
||||
@action setSelectedRowKeys = (keys) => {
|
||||
this.selectedRowKeys = keys;
|
||||
}
|
||||
|
||||
|
||||
@action
|
||||
edit = () => {
|
||||
this.isEditor = true;
|
||||
this.getData();
|
||||
this.getTabInfo();
|
||||
this.detailSelectedKey = '0'
|
||||
}
|
||||
|
||||
init = () => {
|
||||
this.detailSelectedKey = '0'
|
||||
this.isEditor = false;
|
||||
}
|
||||
|
||||
save = () => {
|
||||
if (this.loading)
|
||||
return;
|
||||
this.form.validateForm().then(f => {
|
||||
if (f.isValid) {
|
||||
this.loading = true;
|
||||
if (this.personalEditTables) {
|
||||
const targetDatas = this.tableInfo[this.detailSelectedKey].tabinfo.datas,
|
||||
isPass = (targetDatas.length > 0) ? this.personalEditTables.refs.edit.doRequiredCheck().pass : true
|
||||
if (isPass) {
|
||||
this.editResource()
|
||||
} else {
|
||||
this.loading = false;
|
||||
}
|
||||
} else {
|
||||
this.editResource();
|
||||
}
|
||||
} else {
|
||||
f.showErrors();
|
||||
this.setDate(new Date());
|
||||
this.loading = false;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
editResource = () => {
|
||||
let pDatas = this.form.getFormParams();
|
||||
Api.editResource({ ...{
|
||||
id: this.id
|
||||
},
|
||||
...pDatas,
|
||||
...this.getTableEditParams()
|
||||
}).then(data => {
|
||||
if (data.code == 200) {
|
||||
message.success(i18n.message.saveSuccess());
|
||||
this.init();
|
||||
this.getData();
|
||||
this.selectedRowKeys = [];
|
||||
} else {
|
||||
message.warning(data.message);
|
||||
}
|
||||
this.loading = false;
|
||||
}, error => {
|
||||
message.warning(error.message);
|
||||
this.loading = false;
|
||||
})
|
||||
}
|
||||
|
||||
getTableEditParams = () => {
|
||||
const params = {};
|
||||
this.tableInfo && this.tableInfo.forEach(t => {
|
||||
t.tabinfo.datas = t.tabinfo.datas || [];
|
||||
params[t.tabinfo.rownum] = t.tabinfo.datas.length;
|
||||
t.tabinfo && t.tabinfo.datas && t.tabinfo.datas.forEach((item, index) => {
|
||||
!isEmpty(item) && forEach(item, (value, key) => {
|
||||
Object.assign(params, {
|
||||
[`${key}_${index}`]: value
|
||||
});
|
||||
})
|
||||
})
|
||||
})
|
||||
return params
|
||||
}
|
||||
|
||||
|
||||
|
||||
getData = () => {
|
||||
this.setLoading(true);
|
||||
let params = {
|
||||
viewAttr: this.isEditor ? 2 : 1,
|
||||
id: this.id,
|
||||
viewCondition:this.selectedKey
|
||||
}
|
||||
Api.getResourceExtendForm(params).then((res) => {
|
||||
if (res.code === 200) {
|
||||
res.data.result.conditions && this.form.initFormFields(res.data.result.conditions);
|
||||
res.data.result.conditions && this.setConditions(res.data.result.conditions);
|
||||
this.tableInfo = this.handleTable(res.data.result.tables);
|
||||
this.getTabInfo();
|
||||
res.data.result.buttons && this.setButtons(res.data.result.buttons);
|
||||
res.data.result.tabInfo && this.setTopTab(res.data.result.tabInfo);
|
||||
this.isEditor && this.getSelectedRows();
|
||||
this.setLoading(false);
|
||||
|
||||
} else {
|
||||
message.warning(res.msg);
|
||||
}
|
||||
}, error => {
|
||||
message.warning(error.msg);
|
||||
})
|
||||
}
|
||||
|
||||
handleTable = (datas) => {
|
||||
return datas && datas.map(data => {
|
||||
const { tabinfo: { columns } } = data;
|
||||
const length = columns.length;
|
||||
columns.map(c => {
|
||||
c.width = `${95 / length}%`
|
||||
})
|
||||
return data
|
||||
})
|
||||
}
|
||||
|
||||
getTabInfo = () => {
|
||||
this.tabInfo = [];
|
||||
this.tableInfo && this.tableInfo.forEach((c, idx) => {
|
||||
if (!c.hide) {
|
||||
this.tabInfo.push({
|
||||
key: `${idx}`,
|
||||
title: c.tabname,
|
||||
})
|
||||
}
|
||||
})
|
||||
//if (!isEmpty(this.tabInfo)) this.tabkey = this.tabInfo[0].key;
|
||||
if (!isEmpty(this.tabInfo)) this.detailSelectedKey = this.tabInfo[0].key;
|
||||
}
|
||||
|
||||
setLoading(val) {
|
||||
this.loading = val;
|
||||
}
|
||||
|
||||
|
||||
updateTabKey = (key) => {
|
||||
this.tabKey = key;
|
||||
}
|
||||
|
||||
updateDetailSelectedKey =(key) => {
|
||||
this.detailSelectedKey = key;
|
||||
}
|
||||
|
||||
updateTableInfo = (data) => {
|
||||
this.tableInfo = data
|
||||
}
|
||||
|
||||
setSelectedKey = (key) => {
|
||||
this.selectedKey = key;
|
||||
}
|
||||
|
||||
getSelectedRows = () => {
|
||||
const selectedRows = [];
|
||||
this.tableInfo.forEach(t => {
|
||||
const singleTableRows = [];
|
||||
t.tabinfo.datas.forEach((data, i) => {
|
||||
if (data.viewAttr === 1) {
|
||||
singleTableRows.push(i);
|
||||
}
|
||||
});
|
||||
selectedRows.push(singleTableRows);
|
||||
})
|
||||
this.selectedRows = selectedRows;
|
||||
}
|
||||
|
||||
|
||||
setTopTab(topTab) {
|
||||
this.topTab = topTab;
|
||||
}
|
||||
|
||||
changeData(key) {
|
||||
this.setSelectedKey(key);
|
||||
this.getData();
|
||||
}
|
||||
|
||||
setId(id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
setPersonalEditTables = (ref) => {
|
||||
this.personalEditTables = ref;
|
||||
}
|
||||
|
||||
setConditions(conditions) {
|
||||
this.conditions = conditions;
|
||||
}
|
||||
|
||||
setButtons(buttons) {
|
||||
this.buttons = buttons;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue