<script src="../../api/apis/operationalModule.js"></script>
<template>
  <div class="recordContrast">
    <div class="left">
      <div class="leftTitle" style="display: flex;align-items: center;justify-content: space-between">
        <div>单据列表</div>
      </div>
      <div class="showList">
        <base-tree ref="baseTree" :isCenter="false" :isSaveBtn="false" :Allshow="false" :showCheckbox="false"
                   :menuData="billTypeList" @handleNodeClick="billTypeClickHandle" :treeProps="treeProps"
        ></base-tree>
      </div>
    </div>
    <div class="right" v-loading="tableLoading">
      <div class="topBox" style="margin-bottom: 10px">
        <div class="searchBox">
          <div style="margin-left: 10px;display: flex;align-items: center">
            单据号：
            <el-input v-model="searchObjTable.billCode" clearable></el-input>
          </div>
          <div style="margin-left: 10px;display: flex;align-items: center">
            单据日期起：
            <el-date-picker v-model="searchObjTable.timeStart" value-format="yyyy-MM-dd" type="date"></el-date-picker>
          </div>
          <div style="margin-left: 10px;display: flex;align-items: center">
            单据日期止：
            <el-date-picker v-model="searchObjTable.timeEnd" value-format="yyyy-MM-dd" type="date"></el-date-picker>
          </div>
          <div style="margin-left: 10px;display: flex;align-items: center">
            生成状态：
            <el-select
              class="w-100"
              v-model="searchObjTable.billStatus"
              filterable
              :clearable="true"
              placeholder="请选择"
            >
              <el-option
                v-for="(el, index) in [{label:'已生成',value:'Y'},{label:'未生成',value:'N'}]"
                :key="el.value"
                :label="el.label"
                :value="el.value"
              >
              </el-option>
            </el-select>
          </div>
          <div>
            <el-button type="primary" size="small" @click="getTableData">查询</el-button>
          </div>
        </div>
        <div style="display: flex;align-items: center;justify-content: flex-end;">
        </div>
      </div>
      <div class="leftTitle" style="display: flex;align-items: center;justify-content: space-between">
        <div>分录信息</div>
      </div>
      <div class="table">
        <base-table ref="customtable" :showIndex="false" :slotrow="true"
                    tableHeight="calc(50vh - 100px)" :tableData="tableData" :tableColumn="tableColumn"
                    @radioChange="radioChange" id="printMe"
        >
          <template #operation="{row}">
            <div class="btnList">
              <div class="settingBtn" @click="generateHandle(row)">
                生成
              </div>
            </div>
          </template>
        </base-table>
      </div>
      <!--      辅助核算-->
      <template v-if="this.selected.length">
        <div class="leftTitle"
             style="display: flex;align-items: center;justify-content: space-between;margin-top: 10px"
        >
          <div>辅助核算</div>
          <div>
            <el-button v-if="editFlag" size="mini" type="primary" @click="sonTableDataHandle">新增行</el-button>
          </div>
        </div>
        <div class="table">
          <base-table ref="customtable" :showIndex="false" :slotrow="false"
                      tableHeight="calc(50vh - 100px)" :tableData="this.selected[0].assistEntityList"
                      :tableColumn="assistTableColumn"
                      id="printMe"
          >
          </base-table>
        </div>
      </template>

    </div>
  </div>
</template>


<script>
import baseTree from '@/components/base/BaseMenuTree/index.vue'
import basePage from '@/components/base/basePage/index.vue'
import baseChoice from '@/components/base/baseChoice/index.vue'
import baseDialog from '@/components/base/BaseNewDialog/index.vue'
import baseRightDialog from '@/components/base/baseRightDialog'
import baseTable from '@/components/base/baseTable/index.vue'
import baseForm from '@/components/base/baseNewForm'

import {
  businessModuledeleteAPI,
  businessModuleMdmdeleteListAPI,
  businessModuleMdmSaveListAPI,
  businessModuleMdmupdateListAPI,
  businessModulequeryAllAPI,
  businessModuleUpdateAPI, influenceFactorCorrelationdeleteListAPI,
  influenceFactorCorrelationsaveListAPI,
  influenceFactorCorrelationupdateListAPI,
  influenceFactorqueryAllAPI,
  queryAllAPI, queryBdinfoListAPI,
  queryByIdAPI,
  queryByMdmIdAPI, queryCashFlowMapAPI,
  queryMdmAndFiledsByMdmIdAPI, queryMdmAndFiledssByMdmIdAPI,
  queryMdmsByModuleIdAPI
} from '@/api/apis/operationalModule'
import { GetLoginUserButtonsAPI } from '@/api/apis/buttonList'
import { queryModuleIncludeMdmListAPI } from '@/api/apis/relevance'
import { queryDataPagedByMapAPI, queryOrgBookVOAPI } from '@/api/apis/accountingSubject'
import {
  confTempSaveAPI,
  queryVoucherTypeAPI, tempcheckAbstractAPI,
  tempdeleteAPI, tempQueryAllAPI,
  tempqueryAllAPI,
  tempupdateAPI, typeDeleteAPI, typeSaveAPI, typeUpdateAPI
} from '@/api/apis/ItemEntryTemplate'
import { subjectClassificationqueryAllAPI } from '@/api/apis/classifyDefinition'
import { logqueryBillAPI } from '@/api/apis/businessVoucher'

export default {
  name: 'recordContrast',
  components: { baseDialog, baseChoice, basePage, baseTable, baseRightDialog, baseForm, baseTree },
  data() {
    return {
      searchObjTable: {},
      addTableColumn2: [],
      addTableData2: [],
      addTiTle: '',
      addDialog: false,
      //凭证相关
      voucherClickId: '',
      voucherClickName: '',
      voucherDialogShow: false,
      voucherList: [],
      subClassOptions: [],//会计科目下啦
      queryCashOptions: [],//现金流量下啦
      editFlag: false,
      verifyFlag: false,
      fixedValueClickRow: {},
      addPickKey: '',
      addTableData: [],
      addTableColumn: [
        {
          label: '档案',
          prop: 'mdmName'
        },
        {
          label: '字段',
          prop: 'fieldId'
        },
        {
          label: '备注',
          prop: 'remark'
        },
        {
          label: '操作',
          prop: 'operation',
          width: '100'
        }
      ],
      pkglbookOptions: [],
      treePropsproperty: {
        children: 'sublistMdmModuleDbFileds',
        label: 'chName',
        value: 'id'
      },
      voucher: '',//凭证
      voucherOptions: [],
      voucherClickObj: {},
      pkglbook: '',//账簿
      pkglbookClickObj: {},//账簿
      //公式相关是用字段
      propertyTree: [],
      clickRow: {},
      clickRowKey: '',
      activeTabs: '元数据属性',
      tabItem: ['元数据属性', '固定值'],
      arithmeticArr: ['+', '-', '*', '/', '->', '==', '(', ')', '<', '>', '<=', '>=', 'substr(,,)'],
      //公式text
      textarea: '',
      textareaEn: '',
      //公式相关是用字段
      nowBtns2: [],
      assistTableData: [],
      assistTableColumn: [
        {
          label: '辅助核算类型',
          prop: 'mdmName'
        },
        {
          label: '辅助核算内容',
          prop: 'fieldName'
        },
        {
          label: '备注',
          prop: 'remark'
        },
        {
          label: '操作',
          prop: 'operation',
          width: 60
        }
      ],
      billTypeClickCode: '',
      masterTableData: [],
      masterTableColumn: [
        {
          label: '基础数据编码',
          prop: 'bdcode'
        },
        {
          label: '基础数据名称',
          prop: 'bdname'
        }
      ],
      masterDialog: false,
      basicFormForm: [
        {
          elCol: [
            {
              label: '会计科目',
              prop: 'subjectClassificationId',
              tag: 'elSelect',
              span: 24,
              disabled: false,
              placeholder: '点击选择',
              options: []
            },
            {
              label: '币种',
              prop: 'currencyFieArr',
              tag: 'elCascader',
              span: 24,
              disabled: false,
              options: [],
              optionValue: 'id',
              optionLabel: 'remark',
              props: {
                children: 'sublistMdmModuleDbFileds',
                label: 'chName',
                value: 'id'
              }
            },
            {
              label: '摘要名称',
              prop: 'abstractRes',
              tag: 'elDialog',
              span: 24
            },
            {
              label: '汇率',
              prop: 'exchangeRate',
              tag: 'elInput',
              type: 'number',
              span: 24
            },
            {
              label: '借方数量字段',
              prop: 'jNumFieArr',
              tag: 'elCascader',
              span: 24,
              disabled: false,
              options: [],
              optionValue: 'id',
              optionLabel: 'remark',
              props: {
                children: 'sublistMdmModuleDbFileds',
                label: 'chName',
                value: 'id'
              }
            },
            {
              label: '借方原币金额字段',
              prop: 'jYbSumFieArr',
              tag: 'elCascader',
              span: 24,
              disabled: false,
              options: [],
              optionValue: 'id',
              optionLabel: 'remark',
              props: {
                children: 'sublistMdmModuleDbFileds',
                label: 'chName',
                value: 'id'
              }
            },
            {
              label: '借方本币金额字段',
              prop: 'jBbSumFieArr',
              tag: 'elCascader',
              span: 24,
              disabled: false,
              options: [],
              optionValue: 'id',
              optionLabel: 'remark',
              props: {
                children: 'sublistMdmModuleDbFileds',
                label: 'chName',
                value: 'id'
              }
            },
            {
              label: '贷方数量字段',
              prop: 'dNumFieArr',
              tag: 'elCascader',
              span: 24,
              disabled: false,
              options: [],
              optionValue: 'id',
              optionLabel: 'remark',
              props: {
                children: 'sublistMdmModuleDbFileds',
                label: 'chName',
                value: 'id'
              }
            },
            {
              label: '贷方原币金额字段',
              prop: 'dYbSumFieArr',
              tag: 'elCascader',
              span: 24,
              disabled: false,
              options: [],
              optionValue: 'id',
              optionLabel: 'remark',
              props: {
                children: 'sublistMdmModuleDbFileds',
                label: 'chName',
                value: 'id'
              }
            },
            {
              label: '贷方本币金额字段',
              prop: 'dBbSumFieArr',
              tag: 'elCascader',
              span: 24,
              disabled: false,
              options: [],
              optionValue: 'id',
              optionLabel: 'remark',
              props: {
                children: 'sublistMdmModuleDbFileds',
                label: 'chName',
                value: 'id'
              }
            },
            {
              label: '现金流量项目主键',
              prop: 'pkCashflow',
              tag: 'elSelect',
              span: 24,
              disabled: false,
              placeholder: '点击选择',
              options: []
            },
            {
              label: '备注',
              prop: 'remark',
              tag: 'elInput',
              span: 24,
              type: 'textarea'
            }
          ]
        }
      ],

      basicFormRulers: {
        subjectClassificationId: [
          { required: true, message: '请选择会计科目', trigger: 'change' }
        ],
        currencyFieArr: [
          { required: true, message: '请选择币种', trigger: 'change' }
        ],
        abstractRes: [
          { required: true, message: '请输入摘要名称', trigger: 'change' }
        ],
        exchangeRate: [
          { required: true, message: '请输入汇率', trigger: 'change' }
        ],
        jNumField: [
          { required: true, message: '请选择借方数量字段', trigger: 'change' }
        ],
        jYbSumField: [
          { required: true, message: '请选择借方原币金额字段', trigger: 'change' }
        ],
        jBbSumField: [
          { required: true, message: '请选择借方本币金额字段', trigger: 'change' }
        ],
        dNumField: [
          { required: true, message: '请选择贷方数量字段', trigger: 'change' }
        ],
        dYbSumField: [
          { required: true, message: '请选择贷方原币金额字段', trigger: 'change' }
        ],
        dBbSumField: [
          { required: true, message: '请选择贷方本币金额字段', trigger: 'change' }
        ],
        pkCashflow: [
          { required: true, message: '请选择现金流量项目主键', trigger: 'change' }
        ]

      },
      fixedValueForm: [
        {
          elCol: [
            {
              label: '参照',
              prop: 'factorName',
              tag: 'elDialog',
              span: 24,
              disabled: false,
              options: []
            },
            {
              label: '档案值',
              prop: 'recordData',
              tag: 'elDialog',
              span: 24,
              disabled: false,
              options: [],
              optionValue: 'id',
              optionLabel: 'remark',
              props: {
                children: 'sublistMdmModuleDbFileds',
                label: 'chName',
                value: 'id'
              }
            }
          ]
        }
      ],
      nowBtns: [],
      billTypeName: '',
      billTypeClickID: '',
      billTypeClickName: '',
      billTypeList: [
        {
          name: '人员对照',
          id: 1
        },
        {
          name: '人员对照',
          id: 2
        },
        {
          name: '人员对照',
          id: 3
        },
        {
          name: '人员对照',
          id: 4
        }
      ],
      searchObj: {},
      pageModel: {
        page: 1, //当前页码
        limit: 20, //每页显示多少
        prop7: '',
        propValue7: '',
        prop8: '',
        propValue8: ''
      },
      selected: [],
      treeSelect: [],
      tableColumn: [
        {
          label: '单据号',
          prop: 'billCode',
          width: 200
        },
        {
          label: '单据日期',
          prop: 'billDate',
          width: 251
        },
        {
          label: '生成状态',
          prop: 'billStatus',
          width: 300
        },
        {
          label: '推送信息',
          prop: 'pushInfo',
          width: 250
        },
        {
          label: '操作',
          prop: 'operation',
          width: '100'
        }
      ],
      tableData: [],
      tableLoading: false,
      dialogTitle: '新增',
      examineOperateDialog: false,
      statusView: false,
      passwordDialogShow: false,
      passwordDialogTitle: '新增',
      billTypeADDName: '',
      billTypeADDID: '',
      clickFatherObj: {},
      billDialog: false,
      billTableData: [],
      billtableColumn: [
        {
          label: '主数据名称',
          prop: 'mdmName'
        },
        {
          label: '主数据编码',
          prop: 'mdmCode'
        }
      ],
      billTreeActive: {},
      billTreeActiveFather: {},
      treeProps: {
        children: 'mdmModuleEntity',
        label: 'name'
      },
      billTreeProps: {
        children: 'sublistMdmModuleDbFileds',
        label: 'name'
      }

    }
  },
  methods: {
    //生成方法
    generateHandle(row){

    },
    async ixedValueFormelDialogClick(row) {
      if (row.label === '参照') {
        this.fixedValuelDialogClick(false)
      } else {
        if (!this.fixedValueClickRow.namefieldname) {
          this.$vmNews('请选择参照值')
          return
        }

        this.addTableColumn2 = [
          {
            label: '名称',
            prop: this.fixedValueClickRow.namefieldname
          },
          {
            label: '编码',
            prop: this.fixedValueClickRow.codefieldname
          }

        ]
        this.addDialog = true
        this.addTiTle = this.fixedValueClickRow.dbName
        this.pageModel.propValue7 = ''
        this.pageModel.propValue8 = ''
        this.pageModel.prop7 = ''
        this.pageModel.prop8 = ''
        this.getAddTableData()
      }
    },
    getTableAddList(val) {
      console.log(val, 'val', this.fixedValueClickRow)
      this.pageModel.propValue7 = val
      this.pageModel.propValue8 = val
      this.pageModel.prop7 = this.fixedValueClickRow.codefieldname
      this.pageModel.prop8 = this.fixedValueClickRow.namefieldname
      this.getAddTableData()
    },
    addPickDialog() {
      if (!this.$refs.baseChoice2.optionData[this.fixedValueClickRow.namefieldname]) {
        this.$vmNews('请选择一条数据')
        return
      }
      let obj = this.$refs.baseChoice2.optionData
      this.$set(this.$refs.fixedValueFormRefsName.ruleForm, 'recordData', obj[this.fixedValueClickRow.namefieldname])
      this.textarea += `@@${this.fixedValueClickRow.dbName}:${this.fixedValueClickRow.tablepkname}=${obj[this.fixedValueClickRow.tablepkname]}`
      // this.$set(this.clickRow, `factorid${this.clickNum}`, this.$refs.baseChoice.optionData[this.clickObj.key])
      // this.$set(this.clickRow, `factorname${this.clickNum}`, this.$refs.baseChoice.optionData[this.clickObj.labelKey])
      // this.$set(this.clickRow, `factorpk${this.clickNum}`, this.$refs.baseChoice.optionData['id'])
      // console.log(this.clickRow, 'this.clickRow')
      this.addDialog = false
    },
    async getAddTableData() {
      const res = await queryDataPagedByMapAPI({
        ...this.pageModel,
        pageNum: this.pageModel.page,
        pageSize: this.pageModel.limit,
        tablename: this.fixedValueClickRow.tablename,
        pkentityorg: this.pkglbookClickObj.pkentityorg
      })
      this.$refs.baseChoice2.pageModel.total = res.attribute.total
      this.addTableData2 = res.attribute.list
    },
    addonQuery(res, pageModel) {
      this.pageModel = pageModel
      this.getAddTableData()
    },
    //超级转换器！
    transitionRowHandle(item) {
      let obj = item
      let row = {
        props: {
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      }
      obj.subjectClassificationId = item.subjectClassificationId.toString()
      obj.currencyFieArr = item.currencyField ? this.searchIDHandle(item.currencyField, this.propertyTree, row) : []
      obj.jNumFieArr = item.jNumField ? this.searchIDHandle(item.jNumField, this.propertyTree, row) : []
      obj.jYbSumFieArr = item.jYbSumField ? this.searchIDHandle(item.jYbSumField, this.propertyTree, row) : []
      obj.jBbSumFieArr = item.jBbSumField ? this.searchIDHandle(item.jBbSumField, this.propertyTree, row) : []
      obj.dNumFieArr = item.dNumField ? this.searchIDHandle(item.dNumField, this.propertyTree, row) : []
      obj.dYbSumFieArr = item.dYbSumField ? this.searchIDHandle(item.dYbSumField, this.propertyTree, row) : []
      obj.dBbSumFieArr = item.dBbSumField ? this.searchIDHandle(item.dBbSumField, this.propertyTree, row) : []
      if (obj.assistEntityList) {
        obj.assistEntityList.forEach(ele => {
          ele.fieldArr = this.searchIDHandle(ele.fieldId, this.propertyTree, row)
        })
      }
    },
    sonTableDataHandle() {
      this.selected[0].assistEntityList.push({})
    },
    //凭证相关
    voucherCliclHandle(id, name) {
      this.voucherClickId = id
      this.voucherClickName = name
      this.resetTable()
    },
    voucherDialogDelHandle(item) {
      this.$confirm('确认删除吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        const res = await typeDeleteAPI({
          id: item.id
        })
        this.$vmNews('删除成功', 'success')
        this.getVoucherListHandle()
      })
    },
    voucherDialogEditHandle(item) {
      this.billTypeADDID = item.id
      this.billTypeADDName = item.name
      this.voucherDialogShow = true
      this.passwordDialogTitle = '编辑'
    },
    async getVoucherListHandle() {
      const res = await tempQueryAllAPI({
        mdmId: this.billTypeClickID
      })
      res.attribute.forEach(item => {

      })
      this.voucherList = res.attribute
      console.log(res, 'res')

    },
    async voucherDialogClickHandle() {
      if (!this.billTypeADDName) {
        this.$vmNews('请输入凭证类型')
        return
      }
      if (this.passwordDialogTitle === '新增') {
        const res = await typeSaveAPI({
          name: this.billTypeADDName,
          mdmId: this.billTypeClickID
        })
        this.$vmNews('保存成功', 'success')
        this.getVoucherListHandle()
      } else {
        const res = await typeUpdateAPI({
          id: this.billTypeADDID,
          name: this.billTypeADDName,
          mdmId: this.billTypeClickID
        })
        this.$vmNews('保存成功', 'success')
        this.getVoucherListHandle()
      }
      this.voucherDialogShow = false
    },
    leftAddHandle() {
      this.voucherDialogShow = true
      this.passwordDialogTitle = '新增'
      this.billTypeADDName = ''
      this.billTypeADDID = ''
    },
    //保存方法
    async saveOperate() {
      let flag = this.tableData.some((item, index) => {
        return Object.keys(this.basicFormRulers).some((el) => {
          if (!item[el] || item[el] === []) {
            this.$vmNews(`第${index + 1}行${this.basicFormRulers[el][0].message}`, 'error')
            return true
          }
        })
      })
      console.log(this.tableData, 'this.tableData')
      const res = await confTempSaveAPI(this.tableData)
      this.$vmNews('保存成功', 'success')
      this.editFlag = false
      this.getTableData()
    },
    //关闭方法
    closeOperate() {
      this.editFlag = false
      this.getTableData()
    },
    //现金项目
    cashFlowOptionsChangeHandle(val, row) {
      if (val) {
        let obj = this.queryCashOptions.find((item) => {
          return item.id == val
        })
        this.$set(row, 'subjectClassificationId', obj.id)
        this.$set(row, 'subjectClassificationCode', obj.code)
        this.$set(row, 'subjectClassificationName', obj.name)
      }
    },
    //币种修改事件
    currencyFieArrChangeHandle(val, row) {
      let obj = this.getIdHandle(this.propertyTree, val[val.length - 1])
      let valLabel = this.cascaderChangeHandle(val, this.propertyTree, {
        props: {
          checkStrictly: '',
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      })
      this.$set(row, 'currencyField', val[val.length - 1])
      this.$set(row, 'currencyFieldName', `$${valLabel}`)
      this.$set(row, 'currencyFieldCode', obj.enName)
    },
    //借方数量修改事件
    jNumFieArrChangeHandle(val, row) {
      let obj = this.getIdHandle(this.propertyTree, val[val.length - 1])
      let valLabel = this.cascaderChangeHandle(val, this.propertyTree, {
        props: {
          checkStrictly: '',
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      })
      this.$set(row, 'jNumField', val[val.length - 1])
      this.$set(row, 'jNumFieldName', `$${valLabel}`)
      this.$set(row, 'jNumFieldCode', obj.enName)
    },
    //借方原币金额修改事件
    jYbSumFieArrChangHandle(val, row) {
      let obj = this.getIdHandle(this.propertyTree, val[val.length - 1])
      let valLabel = this.cascaderChangeHandle(val, this.propertyTree, {
        props: {
          checkStrictly: '',
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      })
      this.$set(row, 'jYbSumField', val[val.length - 1])
      this.$set(row, 'jYbSumFieldName', `$${valLabel}`)
      this.$set(row, 'jYbSumFieldCode', obj.enName)
    },
    //借方本币金额修改事件
    jBbSumFieArrChangeHandle(val, row) {
      let obj = this.getIdHandle(this.propertyTree, val[val.length - 1])
      let valLabel = this.cascaderChangeHandle(val, this.propertyTree, {
        props: {
          checkStrictly: '',
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      })
      this.$set(row, 'jBbSumField', val[val.length - 1])
      this.$set(row, 'jBbSumFieldName', `$${valLabel}`)
      this.$set(row, 'jBbSumFieldCode', obj.enName)
    },
    //贷方数量修改事件
    dNumFieArrChangeHandle(val, row) {
      let obj = this.getIdHandle(this.propertyTree, val[val.length - 1])
      let valLabel = this.cascaderChangeHandle(val, this.propertyTree, {
        props: {
          checkStrictly: '',
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      })
      this.$set(row, 'dNumField', val[val.length - 1])
      this.$set(row, 'dNumFieldName', `$${valLabel}`)
      this.$set(row, 'dNumFieldCode', obj.enName)
    },
    //贷方原币金额修改事件
    dYbSumFieArrChangeHandle(val, row) {
      let obj = this.getIdHandle(this.propertyTree, val[val.length - 1])
      let valLabel = this.cascaderChangeHandle(val, this.propertyTree, {
        props: {
          checkStrictly: '',
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      })
      this.$set(row, 'dYbSumField', val[val.length - 1])
      this.$set(row, 'dYbSumFieldName', `$${valLabel}`)
      this.$set(row, 'dYbSumFieldCode', obj.enName)
    },
    //贷方本币金额修改事件
    dBbSumFieArrChangeHandle(val, row) {
      let obj = this.getIdHandle(this.propertyTree, val[val.length - 1])
      let valLabel = this.cascaderChangeHandle(val, this.propertyTree, {
        props: {
          checkStrictly: '',
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      })
      this.$set(row, 'dBbSumField', val[val.length - 1])
      this.$set(row, 'dBbSumFieldName', `$${valLabel}`)
      this.$set(row, 'dBbSumFieldCode', obj.enName)
    },
    //验证接口
    async verifyFlagHandle() {
      const res = await tempcheckAbstractAPI({
        abstractRes: this.textarea
      })
      if (res.flag === true) {
        this.$vmNews('验证通过', 'success')
        this.verifyFlag = true
      }
    },
    //删除新增接口
    deleteRowHandle(row) {
      this.selected[0].assistEntityList.splice(row.index, 1)
    },
    cascaderChangeHandle(val, options, row = {}) {
      let valLabel = ''
      let obj = {}

      function getLabelPath(el, data, path = []) {
        for (let i = 0; i < data.length; i++) {
          const item = data[i]
          path.push(item[row.props.label])

          if (el === item[row.props.value]) {
            obj = item
            return [...path] // 找到了
          }

          if (item[row.props.children] && item[row.props.children].length > 0) {
            const result = getLabelPath(el, item[row.props.children], path)
            if (result) return result
          }

          path.pop() // 回退
        }

        return null
      }

      // 🧠 只处理最后一个值，不遍历 val（val 是一个“路径数组”）
      const lastValue = Array.isArray(val) ? val[val.length - 1] : val
      const labelPath = getLabelPath(lastValue, options)
      valLabel = labelPath ? labelPath.join('.') : ''
      return valLabel
    },
    //找id
    searchIDHandle(val, options, row = {}) {
      console.log(val, options, row, '看看内部')
      let valPath = ''
      let obj = null

      function getValuePath(el, data, path = []) {
        for (let i = 0; i < data.length; i++) {
          const item = data[i]
          path.push(item[row.props.value])

          if (el === String(item[row.props.value])) {
            obj = item
            return [...path] // 找到就返回 path
          }

          if (item[row.props.children] && item[row.props.children].length > 0) {
            const result = getValuePath(el, item[row.props.children], path)
            if (result) return result
          }

          path.pop() // 回退
        }
        return null
      }

      const targetValue = Array.isArray(val) ? val[val.length - 1] : val
      const valuePath = getValuePath(targetValue, options)
      valPath = valuePath ? valuePath : []
      return valPath
    },
    fieldIdChangeHandle(val, row) {
      let obj = this.getIdHandle(this.propertyTree, val[val.length - 1])
      console.log(obj, 'obj')
      this.$set(row, 'fieldId', val[val.length - 1])
      this.$set(row, 'fieldCode', obj.enName)
      let valLabel = this.cascaderChangeHandle(val, this.propertyTree, {
        props: {
          checkStrictly: '',
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      })
      console.log(valLabel, 'valLabel')
      this.$set(row, 'fieldName', valLabel)

    },
    getIdHandle(arr, id) {
      for (let item of arr) {
        if (item.id === id) {
          return item
        }
        if (item.sublistMdmModuleDbFileds && item.sublistMdmModuleDbFileds.length > 0) {
          const found = this.getIdHandle(item.sublistMdmModuleDbFileds, id)
          if (found) return found
        }
      }
      return null
    },
    mdmNameEldialog(row) {
      this.fixedValuelDialogClick(row)
    },
    AddCascaderChange(val, options, row, valLabel, obj) {
      //币种
      if (row.prop === 'currencyFieArr') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'currencyField', val[val.length - 1])
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'currencyFieldName', `$${valLabel}`)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'currencyFieldCode', obj.enName)
      }
      //借方数量字段
      if (row.prop === 'jNumFieArr') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jNumField', val[val.length - 1])
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jNumFieldName', `$${valLabel}`)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jNumFieldCode', obj.enName)
      }
      //   借方原币金额字段
      if (row.prop === 'jYbSumFieArr') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jYbSumField', val[val.length - 1])
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jYbSumFieldName', `$${valLabel}`)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jYbSumFieldCode', obj.enName)
      }
      //   借方本币金额字段
      if (row.prop === 'jBbSumFieArr') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jBbSumField', val[val.length - 1])
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jBbSumFieldName', `$${valLabel}`)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'jBbSumFieldCode', obj.enName)
      }
      //   贷方数量字段
      if (row.prop === 'dNumFieArr') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dNumField', val[val.length - 1])
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dNumFieldName', `$${valLabel}`)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dNumFieldCode', obj.enName)
      }
      //   贷方原币金额字段
      if (row.prop === 'dYbSumFieArr') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dYbSumField', val[val.length - 1])
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dYbSumFieldName', `$${valLabel}`)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dYbSumFieldCode', obj.enName)
      }
      //   贷方本币金额字段
      if (row.prop === 'dBbSumFieArr') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dBbSumField', val[val.length - 1])
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dBbSumFieldName', `$${valLabel}`)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'dBbSumFieldCode', obj.enName)
      }

    },
    //新增弹窗所有下啦获取
    async addGetSelectHandle() {
      this.tableLoading = true
      //会计科目
      const res = await subjectClassificationqueryAllAPI({
        aeConfModuleId: this.clickFatherObj.data.aeConfModuleId,
        pkglorgbook: this.pkglbookClickObj.pkglorgbook
      })
      res.attribute.forEach(item => {
        item.label = item.name
        item.value = item.id
      })
      this.subClassOptions = res.attribute
      //币种数据
      const res2 = await queryMdmAndFiledssByMdmIdAPI({
        mdmId: this.billTypeClickID
      })
      res2.attribute.forEach(item => {
        item.chName = item.remark
      })
      this.treeSelect = res2.attribute
      //现金流量项目
      const res3 = await queryCashFlowMapAPI({})
      res3.attribute.forEach((el) => {
        el.label = `[${el.cfitemcode}] ${el.cfitemname}`
        el.value = el.pkCashflow
      })
      this.queryCashOptions = res3.attribute
      const res4 = await queryMdmAndFiledssByMdmIdAPI({
        mdmId: this.billTypeClickID
      })
      res4.attribute.forEach(item => {
        item.chName = item.remark
      })
      this.propertyTree = res4.attribute
      this.tableLoading = false
    },
    //凭证类别修改方法
    voucherChangeHandle(val) {
      this.voucherOptions.find(item => {
        if (item.value == val) {
          this.voucherClickObj = item
          console.log(this.voucherClickObj, 'voucherClickObj')
        }
      })
      this.resetTable()
    },
    //账簿修改方法
    async changepkglbookHandle(val) {
      this.pkglbookOptions.find(item => {
        if (item.value == val) {
          this.pkglbookClickObj = item
        }
      })
      this.resetTable()
    },
    propertyClick(a, b, c) {
      console.log(a, b, c)
      let val = []
      this.getStr(val, b)
      this.textarea += `@@$${val.reverse().join('.')}`
    },
    getStr(arr, node) {
      arr.push(node.data.chName)
      if (node.parent && node.parent.data.chName) {
        this.getStr(arr, node.parent)
      }
    },
    async getTableList(val) {
      this.openLoading()
      const res = await queryBdinfoListAPI({
        bdname: val
      })
      this.masterTableData = res.attribute
      this.$nextTick(() => {
        this.$refs.baseChoice.optionData = ''
        this.$refs.baseChoice.$refs.customtable.clearRadioIndex()
      })

    },
    async fixedValuelDialogClick(row = false, index) {
      this.fixedValueClickRow = row
      this.masterDialog = true
      this.openLoading()
      const res = await queryBdinfoListAPI({})
      this.masterTableData = res.attribute
    },
    fixedValueOnSelect() {

    },
    switchTabs(item) {
      if (item === this.activeTabs) return
      this.activeTabs = item
    },
    arithmeticItemPush(item) {
      this.textarea += item
    },
    clickBillTree(row, item) {
      console.log(item, '??')
      this.billTreeActive = row
      this.billTreeActiveFather = item
    },
    billClickHandle() {
      if (!this.billTreeActive.id) {
        this.$vmNews('请选择单据项目')
        return
      }
      this.$set(this.$refs.basicFormRefsName.ruleForm, 'mappingFieldName', `$${this.billTreeActiveFather.name}.${this.billTreeActive.name}`)
      this.$set(this.$refs.basicFormRefsName.ruleForm, 'mappingFieldId', this.billTreeActive.id)
      this.$set(this.$refs.basicFormRefsName.ruleForm, 'mappingFieldCode', this.billTreeActive.enName)
      this.billDialog = false
    },
    //档案值改变方法
    cascaderChange(val, options, row, valLabel) {
      console.log(valLabel, 'valLabel')
      this.textarea = this.textarea + '@@$' + valLabel
    },
    async masterPickDialog() {
      if (!this.$refs.baseChoice.optionData.bdname) {
        this.$vmNews('请选择映射档案')
        return
      }
      let row = this.$refs.baseChoice.optionData

      if (this.fixedValueClickRow) {
        this.$set(this.fixedValueClickRow, 'mdmId', row.mdmId)
        this.$set(this.fixedValueClickRow, 'mdmCode', row.mdmCode)
        this.$set(this.fixedValueClickRow, 'mdmName', row.mdmName)

      } else {
        this.fixedValueClickRow = row
        const res = await queryMdmAndFiledssByMdmIdAPI({
          mdmId: row.mdmId
        })
        const res2 = await queryBdinfoListAPI({
          pkBdinfo: row.pkBdinfo
        })
        res.attribute.forEach(item => {
          item.chName = item.remark
        })
        console.log(res2, '2')
        this.$set(this.fixedValueClickRow, 'tablepkname', res2.attribute[0].tablepkname)
        this.$set(this.fixedValueClickRow, 'codefieldname', res2.attribute[0].codefieldname)
        this.$set(this.fixedValueClickRow, 'namefieldname', res2.attribute[0].namefieldname)
        this.$set(this.fixedValueClickRow, 'tablename', res2.attribute[0].tablename)
        this.$set(this.$refs.fixedValueFormRefsName.ruleForm, 'factorName', row.bdname)
        this.$set(this.$refs.fixedValueFormRefsName.ruleForm, 'recordData', '')
        this.fixedValueForm[0].elCol[1].options = res.attribute
      }

      // this.$set(this.$refs.basicFormRefsName.ruleForm, 'factorCode', row.factorCode)
      this.masterDialog = false
    },
    async elDialogClick(row, index) {
      if (row.label === '摘要名称') {
        this.rightAddHandle(false, this.$refs.basicFormRefsName.ruleForm.abstractRes)
      }

    },
    delRightTitle(item) {
      this.$confirm('确认删除吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        const res = await businessModuledeleteAPI({
          id: item.id
        })
        if (res.status == 200) {
          this.$vmNews('删除成功', 'success')
          this.billTypeClickName = ''
          this.billTypeClickID = ''
          this.billTypeClickCode = ''
          this.getLeftList()
          this.resetTable()
        }
      })
    },
    //摘要公式编辑方法
    async rightAddHandle(row = false, str = '', key) {
      this.verifyFlag = false
      this.passwordDialogShow = true
      this.fixedValueClickRow = {}
      if (str || str === 0) {
        this.textarea = str
      } else {
        this.textarea = ''
      }

      this.textareaEn = ''
      this.propertyTree = []
      this.activeTabs = '元数据属性'
      if (row) {
        this.clickRow = row
        this.clickRowKey = key
      } else {
        this.clickRow = false
      }
      const res = await queryMdmAndFiledssByMdmIdAPI({
        mdmId: this.billTypeClickID
      })
      console.log(res, 'rerere')
      res.attribute.forEach(item => {
        item.chName = item.remark
      })
      this.propertyTree = res.attribute
    },
    //公式确认事件
    async passwordChangeHandle() {
      if (!this.verifyFlag) {
        this.$vmNews('请通过验证')
        return
      }
      if (!this.textarea) {
        this.$vmNews('请输入公式')
        return
      }
      if (this.clickRow) {
        this.$set(this.clickRow, this.clickRowKey, this.textarea)
        this.passwordDialogShow = false
      } else {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'abstractRes', this.textarea)
        this.passwordDialogShow = false
      }
    },
    //获取下啦信息
    async getSelect() {
      //账簿信息
      const res2 = await queryOrgBookVOAPI({})
      console.log(res2, 'res2')
      res2.attribute.forEach(el => {
        el.label = el.glorgbookname
        el.value = el.pkentityorg
      })
      this.pkglbookOptions = res2.attribute
      //拿凭证类别
      const res3 = await queryVoucherTypeAPI({})
      res3.attribute.forEach(el => {
        el.label = el.name
        el.value = el.id
      })
      this.voucherOptions = res3.attribute
      return
      const res = await GetBillListAPI({
        page: 1,
        limit: 9999
      })
      res.data[1].forEach(item => {
        item.label = item.appName
        item.value = item.appID
      })
      this.basicFormForm[0].elCol[2].options = res.data[1]
      this.basicFormForm[0].elCol[6].options = res.data[1]
    },
    async getLeftList() {
      this.openLoading()
      const res = await queryModuleIncludeMdmListAPI({})
      res.attribute.forEach((el) => {
        el.fatherRow = true
        el.name = el.aeConfModuleName
        el.id = el.aeConfModuleId
        el.mdmModuleEntity.forEach(item => {
          item.name = item.mdmName
        })
      })
      this.billTypeList = res.attribute
    },
    subClassOptionsChangeHandle(val, row) {
      if (val) {
        let obj = this.subClassOptions.find((item) => {
          return item.id == val
        })
        this.$set(row, 'subjectClassificationId', obj.id)
        this.$set(row, 'subjectClassificationCode', obj.code)
        this.$set(row, 'subjectClassificationName', obj.name)
      }
    },
    onSelect(val, index, indexRow, obj, row, form) {
      //会计科目
      if (row.prop === 'subjectClassificationId') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'subjectClassificationId', obj.id)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'subjectClassificationCode', obj.code)
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'subjectClassificationName', obj.name)
      }
      if (row.prop === 'targetAppID') {
        this.$set(this.$refs.basicFormRefsName.ruleForm, 'targetAppCode', obj.appCode)
      }
    },
    async handleConfirmClick() {
      try {
        await this.$refs.basicFormRefsName.$refs.ruleForm.validate()

      } catch (err) {
        this.$vmNews('请输入必填项')
        return
      }
      let form = this.$refs.basicFormRefsName.ruleForm
      if (this.dialogTitle === '编辑') {
        this.openLoading()
        const res = await tempupdateAPI(
          {
            ...this.$refs.basicFormRefsName.ruleForm,
            assistEntityList: this.addTableData
          }
        )
        if (res.status == 200) {
          this.$vmNews('保存成功', 'success')
          this.examineOperateDialog = false
          this.resetTable()
        }
      } else {
        this.openLoading()
        const res = await confTempSaveAPI(
          {
            ...this.$refs.basicFormRefsName.ruleForm,
            assistEntityList: this.addTableData
          }
        )
        if (res.status == 200) {
          this.$vmNews('保存成功', 'success')
          this.examineOperateDialog = false
          this.resetTable()
        }
      }

    },
    pageChange(model) {
      this.pageModel.page = model.page
      this.pageModel.limit = model.limit
      this.getTableData()
    },
    async getTableData() {
      this.assistTableData = []
      if (!this.billTypeClickID) return
      const res = await logqueryBillAPI({
        ...this.searchObjTable,
        mdmId: this.billTypeClickID
      })
      this.tableData = res.attribute
      this.$nextTick(() => {
        this.$refs.customtable.clearRadioIndex()
        this.$refs.customtable.clearSelection()
        this.selected = []
      })
    },
    resetTable() {
      this.tableData = []
      this.pageModel.page = 1
      this.selected = []
      this.getTableData()
    },
    // 点击某条数据
    radioChange(val) {
      this.selected = []
      this.selected.push(val)
      console.log(val.assistEntityList, '?val.assistEntityList')
      let row = {
        props: {
          children: 'sublistMdmModuleDbFileds',
          label: 'chName',
          value: 'id'
        }
      }
      val.assistEntityList.forEach(item => {
        console.log(item.fieldId, 'item.fieldId')
        item.fieldArr = item.fieldId ? this.searchIDHandle(item.fieldId, this.propertyTree, row) : []
        console.log(item.fieldArr, '?fieldArr', item, this.propertyTree)
      })
      this.assistTableData = val.assistEntityList ? val.assistEntityList : []

    },
    // 删除
    delOperate() {
      if (!this.selected.length) {
        this.$vmNews('请至少选择一条数据')
        return
      }
      this.$confirm('确认删除吗?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(async() => {
        if (this.selected[0].id) {
          const res = await tempdeleteAPI({
            id: this.selected[0].id
          })
          if (res.status == 200) {
            this.$vmNews('删除成功', 'success')
          }
        }
        this.tableData.splice(this.selected[0].index, 1)

      })
    },
    // 编辑
    async editOperate() {
      if (!this.billTypeClickName) {
        this.$vmNews('请选择单据列表')
        return
      }
      if (!this.pkglbook) {
        this.$vmNews('请选择账簿')
        return
      }
      if (!this.voucher) {
        this.$vmNews('请选择凭证')
        return
      }
      await this.addGetSelectHandle()
      this.tableData.forEach(item => {
        this.transitionRowHandle(item)
      })
      this.editFlag = true
      return
      if (!this.selected.length) {
        this.$vmNews('请至少选择一条数据')
        return
      }
      this.dialogTitle = '编辑'
      this.examineOperateDialog = true
      this.$nextTick(() => {
        let form = this.selected[0]
        let row = {
          props: {
            children: 'sublistMdmModuleDbFileds',
            label: 'chName',
            value: 'id'
          }
        }
        this.$refs.basicFormRefsName.ruleForm = {
          ...this.selected[0],
          subjectClassificationId: form.subjectClassificationId.toString(),
          currencyFieArr: form.currencyField ? this.searchIDHandle(form.currencyField, this.propertyTree, row) : [],
          jNumFieArr: form.jNumField ? this.searchIDHandle(form.jNumField, this.propertyTree, row) : [],
          jYbSumFieArr: form.jYbSumField ? this.searchIDHandle(form.jYbSumField, this.propertyTree, row) : [],
          jBbSumFieArr: form.jBbSumField ? this.searchIDHandle(form.jBbSumField, this.propertyTree, row) : [],
          dNumFieArr: form.dNumField ? this.searchIDHandle(form.dNumField, this.propertyTree, row) : [],
          dYbSumFieArr: form.dYbSumField ? this.searchIDHandle(form.dYbSumField, this.propertyTree, row) : [],
          dBbSumFieArr: form.dBbSumField ? this.searchIDHandle(form.dBbSumField, this.propertyTree, row) : []
        }
        console.log(this.$refs.basicFormRefsName.ruleForm, 'this.$refs.basicFormRefsName.ruleForm')
        if (this.selected[0].assistEntityList) {
          this.selected[0].assistEntityList.forEach(item => {
            item.fieldArr = item.fieldId ? this.searchIDHandle(item.fieldId, this.propertyTree, row) : []
          })
          this.addTableData = this.selected[0].assistEntityList
        }
      })
    },
    //新增行新增
    addData() {
      let obj = {}
      this.addTableColumn.forEach(item => {
        obj[item.prop] = ''
      })
      this.addTableData.push(obj)
    },
    //新增方法
    Operate() {
      let obj = {
        exchangeRate: '',
        remark: '',
        mdmName: this.billTypeClickName,
        mdmId: this.billTypeClickID,
        mdmCode: this.billTypeClickCode,
        voucherTypeId: this.voucher,
        voucherTypeName: this.voucherClickObj.name,
        pkGlorgbook: this.pkglbookClickObj.pkglorgbook,
        glOrgbookCode: this.pkglbookClickObj.glorgbookcode,
        glOrgbookName: this.pkglbookClickObj.glorgbookname,
        currencyFieArr: [],
        assistEntityList: [],
        templateTypeId: this.voucherClickId
      }
      this.tableData.push(obj)
      return
    },
    refresh() {
      this.searchObj = {}
    },
    //获取按钮（头部）
    async buttonPermissions() {
      let arr = [
        {
          'id': '297c66371d484f5ea163c70b1c3944a7',
          'create_user_id': '1',
          'create_time': '2025-05-30 11:28:56',
          'modify_time': '2025-05-30 11:28:56',
          'modify_user_id': '1',
          'org_id': '0',
          'companyId': '0',
          'sts': 'Y',
          'start': null,
          'limit': null,
          'offset': null,
          'sort': null,
          'order': null,
          'dir': null,
          'rows': null,
          'page': null,
          'dialect_type': null,
          'pageNum': null,
          'pageSize': null,
          'sorts': 1,
          'dataSourceCode': 'master',
          'code': '1',
          'nameCh': '新增',
          'nameEn': 'Operate',
          'menuId': '936df6d1cd7e4f9ba4c972e0f84b5ab4',
          'iconName': 'el-icon-plus',
          'styles': 'primary',
          'btnFunction': 'Operate',
          'remark': null,
          'userId': null,
          'check': false
        },
        {
          'id': 'ad708a5f65fb42d49e203a230096f43e',
          'create_user_id': '1',
          'create_time': '2025-05-30 11:29:22',
          'modify_time': '2025-05-30 11:29:22',
          'modify_user_id': '1',
          'org_id': '0',
          'companyId': '0',
          'sts': 'Y',
          'start': null,
          'limit': null,
          'offset': null,
          'sort': null,
          'order': null,
          'dir': null,
          'rows': null,
          'page': null,
          'dialect_type': null,
          'pageNum': null,
          'pageSize': null,
          'sorts': 2,
          'dataSourceCode': 'master',
          'code': '2',
          'nameCh': '编辑',
          'nameEn': 'editOperate',
          'menuId': '936df6d1cd7e4f9ba4c972e0f84b5ab4',
          'iconName': 'el-icon-edit',
          'styles': 'primary',
          'btnFunction': 'editOperate',
          'remark': null,
          'userId': null,
          'check': false
        },
        {
          'id': 'cca6382b141e4816833581db63c768da',
          'create_user_id': '1',
          'create_time': '2025-05-30 11:29:39',
          'modify_time': '2025-05-30 11:29:39',
          'modify_user_id': '1',
          'org_id': '0',
          'companyId': '0',
          'sts': 'Y',
          'start': null,
          'limit': null,
          'offset': null,
          'sort': null,
          'order': null,
          'dir': null,
          'rows': null,
          'page': null,
          'dialect_type': null,
          'pageNum': null,
          'pageSize': null,
          'sorts': 3,
          'dataSourceCode': 'master',
          'code': '3',
          'nameCh': '删除',
          'nameEn': 'delOperate',
          'menuId': '936df6d1cd7e4f9ba4c972e0f84b5ab4',
          'iconName': 'el-icon-delete',
          'styles': 'danger',
          'btnFunction': 'delOperate',
          'remark': null,
          'userId': null,
          'check': false
        }
      ]
      let arr2 = [
        {
          'id': '297c66371d484f5ea163c70b1c3944a7',
          'create_user_id': '1',
          'create_time': '2025-05-30 11:28:56',
          'modify_time': '2025-05-30 11:28:56',
          'modify_user_id': '1',
          'org_id': '0',
          'companyId': '0',
          'sts': 'Y',
          'start': null,
          'limit': null,
          'offset': null,
          'sort': null,
          'order': null,
          'dir': null,
          'rows': null,
          'page': null,
          'dialect_type': null,
          'pageNum': null,
          'pageSize': null,
          'sorts': 1,
          'dataSourceCode': 'master',
          'code': '1',
          'nameCh': '新增',
          'nameEn': 'OperateAssist',
          'menuId': '936df6d1cd7e4f9ba4c972e0f84b5ab4',
          'iconName': 'el-icon-plus',
          'styles': 'primary',
          'btnFunction': 'Operate',
          'remark': null,
          'userId': null,
          'check': false
        },
        {
          'id': 'ad708a5f65fb42d49e203a230096f43e',
          'create_user_id': '1',
          'create_time': '2025-05-30 11:29:22',
          'modify_time': '2025-05-30 11:29:22',
          'modify_user_id': '1',
          'org_id': '0',
          'companyId': '0',
          'sts': 'Y',
          'start': null,
          'limit': null,
          'offset': null,
          'sort': null,
          'order': null,
          'dir': null,
          'rows': null,
          'page': null,
          'dialect_type': null,
          'pageNum': null,
          'pageSize': null,
          'sorts': 2,
          'dataSourceCode': 'master',
          'code': '2',
          'nameCh': '编辑',
          'nameEn': 'editOperateAssist',
          'menuId': '936df6d1cd7e4f9ba4c972e0f84b5ab4',
          'iconName': 'el-icon-edit',
          'styles': 'primary',
          'btnFunction': 'editOperate',
          'remark': null,
          'userId': null,
          'check': false
        },
        {
          'id': 'cca6382b141e4816833581db63c768da',
          'create_user_id': '1',
          'create_time': '2025-05-30 11:29:39',
          'modify_time': '2025-05-30 11:29:39',
          'modify_user_id': '1',
          'org_id': '0',
          'companyId': '0',
          'sts': 'Y',
          'start': null,
          'limit': null,
          'offset': null,
          'sort': null,
          'order': null,
          'dir': null,
          'rows': null,
          'page': null,
          'dialect_type': null,
          'pageNum': null,
          'pageSize': null,
          'sorts': 3,
          'dataSourceCode': 'master',
          'code': '3',
          'nameCh': '删除',
          'nameEn': 'delOperateAssist',
          'menuId': '936df6d1cd7e4f9ba4c972e0f84b5ab4',
          'iconName': 'el-icon-delete',
          'styles': 'danger',
          'btnFunction': 'delOperate',
          'remark': null,
          'userId': null,
          'check': false
        }
      ]
      arr.forEach((el) => {
        el.menuName = el.nameCh
        el.icon = el.icoName
        el.type = el.style
        el.name = el.nameCN
      })
      arr2.forEach((el) => {
        el.menuName = el.nameCh
        el.icon = el.icoName
        el.type = el.style
        el.name = el.nameCN
      })
      this.nowBtns = arr
      this.nowBtns2 = arr2
    },
    billTypeClickHandle(item, row) {
      if (item.fatherRow) {
        return
      }
      this.billTypeClickID = item.id
      this.billTypeClickName = item.name
      this.billTypeClickCode = item.mdmCode
      this.clickFatherObj = row.parent
      this.voucherClickId = ''
      this.getVoucherListHandle()
      this.resetTable()
    },
    billTreeClick(item, row) {
      console.log(row, '?')
      if (item.fatherRow) {
        return
      }
      this.billTreeActive = item
      this.billTreeActiveFather = row
    },
    //头部按钮统一调用方法
    clickSave(item) {
      this[item.btnFunction]()
    }
  },
  mounted() {
    this.buttonPermissions()
    this.getLeftList()
    // this.getTableData()
    this.getSelect()
  },
  watch: {
    textarea() {
      this.verifyFlag = false
    }
  }
}
</script>


<style scoped lang="scss">
.tabs {
  width: 200px;
  display: flex;
  align-items: center;
  background: #f5f5f5;
  padding: 2px 5px;

  .tabItem {
    flex: 1;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    padding: 5px 10px;
    text-align: center;
  }

  .acivte {
    background: #fff;
    color: #3876ee;
  }
}

.arithmeticList {
  display: flex;
  align-content: center;
  flex-wrap: wrap;

  .arithmeticItem {
    border-radius: 4px;
    width: 78px;
    margin-bottom: 5px;
    margin-right: 5px;
    height: 50px;
    background-color: #f5f5f5;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
  }
}

.addDialog {
  display: flex;

  .nameTitle {
    padding: 10px;
    font-size: 14px;
    color: #333;
    margin-right: 10px;
    width: 180px;
    text-align: right;
  }

  .left {
    flex: 1;
  }

  .right {
    margin-left: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;

    .document {
      margin-top: 10px;
      height: 300px;
      width: 100%;
      //background-color: pink;
    }
  }
}

.recordContrast {
  display: flex;
  overflow: hidden;
  background-color: #f5f5f5;

  .left {
    width: 270px;
    padding: 10px;
    background-color: #fff;
    border-radius: 4px;
    margin-right: 5px;

    .leftTitle {
      color: #333;
      font-size: 18px;
      font-weight: 500;
    }
  }

  .right {
    overflow: hidden;
    flex: 1;
    padding: 10px;
    background-color: #fff;
    border-radius: 4px;

    .topBox {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .searchBox {
        display: flex;
        align-items: center;

        > div {
          margin-right: 10px;
        }
      }
    }

    .table {
      margin-top: 10px;
    }
  }
}

.searchBtn {
  display: flex;
  align-items: center;
  justify-content: space-around;
  margin-top: 20px;

  .input {
    flex: 1;
    margin-right: 5px;
  }
}

.showList {
  height: calc(100vh - 600px);
  overflow: auto;
  margin-top: 10px;

  .showItem {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 13px;

    .icon {
      display: none;
    }

    &:hover {
      background-color: #ebeced;
      border-radius: 4px;

      .icon {
        display: block !important;
      }
    }

    &.active {
      background-color: #ebeced !important;
    }
  }

  .showItemSon {
    //display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px 10px 40px;
    cursor: pointer;

    .icon {
      display: none;
    }

    &:hover {
      background-color: #ebeced;
      border-radius: 4px;

      .icon {
        display: block !important;
      }
    }

    &.active {
      background-color: #ebeced !important;
    }
  }
}

.elDialog {
  display: flex;
  width: 100%;
  /* width: calc(100% - 14px);1 */
  align-items: center;
  justify-content: space-between;
  border: 1px solid #DCDFE6;
  border-radius: 4px;
  padding: 0 15px;
  cursor: pointer;
  height: 40px !important;

  i {
    color: #c0c4cc
  }
}
</style>
