<!-- @desc:入库办理  @auth:付斌  @time:2024/02/20 15:15 -->
<template>
  <div class="main-div">
    <DkCollapse @on-change="changeCollapse" ref="collapse">
      <DkPanel prop="basic">
        <DkForm slot="content" ref="formInline" style="width:100%;" name="dk-form" v-model="formData"
                :labelMaxWords="5">
          <!--所属公司-->
          <DkFormItem :required="true" prop="ascpId">
            <SelectPop v-model="formData.ascpId" :options="companyList" :multiple="false" :clearable="false"
                       :disabled="true"
                       label-key="ascpName" value-key="cpId"/>
          </DkFormItem>
          <!--入库单号-->
          <DkFormItem prop="entryNo" :required="true">
            <InputPop v-model="formData.entryNo" :readonly="true"/>
          </DkFormItem>
          <!--供应商名称-->
          <DkFormItem prop="supplierName" :required="true">
            <SelectPop v-model="formData.supplierId" :options="supplierList" :multiple="false" :clearable="false"
                       :disabled="true"
                       label-key="supplierName" value-key="supplierId"/>
          </DkFormItem>
          <!--发货日期-->
          <DkFormItem prop="sale1OutDate">
            <InputPop v-model="formData.sale1OutDate" :readonly="true"/>
          </DkFormItem>
          <!--联系人-->
          <DkFormItem prop="consignee">
            <InputPop v-model="formData.customerName" :readonly="true"/>
          </DkFormItem>
          <!--联系电话-->
          <DkFormItem prop="consigneePhone">
            <InputPop :telephone="true" v-model="formData.customerPhone" maxlength="11" :readonly="true"/>
          </DkFormItem>
          <!--详细地址-->
          <DkFormItem prop="takeOverAddress">
            <InputPop ref="addressFull" :readonly="true" v-model="formData.addressFull"/>
          </DkFormItem>
          <!--收货仓库-->
          <DkFormItem prop="receivingWh" :required="true">
            <SelectPop v-model="formData.entryWhId" :options="warehouseList" :multiple="false" :clearable="false"
                       label-key="whName" value-key="whId" :disabled="entryStatus===3 || entryStatus === -2"
                       @on-select="changeItemWhId"/>
          </DkFormItem>
          <DkFormItem prop="entryTime" :label="$t('entryTime')">
            <DatePickerPop v-model="entryDate"
                           :placeholder="$t('inputWords',{'search-name':$t('entryTime')})"
                           type="date" :short-cut-flag="true" :readonly="true"/>
          </DkFormItem>
          <!--备注-->
          <DkFormItem prop="remarks">
            <InputPop v-model="formData.remarks" maxlength=500 textareaFlag/>
          </DkFormItem>
        </DkForm>
      </DkPanel>
      <DkPanel prop="goodsInformation">
        <div slot="content">
          <EditTable ref="table-select" :data="formData.orderEntryItemList"
                     :columns-social="goodsSkuColumns"
                     :columns="goodsSkuColumns"
                     enabledRepeatId="skuId"
                     controlId="skuId"
                     :height="this.tableHeight-60 - 60"
                     :showSeqBtnFlag="false"
                     :enabledRepeat="true"
                     :newRowFlag="false"
                     :readonly="entryStatus===3"
          ></EditTable>

          <DkForm ref="goodsFootFormData" v-model="goodsFootFormData" :labelMaxWords="5" name="dk-form"
                  class="form-content-class">
            <!--货物金额-->
            <DkFormItem prop="sumGoodsAmount">
              <InputNumberPop ref="sumGoodsAmount" v-model="goodsFootFormData.sumGoodsAmount"
                              :clearable="false"
                              :digits="2"
                              :readonly="true"/>
            </DkFormItem>
            <!--总重量-->
            <DkFormItem prop="sumWeight">
              <InputNumberPop ref="sumWeight" v-model="goodsFootFormData.sumWeight" :digits="2"
                              :readonly="true" unit="KG"/>
            </DkFormItem>
            <!--总体积-->
            <DkFormItem prop="sumVolume">
              <InputNumberPop ref="sumVolume" v-model="goodsFootFormData.sumVolume" :digits="2"
                              :readonly="true" unit="m³"/>
            </DkFormItem>
          </DkForm>
        </div>
      </DkPanel>
      <!--附件-->
      <DkPanel prop="files">
        <div id="search-cond-div-files-info" ref="search-cond-div-files-info"
             slot="content">
          <DkPicWall v-model="formData.annexPaths"
                     folder="t_order/annex_paths" :accept="$config.uploadFileConfig.acceptPicType"
                     :format="['jpg','jpeg','png']"></DkPicWall>
        </div>
      </DkPanel>
    </DkCollapse>
    <DkButton style="z-index: 100;position: absolute;right: 4%;" @click="click()">
      {{ $t('barcode') }}
    </DkButton>


    <!--  下部分按钮区域  -->
    <DkSaveButton :viewFlag="entryStatus === -2" ref="saveButton" :loading="loading" @save="submitForm"
                  @close="btnGroupClick"></DkSaveButton>
    <!--查看条码-->
    <DkModal
      v-model="barCodeModel"
      :title="$t('barcode')"
      width="600px"
      :loading="loading"
      :ok-visible-flag="false"
    >
      <DkTable ref="barcodeDetailsFlag"
               primaryKey="barcodeId"
               :id="'table-'+$options.name"
               name="table3" :data="barCodeData"
               :height="this.tableHeight/2-40"
               :select-flag="false"
               :pageFlag="false"
               :pageTotalFlag="false">
        <DkTableColumn type="seq" min-width="44"></DkTableColumn>
        <DkTableColumn field="skuModel" width="150" :filter="false"></DkTableColumn>
        <DkTableColumn field="skuName" width="150" :filter="false"></DkTableColumn>
        <DkTableColumn field="skuCode" width="200" :filter="false"></DkTableColumn>
        <DkTableColumn field="barcode" width="150" :filter="false" :title="$t('skuBarcode')"></DkTableColumn>
        <DkTableColumn field="boxcode" width="150" :filter="false"></DkTableColumn>
      </DkTable>
      <div slot="footer"/>
    </DkModal>

  </div>
</template>

<script>
import {formMixin} from '@/mixins/form'

export default {
  mixins: [formMixin],
  data() {
    let self = this
    return {
      //商品合计信息
      goodsFootFormData: {
        sumGoodsAmount: 0,
        sumVolume: 0,
        sumWeight: 0,
      },
      // 所属公司
      companyList: [],
      // 所属供应商
      supplierList: [],
      // 收货仓库
      warehouseList: [],
      // 条码明细
      barCodeData: [],
      // 查看条码
      barCodeModel: false,
      // 单据状态
      entryStatus: null,
      loading: false,
      entryDate: null,
      formData: {
        supplierName: null,
        contactName: null,
        contactPhones: null,
        addressArea: null,
        addressName: null,
        addressNo: null,
        addressFull: null,
        remarks: '',
        ascpId: null,
        cpId: self.$store.state.user.cpId,
        // 附件
        annexPaths: [],
        // 货物明细
        orderEntryItemList: [],
      },
      //入库商品
      goodsSkuColumns: [
        {field: 'skuModel', type: 'disabled'},
        {field: 'skuName', type: 'disabled'},
        {field: 'skuCode', type: 'disabled'},
        {field: 'orderQuantity', type: 'disabled', width: 'auto', digits: 2},
        {field: 'entryGoingQuantity', type: 'disabled', width: 'auto', digits: 2},
        {field: 'entryGoingAmount', type: 'disabled', flgUserSensitive: true, width: 'auto', digits: 2},
        {field: 'orderPriceSale', type: 'disabled', flgUserSensitive: true, width: 'auto', digits: 2},
        {
          copyVisible: true,
          searchDataFlag: false,
          field: 'whId',
          type: 'select',
          options: () => self.warehouseList,
          labelKey: 'whName',
          valueKey: 'whId',
          fieldUpdate: [
            {updateField: 'warehouseName', valueFiled: 'whName'},
            {updateField: 'whId', valueFiled: 'whId'},
          ]
        },
        {field: 'nonStandardCode', type: 'disabled', width: 'auto'},
        {field: 'skuTypeName', type: 'disabled', width: 'auto'},
        {field: 'brandName', type: 'disabled', width: 'auto'},
        {field: 'skuWeight', type: 'disabled', width: 'auto'},
        {field: 'skuVolume', type: 'disabled', width: 'auto'},
      ],
    }
  },
  methods: {
    /**
     * @desc   : 总单仓库修改明细仓库
     * @author : 付斌
     * @date   : 2023/11/21 9:05
     */
    changeItemWhId() {

    },
    /**
     * @desc   : 保存的提交事件
     * @author : 付斌
     * @date   : 2024-02-20 14:34
     */
    submitForm() {
    },
    /**
     * @desc   : 查看条码
     * @author : 付斌
     * @date   : 2024-02-20 9:04
     */
    click() {
      this.barCodeModel = true
    },
    /**
     * @desc   : 通过id查询
     * @author : 付斌
     * @date   : 2024-02-20 14:35
     */
    detail(id) {

    },
    /**
     * @desc   : 返回一览页面
     * @author : 付斌
     * @date   : 2024-02-20 14:35
     */
    btnGroupClick() {
    },
  },
  created() {
    this.focusItem = 'purEnterId';    // 给第一个组件赋值，可以在混入中自动去聚焦
    this.primaryKey = 'purEnterId'  // 设置主键Id
  },
}
</script>
