From 08c13963b0199d69b761f0fce5794c0aeb000aac Mon Sep 17 00:00:00 2001
From: boyang <1920788179@qq.com>
Date: Wed, 7 May 2025 15:21:07 +0800
Subject: [PATCH] feat: 添加课题组成员查询方式

---
 src/pages/Order/OrderList/OrderDrawer.tsx | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------------------
 src/services/definition.ts                |  12 ++++++++++++
 src/services/request.ts                   | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 268 insertions(+), 41 deletions(-)

diff --git a/src/pages/Order/OrderList/OrderDrawer.tsx b/src/pages/Order/OrderList/OrderDrawer.tsx
index b178dcd..493cfff 100644
--- a/src/pages/Order/OrderList/OrderDrawer.tsx
+++ b/src/pages/Order/OrderList/OrderDrawer.tsx
@@ -11,6 +11,7 @@ import {
   postKingdeeRepMaterialUnit,
   postKingdeeRepMeasureUnit,
   postPrepaidPhoneAvailableList,
+  postResearchGroupsMemberExists,
   postResearchGroupsNameSet,
   postServiceConstCompanyType,
   postServiceConstOrderSource,
@@ -1242,49 +1243,132 @@ export default ({ onClose, data, subOrders, orderOptType }) => {
           <ProFormDependency name={['companyType']}>
             {({ companyType }) => {
               const renderInstitutionContactName = () => (
-                <Group>
-                  <ProFormSelect
-                    key="institutionContactName"
-                    width="xl"
-                    showSearch
-                    name="institutionContactName"
-                    rules={[{ required: true, message: '请输入课题组名称!' }]}
-                    request={async (value) => {
-                      const keywords = value?.keyWords || '';
-                      const res = await postResearchGroupsNameSet({
-                        data: { status: 'ADD_AUDIT_PASS', groupName: keywords },
-                      });
-                      return Object.entries(res?.data || {}).map(
-                        ([researchGroupsId, researchGroupsName]) => ({
-                          label: researchGroupsName,
-                          value: researchGroupsName, // 使用 researchGroupsId 作为 value
-                          key: researchGroupsId,
-                          id: researchGroupsId,
-                        }),
-                      );
-                    }}
-                    fieldProps={{
-                      filterOption: () => true,
-                      onChange: (_, option) => {
-                        form.setFieldsValue({
-                          researchGroupId: option?.id || '',
+                <>
+                  <Group>
+                    <ProFormSelect
+                      key="institutionContactName"
+                      width="xl"
+                      showSearch
+                      name="institutionContactName"
+                      rules={[{ required: true, message: '请输入课题组名称!' }]}
+                      request={async (value) => {
+                        const keywords = value?.keyWords || '';
+                        const res = await postResearchGroupsNameSet({
+                          data: {
+                            status: 'ADD_AUDIT_PASS',
+                            groupName: keywords,
+                          },
                         });
-                      },
+                        return Object.entries(res?.data || {}).map(
+                          ([researchGroupsId, researchGroupsName]) => ({
+                            label: researchGroupsName,
+                            value: researchGroupsName, // 使用 researchGroupsId 作为 value
+                            key: researchGroupsId,
+                            id: researchGroupsId,
+                          }),
+                        );
+                      }}
+                      fieldProps={{
+                        filterOption: () => true,
+                        onChange: async (_, option) => {
+                          const researchGroupId = option?.id || '';
+                          form.setFieldsValue({
+                            researchGroupId: researchGroupId,
+                          });
+
+                          // 检查用户是否已经是该课题组成员
+                          if (researchGroupId) {
+                            const customerContact = form.getFieldValue(
+                              'customerContactNumber',
+                            );
+                            if (customerContact) {
+                              try {
+                                const res =
+                                  await postResearchGroupsMemberExists({
+                                    query: {
+                                      customerContact,
+                                      researchGroupId: Number(researchGroupId),
+                                    },
+                                  });
+
+                                // 响应码200表示请求成功,值为false表示用户不是课题组成员
+                                // 必须先检查res是否存在并且是否有200属性
+                                console.log(res, '5656res');
+                                const isMember = res;
+
+                                if (!isMember) {
+                                  // 显示用户将被添加到课题组的信息
+                                  form.setFields([
+                                    {
+                                      name: 'researchGroupWarning',
+                                      value: true,
+                                    },
+                                  ]);
+                                } else {
+                                  form.setFields([
+                                    {
+                                      name: 'researchGroupWarning',
+                                      value: false,
+                                    },
+                                  ]);
+                                }
+                              } catch (error) {
+                                console.error('检查课题组成员失败:', error);
+                              }
+                            }
+                          }
+                        },
+                      }}
+                      debounceTime={1000}
+                      label="课题组名称"
+                      placeholder="请输入名称"
+                    />
+                    <ProFormDigit
+                      readonly
+                      key="researchGroupId"
+                      width="md"
+                      name="researchGroupId"
+                      label="课题组Id"
+                      fieldProps={{ precision: 0 }} // 只允许整数
+                      rules={[{ required: true, message: '请重新选择课题组!' }]}
+                    />
+                  </Group>
+                  <ProFormDependency
+                    name={[
+                      'researchGroupWarning',
+                      'institutionContactName',
+                      'researchGroupId',
+                    ]}
+                  >
+                    {({
+                      researchGroupWarning,
+                      institutionContactName,
+                      researchGroupId,
+                    }) => {
+                      if (
+                        researchGroupWarning &&
+                        institutionContactName &&
+                        researchGroupId
+                      ) {
+                        const customerNameString =
+                          form.getFieldValue('customerNameString') || '客户';
+                        return (
+                          <div
+                            style={{
+                              color: 'red',
+                              marginBottom: '15px',
+                              marginTop: '0px',
+                            }}
+                          >
+                            订单提交后{customerNameString}将默认加入
+                            {institutionContactName}课题组
+                          </div>
+                        );
+                      }
+                      return null;
                     }}
-                    debounceTime={1000}
-                    label="课题组名称"
-                    placeholder="请输入名称"
-                  />
-                  <ProFormDigit
-                    readonly
-                    key="researchGroupId"
-                    width="md"
-                    name="researchGroupId"
-                    label="课题组Id"
-                    fieldProps={{ precision: 0 }} // 只允许整数
-                    rules={[{ required: true, message: '请重新选择课题组!' }]}
-                  />
-                </Group>
+                  </ProFormDependency>
+                </>
               );
               const renderPlatformType = (fieldKey) => (
                 <ProFormSelect
diff --git a/src/services/definition.ts b/src/services/definition.ts
index 0c8aecb..1c45598 100644
--- a/src/services/definition.ts
+++ b/src/services/definition.ts
@@ -3838,6 +3838,12 @@ export interface ResearchGroupListRequest {
   end?: number;
   /**
    * @description
+   *   课题组ID
+   * @format int64
+   */
+  groupId?: number;
+  /**
+   * @description
    *   课题组名称
    */
   groupName?: string;
@@ -4134,6 +4140,12 @@ export interface ResearchGroupsAccessDTO {
   deleteFlag?: number;
   /**
    * @description
+   *   课题组id
+   * @format int64
+   */
+  groupId?: number;
+  /**
+   * @description
    *   课题组名称
    */
   groupName?: string;
diff --git a/src/services/request.ts b/src/services/request.ts
index 2fbae33..afb252b 100644
--- a/src/services/request.ts
+++ b/src/services/request.ts
@@ -15311,6 +15311,82 @@ export const postResearchGroupsList = /* #__PURE__ */ (() => {
   return request;
 })();
 
+/** @description request parameter type for postResearchGroupsMemberExists */
+export interface PostResearchGroupsMemberExistsOption {
+  /**
+   * @description
+   *   customerContact
+   */
+  query?: {
+    /**
+        @description
+          customerContact */
+    customerContact?: string;
+    /**
+        @description
+          researchGroupId
+        @format int64 */
+    researchGroupId?: number;
+  };
+}
+
+/** @description response type for postResearchGroupsMemberExists */
+export interface PostResearchGroupsMemberExistsResponse {
+  /**
+   * @description
+   *   OK
+   */
+  200: boolean;
+  /**
+   * @description
+   *   Created
+   */
+  201: any;
+  /**
+   * @description
+   *   Unauthorized
+   */
+  401: any;
+  /**
+   * @description
+   *   Forbidden
+   */
+  403: any;
+  /**
+   * @description
+   *   Not Found
+   */
+  404: any;
+}
+
+export type PostResearchGroupsMemberExistsResponseSuccess =
+  PostResearchGroupsMemberExistsResponse[200];
+/**
+ * @description
+ *   查询课题组成员
+ * @tags research-groups-controller
+ * @produces *
+ * @consumes application/json
+ */
+export const postResearchGroupsMemberExists = /* #__PURE__ */ (() => {
+  const method = 'post';
+  const url = '/research/groups/memberExists';
+  function request(
+    option?: PostResearchGroupsMemberExistsOption,
+  ): Promise<PostResearchGroupsMemberExistsResponseSuccess> {
+    return requester(request.url, {
+      method: request.method,
+      ...option,
+    }) as unknown as Promise<PostResearchGroupsMemberExistsResponseSuccess>;
+  }
+
+  /** http method */
+  request.method = method;
+  /** request url */
+  request.url = url;
+  return request;
+})();
+
 /** @description request parameter type for postResearchGroupsNameSet */
 export interface PostResearchGroupsNameSetOption {
   /**
@@ -21089,6 +21165,61 @@ export const postServiceOrderAuditPaymentReceipt = /* #__PURE__ */ (() => {
   return request;
 })();
 
+/** @description response type for postServiceOrderBatchCaculateAndSetIntegral */
+export interface PostServiceOrderBatchCaculateAndSetIntegralResponse {
+  /**
+   * @description
+   *   OK
+   */
+  200: ServerResult;
+  /**
+   * @description
+   *   Created
+   */
+  201: any;
+  /**
+   * @description
+   *   Unauthorized
+   */
+  401: any;
+  /**
+   * @description
+   *   Forbidden
+   */
+  403: any;
+  /**
+   * @description
+   *   Not Found
+   */
+  404: any;
+}
+
+export type PostServiceOrderBatchCaculateAndSetIntegralResponseSuccess =
+  PostServiceOrderBatchCaculateAndSetIntegralResponse[200];
+/**
+ * @description
+ *   计算积分
+ * @tags 内部订单
+ * @produces *
+ * @consumes application/json
+ */
+export const postServiceOrderBatchCaculateAndSetIntegral =
+  /* #__PURE__ */ (() => {
+    const method = 'post';
+    const url = '/service/order/batchCaculateAndSetIntegral';
+    function request(): Promise<PostServiceOrderBatchCaculateAndSetIntegralResponseSuccess> {
+      return requester(request.url, {
+        method: request.method,
+      }) as unknown as Promise<PostServiceOrderBatchCaculateAndSetIntegralResponseSuccess>;
+    }
+
+    /** http method */
+    request.method = method;
+    /** request url */
+    request.url = url;
+    return request;
+  })();
+
 /** @description request parameter type for postServiceOrderCancelSend */
 export interface PostServiceOrderCancelSendOption {
   /**
--
libgit2 0.23.3