<template>
  <div class="page-box" v-loading="Loading.appMainLoading">
    <tablePagination
      :currenButtonData="currenButtonData"
      :tableData="tableData"
      :tableLoading="Loading.tableLoading"
      :tableColumns="tableColumns"
      @rowDrop="rowDrop"
      :totalCount="totalCount"
      :multipleSelection="multipleSelection"
      :MaxResultCount="PageListParams.MaxResultCount"
      @topbutton="topbutton"
      @inlineDialog="inlineDialog"
      @sortChange="sortChange"
      @alertoldSkipCount="alertoldSkipCount"
      @alterResultCount="alterResultCount"
      @handleSelectionChange="handleSelectionChange"
      @buttonOperationClick="buttonOperationClick"
      :currentPageProps="oldSkipCount"
      :quicklySearchOption="quicklySearchOption"
      @quicklySearchClick="quicklySearchClick"
      @quicklySearchClear="quicklySearchClear"
      :primarySearchOption="primarySearchOption"
      @overallSearchFormClick="overallSearchFormClick"
      :httpOverallSearchData="httpOverallSearchData"
    >
    </tablePagination>
    <!-- 新增与编辑 -->
    <newAndEdiDialog
      :loading="Loading.newAndEdiLoading"
      :active="active"
      :pageStatus="pageStatus"
      :formReveal="formReveal"
      :formTitle="formTitle"
      :displayDialog="editDialog"
      :FormData="formReveal ? CreateFormData : editFormData"
      :Form="formReveal ? CreateForm : editForm"
      :Options="editOptions"
      :Handle="editHandle"
      :Rules="formReveal ? editRules.cerateRule : editRules.editRule"
      @FormSubmit="FormSubmit"
      @close="FormClose"
      @goBack="goBack"
    ></newAndEdiDialog>
    <!-- 搜索按钮——窗体组件 -->
    <searchPage
      ref="searchTable"
      :tableLoading="Loading.autoTableLoading"
      :advancedFilter="advancedFilter()"
      :filterPageListParams="filterPageListParams"
      :formTitle="searchTitle"
      :displayDialog="displayDialog.AddNewDialog"
      :searchTableData="searchData"
      :searchTableColumns="searchColumns"
      :searchTotalCount="searchTotalCount"
      :supplierItemPage="searchPageListParams"
      @handleSelectionChange="prepareFormData"
      @SizeChange="searchAlterResultCount($event, searchPageListParams)"
      @CurrentChange="searchAlertoldSkipCount($event, searchPageListParams)"
      @tableButtonClick="searchSubmit(arguments)"
    ></searchPage>
    <!-- 新导入 disabledMethod 导入方式禁用 disabledIsAllowPartImport 是否局部导入禁用-->
    <!-- methodValue 导入方式默认选项  是否局部导入 默认选项  -->
    <importFile
      :loading="Loading.importLoading"
      :show="displayDialog.importDialog"
      :URL="URL"
      :disabledMethod = {method1:false,method2:false,method3:false}
      :disabledIsAllowPartImport = {isAllowPartImport1:false,isAllowPartImport2:false}
      methodValue="0"
      isAllowPartImportValue="1"
      @importClick="postImportMergeClick(arguments)"
      @postImportDown="importDown"
    ></importFile>
    <curren-Drawer
      :title="tableColumns"
      :tableColumns="tableColumns"
      :DrawerLoading="Loading.DrawerLoading"
      :drawer="displayDialog.detailsDialog"
      :dropdownData="dropdownData"
      :propsData="propsData"
      :tabsDesTions="tabsDesTions"
      @drawerShut="(val) => (displayDialog.detailsDialog = val)"
      @drawerbutton="drawerbutton"
      @handleCommand="drawerHandle"
      @close-value="closeValue"
    ></curren-Drawer>
  </div>
</template>
<script>
import { tableMixins } from "@/mixins/TableMixins"
import { LoadingMixins } from "@/mixins/LoadingMixins"
import { drawerMixins } from "@/mixins/drawerMixins"
import { TableHeaderMixins } from "@/mixins/TableHeaderMixins"
import { newAndEdiDialogMixins } from "@/mixins/newAndEdiDialogMixins"
import { mixins } from "@/mixins/mixins"
import { filterSelectMixins } from '@/mixins/filter-Select'
export default {
  name: "LocationGroup",
  mixins: [
    tableMixins,
    LoadingMixins,
    drawerMixins,
    TableHeaderMixins,
    mixins,
    filterSelectMixins,
    newAndEdiDialogMixins
  ],
  computed: {
    editDialog: {
      get: function () {
        return this.displayDialog.newDialog || this.displayDialog.editDialog;
      },
    },
  },
  data () {
    return {
      URL: 'basedata/location-group',
      //常用按钮数据
      currenButtonData: [
        this.defaultAddBtn(),//新增
        this.defaultImportBtn(),//导入
        this.defaultExportBtn(),//导出
        this.defaultFieldSettingBtn(),//字段设置
        this.defaultFreshBtn(),//刷新
        this.defaultFilterBtn(),//筛选
      ],
      //新增
      CreateFormData: {
        remark: null,
        description: null,
        warehouseCode: null,
        areaCode: null,
        groupType: 1,
        defaultInventoryStatus: 1,
        pickPriority: 1,
        overflowLocationGroup: null,
        locSwitch: {
          enableMixItem: true,
          enableMixLot: true,
          enableMixStatus: true,
          enableNegative: true,
          enableKeepZero: true,
          enableOpportunityCount: true,
          enablePick: true,
          enableOverPick: true,
          enableWholeStore: true,
          enableBreakStore: true,
          enableShip: true,
          enableReceive: true,
          enableReturnToSupplier: true,
          enableReturnFromCustomer: true
        },
        code: null,
        company: null,
        name: null,
      },
      //编辑
      editFormData: {
        code: null,
        remark: null,
        description: null,
        warehouseCode: null,
        areaCode: null,
        groupType: 1,
        defaultInventoryStatus: 1,
        pickPriority: 0,
        overflowLocationGroup: null,
        locSwitch: {
          enableMixItem: true,
          enableMixLot: true,
          enableMixStatus: true,
          enableNegative: true,
          enableKeepZero: true,
          enableOpportunityCount: true,
          enablePick: true,
          enableOverPick: true,
          enableWholeStore: true,
          enableBreakStore: true,
          enableShip: true,
          enableReceive: true,
          enableReturnToSupplier: true,
          enableReturnFromCustomer: true
        },
        concurrencyStamp: null,
        name: null,
      },
      editOptions: {},
      CreateForm: [
        { type: "filterSelect", label: "区域代码", prop: "areaCode", optionsLabel: "name", optionsValue: "code", 
          focus: (type,val) => { return this.getFilterList(type, val, "basedata/area")},
          searchButton: (val) => { this.showSerarchPage(val, 'basedata/area', 'Area', '区域选择', this.CreateFormData) }, colSpan: 12 },
        { type: "input", label: "库位组代码", prop: "code", colSpan: 12 },
        { type: "input", label: "库位组名称", prop: 'name', colSpan: 12 },
        { type: "select", label: "类型", prop: "groupType", options: "locationType", colSpan: 12 },
        { type: "select", label: "状态", prop: "defaultInventoryStatus", options: "inventoryStage", colSpan: 12 },
        { type: "input", label: "拣料优先级", prop: "pickPriority", colSpan: 12 },
        { type: "input", label: "描述", prop: "description", colSpan: 12 },
        { type: "input", label: "溢流库位组", prop: "overflowLocationGroup", colSpan: 12 },
        { type: "objectSelect", label: "是否混物品", prop: "locSwitch", showProp: "enableMixItem", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否混批次", prop: "locSwitch", showProp: "enableMixLot", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否混状态", prop: "locSwitch", showProp: "enableMixStatus", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否负库存", prop: "locSwitch", showProp: "enableNegative", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否保留零库存", prop: "locSwitch", showProp: "enableKeepZero", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否机会盘点", prop: "locSwitch", showProp: "enableOpportunityCount", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否领料", prop: "locSwitch", showProp: "enablePick", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否过量领料", prop: "locSwitch", showProp: "enableOverPick", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否整包存储", prop: "locSwitch", showProp: "enableWholeStore", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否散件存储", prop: "locSwitch", showProp: "enableBreakStore", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否发出", prop: "locSwitch", showProp: "enableShip", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否接收", prop: "locSwitch", showProp: "enableReceive", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否退货给供应商", prop: "locSwitch", showProp: "enableReturnToSupplier", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否接收客户退货", prop: "locSwitch", showProp: "enableReturnFromCustomer", options: "whetherOrNot", colSpan: 12 },
        { type: "input", label: "备注", prop: 'remark', colSpan: 12 },
      ],
      editForm: [
        { type: "filterSelect", label: "区域代码", prop: "areaCode", optionsLabel: "name", optionsValue: "code", 
          focus: (type,val) => { return this.getFilterList(type, val, "basedata/area")},
          searchButton: (val) => { this.showSerarchPage(val, 'basedata/area', 'Area', '区域选择', this.editFormData) }, colSpan: 12 },
        { type: "input", label: "库位组代码", prop: "code", disabled:"true", colSpan: 12 },
        { type: "input", label: "库位组名称", prop: 'name', colSpan: 12 },
        { type: "select", label: "类型", prop: "groupType", options: "locationType", colSpan: 12 },
        { type: "select", label: "状态", prop: "defaultInventoryStatus", options: "inventoryStage", colSpan: 12 },
        { type: "input", label: "拣料优先级", prop: "pickPriority", colSpan: 12 },
        { type: "input", label: "描述", prop: "description", colSpan: 12 },
        { type: "input", label: "溢流库位组", prop: "overflowLocationGroup", colSpan: 12 },
        { type: "objectSelect", label: "是否混物品", prop: "locSwitch", showProp: "enableMixItem", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否混批次", prop: "locSwitch", showProp: "enableMixLot", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否混状态", prop: "locSwitch", showProp: "enableMixStatus", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否负库存", prop: "locSwitch", showProp: "enableNegative", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否保留零库存", prop: "locSwitch", showProp: "enableKeepZero", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否机会盘点", prop: "locSwitch", showProp: "enableOpportunityCount", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否领料", prop: "locSwitch", showProp: "enablePick", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否过量领料", prop: "locSwitch", showProp: "enableOverPick", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否整包存储", prop: "locSwitch", showProp: "enableWholeStore", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否散件存储", prop: "locSwitch", showProp: "enableBreakStore", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否发出", prop: "locSwitch", showProp: "enableShip", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否接收", prop: "locSwitch", showProp: "enableReceive", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否退货给供应商", prop: "locSwitch", showProp: "enableReturnToSupplier", options: "whetherOrNot", colSpan: 12 },
        { type: "objectSelect", label: "是否接收客户退货", prop: "locSwitch", showProp: "enableReturnFromCustomer", options: "whetherOrNot", colSpan: 12 },
        { type: "input", label: "备注", prop: 'remark', colSpan: 12 },
      ],
      editRules: {
        cerateRule: {
          code: [
            { required: true, trigger: "blur", message: "不可为空" },
          ],
          areaCode: [{ required: true, trigger: "change", message: "不可为空" }],
          warehouseCode: [{ required: true, trigger: "blur", message: "不可为空" }],
          name: [{ required: true, trigger: "blur", message: "不可为空" }],//编辑必选
        },
        editRule: {
          name: [{ required: true, trigger: "blur", message: "不可为空" }],//编辑必选
          areaCode: [{ required: true, trigger: "change", message: "不可为空" }],
          warehouseCode: [{ required: true, trigger: "blur", message: "不可为空" }],
        }
      },
    };
  },
  mounted () {
    this.paging();
  },
};
</script>
<style lang="scss" scoped>
@import "../../../styles/basicData.scss";
</style>