zhengyiming
2025-02-10 958b79ed89b9e742540f714a80261d222c0fc09b
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
<template>
  <ProDialog title="配置保险产品" v-model="innerVisible" destroy-on-close width="900px">
    <el-scrollbar max-height="400px">
      <el-collapse
        v-model="activeNames"
        @change="handleChange"
        class="configure-insure-product-dialog-collapse"
      >
        <el-collapse-item title="已授权产品" name="Authorized">
          <ConfigureInsureProductItem
            v-for="item in productList.hasAuthList"
            :key="item.productId"
            :productName="item.productName"
            :schemeTypeCount="item.schemeTypeCount"
            :schemeName="item.schemeName"
            isAuthed
            :beforeChange="() => beforeChange(item.productId, true)"
          />
        </el-collapse-item>
        <el-collapse-item title="未授权产品" name="Unauthorized">
          <ConfigureInsureProductItem
            v-for="item in productList.notAuthList"
            :key="item.productId"
            :productName="item.productName"
            :schemeTypeCount="item.schemeTypeCount"
            :schemeName="item.schemeName"
            :isAuthed="false"
            :beforeChange="() => beforeChange(item.productId, false)"
          />
        </el-collapse-item>
      </el-collapse>
    </el-scrollbar>
 
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="emit('onCancel')">取 消</el-button>
        <el-button type="primary" @click="emit('onCancel')">确 定</el-button>
      </span>
    </template>
  </ProDialog>
</template>
 
<script setup lang="ts">
import { ProDialog } from '@bole-core/components';
import { FormInstance } from 'element-plus';
import * as insureMarketProductServices from '@/services/api/InsureMarketProduct';
import { useQuery, useQueryClient } from '@tanstack/vue-query';
import ConfigureInsureProductItem from './ConfigureInsureProductItem.vue';
 
defineOptions({
  name: 'ConfigureInsureProductDialog',
});
 
type Props = {
  modelValue: boolean;
  form?: {
    id: string;
  };
};
 
const props = withDefaults(defineProps<Props>(), {
  modelValue: false,
});
 
const id = computed(() => props.form?.id);
 
const emit = defineEmits<{
  (e: 'update:modelValue', value: boolean): void;
  (e: 'onCancel'): void;
  (e: 'onSelect', value: API.HelpQuestionDto[]): void;
}>();
 
const innerVisible = computed({
  get() {
    return props.modelValue;
  },
  set(val) {
    emit('update:modelValue', val);
  },
});
 
const {
  data: productList,
  isLoading,
  refetch,
} = useQuery({
  queryKey: ['insureMarketProductServices/getUserCanAuthProductList', id],
  queryFn: async () => {
    return await insureMarketProductServices.getUserCanAuthProductList(
      { companyId: id.value },
      {
        showLoading: false,
      }
    );
  },
  placeholderData: () =>
    ({
      hasAuthList: [],
      notAuthList: [],
    } as API.GetCanAuthMarkProductOutput),
  enabled: computed(() => !!id.value),
});
 
const activeNames = ref();
 
function handleChange(val: string[]) {}
 
async function beforeChange(productId: string, isAuthed: boolean) {
  try {
    let params: API.InsureMarketProductToAuthInput = {
      companyId: id.value,
      authProductIds: isAuthed
        ? productList.value.hasAuthList
            .filter((x) => x.productId !== productId)
            .map((x) => x.productId)
        : [...productList.value.hasAuthList.map((x) => x.productId), productId],
    };
    let res = await insureMarketProductServices.insureMarketProductToAuth(params);
    if (res) {
      refetch({
        type: 'inactive',
      });
    }
    return !!res;
  } catch (error) {}
}
 
const formRef = ref<FormInstance>();
function handleConfirm() {
  if (!formRef.value) return;
  formRef.value.validate((valid) => {
    if (valid) {
      //   handleCreateOrUpdate();
    } else {
      return;
    }
  });
}
</script>
 
<style lang="scss" scoped>
@use '@/style/common.scss' as *;
 
.configure-insure-product-dialog-collapse {
  --bole-pro-form-input-height: 20px;
 
  :deep() {
    .el-collapse-item__header {
      font-size: 14px;
      font-weight: bold;
 
      &::before {
        margin-right: 8px;
        width: 2px;
        height: 14px;
        background-color: getCssVar('color', 'primary');
        content: '';
      }
    }
  }
}
</style>
<style lang="scss">
.text-over-tooltip-content {
  max-width: 600px;
}
</style>