Przeglądaj źródła

新增登陆账户

huangbin 4 lat temu
rodzic
commit
efcd3859bf

+ 12 - 1
src/common/components/buttonList/index.vue

@@ -3,7 +3,7 @@
     <a-button :class="item.className"
               v-for="item in btnList"
               :key="item.lable"
-              @click.stop="item.callback">
+              @click.stop="onClick(item.callback)">
       {{item.lable}}
     </a-button>
   </div>
@@ -19,6 +19,17 @@ export default defineComponent({
             default: [],
             type: Array as PropType<BtnList[]>,
         },
+        index: {
+            default: 0,
+            type: Number,
+        },
+    },
+    setup(props, context) {
+        function onClick(fn: Function) {
+            context.emit('onClick', props.index);
+            fn && fn();
+        }
+        return { onClick };
     },
 });
 </script>

+ 2 - 4
src/services/proto/accountinfo/index.ts

@@ -1,6 +1,5 @@
 import { getUserId } from "@/services/bus/account";
 import { getLongTypeLoginID } from "@/services/bus/login";
-import { getAreaUserId } from "@/services/bus/user";
 import {
     ErmcpBizGroupReq, ErmcpBizGroupRsp, LoginaccountOperateReq,
     LoginaccountOperateRsp,
@@ -33,9 +32,8 @@ export const roleOperate = (param: ManagerRoleOperateReq): Promise<ManagerRoleOp
  */
 export const loginAccountOperate = (param: LoginaccountOperateReq): Promise<LoginaccountOperateRsp> => {
     const obj = {
-        userid: getUserId(),
-        modifierid: String(getLongTypeLoginID()),
-        areauserid: getAreaUserId(),
+        modifierid: Number(getLongTypeLoginID()),
+        areauserid: getUserId(),
     }
     Object.assign(param, obj)
     return protoMiddleware<LoginaccountOperateReq>(param, 'LoginaccountOperateReq', 'LoginaccountOperateRsp', 2)

+ 35 - 59
src/views/information/account_info/compoments/add-business/index.vue

@@ -25,10 +25,10 @@
                               v-model:value="formState.roleids">
               <a-row>
                 <a-col :span="12">
-                  <a-checkbox value="22">业务员</a-checkbox>
+                  <a-checkbox :value="22">业务员</a-checkbox>
                 </a-col>
                 <a-col :span="12">
-                  <a-checkbox value="23">跟单员</a-checkbox>
+                  <a-checkbox :value="23">跟单员</a-checkbox>
                 </a-col>
               </a-row>
             </a-checkbox-group>
@@ -77,73 +77,49 @@
 
 <script lang="ts">
 import { closeModal } from '@/common/setup/modal/index';
-import { defineComponent, ref, toRaw } from 'vue';
+import { defineComponent, ref, toRaw, watchEffect } from 'vue';
 import { ValidateErrorEntity } from 'ant-design-vue/es/form/interface';
-import { handleForm, FormState } from './setup';
-import {requestResultLoadingAndInfo} from "@/common/methods/request/resultInfo";
-import {QueryAddUserInfoApply} from "@/services/go/ermcp/customInfo";
-import {loginAccountOperate} from "@/services/proto/accountinfo";
-import {getUserId} from "@/services/bus/account";
-import {getLongTypeLoginID} from "@/services/bus/login";
-import {LoginaccountOperateReq} from "@/services/proto/accountinfo/interface";
+import { handleBusinessForm } from '../setup';
+import { BusinessFormState } from '../interface';
+import { requestResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
+import { loginAccountOperate } from '@/services/proto/accountinfo';
 
 export default defineComponent({
     name: 'add-business-info',
     components: {},
+    props: {
+        roleid: {
+            default: 0,
+            type: Number,
+        },
+    },
     setup(props, context) {
         // 控制关闭弹窗
         const { visible, cancel } = closeModal('account_info_business_btn_add');
         const loading = ref<boolean>(false);
-        const { rules, formState, formRef } = handleForm();
-        function submit() {
-
-            let reqParam :LoginaccountOperateReq = {
-                operatetype: 1,  // uint32 操作类型-1:新增 2:修改 3:新增管理员 4:修改管理员 5:锁定 6:解锁 7:注销 8:恢复 9:重置密码 10:新增登录帐号 11:停用用户 12:恢复用户 13:修改用户信息
-                // userid: number,  // uint64 用户ID(新增成功接口返回的userid)
-                // loginid: number, // uint64 登录ID(新增成功接口返回的loginid)
-                areauserid: getUserId(), // uint64 所属机构(当前登录userid 必填)
-                logincode: "10002130", // string 登录账号
-                accountname: "test432423", // string 账户名称
-                password: "123123", // string 登录密码(明文)
-                mobile: "131111111111", // string 手机号码(明文)
-                roleids: [22], // uint64 账号角色
-                // logintaaccounts: LoginTaaccount[], // LoginTaaccount 期货账户(勾选交易员必填)
-                modifierid: Number(getLongTypeLoginID()), // uint64 修改人ID(当前登录loginid 必填)
-
+        const { rules, formState, formRef } = handleBusinessForm();
+        watchEffect(() => {
+            if (visible.value) {
+                formState.roleids = [props.roleid];
             }
-            requestResultLoadingAndInfo(loginAccountOperate, reqParam, loading,  ['新增账户成功', '新增账户失败:'] ).then(() => {
-                cancel();
-                context.emit('refresh');
-            });
-
-            // formRef.value
-            //     .validate()
-            //     .then(() => {
-            //         const param = toRaw(formState);
-            //         console.log('values', param);
-            //
-            //         let reqParam :LoginaccountOperateReq = {
-            //             operatetype: 1,  // uint32 操作类型-1:新增 2:修改 3:新增管理员 4:修改管理员 5:锁定 6:解锁 7:注销 8:恢复 9:重置密码 10:新增登录帐号 11:停用用户 12:恢复用户 13:修改用户信息
-            //             // userid: number,  // uint64 用户ID(新增成功接口返回的userid)
-            //             // loginid: number, // uint64 登录ID(新增成功接口返回的loginid)
-            //             areauserid: getUserId(), // uint64 所属机构(当前登录userid 必填)
-            //             logincode: param.logincode, // string 登录账号
-            //             accountname: param.accountname, // string 账户名称
-            //             password: param.password, // string 登录密码(明文)
-            //             mobile: param.mobile, // string 手机号码(明文)
-            //             roleids: [22, 23], // uint64 账号角色
-            //             // logintaaccounts: LoginTaaccount[], // LoginTaaccount 期货账户(勾选交易员必填)
-            //             modifierid: getLongTypeLoginID(), // uint64 修改人ID(当前登录loginid 必填)
-            //         }
-            //         requestResultLoadingAndInfo(loginAccountOperate, reqParam, loading, OperateType === 1 ? ['保存草稿成功', '保存草稿失败:'] : ['新增客户资料成功', '新增客户资料失败:']).then(() => {
-            //             cancel();
-            //             context.emit('refresh');
-            //         });
-            //
-            //     })
-            //     .catch((error: ValidateErrorEntity<FormState>) => {
-            //         console.log('error', error);
-            //     });
+        });
+        function submit() {
+            formRef.value
+                .validate()
+                .then(() => {
+                    const param = toRaw(formState);
+                    const reqParam = {
+                        operatetype: 1,
+                    };
+                    Object.assign(reqParam, param);
+                    requestResultLoadingAndInfo(loginAccountOperate, reqParam, loading, ['新增账户成功', '新增账户失败:']).then(() => {
+                        cancel();
+                        context.emit('refresh');
+                    });
+                })
+                .catch((error: ValidateErrorEntity<BusinessFormState>) => {
+                    console.log('error', error);
+                });
         }
         return {
             formState,

+ 0 - 41
src/views/information/account_info/compoments/add-business/setup.ts

@@ -1,41 +0,0 @@
-import { RuleObject } from "ant-design-vue/lib/form/interface";
-import { reactive, ref, UnwrapRef } from "vue";
-
-export interface FormState {
-    logincode: string // 登录账号
-    accountname: string // 账户名称
-    password: string // 登录密码(明文)
-    mobile?: string // 手机号码(明文)
-    roleids: number[]; // uint64 账号角色
-}
-/**
- * 表单
- * @returns 
- */
-export function handleForm() {
-    const formRef = ref();
-    const formState: UnwrapRef<FormState> = reactive({
-        logincode: '',
-        accountname: '',
-        password: '',
-        mobile: '',
-        roleids: [],
-    })
-    // 验证账号角色
-    async function v_TradeUser(rule: RuleObject, value: number[]) {
-        debugger
-        if (formState.roleids.length) {
-            return Promise.resolve();
-
-        } else {
-            return Promise.reject('请选择账号角色');
-        }
-    }
-    const rules = {
-        logincode: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
-        accountname: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
-        password: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
-        roleids: [{ required: true, message: '请选择账号角色', trigger: 'change', type: 'array', }],
-    }
-    return { rules, formState, formRef }
-}

+ 7 - 0
src/views/information/account_info/compoments/interface.ts

@@ -0,0 +1,7 @@
+export interface BusinessFormState {
+    logincode: string // 登录账号
+    accountname: string // 账户名称
+    password: string // 登录密码(明文)
+    mobile?: string // 手机号码(明文)
+    roleids: number[]; // uint64 账号角色
+}

+ 25 - 3
src/views/information/account_info/compoments/setup.ts

@@ -1,6 +1,28 @@
-
-
-
+import { reactive, ref, UnwrapRef } from "vue";
+import { BusinessFormState } from './interface';
+
+
+/**
+ * 表单
+ * @returns 
+ */
+export function handleBusinessForm() {
+    const formRef = ref();
+    const formState: UnwrapRef<BusinessFormState> = reactive({
+        logincode: '',
+        accountname: '',
+        password: '',
+        mobile: '',
+        roleids: [],
+    })
+    const rules = {
+        logincode: [{ required: true, message: '请输入登录账号', trigger: 'blur' }],
+        accountname: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
+        password: [{ required: true, message: '请输入账户名称', trigger: 'blur' }],
+        roleids: [{ required: true, message: '请选择账号角色', trigger: 'change', type: 'array', }],
+    }
+    return { rules, formState, formRef }
+}
 
 
 

+ 31 - 42
src/views/information/account_info/list/account_info_business/index.vue

@@ -9,7 +9,7 @@
              aria-hidden="true">
           <use xlink:href="#icon-shuzhuangtu"></use>
         </svg>
-        多元世纪信息技术有限公司(6)
+        {{getUserName()}}
       </span>
     </div>
     <a-collapse class="spotCollapse"
@@ -33,63 +33,38 @@
           <a-row class="headRow">
             <a-col :span="12">{{item.rolename}}({{item.userlist.length}})</a-col>
             <a-col :span="12">
-              <BtnList :btnList="commonBtn" />
-            </a-col>
-          </a-row>
-        </template>
-        <a-row class="contRow"
-               v-for="(sub, i) in item.userlist"
-               :key="i + '11'">
-          <a-col :span="12">{{sub.accountname}}-{{sub.logincode}}</a-col>
-          <a-col :span="12">{{getLoginStatusEnumItemName(sub.loginstatus)}}</a-col>
-        </a-row>
-      </a-collapse-panel>
-    </a-collapse>
-    <!-- <a-collapse class="spotCollapse"
-                :bordered="false">
-      <template #expandIcon="props">
-        <svg class="icon svg-icon"
-             aria-hidden="true"
-             v-if="props.isActive == 0">
-          <use xlink:href="#icon-shouqi1"></use>
-        </svg>
-        <svg class="icon svg-icon"
-             aria-hidden="true"
-             v-else>
-          <use xlink:href="#icon-shouqi2"></use>
-        </svg>
-      </template>
-      <a-collapse-panel>
-        <template #header>
-          <a-row class="headRow">
-            <a-col :span="12">跟单员(3)</a-col>
-            <a-col :span="12">
-              <BtnList :btnList="commonBtn" />
+              <BtnList :btnList="commonBtn"
+                       :index="i"
+                       @onClick="openAction" />
             </a-col>
           </a-row>
         </template>
         <a-collapse class="busyCollapse"
-                    v-for="(item, i) in merchandiserList"
+                    @change="collapseChange(sub)"
+                    v-for="(sub, i) in item.userlist"
                     :key="i + '11'"
                     :bordered="false">
           <a-collapse-panel :show-arrow="false">
             <template #header>
               <a-row class="contRow">
-                <a-col :span="12">{{item.accountname}}-{{item.logincode}}</a-col>
-                <a-col :span="12">{{getLoginStatusEnumItemName(item.loginstatus)}}</a-col>
+                <a-col :span="12">{{sub.accountname}}-{{sub.logincode}}</a-col>
+                <a-col :span="12">{{getLoginStatusEnumItemName(sub.loginstatus)}}</a-col>
               </a-row>
             </template>
             <BtnList :btnList="forDataBtn" />
           </a-collapse-panel>
         </a-collapse>
       </a-collapse-panel>
-    </a-collapse> -->
-    <Add @refresh="queryTable" />
-    <Modify />
-    <Reset />
+    </a-collapse>
+    <Add @refresh="queryTable"
+         :roleid="roleid" />
+    <Modify @selectedData="selectedData"
+            @refresh="queryTable" />
+    <Reset @selectedData="selectedData"
+           @refresh="queryTable" />
     <Locked />
     <Cancel />
-    <Detail />
+    <Detail @selectedData="selectedData" />
   </div>
 </template>
 
@@ -97,6 +72,7 @@
 import { defineComponent, initData, getBtnList, contextMenu, BtnList } from '@/common/export/table';
 import filterCustomTable from '@/views/information/goods/components/filterTable/index.vue';
 import { queryTableList } from './setup';
+import { handleCollapse } from '../setup';
 import { getLoginStatusEnumItemName } from '@/common/constants/enumsName';
 import Add from '../../compoments/add-business/index.vue';
 import Modify from '../../compoments/modify-business/index.vue';
@@ -104,6 +80,9 @@ import Reset from '../../compoments/reset-business/index.vue';
 import Locked from '../../compoments/locked-business/index.vue';
 import Cancel from '../../compoments/cancel-business/index.vue';
 import Detail from '../../compoments/business-detail/index.vue';
+import { ErmcpLoginUser } from '@/services/go/ermcp/account/interface';
+import { getUserName } from '@/services/bus/user';
+import { ref } from 'vue';
 
 export default defineComponent({
     name: 'account_info_business',
@@ -121,12 +100,17 @@ export default defineComponent({
     setup() {
         const { loading, tableList, queryTable } = queryTableList();
         const { commonBtn, forDataBtn } = getBtnList('account_info_business', true);
+        const { selectedData, collapseChange } = handleCollapse<ErmcpLoginUser>();
+        const roleid = ref<number>(0);
         initData(() => {
             queryTable();
         });
         // 查询
         function search(value: any) {}
-
+        // 处理新增弹窗传递数据
+        function openAction(index: number) {
+            roleid.value = tableList.value[index].roleid;
+        }
         return {
             commonBtn,
             forDataBtn,
@@ -135,6 +119,11 @@ export default defineComponent({
             tableList,
             getLoginStatusEnumItemName,
             queryTable,
+            selectedData,
+            collapseChange,
+            getUserName,
+            openAction,
+            roleid,
         };
     },
 });

+ 1 - 1
src/views/information/account_info/list/account_info_business/setup.ts

@@ -13,4 +13,4 @@ export function queryTableList() {
             .then(res => tableList.value = res)
     }
     return { loading, tableList, queryTable }
-}
+}

+ 7 - 79
src/views/information/account_info/list/setup.ts

@@ -1,90 +1,18 @@
-import { QueryAccMgrLoginUser } from '@/services/go/ermcp/account';
-import { ErmcpLoginUser, ErmcpLoginUserEx } from '@/services/go/ermcp/account/interface';
-import { message } from 'ant-design-vue';
-import { ref } from 'vue';
+import { reactive } from "vue";
 
 /**
- * 处理 /账号列表: 交易用户 业务员 跟单员
+ * 处理折叠面板打开时候选中的数据
  * @returns 
  */
-export function handleAccountManager() {
-    // 交易用户
-    const traderList = ref<ErmcpLoginUserEx[]>([])
-    function getRoleList() {
-        QueryAccMgrLoginUser(2).then(res => {
-            const set = new Set<number>([])
-            traderList.value.length = 0;
-            res.forEach(e => {
-                const { roleid } = e;
-                if (!set.has(roleid)) { // 去重
-                    set.add(roleid)
-                    traderList.value.push(e)
-                }
-            })
-        }).catch(err => message.error(err))
+export function handleCollapse<T>() {
+    const selectedData = reactive({})
+    function collapseChange(value: T) {
+        Object.assign(selectedData, value)
     }
-    // 处理 跟单员 /  业务员 列表
-    function handleList(el: ErmcpLoginUser, type: string, set: Set<number>): ErmcpLoginUser | null {
-        const { userid, roletype } = el;
-        let result = null
-        if (roletype.includes(type)) {  // 过滤角色类型
-            if (!set.has(userid)) { // 去重
-                set.add(userid)
-                result = el
-            }
-        }
-        return result
-    }
-    // 业务员
-    const businesserList = ref<ErmcpLoginUser[]>([])
-    // 跟单员
-    const merchandiserList = ref<ErmcpLoginUser[]>([])
-    function getBusinesserList() {
-        QueryAccMgrLoginUser(1).then(res => {
-            const bSet = new Set<number>([]);
-            const mSet = new Set<number>([]);
-            const list: ErmcpLoginUser[] = []
-            res.forEach(e => {
-                // eslint-disable-next-line prefer-spread
-                list.push.apply(list, e.userlist)
-            })
-            list.forEach(el => {
-                // 业务员
-                const b = handleList(el, '22', bSet)
-                if (b) {
-                    businesserList.value.push(b)
-                }
-                // 跟单员
-                const m = handleList(el, '23', mSet)
-                if (m) {
-                    merchandiserList.value.push(m)
-                }
-            })
-        }).catch(err => message.error(err))
-    }
-    // 管理账户
-    const managersList = ref<ErmcpLoginUser[]>([])
-    function getManagersList() {
-        QueryAccMgrLoginUser(3).then(res => {
-            // const set = new Set<number>([])
-            console.log('managersList', res);
-
-            // traderList.value.length = 0;
-            // res.forEach(e => {
-            //     const { roleid } = e;
-            //     if (!set.has(roleid)) { // 去重
-            //         set.add(roleid)
-            //         traderList.value.push(e)
-            //     }
-            // })
-        }).catch(err => message.error(err))
-    }
-    return { traderList, businesserList, merchandiserList, getRoleList, getBusinesserList }
+    return { selectedData, collapseChange }
 }
 
 
-
-
 /**
  * 获取账户状态
  * @param type