li.shaoyi 1 年間 前
コミット
122c472a0f

+ 21 - 7
src/hooks/enum/index.ts

@@ -1,4 +1,4 @@
-import { reactive, toRefs, computed, onUnmounted } from 'vue'
+import { reactive, toRefs, onUnmounted } from 'vue'
 import { enumType } from '@/services/api/common'
 
 export function useEnum(code: string) {
@@ -7,11 +7,6 @@ export function useEnum(code: string) {
         enums: <Model.EnumTypeRsp[]>[]
     })
 
-    const enumOptions = computed(() => state.enums.map((e) => ({
-        label: e.enumdicname,
-        value: e.enumitemname
-    })))
-
     const controller = new AbortController()
     const readyCallbackMap = new Map<symbol, () => void>()
 
@@ -22,6 +17,25 @@ export function useEnum(code: string) {
         return enumdicname
     }
 
+    // 获取枚举列表
+    const getEnumOptions = (filtered: number | number[] = [], reverse = false) => {
+        const valuesSet = new Set(Array.isArray(filtered) ? filtered : [filtered])
+        const result = state.enums.map((e) => ({
+            label: e.enumdicname,
+            value: e.enumitemname
+        }))
+        if (valuesSet.size > 0) {
+            if (reverse) {
+                // 排除枚举
+                return result.filter((e) => !valuesSet.has(e.value))
+            } else {
+                // 匹配枚举
+                return result.filter((e) => valuesSet.has(e.value))
+            }
+        }
+        return result
+    }
+
     // 注册成功回调
     const registerEnumReadyCallback = (callback: () => void) => {
         if (state.loading) {
@@ -51,7 +65,7 @@ export function useEnum(code: string) {
 
     return {
         ...toRefs(state),
-        enumOptions,
+        getEnumOptions,
         getEnumTypeName,
         registerEnumReadyCallback
     }

+ 4 - 3
src/packages/pc/components/modules/enum/index.vue

@@ -1,6 +1,6 @@
 <template>
     <el-select v-model="selectedValue" :empty-values="[null, undefined, ...emptyValues]" :placeholder="placeholder">
-        <template v-for="item in enumOptions" :key="item.autoid">
+        <template v-for="item in getEnumOptions()" :key="item.autoid">
             <el-option :label="item.label" :value="item.value" />
         </template>
     </el-select>
@@ -28,7 +28,7 @@ const props = defineProps({
 
 const emit = defineEmits(['update:modelValue'])
 
-const { enumOptions, registerEnumReadyCallback } = useEnum(props.code)
+const { getEnumOptions, registerEnumReadyCallback } = useEnum(props.code)
 
 const selectedValue = computed({
     get: () => props.modelValue,
@@ -36,7 +36,8 @@ const selectedValue = computed({
 })
 
 registerEnumReadyCallback(() => {
-    if (!enumOptions.value.some((e) => e.value === props.modelValue)) {
+    const options = getEnumOptions()
+    if (!options.some((e) => e.value === props.modelValue)) {
         selectedValue.value = undefined
     }
 })

+ 2 - 2
src/packages/pc/views/investor/manage/user/index.vue

@@ -112,10 +112,10 @@ const onSearch = (clear = false) => {
 }
 
 areastatusEnum.registerEnumReadyCallback(() => {
-    filterOptons.selectList[0].options = areastatusEnum.enumOptions.value
+    filterOptons.selectList[0].options = areastatusEnum.getEnumOptions()
 })
 
 hasauthEnum.registerEnumReadyCallback(() => {
-    filterOptons.selectList[1].options = hasauthEnum.enumOptions.value
+    filterOptons.selectList[1].options = hasauthEnum.getEnumOptions()
 })
 </script>

+ 9 - 7
src/packages/pc/views/profitshare/institution/config/components/delete/index.vue

@@ -1,7 +1,7 @@
-<!-- 分润管理-机构分润配置-子机构分组管理-删除 -->
+<!-- 分润管理-机构分润配置-子机构分润配置-删除 -->
 <template>
     <app-drawer title="提示" v-model:show="show" :loading="loading" :refresh="refresh">
-        <div class="g-text-message">确认删除分组?</div>
+        <div class="g-text-message">确认删除该配置?</div>
         <template #footer>
             <el-button @click="onCancel(false)">取消</el-button>
             <el-button type="primary" @click="onSubmit">确认</el-button>
@@ -12,12 +12,12 @@
 <script lang="ts" setup>
 import { shallowRef, PropType } from 'vue'
 import { ElMessage } from 'element-plus'
-import { profitShareDelete } from '@/services/api/profitshare'
+import { profitShareDeleteSOrganSec } from '@/services/api/profitshare'
 import AppDrawer from '@pc/components/base/drawer/index.vue'
 
 const props = defineProps({
-    selectedRow: {
-        type: Object as PropType<Model.ProfitShareQueryPageRsp>,
+    record: {
+        type: Object as PropType<Model.InitProfitShareConfig>,
         required: true
     }
 })
@@ -33,9 +33,11 @@ const onCancel = (isRefresh = false) => {
 
 const onSubmit = () => {
     loading.value = true
-    profitShareDelete({
+    profitShareDeleteSOrganSec({
         data: {
-            groupId: props.selectedRow.subareagroupid
+            dividefeetype: props.record.dividefeetype,
+            marketid: props.record.marketid,
+            subareagroupid: props.record.subareagroupid,
         }
     }).then(() => {
         ElMessage.success('删除成功')

+ 178 - 0
src/packages/pc/views/profitshare/institution/config/components/edit/index.vue

@@ -0,0 +1,178 @@
+<!-- 分润管理-机构分润配置-子机构分润配置-编辑 -->
+<template>
+    <app-drawer title="编辑" width="480" v-model:show="show" :refresh="refresh" :loading="loading">
+        <el-form ref="formRef" class="el-form--vertical" label-width="100px" :model="formData" :rules="formRules"
+            :show-message="false">
+            <el-form-item label="分润费用类型">
+                {{ config.feeName }}
+            </el-form-item>
+            <el-form-item label="市场" v-if="config.marketId">
+                {{ config.marketName }}
+            </el-form-item>
+            <el-form-item label="分组" prop="subareagroupid">
+                <el-select v-model="formData.subareagroupid" :empty-values="[null, undefined, 0]">
+                    <el-option v-for="item in dataList" :key="item.subareagroupid" :label="item.subareagroupname"
+                        :value="item.subareagroupid" />
+                </el-select>
+            </el-form-item>
+            <el-form-item label="分润算法" prop="dividetype">
+                <el-radio-group v-model="formData.dividetype">
+                    <el-radio v-for="item in premiumAutoModeEnum.getEnumOptions(1)" :key="item.value"
+                        :value="item.value">
+                        {{ item.label }}
+                    </el-radio>
+                </el-radio-group>
+            </el-form-item>
+            <el-form-item label="分润方式" prop="dividemode">
+                <el-radio-group v-model="formData.dividemode">
+                    <el-radio v-for="item in areadividemodeEnum.getEnumOptions()" :key="item.value" :value="item.value">
+                        {{ item.label }}
+                    </el-radio>
+                </el-radio-group>
+            </el-form-item>
+            <el-form-item label="分润值" prop="dividevalue">
+                <el-input-number v-model="formData.dividevalue" placeholder="请输入" :min="0" :max="100" />
+            </el-form-item>
+        </el-form>
+        <template #footer>
+            <el-button @click="onCancel(false)">取消</el-button>
+            <el-button type="primary" @click="onSubmit">提交</el-button>
+        </template>
+    </app-drawer>
+</template>
+
+<script lang="ts" setup>
+import { ref, PropType, toRaw, onMounted } from 'vue'
+import { ElMessage, FormInstance, FormRules } from 'element-plus'
+import { useEnum } from '@/hooks/enum'
+import { useRequest } from '@/hooks/request'
+import { profitShareQueryPage, profitShareDelSOrganSec } from '@/services/api/profitshare'
+import AppDrawer from '@pc/components/base/drawer/index.vue'
+
+interface Config {
+    feeType: number;
+    feeName: string;
+    marketId: number;
+    marketName: string;
+}
+
+const props = defineProps({
+    config: {
+        type: Object as PropType<Config>,
+        required: true
+    },
+    record: {
+        type: Object as PropType<Model.InitProfitShareConfig>
+    }
+})
+
+// 分润算法
+const premiumAutoModeEnum = useEnum('premiumAutoMode')
+// 分润方式
+const areadividemodeEnum = useEnum('areadividemode')
+
+const formRef = ref<FormInstance>()
+const show = ref(true)
+const refresh = ref(false)
+const loading = ref(false)
+
+// 查询分组
+const { dataList } = useRequest(profitShareQueryPage, {
+    onError: (err) => {
+        ElMessage.error(err)
+    }
+})
+
+const formData = ref<Model.ProfitShareDelSOrganSecReq>({
+    dividefeetype: props.config.feeType,
+    dividemode: 1,
+    dividetype: 1,
+    dividevalue: 0,
+    isedit: 0,
+    marketid: props.config.marketId,
+    subareagroupid: 0
+})
+
+// 表单验证规则
+const formRules: FormRules = {
+    subareagroupid: [{
+        required: true,
+        validator: (rule, value, callback) => {
+            if (value) {
+                callback()
+            } else {
+                callback(new Error('请选择分组'))
+            }
+        }
+    }],
+    dividetype: [{
+        required: true,
+        validator: (rule, value, callback) => {
+            if (value) {
+                callback()
+            } else {
+                callback(new Error('请选择分润算法'))
+            }
+        }
+    }],
+    dividemode: [{
+        required: true,
+        validator: (rule, value, callback) => {
+            if (value) {
+                callback()
+            } else {
+                callback(new Error('请选择分润方式'))
+            }
+        }
+    }],
+    dividevalue: [{
+        required: true,
+        validator: (rule, value, callback) => {
+            if (value) {
+                callback()
+            } else {
+                callback(new Error('请输入分润值'))
+            }
+        }
+    }],
+}
+
+const onCancel = (isRefresh = false) => {
+    show.value = false
+    refresh.value = isRefresh
+}
+
+const onSubmit = () => {
+    formRef.value?.validate((valid) => {
+        if (valid) {
+            const rawData = toRaw(formData.value)
+            loading.value = true
+            profitShareDelSOrganSec({
+                data: rawData
+            }).then(() => {
+                ElMessage.success('保存成功')
+                onCancel(true)
+            }).catch((err) => {
+                ElMessage.error('保存失败:' + err)
+            }).finally(() => {
+                loading.value = false
+            })
+        }
+    })
+}
+
+onMounted(() => {
+    const record = props.record
+    if (record) {
+        formData.value = {
+            dividefeetype: record.dividefeetype,
+            dividemode: record.dividemode,
+            dividetype: record.dividetype,
+            dividevalue: record.dividevalue * 100,
+            isedit: 1,
+            marketid: record.marketid,
+            subareagroupid: record.subareagroupid
+        }
+    }
+})
+</script>

+ 107 - 1
src/packages/pc/views/profitshare/institution/config/index.vue

@@ -1,7 +1,113 @@
 <!-- 分润管理-机构分润配置-子机构分润配置 -->
 <template>
-    <app-view></app-view>
+    <app-view>
+        <fieldset v-for="(item, index) in dataList" :key="index">
+            <legend>{{ item.feeName + (item.marketId && ` [${item.marketName}]`) }}</legend>
+            <app-table :data="item.configs" v-model:columns="tableColumns">
+                <template #headerLeft>
+                    <app-operation :data-list="getFilteredButtons(['profitshare_institution_config_add'])"
+                        @click="(code: string) => showComponent(code, item)" />
+                </template>
+                <!-- 操作 -->
+                <template #operate="{ row }">
+                    <app-operation size="small"
+                        :data-list="getFilteredButtons(['profitshare_institution_config_modify', 'profitshare_institution_config_delete'])"
+                        @click="(code: string) => showComponent(code, item, row)" circle />
+                </template>
+            </app-table>
+        </fieldset>
+        <component :is="componentMap.get(componentId)" v-bind="{ config, record }" @closed="closeComponent"
+            v-if="componentId" />
+    </app-view>
 </template>
 
 <script lang="ts" setup>
+import { ref } from 'vue'
+import { ElMessage } from 'element-plus'
+import { formatDate, parsePercent } from '@/filters'
+import { useEnum } from '@/hooks/enum'
+import { useRequest } from '@/hooks/request'
+import { useOperation } from '@/hooks/operation'
+import { initProfitShare } from '@/services/api/profitshare'
+import AppTable from '@pc/components/base/table/index.vue'
+import AppOperation from '@pc/components/base/operation/index.vue'
+
+interface Data {
+    feeType: number;
+    feeName: string;
+    marketId: number;
+    marketName: string;
+    configs: Model.InitProfitShareConfig[];
+}
+
+// 分润算法
+const premiumAutoModeEnum = useEnum('premiumAutoMode')
+// 分润方式
+const areadividemodeEnum = useEnum('areadividemode')
+
+const config = ref<Data>()
+const dataList = ref<Data[]>([])
+
+const { componentMap, componentId, record, openComponent, closeComponent, getFilteredButtons } = useOperation<Model.InitProfitShareConfig>({
+    onClose: () => run()
+})
+
+const { run } = useRequest(initProfitShare, {
+    onSuccess: (res) => {
+        const { dividefeetype1, dividefeetype6, dividefeetype9, dividefeetype1name, dividefeetype6name, dividefeetype9name, ft1, ft2, ft3, mks } = res.data
+        dataList.value = []
+        if (dividefeetype1 === 1) {
+            mks.forEach((e) => {
+                dataList.value.push({
+                    feeType: 1,
+                    feeName: dividefeetype1name,
+                    marketId: e.marketid,
+                    marketName: e.marketname,
+                    configs: (ft1 && ft1[e.marketid]) || []
+                })
+            })
+        }
+        if (dividefeetype6 === 1) {
+            dataList.value.push({
+                feeType: 6,
+                feeName: dividefeetype6name,
+                marketId: 0,
+                marketName: '',
+                configs: ft2 || []
+            })
+        }
+        if (dividefeetype9 === 1) {
+            mks.forEach((e) => {
+                if (e.trademode !== 17) {
+                    dataList.value.push({
+                        feeType: 9,
+                        feeName: dividefeetype9name,
+                        marketId: e.marketid,
+                        marketName: e.marketname,
+                        configs: (ft3 && ft3[e.marketid]) || []
+                    })
+                }
+            })
+        }
+    },
+    onError: (err) => {
+        ElMessage.error(err)
+        dataList.value = []
+    }
+})
+
+const tableColumns = ref<Model.TableColumn[]>([
+    { field: 'subareagroupname', label: '分组' },
+    { field: 'dividetype', label: '分润算法', formatValue: (val) => premiumAutoModeEnum.getEnumTypeName(val) },
+    { field: 'dividemode', label: '分润方式', formatValue: (val) => areadividemodeEnum.getEnumTypeName(val) },
+    { field: 'dividevalue', label: '分润值', formatValue: (val) => parsePercent(val) },
+    { field: 'creatorid', label: '创建人' },
+    { field: 'createtime', label: '创建时间', formatValue: (val) => formatDate(val) },
+    { field: 'operate', label: '操作', fixed: 'right' }
+])
+
+const showComponent = (code: string, data: Data, row?: Model.InitProfitShareConfig) => {
+    config.value = data
+    openComponent(code, row)
+}
 </script>

+ 6 - 6
src/packages/pc/views/profitshare/institution/group/components/edit/index.vue

@@ -78,13 +78,13 @@ const onSubmit = () => {
 }
 
 onMounted(() => {
-    const params = props.record
-    if (params) {
+    const record = props.record
+    if (record) {
         formData.value = {
-            subareagroupid: params.subareagroupid,
-            remark: params.remark,
-            subareagroupname: params.subareagroupname,
-            subareagrouptype: params.subareagrouptype
+            subareagroupid: record.subareagroupid,
+            remark: record.remark,
+            subareagroupname: record.subareagroupname,
+            subareagrouptype: record.subareagrouptype
         }
     }
 })

+ 1 - 1
src/packages/pc/views/query/order/order/index.vue

@@ -148,6 +148,6 @@ registerMarketReadyCallback(() => {
 })
 
 buildtypeEnum.registerEnumReadyCallback(() => {
-    filterOptons.selectList[2].options = buildtypeEnum.enumOptions.value
+    filterOptons.selectList[2].options = buildtypeEnum.getEnumOptions()
 })
 </script>

+ 1 - 1
src/packages/pc/views/query/order/trade/index.vue

@@ -153,6 +153,6 @@ registerMarketReadyCallback(() => {
 })
 
 buildtypeEnum.registerEnumReadyCallback(() => {
-    filterOptons.selectList[3].options = buildtypeEnum.enumOptions.value
+    filterOptons.selectList[3].options = buildtypeEnum.getEnumOptions()
 })
 </script>

+ 1 - 1
src/packages/pc/views/query/other/bank_inout/index.vue

@@ -110,6 +110,6 @@ const onSearch = (clear = false) => {
 }
 
 executetypeEnum.registerEnumReadyCallback(() => {
-    filterOptons.selectList[0].options = executetypeEnum.enumOptions.value
+    filterOptons.selectList[0].options = executetypeEnum.getEnumOptions()
 })
 </script>

+ 2 - 2
src/packages/pc/views/query/other/bank_statement/index.vue

@@ -32,7 +32,7 @@ import AppFilter from '@pc/components/base/table-filter/index.vue'
 import AppPagination from '@pc/components/base/pagination/index.vue'
 import AppOperation from '@pc/components/base/operation/index.vue'
 
-const { enumOptions, registerEnumReadyCallback } = useEnum('operatetypesearch') // 业务类型
+const { getEnumOptions, registerEnumReadyCallback } = useEnum('operatetypesearch') // 业务类型
 const queryParams = shallowRef<Model.AmountStreamReq>()
 
 const { filterOptons, getQueryParams } = useDataFilter<Model.AmountStreamReq>()
@@ -110,6 +110,6 @@ const processRequiredParams = (callback: (params: Model.AmountStreamReq) => void
 }
 
 registerEnumReadyCallback(() => {
-    filterOptons.selectList[1].options = enumOptions.value
+    filterOptons.selectList[1].options = getEnumOptions()
 })
 </script>

+ 1 - 1
src/packages/pc/views/query/warehouse_receipt_order/order/index.vue

@@ -135,6 +135,6 @@ registerMarketReadyCallback(() => {
 })
 
 wrtradetype2Enum.registerEnumReadyCallback(() => {
-    filterOptons.selectList[1].options = wrtradetype2Enum.enumOptions.value
+    filterOptons.selectList[1].options = wrtradetype2Enum.getEnumOptions()
 })
 </script>

+ 2 - 2
src/types/model/profitshare.d.ts

@@ -86,11 +86,11 @@ declare namespace Model {
         dividefeetype9: number;
         dividefeetype9name: string;
         ft1: {
-            [number]: InitProfitShareConfig[];
+            [key: number]: InitProfitShareConfig[];
         };
         ft2: InitProfitShareConfig[];
         ft3: {
-            [number]: InitProfitShareConfig[];
+            [key: number]: InitProfitShareConfig[];
         };
         mks: InitProfitShareMarket[];
     }