Browse Source

merge from develop branch

ZhaoJun 2 năm trước cách đây
mục cha
commit
74c6be4a68

+ 28 - 0
src/components/AuditForm/ItemAttribute.js

@@ -61,6 +61,9 @@ function ItemAttribute(props) {
         break;
         break;
       case 'DIYTable':
       case 'DIYTable':
         FormContent = <TableName {...formProps} />;
         FormContent = <TableName {...formProps} />;
+      case 'CodeField':
+        FormContent = <CodeField {...formProps} />;
+        break;
     }
     }
 
 
     return FormContent;
     return FormContent;
@@ -180,6 +183,31 @@ function ProjectField(props) {
     </Form>
     </Form>
   );
   );
 }
 }
+function CodeField(props) {
+  const { item, btns, onFinish } = props;
+  const [form] = Form.useForm();
+  return (
+    <Form
+      form={form}
+      labelCol={{ span: 4 }}
+      wrapperCol={{ span: 20 }}
+      autoComplete="off"
+      initialValues={item.props}
+      onFinish={onFinish}
+    >
+      <Form.Item label="标题" name="label">
+        <Input />
+      </Form.Item>
+      <Form.Item label="提示文字" name="placeholder">
+        <Input />
+      </Form.Item>
+      <Form.Item label="必填" name="required" valuePropName="checked">
+        <Switch />
+      </Form.Item>
+      {btns}
+    </Form>
+  );
+}
 
 
 function ManufacturerField(props) {
 function ManufacturerField(props) {
   const { item, btns, onFinish } = props;
   const { item, btns, onFinish } = props;

+ 11 - 0
src/components/AuditForm/constant.js

@@ -11,6 +11,7 @@ import {
   FontColorsOutlined,
   FontColorsOutlined,
   ProjectOutlined,
   ProjectOutlined,
   SolutionOutlined,
   SolutionOutlined,
+  NumberOutlined,
   TableOutlined,
   TableOutlined,
 } from '@ant-design/icons';
 } from '@ant-design/icons';
 
 
@@ -132,6 +133,16 @@ export const COMPONENT_LIST = [
       required: false,
       required: false,
     },
     },
   },
   },
+  {
+    componentName: 'CodeField',
+    icon: <NumberOutlined />,
+    props: {
+      label: '合同编号',
+      bizAlias: '',
+      placeholder: '自动生成',
+      required: false,
+    },
+  },
   {
   {
     componentName: 'DIYTable',
     componentName: 'DIYTable',
     icon: <TableOutlined />,
     icon: <TableOutlined />,

+ 51 - 0
src/components/DDComponents/CodeFiled/index.js

@@ -0,0 +1,51 @@
+import React, { useEffect, useState } from 'react';
+import { Input } from 'antd';
+import { useRequest, useModel } from '@umijs/max';
+import { queryContractCode } from '@/services/contract';
+
+function CodeField(props) {
+  const { depId } = props;
+  const { depList, run } = useModel('depList');
+  const [value, setValue] = useState('');
+
+  //计算合同编号接口
+  const { run: runCode } = useRequest((data) => queryContractCode(data), {
+    manual: true,
+    onSuccess: (data) => {
+      setValue(data?.code);
+    },
+  });
+  useEffect(() => {
+    run();
+  }, []);
+
+  useEffect(() => {
+    if (!depId) return;
+    const dep_code = getDepItemById(depId)?.Code;
+    const compony = depList.find((item) => item.Flag == 1);
+    let params = {
+      company_id: compony?.ID,
+      company_code: compony?.Code,
+      dep_code,
+    };
+    runCode(params);
+  }, [depId, depList]);
+
+  const getDepItemById = (id) => {
+    const fun = (list) => {
+      for (let i = 0; i < list.length; i++) {
+        let item = list[i];
+        if (item.ID == id) {
+          return item;
+        } else if (item.children?.length > 0) {
+          let res = fun(item.children);
+          if (res) return res;
+        }
+      }
+    };
+    return fun(depList);
+  };
+  return <Input value={value} placeholder="选择部门后自动生成" disabled />;
+}
+
+export default CodeField;

+ 15 - 5
src/components/DDComponents/DepartmentField/index.js

@@ -1,10 +1,20 @@
-import { useModel } from '@umijs/max';
-import { TreeSelect } from 'antd';
+import { useRequest } from '@umijs/max';
+import { Select, TreeSelect } from 'antd';
 import { useEffect } from 'react';
 import { useEffect } from 'react';
+import { queryDepsV2 } from '@/services/approval';
 
 
 function DepartmentField(props) {
 function DepartmentField(props) {
   const { value, onChange, disabled = false } = props;
   const { value, onChange, disabled = false } = props;
-  const { depList, run, loading } = useModel('depList');
+  // const { depList, run, loading } = useModel('depList');
+  // 新建合同时,选择本部时,需要用另一个接口请求部门数据
+  const { data, run, loading } = useRequest(queryDepsV2, {
+    manual: true,
+    formatResult: (response) => {
+      return response.data?.map((item) => {
+        return { value: item.ID, label: item.Name };
+      });
+    },
+  });
 
 
   const onChangeValue = (newValue) => {
   const onChangeValue = (newValue) => {
     onChange(String(newValue));
     onChange(String(newValue));
@@ -14,7 +24,7 @@ function DepartmentField(props) {
   }, []);
   }, []);
 
 
   return (
   return (
-    <TreeSelect
+    <Select
       showSearch
       showSearch
       // multiple
       // multiple
       allowClear
       allowClear
@@ -26,7 +36,7 @@ function DepartmentField(props) {
       loading={loading}
       loading={loading}
       style={{ width: '100%' }}
       style={{ width: '100%' }}
       placeholder="请选择部门"
       placeholder="请选择部门"
-      treeData={depList}
+      options={data}
       onChange={onChangeValue}
       onChange={onChangeValue}
       disabled={disabled}
       disabled={disabled}
     />
     />

+ 5 - 1
src/components/DDComponents/index.js

@@ -13,10 +13,11 @@ import DDDateField from './DDDateField';
 import DDDateRangeField from './DDDateRangeField';
 import DDDateRangeField from './DDDateRangeField';
 import DDAttachment from './DDAttachment';
 import DDAttachment from './DDAttachment';
 import TextNote from './TextNote';
 import TextNote from './TextNote';
+import CodeField from './CodeFiled';
 import DIYTable from './DIYTable';
 import DIYTable from './DIYTable';
 
 
 export default function DDComponents(props) {
 export default function DDComponents(props) {
-  const { item, onChange } = props;
+  const { depId = '', item, onChange } = props;
   const { placeholder, options, format, unit, disabled, notUpper } = item.props;
   const { placeholder, options, format, unit, disabled, notUpper } = item.props;
   let component = null;
   let component = null;
   switch (item.componentName) {
   switch (item.componentName) {
@@ -129,6 +130,9 @@ export default function DDComponents(props) {
     case 'FormRelateField': //关联控件
     case 'FormRelateField': //关联控件
       component = '关联控件未渲染!';
       component = '关联控件未渲染!';
       break;
       break;
+    case 'CodeField': //合同编号控件
+      component = <CodeField depId={depId} />;
+      break;
   }
   }
 
 
   return (
   return (

+ 17 - 8
src/pages/ContractManager/component/Modal.jsx

@@ -707,7 +707,14 @@ const ContractModal = (props) => {
                   }}
                   }}
                   disabled={disableds.contract}
                   disabled={disableds.contract}
                   dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
                   dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
-                  treeData={companyDepList}
+                  treeData={
+                    data?.dep_id
+                      ? [
+                          ...companyDepList,
+                          { Name: data.dep_name, ID: data?.dep_id },
+                        ]
+                      : companyDepList
+                  }
                 />
                 />
               </Form.Item>
               </Form.Item>
             </Col>
             </Col>
@@ -1066,13 +1073,15 @@ const ContractModal = (props) => {
                 ) : (
                 ) : (
                   <ul>
                   <ul>
                     {data?.attach_extend &&
                     {data?.attach_extend &&
-                      JSON.parse(data?.attach_extend)?.map((item, idx) => (
-                        <li key={`${idx}_${item.name}`}>
-                          <a onClick={() => handlePreViewSingle(item)}>
-                            {item.name}
-                          </a>
-                        </li>
-                      ))}
+                      JSON.parse(data?.attach_extend)
+                        ?.filter((item) => item)
+                        .map((item, idx) => (
+                          <li key={`${idx}_${item.name}`}>
+                            <a onClick={() => handlePreViewSingle(item)}>
+                              {item.name}
+                            </a>
+                          </li>
+                        ))}
                   </ul>
                   </ul>
                 )}
                 )}
               </Form.Item>
               </Form.Item>

+ 1 - 0
src/pages/Flow/OaDetail.js

@@ -238,6 +238,7 @@ const OaDetail = () => {
               />
               />
             )} */}
             )} */}
           <AuditDetailed
           <AuditDetailed
+            allValues={formValueRef.current.form}
             form={form}
             form={form}
             items={data?.formData}
             items={data?.formData}
             onValuesChange={advanceSubmit}
             onValuesChange={advanceSubmit}

+ 21 - 11
src/pages/Flow/components/AuditDetailed.js

@@ -1,11 +1,25 @@
 import DDComponents from '@/components/DDComponents';
 import DDComponents from '@/components/DDComponents';
 import React, { useMemo, useState } from 'react';
 import React, { useMemo, useState } from 'react';
 import { Button, Form } from 'antd';
 import { Button, Form } from 'antd';
-import tableField from '../../../components/DDComponents/TableField';
 
 
 const AuditDetailed = (props) => {
 const AuditDetailed = (props) => {
   // const [form] = Form.useForm();
   // const [form] = Form.useForm();
-  const { items, form, onValuesChange, onTableValChange } = props;
+  const {
+    allValues = [],
+    items,
+    form,
+    onValuesChange,
+    onTableValChange,
+  } = props;
+
+  const depId = useMemo(() => {
+    const id = items.find((item) => item.componentName == 'DepartmentField')
+      ?.props.id;
+    const value = allValues.find((item) => item.id == id)?.value;
+    if (value) return value[0];
+  }, [allValues, items]);
+
+  console.log(items, allValues);
   const data = useMemo(() => {
   const data = useMemo(() => {
     let linkedData = {};
     let linkedData = {};
     items.forEach((d) => {
     items.forEach((d) => {
@@ -58,14 +72,6 @@ const AuditDetailed = (props) => {
       }
       }
     }
     }
 
 
-    // const handleColumnChange = (value, id) => {
-    //   console.log(value, id);
-    //   let ids = id.split(';');
-    //   let position = ids[0].split(',').map((item) => Number(item));
-    //   let columnID = ids[1];
-    //   onColumnValChange(position, columnID);
-    // };
-
     // const component = DDComponents({ item });
     // const component = DDComponents({ item });
     // if (!component) return null;
     // if (!component) return null;
     return (
     return (
@@ -77,7 +83,11 @@ const AuditDetailed = (props) => {
             label={formLabel}
             label={formLabel}
             rules={[{ required: required }]}
             rules={[{ required: required }]}
           >
           >
-            <DDComponents item={item} />
+            {item.componentName === 'CodeField' ? (
+              <DDComponents item={item} depId={depId} />
+            ) : (
+              <DDComponents item={item} />
+            )}
           </Form.Item>
           </Form.Item>
         ) : (
         ) : (
           <DDComponents item={item} onChange={onTableValChange} />
           <DDComponents item={item} onChange={onTableValChange} />

+ 1 - 2
src/pages/PSRManage/detail.js

@@ -189,7 +189,7 @@ const PSRDetail = () => {
       setExcelData({ ...res.data[0], dayFormat: day });
       setExcelData({ ...res.data[0], dayFormat: day });
       const data = JSON.parse(res.data[0].json_data);
       const data = JSON.parse(res.data[0].json_data);
       console.log(data);
       console.log(data);
-      if (data.cell_data) data.celldata = JSON.parse(data.cell_data);
+      if (data.celldata) data.celldata = JSON.parse(data.celldata);
       if (data.config) data.config = JSON.parse(data.config);
       if (data.config) data.config = JSON.parse(data.config);
       renderSheet(
       renderSheet(
         Array.isArray(data) ? data : [data],
         Array.isArray(data) ? data : [data],
@@ -275,7 +275,6 @@ const PSRDetail = () => {
     };
     };
     option.data.forEach((item) => {
     option.data.forEach((item) => {
       delete item.data;
       delete item.data;
-      delete item.cell_data;
       if (item.celldata) {
       if (item.celldata) {
         item.celldata.forEach((cell) => {
         item.celldata.forEach((cell) => {
           // 生成uuid
           // 生成uuid