<template>
    <lj-win-common :title="title" :show-back="true" :header-height="headerHeight" :show-footer="false"
        :show-header="true" :show-body="true" :show-footer-shadow="false" @fix-body="fixbody" simplefooter>
        <div slot="body" class="main-body flx-col h-full flx-1 overflow-hidden">
            <van-tabs ref="vantabsRef" v-model="tabsActive" color="#2196f3" scrollspy sticky :offset-top="headerHeight"
                @scroll="autoScrollTabs" @rendered="autoRenderedTabs">
                <van-tab title="基础信息" name="base">
                    <rp-summary-item title="基础信息" simple></rp-summary-item>
                    <lj-base-form ref="baseFormRef" :data="mainObject" :group="basicGroup" :editable="true" :columns="columns"
                        @change="handleFormGroupChange"></lj-base-form>

                </van-tab>
                <van-tab title="面料" name="fabricMx" class="overflow-hidden" v-if="mattresstypeEnum">
                    <template #title>
                        <template v-if="isTabsBadge_fabric_error">
                            <van-badge :content="isTabsBadge_fabric_error + '异常'" class="tabs-badge">
                                面料
                            </van-badge>
                        </template>
                        <template v-else>
                            <van-badge :content="isTabsBadge_fabric" class="tabs-badge" color="#2196f3"
                                :show-zero="false">
                                面料
                            </van-badge>
                        </template>
                    </template>
                    <rp-summary-item title="面料明细" simple>
                        <van-tabs ref="tabsFabricMxRef" class="mattress-tabs__fabric" v-model="fabricMxTabs"
                            color="#5AC8FA" sticky :offset-top="fabricHeaderHeight">
                            <van-tab name="tabpage_8" v-if="Number(mattresstypeEnum.if_top_side) == 1">
                                <template #title>
                                    <template v-if="isFilterErrorBadge(fabricMxTab8)">
                                        裥面
                                        <van-badge :content="isFilterErrorBadge(fabricMxTab8) + '异常'"
                                            class="tabs-badge">
                                        </van-badge>
                                    </template>
                                    <template v-else>
                                        裥面
                                        <van-badge :content="isFilterSucessBadge(fabricMxTab8)" class="tabs-badge"
                                            color="#5AC8FA" :show-zero="false">
                                        </van-badge>
                                    </template>
                                </template>
                                <lj-grid table-hover :table-data="fabricMxTab8" :columns="gridColumns_mx" editing
                                    @cell-click="handleGridCellClick" @content-cell-clear="handleGridClear" />
                            </van-tab>
                            <van-tab title="裥底" name="tabpage_9" v-if="Number(mattresstypeEnum.if_button_sdie) == 1">
                                <template #title>
                                    <template v-if="isFilterErrorBadge(fabricMxTab9)">
                                        裥底
                                        <van-badge :content="isFilterErrorBadge(fabricMxTab9) + '异常'"
                                            class="tabs-badge">
                                        </van-badge>
                                    </template>
                                    <template v-else>
                                        裥底
                                        <van-badge :content="isFilterSucessBadge(fabricMxTab9)" class="tabs-badge"
                                            color="#5AC8FA" :show-zero="false">
                                        </van-badge>
                                    </template>
                                </template>
                                <lj-grid table-hover :table-data="fabricMxTab9" :columns="gridColumns_mx" editing
                                    @cell-click="handleGridCellClick" @content-cell-clear="handleGridClear" />
                            </van-tab>
                            <van-tab title="裥大恻" name="tabpage_10" v-if="Number(mattresstypeEnum.if_big_side) == 1">
                                <template #title>
                                    <template v-if="isFilterErrorBadge(fabricMxTab10)">
                                        裥大恻
                                        <van-badge :content="isFilterErrorBadge(fabricMxTab10) + '异常'"
                                            class="tabs-badge">
                                        </van-badge>
                                    </template>
                                    <template v-else>
                                        裥裥大恻面
                                        <van-badge :content="isFilterSucessBadge(fabricMxTab10)" class="tabs-badge"
                                            color="#5AC8FA" :show-zero="false">
                                        </van-badge>
                                    </template>
                                </template>
                                <lj-button-menu :mainButtons="mainButtons_fabric"
                                    @callFunction="handleButtonMenuToolsEvents_fabric10" :moreVisiable="false"
                                    justifyContent="start">
                                </lj-button-menu>
                                <lj-grid ref="grid_tabpage_10" table-hover :table-data="fabricMxTab10"
                                    :columns="gridColumns_mx" editing @cell-click="handleGridCellClick"
                                    @content-cell-clear="handleGridClear" />
                            </van-tab>
                            <van-tab title="裥小恻" name="tabpage_11" v-if="Number(mattresstypeEnum.if_small_side) == 1">
                                <template #title>
                                    <template v-if="isFilterErrorBadge(fabricMxTab11)">
                                        裥小恻
                                        <van-badge :content="isFilterErrorBadge(fabricMxTab11) + '异常'"
                                            class="tabs-badge">
                                        </van-badge>
                                    </template>
                                    <template v-else>
                                        裥小恻
                                        <van-badge :content="isFilterSucessBadge(fabricMxTab11)" class="tabs-badge"
                                            color="#5AC8FA" :show-zero="false">
                                        </van-badge>
                                    </template>
                                </template>
                                <lj-button-menu :mainButtons="mainButtons_fabric"
                                    @callFunction="handleButtonMenuToolsEvents_fabric11" :moreVisiable="false"
                                    justifyContent="start">
                                </lj-button-menu>
                                <lj-grid ref="grid_tabpage_11" table-hover :table-data="fabricMxTab11"
                                    :columns="gridColumns_mx" editing @cell-click="handleGridCellClick"
                                    @content-cell-clear="handleGridClear" />
                            </van-tab>
                            <van-tab title="裥V恻" name="tabpage_12" v-if="Number(mattresstypeEnum.if_v_side) == 1">
                                <template #title>
                                    <template v-if="isFilterErrorBadge(fabricMxTab12)">
                                        裥V恻
                                        <van-badge :content="isFilterErrorBadge(fabricMxTab12) + '异常'"
                                            class="tabs-badge">
                                        </van-badge>
                                    </template>
                                    <template v-else>
                                        裥V恻
                                        <van-badge :content="isFilterSucessBadge(fabricMxTab12)" class="tabs-badge"
                                            color="#5AC8FA" :show-zero="false">
                                        </van-badge>
                                    </template>
                                </template>
                                <lj-grid table-hover :table-data="fabricMxTab12" :columns="gridColumns_mx" editing
                                    @cell-click="handleGridCellClick" @content-cell-clear="handleGridClear" />
                            </van-tab>
                            <van-tab title="拉手刺绣及其他工艺" name="tabpage_13">
                                <template #title>
                                    <template v-if="isFilterErrorBadge(fabricMxTab13)">
                                        拉手刺绣及其他工艺
                                        <van-badge :content="isFilterErrorBadge(fabricMxTab13) + '异常'"
                                            class="tabs-badge">
                                        </van-badge>
                                    </template>
                                    <template v-else>
                                        拉手刺绣及其他工艺
                                        <van-badge :content="isFilterSucessBadge(fabricMxTab13)" class="tabs-badge"
                                            color="#5AC8FA" :show-zero="false">
                                        </van-badge>
                                    </template>
                                </template>
                                <lj-grid table-hover :table-data="fabricMxTab13" :columns="gridColumns_mx" editing
                                    @cell-click="handleGridCellClick" @content-cell-clear="handleGridClear" />
                            </van-tab>
                        </van-tabs>
                    </rp-summary-item>
                </van-tab>
                <van-tab title="床网" name="bednetMx">
                    <template #title>
                        <template v-if="isFilterErrorBadge(bednetMxData)">
                            <van-badge :content="isFilterErrorBadge(bednetMxData) + '异常'" class="tabs-badge">
                                床网
                            </van-badge>
                        </template>
                        <template v-else>
                            <van-badge :content="isFilterSucessBadge(bednetMxData)" class="tabs-badge" color="#2196f3"
                                :show-zero="false">
                                床网
                            </van-badge>
                        </template>
                    </template>
                    <rp-summary-item title="床网明细" simple>
                        <lj-button-menu :mainButtons="mainButtons_bednet"
                            @callFunction="handleButtonMenuToolsEvents_bednet" :moreVisiable="false"
                            justifyContent="start">
                        </lj-button-menu>
                        <lj-grid ref="grid_bednet" table-hover :table-data="bednetMxData" :columns="gridColumns_bednet"
                            editing @cell-click="handleGridCellClick_bednet"
                            @content-cell-clear="handleGridClear_bednet" />
                    </rp-summary-item>
                </van-tab>
                <van-tab title="垫层" name="cushionsMx">
                    <template #title>
                        <template v-if="isFilterErrorBadge(cushionsMxData)">
                            <van-badge :content="isFilterErrorBadge(cushionsMxData) + '异常'" class="tabs-badge">
                                垫层
                            </van-badge>
                        </template>
                        <template v-else>
                            <van-badge :content="isFilterSucessBadge(cushionsMxData)" class="tabs-badge" color="#2196f3"
                                :show-zero="false">
                                垫层
                            </van-badge>
                        </template>
                    </template>
                    <rp-summary-item title="垫层明细" simple>
                        <lj-button-menu :mainButtons="mainButtons_cushions"
                            @callFunction="handleButtonMenuToolsEvents_cushions" :moreVisiable="false"
                            justifyContent="start">
                        </lj-button-menu>
                        <lj-grid ref="grid_cushions" table-hover :table-data="cushionsMxData"
                            :columns="gridColumns_cushions" editing @cell-click="handleGridCellClick_cushions"
                            @content-cell-clear="handleGridClear_cushions" />
                    </rp-summary-item>
                </van-tab>
                <van-tab title="辅料" name="accessoriesMx">
                    <template #title>
                        <template v-if="isFilterErrorBadge(accessoriesMxData)">
                            <van-badge :content="isFilterErrorBadge(accessoriesMxData) + '异常'" class="tabs-badge">
                                辅料
                            </van-badge>
                        </template>
                        <template v-else>
                            <van-badge :content="isFilterSucessBadge(accessoriesMxData)" class="tabs-badge"
                                color="#2196f3" :show-zero="false">
                                辅料
                            </van-badge>
                        </template>
                    </template>
                    <rp-summary-item title="辅料明细" simple>
                        <lj-grid table-hover :table-data="accessoriesMxData" :columns="gridColumns_accessories" editing
                            @cell-click="handleGridCellClick_accessories" @content-cell-clear="handleGridClear" />
                    </rp-summary-item>
                </van-tab>
                <van-tab title="包装" name="packagMx">
                    <template #title>
                        <template v-if="isFilterErrorBadge(packagMxData)">
                            <van-badge :content="isFilterErrorBadge(packagMxData) + '异常'" class="tabs-badge">
                                包装
                            </van-badge>
                        </template>
                        <template v-else>
                            <van-badge :content="isFilterSucessBadge(packagMxData)" class="tabs-badge" color="#2196f3"
                                :show-zero="false">
                                包装
                            </van-badge>
                        </template>
                    </template>
                    <rp-summary-item title="包装明细" simple>
                        <van-form>
                            <van-cell title="包装方式" :value="mainObject.packtype | enumFilter(packtypeOptions)" is-link
                                class="base-cell" @click="handleClickPackagCell('packtype')" />
                            <van-field label="卷包直径" v-model="mainObject.diameter" type="number"
                                v-if="mainObject.packtype == 1" />
                            <van-cell title="木托方式"
                                :value="mainObject.woodpallettype | enumFilter(woodpallettypeOptions)" is-link
                                class="base-cell" v-if="mainObject.packtype == 0"
                                @click="handleClickPackagCell('woodpallettype')" />
                            <van-field label="压包数量" v-model="mainObject.packqty" type="number"
                                v-if="mainObject.packtype == 0" />
                            <van-cell title="地区" :value="mainObject.area | enumFilter(areaOptions)" is-link
                                class="base-cell" @click="handleClickPackagCell('area')" />
                            <van-cell title="柜型" :value="mainObject.cabinet_type | enumFilter(cabinetTypeOptions)"
                                is-link class="base-cell" @click="handleClickPackagCell('cabinet_type')" />
                            <van-field label="体积" v-model="mainObject.cubage" type="number" />
                        </van-form>

                        <lj-grid table-hover :table-data="packagMxData" :columns="gridColumns_packag" editing
                            @cell-click="handleGridCellClick_packag" @content-cell-clear="handleGridClear" />
                    </rp-summary-item>
                </van-tab>
                <van-tab title="内布套" name="innerClothLayerMx" v-if="Number(mainObject.if_n_butao)">
                    <template #title>
                        <template v-if="isFilterErrorBadge(innerClothLayerMxData)">
                            <van-badge :content="isFilterErrorBadge(innerClothLayerMxData) + '异常'" class="tabs-badge">
                                内布套
                            </van-badge>
                        </template>
                        <template v-else>
                            <van-badge :content="isFilterSucessBadge(innerClothLayerMxData)" class="tabs-badge"
                                color="#2196f3" :show-zero="false">
                                内布套
                            </van-badge>
                        </template>
                    </template>
                    <rp-summary-item title="内布套明细" simple>
                        <lj-button-menu :mainButtons="mainButtons_inner"
                            @callFunction="handleButtonMenuToolsEvents_inner" :moreVisiable="false"
                            justifyContent="start">
                        </lj-button-menu>
                        <lj-grid ref="grid_inner" table-hover :table-data="innerClothLayerMxData"
                            :columns="gridColumns_inner" editing @cell-click="handleGridCellClick_inner"
                            @content-cell-clear="handleGridClear" />
                    </rp-summary-item>
                </van-tab>
                <van-tab title="顶布裥棉" name="topCottonMx" v-if="Number(mainObject.if_w_butao)">
                    <template #title>
                        <template v-if="isFilterErrorBadge(topCottonMxData)">
                            <van-badge :content="isFilterErrorBadge(topCottonMxData) + '异常'" class="tabs-badge">
                                顶布裥棉
                            </van-badge>
                        </template>
                        <template v-else>
                            <van-badge :content="isFilterSucessBadge(topCottonMxData)" class="tabs-badge"
                                color="#2196f3" :show-zero="false">
                                顶布裥棉
                            </van-badge>
                        </template>
                    </template>
                    <rp-summary-item title="顶布裥棉" simple>
                        <lj-button-menu :mainButtons="mainButtons_subSpecs"
                            @callFunction="handleButtonMenuToolsEvents_topCotton" :moreVisiable="false"
                            justifyContent="start">
                        </lj-button-menu>
                        <lj-grid ref="grid_topCotton" table-hover :table-data="topCottonMxData"
                            :columns="gridColumns_mx" editing @cell-click="handleGridCellClick"
                            @content-cell-clear="handleGridClear" />
                    </rp-summary-item>
                </van-tab>
                <van-tab title="主副规格" name="subSpecs">
                    <template #title>
                        <template v-if="mainObject.parentid > 0">
                            <van-badge content="副" class="tabs-badge">
                                主副规格
                            </van-badge>
                        </template>
                        <template v-else>
                            <van-badge :content="subSpecsMxData.length > 0 ? subSpecsMxData.length : ''"
                                class="tabs-badge" color="#2196f3">
                                主副规格
                            </van-badge>
                        </template>
                    </template>
                    <rp-summary-item title="主副规格" simple>
                        <lj-button-menu :mainButtons="mainButtons_subSpecs"
                            @callFunction="handleButtonMenuToolsEvents_subSpecs" :moreVisiable="false"
                            justifyContent="start">
                        </lj-button-menu>
                        <lj-grid table-hover ref="grid_subSpecs" :table-data="subSpecsMxData"
                            :columns="gridColumns_subspecs" editing />
                    </rp-summary-item>
                </van-tab>
            </van-tabs>


            <van-action-sheet v-model="showActionSheet" :closeable="false">
                <van-picker :title="actionColumn.title" show-toolbar value-key="label"
                    :default-index="actionColumn.defaultIndex" :columns="actionColumn.enum"
                    @confirm="handleGridSelectConfirm" @cancel="showActionSheet = false" />
            </van-action-sheet>
        </div>
        <div class="detail-control" slot="footer">
            <van-button class="btn" round block @click="gotoCancel">
                取消
            </van-button>
            <van-button class="btn" round block type="info" @click="gotoSave">
                保存
            </van-button>
        </div>

    </lj-win-common>
</template>

<script>
import ljWinCommon from 'components/lj-win-common'
import LjGrid from "components/lj-grid";
import LjTagDouble from "components/lj-tag-double";
import LjBaseForm from 'components/lj-base-form';
import LjStatistic from 'components/lj-statistic.vue';
import RpSummaryItem from 'components/report-widget/rp-summary-item';
import LjCheckbox from 'components/lj-checkbox.vue';
import LjButtonMenu from "components/lj-button-menu";


/**
 * @description 面料分类取值
 */
const mtrltypeTabList = [
    {
        label: "选布料",
        formulakinds: [0, 1, 2, 3, 4, 101, 111],
        value: 3
    },
    {
        label: "喷胶绵",
        formulakinds: [40, 41, 42, 43, 44, 102, 112],
        value: 5
    },
    {
        label: "裥绵海绵",
        formulakinds: [50, 51, 52, 53, 54, 103, 113],
        value: 4
    },
    {
        label: "无纺布",
        formulakinds: [60, 61, 62, 63, 64, 104, 114],
        value: 30
    },
    {
        label: "裥花图案",
        formulakinds: [70, 71, 72, 73, 74, 105, 115],
        value: 26
    },
    {
        label: "布料-加工工艺",
        formulakinds: [80, 81, 82, 83, 84, 106, 116],
        value: 15
    },
    {
        label: "拉手",
        formulakinds: [5],
        value: 10
    },
    {
        label: "刺绣",
        formulakinds: [6],
        value: 11
    },
    {
        label: "大侧*压布",
        formulakinds: [7],
        value: 3
    },
    {
        label: "大侧*边带",
        formulakinds: [8, 9],
        value: 9
    },
    {
        label: "大侧*上下压线",
        formulakinds: [10],
        value: 12
    },
    {
        label: "垫层",
        formulakinds: [11, 32, 33],
        value: 6
    },
    {
        label: "顶布",
        formulakinds: [12],
        value: 3
    },
    {
        label: "毡类",
        formulakinds: [13],
        value: 7
    },
    {
        label: "打底无纺布",
        formulakinds: [14],
        value: 2
    },
    {
        label: "辅料",
        formulakinds: [15],
        value: 8
    },
    {
        label: "PE",
        formulakinds: [16],
        value: 16
    },
    {
        label: "外层PE",
        formulakinds: [17],
        value: 17
    },
    {
        label: "PVC",
        formulakinds: [18],
        value: 18
    },
    {
        label: "卷包包装",
        formulakinds: [19],
        value: 19
    },
    {
        label: "牛皮纸袋",
        formulakinds: [20],
        value: 20
    },
    {
        label: "蓝色PE护角",
        formulakinds: [21],
        value: 21
    },
    {
        label: "无纺布袋",
        formulakinds: [22],
        value: 22
    },
    {
        label: "牛皮袋护角",
        formulakinds: [23],
        value: 23
    },
    {
        label: "编织袋",
        formulakinds: [24],
        value: 24
    },
    {
        label: "外袋",
        formulakinds: [25],
        value: 13
    },
    {
        label: "内袋",
        formulakinds: [26],
        value: 14
    },
    {
        label: "无拉手脚轮",
        formulakinds: [27],
        value: -1
    },
    {
        label: "拉钮",
        formulakinds: [28],
        value: -1
    },
    {
        label: "网面布料",
        formulakinds: [29],
        value: -1
    },
    {
        label: "防火线",
        formulakinds: [30],
        value: -1
    },
    {
        label: "木托",
        formulakinds: [31],
        value: -1
    },
    {
        label: "床网",
        formulakinds: [99],
        value: -1
    },
    {
        label: "拉链",
        formulakinds: [202],
        value: 31
    },
    {
        label: "席垫",
        formulakinds: [203],
        value: 32
    },
    {
        label: "车花边",
        formulakinds: [205],
        value: 32
    }
];
/**
 * @description 包装
 */
const mtrltypeTabList_packag = [
    {
        label: "选布料",
        formulakinds: [0, 1, 2, 3, 4],
        value: 3
    },
    {
        label: "喷胶绵",
        formulakinds: [40, 41, 42, 43, 44],
        value: 5
    },
    {
        label: "裥绵海绵",
        formulakinds: [50, 51, 52, 53, 54],
        value: 4
    },
    {
        label: "无纺布",
        formulakinds: [60, 61, 62, 63, 64],
        value: 2
    },
    {
        label: "裥花图案",
        formulakinds: [70, 71, 72, 73, 74],
        value: 4
    },
    {
        label: "布料-加工工艺",
        formulakinds: [80, 81, 82, 83, 84],
        value: 15
    },
    {
        label: "拉手",
        formulakinds: [5],
        value: 10
    },
    {
        label: "刺绣",
        formulakinds: [6],
        value: 11
    },
    {
        label: "大侧*压布",
        formulakinds: [7],
        value: 2
    },
    {
        label: "大侧*边带",
        formulakinds: [8, 9],
        value: 9
    },
    {
        label: "大侧*上下压线",
        formulakinds: [10],
        value: 12
    },
    {
        label: "垫层",
        formulakinds: [11, 32, 33],
        value: 6
    },
    {
        label: "顶布",
        formulakinds: [12],
        value: 3
    },
    {
        label: "毡类",
        formulakinds: [13],
        value: 7
    },
    {
        label: "打底无纺布",
        formulakinds: [14],
        value: 2
    },
    {
        label: "辅料",
        formulakinds: [15],
        value: 8
    },
    {
        label: "PE",
        formulakinds: [16],
        value: 16
    },
    {
        label: "外层PE",
        formulakinds: [17],
        value: 17
    },
    {
        label: "PVC",
        formulakinds: [18],
        value: 18
    },
    {
        label: "卷包包装",
        formulakinds: [19],
        value: 19
    },
    {
        label: "牛皮纸袋",
        formulakinds: [20],
        value: 20
    },
    {
        label: "蓝色PE护角",
        formulakinds: [21],
        value: 21
    },
    {
        label: "无纺布袋",
        formulakinds: [22],
        value: 22
    },
    {
        label: "牛皮袋护角",
        formulakinds: [23],
        value: 23
    },
    {
        label: "编织袋",
        formulakinds: [24],
        value: 24
    },
    {
        label: "外袋",
        formulakinds: [25],
        value: 13
    },
    {
        label: "内袋",
        formulakinds: [26],
        value: 14
    },
    {
        label: "无拉手脚轮",
        formulakinds: [27],
        value: -1
    },
    {
        label: "拉钮",
        formulakinds: [28],
        value: -1
    },
    {
        label: "网面布料",
        formulakinds: [29],
        value: -1
    },
    {
        label: "防火线",
        formulakinds: [30],
        value: -1
    },
    {
        label: "木托",
        formulakinds: [31],
        value: -1
    },
    {
        label: "床网",
        formulakinds: [99],
        value: -1
    }
];

/**
 * @description 垫层
 */
const mtrltypeTabList_cushions = [
    {
        label: "垫层",
        formulakinds: [11, 32, 33],
        value: 6
    },
    {
        label: "顶布",
        formulakinds: [12],
        value: 29
    },
    {
        label: "毡类",
        formulakinds: [13, 35],
        value: 7
    },
    {
        label: "打底无纺布",
        formulakinds: [14],
        value: 2
    },
    {
        label: "网面布料",
        formulakinds: [29],
        value: 3
    },
    {
        label: "顶布裥棉",
        formulakinds: [1201],
        value: 1201
    }
];

/**
 * @description 辅料
 */
const mtrltypeTabList_accessories = [
    {
        label: "辅料",
        formulakinds: [15],
        value: 8
    }
];

/**
 * @description 内部套
 */
const mtrltypeTabList_inner = [
    {
        label: "选布料",
        formulakinds: [0, 1, 2, 3, 4, 101, 111],
        value: 3
    },
    {
        label: "喷胶绵",
        formulakinds: [40, 41, 42, 43, 44, 102, 112],
        value: 5
    },
    {
        label: "裥绵海绵",
        formulakinds: [50, 51, 52, 53, 54, 103, 113],
        value: 4
    },
    {
        label: "无纺布",
        formulakinds: [60, 61, 62, 63, 64, 104, 114],
        value: 200
    },
    {
        label: "裥花图案",
        formulakinds: [70, 71, 72, 73, 74, 105, 115],
        value: 26
    },
    {
        label: "布料-加工工艺",
        formulakinds: [80, 81, 82, 83, 84, 106, 116],
        value: 15
    },
    {
        label: "拉手",
        formulakinds: [5],
        value: 10
    },
    {
        label: "刺绣",
        formulakinds: [6],
        value: 11
    },
    {
        label: "大侧*压布",
        formulakinds: [7],
        value: 2
    },
    {
        label: "大侧*边带",
        formulakinds: [8, 9],
        value: 9
    },
    {
        label: "大侧*上下压线",
        formulakinds: [10],
        value: 12
    },
    {
        label: "垫层",
        formulakinds: [11, 32, 33],
        value: 6
    },
    {
        label: "顶布",
        formulakinds: [12],
        value: 3
    },
    {
        label: "毡类",
        formulakinds: [13],
        value: 7
    },
    {
        label: "打底无纺布",
        formulakinds: [14],
        value: 2
    },
    {
        label: "辅料",
        formulakinds: [15],
        value: 8
    },
    {
        label: "PE",
        formulakinds: [16],
        value: 16
    },
    {
        label: "外层PE",
        formulakinds: [17],
        value: 17
    },
    {
        label: "PVC",
        formulakinds: [18],
        value: 18
    },
    {
        label: "卷包包装",
        formulakinds: [19],
        value: 19
    },
    {
        label: "牛皮纸袋",
        formulakinds: [20],
        value: 20
    },
    {
        label: "蓝色PE护角",
        formulakinds: [21],
        value: 21
    },
    {
        label: "无纺布袋",
        formulakinds: [22],
        value: 22
    },
    {
        label: "牛皮袋护角",
        formulakinds: [23],
        value: 23
    },
    {
        label: "编织袋",
        formulakinds: [24],
        value: 24
    },
    {
        label: "外袋",
        formulakinds: [25],
        value: 13
    },
    {
        label: "内袋",
        formulakinds: [26],
        value: 14
    },
    {
        label: "无拉手脚轮",
        formulakinds: [27],
        value: -1
    },
    {
        label: "拉钮",
        formulakinds: [28],
        value: -1
    },
    {
        label: "网面布料",
        formulakinds: [29],
        value: -1
    },
    {
        label: "防火线",
        formulakinds: [30],
        value: -1
    },
    {
        label: "木托",
        formulakinds: [31],
        value: -1
    },
    {
        label: "床网",
        formulakinds: [99],
        value: -1
    },
    {
        label: "拉链",
        formulakinds: [202],
        value: 31
    },
    {
        label: "边带",
        formulakinds: [203],
        value: -9
    }
];

export default {
    components: {
        LjGrid,
        ljWinCommon,
        LjTagDouble,
        LjBaseForm,
        LjStatistic,
        RpSummaryItem,
        LjCheckbox,
        LjButtonMenu
    },
    props: {},
    created() {
        var pageParm = $lj.getPageParam();
        this.mainObject = pageParm.mainObject;
        this.title = pageParm.winType == 1 ? '床垫报价-修改' : '床垫报价-新建'

        this.winType = pageParm.winType;

        // 复制报价
        if (this.winType == 2) {
            this.title = "床垫报价-复制";
            this.mainObject.copy_id = pageParm.mainObject.mattressid;
        }

        this.initLayouColumns(pageParm.mainObject);

        this.refresh();

        this.getFormulakindEnum();
    },
    mounted() {
        let user = $lj.getStorage("user");
        this.username = user.username;

        // 赋值：面料tabs粘贴布局离顶部距离
        this.$nextTick(() => {
            let height = this.headerHeight ? this.headerHeight + "" : "0";
            height = Number(height.replace("px", ""));
            const tabsRef = this.$refs.vantabsRef;
            // 查找子元素
            const navElement = tabsRef.$el.querySelector('.van-tabs__nav');
            // 获取高度
            this.fabricHeaderHeight = navElement ? (height + navElement.offsetHeight - 15) + 'px' : (height + 44) + 'px';
        })
    },
    data() {
        return {
            editEnabled: false,
            showActionSheet: false,
            actionColumn: {}, // 当前操作列
            mainObject: {},
            oriMxData: {}, // 原始明细数据
            fabricMxData: [], // 面料明细数据
            fabricMxTab8: [], // 面料明细数据
            fabricMxTab9: [], // 面料明细数据
            fabricMxTab10: [], // 面料明细数据
            fabricMxTab11: [], // 面料明细数据
            fabricMxTab12: [], // 面料明细数据
            fabricMxTab13: [], // 面料明细数据
            cushionsMxData: [], // 垫层明细数据
            accessoriesMxData: [], // 辅料明细数据
            packagMxData: [], // 包装明细数据
            bednetMxData: [], // 床网明细数据
            innerClothLayerMxData: [], // 内布套明细数据
            topCottonMxData: [], // 顶布裥棉明细数据
            topCottonAddList: [], // 顶布裥棉：新增按钮-下拉菜单
            subSpecsMxData: [], // 主副规格明细数据
            gridColumns_bednet: [],
            gridColumns_cushions: [],
            gridColumns_accessories: [],
            gridColumns_packag: [],
            gridColumns_inner: [],
            gridColumns_subspecs: [],
            gridColumns_mx: [],
            username: "",
            tabsActive: "base",
            fabricMxTabs: "",
            headerHeight: 80,// header高度
            fabricHeaderHeight: 0,
            headerBg: "transparent",
            headerTextColor: "#fff",
            // headerOverHeight: 32,// header超出滚动高度
            deptEnum: [],
            mattresstypeEnum: null,
            formulaKindEnum: [], // 计算公式类型
            formulaKindDcEnum: [], // 计算公式类型-垫层
            diancengAreaEnum: [], // 垫层面积
            columns: [], // 表格列布局信息
            basicGroup: [], // 基础信息分组
            cmpFormulas: null, // 计算公式
            cmpFormulaReplace: null, // 计算公式替换
            showAction: false, // 是否显示操作按钮
            billActions: [], // 单据操作按钮
            bednetIndex: -1, // 床网tab索引
            fabricMxTabList: [
                {
                    label: "裥面",
                    name: "tabpage_8",
                    visible: () => Number(this.mattresstypeEnum.if_top_side) == 1,
                    type: [0, 80, 40, 50, 60, 70, 9000],
                    ref: "fabricMxTab8"
                },
                {
                    label: "裥底",
                    name: "tabpage_9",
                    visible: () => Number(this.mattresstypeEnum.if_button_sdie) == 1,
                    type: [1, 81, 41, 51, 61, 71, 9001],
                    ref: "fabricMxTab9"
                },
                {
                    label: "裥大恻",
                    name: "tabpage_10",
                    visible: () => Number(this.mattresstypeEnum.if_big_side) == 1,
                    type: [2, 82, 42, 52, 62, 72, 9002],
                    ref: "fabricMxTab10"
                },
                {
                    label: "裥小恻",
                    name: "tabpage_11",
                    visible: () => Number(this.mattresstypeEnum.if_small_side) == 1,
                    type: [3, 83, 43, 53, 63, 73, 9003],
                    ref: "fabricMxTab11"
                },
                {
                    label: "裥V恻",
                    name: "tabpage_12",
                    visible: () => Number(this.mattresstypeEnum.if_v_side) == 1,
                    type: [4, 84, 44, 54, 64, 74, 9004],
                    ref: "fabricMxTab12"
                },
                {
                    label: "拉手刺绣及其他工艺",
                    name: "tabpage_13",
                    visible: () => true,
                    type: [
                        0, 80, 40, 50, 60, 70, 1, 81, 41, 51, 61, 71, 2, 82, 42, 52, 62, 72, 3, 83, 43, 53, 63, 73, 4, 84, 44, 54, 64, 74, 9000,
                        9001, 9002, 9003, 9004, 9005, 9006
                    ], // not in
                    ref: "fabricMxTab13"
                },
                {
                    label: "床网",
                    name: "bednetMx",
                    ref: "bednetMxData"
                },
                {
                    label: "垫层",
                    name: "cushionsMx",
                    ref: "cushionsMxData"
                },
                {
                    label: "辅料",
                    name: "accessoriesMx",
                    ref: "accessoriesMxData"
                },
                {
                    label: "包装",
                    name: "packagMx",
                    ref: "packagMxData"
                },
                {
                    label: "内布套",
                    name: "innerClothLayerMx",
                    ref: "innerClothLayerMxData"
                },
                {
                    label: "顶布裥棉",
                    name: "topCottonMx",
                    ref: "topCottonMxData"
                }
            ],
            otherMxTabList: [
                {
                    label: "内布套",
                    name: "tabpage_14",
                    type: [101, 102, 103, 104, 105, 106]
                },
                {
                    label: "外布套",
                    name: "tabpage_15",
                    type: [111, 112, 113, 114, 115, 116]
                }
            ],
            fabricMx10NewMtrlGroup: [
                {
                    label: "普通大侧",
                    value: 1
                },
                {
                    label: "上下拼侧1",
                    value: 2
                },
                {
                    label: "上下拼侧2",
                    value: 3
                },
                {
                    label: "上下拼侧3",
                    value: 4
                },
                {
                    label: "左右拼侧1",
                    value: 5
                },
                {
                    label: "左右拼侧2",
                    value: 6
                },
                {
                    label: "左右拼侧3",
                    value: 7
                },
                {
                    label: "左右拼侧4",
                    value: 8
                }
            ],
            fabricMx11NewMtrlGroup: [
                {
                    label: "小侧1",
                    value: 1
                },
                {
                    label: "小侧1-上下拼侧1",
                    value: 2
                },
                {
                    label: "小侧1-上下拼侧2",
                    value: 3
                },
                {
                    label: "小侧1-上下拼侧3",
                    value: 4
                }
            ],
            packtypeOptions: [
                {
                    label: "压包",
                    value: 0
                },
                {
                    label: "卷包",
                    value: 1
                },
                {
                    label: "国内",
                    value: 2
                }
            ],
            woodpallettypeOptions: [
                {
                    label: "普通木托",
                    value: 0
                },
                {
                    label: "夹板木托",
                    value: 1
                },
                {
                    label: "铁管木托",
                    value: 2
                }
            ],
            areaOptions: [
                {
                    label: "普通地区",
                    value: "普通地区"
                },
                {
                    label: "特定地区",
                    value: "特定地区"
                }
            ],
            cabinetTypeOptions: [
                {
                    label: "大柜",
                    value: "大柜"
                },
                {
                    label: "小柜",
                    value: "小柜"
                }
            ],
            statisticData: [
                {
                    label: "【标准金额】",
                    value: 0
                },
                {
                    label: "【大单金额】",
                    value: 0
                },
                {
                    label: "【总成本】",
                    value: 0,
                    power: () => {
                        let userInfo = $lj.getStorage('user');
                        return userInfo.usermode === 0;
                    }
                },
                {
                    label: "【不含税出厂价】",
                    value: 0,
                    power: () => {
                        let userInfo = $lj.getStorage('user');
                        return userInfo.usermode === 0;
                    }
                },
                {
                    label: "【部门不含税价】",
                    value: 0,
                    subtitle: "财务底价",
                    power: () => {
                        let userInfo = $lj.getStorage('user');
                        return userInfo.usermode === 0;
                    }
                },
                {
                    label: "【税金】",
                    value: 0,
                    power: () => {
                        let userInfo = $lj.getStorage('user');
                        return userInfo.usermode === 0;
                    }
                },
                {
                    label: "【部门含税价】",
                    value: 0,
                    power: () => {
                        let userInfo = $lj.getStorage('user');
                        return userInfo.usermode === 0;
                    }
                },
                {
                    label: "【外币价】",
                    value: 0,
                    subtitle: "报价金额",
                    power: () => {
                        let userInfo = $lj.getStorage('user');
                        return userInfo.usermode === 0;
                    }
                }
            ],
            columnsExtraAttr: [
                {
                    field: "deptid",
                    title: "部门",
                    basicinfo: {
                        el: "select",
                        editable: true,
                        // rules: [{ required: true, message: "请先选择部门", trigger: "change" }],
                        props: {
                            filterable: true,
                            clearable: false
                        },
                        order: 1,
                        group: "单据信息"
                    }
                },
                {
                    field: "mattressrelcode",
                    title: "床垫编码",
                    basicinfo: {
                        editable: true,
                        props: { type: "textarea" }
                    }
                },
                {
                    field: "mattresstypeid",
                    title: "床垫类别",
                    basicinfo: {
                        el: "select",
                        editable: true,
                        // rules: [{ required: true, message: "请先选择床垫类别", trigger: "change" }],
                        props: {
                            clearable: false,
                            filterable: true,
                            // onChange: () => funcImportMattressMx()
                        }
                    }
                },
                {
                    field: "mattressname",
                    title: "床垫名称",
                    align: "left",
                    table: "u_mattress",
                    basicinfo: {
                        el: "input",
                        editable: true,
                        props: { type: "textarea" }
                    },
                },
                {
                    field: "dept_profitrate_rangli",
                    title: "部门让利点数",
                    basicinfo: {
                        el: "input",
                        editable: true,
                        props: { type: "number" },
                    }
                },
                {
                    field: "fees_dscrp",
                    title: "额外费用说明",
                    basicinfo: {
                        el: "input",
                        editable: true,
                        props: { type: "textarea", rows: 2 },
                    }
                },
                // {
                //     field: "foreign_cost",
                //     title: "外币价",
                //     basicinfo: {
                //         // titleKey: "bi_foreign_cost" // 报价金额
                //     }
                // },
                // {
                //     field: "nottax_dept_cost",
                //     title: "部门不含税价",
                //     basicinfo: {
                //         // titleKey: "bi_nottax_dept_cost" // 财务底价
                //     }
                // },
                {
                    field: "if_bcp_type",
                    title: "半成品",
                    basicinfo: {
                        editable: true,
                        labelHidden: true,
                        render: function (h, scope, self) {
                            let _render = [
                                h(LjCheckbox, {
                                    props: {
                                        value: scope.data.if_bcp_type,
                                        label: "半成品",
                                    },
                                    on: {
                                        input: function (val) {
                                            self.$emit("input", "if_bcp_type", val);
                                        }
                                    }
                                }),
                                h(LjCheckbox, {
                                    props: {
                                        value: scope.data.if_zhedie_type,
                                        label: "折叠款",
                                    },
                                    on: {
                                        input: function (val) {
                                            self.$emit("input", "if_zhedie_type", val);
                                        }
                                    }
                                }),
                            ];
                            return h("div", {
                                class: "lj-layout-grid-3"
                            }, _render)
                        }
                    }
                },
                {
                    field: "if_m_chai",
                    title: "面拆",
                    basicinfo: {
                        editable: true,
                        render: function (h, scope, self) {
                            let _render = [
                                h(LjCheckbox, {
                                    props: {
                                        value: scope.data.if_m_chai,
                                        label: "面拆",
                                    },
                                    on: {
                                        input: function (val) {
                                            self.$emit("input", "if_m_chai", val);
                                        }
                                    }
                                }),
                                h(LjCheckbox, {
                                    props: {
                                        value: scope.data.if_z_chai,
                                        label: "中拆",
                                    },
                                    on: {
                                        input: function (val) {
                                            self.$emit("input", "if_z_chai", val);
                                        }
                                    }
                                }),
                                h(LjCheckbox, {
                                    props: {
                                        value: scope.data.if_d_chai,
                                        label: "底拆",
                                    },
                                    on: {
                                        input: function (val) {
                                            self.$emit("input", "if_d_chai", val);
                                        }
                                    }
                                }),
                            ];
                            return h("div", {
                                class: "lj-layout-grid-3"
                            }, _render)
                        }
                    }
                },
                {
                    field: "mattress_width",
                    title: "床垫宽/CM",
                    basicinfo: {
                        el: "input",
                        editable: true,
                        props: { type: "number", clearable: true, placeholder: "请输入床垫宽/CM" }
                    }
                },
                {
                    field: "mattress_length",
                    title: "床垫长/CM",
                    basicinfo: {
                        el: "input",
                        editable: true,
                        props: { type: "number", clearable: true, placeholder: "请输入床垫长/CM" }
                    }
                },
                {
                    field: "mattress_height",
                    title: "床垫高/CM",
                    basicinfo: {
                        el: "input",
                        editable: true,
                        props: { type: "number", clearable: true, placeholder: "请输入床垫高/CM" }
                    }
                },
                {
                    field: "if_w_butao",
                    title: "顶布裥棉",
                    basicinfo: {
                        el: "checkbox",
                        editable: true,
                        // editable: ALLOW_EDIT_STATE
                        // render: (scope: any) => {
                        // console.log("if_w_butao scope :>> ", scope);
                        // let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
                        // return (
                        //     <>
                        //     <el-checkbox
                        //         v-model={scope.searchParam.if_w_butao}
                        //         true-value={1}
                        //         false-value={0}
                        //         disabled={_disabled}
                        //         label="顶布裥棉"
                        //         class="mr-8"
                        //     />
                        //     </>
                        // );
                        // }
                    }
                },
                {
                    field: "biandai_qty",
                    title: "边带数",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: (scope) => {
                            let someone =
                                Number(this.mainObject.if_m_chai) +
                                Number(this.mainObject.if_z_chai) +
                                Number(this.mainObject.if_d_chai);
                            if (someone > 0) {
                                return true;
                            }
                            return false;
                        }
                    }
                },
                {
                    field: "if_n_butao",
                    title: "内布套",
                    basicinfo: {
                        el: "checkbox",
                        editable: true,
                        //   labelHidden: true,
                        //   render: (scope: any) => {
                        //     let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
                        //     return (
                        //       <>
                        //         <el-checkbox
                        //           v-model={scope.searchParam.if_n_butao}
                        //           true-value={1}
                        //           false-value={0}
                        //           disabled={_disabled}
                        //           label="内布套"
                        //           class="mr-8"
                        //         />
                        //       </>
                        //     );
                        //   },
                        //   editvisible: (scope: any) => {
                        //     let someone =
                        //       Number(scope.searchParam.if_m_chai) +
                        //       Number(scope.searchParam.if_z_chai) +
                        //       Number(scope.searchParam.if_d_chai);
                        //     if (someone > 0) {
                        //       return true;
                        //     }
                        //     return false;
                        //   }
                    }
                },
                {
                    field: "s_cover_qty",
                    title: "内布套上覆",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                        editvisible: (scope) => {
                            let someone =
                                Number(scope.searchParam.if_m_chai) +
                                Number(scope.searchParam.if_z_chai) +
                                Number(scope.searchParam.if_d_chai);
                            if (someone > 0 && Number(scope.searchParam.if_n_butao)) {
                                return true;
                            }
                            return false;
                        }
                    }
                },
                {
                    field: "z_cover_qty",
                    title: "内布套侧覆",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                        editvisible: (scope) => {
                            let someone =
                                Number(scope.searchParam.if_m_chai) +
                                Number(scope.searchParam.if_z_chai) +
                                Number(scope.searchParam.if_d_chai);
                            if (someone > 0 && Number(scope.searchParam.if_n_butao)) {
                                return true;
                            }
                            return false;
                        }
                    }
                },
                {
                    field: "x_cover_qty",
                    title: "内布套下覆",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                        editvisible: (scope) => {
                            let someone =
                                Number(scope.searchParam.if_m_chai) +
                                Number(scope.searchParam.if_z_chai) +
                                Number(scope.searchParam.if_d_chai);
                            if (someone > 0 && Number(scope.searchParam.if_n_butao)) {
                                return true;
                            }
                            return false;
                        }
                    }
                },
                {
                    field: "if_m_wbutao_way",
                    title: "面料外布套做法",
                    basicinfo: {
                        el: "checkbox",
                        editvisible: (scope) => {
                            let someone =
                                Number(scope.searchParam.if_m_chai) +
                                Number(scope.searchParam.if_z_chai) +
                                Number(scope.searchParam.if_d_chai);
                            if (someone > 0) {
                                return true;
                            }
                            return false;
                        }
                    }
                },
                {
                    field: "s_m_cover_qty",
                    title: "面层向大侧覆盖",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                        editvisible: (scope) => {
                            let someone =
                                Number(scope.searchParam.if_m_chai) +
                                Number(scope.searchParam.if_z_chai) +
                                Number(scope.searchParam.if_d_chai);
                            if (someone > 0 && Number(scope.searchParam.if_m_wbutao_way)) {
                                return true;
                            }
                            return false;
                        }
                    }
                },
                {
                    field: "z_m_cover_qty",
                    title: "大侧向底层覆盖",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                        editvisible: (scope) => {
                            let someone =
                                Number(scope.searchParam.if_m_chai) +
                                Number(scope.searchParam.if_z_chai) +
                                Number(scope.searchParam.if_d_chai);
                            if (someone > 0 && Number(scope.searchParam.if_m_wbutao_way)) {
                                return true;
                            }
                            return false;
                        }
                    }
                },
                {
                    field: "x_m_cover_qty",
                    title: "底层向大侧覆盖",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                        editvisible: (scope) => {
                            let someone =
                                Number(scope.searchParam.if_m_chai) +
                                Number(scope.searchParam.if_z_chai) +
                                Number(scope.searchParam.if_d_chai);
                            if (someone > 0 && Number(scope.searchParam.if_m_wbutao_way)) {
                                return true;
                            }
                            return false;
                        }
                    }
                },
                {
                    field: "commission",
                    title: "佣金点数",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                    }
                },
                {
                    field: "other_rate",
                    title: "额外点数",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                    }
                },
                {
                    field: "extras_cost",
                    title: "额外费用",
                    basicinfo: {
                        el: "input",
                        props: { type: "number", clearable: true },
                        editable: true,
                    }
                },
                {
                    field: "taxes",
                    title: "税金",
                    enum: [
                        {
                            label: "不含税",
                            value: 1
                        },
                        {
                            label: "含税",
                            value: 1.07
                        }
                    ],
                    basicinfo: {
                        el: "select",
                        editable: true,
                        // render: (scope: any) => {
                        // let optionRender = [];
                        // let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
                        // console.log("taxrate scope.enum :>> ", scope.enum);
                        // scope.enum.map(item => {
                        //     optionRender.push(<el-option label={item.label} value={item.value} />);
                        // });
                        // let slotprefix = {
                        //     prefix: () => {
                        //     return <>{scope.searchParam.taxrate}</>;
                        //     }
                        // };

                        // let _taxrate = Number(scope.searchParam.taxrate);
                        // return (
                        //     <el-select
                        //     v-model={_taxrate}
                        //     v-slots={slotprefix}
                        //     class="select-text-right"
                        //     disabled={_disabled}
                        //     onChange={val => funcTaxrateChange(val, scope.searchParam)}
                        //     >
                        //     {optionRender}
                        //     </el-select>
                        // );
                        // }
                    }
                },
                {
                    field: "moneyrate",
                    title: "汇率",
                    basicinfo: {
                        el: "select",
                        editable: true,
                        // render: (scope: any) => {
                        // let optionRender = [];
                        // let _disabled = !ALLOW_EDIT_STATE.includes(scope.status);
                        // scope.enum.map(item => {
                        //     optionRender.push(<el-option label={item.label} value={item.value} />);
                        // });
                        // let slotprefix = {
                        //     prefix: () => {
                        //     return <>{scope.searchParam.moneyrate}</>;
                        //     }
                        // };

                        // return (
                        //     <el-select
                        //     v-model={scope.searchParam.if_moneyrate}
                        //     v-slots={slotprefix}
                        //     class="select-text-right"
                        //     disabled={_disabled}
                        //     onChange={val => funcMoneyrateChange(val, scope.searchParam)}
                        //     >
                        //     {optionRender}
                        //     </el-select>
                        // );
                        // }
                    }
                }
            ],
            columnsExtraAttr_mx: [
                {
                    title: "计算成功?",
                    field: "if_success",
                    datatype: "checkbox",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    },
                    // render: (scope) => {
                    //     if (Number(scope.row.if_success)) {
                    //         return (
                    //             <>
                    //             <ElTag type="danger">异常</ElTag>
                    //             </>
                    //         );
                    //     } else {
                    //         return <;></>;
                    //     }
                    // }
                },
                {
                    title: "+",
                    field: "addmx",
                    width: 80,
                    sloteditable: true,
                    slot(h, scope) {
                        if (scope.row.if_mtrl > 1) {
                            return h('van-button', {
                                props: {
                                    round: true,
                                    plain: true,
                                    size: "small",
                                    type: "info",
                                    icon: "plus",
                                }
                            });
                        } else {
                            return null
                        }
                    }
                },
                {
                    title: "-",
                    field: "delmx",
                    width: 80,
                    sloteditable: true,
                    slot(h, scope) {
                        if (scope.row.if_mtrl > 1) {
                            return h('van-button', {
                                props: {
                                    round: true,
                                    plain: true,
                                    size: "small",
                                    type: "danger",
                                    icon: "minus",
                                }
                            });
                        } else {
                            return null
                        }
                    }
                },
                {
                    title: "位置",
                    field: "chastr"
                },
                {
                    title: "公式名",
                    field: "formulakind",
                    align: "left",
                    slot: (h, scope) => {
                        const { column, row, status } = scope;
                        let itmName = this.formulaKindEnum.find(t => Number(t.value) == Number(row.formulakind)).label;
                        return h("span", {}, itmName);
                    }
                },
                {
                    title: "按物料？",
                    field: "if_mtrl",
                    enum: [
                        {
                            value: "0",
                            label: "无物料"
                        },
                        {
                            value: "1",
                            label: "单物料"
                        },
                        {
                            value: "2",
                            label: "多物料"
                        }
                    ]
                },
                {
                    title: "厚度cm",
                    field: "thickness",
                    type: "number",
                    editable: true,
                },
                {
                    title: "物料",
                    field: "mtrlname",
                    sloteditable: true,
                    clearable: true,
                },
                {
                    title: "数量/长度",
                    field: "qty",
                    type: "number",
                    editable: true,
                },
                {
                    title: "物料单价",
                    field: "price",
                    datatype: "number",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "单位",
                    field: "priceunit"
                },
                {
                    title: "收缩率",
                    field: "shrinkage",
                    datatype: "number",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "克重",
                    field: "gram_weight",
                    datatype: "number",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "幅宽",
                    field: "cloth_width",
                    datatype: "number",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "固定厚度?",
                    field: "if_inputqty",
                    datatype: "checkbox",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "按面积单价？",
                    field: "if_areaprice",
                    datatype: "checkbox",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "成本金额",
                    field: "costamt",
                    datatype: "number",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "金额文本公式",
                    field: "formula",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "金额数字公式",
                    field: "replace_formula",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "清单用量",
                    field: "useqty",
                    datatype: "number",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "用量文本公式",
                    field: "useformula",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "用量数字公式",
                    field: "replace_useformula",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    }
                },
                {
                    title: "工艺填写说明",
                    field: "gydscrp"
                }
            ],
            bednetCoumns: [
                {
                    title: "位置",
                    field: "chastr",
                    visible: false
                },
                {
                    title: "床网",
                    field: "mtrlname",
                    sloteditable: true,
                    clearable: true,
                    width: 250,
                },
            ],
            cushionsColumns: [
                {
                    title: "位置",
                    field: "chastr",
                    sloteditable: true,
                    clearable: true,
                },
                {
                    title: "公式名",
                    field: "formulakind",
                    sloteditable: true,
                    clearable: true,
                },
                {
                    title: "+",
                    field: "addmx",
                    visible: false
                },
                {
                    title: "-",
                    field: "delmx",
                    visible: false
                },
                {
                    title: "按物料?",
                    field: "if_mtrl",
                    visible: false
                },
            ],
            accessoriesColumns: [
                {
                    title: "位置",
                    field: "chastr",
                    visible: false
                },
                {
                    title: "厚度cm",
                    field: "thickness",
                    limited: true
                }
            ],
            packagColumns: [
                {
                    title: "位置",
                    field: "chastr",
                    visible: false
                },
                {
                    title: "厚度cm",
                    field: "thickness",
                    limited: true
                }
            ],
            columnsMxInnerClothLayer: [
                {
                    title: "计算成功?",
                    field: "if_success",
                    datatype: "checkbox",
                    limited: () => {
                        let user = $lj.getStorage("user");
                        return user.usermode != 0;
                    },
                    slot(h, scope) {
                        if (Number(scope.row.if_success)) {
                            return h(VanTag, {
                                props: {
                                    type: "danger",
                                }
                            }, "异常");
                        } else {
                            return null;
                        }
                    }
                },
                {
                    title: "+",
                    field: "addmx",
                    width: 80,
                    sloteditable: true,
                    slot(h, scope) {
                        if (scope.row.if_mtrl > 1) {
                            return h('van-button', {
                                props: {
                                    round: true,
                                    plain: true,
                                    size: "small",
                                    type: "info",
                                    icon: "plus",
                                }
                            });
                        } else {
                            return null
                        }
                    }
                },
                {
                    title: "-",
                    field: "delmx",
                    width: 80,
                    sloteditable: true,
                    slot(h, scope) {
                        if (scope.row.if_mtrl > 1) {
                            return h('van-button', {
                                props: {
                                    round: true,
                                    plain: true,
                                    size: "small",
                                    type: "danger",
                                    icon: "minus",
                                }
                            });
                        } else {
                            return null
                        }
                    }
                },
                {
                    title: "厚度cm",
                    field: "thickness",
                    type: "number",
                    editable: true,
                },
                {
                    title: "物料",
                    field: "mtrlname",
                    sloteditable: true,
                    clearable: true,
                },
                {
                    title: "数量/长度",
                    field: "qty",
                    type: "number",
                    editable: true,
                },
            ],
            columnsMx_subSpecs: [
                {
                    title: "床垫宽/CM",
                    field: "mattress_width",
                    type: "number",
                    editable: true,
                },
                {
                    title: "床垫长/CM",
                    field: "mattress_length",
                    type: "number",
                    editable: true,
                },
                {
                    title: "床垫高/CM",
                    field: "mattress_height",
                    type: "number",
                    editable: true,
                }
            ],
        }
    },
    methods: {
        refresh(cb) {
            let params = {
                arg_mattressid: this.mainObject.mattressid
            }
            $lj.postCommonLJRequest("web_mattress", params, "u_mattress", (res) => {
                if (res && res.datatable && res.datatable.length > 0) {
                    this.mainObject = res.datatable[0];

                    console.log("refresh >>>>", JSON.stringify(this.mainObject));
                }
                this.getType(res);

                cb && cb();

                this.getData_innerClothLayer();
                this.getData_topCotton();

                this.funcAfterMound()
            })


        },
        getType(data) {
            console.log("getType >>>>", Object.keys(data.tableinfo).includes("tableprop")
                && Object.keys(data.tableinfo.tableprop).includes("basicinfo")
                && data.tableinfo.tableprop.basicinfo.basicGroup, JSON.stringify(data));
            if (
                Object.keys(data.tableinfo).includes("tableprop")
                && Object.keys(data.tableinfo.tableprop).includes("basicinfo")
                && data.tableinfo.tableprop.basicinfo.basicGroup) {
                this.basicGroup = data.tableinfo.tableprop.basicinfo.basicGroup
            }

            this.columns = $lj.setExtraColumns(data.tableinfo.columns, this.columnsExtraAttr);

            console.log('getType this.columns :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this.columns));

            let _deptidItem = data.tableinfo.columns.find(item => item.field == 'deptid');
            if (_deptidItem && _deptidItem.enum) {
                this.deptEnum = _deptidItem.enum;
            }

            let _mattresstypeItem = data.tableinfo.columns.find(item => item.field == 'mattresstypeid');
            if (_mattresstypeItem && _mattresstypeItem.enum) {
                this.mattresstypeEnum = _mattresstypeItem.enum.find(o => o.value == this.mainObject.mattresstypeid);
            }

            if (!this.mainObject.deptid) {
                let item = this.columns.find(o => o.field == "deptid");
                this.$refs.baseFormRef.handleClickSelect(item)
            }
        },
        getMattressType() {

            let _dftabs = "";
            let _fabricShowList = undefined;
            let itmshow = null;

            if (_dftabs) {
                _fabricShowList = this.fabricMxTabList
                    .map(o => Object.keys(o).includes("visible") && o.visible() && o)
                    .find(o => o.name == _dftabs);
            }
            if (_fabricShowList) {
                itmshow = _fabricShowList;
            } else {
                itmshow = this.fabricMxTabList.find(o => Object.keys(o).includes("visible") && o.visible() && o);
            }

            this.$nextTick(() => {
                this.fabricMxTabs = itmshow.name
            })
        },
        w_mattress_add_itemname_choose(type) {
            let arr = [];
            if (type == 1) {
            } else if (type == 2) {
            } else if (type == 3) {
                arr.push({
                    label: "内布套",
                    value: "内布套"
                });
                arr.push({
                    label: "内布套拆装",
                    value: "内布套拆装"
                });
            } else if (type == 4) {
                arr.push({
                    label: "顶布裥棉1",
                    value: "顶布裥棉1"
                });
                arr.push({
                    label: "顶布裥棉2",
                    value: "顶布裥棉2"
                });
                arr.push({
                    label: "顶布裥棉3",
                    value: "顶布裥棉3"
                });
                arr.push({
                    label: "顶布裥棉4",
                    value: "顶布裥棉4"
                });
            }
            return arr;
        },
        funcAfterMound() {
            this.topCottonAddList = this.w_mattress_add_itemname_choose(4);


            this.getMattressType();
            this.getData_mx(() => {
                this.funcChaifenTab();

                this.getData_subSpecs();

                this.mainObject.mattressid > 0 && this.gotoSummy();
            })
        },
        getData_mx(cb) {
            let params = {
                arg_mattressid: this.mainObject.mattressid
            }
            $lj.postCommonLJRequest("web_mattress_mx", params, "u_mattress_mx_mtrl", (res) => {
                if (res && res.datatable) {
                    this.oriMxData = {
                        list: res.datatable,
                        tableinfo: res.tableinfo,
                    };

                    cb && cb()
                }
            })

        },
        /**
         * @description 拆分tab
         */
        funcChaifenTab() {
            // 面料
            this.fabricMxData = this.oriMxData.list.filter(
                t => t.formulatype == 0 || (Number(this.mainObject.if_bcp_type) == 1 && t.formulatype == 104)
            );

            console.log("funcChaifenTab fabricMxData :>> ", this.fabricMxData);
            let _mx8 = this.fabricMxTabList.find(t => t.name == "tabpage_8");
            this.fabricMxTab8 = this.fabricMxData.filter(t => _mx8.type.includes(Number(t.formulakind)));
            this.fabricMxTab8.forEach((o, i) => {
                o.xu = i + 1;
            });
            console.log("funcChaifenTab fabricMxTab8 :>> ", this.fabricMxTab8);

            let _mx9 = this.fabricMxTabList.find(t => t.name == "tabpage_9");
            this.fabricMxTab9 = this.fabricMxData.filter(t => _mx9.type.includes(Number(t.formulakind)));
            this.fabricMxTab9.forEach((o, i) => {
                o.xu = i + 1;
            });

            let _mx10 = this.fabricMxTabList.find(t => t.name == "tabpage_10");
            this.fabricMxTab10 = this.fabricMxData.filter(t => _mx10.type.includes(Number(t.formulakind)));
            this.fabricMxTab10.forEach((o, i) => {
                o.xu = i + 1;
            });

            let _mx11 = this.fabricMxTabList.find(t => t.name == "tabpage_11");
            this.fabricMxTab11 = this.fabricMxData.filter(t => _mx11.type.includes(Number(t.formulakind)));
            this.fabricMxTab11.forEach((o, i) => {
                o.xu = i + 1;
            });

            console.log("funcChaifenTab this.fabricMxTab11 :>> ", this.fabricMxTab11);

            let _mx12 = this.fabricMxTabList.find(t => t.name == "tabpage_12");
            this.fabricMxTab12 = this.fabricMxData.filter(t => _mx12.type.includes(Number(t.formulakind)));
            this.fabricMxTab12.forEach((o, i) => {
                o.xu = i + 1;
            });

            let _mx13 = this.fabricMxTabList.find(t => t.name == "tabpage_13");
            this.fabricMxTab13 = this.fabricMxData.filter(t => !_mx13.type.includes(Number(t.formulakind)));
            this.fabricMxTab13.forEach((o, i) => {
                o.xu = i + 1;
            });

            // 垫层
            this.cushionsMxData = this.oriMxData.list.filter(t => t.formulatype == 1);
            this.cushionsMxData.forEach((o, i) => {
                o.xu = i + 1;
            });
            // 辅料
            this.accessoriesMxData = this.oriMxData.list.filter(t => t.formulatype == 2);
            this.accessoriesMxData.forEach((o, i) => {
                o.xu = i + 1;
            });
            // 包装
            this.packagMxData = this.oriMxData.list.filter(t => t.formulatype == 3);
            this.packagMxData.forEach((o, i) => {
                o.xu = i + 1;
            });
            // 床网
            this.bednetMxData = this.oriMxData.list.filter(t => t.formulatype == 99);
            this.bednetMxData.forEach((o, i) => {
                o.xu = i + 1;
            });
        },
        /**窗口高度 */
        fixbody(obj) {
            this.headerHeight = obj.marginTop;
        },
        autoRenderedTabs() {
            this.$refs.vantabsRef.resize();
        },
        // autoScrollBody() {  
        //     this.$nextTick(() => {
        //         let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
        //         // let { scrollTop, isFixed } = data;
        //         if (this.$refs.vantabsRef) {
        //             // let offsetTop = this.$refs.vantabsRef.offsetTop.toString();
        //             let offsetTop = this.headerOverHeight;
        //             console.log("offsetTop init isFixed", offsetTop, scrollTop);
        //             offsetTop = Number(offsetTop.toString().replace("px", ""));
        //             if (scrollTop > offsetTop ) {
        //                 this.headerBg = '#fff';
        //                 this.headerTextColor = '#000';
        //             } else {
        //                 let _per = Math.round(scrollTop / offsetTop * 100) / 100;
        //                 if (_per > 1) {
        //                     _per = 1;
        //                 }
        //                 this.headerBg = `rgba(255,255,255,${_per})`;
        //                 this.headerTextColor = `rgba(255,255,255,1)`;
        //             }
        //         }
        //         console.log("autoScrollTabs inset???", this.headerBg);
        //     });
        // },
        autoScrollTabs(data) {
            this.$nextTick(() => {
                let { scrollTop, isFixed } = data;
                if (this.$refs.vantabsRef) {
                    let offsetTop = this.$refs.vantabsRef.offsetTop.toString();
                    // console.log("offsetTop init isFixed", offsetTop, isFixed, scrollTop);
                    offsetTop = Number(offsetTop.replace("px", ""));

                    if (scrollTop > 0) {
                        this.headerTextColor = '#000'
                    } else {
                        this.headerTextColor = `rgba(255,255,255,1)`;
                    }

                    if (isFixed && scrollTop > 0) {
                        this.headerBg = '#fff';
                    } else {
                        let _per = Math.round(scrollTop / offsetTop * 100) / 100;
                        if (_per > 1) {
                            _per = 1;
                        }
                        this.headerBg = `rgba(255,255,255,${_per})`;
                    }
                }
                // console.log("autoScrollTabs inset???", this.headerBg);
            });
        },
        delBill() {
            $lj.postLJRequest("DeleteL1Outware", {
                token: $lj.getStorage("token"),
                scid: this.mainObject.scid,
                outwareid: this.mainObject.outwareid
            }, function (rsp) {
                if (rsp) {
                    $lj.toast("删除成功", 2000);
                    $lj.sendEvent("outware_scll_plan_refresh");
                    $lj.closeWin();
                }
            })
        },
        saveBill(saveType) {
            if (!$lj.checkPower(5227)) {
                alert("没有[发料单修改]的权限");
                return;
            }
            if (saveType === 1 && !$lj.checkPower(5228)) {
                alert("没有[发料单审核]的权限");
                return;
            }
            if (!this.mxList.length) {
                this.$toast("发料明细为空，请稍后重试");
                return;
            }
            $lj.postLJRequest("OutwareQtyEdit", {
                token: $lj.getStorage("token"),
                outware: this.mainObject,
                outwaremxList: this.mxList,
                saveType: saveType
            }, function (rsp) {
                if (rsp) {
                    $lj.toast("更新成功", 2000);
                    $lj.sendEvent("outware_scll_plan_refresh");
                    $lj.closeWin();
                }
            })
        },
        onSelectAction(item) {
            console.log('item :>> ', JSON.stringify(item));
            if (item.name == "财务审核") {
                this.gotoAudit("flag", 1);
            } else if (item.name == "财务撤审") {
                this.gotoAudit("flag", 0);
            } else if (item.name == "业务下单") {
                this.gotoAudit("xd_flag", 1);
            } else if (item.name == "取消业务下单") {
                this.gotoAudit("xd_flag", 0);
            } else if (item.name == "显示计算公式") {
                this.gotoCheckmx();
            } else if (item.name == "查看历史报价") {
                this.gotoCheckmx();
            } else if (item.name == "复制报价") {
                this.gotoCopyQuote(2);
            } else if (item.name == "删除") {
                if (!$lj.checkPower(77)) {
                    alert("你没有【报价单-删除】的使用权限");
                    return;
                }

                $lj.confirm("提示", "是否删除本单据", () => {
                    $lj.postLJRequest("DelMattress", {
                        token: $lj.getStorage("token"),
                        mattressids: [this.mainObject.mattressid],
                    }, function (rsp) {
                        if (rsp) {
                            this.$toast.success("删除成功");
                            $lj.sendEvent("mattress_quote_refresh");

                            $lj.closeWin();
                        }
                    })
                });
            }

            this.showAction = false;
        },
        gotoEdit(winType = 1) {
            if (!$lj.checkPower(72)) {
                alert("你没有【报价单-修改】的使用权限");
                return;
            }
            $lj.openWin("mattress-quote-new", {
                mainObject: this.mainObject,
                winType: winType
            });
        },
        gotoAudit(type, value) {
            let self = this;
            let title;
            let _params = {};
            if (type == "xd_flag") {
                if (value) {
                    title = "业务下单";
                    if (!$lj.checkPower(94)) {
                        alert("你没有【报价单-业务下单】的使用权限");
                        return;
                    }
                } else {
                    title = "取消业务下单";
                    if (!$lj.checkPower(95)) {
                        alert("你没有【报价单-取消业务下单】的使用权限");
                        return;
                    }
                }
            } else {
                if (value) {
                    title = "财务审核";
                    if (!$lj.checkPower(73)) {
                        alert("你没有【报价单-财务审核】的使用权限");
                        return;
                    }
                } else {
                    title = "财务撤审";
                    if (!$lj.checkPower(74)) {
                        alert("你没有【报价单-财务撤审】的使用权限");
                        return;
                    }
                }
            }
            _params[type] = value;

            $lj.postLJRequest("SaveMattressAuditing", {
                token: $lj.getStorage("token"),
                mattressids: [this.mainObject.mattressid],
                ..._params
            }, function (rsp) {
                if (rsp) {
                    $lj.toast(title + "成功", 2000);
                    // $lj.sendEvent("bednet_quote_refresh");

                    self.refresh();
                }
            })
        },
        gotoCancel() {
            $lj.confirm('提示', '是否放弃保存？', function () {
                $lj.closeWin()
            });
        },
        gotoCheckmx() {
        },
        /**
         * @description 展示计算公式
         * @param timeout
         */
        gotoSummy() {

            let _mattress = this.mainObject;
            _mattress.mattressid = Number(_mattress.mattressid);
            _mattress.xd_flag = Number(_mattress.xd_flag);
            _mattress.js1_flag = Number(_mattress.js1_flag);
            _mattress.flag = Number(_mattress.flag);

            let _mattressMx = [];
            this.fabricMxTabList.map(t => {
                if (t.ref) {
                    console.log('gotoSummy this[t.ref] :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this[t.ref]));
                    if (this[t.ref]) {
                        let fullData = this[t.ref];
                        console.log("fullData :>> ", fullData);
                        fullData = fullData.map((itm, idx) => {
                            itm.xu = idx + 1;
                            return itm;
                        });
                        _mattressMx = _mattressMx.concat(fullData);
                    }
                }
            });

            let _params = {
                token: $lj.getStorage("token"),
                mattress: _mattress,
                mattressMx: _mattressMx
            };

            $lj.postLJRequest("GetComputeMattress", _params, (res) => {
                if (res) {
                    console.log("GetComputeBednet res :>> ", JSON.stringify(res));
                    // let summaryData = [];
                    // let fieldParams = [];
                    // let cpData = {};
                    if (!res.message) {
                        // summaryData = res.formulas;
                        // fieldParams = res.replace;
                        // cpData = res.bednet;
                        this.cmpFormulas = res.formulas;
                        this.cmpFormulaReplace = res.replace;
                    } else {
                        setTimeout(() => {
                            if (res.message) {
                                // ElNotification({
                                //     title: "计算失败",
                                //     message: res.message,
                                //     type: "warning"
                                // });
                                this.$toast.fail("计算失败");
                            }
                        }, 100);
                        return false;
                    }
                    console.log("summaryData :>> ", JSON.stringify(this.cmpFormulas), JSON.stringify(this.cmpFormulaReplace));
                }
            })
        },
        /**
         * @description 合并表格结构数据
         */
        funcMergeColumn(columns, target) {
            return columns.map(t => {
                let itm = target.find(item => t.field === item.field);
                if (itm) {
                    t = $lj.defaultsDeep(itm, t);
                }
                return t;
            });
        },
        getFormulakindEnum() {
            $lj.postCommonLJRequest("_Mapper_formulakind", {}, "", (res) => {
                if (res && res.datatable && res.datatable.length > 0) {
                    this.formulaKindEnum = res.datatable;
                }
            })

            $lj.postCommonLJRequest("_Mapper_formulakind_dc", {}, "", (res) => {
                if (res && res.datatable && res.datatable.length > 0) {
                    this.formulaKindDcEnum = res.datatable;
                }
            })
        },
        initLayouColumns(params) {
            this.gridColumns_mx = $lj.getCommonColumns(this.columnsExtraAttr_mx);
            this.gridColumns_bednet = $lj.getCommonColumns(this.funcMergeColumn(this.columnsExtraAttr_mx, this.bednetCoumns));
            this.gridColumns_cushions = $lj.getCommonColumns(this.funcMergeColumn(this.columnsExtraAttr_mx, this.cushionsColumns));
            this.gridColumns_accessories = $lj.getCommonColumns(this.funcMergeColumn(this.columnsExtraAttr_mx, this.accessoriesColumns));
            this.gridColumns_packag = $lj.getCommonColumns(this.funcMergeColumn(this.columnsExtraAttr_mx, this.packagColumns));

            if (this.mainObject.mattressid <= 0) {


                if (params.deptid) {
                    this.mainObject.deptid = params.deptid;
                }

                this.mainObject.packtype = "0";
                this.mainObject.packqty = 1;
                this.mainObject.dannum_rate = 1;
                this.mainObject.if_moneyrate = "0";
                this.mainObject.moneyrate = "1";
                this.mainObject.taxrate = 1;
                this.mainObject.taxes = 1;

                this.mainObject.woodpallettype = "0";
                this.mainObject.total_hr_cost = "0";
                this.mainObject.total_material_cost = "0";
                this.mainObject.total_hr_cost = 0;
                this.mainObject.total_material_cost = 0;
                this.mainObject.total_fees_cost = 0;
                this.mainObject.total_cost = 0;
                this.mainObject.commissionrate = 0;
                this.mainObject.fob = 0;
                this.mainObject.profitrate = 0;
                this.mainObject.nottax_factory_cost = 0;
                this.mainObject.nottax_dept_cost = 0;
                this.mainObject.dept_cost = 0;
                this.mainObject.foreign_cost = 0;
                this.mainObject.diameter = 0;
                this.mainObject.area = "";
                this.mainObject.cabinet_type = "";
                this.mainObject.hrcost = 0;
                this.mainObject.biandaicost = 0;
                this.mainObject.flag = 0;
                this.mainObject.dept_profitrate_rangli = 0;
                this.mainObject.profitrate_point = 0;
                this.mainObject.chaizhuang_point = 0;
                this.mainObject.haimian_point = 0;
                this.mainObject.qr_auditingdate = "";
                this.mainObject.zhizao_amt = 0;
                this.mainObject.foreign_cost_bz = 0;
                this.mainObject.cubage = 0;
                this.mainObject.discount = 1;
                this.mainObject.butao_point = 1;
                this.mainObject.guanli_rate = 1;
                this.mainObject.if_bcp_type = 0;
                this.mainObject.if_d_chai = 0;
                this.mainObject.if_m_chai = 0;
                this.mainObject.if_m_wbutao_way = 0;
                this.mainObject.if_n_butao = 0;
                this.mainObject.if_w_butao = 0;
                this.mainObject.if_z_chai = 0;
                this.mainObject.if_zhedie_type = 0;
            }

        },
        /**
         * @description 获取内布套数据
         */
        getData_innerClothLayer() {

            this.innerClothLayerMxData = [];
            let params = {
                arg_mattressid: this.mainObject.mattressid,
                arg_formulatype: [101, 102]
            }
            $lj.postCommonLJRequest("web_mattress_mx_neibutao", params, "u_mattress_mx_mtrl__neibutao", (res) => {
                if (res) {
                    this.innerClothLayerMxData = res.datatable;
                    let columns = $lj.setExtraColumns(res.tableinfo.columns, this.columnsMxInnerClothLayer);
                    this.gridColumns_inner = $lj.getCommonColumns(columns);
                }
            })
        },
        /**
         * @description 获取顶布裥棉数据
         */
        getData_topCotton() {

            this.topCottonMxData = [];
            let params = {
                arg_mattressid: this.mainObject.mattressid,
                arg_formulatype: [103]
            }
            $lj.postCommonLJRequest("web_mattress_mx", params, "u_mattress_mx_mtrl", (res) => {
                if (res) {
                    this.topCottonMxData = res.datatable;
                }
            })
        },
        /**
         * @description 获取主副规格数据
         */
        getData_subSpecs() {

            this.subSpecsMxData = [];
            let params = {
                arg_mattressid: this.mainObject.mattressid,
            }
            $lj.postCommonLJRequest("web_mattress_subspecs", params, "u_mattress_subspecs", (res) => {
                if (res ) {
                    this.subSpecsMxData = res.datatable;
                    let columns = $lj.setExtraColumns(res.tableinfo.columns, this.columnsMx_subSpecs);
                    this.gridColumns_subspecs = $lj.getCommonColumns(columns);

                    this.gridColumns_subspecs.unshift({
                        property: "checked",
                        label: "选",
                        type: "selection",
                        editable: true,
                        width: 70,
                        fixed: true
                    })
                }
            })
        },
        /**
         * @description 获取部门利润率
         */
        async wf_factory_profitrate() {

            let depItem = this.deptEnum.find((item) => item.value == this.mainObject.deptid);
            console.log("depItem :>> ", depItem);
            if (depItem) {
                this.mainObject.dept_profitrate = parseFloat(depItem.profitrate);
            }

            let params = {
                arg_deptid: this.mainObject.deptid,
                arg_bednettypeid_mattresstypeid: this.mainObject.mattresstypeid,
                kind: 0
            }
            $lj.postCommonLJRequest("web_factory_profitratelist", params, "", (res) => {
                if (res && res.datatable && res.datatable.length > 0) {
                    this.mainObject.profitrate = parseFloat(res.datatable[0].profitrate);
                }
            })
        },
        /**
         * @description 计算价格
         */
        async wf_cmp_cb() {
            const _mainData = this.mainObject;

            //wf_paixu 未有

            await this.wf_factory_profitrate();

            // 佣金
            if (_mainData.commission == 0 || !_mainData.commission) {
                _mainData.commission = 1;
            }
            if (_mainData.taxrate == 0 || !_mainData.taxrate) {
                _mainData.taxrate = 1;
            }
            if (_mainData.other_rate == 0 || !_mainData.other_rate) {
                _mainData.other_rate = 1;
            }
            if (_mainData.moneyrate == 0 || !_mainData.moneyrate) {
                _mainData.moneyrate = 1;
            }

            if (_mainData.commission < 1) {
                throw new Error("佣金点数不能小于1");
            }
            if (_mainData.taxrate < 1) {
                throw new Error("税率不能小于1");
            }
            if (_mainData.other_rate < 1) {
                throw new Error("额外点数不能小于1");
            }
            if (_mainData.dept_profitrate == 0) {
                throw new Error("部门利润率不能为0！");
            }
            return true;
        },
        async gotoSave() {
            // let self = this
            // try {

            // } catch (e) {
            //     self.$toast.fail(e.message);
            // }

            // console.log("save LjDetailRef.value._mainData :>> ", LjDetailRef.value._mainData);
            // console.log("save------------ :>> ", loadingStatus.save);
            // console.log("save cushionsMxData :>> ", cushionsMxData.value);

            try {

                if (!(await this.wf_cmp_cb())) return;

                let mattress = this.mainObject
                mattress.mattressid = Number(mattress.mattressid);
                mattress.xd_flag = Number(mattress.xd_flag);
                console.log("bbbbbbbbbbbbbbbbbbbb mattress :>> ", mattress);
                // mattress.if_moneyrate = Number(mattress.if_moneyrate ?? 0);
                // mattress.if_bcp_type = Number(mattress.if_bcp_type ?? 0);
                // mattress.if_d_chai = Number(mattress.if_d_chai ?? 0);
                // mattress.if_m_chai = Number(mattress.if_m_chai ?? 0);
                // mattress.if_m_wbutao_way = Number(mattress.if_m_wbutao_way ?? 0);
                // mattress.if_n_butao = Number(mattress.if_n_butao ?? 0);
                // mattress.if_w_butao = Number(mattress.if_w_butao ?? 0);
                // mattress.if_z_chai = Number(mattress.if_z_chai ?? 0);
                // mattress.if_zhedie_type = Number(mattress.if_zhedie_type ?? 0);

                let mattressMx = [];
                this.fabricMxTabList.map(t => {
                    if (t.ref) {
                        let visibleData = this[t.ref];
                        visibleData = visibleData.map((itm, idx) => {
                            itm.xu = idx + 1;
                            return itm;
                        });
                        mattressMx = mattressMx.concat(visibleData);
                    }
                });

                let subspecs = this.subSpecsMxData;

                let _param_mf = {
                    token: $lj.getStorage("token"),
                    mattress,
                    mattressMx,
                    subspecs
                };
                try {
                    console.log("综合 _param_mf :>> ", _param_mf);

                    $lj.postLJRequest("SaveMattress", _param_mf, (res) => {
                        this.$toast.success('保存成功');
                        if (this.winType == 1) {
                            if (res.mattressid) {
                                $lj.sendEvent("mattress_quote_mx_refresh");
                            }
                        } else {
                            // 新建或复制，打开明细页面
                            $lj.openWin("bedbet-quote-mx", {
                                mainObject: res.bednet,
                            });
                        }
                        $lj.closeWin();
                        
                        setTimeout(() => {
                            if (res.message || res.mxmessage.length) {
                                let _msg = res.message;
                                let defaultNum = res.message ? 1 : 0;
                                _msg && (_msg = "1." + _msg + "<br/>");

                                if (res.mxmessage.length) {
                                    res.mxmessage.map((itm, idx) => {
                                        _msg += `${idx + 1 + defaultNum}. ${itm}<br/>`;
                                    });
                                }
                                let _num = res.message ? 1 + res.mxmessage.length : res.mxmessage.length;
                                
                                // ElNotification({
                                //     title: `计算失败(${_num})`,
                                //     message: `<div style="word-wrap:break-word;word-break:break-all;">${_msg}</div>`,
                                //     dangerouslyUseHTMLString: true,
                                //     type: "warning"
                                // });
                                alert(_msg);
                                this.$toast.fail("计算失败");
                            }
                        }, 100);
                    });
                } catch (error) {
                    ElMessage.error(t("sys.api.operationFailed"));
                }
            } catch (e) {
                loadingStatus.save = false;
                console.log("buttonNew eee :>> ", e, loadingStatus.save);
            }
        },
        getPriceid() {
            let _pricelistid = 0;
            console.log("deptEnum :>> ", this.deptEnum);
            if (this.deptEnum) {
                let depItem = this.deptEnum.find((item) => item.value == this.mainObject.deptid);
                console.log("depItem :>> ", depItem);
                if (depItem) {
                    _pricelistid = Number(depItem.pricelistid);
                }
            }
            return _pricelistid;
        },
        /**
         * @description 重新获取明细数据
         * @author w_mattress_add wf_import_dw_2
         */
        wf_import_dw_2() {
            // let _biandaiqty = 0;
            let newMxData = [];
            /**
             * @description 床垫类别参数
             */
            let mattressTypeData = {};
            // const { _mainData, enumMap } = state.LjDetailRef;

            let _pricelistid = this.getPriceid();

            let _params = {
                token: $lj.getStorage("token"),
                mattressid: Number(this.mainObject.mattressid),
                mattresstypeid: this.mainObject.mattresstypeid,
                ifbcptype: this.mainObject.if_bcp_type,
                packtype: this.mainObject.packtype,
                pricelistid: _pricelistid
            };
            $lj.postLJRequest("GetMattressImportDW2", _params, (res) => {
                if (res) {
                    this.oriMxData.list = res.mattressMx;
                    this.mainObject.biandai_qty = res.biandai_qty;
                    this.diancengAreaEnum = res.diancengarea;

                    this.getMattressType();

                    this.funcChaifenTab();
                }
            })

        },
        /**
         * @description 变更床垫分类时，重载明细数据 dw_1 itemchange
         * @author w_mattress_add dw_1 itemchange
         */
        funcImportMattressMx() {

            if (!Number(this.mainObject.deptid)) {
                this.$toast.fail("请先选择部门");
                // console.log("baseformRef.element :>> ", baseformRef.element);
                // baseformRef.element.validateField("deptid");
                this.mainObject.mattresstypeid = "";
                return;
            }

            let _pricelistid = this.getPriceid();

            if (!_pricelistid) {
                this.$toast.fail("选择部门未设置价格表,请检查");
                return;
            }

            if (!this.mainObject.mattresstypeid) {
                this.$toast.fail("请先选择床垫类别");
                return;
            }

            let _mattresstypeItem = this.columns.find(item => item.field == 'mattresstypeid');
            if (_mattresstypeItem && _mattresstypeItem.enum) {
                this.mattresstypeEnum = _mattresstypeItem.enum.find(o => o.value == this.mainObject.mattresstypeid);
            }

            this.wf_import_dw_2();
        },
        /**
         * 基础信息模块：输入框/select/switch等组件值改变事件
         * @param param {column, row}
         */
        handleFormGroupChange({ column, row }) {
            if (!column) {
                return;
            }
            if (column.field == "mattresstypeid") {
                this.funcImportMattressMx()
            } else if (column.field == "moneyrate") {
                this.funcMoneyrateChange()
            } else if (column.field == "if_n_butao") {
                this.funcMoneyrateChange()
            } else if (column.field == "deptid") {
                setTimeout(() => {
                    if (!this.mainObject.mattresstypeid) {
                        let item = this.columns.find(o => o.field == "mattresstypeid");
                        this.$refs.baseFormRef.handleClickSelect(item)
                    }
                }, 200);
            }
        },
        /**
         * @description 明细，新增
         */
        funcAddMtrlMx(data, cb, refName, firstRow) {
            // let callback = (typeof arguments[5] === "undefined" || arguments[1] == null) ? true : arguments[1];
            // console.log("state.LjDetail. :>> ", state.LjDetailRef);
            // console.log("funcAddMtrlMx data :>> ", data);
            let { row, index } = data;

            let tgRefName = "";
            if (refName) {
                tgRefName = refName;
            } else {
                let _target = this.tabsActive == "fabricMx" ? this.fabricMxTabs : this.tabsActive;
                let currentTab = this.fabricMxTabList.find(t => t.name == _target);
                tgRefName = currentTab.ref;
            }

            const records = {
                addmx: "+",
                delmx: "-",
                if_success: 0,
                formulatype: row.formulatype,
                if_mtrl: row.if_mtrl,
                formulaid: row.formulaid,
                sortcode: row.sortcode,
                formulakind: row.formulakind,
                formula: row.formula,
                thickness: 0,
                mtrlid: 0,
                mtrlname: "",
                chastr: row.chastr,
                xu: Number(row.xu) + 0.01
            };

            // 数组中在指定索引后一位，插入数据
            this[tgRefName].splice(index + 1, 0, records);

            // // null 从第一行插入, row: 从当前行下一行插入
            // let _rowIdx = firstRow ? null : row;

            // const { row: newRow } = await $table.insertNextAt(records, _rowIdx);
            // await $table.setEditCell(newRow, "mtrlname");
            // await $table.setCurrentRow(newRow);

            cb && cb();
        },
        /**
         * @description 明细，删除
         */
        funcDelMtrlMx(data, refName) {
            let { row, index } = data;

            let tgRefName = "";
            if (refName) {
                tgRefName = refName;
            } else {
                let _target = this.tabsActive == "fabricMx" ? this.fabricMxTabs : this.tabsActive;

                let currentTab = this.fabricMxTabList.find(t => t.name == _target);
                tgRefName = currentTab.ref;
            }
            // 删除数组中对应索引的元素
            this[tgRefName].splice(index, 1);
        },
        funcMoneyrateChange(val, data) {
            let params = {
                deptid: data.deptid
            }
            $lj.postCommonLJRequest("_Mapper_deptid", params, "", (res) => {
                let _discount = 1;
                let _moneyrate = 1;
                if (res.datatable && res.datatable.length > 0) {
                    _discount = res.datatable[0].discount;
                    _moneyrate = res.datatable[0].moneyrate;
                }
                data.moneyrate = _moneyrate;
                data.discount = _discount;
            })
        },
        /**
         * @description 更新垫层的床网厚度信息
         * @param data 床网订单信息
         */
        wf_rtr_cwdc(data, item, action) { // TODO
            console.log("wf_rtr_cwdc data :>> ", data);
            // const $table = state.cushionsMxRef.element;
            // let { fullData } = $table.getTableData();
            let fullData = this.cushionsMxData;

            // const $tableBednet = state.bednetMxRef.element;
            // let currentBednetIndex = $tableBednet.getRowSeq(data);

            // if (action == "add") {
            //     let records = cloneDeep(fullData.find(o => o.formulakind == 999));
            //     records.thickness = 0;
            //     records.qty = 0;
            //     records._X_ROW_KEY = "";

            //     let bednetList = fullData.filter(o => Number(o.formulakind) == 999);
            //     let lastIndex = $table.getRowSeq(bednetList[bednetList.length - 1]);
            //     console.log("wf_rtr_cwdc lastIndex :>> ", bednetList, lastIndex, records);
            //     $table.insertAt(records, lastIndex);
            // } else {
            //     console.log("wf_rtr_cwdc currentBednetIndex :>> ", action, currentBednetIndex);
            //     let index = 1;
            //     fullData.map(o => {
            //         if (Number(o.formulakind) == 999) {
            //             if (index == currentBednetIndex) {
            //                 if (action == "set") {
            //                     $table.setRow(o, {
            //                         thickness: item.bednet_height,
            //                         qty: 1
            //                     });
            //                 } else if (action == "clear") {
            //                     $table.setRow(o, {
            //                         thickness: 0,
            //                         qty: 0
            //                     });
            //                 } else if (action == "del") {
            //                     // $table.setRow(o, {
            //                     //   thickness: 0,
            //                     //   qty: 0
            //                     // });
            //                     $table.remove(o);
            //                 }
            //             }
            //             index++;
            //         }
            //     });
            // }
        },
        /**
         * @description 数据赋值：物料信息
         * @param data 当前数据
         * @param item 当前选择的数据
         */
        rModelSetMtrl(data, item) {
            console.log("rModelSetMtrl data :>> ", data);
            console.log("rModelSetMtrl item :>> ", item);
            this.$set(data, "mattressid", this.mainObject.mattressid);
            this.$set(data, "mattressmxid", 0);
            this.$set(data, "mtrlid", item.mtrlid);
            this.$set(data, "price", item.pricelistprice);
            this.$set(data, "gram_weight", item.gram_weight);
            this.$set(data, "cloth_width", item.cloth_width);
            this.$set(data, "if_inputqty", Number(item.if_inputqty));
            this.$set(data, "if_areaprice", item.if_areaprice);
            this.$set(data, "mtrlname", item.mtrlname);
            this.$set(data, "priceunit", item.priceunit);
            this.$set(data, "shrinkage", item.price); // 收缩率
            this.$set(data, "thickness", Number(item.thickness));
            this.$set(data, "price_formula", item.price_formula);
            this.$set(data, "qty", 1);
        },
        /**
         * @description 清空物料信息
         * @param data 
         */
        rModelClearMtrl(data) {
            console.log("rModelClearMtrl data :>> ", data);
            data.mattressid = this.mainObject.mattressid;
            data.mattressmxid = 0;
            data.mtrlid = 0;
            data.price = 0;
            data.gram_weight = 0;
            data.cloth_width = 0;
            data.if_inputqty = 0;
            data.if_areaprice = 0;
            data.mtrlname = "";
            data.priceunit = "";
            data.shrinkage = 0;
            data.thickness = 0;
            data.price_formula = "";
            data.qty = "";

        },
        handleGridSelectClick(col, row, cb) {
            this.actionColumn = col;

            let result = '';
            if (row) {
                let idx = col.enum.findIndex(item => item.value == row[col.field]);

                console.log(' result :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(idx));
                this.actionColumn.defaultIndex = idx;
            }
            this.actionColumn.callback = cb;

            this.$nextTick(() => {
                this.showActionSheet = true;
            });
        },
        handleGridSelectConfirm(item) {
            console.log('handleGridSelectConfirm item :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(item));
            this.actionColumn.callback(item);
            this.showActionSheet = false;
        },
        /**
         * ljGrid组件：单元格清除事件捕抓
         * @param param0 
         */
        handleGridClear({ column, row, index }) {
            if (!column) {
                return;
            }
            if (column.property == "mtrlname") {
                this.rModelClearMtrl(row);
                // } else if (column.property == "fabrics1_mtrlid") {
                //     row.fabrics1_mtrlid = 0;
                //     row.fabrics1_price = 0;
                // } else if (column.property == "springname") {
                //     row.springid = 0;
                //     row.springname = "";
                // } else if (column.property == "hard_around_springname") {
                //     data.hard_around_springid = 0;
                //     data.hard_around_springname = "";
            }
        },
        /**
         * ljGrid组件：单元格点击事件捕抓
         * @param param0 
         */
        handleGridCellClick({ column, row, index }) {
            let self = this;
            console.log("handleGridCellClick==>column", JSON.stringify(column));
            console.log("handleGridCellClick==>row", JSON.stringify(row));
            console.log("handleGridCellClick==>index", index);
            if (!column) {
                return;
            }
            // if (column.editable) {
            //     return;
            // }
            if (column.property == "addmx") {
                $lj.confirm('提示', '是否确定要增加明细行吗？', () => {
                    this.funcAddMtrlMx({ row, index }, () => this.wf_rtr_cwdc(row, null, "add"))
                    $lj.toast('添加成功');
                });
            } else if (column.property == "delmx") {
                $lj.confirm('提示', '是否确定要删除当前明细行吗？', () => {
                    this.funcDelMtrlMx({ row, index });
                    $lj.toast('删除成功');
                });
            } else if (column.property == "mtrlname") {
                let _mtrltypeItem = mtrltypeTabList.find(t => t.formulakinds.includes(Number(row.formulakind)));
                !_mtrltypeItem && (_mtrltypeItem = { value: -1 });

                this.fnSelMtrldef({
                    arg_mtrltype: _mtrltypeItem.value,
                }, (item) => {
                    this.rModelSetMtrl(row, item);
                })
            }
        },
        /**
         * 床网：ljGrid组件：单元格点击事件捕抓
         * @param param
         */
        handleGridCellClick_bednet({ column, row, index }) {
            let self = this;
            console.log("handleGridCellClick==>column", JSON.stringify(column));
            console.log("handleGridCellClick==>row", JSON.stringify(row));
            console.log("handleGridCellClick==>index", index);
            if (!column) {
                return;
            }
            // if (column.editable) {
            //     return;
            // }
            if (column.property == "mtrlname") {
                $lj.removeEventListener("bednet-selection");
                $lj.addEventListener("bednet-selection", (ret) => {
                    console.log('？？？？反馈回调~~~~~ ret:>>！！！！！！！！！！ ', JSON.stringify(ret.value));
                    if (ret.value) {
                        let item = ret.value;
                        let _mtrlname =
                            item.typename +
                            " " +
                            item.bednetcode +
                            " " +
                            item.mattress_width +
                            "*" +
                            item.mattress_length +
                            "*" +
                            item.mattress_height;
                        row.mtrlid = item.bednetid;
                        row.mtrlname = _mtrlname;
                        row.price = item.nottax_factory_cost;
                        row.qty = 1;

                        // wf_rtr_cwdc(data, item, "set");
                    }
                });

                let _pricelistid = this.getPriceid();
                // 仓位单选
                $lj.openWin("bednet-quote", {
                    winMode: "single-select",
                    queryParams: {
                        deptid: this.mainObject.deptid,
                        mattress_width: this.mainObject.mattress_width,
                        mattress_length: this.mainObject.mattress_length
                    }
                });
            } else if (column.property == "addmx") {
                $lj.confirm('提示', '是否确定要增加明细行吗？', () => {
                    this.funcAddMtrlMx({ row, index }, () => this.wf_rtr_cwdc(row, null, "add"))
                    $lj.toast('添加成功');
                });
            } else if (column.property == "delmx") {
                $lj.confirm('提示', '是否确定要删除当前明细行吗？', () => {
                    this.funcDelMtrlMx({ row, index });
                    $lj.toast('删除成功');
                });
            }

        },
        /**
         * 床网：ljGrid组件：单元格清除事件捕抓
         * @param param
         */
        handleGridClear_bednet({ column, row, index }) {
            let self = this;
            if (!column) {
                return;
            }
            // if (column.editable) {
            //     return;
            // }
            if (column.property == "mtrlname") {
                row.mtrlid = 0;
                row.mtrlname = "";
                row.price = 0;
            }
        },
        /**
         * 垫层：ljGrid组件：单元格点击事件捕抓
         * @param param
         */
        handleGridCellClick_cushions({ column, row, index }) {
            let self = this;
            console.log("handleGridCellClick==>column", JSON.stringify(column));
            console.log("handleGridCellClick==>row", JSON.stringify(row));
            console.log("handleGridCellClick==>index", index);
            if (!column) {
                return;
            }
            if (column.property == "mtrlname") {
                let _mtrltypeItem = mtrltypeTabList_cushions.find(t => t.formulakinds.includes(Number(row.formulakind)));

                this.fnSelMtrldef({
                    arg_mtrltype: _mtrltypeItem.value,
                }, (item) => {
                    this.rModelSetMtrl(row, item);
                    // row.mtrlname = "321"
                })
            } else if (column.property == "chastr") {
                this.handleGridSelectClick({ enum: this.diancengAreaEnum, ...column }, row, (item) => {
                    row.chastr = item.value;
                })
            } else if (column.property == "formulakind") {
                this.handleGridSelectClick({ enum: this.formulaKindDcEnum, ...column }, row, (item) => {
                    row.formulakind = item.value;
                })
            }

        },
        /**
         * 垫层：ljGrid组件：单元格清除事件捕抓
         * @param param
         */
        handleGridClear_cushions({ column, row, index }) {
            let self = this;
            if (!column) {
                return;
            }
            if (column.property == "mtrlname") {
                this.rModelClearMtrl(row);
            }
        },
        /**
         * 辅料：ljGrid组件：单元格点击事件捕抓
         * @param param
         */
        handleGridCellClick_accessories({ column, row, index }) {
            let self = this;
            console.log("handleGridCellClick==>column", JSON.stringify(column));
            console.log("handleGridCellClick==>row", JSON.stringify(row));
            console.log("handleGridCellClick==>index", index);
            if (!column) {
                return;
            }
            if (column.property == "mtrlname") {
                let _mtrltypeItem = mtrltypeTabList_accessories.find(t => t.formulakinds.includes(Number(row.formulakind)));
                if (!_mtrltypeItem) {
                    this.$toast.fail("不是辅料类型行,不能选物料");
                    return "";
                }

                this.fnSelMtrldef({
                    arg_mtrltype: _mtrltypeItem.value,
                }, (item) => {
                    this.rModelSetMtrl(row, item);
                })
            } else if (column.property == "addmx") {
                $lj.confirm('提示', '是否确定要增加明细行吗？', () => {
                    this.funcAddMtrlMx({ row, index }, () => this.wf_rtr_cwdc(row, null, "add"))
                    $lj.toast('添加成功');
                });
            } else if (column.property == "delmx") {
                $lj.confirm('提示', '是否确定要删除当前明细行吗？', () => {
                    this.funcDelMtrlMx({ row, index });
                    $lj.toast('删除成功');
                });
            }

        },
        /**
         * 包装：ljGrid组件：单元格点击事件捕抓
         * @param param
         */
        handleGridCellClick_packag({ column, row, index }) {
            let self = this;
            console.log("handleGridCellClick==>column", JSON.stringify(column));
            console.log("handleGridCellClick==>row", JSON.stringify(row));
            console.log("handleGridCellClick==>index", index);
            if (!column) {
                return;
            }
            if (column.property == "mtrlname") {
                let _mtrltypeItem = mtrltypeTabList_packag.find(t => t.formulakinds.includes(Number(row.formulakind)));
                !_mtrltypeItem && (_mtrltypeItem = { value: -1 });

                this.fnSelMtrldef({
                    arg_mtrltype: _mtrltypeItem.value,
                }, (item) => {
                    this.rModelSetMtrl(row, item);
                })
            } else if (column.property == "addmx") {
                $lj.confirm('提示', '是否确定要增加明细行吗？', () => {
                    this.funcAddMtrlMx({ row, index }, () => this.wf_rtr_cwdc(row, null, "add"))
                    $lj.toast('添加成功');
                });
            } else if (column.property == "delmx") {
                $lj.confirm('提示', '是否确定要删除当前明细行吗？', () => {
                    this.funcDelMtrlMx({ row, index });
                    $lj.toast('删除成功');
                });
            }

        },
        /**
         * 内布套：ljGrid组件：单元格点击事件捕抓
         * @param param
         */
        handleGridCellClick_inner({ column, row, index }) {
            let self = this;
            console.log("handleGridCellClick==>column", JSON.stringify(column));
            console.log("handleGridCellClick==>row", JSON.stringify(row));
            console.log("handleGridCellClick==>index", index);
            if (!column) {
                return;
            }
            if (column.property == "mtrlname") {
                let _mtrltypeItem = mtrltypeTabList_inner.find(t => t.formulakinds.includes(Number(row.formulakind)));
                !_mtrltypeItem && (_mtrltypeItem = { value: -1 });

                this.fnSelMtrldef({
                    arg_mtrltype: _mtrltypeItem.value,
                }, (item) => {
                    row.mattressid = this.mainObject.mattressid;
                    row.mattressmxid = 0;
                    row.mtrlid = item.mtrlid;
                    row.price = item.pricelistprice;
                    row.gram_weight = item.gram_weight;
                    row.cloth_width = item.cloth_width;
                    row.if_inputqty = Number(item.if_inputqty);
                    row.if_areaprice = item.if_areaprice;
                    row.mtrlname = item.mtrlname;
                    row.priceunit = item.priceunit;
                    row.shrinkage = item.price; // 收缩率
                    Number(item.thickness) > 0 && (row.thickness = item.thickness);
                    item.price_formula != "" && (row.price_formula = item.price_formula);
                    row.qty = 1;

                    if (Number(row.formulakind) == 5) {
                        row.qty = 4;
                    } else if ([7, 8, 9, 10, 202, 203].includes(Number(row.formulakind))) {
                        if (this.mainObject) {
                            row.qty = (this.mainObject.mattress_width * this.mainObject.mattress_length * 2) / 100;
                        }
                    }
                })
            } else if (column.property == "addmx") {
                $lj.confirm('提示', '是否确定要增加明细行吗？', () => {
                    this.funcAddMtrlMx({ row, index }, () => this.wf_rtr_cwdc(row, null, "add"))
                    $lj.toast('添加成功');
                });
            } else if (column.property == "delmx") {
                $lj.confirm('提示', '是否确定要删除当前明细行吗？', () => {
                    this.funcDelMtrlMx({ row, index });
                    $lj.toast('删除成功');
                });
            }

        },
        /**
         * 弹窗：选择物料
         * @param params 参数
         * @param cb 回调赋值
         */
        fnSelMtrldef(params, cb) {
            $lj.removeEventListener("mtrldef-selection");
            $lj.addEventListener("mtrldef-selection", function (ret) {
                console.log('？？？？反馈回调~~~~~ ret:>>！！！！！！！！！！ ', JSON.stringify(ret.value));
                if (ret.value) {
                    cb && cb(ret.value);
                }
            });

            let _pricelistid = this.getPriceid();
            // 仓位单选
            $lj.openWin("mtrldef-selection", {
                winMode: "single-select",
                queryParams: {
                    arg_pricelistid: _pricelistid,
                    ...params,
                }
            });
        },
        /**
         * @description 垫层tab，公式名选择，联动增删床网tab
         * @param val
         * @param lastVal
         * @param scope
         */
        //     cushionsFormulaKindChange(val, lastVal, scope) { // todo
        //         console.log("wf_rtr_cwdc  cushionsFormulaKindChange val :>> ", val, lastVal, scope);
        //         const $table = state.cushionsMxRef.element;
        //         const $table_bednet = state.bednetMxRef.element;

        //         const { visibleData } = $table.getTableData();
        //         if (Number(val) === 999 && Number(lastVal) !== 999) {
        //         // 新增
        //         if ($table_bednet) {
        //             const { visibleData: visibleData_bednet } = $table_bednet.getTableData();
        //             let curIndex = visibleData_bednet.length - 1;
        //             // 寻找垫层当前位置，对上一个床网行位置进行复制
        //             let arr = visibleData.filter((t, i) => t.formulakind == 999 && i < scope.$rowIndex);
        //             if (arr.length > 0) {
        //             curIndex = arr.length - 1;
        //             }
        //             console.log("wf_rtr_cwdc curIndex :>> ", curIndex);
        //             rModelClearMtrl(scope.row);
        //             funcAddMtrlMx({ row: visibleData_bednet[curIndex] }, null, "bednetMxRef", arr.length == 0);
        //         }
        //         } else if (Number(val) !== 999 && Number(lastVal) === 999) {
        //         // 删除
        //         if ($table_bednet) {
        //             const { visibleData: visibleData_bednet } = $table_bednet.getTableData();
        //             let curIndex = visibleData_bednet.length - 1;
        //             curIndex = visibleData
        //             .filter(t => t.formulakind == 999 || t._X_ROW_KEY === scope.row._X_ROW_KEY)
        //             .findIndex(t => t._X_ROW_KEY === scope.row._X_ROW_KEY);
        //             console.log("wf_rtr_cwdc curIndex :>> ", curIndex);
        //             if (visibleData_bednet.length == 1) {
        //             ElMessage.warning("不能全部删除，至少保留一个床网");
        //             scope.row.formulakind = 999;
        //             return false;
        //             }
        //             rModelClearMtrl(scope.row);
        //             funcDelBednet({ row: visibleData_bednet[curIndex], data: visibleData_bednet }, null, "bednetMxRef");
        //         }
        //         } else {
        //         rModelClearMtrl(scope.row);
        //         }
        //     },
        /**
         * @description 面料-裥大、小侧，增加物料
         */
        funcAddMxSide(params, data, target) {
            $lj.postCommonLJRequest("web_mattress_formulalist", params, "", (res) => {
                if (res.datatable) {
                    if (target) {
                        // const $table = targetRef.element;
                        // if ($table) {
                        res.datatable.map(itm => {
                            let records = {
                                formulatype: itm.formulatype,
                                if_mtrl: Number(itm.if_mtrl),
                                formulaid: itm.formulaid,
                                sortcode: data.label,
                                chastr: data.label,
                                formulakind: Number(itm.formulakind),
                                formula: itm.formula,
                                useformula: itm.useformula,
                                gydscrp: itm.gydscrp
                            };

                            if (records.if_mtrl > 1) {
                                records.addmx = "+";
                                records.delmx = "-";
                            }

                            this[target].push(records);
                            // $table.insertAt(records, -1);
                        });
                        // }
                    } else {
                        let arr = [];
                        res.datatable.map(itm => {
                            let records = {
                                formulatype: itm.formulatype,
                                if_mtrl: Number(itm.if_mtrl),
                                formulaid: itm.formulaid,
                                sortcode: data.label,
                                chastr: data.label,
                                formulakind: Number(itm.formulakind),
                                formula: itm.formula,
                                useformula: itm.useformula,
                                gydscrp: itm.gydscrp
                            };

                            if (records.if_mtrl > 1) {
                                records.addmx = "+";
                                records.delmx = "-";
                            }

                            arr.push(records);
                        });
                        return arr;
                    }
                } else {
                    return [];
                }
            });
        },
        /**
         * @description 主副规格tab：按钮菜单
         * @param methodName 
         */
        handleButtonMenuToolsEvents_subSpecs(methodName) {
            switch (methodName) {
                case "add":
                    let records = {
                        mattressid: 0,
                        mattresscode: "",
                        mattress_width: "",
                        mattress_length: "",
                        mattress_height: ""
                    };

                    this.subSpecsMxData.push(records);
                    break;
                case "del":
                    this.subSpecsMxData = this.subSpecsMxData.filter((item) => !item.checked)
                    break;
            }
        },
        /**
         * @description 顶布裥棉tab：按钮菜单
         * @param methodName 
         */
        handleButtonMenuToolsEvents_topCotton(methodName) {
            switch (methodName) {
                case "add":
                    this.handleGridSelectClick({ enum: this.topCottonAddList, title: "新增顶布裥棉" }, null, (item) => {
                        this.wf_add_w_butao(item)
                    })
                    break;
                case "del":
                    this.wf_del_w_butao();
                    // this.subSpecsMxData = this.subSpecsMxData.filter((item) => !item.checked)
                    break;
            }
        },
        /**
         * @description 内布套tab：按钮菜单
         * @param methodName 
         */
        handleButtonMenuToolsEvents_inner(methodName) {
            switch (methodName) {
                case "add":
                    let params = {
                        arg_array_formulatype: [101],
                        arrg_usetype: 0
                    }
                    $lj.postCommonLJRequest("web_mattress_formulalist", params, "", (res) => {
                        if (res) {
                            let idxStr = "";
                            if (this.innerClothLayerMxData.length) {
                                let lastMx = this.innerClothLayerMxData[this.innerClothLayerMxData.length - 1];
                                idxStr = Number(lastMx.chastr.match(/\d+$/)[0]) + 1 + "";
                            } else {
                                idxStr = "";
                            }

                            let _rows = res.datatable.map((item, index) => {
                                let _data = {};
                                if (Number(item.if_mtrl) > 1) {
                                    _data.addmx = "+";
                                    _data.delmx = "-";
                                }
                                _data.formulatype = item.formulatype;
                                _data.if_mtrl = item.if_mtrl;
                                _data.formulaid = item.formulaid;
                                _data.sortcode = item.sortcode;
                                _data.formulakind = item.formulakind;
                                _data.formula = item.formula;
                                _data.chastr = "内布套" + idxStr;
                                _data.useformula = item.useformula;
                                _data.gydscrp = item.gydscrp;
                                _data.pid = index + 1;

                                return _data;
                            });

                            this.innerClothLayerMxData = this.innerClothLayerMxData.concat(_rows);

                            this.$toast.success("导入成功");
                        }
                    })
                    break;
                case "del":
                    // 删除选中
                    let currentIndex = this.$refs.grid_inner.currentIndex;

                    if (currentIndex < 0) {
                        this.$toast.fail("请先选择要删除的行");
                        return;
                    }

                    this.innerClothLayerMxData.splice(currentIndex, 1);
                    break;
                case "delall":
                    this.innerClothLayerMxData = [];
                    break;
            }
        },
        /**
         * @description 垫层tab：按钮菜单
         * @param methodName 
         */
        handleButtonMenuToolsEvents_cushions(methodName) {
            switch (methodName) {
                case "add":
                    this.toAddMx_cushions(0)
                    break;
                case "insert":
                    this.toAddMx_cushions(1)
                    break;
                case "del":
                    // 垫层：删除
                    let currentIndex = this.$refs.grid_topCotton.currentIndex;

                    this.cushionsMxData.splice(currentIndex, 1);
                    break;
            }
        },
        /**
         * @description 垫层：增加明细
         */
        toAddMx_cushions(type) {
            // const { $table, curRecords } = getCurrentRecords(cushionsMxRef.value);
            // const row = curRecords[0];
            let currentIndex = this.$refs.grid_cushions.currentIndex;
            const row = this.cushionsMxData[currentIndex];
            if (type && currentIndex < 0) {
                this.$toast.fail("请先选择要删除的行");
                return;
            }

            const records = {
                chastr: row.chastr,
                formulatype: row.formulatype,
                if_mtrl: row.if_mtrl,
                formulaid: row.formulaid,
                sortcode: row.sortcode,
                formulakind: row.formulakind,
                formula: row.formula,
                thickness: 0,
                mtrlid: 0
            };

            if (type) {
                // 插入
                this.cushionsMxData.splice(currentIndex + 1, 0, records);
            } else {
                // 新增
                this.cushionsMxData.push(records);
            }

            if (row.formulakind == 999) {
                let curIndex = this.bednetMxData.length - 1;
                if (type) {
                    curIndex = this.bednetMxData.filter(t => t.formulakind == 999).findIndex(t => t._X_ROW_KEY === row._X_ROW_KEY);
                }
                funcAddMtrlMx({ row: visibleData_bednet[curIndex], index: curIndex }, null, "bednetMxData");
            }
        },
        wf_add_w_butao(val) {
            console.log("val :>> ", val);

            let fullData = this.topCottonMxData;
            let ifind = fullData.find(t => t.chastr == val.value);
            if (ifind) {
                this.$toast.fail(`该选项${val.value}已存在`);
                return;
            }

            let params = {
                arg_array_formulatype: [103],
                arrg_usetype: 0
            }
            $lj.postCommonLJRequest("web_mattress_formulalist", params, "", (res) => {
                if (res && res.datatable && res.datatable.length > 0) {
                    let _rows = res.datatable.map((item) => {
                        let _data = {};
                        if (Number(item.if_mtrl) > 1) {
                            _data.addmx = "+";
                            _data.delmx = "-";
                        }
                        _data.formulatype = item.formulatype;
                        _data.if_mtrl = item.if_mtrl;
                        _data.formulaid = item.formulaid;
                        _data.sortcode = item.sortcode;
                        _data.formulakind = item.formulakind;
                        _data.formula = item.formula;
                        _data.chastr = val.value;
                        _data.useformula = item.useformula;
                        _data.gydscrp = item.gydscrp;
                        _data.mtrlid = 0;
                        _data.mtrlname = "";

                        return _data;
                    });

                    this.topCottonMxData = this.topCottonMxData.concat(_rows);
                }
            })
        },
        /**
         * @description 删除顶布裥棉明细
         */
        wf_del_w_butao() {
            // 删除选中
            let currentIndex = this.$refs.grid_topCotton.currentIndex;

            if (currentIndex < 0) {
                this.$toast.fail("请先选择要删除的行");
                return;
            }
            let ls_chastr = this.topCottonMxData[currentIndex].chastr;

            $lj.confirm("询问", `是否确定要删除【${ls_chastr}】的明细行?`, () => {
                this.topCottonMxData = this.topCottonMxData.filter((item) => item.chastr != ls_chastr);

                this.$toast.success("删除成功");
            });
        },
        handleClickPackagCell(type) {
            switch (type) {
                case 'packtype':
                    this.handleGridSelectClick({ enum: this.packtypeOptions, title: "包装方式", field: type }, this.mainObject, (item) => {
                        this.mainObject[type] = item.value;

                        this.funcPacktypeChange(item.value);
                    })
                    break;
                case 'woodpallettype':
                    this.handleGridSelectClick({ enum: this.woodpallettypeOptions, title: "木托方式", field: type }, this.mainObject, (item) => {
                        this.mainObject[type] = item.value;
                    })
                    break;
                case 'area':
                    this.handleGridSelectClick({ enum: this.areaOptions, title: "地区", field: type }, this.mainObject, (item) => {
                        this.mainObject[type] = item.value;
                    })
                    break;
                case 'cabinet_type':
                    this.handleGridSelectClick({ enum: this.cabinetTypeOptions, title: "柜型", field: type }, this.mainObject, (item) => {
                        this.mainObject[type] = item.value;
                    })
                    break;
            }
        },
        /**
         * @description 切换包装方式select，获取默认物料
         * @param val
         */
        funcPacktypeChange(val) {
            console.log("wf_import_bz val :>> ", val);

            if (Number(val) == 0) {
                this.mainObject.diameter = 0;
            } else if (Number(val) == 1) {
                this.mainObject.packqty = 0;
            } else {
                this.mainObject.diameter = 0;
                this.mainObject.packqty = 0;
            }

            let _pricelistid = this.getPriceid();

            let _params = {
                token: $lj.getStorage("token"),
                mattresstypeid: this.mainObject.mattresstypeid,
                ifbcptype: this.mainObject.if_bcp_type,
                packtype: this.mainObject.packtype,
                pricelistid: _pricelistid
            };

            $lj.postLJRequest("GetMattressPackagMx", _params, (res) => {
                if (res) {
                    this.mainObject.biandai_qty = res.biandai_qty;
                    this.diancengAreaEnum = res.diancengarea;
                    this.packagMxData = res.mattressMx.map((item, index) => {
                        item.pid = index + 1;
                        return item;
                    });
                }
            })
        },
        handleButtonMenuToolsEvents_bednet(methodName) {
            switch (methodName) {
                case "add":
                    if (!$lj.checkPower(62)) {
                        alert("您没有床网报价建单权限，请检查");
                        return;
                    }
                    // 仓位单选
                    $lj.openWin("bednet-quote-new", {
                        winType: 3,
                        mainObject: {
                            deptid: this.mainObject.deptid,
                            bednetid: 0,
                            mattress_length: this.mainObject.mattress_length,
                            mattress_width: this.mainObject.mattress_width,
                        }
                    });

                    break;
                case "edit":
                    let currentIndex = this.$refs.grid_bednet.currentIndex;

                    if (currentIndex < 0) {
                        this.$toast.fail("请先选择要修改的床网");
                        return;
                    }

                    // 仓位单选
                    $lj.openWin("bednet-quote-new", {
                        winType: 3,
                        mainObject: {
                            deptid: this.mainObject.deptid,
                            bednetid: this.bednetMxData[currentIndex].mtrlid,
                        }
                    });
                    break;
            }

            $lj.removeEventListener("mattress_edit_bednet");
            $lj.addEventListener("mattress_edit_bednet", (ret) => {
                console.log('？？？？反馈回调~~~~~ ret:>>！！！！！！！！！！ ', JSON.stringify(ret.value));
                if (ret.value) {

                    let idx = this.bednetMxData.findIndex(t => t.mtrlid == res.value.bednet.bednetid);
                    let _mtrlname =
                        res.bednet.typename +
                        " " +
                        res.bednet.bednetcode +
                        " " +
                        res.bednet.mattress_width +
                        "*" +
                        res.bednet.mattress_length +
                        "*" +
                        res.bednet.mattress_height;
                    if (idx > -1) {
                        this.bednetMxData[idx].mtrlid = res.bednet.bednetid;
                        this.bednetMxData[idx].mtrlname = _mtrlname;
                        this.bednetMxData[idx].price = res.bednet.nottax_factory_cost;
                    } else {
                        let _data = this.bednetMxData[0];
                        let _row = {
                            addmx: "+",
                            delmx: "-",
                            formulatype: _data.formulatype,
                            if_mtrl: _data.if_mtrl,
                            formulaid: _data.formulaid,
                            sortcode: _data.sortcode,
                            formulakind: _data.formulakind,
                            formula: _data.formula,
                            thickness: 0,
                            mtrlid: res.bednet.bednetid,
                            mtrlname: _mtrlname,
                            price: res.bednet.nottax_factory_cost,
                            qty: 1
                        };

                        this.bednetMxData.push(_row);
                    }
                }
            });
        },
        handleButtonMenuToolsEvents_fabric10(methodName) {
            switch (methodName) {
                case "add":
                    this.handleGridSelectClick({ enum: this.fabricMx10NewMtrlGroup, title: "裥大恻" }, null, (item) => {

                        let hasSame = this.fabricMxTab10.findIndex(t => t.sortcode == item.label);

                        if (hasSame > -1) {
                            this.$toast.fail(item.label + "已存在");
                            return false;
                        }

                        this.fabricMxTab10 = this.fabricMxTab10.filter(t => t.sortcode != "普通大侧");

                        let _params = {
                            arg_array_formulakind: [2, 42, 52, 62, 72, 82],
                            arg_array_formulatype: [0, 1, 2, 3]
                        };
                        this.funcAddMxSide(_params, item, "fabricMxTab10");

                    })
                    break;
                case "del":
                    this.handleDelFabricMxNewMtrlGroup("tabpage_10")
                    break;
            }
        },
        handleButtonMenuToolsEvents_fabric11(methodName) {
            switch (methodName) {
                case "add":
                    this.handleGridSelectClick({ enum: this.fabricMx11NewMtrlGroup, title: "裥小恻" }, null, (item) => {

                        let hasSame = this.fabricMxTab11.findIndex(t => t.sortcode == item.label);
                        if (hasSame > -1) {
                            this.$toast.fail(item.label + "已存在");
                            return false;
                        }

                        this.fabricMxTab11 = this.fabricMxTab11.filter(t => t.sortcode != "小侧1");

                        let _params = {
                            arg_array_formulakind: [3, 83, 43, 53, 63, 73],
                            arg_array_formulatype: [0, 1, 2, 3]
                        };
                        this.funcAddMxSide(_params, item, "fabricMxTab11");

                    })
                    break;
                case "del":
                    this.handleDelFabricMxNewMtrlGroup("tabpage_11")
                    break;
            }
        },
        handleDelFabricMxNewMtrlGroup(target) {
            let sameMx = [];
            let _data = null;
            let currentIndex = -1
            if (target == "tabpage_10") {
                _data = this.fabricMxTab10;
                currentIndex = this.$refs.grid_tabpage_10.currentIndex;

            } else if (target == "tabpage_11") {
                _data = this.fabricMxTab11;
                currentIndex = this.$refs.grid_tabpage_11.currentIndex;

            }

            if (currentIndex < 0) {
                this.$toast.fail("请先选择要删除的行");
                return;
            }

            sameMx = _data.filter(t => t.sortcode == _data[currentIndex].sortcode);

            $lj.confirm(`是否确定要删除${sameMx.length}条明细吗?`, "询问：" + sameMx[0].sortcode, () => {

                if (target == "tabpage_10") {
                    this.fabricMxTab10 = this.fabricMxTab10.filter(t => t.sortcode != sameMx[0].sortcode);
                } else if (target == "tabpage_11") {
                    this.fabricMxTab11 = this.fabricMxTab11.filter(t => t.sortcode != sameMx[0].sortcode);
                }

                this.$toast.success("删除成功");
            })
        }
    },
    computed: {
        isCheckPower(id) {
            return function (id) {
                return !$lj.checkPower(id);
            }
        },
        isTabsBadge_fabric() {
            let arr = [];
            arr = this.fabricMxTab8.filter(t => t.mtrlid && Number(t.mtrlid) > 0);
            arr = arr.concat(this.fabricMxTab9.filter(t => t.mtrlid && Number(t.mtrlid) > 0));
            arr = arr.concat(this.fabricMxTab10.filter(t => t.mtrlid && Number(t.mtrlid) > 0));
            arr = arr.concat(this.fabricMxTab11.filter(t => t.mtrlid && Number(t.mtrlid) > 0));
            arr = arr.concat(this.fabricMxTab12.filter(t => t.mtrlid && Number(t.mtrlid) > 0));
            arr = arr.concat(this.fabricMxTab13.filter(t => t.mtrlid && Number(t.mtrlid) > 0));
            return arr.length > 0 ? arr.length : "";
        },
        isTabsBadge_fabric_error() {
            console.log(' this.fabricMxTab8 :>>>>>>>>>>>>>>>>>>>>>', JSON.stringify(this.fabricMxTab8));
            let arr = [];
            arr = this.fabricMxTab8.filter(t => Number(t.if_success));
            arr = arr.concat(this.fabricMxTab9.filter(t => Number(t.if_success)));
            arr = arr.concat(this.fabricMxTab10.filter(t => Number(t.if_success)));
            arr = arr.concat(this.fabricMxTab11.filter(t => Number(t.if_success)));
            arr = arr.concat(this.fabricMxTab12.filter(t => Number(t.if_success)));
            arr = arr.concat(this.fabricMxTab13.filter(t => Number(t.if_success)));
            return arr.length;
        },
        isFilterErrorBadge(data) {
            return function (data) {
                let arr = [];
                arr = data.filter(t => Number(t.if_success));
                return arr.length;
            }
        },
        isFilterSucessBadge(data) {
            return function (data) {
                let arr = [];
                arr = data.filter(t => t.mtrlid && Number(t.mtrlid) > 0);
                return arr.length > 0 ? arr.length : "";
            }
        },
        mainButtons_subSpecs() {
            let buttons = [
                { icon: "icon-ic_add", color: "primary", span: 3, label: "新增", methodName: "add", visiable: true, isIconLeft: true },
                { icon: "icon-close", color: "error", span: 3, label: "删除", methodName: "del", visiable: true, isIconLeft: true },
            ]
            return buttons;
        },
        mainButtons_inner() {
            let buttons = [
                { icon: "icon-ic_add", color: "primary", span: 3, label: "导入明细", methodName: "add", visiable: true, isIconLeft: true },
                { icon: "icon-close", color: "error", span: 3, label: "删除明细", methodName: "del", visiable: true, isIconLeft: true },
                { icon: "icon-close", color: "error", span: 3, label: "删除全部明细", methodName: "delall", visiable: true, isIconLeft: true },
            ]
            return buttons;
        },
        mainButtons_cushions() {
            let buttons = [
                { icon: "icon-ic_add", color: "primary", span: 3, label: "新增", methodName: "add", visiable: true, isIconLeft: true },
                { icon: "icon-ic_add", color: "primary", span: 3, label: "插入", methodName: "insert", visiable: true, isIconLeft: true },
                { icon: "icon-close", color: "error", span: 3, label: "删除", methodName: "del", visiable: true, isIconLeft: true },
            ]
            return buttons;
        },
        mainButtons_bednet() {
            let buttons = [
                { icon: "icon-ic_add", color: "primary", span: 3, label: "新增", methodName: "add", visiable: true, isIconLeft: true },
                { icon: "icon-ic_add", color: "info", span: 3, label: "修改", methodName: "edit", visiable: true, isIconLeft: true },
            ]
            return buttons;
        },
        mainButtons_fabric() {
            let buttons = [
                { icon: "icon-ic_add", color: "primary", span: 3, label: "新增位置", methodName: "add", visiable: true, isIconLeft: true },
                { icon: "icon-close", color: "error", span: 3, label: "删除位置", methodName: "del", visiable: true, isIconLeft: true },
            ]
            return buttons;
        },
    },
    filters: {
        enumFilter(data, arr) {
            let name = "";
            arr.forEach(itm => {
                if (Number(itm.value) == Number(data)) {
                    name = itm.label;
                } else if (itm.value == data) {
                    name = itm.label;
                }
            });
            return name
        }
    }
}
</script>
<style lang="less">
.eventmx-header {
    position: relative;
    margin: 8px 12px;
    background: #fff;
    border-radius: 8px;

    .card-header {
        // padding: 15px 20px;
        overflow: unset;

        .van-cell__title {
            font-size: 24px;
            // color: #fff;

            .card-title {
                font-weight: bold;
            }
        }

        .van-cell__value {
            display: flex;
            justify-content: flex-end;
            overflow: unset;
        }

        &.van-cell::after {
            content: none;
        }

        .jc-card-label {
            .title {
                color: @light-label-secondary;
            }
        }
    }
}

.main-body {
    .van-tabs {
        .van-sticky {
            &:not(.van-sticky--fixed) {

                .van-tabs__wrap {
                    margin: 0 12px;
                    border-radius: 8px;
                }
            }
        }
    }
}

.mattress-tabs__fabric {
    .van-sticky--fixed {
        z-index: 89;
    }

    // .van-tab__text--ellipsis {
    //     display: block;
    // }
}
</style>
