import { basicData } from './basic-data'
import { extendFormItems } from './extend'
import { baseUrl } from "../../../../config/baseUrl";

export function detailConfig(self) {
    return [
        {
            key: 'one',
            checkedKey: 'main',
            // height: '298px',
            btns: [
                {
                    label: '单据打印',
                    click() {
                        self.documentPrint();
                    }
                },
                // {
                //   label: '打印汇总单',
                //   click() {
                //     self.headerPrint();
                //   }
                // },
                // {
                //   label: '标签补打',
                //   click() {
                //     self.labelPrint();
                //   }
                // },
                // {
                //   label: '打印明细单',
                //   click() {
                //     self.detailsPrint();
                //   }
                // },
            ],
            list: [
                {
                    key: 'main',
                    tab: '主要信息',
                    item: {
                        type: 'p-search-table',
                        autoLoad: false,
                        rowSelectType: 2,
                        rowKey: 'rcvHeaderId',
                        config: basicData(self),
                        // remoteMethod="get",
                        remoteUrl: baseUrl + '/print/v1.0/getRqcNoticeHeaderNew',
                        remoteParams: {},
                        operators: [],
                        scroll: { y: 200 },
                        doneBefore(response) {
                            response.data.list = response.data.list.map(item => {
                                return {
                                    ...item,
                                    ...item.rcvHeadersDTO,
                                    ...item.rcvHeadersProfilesDTO
                                }
                            })
                            return response
                        },
                        selectChange(selectedRowKeys, selectedRows) {
                            let ref = self.queryRefFromName('list');
                            if (selectedRowKeys.length > 0) {
                                self.headerId = selectedRows;

                                self.selectedMainItem = selectedRows[0];
                                self.handleQuerySubList({ rcvHeaderId: selectedRows[0].rcvHeaderId, pageNum: 1, pageSize: 500 }).then(res => {
                                    res.forEach((t) => {
                                        t.warehouseLocatorName = t.whLocatorName
                                        t.realWhLocatorId = t.whLocatorId
                                        t.realWhLocatorCode = t.whLocatorCode
                                    });
                                    ref.data = res;
                                });
                            }
                            ref.data = [];
                        },
                    }
                }
            ]
        },
        {
            key: 'two',
            checkedKey: 'list',
            list: [
                {
                    key: 'list',
                    tab: '商品明细',
                    btns: [
                        // { label: '差异', click() { self.toErrorBill(); } },
                    ],
                    item: {
                        type: 'p-table-edit',
                        rowSelectType: 2,
                        rowKey: 'rcvLineId',
                        config: extendFormItems(self),
                        operations: [
                            // { title: '拆分', click(record) { self.showSplitBill(record); } }
                        ],
                        colChange({ record, name, value }) { },
                        onClick(selectedRowKeys, selectedRows, data) {

                        },
                        onSelectRow(selectedRowKeys, selectedRows) {
                            self.selectedRows = selectedRows

                        },
                    }
                }
            ]
        }
    ]
}
