|
|
@@ -1,17 +1,95 @@
|
|
|
<!-- 会员机构管理-机构管理-产业会员管理-新增 -->
|
|
|
<template>
|
|
|
- <app-drawer title="新增" width="900" v-model:show="show" :loading="loading" :refresh="refresh">
|
|
|
+ <app-drawer title="编辑" width="900" v-model:show="show" :loading="loading" :refresh="refresh">
|
|
|
+ <el-form ref="formRef" label-width="140px" :model="formData" :rules="formRules" :show-message="false">
|
|
|
+ <fieldset class="g-fieldset el-form--horizontal">
|
|
|
+ <legend class="g-fieldset__legend">机构信息</legend>
|
|
|
+ <el-form-item label="经纪会员" prop="userid">
|
|
|
+ <app-select-member v-model="formData.userid" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="角色权限信息:" prop="userid" >
|
|
|
+ <el-button @click="openComponent('Roles')">查看</el-button>
|
|
|
+ </el-form-item>
|
|
|
+ </fieldset>
|
|
|
+ <fieldset class="g-fieldset el-form--horizontal">
|
|
|
+ <legend class="g-fieldset__legend">权限信息</legend>
|
|
|
+ 会员市场:
|
|
|
+ </fieldset>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="onCancel(false)">{{ t('operation.cancel') }}</el-button>
|
|
|
+ <el-button type="primary" @click="onSubmit">{{ t('operation.save') }}</el-button>
|
|
|
+ </template>
|
|
|
+ <component ref="componentRef" v-bind="{ record }" :is="componentMap.get(componentId)" @closed="closeComponent" v-if="componentId" />
|
|
|
</app-drawer>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { shallowRef, PropType, defineAsyncComponent } from 'vue'
|
|
|
+import { shallowRef, PropType, onMounted, ref, defineAsyncComponent } from 'vue'
|
|
|
+import { ElMessage, FormInstance, FormRules } from 'element-plus'
|
|
|
import { i18n } from '@/stores'
|
|
|
+import { useComponent } from '@/hooks/component'
|
|
|
+import { roleadd } from '@/services/api/member'
|
|
|
import AppDrawer from '@pc/components/base/drawer/index.vue'
|
|
|
+import AppSelectMember from '@pc/components/modules/select-member/index.vue'
|
|
|
|
|
|
const { global: { t } } = i18n
|
|
|
-
|
|
|
+const formRef = ref<FormInstance>()
|
|
|
const show = shallowRef(true)
|
|
|
const refresh = shallowRef(false)
|
|
|
const loading = shallowRef(false)
|
|
|
+
|
|
|
+const props = defineProps({
|
|
|
+ record: {
|
|
|
+ type: Object as PropType<Member.OrganRoleRsp>
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const componentMap = new Map<string, unknown>([
|
|
|
+ ['Roles', defineAsyncComponent(() => import('@pc/components/modules/roles/index.vue'))], // 角色权限信息
|
|
|
+])
|
|
|
+const { componentRef, componentId, openComponent, closeComponent } = useComponent()
|
|
|
+
|
|
|
+const formData = ref<Partial<Member.RoleAddReq>>({
|
|
|
+ roleid: 9
|
|
|
+})
|
|
|
+
|
|
|
+// 表单验证规则
|
|
|
+const formRules: FormRules = {
|
|
|
+ userid: [{ required: true }],
|
|
|
+ marketid: [{ required: true }],
|
|
|
+ goodsid: [{ required: true }],
|
|
|
+}
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ const rawData = { ...formData.value }
|
|
|
+ formRef.value?.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ loading.value = true
|
|
|
+ roleadd({
|
|
|
+ data: rawData
|
|
|
+ }).then(() => {
|
|
|
+ ElMessage.success(t('common.tips3'))
|
|
|
+ onCancel(true)
|
|
|
+ }).catch((err) => {
|
|
|
+ ElMessage.error(t('common.tips4') + err)
|
|
|
+ }).finally(() => {
|
|
|
+ loading.value = false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const onCancel = (isRefresh = false) => {
|
|
|
+ show.value = false
|
|
|
+ refresh.value = isRefresh
|
|
|
+}
|
|
|
+
|
|
|
+onMounted(() => {
|
|
|
+ const { userid, } = props.record ?? {}
|
|
|
+ if (userid) {
|
|
|
+ formData.value.userid = userid
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
</script>
|