
<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"
    >
      <!-- <div slot="tableTopSlot">
        上方按钮插槽位置预留
      </div>
      <div slot="searchPrimarySlot">
        普通初级搜索插槽位置预留
      </div> -->
      <!-- <template>表格内容插槽位置预留</template> -->
    </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"
      :DrawerLoading="Loading.DrawerLoading"
      :drawer="displayDialog.detailsDialog"
      :dropdownData="dropdownData"
      :propsData="propsData"
      :tabsDesTions="tabsDesTions"
      :tableLoading="tableLoading"
      :dropdownTabsData="dropdownTabsData"
      @drawerShut="(val) => (displayDialog.detailsDialog = val)"
      @drawerbutton="drawerbutton"
      @handleCommand="drawerHandle"
      @close-value="closeValue"
      :firstTabs="firstTabs"
    ></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: "ItemBasic",
  mixins: [
    tableMixins,
    LoadingMixins,
    drawerMixins,
    TableHeaderMixins,
    mixins,
    filterSelectMixins,
    newAndEdiDialogMixins
  ],
  computed: {
    editDialog: {
      get: function () {
        return this.displayDialog.newDialog || this.displayDialog.editDialog;
      },
    },
  },
  data () {
    return {
      URL: 'basedata/item-basic',
      tableLoading:false,
      //常用按钮数据
      currenButtonData: [
        this.defaultAddBtn(),//新增
        this.defaultImportBtn(),//导入
        this.defaultExportBtn(),//导出
        this.defaultFieldSettingBtn(),//字段设置
        this.defaultFreshBtn(),//刷新
        this.defaultFilterBtn(),//筛选
      ],
      //新增
      CreateFormData: {
        remark: null,
        warehouseCode: null,
        name: null,
        desc1: null,
        desc2: null,
        status: 1,
        canMake: true,
        canBuy: true,
        canOutsourcing: false,
        isRecycled: false,
        type: null,
        category: null,
        group: null,
        color: null,
        configuration: null,
        basicUom: null,
        abcClass: "C",
        productLine: null,
        project: null,
        version: null,
        eco: null,
        validity: 0,
        validityUnit: 9,
        manageType: 1,
        elevel: null,
        code: null,
        company: null,
        isPhantom: false
      },
      //编辑
      editFormData: {
        code: null,
        remark: null,
        name: null,
        desc1: null,
        desc2: null,
        status: 1,
        canMake: true,
        canBuy: true,
        canOutsourcing: false,
        isRecycled: false,
        type: null,
        category: null,
        group: null,
        color: null,
        configuration: null,
        basicUom: null,
        abcClass: null,
        productLine: null,
        project: null,
        version: null,
        eco: null,
        validity: 0,
        validityUnit: 1,
        manageType: 1,
        elevel: null,
        concurrencyStamp: null,
        isPhantom: null
      },
      editOptions: {},
      CreateForm: [
        { type: "input", label: "物料代码", prop: 'code', colSpan: 12, validType:'numberLetter' },
        { type: "input", label: "物料名称", prop: "name", colSpan: 12 },
        { type: "input", label: "物料描述", prop: "desc1", colSpan: 12 },
        { type: "select", label: "状态", prop: "status", options: "itemStatus", colSpan: 12 },
        { type: "filterSelect", label: "计量单位", prop: "basicUom", optionsLabel: "description", optionsValue: "name", 
          focus: (type,val) => { return this.getFilterList(type, val, "basedata/uom")},
          searchButton: (val) => { this.showSerarchPage(val, 'basedata/uom', 'Uom', '计量单位选择', this.CreateFormData) }, colSpan: 12 },
        { type: "select", label: "ABC类", prop: "abcClass", options: "abcClass", clearable: true, filterable: true, allowCreate: true, colSpan: 12 },
        { type: "select", label: "制造件", prop: "canMake", options: "whetherOrNot", colSpan: 12 },
        { type: "select", label: "采购件", prop: "canBuy", options: "whetherOrNot", colSpan: 12 },
        { type: "select", label: "外包件", prop: "canOutsourcing", options: "whetherOrNot", colSpan: 12 },
        { type: "select", label: "回收件", prop: "isRecycled", options: "whetherOrNot", colSpan: 12 },
        { type: "input", label: "产品类", prop: "productLine", colSpan: 12 },
        { type: "input", label: "有效值", prop: "validity", colSpan: 12 },
        { type: "select", label: "有效期", prop: "validityUnit", options: "validityUnit", colSpan: 12 },
        { type: "select", label: "管理类型", prop: "manageType", options: "manageType", colSpan: 12 },
        { type: "filterSelect", label: "项目", prop: "project", optionsLabel: "name", optionsValue: "code", 
          focus: (type,val) => { return this.getFilterList(type, val, "basedata/project")},
          searchButton: (val) => { this.showSerarchPage(val, 'basedata/project', 'Project', '项目选择', this.CreateFormData) }, colSpan: 12 },
        { type: "input", label: "E-LEVEL等级", prop: 'elevel', colSpan: 12 },
        { label: "类型", prop: 'type', type: "select", options: "ItemTypeBasic", colSpan: 12 },
        { type: "input", label: "种类", prop: 'category', colSpan: 12 },
        { type: "input", label: "分组", prop: 'group', colSpan: 12 },
        { type: "input", label: "配置", prop: 'configuration', colSpan: 12 },
        { type: "input", label: "版本", prop: 'version', colSpan: 12 },
        { type: "input", label: "工程变更", prop: 'eco', colSpan: 12 },
        { type: "select", label: "是否虚拟物料", prop: "isPhantom", options: "whetherOrNot", colSpan: 12 },
        { type: "input", label: "备注", prop: 'remark', colSpan: 12 },
      ],
      editForm: [
        { type: "input", label: "物料代码", prop: 'code', disabled: true, colSpan: 12, validType:'numberLetter' },
        { type: "input", label: "物料名称", prop: "name", colSpan: 12 },
        { type: "input", label: "物料描述", prop: "desc1", colSpan: 12 },
        { type: "select", label: "状态", prop: "status", options: "itemStatus", colSpan: 12 },
        { type: "filterSelect", label: "计量单位", prop: "basicUom", optionsLabel: "description", optionsValue: "name", 
          focus: (type,val) => { return this.getFilterList(type, val, "basedata/uom")},
          searchButton: (val) => { this.showSerarchPage(val, 'basedata/uom', 'Uom', '计量单位选择', this.editFormData) }, colSpan: 12 },
        { type: "select", label: "ABC类", prop: "abcClass", options: "abcClass", clearable: true, filterable: true, allowCreate: true, colSpan: 12 },
        { type: "select", label: "制造件", prop: "canMake", options: "whetherOrNot", disabled: true, colSpan: 12 },
        { type: "select", label: "采购件", prop: "canBuy", options: "whetherOrNot", disabled: true, colSpan: 12 },
        { type: "select", label: "外包件", prop: "canOutsourcing", options: "whetherOrNot", disabled: true, colSpan: 12 },
        { type: "select", label: "回收件", prop: "isRecycled", options: "whetherOrNot", disabled: true, colSpan: 12 },
        { type: "input", label: "产品类", prop: "productLine", colSpan: 12 },
        { type: "input", label: "有效值", prop: "validity", colSpan: 12 },
        { type: "select", label: "有效期", prop: "validityUnit", options: "validityUnit", colSpan: 12 },
        { type: "select", label: "管理类型", prop: "manageType", options: "manageType", colSpan: 12 },
        { type: "filterSelect", label: "项目", prop: "project", optionsLabel: "name", optionsValue: "code", 
          focus: (type,val) => { return this.getFilterList(type, val, "basedata/project")},
          searchButton: (val) => { this.showSerarchPage(val, 'basedata/project', 'Project', '项目选择', this.editFormData) }, colSpan: 12 },
        { type: "input", label: "E-LEVEL等级", prop: 'elevel', colSpan: 12 },
        { label: "类型", prop: 'type', type: "select", options: "ItemTypeBasic", disabled: true, colSpan: 12 },
        { type: "input", label: "种类", prop: 'category', colSpan: 12 },
        { type: "input", label: "分组", prop: 'group', colSpan: 12 },
        { type: "input", label: "配置", prop: 'configuration', colSpan: 12 },
        { type: "input", label: "版本", prop: 'version', colSpan: 12 },
        { type: "input", label: "工程变更", prop: 'eco', colSpan: 12 },
        { type: "select", label: "是否虚拟物料", prop: "isPhantom", options: "whetherOrNot", colSpan: 12 },
        { type: "input", label: "备注", prop: 'remark', colSpan: 12 },
      ],
      editRules: {
        cerateRule: {
          code: [{ required: true, trigger: "blur", message: "不可为空" }],
          name: [{ required: true, trigger: "blur", message: "不可为空" }],
          status: [{ required: true, trigger: "blur", message: "不可为空" }],
          canMake: [{ required: true, trigger: "blur", message: "不可为空" }],
          canBuy: [{ required: true, trigger: "blur", message: "不可为空" }],
          canOutsourcing: [{ required: true, trigger: "blur", message: "不可为空" }],
          isRecycled: [{ required: true, trigger: "blur", message: "不可为空" }],
          basicUom: [{ required: true, trigger: "change", message: "不可为空" }],
          abcClass: [{ required: true, trigger: "blur", message: "不可为空" }],
          isBuyPart: [{ required: true, trigger: "blur", message: "不可为空" }],
          validity: [{ required: true, trigger: "blur", message: "不可为空" }],
          manageType: [{ required: true, trigger: "change", message: "不可为空" }],
        },
        editRule: {
          code: [{ required: true, trigger: "blur", message: "不可为空" }],
          name: [{ required: true, trigger: "blur", message: "不可为空" }],
          status: [{ required: true, trigger: "blur", message: "不可为空" }],
          canMake: [{ required: true, trigger: "blur", message: "不可为空" }],
          canBuy: [{ required: true, trigger: "blur", message: "不可为空" }],
          canOutsourcing: [{ required: true, trigger: "blur", message: "不可为空" }],
          isRecycled: [{ required: true, trigger: "blur", message: "不可为空" }],
          basicUom: [{ required: true, trigger: "change", message: "不可为空" }],
          abcClass: [{ required: true, trigger: "blur", message: "不可为空" }],
          isBuyPart: [{ required: true, trigger: "blur", message: "不可为空" }],
          validity: [{ required: true, trigger: "blur", message: "不可为空" }],
          manageType: [{ required: true, trigger: "change", message: "不可为空" }],
        }
      },
      // 自定义详情明细汇总等table页
      dropdownTabsData: [
        {
          label: "详情",
          name: 'xq'
        },
        {
          label: "质量信息",
          name: 'zlxx',
          url: 'basedata/item-quality',
          tableColumns: 'ItemQuality',
          functionName: 'getListByItemcode'
        },
        {
          label: "质检标准",
          name: 'zjbz',
          url: 'basedata/AQL',
          tableColumns: 'AQL',
          functionName: 'getListByItemcode'
        },
        {
          label: "分类信息",
          name: 'flxx',
          url: 'basedata/item-category',
          tableColumns: 'ItemCategory',
          functionName: 'getListByItemcode'
        },
        {
          label: "包装信息",
          name: 'bzxx',
          url: 'basedata/item-pack',
          tableColumns: 'ItemPack',
          functionName: 'getListByItemcode'
        },
        {
          label: "库存余额",
          name: 'kcye',
          url: 'wms/inventory/inventory-balance',
          tableColumns: 'InventoryBalance',
          functionName: 'byItem'
        },
        {
          label: "预计出库存",
          name: 'yjrkc',
          url: 'wms/inventory/expect-in',
          tableColumns: 'expectIn',
          functionName: 'byItem'
        },
        {
          label: "预计入库存",
          name: 'yjckc',
          url: 'wms/inventory/expect-out',
          tableColumns: 'expectOut',
          functionName: 'byItem'
        }
      ],
    };
  },
  mounted () {
    this.paging();
  },
};
</script>
<style lang="scss" scoped>
@import "../../../styles/basicData.scss";
</style>