fmui-base 2.3.5 → 2.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  ---npm publish
4
4
 
5
5
  ## 更新日志
6
+ - 2.3.6:待办表单支持切换组织
6
7
  - 2.3.5:联动字段保存后被清空
7
8
  - 2.3.4:移动端表单下拉单选和按钮按钮组件样式更换
8
9
  - 2.3.3:移动端表单下拉单选和按钮按钮组件样式更换
package/lib/db/db.js CHANGED
@@ -1111,6 +1111,35 @@ context.create('FlowModuleAPI', {
1111
1111
  // content: <Loading />
1112
1112
  // });
1113
1113
  }
1114
+ },
1115
+ getUserSetInfo: {
1116
+ mockUrl: 'query/getUserSetInfo.json',
1117
+ url: _variables2.default.URLS.getUserSetInfo,
1118
+ method: 'GET',
1119
+ header: {
1120
+ Authorization: 'Bearer ' + getLoginUserInfo().token
1121
+ },
1122
+ willFetch: function willFetch() {}
1123
+ },
1124
+ orgSwitch: {
1125
+ mockUrl: 'query/orgSwitch.json',
1126
+ url: _variables2.default.URLS.orgSwitch,
1127
+ method: 'POST',
1128
+ postDataFomat: 'FORM',
1129
+ header: {
1130
+ Authorization: 'Bearer ' + getLoginUserInfo().token
1131
+ },
1132
+ willFetch: function willFetch() {}
1133
+ },
1134
+ updateStartUserOrg: {
1135
+ mockUrl: 'query/updateStartUserOrg.json',
1136
+ url: _variables2.default.URLS.updateStartUserOrg,
1137
+ method: 'POST',
1138
+ postDataFomat: 'FORM',
1139
+ header: {
1140
+ Authorization: 'Bearer ' + getLoginUserInfo().token
1141
+ },
1142
+ willFetch: function willFetch() {}
1114
1143
  }
1115
1144
 
1116
1145
  });
@@ -140,7 +140,10 @@ exports.default = {
140
140
  getProcessListByCodes: approveUrlPrefix + "getProcessListByCodes" + '?', //获取可发起的子流程
141
141
  getRelaObjByRelaId: approveUrlPrefix + "getRelaObjByRelaId" + '?', //获取相关对象
142
142
  getUrgencyEnum: approveUrlPrefix + "getUrgencyEnum" + '?', //获取枚举
143
- getSysSettingByMark: approveUrlPrefix + "getSysSettingByMark" + '?' //获取系统设置
143
+ getSysSettingByMark: approveUrlPrefix + "getSysSettingByMark" + '?', //获取系统设置
144
+ getUserSetInfo: urlBasicPrefix + 'setting/userinfo/getUserSetInfo' + '?', //获取用户组织信息
145
+ orgSwitch: urlBasicPrefix + 'front/personal/orgSwitch' + '?', //切换组织
146
+ updateStartUserOrg: approveUrlPrefix + 'updateStartUserOrg' + '?' //更新发起人组织
144
147
  },
145
148
  nodataIcon: context + "/mobile/fmui/images/noData.png",
146
149
  loadingIcon: context + "/mobile/fmui/images/loading.gif",
@@ -137,6 +137,33 @@ function isSysTransferCommentRequired() {
137
137
  return getSysSettingByMark('approveTransferComment') == '1';
138
138
  }
139
139
 
140
+ /** 组织切换相关接口不可用(如后台未部署、404) */
141
+ function isApproveOrgApiUnavailableError(err) {
142
+ if (!err) {
143
+ return false;
144
+ }
145
+ var code = err.status || err.statusCode || err.code;
146
+ if (code == 404 || code == '404') {
147
+ return true;
148
+ }
149
+ if (err.error) {
150
+ code = err.error.errorCode || err.error.code || err.error.status;
151
+ if (code == 404 || code == '404') {
152
+ return true;
153
+ }
154
+ }
155
+ var msg = '';
156
+ if (err.error && err.error.errorMsg) {
157
+ msg = err.error.errorMsg;
158
+ } else if (err.message) {
159
+ msg = err.message;
160
+ } else if (typeof err === 'string') {
161
+ msg = err;
162
+ }
163
+ msg = (msg || '').toLowerCase();
164
+ return msg.indexOf('404') >= 0 || msg.indexOf('not found') >= 0;
165
+ }
166
+
140
167
  var isCaReload = false;
141
168
  window.addEventListener('pageshow', function () {
142
169
  console.log("isCaReload===" + isCaReload);
@@ -487,7 +514,7 @@ var PageHome = function (_React$Component) {
487
514
  selectProcessCode: '', //选中的子流程
488
515
  subProcessType: '', //子流程类型 0串行 1并行
489
516
  urgencyList: [], //紧急程度列表
490
- urgency: '' }, _defineProperty(_param, 'urgent', ''), _defineProperty(_param, 'backInitiatorEndFlow', '0'), _defineProperty(_param, 'oauthWindowURL', ''), _defineProperty(_param, 'signDataId', ''), _defineProperty(_param, 'isCaUser', '0'), _defineProperty(_param, 'caFirm', ''), _defineProperty(_param, 'caESignatureName', ''), _defineProperty(_param, 'caFormSign', ''), _defineProperty(_param, 'addlotsReturn', ''), _defineProperty(_param, 'inscriptionShow', ''), _param);
517
+ urgency: '' }, _defineProperty(_param, 'urgent', ''), _defineProperty(_param, 'backInitiatorEndFlow', '0'), _defineProperty(_param, 'oauthWindowURL', ''), _defineProperty(_param, 'signDataId', ''), _defineProperty(_param, 'isCaUser', '0'), _defineProperty(_param, 'caFirm', ''), _defineProperty(_param, 'caESignatureName', ''), _defineProperty(_param, 'caFormSign', ''), _defineProperty(_param, 'addlotsReturn', ''), _defineProperty(_param, 'inscriptionShow', ''), _defineProperty(_param, 'showOrgSwitcher', false), _defineProperty(_param, 'approveOrgOptions', []), _defineProperty(_param, 'approveOrgSelectValue', {}), _defineProperty(_param, 'approveCurOrgId', ''), _defineProperty(_param, 'startUserOrgId', ''), _defineProperty(_param, 'taskAssignOrgId', ''), _defineProperty(_param, 'approveOrgApiUnavailable', false), _param);
491
518
  FlowCommon = require('pages/flow_common/' + module).default ? require('pages/flow_common/' + module).default : require('pages/flow_common/' + module);
492
519
 
493
520
  //处理特有参数
@@ -1517,8 +1544,11 @@ var PageHome = function (_React$Component) {
1517
1544
  caESignatureName: caESignatureName,
1518
1545
  caFormSign: caFormSign,
1519
1546
  addlotsReturn: addlotsReturn,
1520
- inscriptionShow: inscriptionShow
1547
+ inscriptionShow: inscriptionShow,
1548
+ startUserOrgId: content.startUserOrgId || content.startUserGroupId || '',
1549
+ taskAssignOrgId: content.taskAssignOrgId || ''
1521
1550
  }, function () {
1551
+ t.initApproveOrgSwitcher();
1522
1552
  t.refs["selectMember_circulate"].initSelectData();
1523
1553
  t.refs["selectMember_circulate1"].initSelectData();
1524
1554
 
@@ -7538,6 +7568,256 @@ var PageHome = function (_React$Component) {
7538
7568
  sendShortMessage: newremindStyle
7539
7569
  });
7540
7570
  }
7571
+ }, {
7572
+ key: 'hideApproveOrgSwitcherSilently',
7573
+ value: function hideApproveOrgSwitcherSilently() {
7574
+ this.setState({
7575
+ showOrgSwitcher: false,
7576
+ approveOrgOptions: [],
7577
+ approveOrgSelectValue: {},
7578
+ approveCurOrgId: '',
7579
+ approveOrgApiUnavailable: true
7580
+ });
7581
+ }
7582
+ }, {
7583
+ key: 'isApproveOrgSwitcherScene',
7584
+ value: function isApproveOrgSwitcherScene() {
7585
+ var permissionCode = this.state.permissionCode;
7586
+ return permissionCode == 'pending' || permissionCode == 'start' || permissionCode == 'draft';
7587
+ }
7588
+ }, {
7589
+ key: 'isApproveStartOrgUpdateScene',
7590
+ value: function isApproveStartOrgUpdateScene() {
7591
+ var permissionCode = this.state.permissionCode;
7592
+ return permissionCode == 'start' || permissionCode == 'draft' || this.state.isStart == true;
7593
+ }
7594
+ }, {
7595
+ key: 'resolveApproveOrgTargetId',
7596
+ value: function resolveApproveOrgTargetId(orgList, curOrgId, preferredOrgId, fallbackOrgId) {
7597
+ if (preferredOrgId) {
7598
+ for (var i = 0; i < orgList.length; i++) {
7599
+ if (orgList[i].id == preferredOrgId) {
7600
+ return preferredOrgId;
7601
+ }
7602
+ }
7603
+ }
7604
+ if (fallbackOrgId) {
7605
+ for (var i = 0; i < orgList.length; i++) {
7606
+ if (orgList[i].id == fallbackOrgId) {
7607
+ return fallbackOrgId;
7608
+ }
7609
+ }
7610
+ }
7611
+ return curOrgId;
7612
+ }
7613
+ }, {
7614
+ key: 'buildApproveOrgOption',
7615
+ value: function buildApproveOrgOption(org) {
7616
+ var orgName = org.name || org.orgNamePath || org.orgName || '';
7617
+ return {
7618
+ text: orgName,
7619
+ value: org.id
7620
+ };
7621
+ }
7622
+ }, {
7623
+ key: 'renderApproveOrgSwitcher',
7624
+ value: function renderApproveOrgSwitcher(orgList, selectedOrgId) {
7625
+ if (!orgList || orgList.length <= 1) {
7626
+ this.setState({
7627
+ showOrgSwitcher: false,
7628
+ approveOrgOptions: [],
7629
+ approveOrgSelectValue: {},
7630
+ approveCurOrgId: ''
7631
+ });
7632
+ return;
7633
+ }
7634
+ var options = [];
7635
+ var selectValue = {};
7636
+ for (var i = 0; i < orgList.length; i++) {
7637
+ var option = this.buildApproveOrgOption(orgList[i]);
7638
+ options.push(option);
7639
+ if (orgList[i].id == selectedOrgId) {
7640
+ selectValue = option;
7641
+ }
7642
+ }
7643
+ if (!selectValue.value && options.length > 0) {
7644
+ selectValue = options[0];
7645
+ selectedOrgId = selectValue.value;
7646
+ }
7647
+ this.setState({
7648
+ showOrgSwitcher: true,
7649
+ approveOrgOptions: options,
7650
+ approveOrgSelectValue: selectValue,
7651
+ approveCurOrgId: selectedOrgId || ''
7652
+ });
7653
+ }
7654
+ }, {
7655
+ key: 'initApproveOrgSwitcher',
7656
+ value: function initApproveOrgSwitcher() {
7657
+ var t = this;
7658
+ if (!t.isApproveOrgSwitcherScene() || t.state.approveOrgApiUnavailable) {
7659
+ return;
7660
+ }
7661
+ if (!window.approveOrgSwitcherSeq) {
7662
+ window.approveOrgSwitcherSeq = 0;
7663
+ }
7664
+ window.approveOrgSwitcherSeq++;
7665
+ var currentSeq = window.approveOrgSwitcherSeq;
7666
+ var autoSwitchKey = t.state.taskId || t.state.processInstanceId || '';
7667
+ if (!window.approveOrgAutoSwitchedMap) {
7668
+ window.approveOrgAutoSwitchedMap = {};
7669
+ }
7670
+ _db2.default.FlowModuleAPI.getUserSetInfo({}).then(function (userInfo) {
7671
+ if (currentSeq != window.approveOrgSwitcherSeq || t.state.approveOrgApiUnavailable) {
7672
+ return;
7673
+ }
7674
+ if (!userInfo) {
7675
+ t.hideApproveOrgSwitcherSilently();
7676
+ return;
7677
+ }
7678
+ if (userInfo.content && !userInfo.orgList) {
7679
+ userInfo = userInfo.content;
7680
+ }
7681
+ var orgList = userInfo.orgList || [];
7682
+ if (!orgList || orgList.length <= 1) {
7683
+ t.setState({ showOrgSwitcher: false });
7684
+ return;
7685
+ }
7686
+ var curOrgId = userInfo.curOrgId || '';
7687
+ var targetOrgId = t.resolveApproveOrgTargetId(orgList, curOrgId, t.state.taskAssignOrgId, t.state.startUserOrgId);
7688
+ if (targetOrgId && targetOrgId != curOrgId && !window.approveOrgAutoSwitchedMap[autoSwitchKey]) {
7689
+ t.switchApproveOrg(targetOrgId, function () {
7690
+ if (currentSeq != window.approveOrgSwitcherSeq) {
7691
+ return;
7692
+ }
7693
+ window.approveOrgAutoSwitchedMap[autoSwitchKey] = true;
7694
+ t.renderApproveOrgSwitcher(orgList, targetOrgId);
7695
+ }, function () {
7696
+ if (currentSeq != window.approveOrgSwitcherSeq) {
7697
+ return;
7698
+ }
7699
+ t.hideApproveOrgSwitcherSilently();
7700
+ }, { silent: true });
7701
+ return;
7702
+ }
7703
+ t.renderApproveOrgSwitcher(orgList, targetOrgId || curOrgId);
7704
+ }).catch(function (err) {
7705
+ if (currentSeq == window.approveOrgSwitcherSeq) {
7706
+ t.hideApproveOrgSwitcherSilently();
7707
+ }
7708
+ });
7709
+ }
7710
+ }, {
7711
+ key: 'handleApproveOrgSelect',
7712
+ value: function handleApproveOrgSelect(value) {
7713
+ var t = this;
7714
+ if (t.state.approveOrgApiUnavailable) {
7715
+ return;
7716
+ }
7717
+ if (!value || !value.value) {
7718
+ return;
7719
+ }
7720
+ var newOrgId = value.value;
7721
+ if (newOrgId == t.state.approveCurOrgId) {
7722
+ return;
7723
+ }
7724
+ var prevOrgId = t.state.approveCurOrgId;
7725
+ var prevSelectValue = t.state.approveOrgSelectValue;
7726
+ t.switchApproveOrg(newOrgId, function () {
7727
+ t.setState({
7728
+ approveCurOrgId: newOrgId,
7729
+ approveOrgSelectValue: value,
7730
+ startUserOrgId: t.isApproveStartOrgUpdateScene() ? newOrgId : t.state.startUserOrgId
7731
+ });
7732
+ }, function () {
7733
+ t.setState({
7734
+ approveCurOrgId: prevOrgId,
7735
+ approveOrgSelectValue: prevSelectValue
7736
+ });
7737
+ });
7738
+ }
7739
+ }, {
7740
+ key: 'switchApproveOrg',
7741
+ value: function switchApproveOrg(orgId, callback, failCallback, options) {
7742
+ var t = this;
7743
+ options = options || {};
7744
+ var silent = options.silent === true;
7745
+ var handleOrgApiError = function handleOrgApiError(err) {
7746
+ if (silent || isApproveOrgApiUnavailableError(err)) {
7747
+ t.hideApproveOrgSwitcherSilently();
7748
+ if (typeof failCallback === 'function') {
7749
+ failCallback();
7750
+ }
7751
+ return;
7752
+ }
7753
+ var errMsg = '组织切换失败';
7754
+ if (err && err.error && err.error.errorMsg) {
7755
+ errMsg = err.error.errorMsg;
7756
+ } else if (err && err.message) {
7757
+ errMsg = err.message;
7758
+ }
7759
+ _Toast2.default.show({
7760
+ type: 'error',
7761
+ content: errMsg
7762
+ });
7763
+ if (typeof failCallback === 'function') {
7764
+ failCallback();
7765
+ }
7766
+ };
7767
+ var afterOrgSwitchSuccess = function afterOrgSwitchSuccess() {
7768
+ if (t.isApproveStartOrgUpdateScene()) {
7769
+ var processInstanceId = t.state.processInstanceId || '';
7770
+ if (!processInstanceId) {
7771
+ if (typeof callback === 'function') {
7772
+ callback();
7773
+ }
7774
+ return;
7775
+ }
7776
+ _db2.default.FlowModuleAPI.updateStartUserOrg({
7777
+ processInstanceId: processInstanceId,
7778
+ orgId: orgId,
7779
+ userId: getLoginUserInfo().userId
7780
+ }).then(function () {
7781
+ if (typeof callback === 'function') {
7782
+ callback();
7783
+ }
7784
+ }).catch(function (err) {
7785
+ if (silent || isApproveOrgApiUnavailableError(err)) {
7786
+ t.hideApproveOrgSwitcherSilently();
7787
+ if (typeof callback === 'function') {
7788
+ callback();
7789
+ }
7790
+ return;
7791
+ }
7792
+ var errMsg = '更新发起人组织失败';
7793
+ if (err && err.error && err.error.errorMsg) {
7794
+ errMsg = err.error.errorMsg;
7795
+ } else if (err && err.message) {
7796
+ errMsg = err.message;
7797
+ }
7798
+ _Toast2.default.show({
7799
+ type: 'error',
7800
+ content: errMsg
7801
+ });
7802
+ if (typeof failCallback === 'function') {
7803
+ failCallback();
7804
+ }
7805
+ });
7806
+ return;
7807
+ }
7808
+ if (typeof callback === 'function') {
7809
+ callback();
7810
+ }
7811
+ };
7812
+ _db2.default.FlowModuleAPI.orgSwitch({
7813
+ curOrgIdRadios: orgId,
7814
+ curOrgId: orgId
7815
+ }).then(function () {
7816
+ afterOrgSwitchSuccess();
7817
+ }).catch(function (err) {
7818
+ handleOrgApiError(err);
7819
+ });
7820
+ }
7541
7821
  }, {
7542
7822
  key: 'changeUrgencyList',
7543
7823
  value: function changeUrgencyList(value) {
@@ -7842,6 +8122,23 @@ var PageHome = function (_React$Component) {
7842
8122
  )
7843
8123
  )
7844
8124
  ),
8125
+ _react2.default.createElement(
8126
+ 'div',
8127
+ { className: this.state.showOrgSwitcher ? 'approve-org-switch-wrap' : 't-DN' },
8128
+ _react2.default.createElement(
8129
+ _Group2.default.List,
8130
+ null,
8131
+ _react2.default.createElement(_SelectField2.default, {
8132
+ label: '\u5F53\u524D\u7EC4\u7EC7',
8133
+ readOnly: false,
8134
+ options: this.state.approveOrgOptions,
8135
+ placeholder: '\u8BF7\u9009\u62E9',
8136
+ onSelect: this.handleApproveOrgSelect.bind(this),
8137
+ value: this.state.approveOrgSelectValue,
8138
+ multiLine: true
8139
+ })
8140
+ )
8141
+ ),
7845
8142
  _react2.default.createElement(
7846
8143
  _Tab2.default,
7847
8144
  { activeKey: this.state.activeItemIndex == null ? '0' : this.state.activeItemIndex, onChange: this.handleChange.bind(this) },
@@ -1,4 +1,7 @@
1
1
  .approval-details{
2
2
  padding-bottom: calc(62px + constant(safe-area-inset-bottom)) !important; /* 兼容旧版 iOS */
3
3
  padding-bottom: calc(62px + env(safe-area-inset-bottom)) !important; /* 兼容新版 iOS */
4
+ }
5
+ .approve-org-switch-wrap{
6
+ background: #fff;
4
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fmui-base",
3
- "version": "2.3.5",
3
+ "version": "2.3.6",
4
4
  "title": "fmui-base",
5
5
  "description": "fmui移动端组件",
6
6
  "main": "lib/index.js",