cloud-web-corejs 1.0.54-dev.790 → 1.0.54-dev.792

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.
Files changed (43) hide show
  1. package/package.json +1 -1
  2. package/src/components/table/tableForm.vue +4 -2
  3. package/src/components/wf/content.vue +2 -2
  4. package/src/components/wf/content2.vue +4 -2
  5. package/src/components/wf/wf.js +18 -0
  6. package/src/components/xform/form-designer/designer.js +15 -11
  7. package/src/components/xform/form-designer/form-widget/container-widget/detail-plain-widget.vue +76 -0
  8. package/src/components/xform/form-designer/form-widget/field-widget/mixins/time-limit-mixin.js +92 -0
  9. package/src/components/xform/form-designer/form-widget/field-widget/time-widget.vue +44 -5
  10. package/src/components/xform/form-designer/indexMixin.js +1 -0
  11. package/src/components/xform/form-designer/setting-panel/form-dynamicField-setting.vue +1 -0
  12. package/src/components/xform/form-designer/setting-panel/property-editor/container-detail-plain/detail-plain-editor.vue +75 -0
  13. package/src/components/xform/form-designer/setting-panel/property-editor/field-time/time-defaultValue-editor.vue +23 -2
  14. package/src/components/xform/form-designer/setting-panel/property-editor/field-time/time-timeLimit-editor.vue +56 -0
  15. package/src/components/xform/form-designer/setting-panel/propertyRegister.js +2 -0
  16. package/src/components/xform/form-designer/widget-panel/widgetsConfig.js +26 -0
  17. package/src/components/xform/form-render/container-item/detail-plain-item.vue +92 -0
  18. package/src/components/xform/form-render/indexMixin.js +3 -1
  19. package/src/components/xform/lang/zh-CN.js +1 -0
  20. package/src/components/xform/utils/util.js +1 -1
  21. package/src/index.js +10 -7
  22. package/src/store/config/index.js +0 -1
  23. package/src/views/bd/project/branch/form_script/list.vue +12 -3
  24. package/src/views/bd/project/branch/form_template/list.vue +12 -3
  25. package/src/views/bd/project/branch/menu_kind/list.vue +13 -3
  26. package/src/views/bd/project/core/branchPage.js +5 -5
  27. package/src/views/bd/project/core/branchPageWrap.vue +16 -7
  28. package/src/views/bd/project/core/branchSearchPage.js +285 -0
  29. package/src/views/bd/project/core/branchSelect.vue +1 -22
  30. package/src/views/bd/project/core/branchTreeBar.vue +81 -0
  31. package/src/views/bd/setting/formVersion/button.vue +5 -0
  32. package/src/views/bd/setting/formVersion/ftHistoryDialog.vue +21 -12
  33. package/src/views/bd/setting/formVersion/link.vue +5 -0
  34. package/src/views/bd/setting/form_script/edit.vue +1 -0
  35. package/src/views/bd/setting/form_script/edit1.vue +1 -0
  36. package/src/views/bd/setting/form_script/form_list.vue +1 -0
  37. package/src/views/bd/setting/form_script/list.vue +1 -0
  38. package/src/views/bd/setting/form_script/list1.vue +2 -0
  39. package/src/views/bd/setting/form_template/edit.vue +1 -0
  40. package/src/views/bd/setting/form_template/list.vue +2 -0
  41. package/src/views/bd/setting/table_model/edit.vue +1 -0
  42. package/src/views/bd/setting/table_model/list.vue +1 -0
  43. package/src/views/user/wf/wfReport/index.vue +24 -1
@@ -0,0 +1,92 @@
1
+ <!--
2
+ /**
3
+ * 简洁详情模块(detail-plain):与 detail 同构,但不渲染标题栏(标题/翻单/流程/按钮控件),
4
+ * 模块导航默认关闭。仅保留 panes(详情tab)内容区。
5
+ */
6
+ -->
7
+
8
+ <template>
9
+ <container-item-wrapper :widget="widget">
10
+ <div
11
+ class="detail-wrap grid-container"
12
+ :class="[customClass]"
13
+ :ref="widget.id"
14
+ >
15
+ <baseTabs :showNav="!widget.options.hideNav && !plainMode">
16
+ <detail-pane-widget
17
+ v-for="(paneWidget, index) in widget.panes"
18
+ :key="index"
19
+ :widget="paneWidget"
20
+ :parent-list="widget.panes"
21
+ :index-of-parent-list="index"
22
+ :parent-widget="widget"
23
+ :col-height="widget.options.colHeight"
24
+ tabRef="baseTabRef"
25
+ :tabPaneGrade="2"
26
+ ></detail-pane-widget>
27
+ </baseTabs>
28
+ </div>
29
+ </container-item-wrapper>
30
+ </template>
31
+
32
+ <script>
33
+ import emitter from "../../../../components/xform/utils/emitter";
34
+ import i18n from "../../../../components/xform/utils/i18n";
35
+ import refMixin from "../../../../components/xform/form-render/refMixin";
36
+ import ContainerItemWrapper from "./container-item-wrapper";
37
+ import containerItemMixin from "./containerItemMixin";
38
+ import detailPaneWidget from "../../../../components/xform/form-render/container-item/detail-pane-item";
39
+ import FieldComponents from "../../../../components/xform/form-designer/form-widget/field-widget/index";
40
+
41
+ export default {
42
+ name: "detail-plain-item",
43
+ componentName: "ContainerItem",
44
+ mixins: [emitter, i18n, refMixin, containerItemMixin],
45
+ components: {
46
+ ContainerItemWrapper,
47
+ detailPaneWidget,
48
+ ...FieldComponents,
49
+ },
50
+ props: {
51
+ widget: Object,
52
+ },
53
+ inject: ["refList", "sfRefList", "globalModel", "previewState"],
54
+ created() {
55
+ this.initRefList();
56
+ this.handleOnCreated();
57
+ },
58
+ mounted() {
59
+ this.handleOnMounted();
60
+ },
61
+ beforeDestroy() {
62
+ this.unregisterFromRefList();
63
+ },
64
+ computed: {
65
+ // 素身详情模式(宿主 VFormRender 传 plainDetailMode):强制关闭模块导航
66
+ plainMode() {
67
+ let formRef = this.getFormRef && this.getFormRef();
68
+ return !!(formRef && formRef.plainDetailMode);
69
+ },
70
+ },
71
+ };
72
+ </script>
73
+
74
+ <style lang="scss" scoped>
75
+ .grid-container {
76
+ min-height: 50px;
77
+ outline: 1px dashed #336699;
78
+
79
+ > div {
80
+ height: 100%;
81
+ }
82
+
83
+ .form-widget-list {
84
+ height: 100%;
85
+ }
86
+ }
87
+
88
+ .grid-container.selected,
89
+ .grid-cell.selected {
90
+ outline: 2px solid $--color-primary !important;
91
+ }
92
+ </style>
@@ -1660,7 +1660,7 @@ modules = {
1660
1660
  t.buildDataFromWidget(e);
1661
1661
  });
1662
1662
  });
1663
- else if ("detail" === e.type)
1663
+ else if ("detail" === e.type || "detail-plain" === e.type)
1664
1664
  e.panes &&
1665
1665
  e.panes.length > 0 &&
1666
1666
  e.panes.forEach(function (e) {
@@ -3601,6 +3601,7 @@ modules = {
3601
3601
  "vf-box": "widgetList",
3602
3602
  card: "widgetList",
3603
3603
  detail: "panes",
3604
+ "detail-plain": "panes",
3604
3605
  "detail-pane": "widgetList",
3605
3606
  "detail-h5": "panes",
3606
3607
  "h5-card": "panes",
@@ -3787,6 +3788,7 @@ modules = {
3787
3788
  "vf-box": "widgetList",
3788
3789
  card: "widgetList",
3789
3790
  detail: "panes",
3791
+ "detail-plain": "panes",
3790
3792
  "detail-pane": "widgetList",
3791
3793
  "detail-h5": "panes",
3792
3794
  "h5-card": "panes",
@@ -92,6 +92,7 @@ export default {
92
92
  panel: "面板",
93
93
  query: "查询模块",
94
94
  detail: "详情模块",
95
+ "detail-plain": "详情模块(简洁)",
95
96
  "detail-pane": "详情tab",
96
97
  "detail-h5": "H5详情",
97
98
  "list-h5": "H5列表",
@@ -1554,7 +1554,7 @@ function loopHandleWidgetItem(e, p, callback) {
1554
1554
  loopHandleWidgetItem(childItem, e, callback);
1555
1555
  });
1556
1556
  });
1557
- } else if ("detail" === e.type) {
1557
+ } else if ("detail" === e.type || "detail-plain" === e.type) {
1558
1558
  if (e.panes) {
1559
1559
  e.panes.forEach(function (childItem) {
1560
1560
  loopHandleWidgetItem(childItem, e, callback);
package/src/index.js CHANGED
@@ -189,13 +189,16 @@ Vue.component("advancedSearchDialog", () =>
189
189
  import("@base/components/advancedSearchDialog/index.vue")
190
190
  );
191
191
 
192
- Vue.component("baseTabs", () =>
193
- import("@base/components/baseTabs/index.vue")
194
- );
195
-
196
- Vue.component("baseTabPane", () =>
197
- import("@base/components/baseTabs/baseTabPane.vue")
198
- );
192
+ // baseTabs/baseTabPane 必须同步注册,不可懒注册:
193
+ // xform 详情容器(detail-item)把所有 detail-pane 及其内部字段组件放在 <baseTabs> 的默认插槽里。
194
+ // 异步组件未解析时 Vue 只渲染占位注释节点,插槽内的组件不会被实例化,
195
+ // 于是 detail-item 的 mounted 早于内部字段组件的 created(registerToRefList)执行,
196
+ // 模板脚本 onMounted 里的 getWidgetRef('xxx') 首次进入必然拿到 undefined(二次进入因异步工厂已缓存而正常)。
197
+ import baseTabs from "@base/components/baseTabs/index.vue";
198
+ import baseTabPane from "@base/components/baseTabs/baseTabPane.vue";
199
+
200
+ Vue.component(baseTabs.name, baseTabs);
201
+ Vue.component(baseTabPane.name, baseTabPane);
199
202
 
200
203
  import vb_tabs from "@base/components/vb-tabs/index.vue";
201
204
  import vb_tab_pane from "@base/components/vb-tabs/tab-pane.vue";
@@ -102,7 +102,6 @@ const bdProjectMenus = [
102
102
  hasChild: false,
103
103
  grade: 2,
104
104
  type: 0,
105
- repeatOpen: true,
106
105
  children: [],
107
106
  },
108
107
  {
@@ -1,22 +1,31 @@
1
1
  <template>
2
+ <!-- 分支说明与「打开新分支」放在左侧树区域顶部,不再占用内容区工具条 -->
2
3
  <branchPageWrap
3
4
  :branchCode.sync="branchCode"
4
5
  :branchLabel="branchLabel"
6
+ :show-bar="false"
5
7
  @branch-change="onBranchChange"
6
- @open-new="openNewBranch"
7
8
  >
8
- <baseList :key="branchCode"></baseList>
9
+ <baseList :key="branchCode">
10
+ <template #treeTop>
11
+ <branchTreeBar
12
+ :branchLabel="branchLabel"
13
+ @open-new="openNewBranch"
14
+ ></branchTreeBar>
15
+ </template>
16
+ </baseList>
9
17
  </branchPageWrap>
10
18
  </template>
11
19
 
12
20
  <script>
13
21
  import branchPage from "../../core/branchPage";
22
+ import branchTreeBar from "../../core/branchTreeBar.vue";
14
23
  // 逻辑脚本对应 scriptType=1 的 list1
15
24
  import baseList from "@base/views/bd/setting/form_script/list1.vue";
16
25
 
17
26
  export default {
18
27
  name: "branch_form_script:list",
19
- components: { baseList },
28
+ components: { baseList, branchTreeBar },
20
29
  mixins: [branchPage],
21
30
  };
22
31
  </script>
@@ -1,21 +1,30 @@
1
1
  <template>
2
+ <!-- 分支说明与「打开新分支」放在左侧树区域顶部,不再占用内容区工具条 -->
2
3
  <branchPageWrap
3
4
  :branchCode.sync="branchCode"
4
5
  :branchLabel="branchLabel"
6
+ :show-bar="false"
5
7
  @branch-change="onBranchChange"
6
- @open-new="openNewBranch"
7
8
  >
8
- <baseList :key="branchCode"></baseList>
9
+ <baseList :key="branchCode">
10
+ <template #treeTop>
11
+ <branchTreeBar
12
+ :branchLabel="branchLabel"
13
+ @open-new="openNewBranch"
14
+ ></branchTreeBar>
15
+ </template>
16
+ </baseList>
9
17
  </branchPageWrap>
10
18
  </template>
11
19
 
12
20
  <script>
13
21
  import branchPage from "../../core/branchPage";
22
+ import branchTreeBar from "../../core/branchTreeBar.vue";
14
23
  import baseList from "@base/views/bd/setting/form_template/list.vue";
15
24
 
16
25
  export default {
17
26
  name: "branch_form_template:list",
18
- components: { baseList },
27
+ components: { baseList, branchTreeBar },
19
28
  mixins: [branchPage],
20
29
  };
21
30
  </script>
@@ -1,21 +1,31 @@
1
1
  <template>
2
+ <!-- 先选分支再进入,进入后分支作为第一个查询条件可继续切换;不提供「打开新分支」 -->
2
3
  <branchPageWrap
3
4
  :branchCode.sync="branchCode"
4
5
  :branchLabel="branchLabel"
6
+ :show-bar="false"
7
+ :show-open-new="false"
5
8
  @branch-change="onBranchChange"
6
- @open-new="openNewBranch"
7
9
  >
8
- <baseList :key="branchCode"></baseList>
10
+ <branchList :initBranchCode="branchCode" @branch-change="onBranchChange"></branchList>
9
11
  </branchPageWrap>
10
12
  </template>
11
13
 
12
14
  <script>
13
15
  import branchPage from "../../core/branchPage";
16
+ import branchSearchPage from "../../core/branchSearchPage";
14
17
  import baseList from "@base/views/bd/setting/menu_kind/list.vue";
15
18
 
19
+ // 复用原分类列表,只把分支塞进查询条件
20
+ const branchList = {
21
+ name: "branch_menu_kind_list",
22
+ extends: baseList,
23
+ mixins: [branchSearchPage],
24
+ };
25
+
16
26
  export default {
17
27
  name: "branch_menu_kind:list",
18
- components: { baseList },
28
+ components: { branchList },
19
29
  mixins: [branchPage],
20
30
  };
21
31
  </script>
@@ -59,11 +59,11 @@ modules = {
59
59
  },
60
60
  updateTabTitle() {
61
61
  let base = this.baseTabTitle || this.resolveBaseTabTitle();
62
- let title = this.branchName
63
- ? `${base}-${this.branchName}`
64
- : this.branchCode
65
- ? `${base}-${this.branchCode}`
66
- : base;
62
+ let suffix = this.branchName || this.branchCode;
63
+ // 菜单名形如「表单模板-分支」,选中分支后把末尾的「分支」换成分支名
64
+ let title = suffix
65
+ ? `${base.replace(/[--—]?\s*分支$/, "")}-${suffix}`
66
+ : base;
67
67
  this.$store.dispatch("tagsView/updateVisitedView2", {
68
68
  view: this.$route,
69
69
  title,
@@ -1,12 +1,13 @@
1
1
  <template>
2
2
  <div class="bd-branch-page" :class="{ 'has-branch': !!branchCode }">
3
3
  <!-- 已选分支:内容区顶部工具条,不可改;提供打开新分支 -->
4
- <div class="branch-bar" v-if="branchCode">
4
+ <div class="branch-bar" v-if="branchCode && showBar">
5
5
  <span class="branch-locked">
6
6
  <span class="label">{{ $t1("分支") }}:</span>
7
7
  <span class="value">{{ branchLabel || branchCode }}</span>
8
8
  </span>
9
9
  <el-button
10
+ v-if="showOpenNew"
10
11
  size="mini"
11
12
  type="primary"
12
13
  plain
@@ -25,7 +26,6 @@
25
26
  <p class="tip">{{ $t1("请先选择分支") }}</p>
26
27
  <branchSelect
27
28
  :value="branchCode"
28
- :auto-restore="false"
29
29
  @input="$emit('update:branchCode', $event)"
30
30
  @change="$emit('branch-change', $event)"
31
31
  ></branchSelect>
@@ -44,6 +44,15 @@ export default {
44
44
  props: {
45
45
  branchCode: String,
46
46
  branchLabel: String,
47
+ // 页面自己在查询条件里展示/切换分支时,顶部工具条就是多余的
48
+ showBar: {
49
+ type: Boolean,
50
+ default: true,
51
+ },
52
+ showOpenNew: {
53
+ type: Boolean,
54
+ default: true,
55
+ },
47
56
  },
48
57
  watch: {
49
58
  branchCode() {
@@ -205,11 +214,11 @@ export default {
205
214
  display: inline-block;
206
215
  margin-left: 12px;
207
216
  padding: 2px 8px;
208
- font-size: 12px;
209
- font-weight: 400;
210
- line-height: 18px;
211
- color: #6386fa;
212
- background: #f0f3ff;
217
+ font-size: 14px;
218
+ font-weight: 600;
219
+ line-height: 20px;
220
+ color: #ff731c;
221
+ background: #fff3ea;
213
222
  border-radius: 2px;
214
223
  vertical-align: middle;
215
224
  }
@@ -0,0 +1,285 @@
1
+ import branchScope from "./branchScope";
2
+ import { BRANCH_FLAG, needInject } from "./branchContext";
3
+
4
+ const BRANCH_FIELD = "branchCode";
5
+
6
+ /** 只读接口:分支未就绪时直接返回空结果,避免表格一直转圈 */
7
+ const READ_SUFFIXES = [
8
+ "/getAllList",
9
+ "/getChildren",
10
+ "/listPage",
11
+ "/listOtherPage",
12
+ "/listPageWf",
13
+ ];
14
+
15
+ function isReadUrl(url) {
16
+ if (!url) {
17
+ return false;
18
+ }
19
+ let path = url;
20
+ let qIndex = path.indexOf("?");
21
+ if (qIndex >= 0) {
22
+ path = path.substring(0, qIndex);
23
+ }
24
+ return READ_SUFFIXES.some((item) => path.endsWith(item));
25
+ }
26
+
27
+ /**
28
+ * 分支工程页面(分支收敛到查询条件)通用逻辑:
29
+ * 1. 不做进入前的分支门禁,也不提供「打开新分支」,分支就是查询条件里的第一个下拉框
30
+ * 2. 没选到有效分支时整页不可操作:不查询、不保存、不导入导出
31
+ * 3. 切换分支即清空其余查询条件并重新查询;分支不做记忆,每次进来都要重新选
32
+ * 4. 页面用 extends 复用 bd/setting 下的原组件,这里全部改在实例级的 $vxeTableUtil /
33
+ * $http / $jsonImport / $jsonExport 上做,不必重写原组件的任何方法
34
+ */
35
+ let modules = {};
36
+ modules = {
37
+ mixins: [branchScope(BRANCH_FLAG.BRANCH)],
38
+ props: {
39
+ // 由外层前置选择页带进来的分支,组件挂载时就已经确定
40
+ initBranchCode: String,
41
+ },
42
+ data() {
43
+ return {
44
+ branchCode: this.initBranchCode || "",
45
+ branchName: "",
46
+ branches: [],
47
+ branchesLoaded: false,
48
+ };
49
+ },
50
+ computed: {
51
+ /** 后台匹配得到分支才算就绪;分支列表未回来前,先按已选分支放行 */
52
+ branchReady() {
53
+ if (!this.branchCode) {
54
+ return false;
55
+ }
56
+ if (!this.branchesLoaded) {
57
+ return true;
58
+ }
59
+ return this.branches.some((item) => item.branchCode === this.branchCode);
60
+ },
61
+ },
62
+ created() {
63
+ this.patchVxeTableUtil();
64
+ this.patchBranchGuard();
65
+ },
66
+ watch: {
67
+ "formData.branchCode"(val) {
68
+ this.applyBranch(val);
69
+ },
70
+ },
71
+ methods: {
72
+ /** 实例级覆盖 $vxeTableUtil.initVxeTable,给原页面的查询条件补一列分支 */
73
+ patchVxeTableUtil() {
74
+ let origin = this.$vxeTableUtil;
75
+ if (!origin || this._branchVxePatched) {
76
+ return;
77
+ }
78
+ this._branchVxePatched = true;
79
+ let that = this;
80
+ // $vxeTableUtil 上都是无 this 依赖的普通函数,原型继承 + 覆盖单个方法即可
81
+ this.$vxeTableUtil = Object.assign(Object.create(origin), {
82
+ initVxeTable(option) {
83
+ that.injectBranchSearchColumn(option);
84
+ return origin.initVxeTable(option);
85
+ },
86
+ });
87
+ },
88
+ /** 分支未就绪时拦掉本页所有分支相关请求与导入导出 */
89
+ patchBranchGuard() {
90
+ if (this._branchGuardPatched) {
91
+ return;
92
+ }
93
+ this._branchGuardPatched = true;
94
+ let that = this;
95
+
96
+ // $commonHttp 内部转调 this.$http,表格查询/树懒加载/行保存都会走到这里
97
+ let originHttp = this.$http;
98
+ let wrapped = function (option) {
99
+ if (option && needInject(option.url) && !that.branchReady) {
100
+ return that.refuseBranchRequest(option);
101
+ }
102
+ return originHttp.apply(this, arguments);
103
+ };
104
+ Object.assign(wrapped, originHttp);
105
+ wrapped.prototype = originHttp.prototype;
106
+ this.$http = wrapped;
107
+
108
+ let originImport = this.$jsonImport;
109
+ if (typeof originImport === "function") {
110
+ this.$jsonImport = function () {
111
+ if (!that.checkBranchReady()) {
112
+ return;
113
+ }
114
+ return originImport.apply(this, arguments);
115
+ };
116
+ }
117
+ let originExport = this.$jsonExport;
118
+ if (typeof originExport === "function") {
119
+ this.$jsonExport = function () {
120
+ if (!that.checkBranchReady()) {
121
+ return;
122
+ }
123
+ return originExport.apply(this, arguments);
124
+ };
125
+ }
126
+ },
127
+ refuseBranchRequest(option) {
128
+ if (isReadUrl(option.url)) {
129
+ let res = { type: "success", objx: { records: [], total: 0 } };
130
+ if (option.callback) {
131
+ option.callback(res);
132
+ }
133
+ if (option.success) {
134
+ option.success(res);
135
+ }
136
+ return Promise.resolve(res);
137
+ }
138
+ this.warnBranchRequired();
139
+ if (option.error) {
140
+ option.error(null);
141
+ }
142
+ return Promise.resolve(null);
143
+ },
144
+ checkBranchReady() {
145
+ if (this.branchReady) {
146
+ return true;
147
+ }
148
+ this.warnBranchRequired();
149
+ return false;
150
+ },
151
+ warnBranchRequired() {
152
+ // 同一批操作只提示一次,避免树表并发请求刷屏
153
+ if (this._branchWarning) {
154
+ return;
155
+ }
156
+ this._branchWarning = true;
157
+ setTimeout(() => {
158
+ this._branchWarning = false;
159
+ }, 1000);
160
+ this.$message({
161
+ type: "warning",
162
+ message: this.$t1("请先选择分支"),
163
+ });
164
+ },
165
+ injectBranchSearchColumn(option) {
166
+ if (!option) {
167
+ return;
168
+ }
169
+ this._branchTableRef = option.tableRef || this._branchTableRef;
170
+ let columns = option.searchColumns || [];
171
+ if (columns.some((item) => item.field === BRANCH_FIELD)) {
172
+ return;
173
+ }
174
+ option.searchColumns = [this.buildBranchSearchColumn(), ...columns];
175
+ },
176
+ buildBranchSearchColumn() {
177
+ return {
178
+ title: this.$t1("分支"),
179
+ field: BRANCH_FIELD,
180
+ type: "select",
181
+ common: true,
182
+ // fixed 让「查询条件设置」的保存结果无法把它挪位置或收进高级筛选
183
+ fixed: true,
184
+ // 分支不允许清空,页面必须始终处在某个分支下
185
+ clearable: false,
186
+ itemOption: [],
187
+ // 不做记忆,只回填前置页刚选的分支
188
+ defaultValue: this.branchCode || null,
189
+ syncHandle: () => {
190
+ return this.loadBranches();
191
+ },
192
+ };
193
+ },
194
+ loadBranches() {
195
+ return new Promise((resolve) => {
196
+ this.$http({
197
+ url: USER_PREFIX + "/bd_branch/listPage",
198
+ method: "post",
199
+ data: {
200
+ enabled: true,
201
+ current: 1,
202
+ size: 500,
203
+ },
204
+ success: (res) => {
205
+ let records = res?.objx?.records || [];
206
+ this.branches = records;
207
+ this.branchesLoaded = true;
208
+ this.dropInvalidBranch();
209
+ this.syncBranchName();
210
+ resolve(
211
+ records.map((item) => {
212
+ return {
213
+ label: item.branchName + "(" + item.branchCode + ")",
214
+ value: item.branchCode,
215
+ };
216
+ })
217
+ );
218
+ },
219
+ error: () => {
220
+ this.branchesLoaded = true;
221
+ resolve([]);
222
+ },
223
+ });
224
+ });
225
+ },
226
+ /** 已选分支后台查不到(停用/删除)时清掉,页面回到不可操作状态 */
227
+ dropInvalidBranch() {
228
+ if (!this.branchCode || this.branchReady) {
229
+ return;
230
+ }
231
+ this.branchCode = "";
232
+ if (this.formData) {
233
+ this.$set(this.formData, BRANCH_FIELD, null);
234
+ }
235
+ this.$message({
236
+ type: "warning",
237
+ message: this.$t1("原分支已不可用,请重新选择分支"),
238
+ });
239
+ // 清掉可能已经查回来的旧分支数据
240
+ this.reloadBranchTable();
241
+ },
242
+ syncBranchName() {
243
+ let current = this.branches.find(
244
+ (item) => item.branchCode === this.branchCode
245
+ );
246
+ this.branchName = current ? current.branchName || "" : "";
247
+ },
248
+ applyBranch(val) {
249
+ let branchCode = val || "";
250
+ // 值没变就不要再触发一次查询
251
+ if (branchCode === this.branchCode) {
252
+ return;
253
+ }
254
+ this.branchCode = branchCode;
255
+ this.syncBranchName();
256
+ // 换分支等于换了一套数据,其余查询条件全部清空
257
+ this.formData = { [BRANCH_FIELD]: branchCode || null };
258
+ this.reloadBranchTable();
259
+ // 通知外层同步标签页名等分支信息
260
+ this.$emit("branch-change", {
261
+ branchCode: this.branchCode,
262
+ branchName: this.branchName,
263
+ });
264
+ },
265
+ reloadBranchTable() {
266
+ let grid = this.$refs[this._branchTableRef || "table-m1"];
267
+ if (grid) {
268
+ grid.commitProxy("reload");
269
+ }
270
+ },
271
+ searchEvent() {
272
+ if (!this.checkBranchReady()) {
273
+ return;
274
+ }
275
+ this.reloadBranchTable();
276
+ },
277
+ /** 重置查询条件时保留已选分支 */
278
+ resetEvent() {
279
+ let branchCode = this.formData ? this.formData.branchCode : "";
280
+ this.formData = { [BRANCH_FIELD]: branchCode || null };
281
+ this.reloadBranchTable();
282
+ },
283
+ },
284
+ };
285
+ export default modules;
@@ -19,17 +19,10 @@
19
19
  </template>
20
20
 
21
21
  <script>
22
- const STORAGE_KEY = "bdProjectBranchCode";
23
-
24
22
  export default {
25
23
  name: "bdBranchSelect",
26
24
  props: {
27
25
  value: String,
28
- // 首次进入时是否自动回填上次选择的分支
29
- autoRestore: {
30
- type: Boolean,
31
- default: true,
32
- },
33
26
  },
34
27
  data() {
35
28
  return {
@@ -51,26 +44,12 @@ export default {
51
44
  },
52
45
  success: (res) => {
53
46
  this.branches = res?.objx?.records || [];
54
- this.restore();
55
47
  },
56
48
  });
57
49
  },
58
- restore() {
59
- if (!this.autoRestore || this.value) {
60
- return;
61
- }
62
- let last = localStorage.getItem(STORAGE_KEY);
63
- if (last && this.branches.some((item) => item.branchCode === last)) {
64
- this.handleChange(last);
65
- }
66
- },
50
+ // 分支不做记忆,每次进页面都要重新选
67
51
  handleChange(val) {
68
52
  let branchCode = val || "";
69
- if (branchCode) {
70
- localStorage.setItem(STORAGE_KEY, branchCode);
71
- } else {
72
- localStorage.removeItem(STORAGE_KEY);
73
- }
74
53
  this.$emit("input", branchCode);
75
54
  this.$emit(
76
55
  "change",