刘光辉
10 小时以前 0dfe84494048ce27ba8449831782128412d3eb13
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
<script lang="ts" setup>
import type { PermissionSwitches } from '#/utils/permissionSwitch';
 
import { onMounted, reactive, toRefs } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
 
import { getSysConfig, update } from '#/api/system/sysConfig';
import { $t } from '#/locales';
import { useBaseStore } from '#/store';
import { isPermissionSwitchEnabled, normalizePermissionSwitches, PERMISSION_SWITCH_KEYS } from '#/utils/permissionSwitch';
 
import PermissionRelationGuide from './components/PermissionRelationGuide.vue';
 
interface State {
  baseForm: any;
  activeKey: number;
  btnLoading: boolean;
}
 
defineOptions({ name: 'SysConfigParameter' });
 
const defaultViewOptions = [
  { id: 'timeGridDay', fullName: '日' },
  { id: 'timeGridWeek', fullName: '周' },
  { id: 'dayGridMonth', fullName: '月' },
];
const firstDayOptions = [
  { id: 1, fullName: '一' },
  { id: 2, fullName: '二' },
  { id: 3, fullName: '三' },
  { id: 4, fullName: '四' },
  { id: 5, fullName: '五' },
  { id: 6, fullName: '六' },
  { id: 0, fullName: '日' },
];
const durationOptions = [
  { id: 30, fullName: '30分钟' },
  { id: 60, fullName: '1小时' },
  { id: 90, fullName: '1小时30分钟' },
  { id: 120, fullName: '2小时' },
  { id: 180, fullName: '3小时' },
];
const scopeOptions = [
  { id: 1, fullName: '无范围限制' },
  { id: 6, fullName: '同一公司/单位' },
  { id: 2, fullName: '同一部门' },
  { id: 3, fullName: '同一岗位' },
];
const state = reactive<State>({
  baseForm: {},
  activeKey: 1,
  btnLoading: false,
});
const { baseForm, activeKey, btnLoading } = toRefs(state);
const { createConfirm, createMessage } = useMessage();
const baseStore = useBaseStore();
let savedPermissionSwitches: PermissionSwitches = normalizePermissionSwitches();
 
function initData() {
  getSysConfig().then((res) => {
    const permissionSwitches = normalizePermissionSwitches(res.data);
    state.baseForm = { ...res.data, ...permissionSwitches };
    savedPermissionSwitches = { ...permissionSwitches };
    state.baseForm.linkTime = state.baseForm.linkTime ? state.baseForm.linkTime : 24;
    state.baseForm.addSignLevel = state.baseForm.addSignLevel ? state.baseForm.addSignLevel : 1;
    state.baseForm.unClickNum = state.baseForm.unClickNum ? state.baseForm.unClickNum : 1;
  });
}
function handleSubmit() {
  const nextPermissionSwitches = normalizePermissionSwitches(state.baseForm);
  const permissionSwitchChanged = PERMISSION_SWITCH_KEYS.some((key) => nextPermissionSwitches[key] !== savedPermissionSwitches[key]);
  Object.assign(state.baseForm, nextPermissionSwitches);
  createConfirm({
    iconType: 'warning',
    title: $t('common.tipTitle'),
    content: permissionSwitchChanged
      ? '权限开关变更后需要重新登录才能完整生效;身份开关会改变运行时授权,其他开关只控制配置入口且不会撤销已有授权。您确定要保存吗?'
      : '您确定要保存,是否继续?',
    onOk: () => {
      state.btnLoading = true;
      update(state.baseForm)
        .then((res) => {
          createMessage.success(res.msg);
          if (permissionSwitchChanged) createMessage.warning('权限设置已保存,请重新登录后验证菜单和权限结果');
          state.btnLoading = false;
          const sysConfigInfo = {
            sysName: state.baseForm.sysName,
            sysVersion: state.baseForm.sysVersion,
            loginIcon: state.baseForm.loginIcon,
            copyright: state.baseForm.copyright,
            companyName: state.baseForm.companyName,
            logoIcon: state.baseForm.logoIcon,
            appIcon: state.baseForm.appIcon,
            title: state.baseForm.title,
            defaultView: state.baseForm.defaultView,
            showLunarCalendar: state.baseForm.showLunarCalendar,
            firstDay: state.baseForm.firstDay,
            duration: state.baseForm.duration,
            flowSign: state.baseForm.flowSign,
            flowTodo: state.baseForm.flowTodo,
            delegateScope: state.baseForm.delegateScope,
            delegateAck: state.baseForm.delegateAck,
            proxyScope: state.baseForm.proxyScope,
            proxyAck: state.baseForm.proxyAck,
          };
          localStorage.setItem('_APP_LOGIN_LOGO_', sysConfigInfo.loginIcon || '');
          baseStore.setSysConfig(sysConfigInfo);
          initData();
        })
        .catch(() => {
          state.btnLoading = false;
        });
    },
  });
}
 
function onNumberChange(val, key) {
  if (val) return;
  state.baseForm[key] = 1;
}
 
function onFlowTodoChange(value) {
  if (!value) state.baseForm.flowSign = 0;
}
 
onMounted(() => {
  initData();
});
</script>
<template>
  <div class="jnpf-content-wrapper">
    <div class="jnpf-content-wrapper-center bg-white">
      <a-form :colon="false" label-align="right" :label-col="{ style: { width: '90px' } }" class="h-full">
        <a-tabs class="jnpf-content-wrapper-tabs tabs-contain" v-model:active-key="activeKey">
          <a-tab-pane :key="1" tab="基础参数" class="p-[30px]">
            <a-row>
              <a-col :span="24">
                <a-form-item label="系统图标">
                  <div class="img-list">
                    <JnpfUploadImgSingle type="userAvatar" v-model:value="baseForm.loginIcon" tip-text="登录图标" />
                    <JnpfUploadImgSingle type="userAvatar" v-model:value="baseForm.logoIcon" tip-text="LOGO图标" />
                    <JnpfUploadImgSingle type="userAvatar" v-model:value="baseForm.appIcon" tip-text="APP图标" />
                  </div>
                </a-form-item>
              </a-col>
              <a-col :span="24">
                <a-form-item label="系统标题">
                  <a-input v-model:value="baseForm.title" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="系统名称">
                  <a-input v-model:value="baseForm.sysName" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="系统版本">
                  <a-input v-model:value="baseForm.sysVersion" placeholder="请输入" allow-clear readonly />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="公司名称">
                  <a-input v-model:value="baseForm.companyName" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="版权信息">
                  <a-input v-model:value="baseForm.copyright" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="公司简称">
                  <a-input v-model:value="baseForm.companyCode" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="公司地址">
                  <a-input v-model:value="baseForm.companyAddress" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="公司法人">
                  <a-input v-model:value="baseForm.companyContacts" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="公司电话">
                  <a-input v-model:value="baseForm.companyTelePhone" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="12">
                <a-form-item label="公司邮箱">
                  <a-input v-model:value="baseForm.companyEmail" placeholder="请输入" allow-clear />
                </a-form-item>
              </a-col>
              <a-col :span="24">
                <a-form-item label="系统描述">
                  <a-textarea v-model:value="baseForm.sysDescription" :auto-size="{ minRows: 5, maxRows: 10 }" placeholder="请输入" />
                </a-form-item>
              </a-col>
              <a-form-item label=" ">
                <a-button type="primary" @click.prevent="handleSubmit" :loading="btnLoading">保存</a-button>
              </a-form-item>
            </a-row>
          </a-tab-pane>
          <a-tab-pane :key="2" tab="流程设置" class="p-[30px]">
            <a-row>
              <a-col :span="10">
                <JnpfGroupTitle class="-mt-[12px] mb-[20px]" content="基础设置" />
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>流程办理<BasicHelp text="启用办理则系统会显示流程办理相关的菜单。" /></template>
                  <jnpf-switch v-model:value="baseForm.flowTodo" @change="onFlowTodoChange(baseForm.flowTodo)" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }" v-if="baseForm.flowTodo">
                  <template #label>流程签收<BasicHelp text="启用签收则系统会显示流程签收相关的菜单。" /></template>
                  <jnpf-switch v-model:value="baseForm.flowSign" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>加签层级<BasicHelp text="启用多层级可能导致加签死循环属于业务操作问题。" /></template>
                  <a-input-number
                    v-model:value="baseForm.addSignLevel"
                    placeholder="请输入"
                    :min="1"
                    :max="6"
                    :precision="0"
                    addon-after="级"
                    @change="onNumberChange($event, 'addSignLevel')" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>链接时效性<BasicHelp text="审批链接是否有效:审批链接发送时间 + 审批链接时效性。" /></template>
                  <a-input-number
                    v-model:value="baseForm.linkTime"
                    placeholder="请输入"
                    :min="1"
                    :precision="0"
                    addon-after="小时"
                    @change="onNumberChange($event, 'linkTime')" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>链接点击失效<BasicHelp text="禁用:不判断点击次数;启用:根据失效次数判断,点击超过次数链接失效。" /></template>
                  <jnpf-switch v-model:value="baseForm.isClick" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }" v-if="baseForm.isClick">
                  <template #label>失效次数</template>
                  <a-input-number
                    v-model:value="baseForm.unClickNum"
                    placeholder="请输入"
                    :min="1"
                    :precision="0"
                    addon-after="次"
                    @change="onNumberChange($event, 'unClickNum')" />
                </a-form-item>
                <JnpfGroupTitle class="mb-[20px]" content="委托设置" />
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>范围设置<BasicHelp text="设置受托人的选择范围" /></template>
                  <jnpf-select v-model:value="baseForm.delegateScope" :options="scopeOptions" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>委托确认<BasicHelp text="需受托人确认接收请求" /></template>
                  <jnpf-switch v-model:value="baseForm.delegateAck" />
                </a-form-item>
                <JnpfGroupTitle class="mb-[20px]" content="代理设置" />
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>范围设置<BasicHelp text="设置代理人的选择范围" /></template>
                  <jnpf-select v-model:value="baseForm.proxyScope" :options="scopeOptions" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>代理确认<BasicHelp text="需代理人确认接收请求" /></template>
                  <jnpf-switch v-model:value="baseForm.proxyAck" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }" label=" ">
                  <a-button type="primary" @click.prevent="handleSubmit">保存</a-button>
                </a-form-item>
              </a-col>
            </a-row>
          </a-tab-pane>
          <a-tab-pane :key="3" tab="模块设置" class="p-[30px]">
            <a-row>
              <a-col :span="10">
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>菜单消息详情<BasicHelp text="开启后,站内消息侧边栏中的菜单消息显示查看内容按钮。" /></template>
                  <jnpf-switch v-model:value="baseForm.menuMessageDetail" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>组织默认层级<BasicHelp text="系统默认9级,超过9级将对系统性能产生较大影响" /></template>
                  <a-input-number
                    v-model:value="baseForm.orgLevel"
                    placeholder="请输入"
                    :min="1"
                    :precision="0"
                    addon-after="级"
                    @change="onNumberChange($event, 'orgLevel')" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>岗位默认层级<BasicHelp text="系统默认9级,超过9级将对系统性能产生较大影响" /></template>
                  <a-input-number
                    v-model:value="baseForm.positionLevel"
                    placeholder="请输入"
                    :min="1"
                    :precision="0"
                    addon-after="级"
                    @change="onNumberChange($event, 'positionLevel')" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '120px' } }">
                  <template #label>系统岗位名称<BasicHelp text="系统内置的默认岗位,用于将人员分配到职能层级上,该岗位是虚拟岗位不显示在业务端" /></template>
                  <a-input v-model:value="baseForm.sysPositionName" placeholder="请输入" allow-clear />
                </a-form-item>
                <a-form-item label=" " :label-col="{ style: { width: '120px' } }">
                  <a-button type="primary" @click.prevent="handleSubmit">保存</a-button>
                </a-form-item>
              </a-col>
            </a-row>
          </a-tab-pane>
          <a-tab-pane :key="4" tab="日程设置" class="p-[30px]">
            <a-row>
              <a-col :span="10">
                <a-form-item label="默认视图">
                  <jnpf-radio v-model:value="baseForm.defaultView" :options="defaultViewOptions" option-type="button" button-style="solid" />
                </a-form-item>
                <a-form-item label="显示农历">
                  <a-switch v-model:checked="baseForm.showLunarCalendar" />
                </a-form-item>
                <a-form-item label="周第一天">
                  <jnpf-select v-model:value="baseForm.firstDay" :options="firstDayOptions" placeholder="请选择" />
                </a-form-item>
                <a-form-item label="默认时长">
                  <jnpf-select v-model:value="baseForm.duration" :options="durationOptions" placeholder="请选择" />
                </a-form-item>
                <a-form-item label=" ">
                  <a-button type="primary" @click.prevent="handleSubmit">保存</a-button>
                </a-form-item>
              </a-col>
            </a-row>
          </a-tab-pane>
          <a-tab-pane :key="5" tab="权限设置" class="p-[30px]">
            <a-alert
              show-icon
              type="warning"
              class="mb-[20px]"
              message="用户角色和角色权限始终启用。身份开关影响运行时授权,其他开关只控制配置入口;保存后请重新登录。" />
            <a-row :gutter="[0, 28]">
              <a-col :span="12">
                <JnpfGroupTitle class="mb-[20px]" content="权限功能开关" />
                <a-form-item :label-col="{ style: { width: '210px' } }">
                  <template #label>启用身份管理<BasicHelp text="开启后按当前身份过滤岗位和角色权限;关闭后不使用身份过滤。" /></template>
                  <jnpf-switch v-model:value="baseForm.standingSwitch" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '210px' } }">
                  <template #label>
                    启用组织/岗位角色配置
                    <BasicHelp text="控制角色管理及角色权限中的组织角色、岗位角色页签。" />
                  </template>
                  <jnpf-switch v-model:value="baseForm.orgPositionRoleSwitch" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '210px' } }">
                  <template #label>启用组织权限配置<BasicHelp text="控制权限管理中的组织权限页签。" /></template>
                  <jnpf-switch v-model:value="baseForm.orgPermissionSwitch" />
                </a-form-item>
                <a-form-item :label-col="{ style: { width: '210px' } }">
                  <template #label>启用权限集合配置<BasicHelp text="控制系统权限下的权限集合菜单。" /></template>
                  <jnpf-switch v-model:value="baseForm.permissionGroupSwitch" />
                </a-form-item>
                <a-form-item label=" " :label-col="{ style: { width: '210px' } }">
                  <a-button type="primary" :loading="btnLoading" @click.prevent="handleSubmit">保存</a-button>
                </a-form-item>
              </a-col>
              <a-col :span="24">
                <JnpfGroupTitle class="mb-[16px]" content="权限合并关系" />
                <PermissionRelationGuide :identity-enabled="isPermissionSwitchEnabled(baseForm.standingSwitch)" />
              </a-col>
            </a-row>
          </a-tab-pane>
        </a-tabs>
      </a-form>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.img-list {
  display: flex;
 
  .single-img-container {
    margin-right: 20px;
 
    :last-child {
      margin-right: 0;
    }
  }
}
</style>