浏览代码

库存明细

huangbin 4 年之前
父节点
当前提交
0541899795

+ 4 - 3
src/common/setup/table/compose.ts

@@ -56,7 +56,7 @@ export function handleComposeTable<T>({ queryFn, menuType, isDetail, tableName,
 
 
 // 表格 + 表头 + 表格明细 + 单击表格  通用处理逻辑
-export function handleComposeTable_detail<T>({ queryFn, tableName, tableFilterKey }: ComposeTableDetailParam) {
+export function handleComposeTable_detail<T>({ queryFn, tableName, tableFilterKey, menuType }: ComposeTableDetailParam) {
     // 控制 drawer 组件是否显示
     const { visible, openDrawer, closeDrawer } = handleTableDrawer()
     // 表头数据
@@ -86,9 +86,10 @@ export function handleComposeTable_detail<T>({ queryFn, tableName, tableFilterKe
     const { expandedRowKeys, selectedRow, Rowclick } = getTableEvent<T>(events);
     cacheSelectedRow = selectedRow as Ref<T>
     // 明细tab 列表
-    const list = getThirdMenuData()
+    const data = getThirdMenuData()
+    const list = data.find((e) => e.code === menuType);
     const tabList = ref<TabList[]>([])
-    list[0]?.children.forEach(el => {
+    list?.children.forEach(el => {
         const { code, title, type } = el
         if (type === 3) {
             tabList.value.push({ lable: title, code })

+ 3 - 1
src/common/setup/table/interface.ts

@@ -31,6 +31,7 @@ export interface ComposeTableDetailParam {
     queryFn: Function,  // 查询表格数据
     tableName: keyof TableKey, // 表头key
     tableFilterKey: string[], // 表格过滤字段
+    menuType?: keyof ButtonListKey
 }
 
 export interface TabList {
@@ -94,7 +95,8 @@ export interface ButtonListKey {
     finance_report_finance: string; // 财务报表
     exposure_report_exposure: string; // 敞口报表
     spot_report_spot: string; // 现货报表
-    inventory_report_inventory: string; // 库存报表
+    inventory_report_warehouse: string; // 库存报表(仓库)
+    inventory_report_inventory_category: string; // 库存报表(品类)
 
     /********* =================== 千海金=================== **********/
     platinum_custom_info_normal: string; // 千海金 客户资料 正常

+ 3 - 3
src/services/go/ermcp/report/interface.ts

@@ -150,7 +150,7 @@ export interface Ermcp3AreaSpotPLReport {
  * 查询库存报表请求
  */
 export interface AreaStockReportReq {
-    userid: number //                用户ID
+    userid?: number //                用户ID
     querytype: number //             查询类型 1-报表 2-报表明细
     cycletime: string //             周期时间 日(YYYYMMDD) 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】
     cycletype: number//              周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】
@@ -159,7 +159,7 @@ export interface AreaStockReportReq {
     deliverygoodsid?: number //      品种ID
     wrstandardid?: number//          品类ID
     spotgoodsbrandid?: number//      品牌ID
-    warehouseinfoid?: number //      仓库ID
+    warehouseinfoid?: string //      仓库ID
 }
 
 /**
@@ -300,7 +300,7 @@ export interface Ermcp3ArealSumPL {
  * 查询期货报表请求
  */
 export interface QryTaFutureDataReportReq {
-    userid: number  //  用户ID
+    userid?: number  //  用户ID
     querytype: number // 查询类型 1-报表 2-报表明细
     cycletype: number // 周期类型 - 0:日 1:月 2:季 3:年 4:周 5:全报表【原值】
     cycletime: string // 周期时间 日(YYYYMMDD) 月(YYYYMM) 季(YYYYQ) 年(YYYY) 周(YYYYMMDD周内任意一天) 全(0)【原值】

+ 96 - 44
src/views/report/future_report/list/future_report/index.vue

@@ -1,70 +1,122 @@
 <template>
   <!-- 期货报表 -->
-  <div class="spot-report"
+  <div class="table-detail-container table-height"
        :loading="loading">
-    <Filter @update="update"></Filter>
-    <contextMenu :contextMenuList="forDataBtn">
-      <a-table :columns="columns"
-               class="topOrderTable"
-               :pagination="false"
-               :expandedRowKeys="expandedRowKeys"
-               :customRow="Rowclick"
-               rowKey="key"
-               :data-source="tableList"
-               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }">
-      </a-table>
-    </contextMenu>
+    <Filter @update="search"></Filter>
+    <a-table :columns="columns"
+             class="topOrderTable"
+             :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
+             :pagination="false"
+             :expandedRowKeys="expandedRowKeys"
+             :customRow="Rowclick"
+             rowKey="key"
+             :data-source="tableList">
+    </a-table>
+    <!-- 明细 -->
+    <Description v-if="visible"
+                 @close="closeDrawer"
+                 @changeTab="changeTab"
+                 :columns="columnsDetail"
+                 :tabList="tabList"
+                 :tableList="detailTableList" />
   </div>
 </template>
 
 <script lang="ts">
 import Filter from '../../components/filterTable/index.vue';
-import { defineComponent, initData, getTableColumns, getTableEvent, getBtnList, contextMenu, BtnList } from '@/common/export/table';
-import { queryTableList } from '../../../setup';
+import { defineComponent, queryTableList } from '@/common/export/table';
+import { ComposeTableDetailParam, handleComposeTable_detail } from '@/common/setup/table/compose';
+import Description from '@/common/components/description/index.vue';
+import { watchEffect } from 'vue';
+import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 import { handleInitTypeAndTime } from '@/views/report/setup';
-import { qryAreaSpotplReport, qryTaFutureDataReport } from '@/services/go/ermcp/report';
-import { Ermcp3AreaSpotPLReport, Ermcp3TaFutuReDataReport } from '@/services/go/ermcp/report/interface';
+import { qryTaFutureDataReport } from '@/services/go/ermcp/report';
+import { Ermcp3TaFutuReDataReport, QryTaFutureDataReportReq } from '@/services/go/ermcp/report/interface';
 import { TypeAndTime } from '@/views/report/interface';
+import { TabList } from '@/common/setup/table/interface';
 
 export default defineComponent({
     name: 'inventory_report_inventory_category',
     components: {
         Filter,
-        contextMenu,
-        BtnList,
+        Description,
     },
     setup() {
-        // 表头数据
-        const { columns, registerColumn, updateColumn } = getTableColumns();
-        // 表格事件
-        const { expandedRowKeys, selectedRow, Rowclick, btnClick } = getTableEvent<any>({});
-        // // 表格操作按钮列表
-        // const { commonBtn, forDataBtn } = getBtnList('warehouse_info_normal', true);
+        let cycletime = '';
         // 表格列表数据
-        const { loading, tableList, queryTable } = queryTableList<Ermcp3TaFutuReDataReport>(qryTaFutureDataReport);
-        initData(() => {
+        const { loading, tableList, queryTable } = queryTableList<Ermcp3TaFutuReDataReport>();
+        // 获取列表数据
+        const queryTableAction = () => {
             const { getInitTime, getInitType } = handleInitTypeAndTime();
+            cycletime = getInitTime();
+            const param: QryTaFutureDataReportReq = {
+                cycletype: getInitType(),
+                cycletime,
+                querytype: 1,
+            };
             // 获取列表数据
-            queryTable({ cycletype: getInitType(), cycletime: getInitTime() });
-            // 注册表头信息 过滤
-            registerColumn('table_pcweb_futures_report', []);
-        });
-        function update(value: TypeAndTime) {
-            queryTable(value);
-        }
-
-        return {
+            queryTable(qryTaFutureDataReport, param);
+        };
+        const param: ComposeTableDetailParam = {
+            queryFn: queryTableAction, // 查询表格数据
+            tableName: 'table_pcweb_futures_report', // 表头key
+            tableFilterKey: [], // 表格过滤字段
+        };
+        const {
+            visible,
+            closeDrawer, // 控制 drawer 组件是否显示
             columns,
-
+            updateColumn, //  表头数据
+            columnsDetail,
+            registerColumnDetail,
+            detailTableList, // 明细表头数据
             expandedRowKeys,
             selectedRow,
-            Rowclick,
-            loading,
-            tableList,
-            queryTable,
-            btnClick,
-            update,
-        };
+            Rowclick, // 表格事件
+            tabList,
+        } = handleComposeTable_detail<Ermcp3TaFutuReDataReport>(param);
+
+        // 切换明细
+        function changeTab(index: number, current: TabList) {
+            const { code, lable } = current;
+            const data = selectedRow.value as Ermcp3TaFutuReDataReport;
+            const { cycletype, currencyid, goodsgroupid, goodsid, buyorsell } = data;
+            const param: QryTaFutureDataReportReq = {
+                querytype: 2,
+                cycletype,
+                cycletime,
+                currencyid,
+                goodsgroupid,
+                goodsid,
+                buyorsell,
+            };
+            if (code === 'future_report_future_detail') {
+                // 账户明细
+                // 注册表头
+                registerColumnDetail('table_pcweb_futures_statement_account_details', []);
+            } else {
+                console.error(`${lable}没有配置对应的code: ${code},`);
+                return;
+            }
+            // 查询明细数据
+            queryResultLoadingAndInfo(qryTaFutureDataReport, loading, param).then((res) => {
+                detailTableList.value = res;
+            });
+        }
+        watchEffect(() => {
+            if (visible.value) {
+                if (tabList.value.length) {
+                    changeTab(0, tabList.value[0]);
+                }
+            }
+        });
+        function search(value: TypeAndTime) {
+            cycletime = value.cycletime;
+            const obj = Object.assign(value, { querytype: 1 });
+            queryTable(qryTaFutureDataReport, obj);
+        }
+
+        return { loading, tableList, visible, closeDrawer, columns, updateColumn, search, columnsDetail, detailTableList, expandedRowKeys, selectedRow, Rowclick, tabList, changeTab };
     },
 });
 </script>

+ 100 - 45
src/views/report/inventory-report/list/warehouse/index.vue

@@ -1,70 +1,125 @@
 <template>
-  <!-- 库存报表(品类) -->
-  <div class="spot-report"
+  <!-- 库存报表(仓库) -->
+  <div class="table-detail-container table-height"
        :loading="loading">
-    <Filter @update="update"></Filter>
-    <contextMenu :contextMenuList="forDataBtn">
-      <a-table :columns="columns"
-               class="topOrderTable"
-               :pagination="false"
-               :expandedRowKeys="expandedRowKeys"
-               :customRow="Rowclick"
-               rowKey="key"
-               :data-source="tableList"
-               :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }">
-      </a-table>
-    </contextMenu>
+    <Filter @update="search"></Filter>
+    <a-table :columns="columns"
+             class="topOrderTable"
+             :scroll="{ x: '100%', y: 'calc(100vh - 163px)' }"
+             :pagination="false"
+             :expandedRowKeys="expandedRowKeys"
+             :customRow="Rowclick"
+             rowKey="key"
+             :data-source="tableList">
+    </a-table>
+    <!-- 明细 -->
+    <Description v-if="visible"
+                 @close="closeDrawer"
+                 @changeTab="changeTab"
+                 :columns="columnsDetail"
+                 :tabList="tabList"
+                 :tableList="detailTableList" />
   </div>
 </template>
 
 <script lang="ts">
 import Filter from '../../components/filterTable/index.vue';
-import { defineComponent, initData, getTableColumns, getTableEvent, getBtnList, contextMenu, BtnList } from '@/common/export/table';
-import { queryTableList } from '../../../setup';
+import { defineComponent, queryTableList } from '@/common/export/table';
+import { ComposeTableDetailParam, handleComposeTable_detail } from '@/common/setup/table/compose';
+import Description from '@/common/components/description/index.vue';
+import { watchEffect } from 'vue';
+import { queryResultLoadingAndInfo } from '@/common/methods/request/resultInfo';
 import { handleInitTypeAndTime } from '@/views/report/setup';
-import { qryAreaSpotplReport, qryAreaStockReport } from '@/services/go/ermcp/report';
-import { Ermcp3AreaSpotPLReport, Ermcp3AreaStockReport } from '@/services/go/ermcp/report/interface';
+import { qryAreaStockReport } from '@/services/go/ermcp/report';
+import { AreaStockReportReq, Ermcp3AreaStockReport } from '@/services/go/ermcp/report/interface';
 import { TypeAndTime } from '@/views/report/interface';
+import { TabList } from '@/common/setup/table/interface';
 
 export default defineComponent({
     name: 'inventory_report_warehouse',
     components: {
         Filter,
-        contextMenu,
-        BtnList,
+        Description,
     },
     setup() {
-        // 表头数据
-        const { columns, registerColumn, updateColumn } = getTableColumns();
-        // 表格事件
-        const { expandedRowKeys, selectedRow, Rowclick, btnClick } = getTableEvent<any>({});
-        // // 表格操作按钮列表
-        // const { commonBtn, forDataBtn } = getBtnList('warehouse_info_normal', true);
+        let cycletime = '';
         // 表格列表数据
-        const { loading, tableList, queryTable } = queryTableList<Ermcp3AreaStockReport>(qryAreaStockReport);
-        initData(() => {
+        const { loading, tableList, queryTable } = queryTableList<Ermcp3AreaStockReport>();
+        // 获取列表数据
+        const queryTableAction = () => {
             const { getInitTime, getInitType } = handleInitTypeAndTime();
+            cycletime = getInitTime();
+            const param: AreaStockReportReq = {
+                cycletype: getInitType(),
+                cycletime,
+                querytype: 1,
+                sumfields: '1,2,4',
+            };
             // 获取列表数据
-            queryTable({ cycletype: getInitType(), cycletime: getInitTime() }, { sumfields: '1,2,4' });
-            // 注册表头信息 过滤
-            registerColumn('table_pcweb_warehouse_report', []);
-        });
-        function update(value: TypeAndTime) {
-            queryTable(value, { sumfields: '1,2,4' });
-        }
-
-        return {
+            queryTable(qryAreaStockReport, param);
+        };
+        const param: ComposeTableDetailParam = {
+            queryFn: queryTableAction, // 查询表格数据
+            tableName: 'table_pcweb_warehouse_report', // 表头key
+            tableFilterKey: [], // 表格过滤字段
+            menuType: 'inventory_report_warehouse',
+        };
+        const {
+            visible,
+            closeDrawer, // 控制 drawer 组件是否显示
             columns,
-
+            updateColumn, //  表头数据
+            columnsDetail,
+            registerColumnDetail,
+            detailTableList, // 明细表头数据
             expandedRowKeys,
             selectedRow,
-            Rowclick,
-            loading,
-            tableList,
-            queryTable,
-            btnClick,
-            update,
-        };
+            Rowclick, // 表格事件
+            tabList,
+        } = handleComposeTable_detail<Ermcp3AreaStockReport>(param);
+        // 切换明细
+        function changeTab(index: number, current: TabList) {
+            const { code, lable } = current;
+            const data = selectedRow.value as Ermcp3AreaStockReport;
+            const { cycletype, deliverygoodsid, wrstandardid, spotgoodsbrandid, warehouseinfoid } = data;
+
+            const param: AreaStockReportReq = {
+                querytype: 2,
+                cycletype,
+                cycletime,
+                sumfields: '1,2,4',
+                deliverygoodsid,
+                wrstandardid,
+                spotgoodsbrandid,
+                warehouseinfoid,
+            };
+            if (code === 'inventory_report_warehouse_inventory_detail') {
+                // 库存明细
+                // 注册表头
+                registerColumnDetail('table_pcweb_inventory_warehouse_report_warehouse_details', []);
+            } else {
+                console.error(`${lable}没有配置对应的code: ${code},`);
+                return;
+            }
+            // 查询明细数据
+            queryResultLoadingAndInfo(qryAreaStockReport, loading, param).then((res) => {
+                detailTableList.value = res;
+            });
+        }
+        watchEffect(() => {
+            if (visible.value) {
+                if (tabList.value.length) {
+                    changeTab(0, tabList.value[0]);
+                }
+            }
+        });
+        function search(value: TypeAndTime) {
+            cycletime = value.cycletime;
+            const obj = Object.assign(value, { querytype: 1, sumfields: '1,2,4' });
+            queryTable(qryAreaStockReport, obj);
+        }
+
+        return { loading, tableList, visible, closeDrawer, columns, updateColumn, search, columnsDetail, detailTableList, expandedRowKeys, selectedRow, Rowclick, tabList, changeTab };
     },
 });
 </script>

+ 2 - 2
src/views/report/setup.ts

@@ -85,8 +85,8 @@ export function handleInitTypeAndTime() {
 
 /**
  * 获取表格列表数据
- * @param type 
- * @returns 
+ * @param type
+ * @returns
  */
 export function queryTableList<T>(fn: Function) {
     // 加载状态