ZhaoJun преди 1 година
родител
ревизия
f3f4f67155

+ 1 - 1
config/config.js

@@ -143,7 +143,7 @@ export default {
       // target: 'http://192.168.20.53:8888/',
       // target: 'http://120.55.44.4:8896/',
       // target: 'http://47.96.12.136:8888/',
-      target: 'http://47.96.12.136:8896/',
+      target: 'http://47.96.12.136:8895/',
       // target: 'http://oraysmart.com:8889/',
       // target: 'http://oraysmart.com:8888/api',
       // changeOrigin: true,

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

@@ -57,6 +57,9 @@ function ItemAttribute(props) {
       case 'ManufacturerField':
         FormContent = <ManufacturerField {...formProps} />;
         break;
+      case 'CodeField':
+        FormContent = <CodeField {...formProps} />;
+        break;
       default:
         FormContent = null;
         break;
@@ -528,3 +531,29 @@ function ManufacturerField(props) {
     </Form>
   );
 }
+
+function CodeField(props) {
+  const { item, btns, onFinish } = props;
+  const [form] = Form.useForm();
+  return (
+    <Form
+      form={form}
+      labelCol={{ span: 6 }}
+      wrapperCol={{ span: 18 }}
+      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>
+  );
+}

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

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

+ 22 - 29
src/components/DDComponents/CodeFiled/index.js

@@ -3,44 +3,37 @@ import { Input } from 'antd';
 import { useRequest, useModel } from 'umi';
 import { queryContractCode } from '@/services/contract';
 import { queryDepsV2 } from '@/services/department';
+import { connect } from 'dva';
 
 function CodeField(props) {
-  const { depId, onChange } = props;
-  const [depList, setDepList] = useState([]);
+  const { depId, onChange, depUserTree } = props;
   const [value, setValue] = useState('');
+  //
+  // // 每次更新时 计算合同编号接口 并返回
+  // const { run: runCode } = useRequest(data => queryContractCode(data), {
+  //   manual: true,
+  //   onSuccess: data => {
+  //     setValue(data?.code);
+  //     onChange?.(data?.code);
+  //   },
+  // });
 
-  // 每次更新时 计算合同编号接口 并返回
-  const { run: runCode } = useRequest(data => queryContractCode(data), {
-    manual: true,
-    onSuccess: data => {
-      setValue(data?.code);
-      onChange?.(data?.code);
-    },
-  });
-
-  const getDepList = async () => {
-    const res = await queryDepsV2().catch(err => console.log(err));
+  const getContractCode = async params => {
+    const res = queryContractCode(params).catch(err => console.log(err));
     console.log(res);
-    if (res && res.code === 200) {
-      setDepList(res.data.list);
-    }
   };
-  // 初始化时请求部门列表
-  useEffect(() => {
-    getDepList();
-  }, []);
 
   useEffect(() => {
-    if (!depId || !depList.length) return;
+    if (!depId || !depUserTree.length) 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,
+    const company = depUserTree.find(item => item.Flag == 1);
+    const params = {
+      company_id: company?.ID,
+      company_code: company?.Code,
       dep_code,
     };
-    runCode(params);
-  }, [depId, depList]);
+    getContractCode(params);
+  }, [depId, depUserTree]);
 
   const getDepItemById = id => {
     const fun = list => {
@@ -55,9 +48,9 @@ function CodeField(props) {
         }
       }
     };
-    return fun(depList);
+    return fun(depUserTree);
   };
   return <Input value={value} placeholder="选择部门后自动生成" disabled />;
 }
 
-export default CodeField;
+export default connect(({ user }) => ({ depUserTree: user.depUserTree }))(CodeField);

+ 20 - 20
src/components/DDComponents/DepartmentField/index.js

@@ -5,27 +5,27 @@ import { connect } from 'dva';
 
 function DepartmentField(props) {
   const { value = [], onChange, depUserTree } = props;
-  const [treeData, setTreeData] = useState([]);
+  // const [treeData, setTreeData] = useState([]);
 
-  const genTreeNode = dep => {
-    return {
-      id: dep.dept_id,
-      pId: dep.parent_id,
-      value: dep.dept_id,
-      title: dep.name,
-      isLeaf: false,
-    };
-  };
-
-  const onLoadData = async ({ id }) => {
-    let depList = await queryDDdepList({ dept_id: id });
+  // const genTreeNode = dep => {
+  //   return {
+  //     id: dep.dept_id,
+  //     pId: dep.parent_id,
+  //     value: dep.dept_id,
+  //     title: dep.name,
+  //     isLeaf: false,
+  //   };
+  // };
 
-    console.log(depList);
-    if (depList.length > 0) {
-      let nodes = depList.map(genTreeNode);
-      setTreeData([...treeData, ...nodes]);
-    }
-  };
+  // const onLoadData = async () => {
+  //   let depList = await queryDDdepList();
+  //
+  //   console.log(depList);
+  //   if (depList.length > 0) {
+  //     let nodes = depList.map(genTreeNode);
+  //     setTreeData([...treeData, ...nodes]);
+  //   }
+  // };
 
   const onChangeValue = newValue => {
     onChange(newValue);
@@ -34,7 +34,7 @@ function DepartmentField(props) {
   return (
     <TreeSelect
       showSearch
-      multiple
+      // multiple
       allowClear
       defaultValue={value}
       dropdownStyle={{

+ 6 - 5
src/components/DDComponents/ManufacturerField/index.js

@@ -2,8 +2,6 @@ import React, { useState, useEffect } from 'react';
 import { Select } from 'antd';
 import { querySupplierList } from '@/services/contract';
 
-const { Option } = Select;
-
 function ManufacturerField(props) {
   const { value, disabled = false, onChange } = props;
   const user = JSON.parse(localStorage.getItem('currentUser'));
@@ -17,13 +15,13 @@ function ManufacturerField(props) {
       project_id: 1,
       is_super: user.IsSuper,
       created_by: user.CName,
-      pageSize: 9999,
+      page_size: 9999,
     }).catch(err => {
       console.log(err);
       setLoading(false);
     });
-    console.log('--------------------------', res);
-    if (res?.code === 200) {
+
+    if (res?.code === 200 && res.data.length) {
       const supplier = res?.data.list.map(item => {
         return { label: item.name, value: item.id };
       });
@@ -31,9 +29,12 @@ function ManufacturerField(props) {
     }
     setLoading(false);
   };
+
+  // 只要第一次加载即可
   useEffect(() => {
     getSupplier();
   }, []);
+
   return (
     <Select
       showSearch

+ 4 - 0
src/components/DDComponents/index.js

@@ -16,6 +16,7 @@ import DIYTable from './DIYTable/index.tsx';
 import TextNode from './TextNote';
 import DDProjectField from './ProjectField';
 import ManufacturerField from './ManufacturerField';
+import CodeField from './CodeFiled';
 
 const { Option } = Select;
 const { RangePicker } = DatePicker;
@@ -132,6 +133,9 @@ export default function DDComponents(props) {
     case 'DepartmentField': // 部门控件
       component = <DepartmentField onChange={onChange} />;
       break;
+    case 'CodeField': // 合同编号控件
+      component = <CodeField depId={depId} onChange={onChange} />;
+      break;
     case 'ProjectField': // 项目控件
       component = <DDProjectField value={defaultValue} disabled={disabled} onChange={onChange} />;
       break;

+ 1 - 1
src/pages/Detail/AuditDetailed.js

@@ -65,7 +65,7 @@ const AuditDetailed = props => {
 
     const renderComponents = () => {
       let content = '';
-      if (item.componentName === 'CodeFiled') {
+      if (item.componentName === 'CodeField') {
         content = <DDComponents item={item} depId={depId} />;
       } else if (item.componentName === 'FormulaField') {
         const strList = item.props?.formula?.map(formu => {

+ 0 - 1
src/pages/Detail/CommitAuditModal.js

@@ -86,7 +86,6 @@ function CommitAuditModal(props) {
   const formValueRef = useRef({
     form: [],
   });
-  console.log(formComponentValues);
 
   useEffect(() => {
     if (!visible) return;

+ 5 - 1
src/utils/request.js

@@ -81,7 +81,11 @@ export default function request(url, option, jwt) {
   // console.log(API_HOST);
   const time = url.indexOf('?') > -1 ? `&time=${number}` : `?time=${number}`;
   if (url.indexOf('http://') == -1 && url.indexOf('https://') == -1) {
-    if (url.indexOf('/api/v') === -1 && url.indexOf('/api/supplier')) {
+    if (
+      url.indexOf('/api/v') === -1 &&
+      url.indexOf('/api/supplier') === -1 &&
+      url.indexOf('/api/contract') === -1
+    ) {
       url = `/api/v1${url}${time}`;
     }
     // API_HOST在config/config.js的define中配置