import { initDictionary, resultExtendedField } from '@/blocks/utils'
import { getOrganization } from '@/blocks/components/formConfig/departmenTree.js'
let options = null
export default {
  data() {
    return {
      options: options || {},
      tableExtendedField: [],
      childrenTableExtendedField: [],
      formExtendedField: [],
      childrenFormExtendedField: [],
    }
  },
  mounted() {
    let _this = this
    getOrganization(this)
        //运单扩展字段
    resultExtendedField({ extendedObjectCode: '18' }).then((data) => {
      if (data) {
        _this.tableExtendedField = data.table
        _this.formExtendedField = data.form
      }
    })
        //商品扩展字段
    resultExtendedField({ extendedObjectCode: '19' }).then((data) => {
      if (data) {
        _this.childrenTableExtendedField = data.table
        _this.childrenFormExtendedField = data.form
        console.log(_this.childrenFormExtendedField)
      }
    })



    initDictionary([
      { objectcode: 'SETTLEMENT_CYCLE' },//结算单周期
      { objectcode: 'EXPENSE_STATUS' },
      { objectcode: 'ORDER_TYPE' },
      { objectcode: 'PACK_TYPE' },
      { objectcode: 'CARGO_THERMOSPHERE' },
      { objectcode: 'DELIVERY_METHOD_TYPE' },
      { objectcode: 'TEMPERATURE_REQUIREMENT' },
      { objectcode: 'TRANSPORT_TYPE' },
      { objectcode: 'SHIPPER_TYPE' },
      { objectcode: 'CONSIGNEE_TYPE' },
      { objectcode: 'TAX_POINT' },
      { objectcode: 'ORDER_BUSINESS_TYPE' },
      { objectcode: 'ORDER_TYPE' },
      { objectcode: 'PACK_TYPE' },
      { objectcode: 'CARGO_THERMOSPHERE' },
      { objectcode: 'DELIVERY_METHOD_TYPE' },
      { objectcode: 'TEMPERATURE_REQUIREMENT' },
      { objectcode: 'TRANSPORT_TYPE' },
      { objectcode: 'SHIPPER_TYPE' },
      { objectcode: 'CONSIGNEE_TYPE' },
      { objectcode: 'LOCATION_FLAG' },
      { objectcode: 'SYNCHRONOUS_STATUS' },
      { objectcode: 'SETTLEMENT_STATUS' },
    ]).then((res) => {
      for (let key in res) {
        res[key].forEach((item) => {
          if (!isNaN(item.value)) {
            item.value = +item.value
          }
          if (key == 'TAX_POINT') {
            item.label = item.label + '%'
          }
        })
      }

      _this.options = { ..._this.options, ...res }
    })
  },
  computed: {},
  methods: {},
}
