import { observable, action, toJS } from "mobx"; import { WeaForm } from "comsMobx"; import isEmpty from 'lodash/isEmpty' import { WeaTableNew } from "comsMobx"; import { Modal, message } from "antd"; import { i18n } from "../public/i18n"; export class CompanyExtendStore { @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 date; @observable personalEditTables; @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.tabkey = '0'; } init = () => { //this.tabkey = '0'; this.isEditor = false; } save = () => { if (this.loading) return; this.loading = true; this.form.validateForm().then(f => { if (f.isValid) { if (this.personalEditTables) { // const targetDatas = this.tableInfo[this.tabkey].tabinfo.datas, // isPass = (targetDatas.length > 0) ? this.personalEditTables.refs.edit.doRequiredCheck().pass : true let isPass = 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({ ...{ // operation: 'editpersonalinfo', // id: this.hrmId // }, // ...pDatas, // ...this.getTableEditParams() // }). // then(data => { // if (data.status == '1') { // 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 = (params) => { this.loading = true; params = { ...params, viewAttr:this.isEditor ? 2 : 1 } let data = { "result": { "tables": [ { "tabinfo": { "rownum": "rownum", "columns": [ { "com": [ { "key": "member", "label": "", "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "otherParams": { "inputType": "multilang", "isBase64": true }, "quickSearch": false, "type": "INPUT", "viewAttr": 1, "width": "80%" } ], "dataIndex": "member", "width": "80%%", "title": "成员", "key": "member" }, { "com": [ { "key": "title", "label": "", "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "otherParams": { "inputType": "multilang", "isBase64": true }, "quickSearch": false, "type": "INPUT", "viewAttr": 1, "width": "80%" } ], "dataIndex": "title", "width": "80%%", "title": "称谓", "key": "title" }, { "com": [ { "key": "company", "label": "", "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "otherParams": { "inputType": "multilang", "isBase64": true }, "quickSearch": false, "type": "INPUT", "viewAttr": 1, "width": "80%" } ], "dataIndex": "company", "width": "80%%", "title": "工作单位", "key": "company" }, { "com": [ { "key": "jobtitle", "label": "", "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "otherParams": { "inputType": "multilang", "isBase64": true }, "quickSearch": false, "type": "INPUT", "viewAttr": 1, "width": "80%" } ], "dataIndex": "jobtitle", "width": "80%%", "title": "职务", "key": "jobtitle" }, { "com": [ { "key": "address", "label": "", "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "otherParams": { "inputType": "multilang", "isBase64": true }, "quickSearch": false, "type": "INPUT", "viewAttr": 1, "width": "80%" } ], "dataIndex": "address", "width": "80%%", "title": "地址", "key": "address" } ], "datas": [ { "address": "", "jobtitle": "1", "member": "1", "company": "1", "title": "1" } ] }, "hide": false, "tabname": "家庭情况" } ], "buttons": { "hasSave": true, "hasEdit": true }, "id": "22", "conditions": [ { "hide": false, "title": "个人信息", "defaultshow": true, "items": [ { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "DATEPICKER", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "birthday" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "出生日期", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "value": "", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "folk" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "民族", "labelcol": 6, "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 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "nativeplace" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "籍贯", "labelcol": 6, "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 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "regresidentplace" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "户口", "labelcol": 6, "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 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "certificatenum" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "身份证号码", "labelcol": 6, "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 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "SELECT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "maritalstatus" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "key": "0", "label": "婚姻状况", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "options": [ { "disabled": false, "key": "0", "selected": true, "showname": "未婚", "visible": true }, { "disabled": false, "key": "1", "selected": false, "showname": "已婚", "visible": true }, { "disabled": false, "key": "2", "selected": false, "showname": "离异", "visible": true } ], "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "value": "0", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "policy" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "政治面貌", "labelcol": 6, "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 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "DATEPICKER", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "bememberdate" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "入团日期", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "value": "", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "DATEPICKER", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "bepartydate" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "入党日期", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "value": "", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "SELECT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "islabouunion" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "key": "1", "label": "工会会员", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "options": [ { "disabled": false, "key": "1", "selected": true, "showname": "是", "visible": true }, { "disabled": false, "key": "0", "selected": false, "showname": "否", "visible": true } ], "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "value": "1", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "browserConditionParam": { "asynLoadAll": false, "checkStrictly": true, "completeParams": {}, "conditionDataParams": {}, "dataParams": {}, "defaultCheckStrictly": true, "defaultExpandedLevel": 0, "destDataParams": {}, "expandfirstnode": false, "handleTypes": "", "hasAddBtn": false, "hasAdvanceSerach": true, "hasBorder": false, "hasTabConditions": false, "hideAdvanceSearch": false, "hideVirtualOrg": false, "icon": "icon-coms-hrm", "iconBgcolor": "#217346", "idSeparator": ",", "isAutoComplete": 1, "isDetail": 0, "isMultCheckbox": false, "isSingle": true, "linkUrl": "/spa/hrm/engine.html#/hrmengine/edu?id=", "mobileLinkUrl": "", "noOperate": true, "otherParams": {}, "pageSize": 10, "quickSearchName": "", "replaceDatas": [], "replaceNotCtrl": false, "scrollx": false, "searchParams": {}, "searchPlaceholder": "", "showCheckStrictly": true, "title": "学历", "type": "30", "viewAttr": 1 }, "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "BROWSER", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "educationlevel" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "学历", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "degree" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "学位", "labelcol": 6, "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 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "SELECT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "healthinfo" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "key": "0", "label": "健康状况", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "options": [ { "disabled": false, "key": "0", "selected": true, "showname": "优秀", "visible": true }, { "disabled": false, "key": "1", "selected": false, "showname": "良好", "visible": true }, { "disabled": false, "key": "2", "selected": false, "showname": "一般", "visible": true }, { "disabled": false, "key": "3", "selected": false, "showname": "较差", "visible": true } ], "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "value": "0", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUTNUMBER", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "height" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "身高(cm)", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "value": "0", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUTNUMBER", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "weight" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "体重(kg)", "labelcol": 6, "length": 0, "maxFilesNumber": 0, "maxUploadSize": 0, "multiSelection": false, "multiple": false, "precision": 0, "secretLimit": false, "showOrder": 0, "showTime": false, "stringLength": 0, "supportCancel": false, "tipPosition": "bottom", "value": "0", "valueList": [], "viewAttr": 1 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "residentplace" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "现居住地", "labelcol": 6, "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 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "homeaddress" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "家庭联系方式", "labelcol": 6, "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 }, { "belong": "PC", "checkbox": false, "checkboxValue": false, "colSpan": 2, "conditionType": "INPUT", "dateGroup": false, "defaultDisplayInBar": false, "detailtype": 1, "domkey": [ "tempresidentnumber" ], "entSearch": false, "fieldcol": 12, "hasBorder": false, "helpfulTipProps": {}, "hide": false, "isBase64": false, "isQuickSearch": false, "label": "暂住证号码", "labelcol": 6, "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 } ] } ], "topTab": [ { "title": "总部信息", "viewCondition": "1" } ] } } // API.getResourceCard(params).then((data) => { // this.loading = false; // this.form.initFormFields(data.result.conditions); // this.conditions = data.result.conditions; // this.tableInfo = this.handleTable(data.result.tables); // this.getTabInfo(); // this.buttons = data.result.buttons; // this.hrmId = data.result.id; // this.isEditor && this.getSelectedRows(); // }) this.loading = false; this.form.initFormFields(data.result.conditions); this.conditions = data.result.conditions; this.tableInfo = this.handleTable(data.result.tables); this.getTabInfo(); this.buttons = data.result.buttons; this.setTopTab(data.result.topTab); } 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; } setLoading(val) { this.loading(false); } updateDetailSelectedKey = (key) => { this.detailSelectedKey = key; } 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); } }