<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"
      :currentPageProps="oldSkipCount"
      :quicklySearchOption="quicklySearchOption"
      @quicklySearchClick="quicklySearchClick"
      @quicklySearchClear="quicklySearchClear"
      :primarySearchOption="primarySearchOption"
      @overallSearchFormClick="overallSearchFormClick"
      :httpOverallSearchData="httpOverallSearchData"
    >
    </tablePagination>
    <curren-Drawer
      :title="tableColumns"
      :DrawerLoading="Loading.DrawerLoading"
      :drawer="displayDialog.detailsDialog"
      :propsData="propsData"
      :tabsDesTions="tabsDesTions"
      :Butttondata="DrawerButtonData"
      @drawerShut="(val) => (displayDialog.detailsDialog = val)"
      @drawerbutton="drawerbuttonHandle"
      @close-value="closeValue"
      :currenButtonData="currenButtonData"
      :tableColumns="detailsTableColumns"
      :totalCount="totalCountDetails"
      :MaxResultCount="MaxResultCountDetails"
      @alterResultCountDetails="alterResultCountDetails"
      @alertoldSkipCountDetails="alertoldSkipCountDetails"
    ></curren-Drawer>
  </div>
</template>
<script>
import { materialRequestByType,getDetailed,postCancel } from "@/api/wms-api"
import { tableMixins } from "@/mixins/TableMixins"
import { LoadingMixins } from "@/mixins/LoadingMixins"
import { drawerMixins } from "@/mixins/drawerMixins"
import { TableHeaderMixins } from "@/mixins/TableHeaderMixins"
import { mixins } from "@/mixins/mixins"
import { requestData } from "@/utils/processButtonData"
import requestDataNames from "@/utils/processButtonData"
export default {
  name: "ThirdLocationRequest",
  mixins: [
    tableMixins,
    LoadingMixins,
    drawerMixins,
    TableHeaderMixins,
    mixins,
  ],
  computed: {
    editDialog: {
      get: function () {
        return this.displayDialog.newDialog || this.displayDialog.editDialog;
      },
    },
    //按钮显示
    hideButton: function () {
      return function (val) {
        let data = true
        val.forEach(key => {
          if (this.propsData.requestStatus == key) {
            data = false
          }
        })
        return data
      }
    },
  },
  data () {
    let _this = this;
    return {
      URL: 'wms/store/third-location-request',
      tableLoading: false,
      handleMultipleSelection: [],
      //常用按钮数据
      currenButtonData: [
        // this.defaultImportBtn(),//导入
        this.defaultFieldSettingBtn(),//字段设置
        this.defaultFreshBtn(),//刷新
        this.defaultFilterBtn(),//筛选
      ],
      DrawerButtonData: [
        {
          type: 'danger',
          label: '取消',
          hide: () => { return this.hideButton([1,5])},//新增，执行中
          name: "cancel",
          size: 'mini'
        },
      ],
    };
  },
  mounted () {
    this.paging()
  },
  methods:{
    drawerbuttonHandle (val) {
      // 取消
      if(val == 'cancel'){
        this.$confirm('是否确定取消请求?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          distinguishCancelAndClose: true,
          closeOnClickModal: false,
          type: 'warning'
        }).then(() => {
          this.Loading.appMainLoading = true
          postCancel(this.propsData.id, this.URL).then(res => {
            this.$successMsg('已取消请求')
            this.Loading.appMainLoading = false
            getDetailed(this.propsData.id, this.URL).then(res => {
              this.propsData = res
            })
            this.paging();
          }).catch(err => {
            this.Loading.appMainLoading = false
          })
        })
      } else {
        this.drawerbutton(val, this)
      }
    },
  }
};
</script>
<style lang="scss" scoped>
@import "../../styles/mainbasicData.scss";
</style>