1
0

5 Коммитууд 722a0a44db ... 419e8ad237

Эзэн SHA1 Мессеж Огноо
  XuZinan 419e8ad237 Merge branch 'auth' into develop 2 жил өмнө
  XuZinan aa49e8ec5b 详情页面跳转 2 жил өмнө
  XuZinan 417fa8d241 页面更新 2 жил өмнө
  XuZinan 48bf546f2a 接口初步 2 жил өмнө
  XuZinan cdeb714ef3 审核页面初步 2 жил өмнө

+ 5 - 0
config/router.config.js

@@ -39,6 +39,11 @@ export default [
             path: '/home/flow-list',
             component: './Flow/List',
           },
+
+          {
+            path: '/home/auth',
+            component: './Auth/Auth',
+          },
         ],
       },
       {

+ 106 - 0
src/pages/Auth/Auth.js

@@ -0,0 +1,106 @@
+import React, { useEffect } from 'react';
+import { Table, Collapse } from 'antd';
+import { connect } from 'dva';
+import router from 'umi/router';
+
+const { Panel } = Collapse;
+
+function Auth(props) {
+  const {
+    dispatch,
+    authList,
+    checkedList,
+    checkedPagination,
+    typeOptions,
+    currentUser,
+    loading,
+  } = props;
+
+  //监测当前用户,有值时调用列表接口
+  useEffect(() => {
+    if (!currentUser.ID) return;
+    dispatch({
+      type: 'auth/queryAuthList',
+      payload: { user_id: currentUser.ID },
+    });
+    dispatch({
+      type: 'auth/queryCheckedList',
+      payload: { user_id: currentUser.ID, params: {} },
+    });
+  }, [currentUser]);
+
+  useEffect(() => {
+    //分类列表
+    dispatch({ type: 'auth/queryClassify' });
+  }, []);
+
+  const columns = [
+    { title: '流程名称', dataIndex: 'name' },
+    { title: '所属项目', dataIndex: 'project_name' },
+  ];
+
+  const flowColumns = [
+    { title: '名称', dataIndex: 'version_name' },
+    { title: '节点', dataIndex: 'node_name' },
+    { title: '创建人', dataIndex: 'author' },
+    {
+      title: '分类',
+      render: (_, record) => typeOptions.find(cur => cur.id == record.classify_id)?.name,
+    },
+    { title: '操作', render: (_, record) => <a onClick={() => loadNode(record)}>加载</a> },
+  ];
+
+  const loadNode = item => {
+    // localStorage.excelItem = JSON.stringify({ version_id: item.version_id });
+    //调用接口获取version信息
+    dispatch({
+      type: 'auth/queryVersionByNode',
+      callback: versionList => {
+        let version = versionList.find(v => v.id == item.version_id) || {};
+        localStorage.excelItem = JSON.stringify(version);
+      },
+    });
+
+    router.push(`/home/detail/${item.project_id}/${item.template_id}`);
+  };
+
+  const renderUnauth = data => (
+    <Table columns={flowColumns} dataSource={data} pagination={false} rowKey="id" />
+  );
+
+  const renderAuth = data => (
+    <Table columns={flowColumns} dataSource={data} pagination={checkedPagination} rowKey="id" />
+  );
+
+  return (
+    <Collapse defaultActiveKey={['0']}>
+      <Panel header="未审批" key="0">
+        <Table
+          columns={columns}
+          dataSource={authList}
+          expandable={{ expandedRowRender: record => renderUnauth(record.nodes) }}
+          pagination={false}
+          rowKey="key"
+        />
+      </Panel>
+      <Panel header="已审批" key="1">
+        <Table
+          columns={columns}
+          dataSource={checkedList}
+          expandable={{ expandedRowRender: record => renderAuth(record.nodes) }}
+          pagination={false}
+          rowKey="key"
+        />
+      </Panel>
+    </Collapse>
+  );
+}
+
+export default connect(({ auth, loading, user }) => ({
+  authList: auth.authList,
+  checkedList: auth.checkedList.list,
+  checkedPagination: auth.checkedList.pagination,
+  typeOptions: auth.typeOptions,
+  loading: loading.models.auth,
+  currentUser: user.currentUser,
+}))(Auth);

+ 107 - 0
src/pages/Auth/models/auth.js

@@ -0,0 +1,107 @@
+import { queryAuthList, queryCheckedList, queryVersionByNode } from '@/services/bomAuth';
+import { queryClassify } from '@/services/boom';
+export default {
+  namespace: 'auth',
+  state: {
+    authList: [],
+    checkedList: { list: [], pagination: {} },
+  },
+  effects: {
+    *queryAuthList({ payload }, { call, put }) {
+      const responce = yield call(queryAuthList, payload);
+      if (responce) {
+        let data = responce.data;
+        let ret = [];
+        data.forEach(e => {
+          let item = ret.find(item => item.key == `${e.template_id}_${e.project_id}`);
+          if (!item) {
+            item = {
+              key: `${e.template_id}_${e.project_id}`,
+              name: e.name,
+              project_name: e.ding_schema,
+              nodes: [],
+            };
+            ret.push(item);
+          }
+          item.nodes.push({
+            template_id: e.template_id,
+            project_id: e.project_id,
+            version_name: e.version_name,
+            node_name: e.TemplateNodeInfo?.label,
+            author: e.AuthorInfo?.CName,
+            classify_id: e.classify_id,
+            version_id: e.version_id,
+            id: e.id,
+          });
+        });
+        yield put({
+          type: 'save',
+          payload: { authList: ret },
+        });
+      }
+    },
+
+    *queryCheckedList({ payload }, { call, put }) {
+      const responce = yield call(queryCheckedList, payload);
+      if (responce) {
+        let data = responce.data.list;
+        let ret = [];
+        data.forEach(e => {
+          let item = ret.find(item => item.key == `${e.template_id}_${e.project_id}`);
+          if (!item) {
+            item = {
+              key: `${e.template_id}_${e.project_id}`,
+              name: e.name,
+              project_name: e.ding_schema,
+              nodes: [],
+            };
+            ret.push(item);
+          }
+          item.nodes.push({
+            template_id: e.template_id,
+            project_id: e.project_id,
+            version_name: e.version_name,
+            node_name: e.TemplateNodeInfo?.label,
+            author: e.AuthorInfo?.CName,
+            classify_id: e.classify_id,
+            version_id: e.version_id,
+            id: e.id,
+          });
+        });
+        yield put({
+          type: 'save',
+          payload: { checkedList: { list: ret, pagination: responce.data.pagination } },
+        });
+      }
+    },
+
+    *queryClassify({ payload, callback }, { call, put }) {
+      const data = yield call(queryClassify, payload);
+      if (data) {
+        yield put({
+          type: 'save',
+          payload: {
+            typeOptions: data?.map(item => {
+              return { ...item, label: item.name, value: item.id };
+            }),
+          },
+        });
+      }
+    },
+
+    *queryVersionByNode({ payload, callback }, { call, put }) {
+      const data = yield call(queryVersionByNode, payload);
+      if (data) {
+        callback && callback(data.data.excel_version_tree);
+      }
+    },
+  },
+  reducers: {
+    save(state, action) {
+      return {
+        ...state,
+        ...action.payload,
+      };
+    },
+  },
+};

+ 19 - 0
src/services/bomAuth.js

@@ -0,0 +1,19 @@
+import request from '@/utils/request';
+import { stringify } from 'qs';
+
+//获取未审核列表
+//params: user_id
+export async function queryAuthList({ user_id }) {
+  return request(`/purchase/bom/get-audit-list/${user_id}`);
+}
+
+//获取已审核列表
+//params: user_id, page_size, current_page
+export async function queryCheckedList({ user_id, params }) {
+  return request(`/purchase/bom/get-checked-list/${user_id}?${stringify(params)}`);
+}
+
+// 根据节点id查询所有version
+export async function queryVersionByNode(params) {
+  return request(`/purchase/bom/flow/node?${stringify(params)}`);
+}