2022-06-20 17:08:10 +08:00
|
|
|
import {
|
|
|
|
|
observable,
|
|
|
|
|
action
|
|
|
|
|
} from 'mobx';
|
|
|
|
|
import * as mobx from 'mobx';
|
|
|
|
|
import * as Api from '../apis/resource'; // 引入API接口文件
|
|
|
|
|
import {
|
|
|
|
|
WeaForm
|
|
|
|
|
} from 'comsMobx';
|
|
|
|
|
import {
|
|
|
|
|
WeaTableNew
|
|
|
|
|
} from 'comsMobx';
|
|
|
|
|
import {
|
|
|
|
|
Modal,
|
|
|
|
|
message,
|
|
|
|
|
} from 'antd'
|
|
|
|
|
import {
|
|
|
|
|
i18n
|
|
|
|
|
} from '../public/i18n';
|
2022-06-29 18:37:25 +08:00
|
|
|
import {getSecondPath} from '../util/index'
|
2022-06-20 17:08:10 +08:00
|
|
|
|
|
|
|
|
const toJS = mobx.toJS;
|
|
|
|
|
const {
|
|
|
|
|
TableStore
|
|
|
|
|
} = WeaTableNew;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export class ResourceStore {
|
|
|
|
|
@observable tableStore = new TableStore();
|
|
|
|
|
@observable topMenu = []
|
|
|
|
|
@observable rightMenu = [];
|
|
|
|
|
@observable condition = [];
|
|
|
|
|
@observable searchCondition = [];
|
|
|
|
|
@observable isEdit = true;
|
|
|
|
|
@observable isNew = true;
|
|
|
|
|
@observable isPanelShow = false; //高级搜索面板
|
|
|
|
|
@observable form2 = new WeaForm();
|
|
|
|
|
@observable form = new WeaForm();
|
2022-10-21 17:51:28 +08:00
|
|
|
@observable lastName = '';
|
2022-06-22 10:28:25 +08:00
|
|
|
@observable conditionNum = 8;
|
2022-06-20 17:08:10 +08:00
|
|
|
@observable ids = ''; //选择行id
|
|
|
|
|
@observable searchConditionLoading = true;
|
|
|
|
|
@observable nEdialogTitle = '';
|
|
|
|
|
@observable visible = false;
|
|
|
|
|
@observable dialogLoading = true;
|
|
|
|
|
@observable schemeId = '';
|
|
|
|
|
@observable date = '';
|
|
|
|
|
|
|
|
|
|
@observable defaultShowLeft = true;
|
|
|
|
|
@observable companysId = 1
|
2022-10-21 17:51:28 +08:00
|
|
|
@observable hasRight = '';
|
|
|
|
|
|
|
|
|
|
@observable selectTreeNodeInfo;
|
2022-06-20 17:08:10 +08:00
|
|
|
|
|
|
|
|
|
2022-10-21 17:51:28 +08:00
|
|
|
@action getTableInfo() {
|
2022-06-20 17:08:10 +08:00
|
|
|
let params;
|
|
|
|
|
this.tableStore = new TableStore();
|
|
|
|
|
if (this.isEmptyObject(this.form2.getFormParams())) {
|
|
|
|
|
params = {
|
2022-10-21 17:51:28 +08:00
|
|
|
...this.selectTreeNodeInfo,
|
|
|
|
|
lastName: this.lastName
|
2022-06-20 17:08:10 +08:00
|
|
|
};
|
|
|
|
|
} else {
|
|
|
|
|
params = {
|
2022-10-21 17:51:28 +08:00
|
|
|
...this.selectTreeNodeInfo,
|
2022-06-20 17:08:10 +08:00
|
|
|
...this.form2.getFormParams()
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
Api.getSearchList(params).then(res => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
res.data.datas && this.tableStore.getDatas(res.data.datas, 1);
|
|
|
|
|
} else {
|
|
|
|
|
message.warning(res.msg);
|
|
|
|
|
}
|
|
|
|
|
}, error => {
|
|
|
|
|
message.warning(error.msg);
|
|
|
|
|
})
|
2022-10-21 17:51:28 +08:00
|
|
|
}
|
2022-06-20 17:08:10 +08:00
|
|
|
|
2022-10-21 17:51:28 +08:00
|
|
|
@action("nodetree事件") doSearch(params) {
|
|
|
|
|
this.selectTreeNodeInfo = params;
|
|
|
|
|
this.getTableInfo();
|
2022-06-20 17:08:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
save() {
|
|
|
|
|
let params = {
|
|
|
|
|
...this.form.getFormParams()
|
|
|
|
|
};
|
|
|
|
|
this.form.validateForm().then(f => {
|
|
|
|
|
if (f.isValid) {
|
|
|
|
|
Api.add(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 = this.isNew ? {} : {
|
|
|
|
|
id: this.schemeId
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getSearchCondition() {
|
|
|
|
|
this.setScLoadingStatus(false);
|
|
|
|
|
Api.getAdvanceSearchCondition().then(res => {
|
|
|
|
|
if (res.code === 200) {
|
|
|
|
|
this.setScLoadingStatus(false);
|
|
|
|
|
res.data.conditions && this.setSearchCondition(res.data.conditions);
|
|
|
|
|
res.data.conditions && this.form2.initFormFields(res.data.conditions);
|
|
|
|
|
} else {
|
|
|
|
|
message.warning(res.msg);
|
|
|
|
|
}
|
|
|
|
|
}, error => {
|
|
|
|
|
message.warning(error.msg);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-10-21 17:51:28 +08:00
|
|
|
@action getHasRight() {
|
2022-06-20 17:08:10 +08:00
|
|
|
Api.getHasRight().then(res => {
|
|
|
|
|
if (res.code === 200) {
|
2022-10-21 17:51:28 +08:00
|
|
|
this.setHasRight(res.data.hasRight);
|
2022-06-20 17:08:10 +08:00
|
|
|
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);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-29 18:37:25 +08:00
|
|
|
@action export(){
|
|
|
|
|
const params = {
|
|
|
|
|
...this.form.getFormParams()
|
|
|
|
|
}
|
|
|
|
|
Api.exportResource(toJS(this.tableStore.selectedRowKeys).toString());
|
2022-06-30 17:14:04 +08:00
|
|
|
this.tableStore.selectedRowKeys = [];
|
2022-06-29 18:37:25 +08:00
|
|
|
}
|
|
|
|
|
|
2022-06-20 17:08:10 +08:00
|
|
|
updateFields(val) {
|
|
|
|
|
this.form2.updateFields({
|
2022-10-21 17:51:28 +08:00
|
|
|
lastName: {
|
2022-06-20 17:08:10 +08:00
|
|
|
value: val
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setSearchCondition(condition) {
|
|
|
|
|
this.searchCondition = condition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setScLoadingStatus(bool) {
|
|
|
|
|
this.searchConditionLoading = bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setPanelStatus(bool) {
|
|
|
|
|
this.isPanelShow = bool;
|
|
|
|
|
bool && this.getSearchCondition();
|
|
|
|
|
if (!bool) {
|
|
|
|
|
this.scLoadingReset();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-21 17:51:28 +08:00
|
|
|
setLastName(val) {
|
|
|
|
|
this.lastName = val;
|
2022-06-20 17:08:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
isEmptyObject(obj) {
|
|
|
|
|
for (let key in obj) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setIds(ids) {
|
|
|
|
|
this.ids = ids;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
scLoadingReset() {
|
|
|
|
|
this.searchConditionLoading = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
formReset() {
|
|
|
|
|
this.form = new WeaForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dialogLoadingReset() {
|
|
|
|
|
this.dialogLoading = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setVisible(bool) {
|
|
|
|
|
this.visible = bool;
|
|
|
|
|
this.formReset();
|
|
|
|
|
!bool && this.dialogLoadingReset();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setDialogLoadingStatus(bool) {
|
|
|
|
|
this.dialogLoading = bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setNeDialogTitle(title) {
|
|
|
|
|
this.nEdialogTitle = title;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setIsNew(bool) {
|
|
|
|
|
this.isNew = bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setCondition(condition) {
|
|
|
|
|
this.condition = condition;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setSchemeId(schemeId) {
|
|
|
|
|
this.schemeId = schemeId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setDate(date) {
|
|
|
|
|
this.date = date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setTopMenu(topMenu) {
|
|
|
|
|
this.topMenu = topMenu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setRightMenu(rightMenu) {
|
|
|
|
|
this.rightMenu = rightMenu;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setHasRight(bool) {
|
|
|
|
|
this.hasRight = bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|