Преглед на файлове

Squashed commit of the following:
pull
commit 9117fbf015fcca9a0c1bd2a0ef8ab501950b9fd2
Author: xujunjie <645007605@qq.com>
Date: Wed Aug 10 15:26:21 2022 +0800

控件

Renxy преди 2 години
родител
ревизия
86adf40f3b

+ 2 - 2
config/config.js

@@ -140,8 +140,8 @@ export default {
   chainWebpack: webpackPlugin,
   proxy: {
     '/api': {
-      target: 'http://192.168.20.152:8888/',
-      // target: 'http://47.96.12.136:8896/',
+      // target: 'http://192.168.20.152:8888/',
+      target: 'http://47.96.12.136:8896/',
       // target: 'http://oraysmart.com:8889/',
       // target: 'http://oraysmart.com:8888/api',
       // changeOrigin: true,

+ 6 - 3
src/components/DDComponents/InnerContactField/index.js

@@ -8,14 +8,17 @@ function InnerContactField(props) {
   const { userList } = props;
 
   return (
-    <Select>
+    <Select
+      showSearch
+      filterOption={(input, option) => option.children.toLowerCase().includes(input.toLowerCase())}
+    >
       {userList.map(item => (
-        <Option >{item.CName}</Option>
+        <Option key={item.ID}>{item.CName}</Option>
       ))}
     </Select>
   );
 }
 
 export default connect(({ user }) => ({
-  userList: user.userList,
+  userList: user.list,
 }))(InnerContactField);

+ 112 - 43
src/pages/PurchaseAdmin/PurchaseList/Detail/AuditDetailed.js

@@ -1,7 +1,10 @@
-import { Button, Form, Input, InputNumber, Select, DatePicker, Rate, Upload } from 'antd';
+import { Button, Input, InputNumber, Select, DatePicker, Rate, Upload } from 'antd';
 import { InnerContactField } from '@/components/DDComponents';
 import { PlusOutlined } from '@ant-design/icons';
-import React, { useState } from 'react';
+import React, { useMemo, useState } from 'react';
+import { Form } from '@ant-design/compatible';
+import '@ant-design/compatible/assets/index.css';
+
 const { Option } = Select;
 const { RangePicker } = DatePicker;
 const layout = {
@@ -13,33 +16,56 @@ const layout = {
   },
 };
 
-const AuditDetailed = ({ items }) => {
+const AuditDetailed = props => {
+  // const [form] = Form.useForm();
+  const { items, form } = props;
+
+  const behavior = useMemo(() => {
+    let data = {};
+    let watchList = {};
+    items.forEach(d => {
+      const item = d.props;
+      if (item.behaviorLinkage) {
+        const key = item.id;
+        item.behaviorLinkage.forEach(b => {
+          const value = b.value;
+          b.targets.forEach(t => {
+            data[t.fieldId] = { key, value };
+          });
+          watchList[key] = true;
+        });
+      }
+    });
+
+    return data;
+  }, [items]);
+
   const onFinish = values => {
     console.log(values);
   };
-  const selectBefore = (
-    <Select defaultValue="是" className="select-before">
-      <Option value="是">是</Option>
-      <Option value="否">否</Option>
-    </Select>
-  );
-  const prefixSelector = (
-    <Form.Item name="prefix" noStyle>
-      <Select style={{ width: 70 }}>
-        <Option value="86">+86</Option>
-        <Option value="87">+87</Option>
-      </Select>
-    </Form.Item>
-  );
+  // const selectBefore = (
+  //   <Select defaultValue="是" className="select-before">
+  //     <Option value="是">是</Option>
+  //     <Option value="否">否</Option>
+  //   </Select>
+  // );
+  // const prefixSelector = (
+  //   <Form.Item name="prefix" noStyle>
+  //     <Select style={{ width: 70 }}>
+  //       <Option value="86">+86</Option>
+  //       <Option value="87">+87</Option>
+  //     </Select>
+  //   </Form.Item>
+  // );
 
-  const children = [];
-  for (let i = 10; i < 36; i++) {
-    children.push(<Option key={i.toString(36) + i}>{i.toString(36) + i}</Option>);
-  }
+  // const children = [];
+  // for (let i = 10; i < 36; i++) {
+  //   children.push(<Option key={i.toString(36) + i}>{i.toString(36) + i}</Option>);
+  // }
 
-  const handleChange = value => {
-    console.log(`selected ${value}`);
-  };
+  // const handleChange = value => {
+  //   console.log(`selected ${value}`);
+  // };
 
   const GetComponent = item => {
     const {
@@ -70,11 +96,21 @@ const AuditDetailed = ({ items }) => {
       notUpper,
       children, // 子控件
     } = item.props;
+    // 判断是否属于关联项
+    if (behavior[id]) {
+      const { key, value } = behavior[id];
+      let currentValue = form.getFieldValue(key);
+      // 判断是否需要渲染
+      if (currentValue instanceof Array) {
+        if (currentValue?.indexOf(value) == -1) return null;
+      } else {
+        if (currentValue != value) return null;
+      }
+    }
     //{ id: startId, label: startLabel, upper, unit } = statField;是个array
     //objOptions ={value}
     // children ={componentName, props ={ id,label,bizAlias,required,}}
 
-    console.log(item.props);
     let component;
     switch (item.componentName) {
       case 'TextField': //单行输入
@@ -88,21 +124,35 @@ const AuditDetailed = ({ items }) => {
         break;
       case 'DDSelectField': //单选框
         component = (
-          <Select style={{ width: '100%' }} defaultValue="">
-            {options.map(cur => (
-              <Option key={cur.key} value={cur.key}>
-                {cur.value}
-              </Option>
-            ))}
+          <Select style={{ width: '100%' }} onChange={e => console.log(e)}>
+            {options.map(cur => {
+              if (typeof cur == 'string') {
+                cur = JSON.parse(cur);
+              }
+
+              return (
+                <Option key={cur.key} value={cur.key}>
+                  {cur.value}
+                </Option>
+              );
+            })}
           </Select>
         );
         break;
       case 'DDMultiSelectField': //多选框
         component = (
-          <Select mode="multiple" allowClear style={{ width: '100%' }} defaultValue="">
-            {options.map(cur => (
-              <Option value={cur}>{cur}</Option>
-            ))}
+          <Select mode="multiple" allowClear style={{ width: '100%' }}>
+            {options.map(cur => {
+              if (typeof cur == 'string') {
+                cur = JSON.parse(cur);
+              }
+
+              return (
+                <Option key={cur.key} value={cur.key}>
+                  {cur.value}
+                </Option>
+              );
+            })}
           </Select>
         );
         break;
@@ -151,17 +201,21 @@ const AuditDetailed = ({ items }) => {
       case 'FormRelateField': //关联控件
         break;
     }
+    if (!component) return null;
     return (
       <Form.Item
-        name={['user', 'introduction']}
+        // name={id}
         label={bizAlias || label}
-        rules={[
-          {
-            required,
-          },
-        ]}
+        // rules={[
+        //   {
+        //     required,
+        //   },
+        // ]}
       >
-        {component}
+        {form.getFieldDecorator(id, {
+          rules: [{ required }],
+        })(component)}
+        {/* {component} */}
         {notUpper == 1 && <p>大写</p>}
       </Form.Item>
     );
@@ -172,8 +226,23 @@ const AuditDetailed = ({ items }) => {
       style={{ height: '300px', overflowY: 'scroll' }}
       layout="vertical"
       autoComplete="off"
+      form={form}
       onFinish={onFinish}
     >
+      {/* <Form.Item name={'DDSelectField_4XTULZ7SMI80'} label="单选框">
+        <Select
+          style={{ width: '30%' }}
+          defaultValue="Home"
+          onChange={e => {
+            form.setFieldsValue({
+              DDSelectField_4XTULZ7SMI80: e,
+            });
+          }}
+        >
+          <Option value="option_0">option_0</Option>
+          <Option value="option_1">option_1</Option>
+        </Select>
+      </Form.Item> */}
       {/* <Form.Item
         name={['user', 'name']}
         label="单行输入"
@@ -273,4 +342,4 @@ const AuditDetailed = ({ items }) => {
   );
 };
 
-export default AuditDetailed;
+export default Form.create()(AuditDetailed);

+ 59 - 72
src/pages/PurchaseAdmin/PurchaseList/Detail/CommitAuditModal.js

@@ -24,123 +24,110 @@ function CommitAuditModal(props) {
 
   const res = {
     result: {
-      creatorUserId: '26652461xxxx5992',
-      appUuid: 'xxxx',
-      formCode: 'PROC-17428B8C-6C60-470E-xxxx-64F1037AE067',
-      formUuid: 'FORM-28215C3E-00E3-4118-xxxx-4091F828AF2F',
-      name: '示例模板',
-      memo: 'xxxx',
-      ownerId: '25xxxx01',
-      ownerIdType: '25xxxx01',
+      creatorUserId: '1649060463062661',
+      gmtModified: '2022-08-10T15:24Z',
+      formUuid: 'FORM-50442153-A9E8-4247-903C-AAF68B4C6219',
+      bizType: '',
+      ownerIdType: 'orgId',
+      formCode: 'PROC-F2AD61A8-25CF-47AB-96EA-E0D0850BBE35',
+      memo: '',
+      engineType: 0,
+      ownerId: '8642326',
+      gmtCreate: '2022-08-09T11:53Z',
       schemaContent: {
-        title: '示例模板',
-        icon: 'common',
+        icon: 'promotion',
+        title: '测试2',
         items: [
           {
-            componentName: 'TextareaField',
+            children: [
+              {
+                componentName: 'NumberField',
+                props: {
+                  id: 'NumberField_S1TT9HEIZGG0',
+                  label: '数字输入框',
+                  required: false,
+                },
+              },
+              {
+                componentName: 'DDSelectField',
+                props: {
+                  id: 'DDSelectField_1UAHP7C7C3NK0',
+                  label: '单选框',
+                  required: false,
+                },
+              },
+              {
+                props: {
+                  id: 'PhoneField_SEIS8H2KAQO0',
+                  label: '电话',
+                  required: false,
+                },
+              },
+            ],
+            componentName: 'TableField',
             props: {
               staffStatusEnabled: false,
               holidayOptions: [],
-              id: 'TextareaField-JBQAB8UJ',
-              label: '印制目的',
-              placeholder: '',
-              required: true,
+              id: 'TableField_1NFDDN09KZQ80',
+              label: '表格',
               push: {},
+              actionName: '添加',
             },
           },
           {
-            componentName: 'DDSelectField',
-            props: {
-              staffStatusEnabled: false,
-              holidayOptions: [],
-              options: [
-                { value: '是', key: 'option_JYF5F53R' },
-                { value: '否', key: 'option_JYF5F53S' },
-              ],
-              id: 'DDSelectField-JBRMGAXZ',
-              label: '是否日常项目',
-              placeholder: '',
-              required: true,
-            },
-          },
-          {
-            componentName: 'TextField',
+            componentName: 'DepartmentField',
             props: {
               staffStatusEnabled: false,
               holidayOptions: [],
-              id: 'TextField-JBQAB8UH',
-              label: '项目号',
-              placeholder: '',
-              required: true,
+              id: 'DepartmentField_23VD81FG2G5C0',
+              label: '部门',
+              placeholder: '请选择',
+              required: false,
               push: {},
             },
           },
           {
-            componentName: 'TextareaField',
+            componentName: 'DDAttachment',
             props: {
               staffStatusEnabled: false,
               holidayOptions: [],
-              id: 'TextareaField-JBQAB8UF',
-              label: '印制内容',
-              placeholder: '包含印制份数',
-              required: true,
+              id: 'DDAttachment_YP8901BICJ4',
+              label: '附件',
+              required: false,
               push: {},
             },
           },
-          {
-            componentName: 'MoneyField',
-            props: {
-              staffStatusEnabled: false,
-              holidayOptions: [],
-              notUpper: '1',
-              id: 'MoneyField-JBQAB8UK',
-              label: '预计印制费(元)',
-              placeholder: '可询问印刷社后填写',
-              required: true,
-            },
-          },
           {
             componentName: 'TextareaField',
             props: {
               staffStatusEnabled: false,
+              holidayOptions: [],
               id: '请假事由',
               label: '请假事由',
               placeholder: '请输入请假事由',
               required: false,
+              push: {},
             },
           },
           {
             componentName: 'DDPhotoField',
             props: {
               staffStatusEnabled: false,
+              holidayOptions: [],
               id: '图片',
               label: '上传病假单(如病假)',
-            },
-          },
-          {
-            componentName: 'TextNote',
-            props: {
-              staffStatusEnabled: false,
-              holidayOptions: [],
-              link: 'https://meta.zbox.filez.com/v/link/view/ae35765eb1ad4444a863a4feefa8b41c',
-              notPrint: '0',
-              bizAlias: '',
-              id: 'TextNote_1NYDZYJ979K00',
+              push: {},
             },
           },
         ],
       },
-      icon: 'null',
+      appUuid: 'ding0cdce2d5dbf986d9',
       appType: 0,
-      bizType: 'hrm.xxxx',
-      engineType: 0,
-      status: 'PUBLISHED',
-      listOrder: 1,
-      customSetting: 'null',
-      procType: 'inner',
       visibleRange: 'PRIVATE',
-      gmtCreate: '1638326995000',
-      gmtModified: '1640344585000',
+      listOrder: 1084,
+      name: '测试2',
+      status: 'PUBLISHED',
+      procType: '',
     },
   };
   const [schemaContent, setSchemaContent] = useState(res.result.schemaContent);

+ 9 - 3
src/pages/PurchaseAdmin/PurchaseList/Detail/Index.js

@@ -68,6 +68,7 @@ function Detail(props) {
   const sheetRef2 = useRef();
   const sheetRef3 = useRef();
   const fileRef = useRef();
+  const userRef = useRef();
   const statusRef = useRef({
     edit: false,
     compare: false,
@@ -569,7 +570,7 @@ function Detail(props) {
         }
         return true;
       };
-      console.log('是否有权限提交流转   ', getIsSubmit());
+      // console.log('是否有权限提交流转   ', getIsSubmit());
       if (getIsSubmit() && version.audit_status != 3)
         menuList.push(<Menu.Item key="commitAudit">提交流转</Menu.Item>);
 
@@ -796,8 +797,13 @@ function Detail(props) {
     });
   };
 
-  const getUser = user => {
-    setUser(user);
+  const getUser = newUser => {
+    try {
+      if (JSON.stringify(newUser) != JSON.stringify(userRef.current)) {
+        userRef.current = newUser;
+        setUser(newUser);
+      }
+    } catch (error) {}
   };
 
   const renderNode = () => {