trunk/pc4mobx/organization/stores/group.js

458 lines
15 KiB
JavaScript

import {
observable,
action
} from 'mobx';
import * as mobx from 'mobx';
import * as Api from '../apis/group'; // 引入API接口文件
import {
WeaForm
} from 'comsMobx';
import {
Modal,
message,
} from 'antd'
import {
i18n
} from '../public/i18n';
const toJS = mobx.toJS;
export class GroupStore {
@observable topMenu = []
@observable rightMenu = [];
@observable condition = [];
@observable groupCondition = [];
@observable isEdit = true;
@observable form = new WeaForm();
@observable form1 = new WeaForm();
@observable nEdialogTitle = '';
@observable visible = false;
@observable dialogLoading = true;
@observable selectedKey = 1;
@observable topTab = [];
@observable date = '';
@action
getGroupForm() {
let params = {
viewattr: 1
}
//api
let condition = [
{
"title": "总部信息",
"defaultshow": true,
"items": [
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companyname"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "总部名称",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"rules": "required|string",
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "E9TEST",
"valueList": [],
"viewAttr": 1
},
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companydesc"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "总部全称",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"rules": "required|string",
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "E9TEST",
"valueList": [],
"viewAttr": 1
},
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companyweb"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "公司网站",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "",
"valueList": [],
"viewAttr": 1
}
]
}
]
this.setGroupCondition(condition);
this.form1.initFormFields(condition);
this.getTabInfo();
}
getTabInfo() {
// Api.getTabInfo().then(res => {
// if (res.code === 200) {
// res.data.topTabs && this.setTopTab(res.data.topTabs);
// res.data.topTabCount && this.setTopTabCount(res.data.topTabCount);
// } else {
// message.warning(res.msg);
// }
// }, error => {
// message.warning(error.msg);
// })
const topTab = [
{
"title": "总部信息",
"viewCondition": "1"
}
]
this.setTopTab(topTab)
}
@action
getHasRight() {
const rightMenu = [
{
"isTop": "1",
"menuFun": "doEdit",
"menuIcon": "icon-coms-edit",
"menuName": "编辑",
"type": "BTN_EDIT"
}
]
const topMenu = [
{
"isTop": "1",
"menuFun": "doEdit",
"menuIcon": "icon-coms-edit",
"menuName": "编辑",
"type": "BTN_EDIT"
}
]
this.setTopMenu(topMenu);
this.setRightMenu(rightMenu);
// Api.getHasRight().then(res => {
// if (res.code === 200) {
// res.data.rightMenu && this.setRightMenu(res.data.rightMenu);
// res.data.topMenu && this.setTopMenu(res.data.topMenu);
// } else {
// message.warning(res.msg);
// }
// }, error => {
// message.warning(error.msg);
// })
}
edit() {
// let params = { ...this.form.getFormParams(), id: this.schemeId };
// this.form.validateForm().then(f => {
// if (f.isValid) {
// Api.edit(params).then(response => {
// return response.json()
// }).then(data => {
// if (data.code === 200) {
// message.success(data.msg);
// this.getTableInfo();
// this.setVisible(false);
// } else {
// message.warning(data.msg);
// }
// }).catch(error => {
// message.warning(error.msg);
// })
// } else {
// f.showErrors();
// this.setDate(new Date());
// }
// });
}
getForm() {
let params = {
viewattr: 2
}
const condition = [
{
"title": "总部信息",
"defaultshow": true,
"items": [
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companyname"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "总部名称",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"rules": "required|string",
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "E9TEST",
"valueList": [],
"viewAttr": 3
},
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companydesc"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "总部全称",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"rules": "required|string",
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "E9TEST",
"valueList": [],
"viewAttr": 3
},
{
"belong": "PC",
"checkbox": false,
"checkboxValue": false,
"colSpan": 2,
"conditionType": "INPUT",
"dateGroup": false,
"defaultDisplayInBar": false,
"detailtype": 1,
"domkey": [
"companyweb"
],
"entSearch": false,
"fieldcol": 16,
"hasBorder": false,
"helpfulTipProps": {},
"hide": false,
"isBase64": false,
"isQuickSearch": false,
"label": "公司网站",
"labelcol": 8,
"length": 0,
"maxFilesNumber": 0,
"maxUploadSize": 0,
"multiSelection": false,
"multiple": false,
"otherParams": {
"inputType": "multilang",
"isBase64": true
},
"precision": 0,
"secretLimit": false,
"showOrder": 0,
"showTime": false,
"stringLength": 0,
"supportCancel": false,
"tipPosition": "bottom",
"value": "",
"valueList": [],
"viewAttr": 2
}
]
}
]
this.setCondition(condition);
this.form.initFormFields(condition);
this.setDialogLoadingStatus(false);
// this.setDialogLoadingStatus(true);
// Api.getSchemeForm(params).then(res => {
// if (res.code === 200) {
// this.setDialogLoadingStatus(false);
// res.data.condition && this.setCondition(res.data.condition);
// res.data.condition && this.form.initFormFields(res.data.condition);
// } else {
// message.warning(res.msg);
// }
// }, error => {
// message.warning(error.msg);
// })
}
changeData(key) {
this.setSelectedKey(key);
}
setVisible(bool) {
this.visible = bool;
}
setGroupCondition(groupCondition) {
this.groupCondition = groupCondition
}
setCondition(condition) {
this.condition = condition;
}
setTopMenu(topMenu) {
this.topMenu = topMenu;
}
setRightMenu(rightMenu) {
this.rightMenu = rightMenu;
}
setTopTab(topTab) {
this.topTab = topTab;
}
setNeDialogTitle(title) {
this.nEdialogTitle = title;
}
setDialogLoadingStatus(bool) {
this.dialogLoading = bool;
}
}