|
|
@@ -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>
|