<template>
  <div class="drawer-body">



    <a-collapse v-model="groupbox1_activeKey">
      <a-collapse-panel key="1" header="基本信息">

        <vxe-form :data="formOptions.data" ref="xForm" :title-width="formOptions.titleWidth"
          :title-align="formOptions.titleAlign" :rules="formOptions.rules" :items="formOptions.items" titleColon>
        </vxe-form>
      </a-collapse-panel>
      <a-collapse-panel key="2" header="材料部分">

        <div slot="extra">
          （合计）板材数量：{{ parseFloat(formOptions.data.fittings_total_quantity || 0).toFixed(0) }}
          封边用量：{{ parseFloat(formOptions.data.fittings_total_seal || 0).toFixed(2) }}
          板材用量：{{ parseFloat(formOptions.data.fittings_total_board_length || 0).toFixed(3) }}
          油漆面积：{{ parseFloat(formOptions.data.fittings_total_paint_area || 0).toFixed(3) }}
        </div>
        <vxe-table border show-overflow keep-source ref="fittings_xTable" :data="fittings_detailsData" :keyboard-config="{
          isArrow: true, isDel: true,
          isEnter: false, isTab: true, isEdit: true, isChecked: true
        }" :mouse-config="{ selected: true }" @pulldownSelected="fittings_onPulldownSelected" show-footer
          :footer-method="fittings_footerMethod" :footer-cell-class-name="fittings_footerCellClassName"
          @popupSelected="fittings_onPopupSelected" :export-config="{}" @edit-closed="fittings_afterEditEvent"
          @edit-actived="fittings_beforeEditEvent"
          :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: fittings_beforeEditMethod }">
          <vxe-column width="60" v-if="!isReadonly">
            <template #default="{ row }">
              <div class="oplinks2">
                <a @click.stop="fittings_pageAdd(row)" title="新增">
                  <a-icon type="plus-circle" />
                </a>
                <a @click.stop="fittings_pageDelete(row)" title="删除">
                  <a-icon type="delete" />
                </a>
              </div>
            </template>
          </vxe-column>
          <vxe-column type="seq" title="序号" width="48"></vxe-column>
          <vxe-column field="fittings" title="部件" width="160" :params="editorFittings" formatter="formatRef"
            :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>
          <vxe-column field="material" title="材料（免漆）" width="160" :params="editorMaterial" formatter="formatRef"
            :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>
          <vxe-column field="paint_material" title="材料（油漆）" width="160" :params="editorMaterial" formatter="formatRef"
            :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>

          <vxe-column field="long_formula" title="长" width="160" :edit-render="{ name: 'EditExpressions' }"
            :params="{ moreExpressionsList: getMoreExpressionsList }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.long_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.long_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.long, 0)"></span>
              </a-tooltip>
            </template>
          </vxe-column>
          <vxe-column field="width_formula" title="宽" width="160" :edit-render="{ name: 'EditExpressions' }"
            :params="{ moreExpressionsList: getMoreExpressionsList }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.width_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.width_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.width, 0)"></span>
              </a-tooltip>
            </template>
          </vxe-column>
          <vxe-column field="height_formula" title="厚" width="160" :edit-render="{ name: 'EditExpressions' }"
            :params="{ moreExpressionsList: getMoreExpressionsList }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.height_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.height_formula || '' }}
                </span>

                <span v-else v-html="formatShowNumber(row.height, 0)"></span>
              </a-tooltip>
            </template>
          </vxe-column>
          <vxe-column field="quantity" title="数量" width="80"
            :edit-render="{ name: '$input', props: { type: 'number' } }"></vxe-column>

          <vxe-column field="banding" title="封边" width="160" :params="editorBanding" formatter="formatRef"
            :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>

          <vxe-column field="seal_formula" title="封边用量" width="180" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.seal_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.seal_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.seal, 2)"></span>
              </a-tooltip>
            </template>
          </vxe-column>
          <vxe-column type="seq" title="序号" width="48"></vxe-column>
          <vxe-column field="rate_materials" title="主材利用率" width="80"
            :edit-render="{ name: '$input', props: { type: 'number' } }"></vxe-column>
          <vxe-column field="paint_number" title="油漆面" width="80"
            :edit-render="{ name: '$input', props: { type: 'number' } }"></vxe-column>
          <vxe-column field="board_length_formula" title="板材用量(块)" width="220" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.board_length_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.board_length_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.board_length, 3)"></span>
              </a-tooltip>
            </template>

          </vxe-column>
          <vxe-column field="paint_area_formula" title="油漆面积(㎡)" width="220" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.paint_area_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.paint_area_formula || '' }}
                </span>
                <span v-else>
                  {{ parseFloat(row.paint_area || 0).toFixed(3) }}
                </span>
              </a-tooltip>
            </template>
          </vxe-column>
          <vxe-column field="real_quantity" title="实木用量(立方)" width="80"
            :edit-render="{ name: '$input', props: { type: 'number' } }"></vxe-column>
          <vxe-column field="remark" title="备注" width="120" :edit-render="{ name: 'textarea' }"></vxe-column>

        </vxe-table>

      </a-collapse-panel>
      <a-collapse-panel key="3" header="配件部分">

        <div slot="extra">
          （合计）金额：{{ parseFloat(formOptions.data.parts_total_amount || 0).toFixed(2) }}
        </div>
        <vxe-table border show-overflow keep-source ref="parts_xTable" :data="parts_detailsData" :keyboard-config="{
          isArrow: true, isDel: true,
          isEnter: false, isTab: true, isEdit: true, isChecked: true
        }" :mouse-config="{ selected: true }" @pulldownSelected="parts_onPulldownSelected"
          @popupSelected="parts_onPopupSelected" :export-config="{}" @edit-closed="parts_afterEditEvent"
          @edit-actived="parts_beforeEditEvent" show-footer :footer-method="parts_footerMethod"
          :footer-cell-class-name="parts_footerCellClassName"
          :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: parts_beforeEditMethod }">
          <vxe-column width="60" v-if="!isReadonly">
            <template #default="{ row }">
              <div class="oplinks2">
                <a @click.stop="parts_pageAdd(row)" title="新增">
                  <a-icon type="plus-circle" />
                </a>
                <a @click.stop="parts_pageDelete(row)" title="删除">
                  <a-icon type="delete" />
                </a>
              </div>
            </template>
          </vxe-column>
          <vxe-column type="seq" title="序号" width="48"></vxe-column>
          <vxe-column field="parts" title="配件" width="260" :params="editorParts" formatter="formatRef"
            :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>
          <vxe-column field="spec" title="规格" width="120" :edit-render="{ name: '$input' }"></vxe-column>
          <vxe-column field="quantity" title="数量" width="120"
            :edit-render="{ name: '$input', props: { type: 'integer' } }"></vxe-column>
          <vxe-column field="price" title="单价" width="120"
            :edit-render="{ name: '$input', props: { type: 'number' } }"></vxe-column>

          <vxe-column field="amount_formula" title="金额" width="220" :edit-render="{ name: 'EditExpressions' }"
          :params="{ moreExpressionsList: getMoreExpressionsList }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.amount_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.amount_formula || '' }}
                </span>

                <span v-else v-html="formatShowNumber(row.amount, 2)"></span>
              </a-tooltip>
            </template>

          </vxe-column>


        </vxe-table>

      </a-collapse-panel>

      <a-collapse-panel key="4" header="包装部分">
        <div slot="extra">
          （合计）金额：{{ parseFloat(formOptions.data.packaging_total_amount || 0).toFixed(2) }}
        </div>
        <vxe-table border show-overflow keep-source ref="packaging_xTable" :data="packaging_detailsData" :keyboard-config="{
          isArrow: true, isDel: true,
          isEnter: false, isTab: true, isEdit: true, isChecked: true
        }" :mouse-config="{ selected: true }" @pulldownSelected="packaging_onPulldownSelected"
          @popupSelected="packaging_onPopupSelected" :export-config="{}" @edit-closed="packaging_afterEditEvent"
          @edit-actived="packaging_beforeEditEvent" show-footer :footer-method="packaging_footerMethod"
          :footer-cell-class-name="packaging_footerCellClassName"
          :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: packaging_beforeEditMethod }">
          <vxe-column width="60" v-if="!isReadonly">
            <template #default="{ row }">
              <div class="oplinks2">
                <a @click.stop="packaging_pageAdd(row)" title="新增">
                  <a-icon type="plus-circle" />
                </a>
                <a @click.stop="packaging_pageDelete(row)" title="删除">
                  <a-icon type="delete" />
                </a>
              </div>
            </template>
          </vxe-column>
          <vxe-column type="seq" title="序号" width="48"></vxe-column>
          <vxe-column field="packaging" title="包装" width="260" :params="editorPackaging" formatter="formatRef"
            :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>
          <vxe-column field="long_formula" title="长" width="200" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.long_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.long_formula || '' }}
                </span>

                <span v-else v-html="formatShowNumber(row.long, 1)"></span>
              </a-tooltip>
            </template>
          </vxe-column>
          <vxe-column field="width_formula" title="宽" width="200" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.width_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.width_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.width, 1)"></span>
              </a-tooltip>
            </template>
          </vxe-column>
          <vxe-column field="height_formula" title="高" width="200" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.height_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.height_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.height, 1)"></span>
              </a-tooltip>
            </template>
          </vxe-column>

          <vxe-column field="quantity_formula" title="数量" width="200" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.quantity_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.quantity_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.quantity, 1)"></span>
              </a-tooltip>
            </template>
          </vxe-column>

          <vxe-column field="price_formula" title="单价" width="200" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.price_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.price_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.price, 2)"></span>
              </a-tooltip>
            </template>
          </vxe-column>

          <vxe-column field="amount_formula" title="金额" width="200" :edit-render="{ name: 'EditExpressions' }">
            <template #default="{ row }">
              <a-tooltip>
                <template slot="title">
                  {{ row.amount_formula || '' }}
                </template>
                <span v-if="showExp">
                  {{ row.amount_formula || '' }}
                </span>
                <span v-else v-html="formatShowNumber(row.amount, 2)"></span>
              </a-tooltip>
            </template>
          </vxe-column>

        </vxe-table>

      </a-collapse-panel>

    </a-collapse>



    <div class="groupbox" v-if="showType == '1' || showType == '2'">
      <h3>费用（免漆）</h3>
      <a-collapse v-model="groupbox2_activeKey">
        <a-collapse-panel key="1" header="材料">

          <div slot="extra">
            （合计）金额：{{ parseFloat(formOptions.data.material_total_amount || 0).toFixed(2) }}
          </div>

          <vxe-table border show-overflow keep-source ref="material_xTable" :data="material_detailsData" :keyboard-config="{
            isArrow: true, isDel: true,
            isEnter: false, isTab: true, isEdit: true, isChecked: true
          }" :mouse-config="{ selected: true }" @pulldownSelected="material_onPulldownSelected"
            @popupSelected="material_onPopupSelected" :export-config="{}" @edit-closed="material_afterEditEvent"
            :footer-cell-class-name="material_footerCellClassName"
            :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: material_beforeEditMethod }">
            <vxe-column width="60" v-if="!isReadonly">
              <template #default="{ row }">
                <div class="oplinks2">
                  <a @click.stop="material_pageAdd(row)" title="新增">
                    <a-icon type="plus-circle" />
                  </a>
                  <a @click.stop="material_pageDelete(row)" title="删除">
                    <a-icon type="delete" />
                  </a>
                </div>
              </template>
            </vxe-column>
            <vxe-column type="seq" title="序号" width="48"></vxe-column>
            <vxe-column field="material" title="材料" width="260" :params="editorMaterial2" formatter="formatRef"
              :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>

            <vxe-column field="quantity_formula" title="总用量" width="200" :params="{ hasTotalQuantity: true }"
              :edit-render="{ name: 'EditExpressions' }">
              <template #default="{ row }">
                <a-tooltip>
                  <template slot="title">
                    {{ row.quantity_formula || '' }}
                  </template>
                  <span v-if="showExp">
                    {{ row.quantity_formula || '' }}
                  </span>
                  <span v-else v-html="formatShowNumber(row.quantity, 3)"></span>
                </a-tooltip>
              </template>

            </vxe-column>

            <vxe-column field="price" title="单价" width="120"
              :edit-render="{ name: '$input', props: { type: 'number' } }"></vxe-column>
            <vxe-column field="amount_formula" title="金额" width="200" :edit-render="{ name: 'EditExpressions' }">
              <template #default="{ row }">
                <a-tooltip>
                  <template slot="title">
                    {{ row.amount_formula || '' }}
                  </template>
                  <span v-if="showExp">
                    {{ row.amount_formula || '' }}
                  </span>
                  <span v-else v-html="formatShowNumber(row.amount, 2)"></span>
                </a-tooltip>
              </template>
            </vxe-column>

          </vxe-table>


        </a-collapse-panel>
        <a-collapse-panel key="2" header="人工" :disabled="false">

          <div slot="extra">
            （合计）金额：{{ parseFloat(formOptions.data.labor_total_amount || 0).toFixed(2) }}
          </div>
          <vxe-table border show-overflow keep-source ref="labor_xTable" :data="labor_detailsData" :keyboard-config="{
            isArrow: true, isDel: true,
            isEnter: false, isTab: true, isEdit: true, isChecked: true
          }" :mouse-config="{ selected: true }" @pulldownSelected="labor_onPulldownSelected"
            @popupSelected="labor_onPopupSelected" :export-config="{}" @edit-closed="labor_afterEditEvent"
            @edit-actived="labor_beforeEditEvent" :footer-cell-class-name="labor_footerCellClassName"
            :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: labor_beforeEditMethod }">
            <vxe-column width="60" v-if="!isReadonly">
              <template #default="{ row }">
                <div class="oplinks2">
                  <a @click.stop="labor_pageAdd(row)" title="新增">
                    <a-icon type="plus-circle" />
                  </a>
                  <a @click.stop="labor_pageDelete(row)" title="删除">
                    <a-icon type="delete" />
                  </a>
                </div>
              </template>
            </vxe-column>
            <vxe-column type="seq" title="序号" width="48"></vxe-column>
            <vxe-column field="labor" title="项目" width="260" :params="editorLabor" formatter="formatRef"
              :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>

            <vxe-column field="amount_formula" title="金额" width="200" :edit-render="{ name: 'EditExpressions' }">

              <template #default="{ row }">
                <a-tooltip>
                  <template slot="title">
                    {{ row.amount_formula || '' }}
                  </template>
                  <span v-if="showExp">
                    {{ row.amount_formula || '' }}
                  </span>
                  <span v-else v-html="formatShowNumber(row.amount, 2)"></span>
                </a-tooltip>
              </template>
            </vxe-column>

          </vxe-table>



        </a-collapse-panel>

        <a-collapse-panel key="3" header="其他费用" :disabled="false">
          <div slot="extra">
            （合计）金额：{{ parseFloat(formOptions.data.expense_total_amount || 0).toFixed(2) }}
          </div>
          <vxe-table border show-overflow keep-source ref="expense_xTable" :data="expense_detailsData" :keyboard-config="{
            isArrow: true, isDel: true,
            isEnter: false, isTab: true, isEdit: true, isChecked: true
          }" :mouse-config="{ selected: true }" @pulldownSelected="expense_onPulldownSelected"
            @popupSelected="expense_onPopupSelected" :export-config="{}" @edit-closed="expense_afterEditEvent"
            @edit-actived="expense_beforeEditEvent" :footer-cell-class-name="expense_footerCellClassName"
            :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: expense_beforeEditMethod }">
            <vxe-column width="60" v-if="!isReadonly">
              <template #default="{ row }">
                <div class="oplinks2">
                  <a @click.stop="expense_pageAdd(row)" title="新增">
                    <a-icon type="plus-circle" />
                  </a>
                  <a @click.stop="expense_pageDelete(row)" title="删除">
                    <a-icon type="delete" />
                  </a>
                </div>
              </template>
            </vxe-column>
            <vxe-column type="seq" title="序号" width="48"></vxe-column>
            <vxe-column field="item_name" title="项目" width="220" :edit-render="{ name: '$input' }"></vxe-column>
            <vxe-column field="amount_formula" title="金额" width="220" :edit-render="{ name: 'EditExpressions' }">
              <template #default="{ row }">
                <a-tooltip>
                  <template slot="title">
                    {{ row.amount_formula || '' }}
                  </template>
                  <span v-if="showExp">
                    {{ row.amount_formula || '' }}
                  </span>
                  <span v-else v-html="formatShowNumber(row.amount, 2)"></span>
                </a-tooltip>
              </template>
            </vxe-column>

          </vxe-table>



        </a-collapse-panel>
      </a-collapse>
    </div>


    <div class="groupbox" v-if="showType == '1' || showType == '3'">
      <h3>费用（油漆）</h3>
      <a-collapse v-model="groupbox3_activeKey">
        <a-collapse-panel key="1" header="材料">

          <div slot="extra">
            （合计）金额：{{ parseFloat(formOptions.data.paintMaterial_total_amount || 0).toFixed(2) }}
          </div>
          <vxe-table border show-overflow keep-source ref="paintMaterial_xTable" :data="paintMaterial_detailsData"
            :keyboard-config="{
              isArrow: true, isDel: true,
              isEnter: false, isTab: true, isEdit: true, isChecked: true
            }" :mouse-config="{ selected: true }" @pulldownSelected="paintMaterial_onPulldownSelected"
            @popupSelected="paintMaterial_onPopupSelected" :export-config="{}" @edit-closed="paintMaterial_afterEditEvent"
            :footer-cell-class-name="paintMaterial_footerCellClassName"
            :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: paintMaterial_beforeEditMethod }">
            <vxe-column width="60" v-if="!isReadonly">
              <template #default="{ row }">
                <div class="oplinks2" v-if="!row.isMain && !row.isBanding">
                  <a @click.stop="paintMaterial_pageAdd(row)" title="新增">
                    <a-icon type="plus-circle" />
                  </a>
                  <a @click.stop="paintMaterial_pageDelete(row)" title="删除">
                    <a-icon type="delete" />
                  </a>
                </div>
              </template>
            </vxe-column>
            <vxe-column type="seq" title="序号" width="48"></vxe-column>
            <vxe-column field="material" title="材料" width="260" :params="editorMaterial2" formatter="formatRef"
              :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>

            <vxe-column field="quantity_formula" title="总用量" width="200" :params="{ hasTotalQuantity: true }"
              :edit-render="{ name: 'EditExpressions' }">
              <template #default="{ row }">
                <a-tooltip>
                  <template slot="title">
                    {{ row.quantity_formula || '' }}
                  </template>
                  <span v-if="showExp">
                    {{ row.quantity_formula || '' }}
                  </span>
                  <span v-else v-html="formatShowNumber(row.quantity, 3)"></span>
                </a-tooltip>
              </template>
            </vxe-column>
            <vxe-column field="price" title="单价" width="120"
              :edit-render="{ name: '$input', props: { type: 'number' } }"></vxe-column> 
            <vxe-column field="amount_formula" title="金额" width="200" :edit-render="{ name: 'EditExpressions' }">
              <template #default="{ row }">
                <a-tooltip>
                  <template slot="title">
                    {{ row.amount_formula || '' }}
                  </template>
                  <span v-if="showExp">
                    {{ row.amount_formula || '' }}
                  </span>
                  <span v-else v-html="formatShowNumber(row.amount, 2)"></span>
                </a-tooltip>
              </template>
            </vxe-column>

          </vxe-table>


        </a-collapse-panel>
        <a-collapse-panel key="2" header="人工" :disabled="false">

          <div slot="extra">
            （合计）金额：{{ parseFloat(formOptions.data.paintLabor_total_amount || 0).toFixed(2) }}
          </div>
          <vxe-table border show-overflow keep-source ref="paintLabor_xTable" :data="paintLabor_detailsData"
            :keyboard-config="{
              isArrow: true, isDel: true,
              isEnter: false, isTab: true, isEdit: true, isChecked: true
            }" :mouse-config="{ selected: true }" @pulldownSelected="paintLabor_onPulldownSelected"
            @popupSelected="paintLabor_onPopupSelected" :export-config="{}" @edit-closed="paintLabor_afterEditEvent"
            @edit-actived="paintLabor_beforeEditEvent" :footer-cell-class-name="paintLabor_footerCellClassName"
            :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: paintLabor_beforeEditMethod }">
            <vxe-column width="60" v-if="!isReadonly">
              <template #default="{ row }">
                <div class="oplinks2">
                  <a @click.stop="paintLabor_pageAdd(row)" title="新增">
                    <a-icon type="plus-circle" />
                  </a>
                  <a @click.stop="paintLabor_pageDelete(row)" title="删除">
                    <a-icon type="delete" />
                  </a>
                </div>
              </template>
            </vxe-column>
            <vxe-column type="seq" title="序号" width="48"></vxe-column>
            <vxe-column field="labor" title="项目" width="260" :params="editorLabor" formatter="formatRef"
              :edit-render="{ name: 'MkGridDataSelector' }"></vxe-column>

            <vxe-column field="amount_formula" title="金额" width="200" :edit-render="{ name: 'EditExpressions' }">
              <template #default="{ row }">
                <a-tooltip>
                  <template slot="title">
                    {{ row.amount_formula || '' }}
                  </template>
                  <span v-if="showExp">
                    {{ row.amount_formula || '' }}
                  </span>
                  <span v-else v-html="formatShowNumber(row.amount, 2)"></span>
                </a-tooltip>
              </template>
            </vxe-column>

          </vxe-table>



        </a-collapse-panel>

        <a-collapse-panel key="3" header="其他费用" :disabled="false">
          <div slot="extra">
            （合计）金额：{{ parseFloat(formOptions.data.paintExpense_total_amount || 0).toFixed(2) }}
          </div>
          <vxe-table border show-overflow keep-source ref="paintExpense_xTable" :data="paintExpense_detailsData"
            :keyboard-config="{
              isArrow: true, isDel: true,
              isEnter: false, isTab: true, isEdit: true, isChecked: true
            }" :mouse-config="{ selected: true }" @pulldownSelected="paintExpense_onPulldownSelected"
            @popupSelected="paintExpense_onPopupSelected" :export-config="{}" @edit-closed="paintExpense_afterEditEvent"
            @edit-actived="paintExpense_beforeEditEvent" :footer-cell-class-name="paintExpense_footerCellClassName"
            :edit-config="{ trigger: 'click', mode: 'cell', icon: 'vxe-icon-edit', showStatus: false, beforeEditMethod: paintExpense_beforeEditMethod }">
            <vxe-column width="60" v-if="!isReadonly">
              <template #default="{ row }">
                <div class="oplinks2">
                  <a @click.stop="paintExpense_pageAdd(row)" title="新增">
                    <a-icon type="plus-circle" />
                  </a>
                  <a @click.stop="paintExpense_pageDelete(row)" title="删除">
                    <a-icon type="delete" />
                  </a>
                </div>
              </template>
            </vxe-column>
            <vxe-column type="seq" title="序号" width="48"></vxe-column>
            <vxe-column field="item_name" title="项目" width="220" :edit-render="{ name: '$input' }"></vxe-column>
            <vxe-column field="amount_formula" title="金额" width="200" :edit-render="{ name: 'EditExpressions' }">
              <template #default="{ row }">
                <a-tooltip>
                  <template slot="title">
                    {{ row.amount_formula || '' }}
                  </template>
                  <span v-if="showExp">
                    {{ row.amount_formula || '' }}
                  </span>
                  <span v-else v-html="formatShowNumber(row.amount, 2)"></span>
                </a-tooltip>
              </template>
            </vxe-column>

          </vxe-table>



        </a-collapse-panel>

      </a-collapse>
    </div>



  </div>
</template>

<script>
import BASE_URL from '@/services/Middle/bathroom/BathroomQuotation/api.js';
const settings = require('../../basic/settings.js');

import Vue from 'vue'
import VXETable from 'vxe-table'
import EditExpressions from '../../basic/EditExpressions.vue'
Vue.component(EditExpressions.name, EditExpressions)
// 创建一个下拉表格渲染
VXETable.renderer.add('EditExpressions', {
  autofocus: '.vxe-input--inner',
  renderEdit(h, renderOpts, params) {
    return <edit-expressions params={params}></edit-expressions>
  }
})

export default {

  name: 'drawer',
  components: {},
  props: {
    pageMode: {
      type: String,
      default: "edit"
    },
    dataId: {
    },
    item: {
      type: Object
    }
  },

  data() {
    // 页面数据变量
    var pageData = {
      // 当前项目名称
      currentConfigName: "",
      // 当前项目ID
      currentBeid: 0,
      settignsValues: {},
      showType: '1',
      showExp: false,

      showAll: false,

      modalVisible: false,
      scheme_loading: false, // 加载中
      scheme_tableData: [], // 表格数据
      scheme_tableColumn: [ // 表格列
        { field: 'type', sortable: true, title: '类型', params: settings.options_schemeType, formatter: 'formatEnum' }, // 类型:1.主柜,2.抽屉
        { field: 'name', sortable: true, title: '设计方案名称' }, // 设计方案名称
      ],
      scheme_tablePage: { // 表格分页
        total: 0, // 总数
        currentPage: 1, // 当前页
        pageSize: 100 // 每页显示条数
      },
      groupbox1_activeKey: ["1", "2", "3", "4"],
      groupbox2_activeKey: ["1", "2", "3", "4"],
      groupbox3_activeKey: ["1", "2", "3", "4"],

      isReadonly: false,
      fittings_detailsData: [],
      parts_detailsData: [],



      editorFittings: {
        dataUrl: `${BASE_URL.BASE_URL}/BathroomFittings/v1/bathroom/fittings/list`,
        listdataFieldName: 'BathroomFittings',
        columns: [
          { field: 'name', title: '名称' },
          { field: 'remark', title: '备注' }
        ],
        placeholder: "请输入名称",
        searchFieldNames: ['name'],
        textField: 'name'
      },
      editorMaterial: {
        dataUrl: `${BASE_URL.BASE_URL}/BathroomMaterial/v1/bathroom/material/list`,
        listdataFieldName: 'BathroomMaterial',
        columns: [
          { field: 'name', title: '名称' },
          { field: 'remark', title: '备注' }
        ],
        placeholder: "请输入名称",
        searchFieldNames: ['name'],
        textField: 'name'
      },

      editorMaterial2: {
        dataUrl: `${BASE_URL.BASE_URL}/BathroomMaterial/v1/bathroom/material/list`,
        listdataFieldName: 'BathroomMaterial',
        columns: [
          { field: 'name', title: '名称' },
          { field: 'remark', title: '备注' }
        ],
        placeholder: "请输入名称",
        searchFieldNames: ['name'],
        extendData: [{ id: '封边条', name: '封边条' }],
        textField: 'name'
      },
      editorBanding: {
        dataUrl: `${BASE_URL.BASE_URL}/BathroomBanding/v1/bathroom/banding/list`,
        listdataFieldName: 'BathroomBanding',
        columns: [
          { field: 'name', title: '名称' },
          { field: 'remark', title: '备注' }
        ],
        placeholder: "请输入名称",
        searchFieldNames: ['name'],
        textField: 'name'
      },
      editorParts: {
        dataUrl: `${BASE_URL.BASE_URL}/BathroomParts/v1/bathroom/parts/list`,
        listdataFieldName: 'BathroomParts',
        columns: [
          { field: 'name', title: '名称' },
          { field: 'remark', title: '备注' }
        ],
        placeholder: "请输入名称",
        searchFieldNames: ['name'],
        textField: 'name'
      },
      editorPackaging: {
        dataUrl: `${BASE_URL.BASE_URL}/BathroomPackaging/v1/bathroom/packaging/list`,
        listdataFieldName: 'BathroomPackaging',
        columns: [
          { field: 'name', title: '名称' },
          { field: 'remark', title: '备注' }
        ],
        placeholder: "请输入名称",
        searchFieldNames: ['name'],
        textField: 'name'
      },
      editorLabor: {
        dataUrl: `${BASE_URL.BASE_URL}/BathroomLabor/v1/bathroom/labor/list`,
        listdataFieldName: 'BathroomLabor',
        columns: [
          { field: 'name', title: '名称' },
          { field: 'remark', title: '备注' }
        ],
        placeholder: "请输入名称",
        searchFieldNames: ['name'],
        textField: 'name'
      },




      packaging_detailsData: [],


      material_detailsData: [],
      labor_detailsData: [],
      paintMaterial_detailsData: [],
      paintLabor_detailsData: [],
      bathroomMaterial_list: [],//材料的数据
      fittings_list: [],//材料的数据
      moreExpressionsList_material_height: [],//材料的厚度 变量列表
      moreExpressionsList_fittings: [],
      expense_detailsData: [

      ],
      paintExpense_detailsData: [

      ],

      uploadDefaultImg: null,
      detailDataFieldName: "bathroom_quotation",

      actions: {
      },

      keyName: 'id',
      // 是否编辑模式
      isEdit: false,
      // 表单数据
      formOptions: {
        data: {
          // =============================== 表单数据 自动生成 Start ===============================

          id: 0,
          code: "",
          order_code: "",
          customer: "",
          phone: "",
          address: "",
          model_id: 0,
          design_id: 0,
          project_name: "",
          main_cabinet_length: "",
          main_cabinet_width: "",
          main_cabinet_height: "",
          create_uid: 0,
          update_uid: 0,
          create_time: new Date(2100, 1, 1).getTime() / 10000,
          update_time: new Date(2100, 1, 1).getTime() / 10000,

          // =============================== 表单数据 自动生成 End ===============================
        },
        // 标题宽度
        titleWidth: 100,
        // 标题对齐方式
        titleAlign: 'right',

        // 表单校验规则
        rules: {
        },
        // 表单项
        items: [

          { field: 'name', title: '抽屉名', span: 6, itemRender: { name: '$input' } },
          //{ field: 'quantity', title: '数量', span: 6, itemRender: { name: '$input', props: { type: "number" }, events: { change: this.calculateAll } } },

          { field: 'show_expense', title: '单价(免漆)', span: 6, itemRender: { name: '$input' } },
          { field: 'show_paint_expense', title: '单价(油漆)', span: 6, itemRender: { name: '$input' } },

          { field: 'long', title: '长', span: 6, itemRender: { name: '$input', events: { change: this.calculateAll } } },
          { field: 'width', title: '宽', span: 6, itemRender: { name: '$input', events: { change: this.calculateAll } } },
          { field: 'height', title: '高', span: 6, itemRender: { name: '$input', events: { change: this.calculateAll } } },



        ]
      },
      // 新增模式表单项
      addModeItems: [

      ],


    };


    // 合并表单数据及配置
    pageData.formOptions = Object.assign({}, this.$mk.config.defaults.formOptions, pageData.formOptions);

    return pageData;
  },

  computed: {
  },


  created() {
    this.loadSettings();
    let data = this.item;
    this.formOptions.data = data;
    this.fittings_detailsData = data.fittingsList || [];
    this.parts_detailsData = data.partsList || [];
    this.packaging_detailsData = data.packagingList || [];
    this.labor_detailsData = data.laborList || [];
    this.material_detailsData = data.materialList || [];
    this.paintLabor_detailsData = data.paint_laborList || [];
    this.paintMaterial_detailsData = data.paint_materialList || [];
    this.expense_detailsData = data.expense_list || [];
    this.paintExpense_detailsData = data.paint_expenseList || [];

      

    this.materialHeightInit()
    this.fittingsListInit();
    this.detailDataInit();
    this.resetMaterial();
    this.resetPaintMaterial();
    this.calculateAll();
  },
  // 函数
  methods: {


    fittingsListInit() { // 获取部件数据

      this.$mk.post({ // 获取材料列表
        url: `${BASE_URL.BASE_URL}//BathroomFittings/v1/bathroom/fittings/list`,
        data: { "page": 1, "limit": 100, "order_bys": [], "search_rules": [] }
      }).then(a => {

        this.fittings_list = a.data.BathroomFittings || [];
        this.moreExpressionsList_fittings = [];


        this.fittings_list.forEach(o => {
          if (o.IsShowExpression) {
            this.moreExpressionsList_fittings.push(this.formatName(o.name) + "的长");
            this.moreExpressionsList_fittings.push(this.formatName(o.name) + "的宽");
            this.moreExpressionsList_fittings.push(this.formatName(o.name) + "的厚");
          }
        });

      });
    },
    materialHeightInit() {

      this.$mk.post({
        url: `${BASE_URL.BASE_URL}/BathroomMaterial/v1/bathroom/material/list`,
        data: { "page": 1, "limit": 100, "order_bys": [], "search_rules": [] }
      }).then(a => {


        this.bathroomMaterial_list = a.data.BathroomMaterial || [];
        this.moreExpressionsList_material_height = [];

        this.bathroomMaterial_list.forEach(o => {
          this.fittings_detailsData.forEach(item => {
            if (item.material && item.material[0] && item.material[0].toString() == o.id.toString()) {

              item.material_default_height = o.spec || "15";
            }
          });

        });

        this.bathroomMaterial_list.forEach(o => { // 遍历材料列表

          this.moreExpressionsList_material_height.push(this.formatName(o.name) + "的厚度");

        });



      });
    },


    getMoreExpressionsList() {
      return [...this.moreExpressionsList_material_height, ...this.moreExpressionsList_fittings]
    },

    loadSettings() {

      this.$mk.post({
        url: `${BASE_URL.BASE_URL}/BathroomScheme/v1/settings/list`,
        data: {
        }
      }).then(a => {

        let data = {};
        let getName = (info) => {
          for (let name in info) {
            return name;
          }
          return null;
        }
        a.data.settings.forEach(o => {
          let name = getName(o.setting);
          if (!name) return;
          data[name] = o.setting[name];
        });

        this.settignsValues = data;
      }).catch((a) => {
        this.$mk.error(a.data.msg);
      });
    },
    reloadDrawer() {
      let drawer_detailData = this.item;
      if (!drawer_detailData.scheme_id) return;
      const json = `{"id":${drawer_detailData.scheme_id}}`; // 构造json
      this.$mk.post({ // 获取详情数据
        url: `${BASE_URL.BASE_URL}/BathroomScheme/v1/bathroom/scheme/detail`, // 详情接口地址
        loading: "加载中...",
        data: json,
        config: {
          headers: {
            'Content-Type': 'application/json'
          }
        }
      }).then(a => {

        let row = a.data.bathroom_scheme; // 重新加载方案数据


        let fittingsList = JSON.parse(row.fittingsList || "[]"); // 获取部件列表
        fittingsList = fittingsList.filter(a => a.fittings && a.fittings[0]); // 过滤部件列表
        let partsList = JSON.parse(row.partsList || "[]"); // 获取配件列表
        partsList = partsList.filter(a => a.parts && a.parts[0]); // 过滤配件列表
        let packagingList = JSON.parse(row.packagingList || "[]"); // 获取包装列表
        packagingList = packagingList.filter(a => a.packaging && a.packaging[0]); // 过滤包装列表

        let laborList = JSON.parse(row.laborList || "[]"); // 获取人工列表
        laborList = laborList.filter(a => a.labor && a.labor[0]); // 过滤人工列表
        let materialList = JSON.parse(row.materialList || "[]"); // 获取材料列表
        materialList = materialList.filter(a => a.material && a.material[0]); // 过滤材料列表


        let paintLaborList = JSON.parse(row.paintLaborList || "[]"); // 获取油漆人工列表
        paintLaborList = paintLaborList.filter(a => a.labor && a.labor[0]); // 过滤油漆人工列表
        let paintMaterialList = JSON.parse(row.paintMaterialList || "[]"); // 获取油漆材料列表
        paintMaterialList = paintMaterialList.filter(a => a.material && a.material[0]); // 过滤油漆材料列表


        let updateToList = ({ sourceList, targetList }) => {
          sourceList.forEach(item => {
            targetList.forEach(targetItem => {
              if (targetItem.id == item.id) {
                Object.assign(targetItem, item);
              }
            })
          });

        };
        updateToList({ sourceList: fittingsList, targetList: this.fittings_detailsData })
        updateToList({ sourceList: partsList, targetList: this.parts_detailsData })
        updateToList({ sourceList: packagingList, targetList: this.packaging_detailsData })
        updateToList({ sourceList: laborList, targetList: this.labor_detailsData })
        updateToList({ sourceList: materialList, targetList: this.material_detailsData })
        updateToList({ sourceList: paintLaborList, targetList: this.paintLabor_detailsData })
        updateToList({ sourceList: paintMaterialList, targetList: this.paintMaterial_detailsData })


        this.calculateAll();


      });
    },

    formatShowNumber(value, points) {
      if (!value) {
        return '<span>' + (0.0).toFixed(points || 0) + '</span>';
      }
      return parseFloat(value).toFixed(points || 0)
    },
    toggleAll() {

      this.showAll = !this.showAll;
      if (this.showAll) {
        this.groupbox1_activeKey = ["1", "2", "3", "4", "5"];
        this.groupbox2_activeKey = ["1", "2", "3"];
        this.groupbox3_activeKey = ["1", "2", "3"];
      } else {

        this.groupbox1_activeKey = [];
        this.groupbox2_activeKey = [];
        this.groupbox3_activeKey = [];
      }

    },


    print() { // 打印

      let hiprint = this.$hiPrint; // 获取打印组件
      let tdata = JSON.parse(JSON.stringify(this.formOptions.data)); // 复制表单数据


      tdata.project_name = tdata.name;
      tdata.main_cabinet_length = tdata.long;
      tdata.main_cabinet_width = tdata.width;
      tdata.main_cabinet_height = tdata.height; 

      tdata.fittings = this.printFormatListData(this.fittings_detailsData); // 格式化部件数据
      tdata.parts = this.printFormatListData(this.parts_detailsData); // 格式化配件数据
      tdata.packaging = this.printFormatListData(this.packaging_detailsData); // 格式化包装数据
      tdata.labor = this.printFormatListData(this.labor_detailsData); // 格式化人工数据
      tdata.material = this.printFormatListData(this.material_detailsData); // 格式化材料数据
      tdata.paintLabor = this.printFormatListData(this.paintLabor_detailsData); // 格式化油漆人工数据
      tdata.paintMaterial = this.printFormatListData(this.paintMaterial_detailsData); // 格式化油漆材料数据
      tdata.expense = this.printFormatListData(this.expense_detailsData); // 格式化费用结算数据
      tdata.paintExpense = this.printFormatListData(this.paintExpense_detailsData); // 格式化油漆费用结算数据

      hiprint.init(); // 初始化打印组件
      var hiprintTemplate = new hiprint.PrintTemplate({ // 创建打印模板
        template: settings.printTemplate // 模板内容
      });
      hiprintTemplate.print(tdata, { printer: '', title: '报价单' }); // 打印
    },
    printFormatListData(detailsData) { // 格式化打印列表数据

      let data = JSON.parse(JSON.stringify(detailsData)); // 复制数据
      data.forEach(item => { // 遍历数据

        for (let name in item) { // 遍历数据的每个字段
          let o = item[name]; // 获取字段值
          if (Array.isArray(o) && o[1]) { // 如果字段值是数组
            item[name] = o[1]; // 设置字段值为数组的第二个元素
          }
          if (typeof (o) == "number") { // 如果字段值是数字
            item[name] = parseFloat(o || 0).toFixed(2) // 设置字段值为数字的字符串
          }
        }
      });
      return data; // 返回数据
    },



    setShowType(value) {

      this.showType = value
    },

    //把来源数据添加到目标表格数据
    addToList({ listData, scheme_id, detailsData }) {

      let newInfos = [];
      listData.forEach(item => {
        let info = JSON.parse(JSON.stringify(item));
        let source = JSON.parse(JSON.stringify(item));
        info.source = source;
        info.scheme_id = scheme_id;

        //第二次选择 方案 的时候 ，先找到原来行，
        let oldDetailItem = detailsData.filter(a => a.scheme_id == scheme_id && a.source && a.source.id == item.id);

        if (oldDetailItem.length) {
          //覆盖 更新 原来行的数据 
          Object.assign(oldDetailItem[0], info);
        } else {
          //准备 要附加进去的行
          newInfos.push(info);
        }
      });


      let j = 0;
      for (let i = 0; i < detailsData.length && j < newInfos.length; i++) {
        let item = detailsData[i];

        //没有选择部件的行，覆盖数据
        if (!item.fittings || !item.fittings[0]) {
          Object.assign(detailsData[i], newInfos[j]);
          j++;
        }
      }
      //剩下的行，直接push进去
      for (; j < newInfos.length; j++) {
        detailsData.push(newInfos[j]);
      }
    },


    detailDataInit() {
      for (let i = this.fittings_detailsData.length; i < settings.table_min_count; i++) {
        this.fittings_detailsData.push({});
      }


      for (let i = this.parts_detailsData.length; i < settings.table_min_count; i++) {
        this.parts_detailsData.push({});
      }

      for (let i = this.packaging_detailsData.length; i < settings.table_min_count; i++) {
        this.packaging_detailsData.push({});
      }


      for (let i = this.material_detailsData.length; i < settings.table_min_count; i++) {
        this.material_detailsData.push({});
      }
      for (let i = this.labor_detailsData.length; i < settings.table_min_count; i++) {
        this.labor_detailsData.push({});
      }
      for (let i = this.paintMaterial_detailsData.length; i < settings.table_min_count; i++) {
        this.paintMaterial_detailsData.push({});
      }
      for (let i = this.paintLabor_detailsData.length; i < settings.table_min_count; i++) {
        this.paintLabor_detailsData.push({});
      }

      for (let i = this.expense_detailsData.length; i < settings.table_min_count; i++) {
        this.expense_detailsData.push({});
      }
      for (let i = this.paintExpense_detailsData.length; i < settings.table_min_count; i++) {
        this.paintExpense_detailsData.push({});
      }


    },
    // 获取路由的id参数
    getDataId() {
      let dataId = this.dataId;
      if (this.$route.params.id) {
        dataId = this.$route.params.id;
      }
      if (!dataId) {
        dataId = 0;
      }
      return dataId;
    },



    // 返回
    back() {
      // 如果是新增模式，关闭当前页面
      if (!this.isEdit) {
        this.$closePage({
          closeRoute: "/BathroomQuotation/BathroomQuotationAdd"
        });
      } else {
        // 如果是编辑模式，关闭当前页面
        this.$closePage({
          closeRoute: "/BathroomQuotation/BathroomQuotationUpdate"
        });
      }
      // 打开列表页面
      this.$openPage('/BathroomQuotation/BathroomQuotationList')
    },
    fittings_onPulldownSelected({ row, selectedData, column }) {

      if (column.field == "banding") {
        if (selectedData.formula) {
          row.seal_formula = selectedData.formula;
        }

      }
      if (column.field == "paint_material") {
        this.resetPaintMaterial();
      }
      if (column.field == "material") {
        this.resetMaterial();

        if (selectedData.spec) {
          row.material_default_height = selectedData.spec;
        }
      }
      if (!row.rate_materials && this.settignsValues.Main_material_utilization_rate) {
        row.rate_materials = this.settignsValues.Main_material_utilization_rate;
      }
      if (!row.paint_number && this.settignsValues.Default_rate_of_paint_surface) {
        row.paint_number = this.settignsValues.Default_rate_of_paint_surface;
      }

      if (!row.board_length_formula) {
        row.board_length_formula = this.settignsValues.Default_board_length_formula || '{板材的长}*{板材的宽}*{部件的数量}/{主材利用率}/1000000/2.96';
      }

      if (!row.paint_area_formula) {
        row.paint_area_formula = this.settignsValues.Default_paint_area_formula || '{板材的长}*{板材的宽}*{部件的数量}*{油漆面}/1000000';
      }
    },
    fittings_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    fittings_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    fittings_afterEditEvent({ column, row }) {
      console.log(row, column);

      this.calculateAll();
    },
    fittings_beforeEditEvent({ column, row }) {
      console.log(row, column);
    },
    fittings_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    fittings_footerMethod({ columns }) {
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'quantity':
              sumCell = parseFloat(this.formOptions.data.fittings_total_quantity || 0).toFixed(0)
              break
            case 'seal_formula':
              sumCell = parseFloat(this.formOptions.data.fittings_total_seal || 0).toFixed(2)
              break
            case 'board_length_formula':
              sumCell = parseFloat(this.formOptions.data.fittings_total_board_length || 0).toFixed(3)
              break
            case 'paint_area_formula':
              sumCell = parseFloat(this.formOptions.data.fittings_total_paint_area || 0).toFixed(3)
              break


          }
          sums.push(sumCell)
        }
      })
      // 返回一个二维数组的表尾合计
      return [sums]
    },
    fittings_pageAdd(row) {
      const $table = this.$refs.fittings_xTable
      const record = {
      }
      if (row) {

        this.fittings_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.fittings_detailsData.push(record)
      }
    },
    fittings_pageDelete(row) {
      const $table = this.$refs.fittings_xTable;
      this.fittings_detailsData.splice($table.getRowSeq(row) - 1, 1);
      this.resetMaterial();
      this.resetPaintMaterial();
    },



    parts_onPulldownSelected({ selectedData, row }) {
      console.log(row, selectedData);
      if (selectedData.spec) {
        row.spec = selectedData.spec;

      }
      if (selectedData.price) {
        row.price = selectedData.price;

      }

    },
    parts_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    parts_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    parts_afterEditEvent() {

      this.calculateAll();
    },
    parts_beforeEditEvent({ column, row }) {
      console.log(row, column);
    },
    parts_pageAdd(row) {
      const $table = this.$refs.parts_xTable
      const record = {
      }
      if (row) {
        this.parts_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.parts_detailsData.push(record)
      }
    },
    parts_pageDelete(row) {
      const $table = this.$refs.parts_xTable;
      this.parts_detailsData.splice($table.getRowSeq(row) - 1, 1);
      this.calculateAll();
    },
    parts_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    parts_footerMethod({ columns, data }) {
      console.log(data)
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'amount_formula':
              sumCell = parseFloat(this.formOptions.data.parts_total_amount || 0).toFixed(2)
              break
          }
          sums.push(sumCell)
        }
      })
      return [sums]
    },



    // 包装下拉选择事件
    packaging_onPulldownSelected({ row, name, column, params, selectedData }) {
      console.log(row, name, params);

      if (column.field == "packaging") {

        if (selectedData && selectedData.default_quantity) {
          row.quantity = selectedData.default_quantity; // 设置默认数量
        }
      }

    },
    packaging_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    packaging_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    packaging_afterEditEvent({ column, row }) {
      console.log(row, column);

      this.calculateAll();
    },
    packaging_beforeEditEvent({ column, row }) {
      console.log(row, column);
    },
    packaging_pageAdd(row) {
      const $table = this.$refs.packaging_xTable
      const record = {
      }
      if (row) {
        this.packaging_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.packaging_detailsData.push(record)
      }
    },
    packaging_pageDelete(row) {
      const $table = this.$refs.packaging_xTable;
      this.packaging_detailsData.splice($table.getRowSeq(row) - 1, 1);
    },
    packaging_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    packaging_footerMethod({ columns, data }) {
      console.log(data)
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'amount_formula':
              sumCell = parseFloat(this.formOptions.data.packaging_total_amount || 0).toFixed(2)
              break
          }
          sums.push(sumCell)
        }
      })
      return [sums]
    },


    material_onPulldownSelected({ row, name, params }) {
      console.log(row, name, params);

    },
    material_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    material_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    material_afterEditEvent({ column, row }) {
      console.log(row, column);

      this.calculateAll();
    },
    material_pageAdd(row) {
      const $table = this.$refs.material_xTable
      const record = {

      }
      if (row) {
        this.material_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.material_detailsData.push(record)
      }
    },
    material_pageDelete(row) {
      const $table = this.$refs.material_xTable;
      this.material_detailsData.splice($table.getRowSeq(row) - 1, 1);
    },
    material_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    material_footerMethod({ columns, data }) {
      console.log(data)
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'amount_formula':
              sumCell = parseFloat(this.formOptions.data.material_total_amount || 0).toFixed(2)
              break
          }
          sums.push(sumCell)
        }
      })
      return [sums]
    },



    labor_onPulldownSelected({ row, name, params }) {
      console.log(row, name, params);

    },
    labor_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    labor_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    labor_afterEditEvent({ column, row }) {
      console.log(row, column);

      this.calculateAll();
    },
    labor_beforeEditEvent({ column, row }) {
      console.log(row, column);
    },
    labor_pageAdd(row) {
      const $table = this.$refs.labor_xTable
      const record = {
      }
      if (row) {

        this.labor_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.labor_detailsData.push(record)
      }
    },
    labor_pageDelete(row) {
      const $table = this.$refs.labor_xTable;
      this.labor_detailsData.splice($table.getRowSeq(row) - 1, 1);
    },
    labor_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    labor_footerMethod({ columns, data }) {
      console.log(data)
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'amount_formula':
              sumCell = parseFloat(this.formOptions.data.labor_total_amount || 0).toFixed(2)
              break
          }
          sums.push(sumCell)
        }
      })
      return [sums]
    },



    expense_onPulldownSelected({ row, name, params }) {
      console.log(row, name, params);

    },
    expense_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    expense_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    expense_afterEditEvent({ column, row }) {
      console.log(row, column);
      this.calculateAll();
    },
    expense_beforeEditEvent({ column, row }) {
      console.log(row, column);
    },
    expense_pageAdd(row) {
      const $table = this.$refs.expense_xTable
      const record = {
      }
      if (row) {
        this.expense_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.expense_detailsData.push(record)
      }
    },
    expense_pageDelete(row) {
      const $table = this.$refs.expense_xTable;
      this.expense_detailsData.splice($table.getRowSeq(row) - 1, 1);
    },
    expense_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    expense_footerMethod({ columns, data }) {
      console.log(data)
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'amount_formula':
              sumCell = parseFloat(this.formOptions.data.expense_total_amount || 0).toFixed(2)
              break
          }
          sums.push(sumCell)
        }
      })
      return [sums]
    },



    paintMaterial_onPulldownSelected({ row, name, params }) {
      console.log(row, name, params);

    },
    paintMaterial_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    paintMaterial_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    paintMaterial_afterEditEvent({ column, row }) {
      console.log(row, column);
      this.calculateAll();
    },
    paintMaterial_pageAdd(row) {
      const $table = this.$refs.paintMaterial_xTable
      const record = {

      }
      if (row) {

        this.paintMaterial_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.paintMaterial_detailsData.push(record)
      }
    },
    paintMaterial_pageDelete(row) {
      const $table = this.$refs.paintMaterial_xTable;
      this.paintMaterial_detailsData.splice($table.getRowSeq(row) - 1, 1);
    },
    paintMaterial_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    paintMaterial_footerMethod({ columns, data }) {
      console.log(data)
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'amount_formula':
              sumCell = parseFloat(this.formOptions.data.paintMaterial_total_amount || 0).toFixed(2)
              break
          }
          sums.push(sumCell)
        }
      })
      return [sums]
    },


    paintLabor_onPulldownSelected({ row, name, params }) {
      console.log(row, name, params);

    },
    paintLabor_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    paintLabor_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    paintLabor_afterEditEvent({ column, row }) {
      console.log(row, column);
      this.calculateAll();
    },
    paintLabor_beforeEditEvent({ column, row }) {
      console.log(row, column);
    },
    paintLabor_pageAdd(row) {
      const $table = this.$refs.paintLabor_xTable
      const record = {
      }
      if (row) {

        this.paintLabor_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.paintLabor_detailsData.push(record)
      }
    },
    paintLabor_pageDelete(row) {
      const $table = this.$refs.paintLabor_xTable;
      this.paintLabor_detailsData.splice($table.getRowSeq(row) - 1, 1);
    },
    paintLabor_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    paintLabor_footerMethod({ columns, data }) {
      console.log(data)
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'amount_formula':
              sumCell = parseFloat(this.formOptions.data.paintLabor_total_amount || 0).toFixed(2)
              break
          }
          sums.push(sumCell)
        }
      })
      return [sums]
    },


    paintExpense_onPulldownSelected({ row, name, params }) {
      console.log(row, name, params);

    },
    paintExpense_onPopupSelected({ rows, name, params }) {
      console.log(rows, name, params);
    },
    paintExpense_beforeEditMethod({ column, row }) {
      console.log(row, column);
      return true;
    },
    paintExpense_afterEditEvent({ column, row }) {
      console.log(row, column);
      this.calculateAll();
    },
    paintExpense_beforeEditEvent({ column, row }) {
      console.log(row, column);
    },
    paintExpense_pageAdd(row) {
      const $table = this.$refs.paintExpense_xTable
      const record = {
      }
      if (row) {
        this.paintExpense_detailsData.splice($table.getRowSeq(row), 0, record);
      } else {
        this.paintExpense_detailsData.push(record)
      }
    },
    paintExpense_pageDelete(row) {
      const $table = this.$refs.paintExpense_xTable;
      this.paintExpense_detailsData.splice($table.getRowSeq(row) - 1, 1);
    },
    paintExpense_footerCellClassName({ columnIndex }) {
      if (columnIndex === 0) {
        return 'col-blue'
      }
    },
    paintExpense_footerMethod({ columns, data }) {
      console.log(data)
      const sums = []
      columns.forEach((column, columnIndex) => {
        if (columnIndex === 0) {
          sums.push('')
        } else {
          let sumCell = ''
          switch (column.field) {
            case 'amount_formula':
              sumCell = parseFloat(this.formOptions.data.paintExpense_total_amount || 0).toFixed(2)
              break
          }
          sums.push(sumCell)
        }
      })
      return [sums]
    },




    formatName(v) {
      return (v || "").replace("\r", "").replace("\n", "").replace("\t", "").replace(" ", "");
    },



    resetMaterial() { 
      let material_items = [];

      this.fittings_detailsData.forEach(item => {

        if (item.material && item.material[0]) {

          if (material_items.filter(a => a && a[0] == item.material[0]).length == 0) {
            material_items.push(item.material);
          }

        }
      });

      let material_list = [];
      material_items.forEach(item => {

        let name = this.formatName(item[1]);
        let old = this.material_detailsData.filter(a => a.material && a.material[0] == item[0] ? true : false);
        let info = {
          isMain: true,
          material: item,
          quantity_formula: `{${name}的总用量}`,
          price: 0
        };
        if (old.length) {
          info.quantity_formula = `{${name}的总用量}`;
          info.price = old[0].price;
          info.amount_formula = old[0].amount_formula;
        }
        material_list.push(info)
      })


      var b1 = true;
      if (b1) {
        let info = {
          isBanding: true,
          material: ['封边条', '封边条'],
          quantity_formula: '',
          price: 0
        };
        let old = this.material_detailsData.filter(a => a.isBanding ? true : false);

        if (old.length) {
          info.quantity_formula = old[0].quantity_formula;
          info.amount_formula = old[0].amount_formula;
          info.price = old[0].price;
        }
        material_list.push(info)
      }


      let ds = [];
      this.material_detailsData.forEach(item => {
        if (item.isMain) return;
        if (item.isBanding) return;
        ds.push(item);
      });
      this.material_detailsData = [...material_list, ...ds];

    },



    resetPaintMaterial() {
      let material_items = [];

      this.fittings_detailsData.forEach(item => {

        if (item.paint_material && item.paint_material[0]) {

          if (material_items.filter(a => a && a[0] == item.paint_material[0]).length == 0) {
            material_items.push(item.paint_material);
          }

        }
      });

      let material_list = [];
      material_items.forEach(item => {
        let name = this.formatName(item[1]);
        let old = this.paintMaterial_detailsData.filter(a => a.material && a.material[0] == item[0] ? true : false);
        let info = {
          isMain: true,
          material: item,
          quantity_formula: `{${name}的总用量}`,
          price: 0
        };
        if (old.length) {
          info.quantity_formula = `{${name}的总用量}`;
          info.price = old[0].price;
          info.amount_formula = old[0].amount_formula;
        }
        material_list.push(info)
      })


      var b1 = true;
      if (b1) {
        let info = {
          isBanding: true,
          material: ['封边条', '封边条'],
          quantity_formula: '',
          price: 0
        };
        let old = this.paintMaterial_detailsData.filter(a => a.isBanding ? true : false);

        if (old.length) {
          info.quantity_formula = old[0].quantity_formula;
          info.amount_formula = old[0].amount_formula;
          info.price = old[0].price;
        }
        material_list.push(info)
      }


      let ds = [];
      this.paintMaterial_detailsData.forEach(item => {
        if (item.isMain) return;
        if (item.isBanding) return;
        ds.push(item);
      });
      this.paintMaterial_detailsData = [...material_list, ...ds];

    },



    formatDetailsData(data) {

      if (!data) return;
      data.forEach(item => {
        delete item._X_ROW_KEY
        if (!item.id) {
          item.id = settings.getGuid();
        }
      });
    },

    // 取消 返回
    cancel() {
      this.back();
    },


    getExpressionItemValue({ name, row, defaultValue }) {

      if (!name) return '';
      //计算材料的总用量
      if (name.indexOf('的总用量') > 0) {

        name = this.formatName(name);
        let sum = 0;
        this.fittings_detailsData.forEach(item => {
          if (item.material && item.material[1]) {
            let name_current = this.formatName(item.material[1]);
            if (name == name_current + "的总用量") {
              sum += parseFloat(item.board_length || 0);
              return;
            }
          }
          if (item.paint_material && item.paint_material[1]) {
            let name_current = this.formatName(item.paint_material[1]);
            if (name == name_current + "的总用量") {
              sum += parseFloat(item.board_length || 0);
              return;
            }
          }

        });
        return sum;

      }

      //计算材料的厚度
      if (name.indexOf('的厚度') > 0) {

        name = this.formatName(name);
        name = name.substr(0, name.length - 3);
        console.log(name);
        let v = 0;
        this.bathroomMaterial_list.forEach(o => { // 遍历材料列表

          if (name == this.formatName(o.name)) {

            v = parseFloat(o.spec || 15);
          }


        });
        return v;

      }
      let nn = [{ n: '的长', name: 'long' }, { n: '的宽', name: 'width' }, { n: '的厚', name: 'height' }];
      for (let i = 0; i < nn.length; i++) {

        if (name.indexOf(nn[i].n) > 0 &&
          this.fittings_list.filter(a => this.formatName(a.name) + nn[i].n == name).length) {
          name = this.formatName(name);
          name = name.substr(0, name.length - 2);
          console.log(name);
          let v = 0;
          this.fittings_detailsData.forEach(o => {
            if (o.fittings && name == this.formatName(o.fittings[1])) {
              v = parseFloat(o[nn[i].name] || 0);
            }
          });
          return v;
        }

      }

      let fun = settings.expressionsDefines[name];
      if (!fun) {
        return defaultValue || 0;
      }
      var v = fun({ data: this.formOptions.data, row: row }) || defaultValue;

      return parseFloat(v || 0);
    },

    //根据表达式计算出值
    getExpressionValue({ row, exp, defaultValue }) {

      try {
        let value = exp.toString();

        value = value.replace(/{([\u4e00-\u9fa5_a-zA-Z0-9]+)}/g, (n) => {
          let name = n.substr(1, n.length - 2);
          return this.getExpressionItemValue({ row, name, defaultValue })
        });

        value = value.replace("/，/g", ",");
        value = value.replace("/？/g", "?");
        value = value.replace("/：/g", ":");
        eval("value = " + value)
        return value;
      } catch {
        return defaultValue || 0;
      }

    },




    calculateAll() {

      this._calculateAll();
      this.$forceUpdate();

    },

    _calculateAll() {


      this.calculateRows({ detailsData: this.fittings_detailsData, names: ["long", "width", "height", "seal", "board_length", "paint_area"], totalPrev: "fittings" });

      this.totalRows({ detailsData: this.fittings_detailsData, names: ["quantity"], totalPrev: "fittings" });


      this.calculateRows({ detailsData: this.parts_detailsData, names: ["amount"], totalPrev: "parts" });
      this.calculateRows({ detailsData: this.packaging_detailsData, names: ["long", "width", "height", "quantity", "amount"], totalPrev: "packaging" });

      this.calculateRows({ detailsData: this.material_detailsData, names: ["quantity", "amount"], totalPrev: "material" });
      this.calculateRows({ detailsData: this.labor_detailsData, names: ["amount"], totalPrev: "labor" });

      this.calculateRows({ detailsData: this.paintMaterial_detailsData, names: ["quantity", "amount"], totalPrev: "paintMaterial" });
      this.calculateRows({ detailsData: this.paintLabor_detailsData, names: ["amount"], totalPrev: "paintLabor" });


      this.calculateRows({ detailsData: this.expense_detailsData, names: ["amount"], totalPrev: "expense" });
      this.calculateRows({ detailsData: this.paintExpense_detailsData, names: ["amount"], totalPrev: "paintExpense" });



      this.formOptions.data.expense = parseFloat(this.formOptions.data.expense_total_amount || 0) +
        parseFloat(this.formOptions.data.material_total_amount || 0) +
        parseFloat(this.formOptions.data.labor_total_amount || 0)+
        parseFloat(this.formOptions.data.parts_total_amount || 0) + 
        parseFloat(this.formOptions.data.packaging_total_amount || 0);


      this.formOptions.data.paint_expense = parseFloat(this.formOptions.data.paintExpense_total_amount || 0) +
        parseFloat(this.formOptions.data.paintMaterial_total_amount || 0) +
        parseFloat(this.formOptions.data.paintLabor_total_amount || 0)+
        parseFloat(this.formOptions.data.parts_total_amount || 0) + 
        parseFloat(this.formOptions.data.packaging_total_amount || 0);


      this.formOptions.data.show_expense = parseFloat(this.formOptions.data.expense || 0).toFixed(2);
      this.formOptions.data.show_paint_expense = parseFloat(this.formOptions.data.paint_expense || 0).toFixed(2);

      this.formOptions.data = JSON.parse(JSON.stringify(this.formOptions.data))


      let postdata = this.item;

      postdata.fittingsList = JSON.parse(JSON.stringify(this.fittings_detailsData));
      postdata.partsList = JSON.parse(JSON.stringify(this.parts_detailsData));
      postdata.packagingList = JSON.parse(JSON.stringify(this.packaging_detailsData));
      postdata.laborList = JSON.parse(JSON.stringify(this.labor_detailsData));
      postdata.materialList = JSON.parse(JSON.stringify(this.material_detailsData));
      postdata.paint_laborList = JSON.parse(JSON.stringify(this.paintLabor_detailsData));
      postdata.paint_materialList = JSON.parse(JSON.stringify(this.paintMaterial_detailsData));
      postdata.expense_list = JSON.parse(JSON.stringify(this.expense_detailsData));
      postdata.paint_expenseList = JSON.parse(JSON.stringify(this.paintExpense_detailsData));

      postdata.fittingsList = postdata.fittingsList.filter(item => item.fittings && item.fittings[1] ? true : false);
      postdata.partsList = postdata.partsList.filter(item => item.parts && item.parts[1] ? true : false);
      postdata.packagingList = postdata.packagingList.filter(item => item.packaging && item.packaging[1] ? true : false);
      postdata.laborList = postdata.laborList.filter(item => item.labor && item.labor[1] ? true : false);
      postdata.materialList = postdata.materialList.filter(item => item.material && item.material[1] ? true : false);


      postdata.paint_laborList = postdata.paint_laborList.filter(item => item.labor && item.labor[1] ? true : false);
      postdata.paint_materialList = postdata.paint_materialList.filter(item => item.material && item.material[1] ? true : false);

      postdata.expense_list = postdata.expense_list.filter(item => item.item_name ? true : false);
      postdata.paint_expenseList = postdata.paint_expenseList.filter(item => item.item_name ? true : false);

      postdata.expense = parseFloat(this.formOptions.data.expense_total_amount || 0) +
        parseFloat(this.formOptions.data.material_total_amount || 0) +
        parseFloat(this.formOptions.data.labor_total_amount || 0)+
        parseFloat(this.formOptions.data.parts_total_amount || 0) + 
        parseFloat(this.formOptions.data.packaging_total_amount || 0);


      postdata.paint_expense = parseFloat(this.formOptions.data.paintExpense_total_amount || 0) +
        parseFloat(this.formOptions.data.paintMaterial_total_amount || 0) +
        parseFloat(this.formOptions.data.paintLabor_total_amount || 0)+
        parseFloat(this.formOptions.data.parts_total_amount || 0) + 
        parseFloat(this.formOptions.data.packaging_total_amount || 0);


      postdata.amount = parseFloat(postdata.quantity || 0) * parseFloat(postdata.expense || 0);
      postdata.paint_amount = parseFloat(postdata.quantity || 0) * parseFloat(postdata.paint_expense || 0);

      this.formatDetailsData(postdata.fittingsList);
      this.formatDetailsData(postdata.partsList);
      this.formatDetailsData(postdata.packagingList);
      this.formatDetailsData(postdata.laborList);
      this.formatDetailsData(postdata.materialList);
      this.formatDetailsData(postdata.paint_laborList);
      this.formatDetailsData(postdata.paint_materialList);
      this.formatDetailsData(postdata.expense_list);
      this.formatDetailsData(postdata.paint_expenseList);


      this.$emit("update");

    },


    calculateRows({ detailsData, names, totalPrev }) {

      let totals = {};
      detailsData.forEach(row => {
        names.forEach(name => {

          let formula = row[name + '_formula'];
          if (!formula) {
            return;
          }
          row[name] = this.getExpressionValue({ row, exp: formula });
          totals[name] = totals[name] || 0;
          totals[name] = totals[name] + row[name];
        })
      });

      names.forEach(name => {
        let total = totals[name];
        this.formOptions.data[totalPrev + "_total_" + name] = total;

      });



    },

    totalRows({ detailsData, names, totalPrev }) {

      let totals = {};
      detailsData.forEach(row => {
        names.forEach(name => {

          totals[name] = totals[name] || 0;
          totals[name] = totals[name] + parseFloat(row[name] || 0);
        })
      });

      names.forEach(name => {
        let total = totals[name];
        this.formOptions.data[totalPrev + "_total_" + name] = total;

      });



    },

  },
  // 监听属性
  watch: {

  }
};

</script>


<style scoped lang="less">
.drawer-body {}

.formtabs .ant-tabs-tabpane {
  /* background: white; */
  padding: 12px;
}

.gridPanel {
  height: calc(100vh - 600px);
}


.imagePanel {
  cursor: pointer;
  padding: 10px;
  width: 100px;

  img {
    width: 80px;
    height: 80px;
  }
}

p.tip {
  padding: 12px 20px 12px 20px;
  margin: 8px 0;
  background-color: #f8f8f8;
  border-left: 4px solid #409eff;
}

.oplinks2 a {
  margin-left: 6px;
}

.mytable-footer .col-blue {
  background-color: #2db7f5 !important;
  color: #fff !important;
}

.groupbox {
  margin: 8px;
  border: 1px solid #ddd;
  padding: 10px;

  h3 {
    font-weight: bold;
  }
}
</style>
