<template>
  <div class="mod-config yzz">
    <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;">
      <el-form :inline="true" label-position="top" style="margin-top: 0px">
        <el-form-item :label="'申请单号'">
          <el-input v-model="searchData.notifyNo" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item :label="'申请账号'">
          <el-input v-model="searchData.userName" style="width: 120px"></el-input>
        </el-form-item>
        <el-form-item label="状态" >
          <el-select v-model="searchData.status" placeholder="请选择" style="width: 120px">
            <el-option label="全部" value=""></el-option>
            <el-option label="ISSUE" value="ISSUE"></el-option>
            <el-option label="CANCEL" value="CANCEL"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="'申请单日期'">
          <el-date-picker
            style="width: 120px"
            v-model="searchData.startDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item style="margin-top: 23px;">
          <label style="margin-left: 0px;font-size: 19px">&#10142</label>
        </el-form-item>
        <el-form-item :label="' '">
          <el-date-picker
            style="width: 120px"
            v-model="searchData.endDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-top: 0px">
        <el-form-item label="是否领料" >
          <el-select v-model="searchData.issueFlag" placeholder="请选择" style="width: 120px">
            <el-option label="全部" value=""></el-option>
            <el-option label="Y" value="Y"></el-option>
            <el-option label="N" value="N"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="领料结果" >
          <el-select v-model="searchData.issueResult" placeholder="请选择" style="width: 120px">
            <el-option label="全部" value=""></el-option>
            <el-option label="部分发料" value="部分发料"></el-option>
            <el-option label="全部发料" value="全部发料"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="searchTable()">查询</el-button>
          <!-- <el-button type="primary" @click="createNotifyModal()">新增</el-button> -->
          <download-excel
            :fields="fields()"
            :data="exportData"
            type="xls"
            :name="exportName"
            :header="exportHeader"
            :footer="exportFooter"
            :fetch="createExportData"
            :before-generate="startDownload"
            :before-finish="finishDownload"
            worksheet="导出信息"
            class="el-button el-button--primary el-button--medium">
            {{ '导出' }}
          </download-excel>
        </el-form-item>
      </el-form>
    </el-form>
    <el-table
      :data="dataList"
      @row-click="changeData"
      :height="height"
      border
      highlight-current-row
      ref="mainTable"
      v-loading="dataListLoading"
      style="width: 100%; ">
      <el-table-column
        v-for="(item,index) in columnList1" :key="index"
        :sortable="item.columnSortable"
        :prop="item.columnProp"
        :header-align="item.headerAlign"
        :show-overflow-tooltip="item.showOverflowTooltip"
        :align="item.align"
        :fixed="item.fixed==''?false:item.fixed"
        :min-width="item.columnWidth"
        :label="item.columnLabel">
        <template slot-scope="scope">
          <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
          <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                             style="width: 100px; height: 80px"/></span>
        </template>
      </el-table-column>
      <el-table-column
        header-align="center"
        align="center"
        width="80"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" v-if="scope.row.status==='已下达'" @click="closeNotifyModel(scope.row)">关闭</a>
          <a type="text" size="small" v-if="scope.row.status==='已关闭'" @click="openNotify(scope.row)">开启</a>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="sizeChangeHandle"
      @current-change="currentChangeHandle"
      :current-page="pageIndex"
      :page-sizes="[20, 50, 100, 1000]"
      :page-size="pageSize"
      :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>


    <el-tabs style="font-size: 12px;min-height: 200px" class="customer-tab" v-model="activeName"  type="border-card"  @tab-click="tabClick">
      <el-tab-pane label="申请单明细" name="detail">
        <el-table
          :data="dataList2"
          :height="height"
          border
          v-loading="dataListLoading"
          style="width: 100%; ">
          <el-table-column
            header-align="center"
            align="center"
            width="80"
            label="操作">
            <template slot-scope="scope">
              <a type="text" size="small" v-if="currentRow.status==='已下达'" @click="deleteNotifySOSPlus(scope.row)">删除</a>
            </template>
          </el-table-column>
          <el-table-column
            v-for="(item,index) in columnList2" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                 style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>

      </el-tab-pane>
      <el-tab-pane label="材料明细" name="sub">
        <el-table
          :data="dataList3"
          :height="height"
          border
          :row-class-name="tableRowClassName"
          v-loading="dataListLoading"
          style="width: 100%; ">

          <el-table-column
            header-align="center"
            align="center"
            width="80"
            label="操作">
            <template slot-scope="scope">
              <a type="text" size="small" v-if="currentRow.status==='已下达'" @click="deleteNotifyMaterial(scope.row)">删除</a>

            </template>
          </el-table-column>
          <el-table-column
            v-for="(item,index) in columnList3" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                 style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane label="材料汇总" name="sum">
        <el-table
          :data="dataList4"
          :height="height"
          border
          v-loading="dataListLoading"
          style="width: 100%; ">
          <!--          <el-table-column-->
          <!--            header-align="center"-->
          <!--            align="center"-->
          <!--            width="80"-->
          <!--            fixed="left"-->
          <!--            label="操作">-->
          <!--            <template slot-scope="scope">-->
          <!--              <a type="text" size="small" @click="printLabel(scope.row)">打印标签</a>-->
          <!--            </template>-->
          <!--          </el-table-column>-->
          <el-table-column
            v-for="(item,index) in columnList4" :key="index"
            :sortable="item.columnSortable"
            :prop="item.columnProp"
            :header-align="item.headerAlign"
            :show-overflow-tooltip="item.showOverflowTooltip"
            :align="item.align"
            :fixed="item.fixed==''?false:item.fixed"
            :min-width="item.columnWidth"
            :label="item.columnLabel">
            <template slot-scope="scope">
              <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
              <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                                 style="width: 100px; height: 80px"/></span>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
    </el-tabs>

    <el-dialog title="关闭原因" :close-on-click-modal="false" v-drag :visible.sync="closeModalFlag" width="450px">
      <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item >
              <el-input
                type="textarea"
                v-model="closeData.closeRemark "
                :rows="3"
                resize='none'
                maxlength="200"
                show-word-limit
                style="height: 60px" >
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-footer style="height:40px;margin-top: 60px;text-align:center">
        <el-button type="primary" @click="closeNotify()">保存</el-button>
        <el-button type="primary" @click="closeModalFlag=false">关闭</el-button>
      </el-footer>
    </el-dialog>




  </div>
</template>

<script>
  import {
    searchNotifyHeader
    , searchNotifyOrderList
    , searchNotifyMaterialList
    , searchSumNotifyMaterialList
    , deleteNotifySOSPlus
    , updateNotifyStatus
    , deleteNotifyMaterial
    , searchNotifyLog
    , searchNotifyLogClose

  } from "@/api/orderIssure/soIssueNotify.js"



  export default {

    data() {
      return {
        height:200,
        activeName: 'detail',
        dataList: [],
        dataList2: [],
        dataList3: [],
        dataList4: [],
        dataList5: [],
        dataList6: [],
        userBuList:[],
        createNotifyFlag: false,
        saveOrderDetailFlag: false,
        closeData:{
          site:'',
          notifyNo:'',
          closeRemark:'',
          username:this.$store.state.user.name,
        },
        closeModalFlag:false,
        searchData: {
          page: 1,
          limit: 100,
          site:'',
          userName: '',
          notifyNo: '',
          status: '',
          issueFlag: '',
          loginUserName: this.$store.state.user.name,
          issueResult: '',
          startDate: this.dayjs().format("YYYY-MM-DD"),
          endDate: this.dayjs().format("YYYY-MM-DD"),
          sql: "",
        },
        notifyData:{
          site: '',
          bu: '',
          notifyNo: '',
          notifyDate: '',
          enteredDate: '',
          userName: this.$store.state.user.name,
          userDisplay: '',
          remark: '',
          planIssueDate: '',
          outWorkOrderFlag: false,
        },
        pageIndex: 1,
        pageSize: 100,
        totalPage: 0,
        //工单分页
        co_pageIndex: 1,
        co_pageSize: 100,
        co_totalPage: 0,
        dataListLoading: false,
        currentRow:'',
        columnList1:[
          {
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1NotifyNo',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "notifyNo",
            headerAlign: "center",
            align: "center",
            columnLabel: "申请单单号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1NotifyDate',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "notifyDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "申请日期",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1UserName',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "userName",
            headerAlign: "center",
            align: "left",
            columnLabel: "申请账号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1UserDisplay',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "userDisplay",
            headerAlign: "center",
            align: "left",
            columnLabel: "申请人姓名",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1IssueFlag',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "issueFlag",
            headerAlign: "center",
            align: "center",
            columnLabel: "是否领料",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1IssueResult',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "issueResult",
            headerAlign: "center",
            align: "left",
            columnLabel: "领料结果",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1Status',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "status",
            headerAlign: "center",
            align: "left",
            columnLabel: "状态",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1WcsPushFlag',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "wcsPushFlag",
            headerAlign: "center",
            align: "left",
            columnLabel: "推送WCS",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table1Remark',
            tableId: "701002Table1",
            tableName: "领料申请主表",
            columnProp: "remark",
            headerAlign: "center",
            align: "left",
            columnLabel: "备注",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 200
          },
        ],
        columnList2:[
          {
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table2ItemNo',
            tableId: "701002Table2",
            tableName: "申请单派工单明细表",
            columnProp: "itemNo",
            headerAlign: "center",
            align: "right",
            columnLabel: "序号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 40
          },
          {
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table2NeedDate',
            tableId: "701002Table2",
            tableName: "领料申请派工单子表",
            columnProp: 'needDate',
            headerAlign: "center",
            align: "left",
            columnLabel: '要求发料时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80,
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table2SOOrderNo',
            tableId: "701002Table2",
            tableName: "申请单派工单明细表",
            columnProp: "sOOrderNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "生产订单",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          }, {
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table2FGPartNo',
            tableId: "701002Table2",
            tableName: "申请单派工单明细表",
            columnProp: "fGPartNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "工单物料",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80

          },

        ],
        columnList3:[
          {
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3ItemNo',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "itemNo",
            headerAlign: "center",
            align: "right",
            columnLabel: "申请单序号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3ComponentPartNo',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "componentPartNo",
            headerAlign: "center",
            align: "center",
            columnLabel: "材料编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3NeedDate',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "needDate",
            headerAlign: "center",
            align: "center",
            columnLabel: "需求时间",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 110
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3QtyToIssue',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "qtyToIssue",
            headerAlign: "center",
            align: "right",
            columnLabel: "申请数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3QtyToIssueOriginal',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "qtyToIssueOriginal",
            headerAlign: "center",
            align: "right",
            columnLabel: "已发数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3IssueType',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "issueType",
            headerAlign: "center",
            align: "right",
            columnLabel: "类型",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3Remark',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "remark",
            headerAlign: "center",
            align: "left",
            columnLabel: "备注",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 160
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3SOOrderNo',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "orderNo",
            headerAlign: "center",
            align: "left",
            columnLabel: "生产订单",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table3BOMItemNo',
            tableId: "701002Table3",
            tableName: "申请单材料明细表",
            columnProp: "bOMItemNo",
            headerAlign: "center",
            align: "right",
            columnLabel: "BOM序号",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80

          },
        ],
        columnList4:[
          {
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table4IssueType',
            tableId: "701002Table4",
            tableName: "申请单材料明细表",
            columnProp: "issueType",
            headerAlign: "center",
            align: "center",
            columnLabel: "类型",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          {
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table4ComponentPartNo',
            tableId: "701002Table4",
            tableName: "申请单材料明细表",
            columnProp: "componentPartNo",
            headerAlign: "center",
            align: "center",
            columnLabel: "材料编码",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 100
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table4PartDesc',
            tableId: "701002Table4",
            tableName: "申请单材料明细表",
            columnProp: "partDesc",
            headerAlign: "center",
            align: "left",
            columnLabel: "材料名称",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 130
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table4QtyToIssue',
            tableId: "701002Table4",
            tableName: "申请单材料明细表",
            columnProp: "qtyToIssue",
            headerAlign: "center",
            align: "right",
            columnLabel: "合计申请数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },{
            userId: this.$store.state.user.name,
            functionId: 701002,
            serialNumber: '701002Table4QtyToIssueOriginal',
            tableId: "701002Table4",
            tableName: "申请单材料明细表",
            columnProp: "qtyToIssueOriginal",
            headerAlign: "center",
            align: "right",
            columnLabel: "合计已发数量",
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
        ],

        // 导出 start
        exportData: [],
        exportName: '发料申请单'+this.dayjs().format('YYYYMMDDHHmmss'),
        exportHeader: ["发料申请单"],
        exportFooter: [],
        // 导出 end
        orderDetailData:{
          orderNo:'',
          seqNo:'',
          locationNo:'',
          qtyrequired:'',
          issureQty:0,
          partDesc:'',
          partNo:'',
          resourceId:'',
          resourceDesc:'',
          needDate:'',
          itemDesc:'',
          workCenterNo:'',
          itemNo:0,
          materialType:'BOM物料',
        },
        chooseSOSModalFlag: false,
        chooseSOSData: {
          orderno: '',
          seqno: '',
          sResourceid: '',
          startDate: '',
          endDate: '',
        },
        chooseOrderModalFlag: false,
        chooseOrderData: {
          page: 1,
          limit: 100,
          orderNo: '',
          status: '',
          date3: '',
          date4: '',
          statusList: '',
        },
        chooseOrderList: [],
        chooseOperationModalFlag: false,
        chooseOperationData: {
          orderNo: '',
          site: '',
          itemDesc: ''
        },
        chooseOperationList: [],
        chooseResourceModalFlag: false,
        chooseResourceData: {
          site: '',
          workCenterNo: '',
          resourceID: '',
          resourceDesc: '',
        },
        chooseResourceList: [],
        chooseSOSList: [],
        choosePartModalFlag: false,
        choosePartData: {
          site: '',
          sourceBu: '',
          partNo: '',
          partDesc: '',
          spec: '',
        },
        choosePartList: [],
      }
    },
    mounted () {
      this.$nextTick(() => {
        this.height = (window.innerHeight- 315) / 2
      })
    },


    created () {

    },
    methods: {

      // 每页数
      sizeChangeHandle (val) {
        this.pageSize = val
        this.searchTable()
      },
      // 当前页
      currentChangeHandle (val) {
        this.pageIndex = val
        this.searchTable()
      },
      tabClick (tab, event) {
        // 刷新列表数据
        this.refreshCurrentTabTable()
      },
      changeData(row){
        this.currentRow = JSON.parse(JSON.stringify(row));
        this.refreshCurrentTabTable ();
      },
      refreshCurrentTabTable(){
        if(this.currentRow===''||this.currentRow===null){
          this.currentRow={site:'',notifyNo:''}
        }
        if(this.activeName==='detail'){
          searchNotifyOrderList(this.currentRow).then(({data}) => {
            //区分请求成功和失败的状况
            if (data && data.code == 0) {
              this.dataList2 = data.rows

            } else {
              this.dataList2 = [];
            }
          });
        }else if(this.activeName==='sub'){
          searchNotifyMaterialList(this.currentRow).then(({data}) => {
            //区分请求成功和失败的状况
            if (data && data.code == 0) {
              this.dataList3 = data.rows

            } else {
              this.dataList3 = [];
            }
          });
        }else if(this.activeName==='change'){
          searchNotifyLog(this.currentRow).then(({data}) => {
            //区分请求成功和失败的状况
            if (data && data.code == 0) {
              this.dataList5 = data.rows

            } else {
              this.dataList5 = [];
            }
          });
        }else if(this.activeName==='close'){
          searchNotifyLogClose(this.currentRow).then(({data}) => {
            //区分请求成功和失败的状况
            if (data && data.code == 0) {
              this.dataList6 = data.rows

            } else {
              this.dataList6 = [];
            }
          });
        }else {
          searchSumNotifyMaterialList(this.currentRow).then(({data}) => {
            //区分请求成功和失败的状况
            if (data && data.code == 0) {
              this.dataList4 = data.rows

            } else {
              this.dataList4 = [];
            }
          });
        }
      },
      searchTable(){
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        searchNotifyHeader(this.searchData).then(({data}) => {
          //区分请求成功和失败的状况
          if (data && data.code == 0) {
            this.dataList = data.page.list
            this.pageIndex = data.page.currPage
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = [];
          }
        });
      },
      closeNotifyModel(row){
        this.closeData.site=row.site
        this.closeData.notifyNo=row.notifyNo
        this.closeData.closeRemark=''
        this.closeModalFlag=true
      },
      closeNotify(){
        if(this.closeData.closeRemark==null||this.closeData.closeRemark===''){
          this.$alert("必须输入关闭原因", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }

            let inData={
              site:this.closeData.site,
              notifyNo:this.closeData.notifyNo,
              closeRemark:this.closeData.closeRemark,
              username:this.$store.state.user.name,
              status:'已关闭',
            }
          updateNotifyStatus(inData).then(({data}) => {
            if (data && data.code === 0) {
              this.closeModalFlag=false
              this.searchTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })

      },
      openNotify(row){
        this.$confirm('确认打开?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let inData={
            site:row.site,
            notifyNo:row.notifyNo,
            status:'已下达',
          }
          updateNotifyStatus(inData).then(({data}) => {
            if (data && data.code === 0) {
              this.searchTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },
      deleteNotifyMaterial(row){
        this.$confirm('确认删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteNotifyMaterial(row).then(({data}) => {
            if (data && data.code === 0) {
              this.refreshCurrentTabTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },
      deleteNotifySOSPlus(row){
        this.$confirm('确认删除?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          deleteNotifySOSPlus(row).then(({data}) => {
            if (data && data.code === 0) {
              this.refreshCurrentTabTable()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {}
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        })
      },




      //导出excel
      async createExportData() {
        this.searchData.limit = -1
        this.searchData.page = 1
        const {data} = await searchNotifyHeader(this.searchData)
        return data.page.list;
      },
      startDownload() {
        //  this.exportData = this.dataList

      },
      finishDownload() {
      },
      fields() {
        let json = "{"
        this.columnList1.forEach((item, index) => {
          if (index == this.columnList1.length - 1) {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
          } else {
            json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
          }
        })
        json += "}"
        let s = eval("(" + json + ")")

        return s
      },

      tableRowClassName ({row, rowIndex}) {

        if (row.qtyToIssueOriginal<row.qtyToIssue&&new Date(row.needDate)<new Date(this.dayjs().format("YYYY-MM-DD HH:mm"))) {
          return 'error-row'
        }

        return ''
      },


    },

  }
</script>

<style scoped>
/deep/ .el-form-item--medium .el-form-item__content {
  height: auto;
}
.disabled {
  cursor: not-allowed !important;
  color: #C0C4CC !important;
  pointer-events: none;
}

.text-right >>> .el-input__inner {
  text-align: right !important;
}

.text-right >>> .el-input-number__input {
  text-align: right !important;
}

.single-line-multi-select >>> .el-select__tags {
  display: flex;
  flex-wrap: nowrap;
  overflow: hidden;
  white-space: nowrap;
  max-width: 100%;
}

.single-line-multi-select >>> .el-tag {
  flex-shrink: 0;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.single-line-multi-select >>> .el-select__input {
  flex-shrink: 0;
  min-width: 30px;
}
</style>
