|
@@ -32,6 +32,14 @@ const useOptions = (
|
|
|
return mainStore?.myUserInfo
|
|
|
})
|
|
|
|
|
|
+ const isAdmin = computed(() => {
|
|
|
+ return userInfo?.value?.role === 'ADMIN'
|
|
|
+ })
|
|
|
+
|
|
|
+ const isChief = computed(() => {
|
|
|
+ return userInfo?.value?.role === 'CHIEF'
|
|
|
+ })
|
|
|
+
|
|
|
const dataModel = reactive<DataModel>(unref(initModel) || {})
|
|
|
|
|
|
if (isRef(initModel)) {
|
|
@@ -85,16 +93,20 @@ const useOptions = (
|
|
|
})
|
|
|
|
|
|
const groupList = computed<Group[]>(() => {
|
|
|
- return groupListResult?.value?.map((n) => {
|
|
|
- return {
|
|
|
- value: n,
|
|
|
- label: `第${n}组`,
|
|
|
- }
|
|
|
- })
|
|
|
+ const list =
|
|
|
+ groupListResult?.value?.map((n) => {
|
|
|
+ return {
|
|
|
+ value: n,
|
|
|
+ label: `第${n}组`,
|
|
|
+ }
|
|
|
+ }) || []
|
|
|
+ return list?.length && (isAdmin.value || isChief.value)
|
|
|
+ ? [{ label: '全部', value: void 0 } as unknown as Group].concat(list)
|
|
|
+ : list
|
|
|
})
|
|
|
|
|
|
const groupListWithAll = computed(() => {
|
|
|
- return groupList.value?.length ? [{ label: '全部', value: void 0 } as unknown as Group].concat(groupList.value) : []
|
|
|
+ return groupList.value
|
|
|
})
|
|
|
|
|
|
watch(
|
|
@@ -106,7 +118,8 @@ const useOptions = (
|
|
|
if (!dataModel.question && userInfo.value?.mainNumber) {
|
|
|
dataModel.question = userInfo.value.mainNumber
|
|
|
}
|
|
|
- if (!dataModel.group && userInfo.value?.markingGroupNumber) {
|
|
|
+
|
|
|
+ if (!dataModel.group && userInfo.value?.markingGroupNumber && !(isAdmin.value || isChief.value)) {
|
|
|
dataModel.group = userInfo.value.markingGroupNumber
|
|
|
}
|
|
|
},
|
|
@@ -152,9 +165,9 @@ const useOptions = (
|
|
|
{ deep: true }
|
|
|
)
|
|
|
watch(
|
|
|
- [groupList, userInfo],
|
|
|
+ [groupList, userInfo, isAdmin, isChief],
|
|
|
() => {
|
|
|
- if (userInfo.value?.markingGroupNumber && !dataModel.question) {
|
|
|
+ if (userInfo.value?.markingGroupNumber && !dataModel.question && !(isAdmin.value || isChief.value)) {
|
|
|
changeModelValue('group')(userInfo.value?.markingGroupNumber)
|
|
|
}
|
|
|
},
|
|
@@ -165,9 +178,9 @@ const useOptions = (
|
|
|
const initFinish = ref<boolean>(false)
|
|
|
|
|
|
const destroyInit = watch(
|
|
|
- dataModel,
|
|
|
+ [dataModel, isAdmin, isChief],
|
|
|
() => {
|
|
|
- if (types.every((t) => dataModel[t])) {
|
|
|
+ if (types.every((t) => dataModel[t] || (t === 'group' && (isAdmin.value || isChief.value)))) {
|
|
|
nextTick(() => {
|
|
|
initCallbacks.forEach((cb) => cb(dataModel))
|
|
|
initFinish.value = true
|