ny
昨天 282fbc6488f4e8ceb5fda759f963ee88fbf7b999
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
<script setup lang="ts">
import { computed, onMounted, reactive, toRefs, unref } from 'vue';
 
import { useMessage } from '@jnpf/hooks';
 
import { useUserStore } from '@vben/stores';
 
import { changeAppAuth, getAppAuth, getDevUser, saveAppAuth } from '#/api/system/system';
import { QueryUserSelect } from '#/components/CommonModal';
 
defineOptions({ name: 'AppConfigAppAuth' });
 
interface State {
  baseForm: any;
  btnLoading: boolean;
  oldCreateUserId: string;
  disabled: boolean;
  btnDisabled: boolean;
}
const rangeOptions = [
  { id: 1, fullName: '全部开发成员' },
  { id: 0, fullName: '自定义' },
];
const state = reactive<State>({
  baseForm: {
    isAllDevUser: 1,
    fullName: '',
    createUserId: '',
    devUsers: [],
  },
  oldCreateUserId: '',
  btnLoading: false,
  btnDisabled: false,
  disabled: false,
});
const { baseForm, btnLoading, disabled, btnDisabled } = toRefs(state);
const { createMessage } = useMessage();
 
const userStore = useUserStore();
 
const getUserInfo: any = computed(() => userStore.getUserInfo || {});
 
function initData() {
  getAppAuth(unref(getUserInfo).systemId).then((res) => {
    state.baseForm = res.data;
    state.oldCreateUserId = res.data.createUserId;
    state.disabled = res.data.createUserId !== unref(getUserInfo).userId;
  });
}
function onCreateUserIdChange(id, data) {
  if (id === state.oldCreateUserId) return false;
  state.baseForm.fullName = data.fullName;
  state.btnDisabled = true;
  const query = { createUserId: id, systemId: unref(getUserInfo).systemId };
  changeAppAuth(query)
    .then((res) => {
      createMessage.success(res.msg);
      initData();
      state.btnDisabled = false;
    })
    .catch(() => {
      state.btnDisabled = false;
    });
}
function handleSubmit() {
  state.btnLoading = true;
  const query = { ...state.baseForm, systemId: unref(getUserInfo).systemId };
  saveAppAuth(query)
    .then((res) => {
      createMessage.success(res.msg);
      initData();
      state.btnLoading = false;
    })
    .catch(() => {
      state.btnLoading = false;
    });
}
 
onMounted(() => {
  initData();
});
</script>
<template>
  <div class="app-auth-v jnpf-config-wrapper">
    <div class="auth-common-pane">
      <div class="pane-header">
        <p>应用创建者</p>
        <p class="pane-header-subTitle">应用的创建者拥有应用管理后台的全部权限;</p>
      </div>
      <div class="pane-content">
        <a-form :colon="false" label-align="left" :label-col="{ style: { width: '100px' } }">
          <a-form-item label="创建人">
            <div class="flex">
              <span class="mr-[10px]">{{ baseForm.fullName }}</span>
              <QueryUserSelect v-model:value="baseForm.createUserId" required :api="getDevUser" @change="onCreateUserIdChange" v-if="!disabled">
                <template #action>
                  <span class="link-text" :class="{ 'link-text-disabled': disabled }">移交</span>
                </template>
              </QueryUserSelect>
            </div>
          </a-form-item>
        </a-form>
      </div>
    </div>
    <div class="auth-common-pane">
      <div class="pane-header">
        <p>应用开发者</p>
        <p class="pane-header-subTitle">
          用于创建者授权给其他开发者一起开发应用,应用开发者拥有“应用后台的开发权限”,有应用授权的查看权限没有操作权限,无删除应用;
        </p>
      </div>
      <div class="pane-content">
        <a-form :colon="false" label-align="left" :label-col="{ style: { width: '100px' } }">
          <a-form-item label="权限成员">
            <JnpfRadio v-model:value="baseForm.isAllDevUser" :options="rangeOptions" :disabled="disabled" />
          </a-form-item>
          <a-form-item label=" " class="!mt-[-20px]" v-if="!baseForm.isAllDevUser">
            <QueryUserSelect v-model:value="baseForm.devUsers" multiple placeholder="选择成员" :api="getDevUser" :disabled="disabled" />
          </a-form-item>
          <a-form-item label=" " v-if="!disabled">
            <a-button type="primary" @click.prevent="handleSubmit" :loading="btnLoading" :disabled="btnDisabled">保存</a-button>
          </a-form-item>
        </a-form>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.app-auth-v {
  padding: 20px 30px;
 
  .auth-common-pane {
    padding: 10px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color-base);
    border-radius: 8px;
 
    .pane-header {
      padding: 0 10px 10px;
      font-size: 18px;
      line-height: 30px;
      border-bottom: 1px solid var(--border-color-base);
 
      .pane-header-subTitle {
        margin-top: 4px;
        font-size: 14px;
        line-height: 20px;
        color: var(--text-color-label);
      }
    }
 
    .pane-content {
      padding: 10px;
    }
  }
}
</style>