Browse Source

Merge branch 'master' of http://120.55.44.4:10080/xujunjie/BomWeb

Renxy 2 years ago
parent
commit
e2c770727c

+ 58 - 65
src/components/Flow/node/rect/mapServe.tsx

@@ -124,7 +124,7 @@ const Component = (props: any) => {
         });
       });
     } catch (error) {
-      message.error("excel文件导入失败!请联系管理员。")
+      message.error('excel文件导入失败!请联系管理员。');
       return false;
     }
   };
@@ -146,6 +146,7 @@ const Component = (props: any) => {
     var idx = name?.lastIndexOf('/');
     let str = name.substring(idx + 1, name.length);
     setFileName(str);
+    onNodeConfigChange('version_name', str);
   };
 
   useEffect(() => {
@@ -192,7 +193,6 @@ const Component = (props: any) => {
           onChange={value => {
             onNodeConfigChange('muti_version', value);
           }}
-          disabled={meta?.editMode == 2}
           options={[
             { label: '是', value: 1 },
             { label: '否', value: 0 },
@@ -204,7 +204,6 @@ const Component = (props: any) => {
           onChange={value => {
             onNodeConfigChange('is_start_node', value);
           }}
-          disabled={meta?.editMode == 2}
           options={[
             { label: '是', value: 1 },
             { label: '否', value: 0 },
@@ -215,19 +214,16 @@ const Component = (props: any) => {
             <InputFiled
               label="模板名称"
               value={nodeConfig.version_name}
-              disabled={meta?.editMode == 2}
               onChange={value => {
                 onNodeConfigChange('version_name', value);
               }}
             />
 
-            {meta?.editMode == 1 && (
-              <UploadFiled
-                label="模板"
-                onChange={url => onNodeConfigChange('bom_template', url)}
-                beforeUpload={beforeUpload}
-              />
-            )}
+            <UploadFiled
+              label="模板"
+              onChange={url => onNodeConfigChange('bom_template', url)}
+              beforeUpload={beforeUpload}
+            />
 
             {/* <div onClick={handleFileNameClick}>{fileName}</div> */}
             <a href={nodeConfig.bom_template}>{fileName}</a>
@@ -252,68 +248,65 @@ const Component = (props: any) => {
         </div>
       </div>
       {meta?.editMode != 2 && (
-        <>
-          <div className={`${PREFIX}-panel-group`}>
-            <h5>样式</h5>
-            <Position
-              x={nodeConfig.x}
-              y={nodeConfig.y}
-              onChange={(key, value) => {
-                onNodeConfigChange(key, value);
-              }}
-            />
-            <Size
-              width={nodeConfig.width}
-              height={nodeConfig.height}
-              onChange={(key, value) => {
-                onNodeConfigChange(key, value);
-              }}
-            />
-            <ColorPicker
-              label="填充"
-              value={nodeConfig.fill}
-              onChange={(value: string) => {
-                onNodeConfigChange('fill', value);
+        <div className={`${PREFIX}-panel-group`}>
+          <h5>样式</h5>
+          <Position
+            x={nodeConfig.x}
+            y={nodeConfig.y}
+            onChange={(key, value) => {
+              onNodeConfigChange(key, value);
+            }}
+          />
+          <Size
+            width={nodeConfig.width}
+            height={nodeConfig.height}
+            onChange={(key, value) => {
+              onNodeConfigChange(key, value);
+            }}
+          />
+          <ColorPicker
+            label="填充"
+            value={nodeConfig.fill}
+            onChange={(value: string) => {
+              onNodeConfigChange('fill', value);
+            }}
+          />
+          <ColorPicker
+            label="边框"
+            value={nodeConfig.stroke}
+            onChange={(value: string) => {
+              onNodeConfigChange('stroke', value);
+            }}
+          />
+          <InputNumberFiled
+            label="消息数量"
+            value={nodeConfig.count}
+            onChange={value => {
+              onNodeConfigChange('count', value);
+            }}
+          />
+          <div style={{ display: 'flex' }}>
+            <InputNumberFiled
+              label="字号"
+              value={nodeConfig.fontSize}
+              width={68}
+              onChange={value => {
+                onNodeConfigChange('fontSize', value);
               }}
+              style={{ marginRight: 10 }}
             />
             <ColorPicker
-              label="边框"
-              value={nodeConfig.stroke}
+              value={nodeConfig.fontFill}
               onChange={(value: string) => {
-                onNodeConfigChange('stroke', value);
+                onNodeConfigChange('fontFill', value);
               }}
             />
-            <InputNumberFiled
-              label="消息数量"
-              value={nodeConfig.count}
-              onChange={value => {
-                onNodeConfigChange('count', value);
-              }}
-            />
-            <div style={{ display: 'flex' }}>
-              <InputNumberFiled
-                label="字号"
-                value={nodeConfig.fontSize}
-                width={68}
-                onChange={value => {
-                  onNodeConfigChange('fontSize', value);
-                }}
-                style={{ marginRight: 10 }}
-              />
-              <ColorPicker
-                value={nodeConfig.fontFill}
-                onChange={(value: string) => {
-                  onNodeConfigChange('fontFill', value);
-                }}
-              />
-            </div>
           </div>
-
-          <Button type="primary" onClick={onSave}>
-            保存
-          </Button>
-        </>
+        </div>
       )}
+      <Button type="primary" onClick={onSave}>
+        保存
+      </Button>
     </div>
   );
 };

+ 18 - 21
src/pages/Detail/FlowModal.js

@@ -57,6 +57,7 @@ function FlowModal(props) {
     dispatch,
     isOut,
     onCommit,
+    commitLoading,
     currentUser,
     typeOptions,
     userList,
@@ -458,29 +459,18 @@ function FlowModal(props) {
         onCancel={onClose}
         footer={false}
         width="98%"
+        bodyStyle={{ maxHeight: '660px' }}
       >
         <Row gutter={8}>
           <Col span={14}>
             <Flow meta={{ type: 'view' }} flowDetail={graphData} onSelectNode={handleSelectNode} />
           </Col>
           <Col span={10}>
-            <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
-              <div style={{ fontSize: '16px' }}>清单列表</div>
-              {isOut && (
-                <Button
-                  type="primary"
-                  style={{ float: 'right', marginBottom: '10px' }}
-                  onClick={() => setVersionVisible(true)}
-                >
-                  新建清单
-                </Button>
-              )}
-            </div>
-
+            <div style={{ fontSize: '16px', marginBottom: '10px' }}>清单列表</div>
             <div style={{ display: 'flex' }}>
               <Select
                 defaultValue={selectType}
-                style={{ width: '30%' }}
+                style={{ width: '20%' }}
                 onChange={value => {
                   setSelectType(value);
                   setInputValue('');
@@ -495,19 +485,24 @@ function FlowModal(props) {
                 value={inputValue}
                 onChange={e => setInputValue(e.target.value)}
               />
-              <Button type="primary" style={{ marginLeft: '10px' }}>
-                搜索
-              </Button>
+              {isOut && (
+                <Button
+                  type="primary"
+                  style={{ marginLeft: '20%' }}
+                  onClick={() => setVersionVisible(true)}
+                >
+                  新建清单
+                </Button>
+              )}
             </div>
             <div style={{ width: '100%', marginTop: '10px' }}>
               <Table
-                style={{ maxHeight: '80%' }}
                 columns={columns}
                 dataSource={showData} //data
                 loading={nodeLoading}
                 bordered={false}
                 pagination={{ position: ['none', 'none'], pageSize: 999, onChange }}
-                scroll={{ y: 65 * pageSize }}
+                scroll={{ y: '460px' }}
                 // childrenColumnName="none"
                 // expandable={{
                 //   expandedRowRender: record => (
@@ -543,9 +538,11 @@ function FlowModal(props) {
         visible={versionVisible}
         onClose={() => setVersionVisible(false)}
         onOk={values => {
-          onCommit?.(values);
-          setVersionVisible(false);
+          onCommit?.(values, null, () => {
+            setVersionVisible(false);
+          });
         }}
+        loading={commitLoading}
       />
     </>
   );

+ 15 - 1
src/pages/Detail/Index.js

@@ -20,7 +20,12 @@ import CommitAuditModal from './CommitAuditModal';
 import CommentContent from '@/components/CommentContent';
 import MergeModal from './MergeModal';
 import { GetTokenFromUrl, getToken } from '@/utils/utils';
-import { queryDelPurchaseExcel, queryDetail, queryDingInstanceExecute } from '@/services/boom';
+import {
+  queryDelPurchaseExcel,
+  queryDelSheetRecord,
+  queryDetail,
+  queryDingInstanceExecute,
+} from '@/services/boom';
 import HistoryDrawer from './HistoryDrawer';
 import AuditFlow from './AuditFlow';
 import { getCurrentUser } from '@/utils/authority';
@@ -322,6 +327,14 @@ function Detail(props) {
     });
   };
 
+  const onDelSheet = async id => {
+    const params = {
+      excel_id: version.id,
+      sheet_id: id,
+    };
+    await queryDelSheetRecord(params);
+  };
+
   const onAudit = ({ audit_comment }) => {
     const flowNode = flow.currentNode;
     dispatch({
@@ -1120,6 +1133,7 @@ function Detail(props) {
               templateId={templateId}
               getUser={getUser}
               onUpdate={onUpdate}
+              onDelSheet={onDelSheet}
             />
           )}
         </div>

+ 26 - 5
src/pages/Detail/LuckySheet.js

@@ -13,6 +13,8 @@ class LuckySheet extends React.Component {
     super(props);
     this.sheetRef = React.createRef();
     this.luckysheet = null;
+    this.updateTimer = null;
+    this.currentSheetIndex = null;
     this.updateCell = {
       add: [],
       diff: [],
@@ -62,8 +64,9 @@ class LuckySheet extends React.Component {
     return uuid.join('');
   }
   renderSheet(currentData) {
-    const { onClickCell, version, getUser, onUpdate, templateId } = this.props;
+    const { onClickCell, version, getUser, onUpdate, templateId, onDelSheet } = this.props;
     const data = currentData || this.props.data;
+    const _this = this;
     if (!this.luckysheet) {
       clearTimeout(this.renderTimer);
       this.renderTimer = setTimeout(() => {
@@ -90,8 +93,26 @@ class LuckySheet extends React.Component {
           }
         },
         updated(operate) {
-          console.log(operate);
-          onUpdate && onUpdate();
+          if (operate.type == 'datachange') {
+            if(_this.currentSheetIndex != operate.sheetIndex) {
+              _this.currentSheetIndex = operate.sheetIndex
+              return;
+            }
+            clearTimeout(_this.updateTimer);
+            _this.updateTimer = setTimeout(() => {
+              onUpdate.bind(_this)
+              onUpdate();
+            }, 1000);
+          }
+        },
+        sheetActivate: sheet => {
+          console.log(sheet);
+          setTimeout(() => {
+            this.luckysheet.setCellFormat(0, 0, 'bg', '#fff');
+          }, 100);
+        },
+        sheetDeleteAfter: sheet => {
+          onDelSheet && onDelSheet(sheet?.sheet.id);
         },
         sheetActivate: sheet => {
           console.log(sheet);
@@ -109,8 +130,8 @@ class LuckySheet extends React.Component {
         templateId: templateId,
         // flowId: version.flow_id,
         loadUrl: `/api/v1/purchase/record/sheet?gridKey=${version.id}&JWT-TOKEN=${token}`,
-        updateUrl: `ws://${location.host}/api/v1/ws?id=${version.id}&sid=${templateId}&JWT-TOKEN=${token}`,
-        // updateUrl: `ws://120.55.44.4:8896/api/v1/ws?id=${version.id}&sid=${templateId}&JWT-TOKEN=${token}`,
+        // updateUrl: `ws://${location.host}/api/v1/ws?id=${version.id}&sid=${templateId}&JWT-TOKEN=${token}`,
+        updateUrl: `ws://120.55.44.4:8896/api/v1/ws?id=${version.id}&sid=${templateId}&JWT-TOKEN=${token}`,
         authorityUrl: `/api/v1/purchase/bom/user/excel/col?depId=${localStorage.depId}&JWT-TOKEN=${token}`,
         getUser,
         // workbookCreateBefore(luckysheet) {

+ 10 - 6
src/pages/Detail/models/detail.js

@@ -81,7 +81,7 @@ export default {
     auditExcel: [],
     dingInstanceD: [],
     typeOptions: [],
-    classifyList:[],
+    classifyList: [],
   },
 
   effects: {
@@ -565,13 +565,15 @@ export default {
         });
       }
     },
-    *queryClassify ({ payload, callback }, { call, put }) {
+    *queryClassify({ payload, callback }, { call, put }) {
       const data = yield call(queryClassify, payload);
       if (data) {
-         yield put({
+        yield put({
           type: 'save',
           payload: {
-            typeOptions: data?.map(item=>{return {...item, label:item.name, value:item.id}}),
+            typeOptions: data?.map(item => {
+              return { ...item, label: item.name, value: item.id };
+            }),
           },
         });
       }
@@ -579,10 +581,12 @@ export default {
     *queryBindClassify({ payload, callback }, { call, put }) {
       const data = yield call(queryBindClassify, payload);
       if (data) {
-         yield put({
+        yield put({
           type: 'save',
           payload: {
-            classifyList: data?.map(item=>{return {...item, label:item.name, value:item.id}}),
+            classifyList: data?.map(item => {
+              return { ...item, label: item.name, value: item.id };
+            }),
           },
         });
       }

+ 24 - 13
src/pages/Flow/Flow.js

@@ -2,7 +2,7 @@ import Flow, { FLOW_TYPE } from '@/components/Flow';
 import { connect } from 'dva';
 import React, { useEffect } from 'react';
 import { UnityAction } from '@/utils/utils';
-import { Button } from 'antd';
+import { Button, Spin } from 'antd';
 import router from 'umi/router';
 
 @connect(({ xflow, user }) => ({
@@ -11,6 +11,11 @@ import router from 'umi/router';
   permission: user.currentUser.Permission,
 }))
 class FlowPage extends React.PureComponent {
+  constructor(props) {
+    super(props);
+    this.state = { spinning: false };
+  }
+
   onUpdate(node) {
     const { dispatch, flowDetail } = this.props;
     let params = {
@@ -31,6 +36,9 @@ class FlowPage extends React.PureComponent {
         nodeId: node.Id,
         body: params,
       },
+      callback: () => {
+        // this.setState({ spinning: false });
+      },
     });
   }
 
@@ -59,6 +67,7 @@ class FlowPage extends React.PureComponent {
 
     UnityAction.on('NODE_SAVE', nodeConfig => {
       this.onUpdate(nodeConfig);
+      // this.setState({ spinning: true });
     });
   }
   componentWillUnmount() {
@@ -67,7 +76,7 @@ class FlowPage extends React.PureComponent {
   getEditMode() {
     const { flowDetail, permission } = this.props;
 
-    return 2
+    return 2;
   }
   render() {
     const { flowDetail, permission, currentUser } = this.props;
@@ -76,24 +85,26 @@ class FlowPage extends React.PureComponent {
     if (
       // 判断是否有权限
       permission['func-01-point-bom-flow'] ||
-      // 判断是否为创建者
-      flowDetail.Creator == currentUser.ID) {
-      editMode = 1
+      // 判断是否为管理员
+      currentUser.IsSuper
+    ) {
+      editMode = 1;
     }
 
     return (
-      <div>
+      <Spin spinning={this.state.spinning}>
         {/* <Form></Form> */}
         <Button style={{ marginBottom: 20 }} onClick={() => router.go(-1)}>
           返回
         </Button>
-        {currentUser.ID && <Flow
-          meta={{ type: 'edit', editMode, flowId: 1 }}
-          flowDetail={flowDetail}
-        // onUpdate={node => this.onUpdate(node)}
-        />}
-
-      </div>
+        {currentUser.ID && (
+          <Flow
+            meta={{ type: 'edit', editMode, flowId: 1 }}
+            flowDetail={flowDetail}
+            // onUpdate={node => this.onUpdate(node)}
+          />
+        )}
+      </Spin>
     );
   }
 }

+ 2 - 1
src/pages/Flow/models/flow.js

@@ -196,10 +196,11 @@ export default {
         payload: { flowList: res.data },
       });
     },
-    *updateNode({ payload }, { call, put }) {
+    *updateNode({ payload, callback }, { call, put }) {
       const data = yield call(updateNode, payload);
       console.log(data);
       message.success('修改成功');
+      callback && callback();
     },
     *queryAuditList({ payload }, { call, put }) {
       const response = yield call(queryAuditList, payload);

+ 30 - 27
src/pages/List/ClassifyModal.js

@@ -1,54 +1,53 @@
-import { List, Modal, Select, Table } from "antd";
-import TreeSelect from "rc-tree-select";
-import React, { useEffect, useMemo } from "react";
+import { Button, List, Modal, Select, Table } from 'antd';
+import TreeSelect from 'rc-tree-select';
+import React, { useEffect, useMemo } from 'react';
 
-const ClassifyModal = ({ data, visible,userList, onClose, handleChange }) => {
-  const {classify =[], project_id} = data
+const ClassifyModal = ({ data, visible, userList, onClose, handleChange }) => {
+  const { classify = [], project_id } = data;
   const list = useMemo(() => {
     return userList.map(item => {
-      return {label:item.CName, value:item.ID}
-    })
-  }, [userList])
+      return { label: item.CName, value: item.ID };
+    });
+  }, [userList]);
 
   const onChange = (e, item) => {
-    console.log(e, item)
+    console.log(e, item);
     const idx = classify.findIndex(cur => cur.classify_id == item.classify_id);
     if (idx > -1) {
       const curClassifyItem = { ...classify[idx], uid: e.join(',') };
       classify[idx] = curClassifyItem;
-      handleChange({project_id, classify})
+      handleChange({ project_id, classify });
     }
-  }
+  };
 
   const columns = [
     {
       title: '分类名称',
       width: '50%',
-      render: item =>  item.name,
+      render: item => item.name,
     },
     {
       title: '选择操作人',
       width: '50%',
       render: item => {
-        return ( 
+        return (
           <Select
             mode="multiple"
             allowClear
             style={{ width: '100%' }}
             placeholder="选择操作人"
-            defaultValue={item.uid ? item.uid.split(",").map(item=>Number(item)) : []}
-            onChange={(e) =>  onChange(e,item) }
+            defaultValue={item.uid ? item.uid.split(',').map(item => Number(item)) : []}
+            onChange={e => onChange(e, item)}
             options={list}
           />
-        )
-      }
-    }
-  ]
-  
+        );
+      },
+    },
+  ];
 
-  return ( 
+  return (
     <Modal
-      width='60%'
+      width="60%"
       // confirmLoading={loading}
       maskClosable={false}
       destroyOnClose
@@ -56,15 +55,19 @@ const ClassifyModal = ({ data, visible,userList, onClose, handleChange }) => {
       visible={visible}
       onCancel={onClose}
       onOk={onClose}
+      footer={[
+        <Button key="submit" type="primary" onClick={onClose}>
+          确定
+        </Button>,
+      ]}
     >
       <Table
         columns={columns}
         dataSource={classify}
-        pagination={{ position: ['none', 'none'] }}
+        pagination={{ position: ['none', 'none'], pageSize: 999 }}
         scroll={{ y: 500 }}
       />
     </Modal>
-  )
-
-}
-export default ClassifyModal;
+  );
+};
+export default ClassifyModal;

+ 6 - 2
src/pages/List/List.js

@@ -20,6 +20,7 @@ function List(props) {
   const [versionVisible, setVersionVisible] = useState(false);
   const [flowDetail, setFlowDetail] = useState();
   const [loading2, setLoading2] = useState(false);
+  const [commitLoading, setCommitLoading] = useState(false);
   const [visible, setVisible] = useState(false);
 
   const [data, setData] = useState([]);
@@ -89,7 +90,6 @@ function List(props) {
       },
     },
   ];
-
   const queryList = page => {
     console.log(page);
     dispatch({
@@ -137,7 +137,7 @@ function List(props) {
     return !loadingVersion.effects['detail/queryComment'] && loadingVersion.models.detail;
   };
 
-  const onCommit = async (values, id) => {
+  const onCommit = async (values, id, callback) => {
     let currentNode = flowDetail.nodes.find?.(item => item.Id == version.template_node_id);
     let sheets = await queryRecordSheet({ gridKey: version.id, 'JWT-TOKEN': token });
     // if (!currentNode.muti_version) {
@@ -165,6 +165,7 @@ function List(props) {
       data: sheets,
       base_id: version.id,
     };
+    setCommitLoading(true);
     dispatch({
       type: 'list/commitSheet',
       payload: params,
@@ -173,6 +174,8 @@ function List(props) {
         const data = await queryBoomFlowDetail({ id: newVersion.template_id });
         console.log(data);
         setFlowDetail(data);
+        setCommitLoading(false);
+        callback && callback();
       },
     });
   };
@@ -218,6 +221,7 @@ function List(props) {
         version={version}
         onCommit={onCommit}
         onChangeVersion={version => changeVersion(version)}
+        commitLoading={commitLoading}
         onDelVersion={onDelVersion}
       />
       <ClassifyModal

+ 10 - 3
src/services/boom.js

@@ -13,6 +13,14 @@ import { stringify } from 'qs';
 export async function queryRecord(params) {
   return request(`/purchase/record?${stringify(params)}`);
 }
+//删除excel中单个sheet页
+export async function queryDelSheetRecord(params) {
+  const response = await request(`/purchase/bom/del-purchase-excel-sheet?${stringify(params)}`);
+  if (response.code == 200) {
+    message.success('删除成功');
+  }
+}
+
 // 查询全部工作流
 export async function queryFlowList(params) {
   return request(`/purchase/bom/flows?${stringify(params)}`);
@@ -398,7 +406,7 @@ export async function queryUserListByRoleID(params) {
 
 //新增工作流时调用接口 给项目绑定默认分类列表
 //purchase/bom/default-bind-classify?project_id=1
-export async function queryDefaultBindClassify (params) {
+export async function queryDefaultBindClassify(params) {
   let res = await request(`/purchase/bom/default-bind-classify?${stringify(params)}`, {
     method: 'GET',
   });
@@ -413,7 +421,7 @@ export async function queryClassify() {
   return res.data;
 }
 
-export async function queryBindClassify (params) {
+export async function queryBindClassify(params) {
   let res = await request(`/purchase/bom/get-bind-classify?${stringify(params)}`, {
     method: 'GET',
   });
@@ -433,4 +441,3 @@ export async function queryDelPurchaseExcel(params) {
   });
   return res;
 }
-