+ hasRight &&
{children}
)
diff --git a/pc4mobx/organization/components/resource/ResourceCard.js b/pc4mobx/organization/components/resource/ResourceCard.js
new file mode 100644
index 0000000..e69de29
diff --git a/pc4mobx/organization/components/staff/Staff.js b/pc4mobx/organization/components/staff/Staff.js
index 37fbfd0..5a0ce31 100644
--- a/pc4mobx/organization/components/staff/Staff.js
+++ b/pc4mobx/organization/components/staff/Staff.js
@@ -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 &&
}
)
}
diff --git a/pc4mobx/organization/stores/fieldDefined.js b/pc4mobx/organization/stores/fieldDefined.js
index 037e602..d67de8a 100644
--- a/pc4mobx/organization/stores/fieldDefined.js
+++ b/pc4mobx/organization/stores/fieldDefined.js
@@ -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 = {
diff --git a/pc4mobx/organization/stores/importDialog.js b/pc4mobx/organization/stores/importDialog.js
new file mode 100644
index 0000000..210967c
--- /dev/null
+++ b/pc4mobx/organization/stores/importDialog.js
@@ -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;
+ }
+
+
+
+ }
\ No newline at end of file
diff --git a/pc4mobx/organization/stores/index.js b/pc4mobx/organization/stores/index.js
index 9648672..5c00af0 100644
--- a/pc4mobx/organization/stores/index.js
+++ b/pc4mobx/organization/stores/index.js
@@ -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()
};
diff --git a/pc4mobx/organization/stores/newImport.js b/pc4mobx/organization/stores/newImport.js
index 220dd76..8fe6448 100644
--- a/pc4mobx/organization/stores/newImport.js
+++ b/pc4mobx/organization/stores/newImport.js
@@ -38,7 +38,7 @@ import {
findIndex
} from 'lodash';
-export class newImportStore {
+export class NewImportStore {
@observable hasRight = '';
@action getHasRight(){
diff --git a/pc4mobx/organization/stores/resourceCard.js b/pc4mobx/organization/stores/resourceCard.js
new file mode 100644
index 0000000..de4b4a6
--- /dev/null
+++ b/pc4mobx/organization/stores/resourceCard.js
@@ -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;
+ }
+
+
+}