<template>
  <div class="app-container">
    <div v-if="isPercentage" class="percentage" style="width: 210px;height: 90px;background: #fff;position: fixed;bottom: 0;left: 0;z-index: 9999999999999;">
      <h4 style="padding-left: 10px;line-height: 0;">导出进度：</h4>
      <el-progress style="padding-left: 10px;" :text-inside="true" :stroke-width="26" :percentage="percentage" />
    </div>
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane v-if="isDistributionSheet" label="采购配单" name="first">
        <div class="purchaseDistributionSheet">
          <el-table
            :key="tableKey1"
            v-loading="listLoading1"
            element-loading-text="给我一点时间"
            :data="list1"
            border
            fit
            :row-style="tableRowStyle"
            :cell-style="tableCellStyle"
            highlight-current-row
            style="width: 100%;"
            class="elTable table-fixed"
            @cell-click="cellClick"
            @sort-change="tableSort"
          >
            <el-table-column label="序号" align="center" type="index" width="50px">
              <template slot-scope="scope">
                <span>{{ scope.$index + (pageNum1-1) * pageSize1 + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column label="备件编号" align="center" min-width="150px">
              <template slot-scope="scope">
                <span>{{ scope.row.partCode }}</span>
              </template>
            </el-table-column>
            <el-table-column label="备件名称" align="center" min-width="120px">
              <template slot-scope="scope">
                <span>{{ scope.row.partName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="备件规格" align="center" min-width="120px">
              <template slot-scope="scope">
                <span>{{ scope.row.specification }}</span>
              </template>
            </el-table-column>
            <el-table-column label="备件品牌" min-width="100px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brand }}</span>
              </template>
            </el-table-column>
            <el-table-column label="计量单位" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.unit }}</span>
              </template>
            </el-table-column>
            <el-table-column label="图片" min-width="110px" align="center">
              <template slot-scope="scope">
                <el-popover placement="right" title="" trigger="hover">
                  <img v-if="scope.row.picpath !==''" :src="scope.row.picpath">
                  <img v-if="scope.row.picpath !==''" slot="reference" :src="scope.row.picpath" :alt="scope.row.srcpath" style="height: 100px;width:100px;">
                </el-popover>
              </template>
            </el-table-column>
            <el-table-column label="供应商" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.providerName }}</span>
              </template>
            </el-table-column>
            <el-table-column sortable prop="price" label="单价" min-width="70px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.price }}</span>
              </template>
            </el-table-column>
            <el-table-column sortable prop="sumAmount" label="申购数量" min-width="90px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.sumAmount }}</span>
              </template>
            </el-table-column>
            <el-table-column label="采购数量" min-width="110px" align="center">
              <template slot-scope="scope">
                <el-form :model="scope.row" :rules="rules">
                  <el-form-item prop="amount">
                    <el-input
                      v-model="scope.row.amount"
                      style="width:80px;margin-top:25px;height:10px"
                    />
                  </el-form-item>
                </el-form>
              </template>
            </el-table-column>
          </el-table>
          <el-button :disabled="confirmationSheetDisabled" type="primary" style="float: right;margin-top: 10px;" @click="confirmationSheet()">确认配单</el-button>
          <el-dialog :title="textMap[dialogStatusConfirmation]" :visible.sync="dialogFormVisibleConfirmation" :close-on-click-modal="false" style="width:100%;margin: 0 auto;overflow:auto">
            <div class="app-contentConfirmationSheet">
              <el-form ref="temp1" :rules="rules" :model="temp1" label-position="right" label-width="90px" style="width:100%;margin-bottom:50px">
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="配单号:" prop="matchCode">
                      <el-input ref="matchCode" v-model="temp1.matchCode" disabled />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="提交日期：" prop="buyerDate">
                      <el-date-picker
                        v-model="temp1.buyerDate"
                        :picker-options="pickerOptions"
                        type="date"
                        placeholder="提交日期"
                        format="yyyy-MM-dd"
                        value-format="yyyy-MM-dd"
                        style="width:170px;"
                      />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="采购员：" prop="buyerPerson">
                      <el-select v-model="temp1.buyerPerson" placeholder="采购员" class="filter-item">
                        <el-option
                          v-for="item in findAllEmploye"
                          :key="item.id"
                          :label="item.name"
                          :value="item.id"
                        />
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <div v-for="(item,index) in listConfirmationSheet" :key="index" class="app-content">
                <div class="title">
                  <div>
                    <b>采购单号：</b>
                    <span>{{ item.orderNumber }}</span>
                  </div>
                  <div>
                    <b>供应商：</b>
                    <span>{{ item.providerName }}</span>
                  </div>
                </div>
                <el-table
                  :key="tableKey1"
                  v-loading="listLoading1"
                  element-loading-text="给我一点时间"
                  :data="item.list"
                  border
                  fit
                  highlight-current-row
                  style="width: 97%;margin:0 auto"
                  :row-style="rowStyle"
                  :cell-style="cellStyle"
                  class="elTable table-fixed"
                >
                  <!-- table表格 -->
                  <el-table-column label="序号" align="center" type="index" width="50px">
                    <template slot-scope="scope">
                      <span>{{ scope.$index + (pageNum1-1) * pageSize1 + 1 }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="备件编号" align="center" min-width="150px">
                    <template slot-scope="scope">
                      <span>{{ scope.row.partCode }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="备件名称" align="center" min-width="120px">
                    <template slot-scope="scope">
                      <span>{{ scope.row.partName }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="备件规格" align="center" min-width="120px">
                    <template slot-scope="scope">
                      <span>{{ scope.row.specification }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="图片" min-width="110px" align="center">
                    <template slot-scope="scope">
                      <el-popover placement="right" title="" trigger="hover">
                        <img v-if="scope.row.picpath !==''" :src="scope.row.picpath">
                        <img v-if="scope.row.picpath !==''" slot="reference" :src="scope.row.picpath" :alt="scope.row.srcpath" style="height: 100px;width:100px;">
                      </el-popover>
                    </template>
                  </el-table-column>
                  <el-table-column label="备件品牌" min-width="100px" align="center">
                    <template slot-scope="scope">
                      <span>{{ scope.row.brand }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="计量单位" min-width="80px" align="center">
                    <template slot-scope="scope">
                      <span>{{ scope.row.unit }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="单价" min-width="70px" align="center">
                    <template slot-scope="scope">
                      <span>{{ scope.row. price }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="申购数量" min-width="90px" align="center">
                    <template slot-scope="scope">
                      <span>{{ scope.row.sumAmount }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="合计采购数量" min-width="90px" align="center">
                    <template slot-scope="scope">
                      <span>{{ scope.row.amount }}</span>
                    </template>
                  </el-table-column>
                  <el-table-column label="总价" min-width="90px" align="center">
                    <template slot-scope="scope">
                      <span>{{ (scope.row.sumPrice = scope.row.price * parseFloat(scope.row.amount))| keepTwoNum }}</span>
                    </template>
                  </el-table-column>
                </el-table>
                <div ref="total" class="total">
                  合计：
                  <span>{{ item.Sum }}</span>
                </div>
              </div>
              <div slot="footer" class="dialog-footer" style="bottom:10px">
                <el-button type="primary" :disabled="isokDisable" @click="confirmationSheetData()">确认</el-button>
                <el-button @click="dialogFormVisibleConfirmation= false;getList1();">取消</el-button>
              </div>
            </div>
          </el-dialog>
        </div>
      </el-tab-pane>
      <el-tab-pane v-if="isDistributionManagement" label="配单管理" name="fouth">
        <div class="DistributionManagement">
          <div class="filter-container">
            <el-select v-model="getdataListParm4.parammaps.pastureName" style="width: 140px;" placeholder="牧场" class="filter-item">
              <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
            </el-select>
            <el-input v-model="getdataListParm4.parammaps.matchCode" placeholder="配单号" clearable style="width: 200px;" class="filter-item" />
            <el-select v-model="getdataListParm4.parammaps.statue" clearable placeholder="审核状态" class="filter-item" style="width: 120px;">
              <el-option v-for="item in status2" :key="item.id" :label="item.name" :value="item.id" />
            </el-select>
            <el-date-picker ref="inputDatetime4" v-model="getdataListParm4.parammaps.inputDatetime" class="inputDatetime" type="datetimerange" style="width: 270px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始提交日期" end-placeholder="结束提交日期" />
            <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search4">搜索</el-button>

            
            
          </div>
          <el-table
            :key="tableKey4"
            v-loading="listLoading4"
            element-loading-text="给我一点时间"
            :data="list4"
            border
            fit
            highlight-current-row
            style="width: 100%;"
            :row-style="rowStyle"
            :cell-style="cellStyle"
            class="elTable table-fixed" 
            @sort-change="tableSort"
            @current-change="handleCurrentChange"
        
          >
         
            <el-table-column label="序号" align="center" type="index" width="50px">
              <template slot-scope="scope">
                <span>{{ scope.$index + (pageNum2-1) * pageSize2 + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column label="牧场" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.pastureName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="配单号" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.matchCode }}</span>
              </template>
            </el-table-column>
            <el-table-column label="采购员" min-width="130px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.empname }}</span>
              </template>
            </el-table-column>
            <el-table-column label="提交日期" sortable prop="dealTime" min-width="110px" align="center" />
            <el-table-column sortable prop="cou" label="采购单数" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.cou }}</span>
              </template>
            </el-table-column>
            <el-table-column label="审核状态" min-width="80px" align="center" :formatter="statue" />
           
            <el-table-column label="操作" align="center" width="250px" class-name="small-padding fixed-width" fixed="right">
              <template slot-scope="{row}">
                <el-button v-if="isPurchaseSee" type="primary" size="mini" @click="form_see4(row)">查看</el-button>
                <el-button v-if="parseFloat(row.statue) === 0 && isExamineDM" style="display:inline-block" type="success" size="mini" @click="handleExamine(row)">审核</el-button>
                <el-button v-else style="display:none;" type="success" size="mini" @click="handleExamine(row)">审核</el-button>
                <el-button v-if="parseFloat(row.statue) === 2" type="success" style="display:inline-block" size="mini" @click="form_edit(row)">编辑</el-button>
                <el-button v-else style="display:none;" type="success" size="mini" @click="form_edit(row)">编辑</el-button>
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total4>0" :total="total4" :page.sync="getdataListParm4.offset" :limit.sync="getdataListParm4.pagecount" @pagination="getList4" />
          <el-dialog :title="textMap[dialogStatusSee4]" :visible.sync="dialogFormVisibleSee4" :close-on-click-modal="false">
            <div class="app-contentSee">
              <el-form ref="temp4" :rules="rules" :model="temp4" label-position="right" label-width="80px" style="width: 800px;margin-bottom:30px">
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="配单号:" prop="matchCode">
                      <span>{{ temp4.matchCode }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="采购员:" prop="empname">
                      <span>{{ temp4.empname }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="配单日期:" prop="dealTime">
                      <span>{{ temp4.dealTime }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <el-table
                :key="tableKeySee4"
                v-loading="listLoadingSee4"
                element-loading-text="给我一点时间"
                :data="listSee4"
                border
                fit
                highlight-current-row
                style="width: 100%;margin-bottom:100px"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable table-fixed"
                
              >
             
                <el-table-column label="序号" align="center" type="index" width="50px" />
                <el-table-column label="采购单号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.buyeCode }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件编号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partCode }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件名称" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件规格" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件品牌" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.brand }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="计量单位" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.unit }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="供应商" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.providerName }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="price" label="单价" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.price }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="sumAmount" label="申购数量" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.sumAmount }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="amount" label="采购数量" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.amount }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="sumPrice" label="总价" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.sumPrice }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件图片" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <el-popover placement="right" title="" trigger="hover">
                      <img v-if="scope.row.picpath !==''" :src="scope.row.picpath">
                      <img v-if="scope.row.picpath !==''" slot="reference" :src="scope.row.picpath" :alt="scope.row.srcpath" style="height: 100px;width:100px;">
                    </el-popover>
                  </template>
                </el-table-column>
                <el-table-column prop="SGremark" label="备注" min-width="60px" align="center" />
              </el-table>
              <el-form ref="temp4" :rules="rules" :model="temp4" label-position="right" label-width="120px" style="width: 90%;margin:0 auto;">
                <el-row>
                  <el-col>
                    <el-form-item label="流程进度" />
                    <el-steps :active="active" align-center finish-status="success">
                      <el-step
                        v-for="(item,index) in activeList"
                        :key="index"
                        :title="item.title"
                        :status="item.status"
                      >
                        <template slot="description">
                          <div class="step-row">
                            <div>{{ item.name }}&nbsp;&nbsp;{{ item.date }}</div>
                            <div>{{ item.reason }}</div>
                          </div>
                        </template>
                      </el-step>
                    </el-steps>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col>
                    <el-form-item label="操作：">
                      <!-- 审核 -->
                      <el-button v-if="isExamineDM && temp4.statue == 0" type="success" style="display:inline-block" @click="handleExamine()">审核</el-button>
                      <el-button v-else type="success" style="display:none" @click="handleExamine()">审核</el-button>

                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:10px">
                <el-button @click="dialogFormVisibleSee4 = false;">关闭</el-button>
              </div>
            </div>
          </el-dialog>

          <el-dialog :title="textMap[dialogStatusUpdate4]" width="90%" :visible.sync="dialogFormVisibleUpdate4" :close-on-click-modal="false">
            <div class="app-contentUpdate">
              <el-form
                ref="updateTemp4"
                :rules="rules"
                :model="updateTemp4"
                label-position="right"
                label-width="80px"
                style="width:80%;margin-bottom:30px"
              >
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="配单号:" prop="matchCode">
                      <span>{{ updateTemp4.matchCode }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="采购员:" prop="empname">
                      <span>{{ updateTemp4.empname }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="配单日期:" prop="dealTime">
                      <span>{{ updateTemp4.dealTime }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <el-table
                :key="tableKeyUpdate4"
                v-loading="listLoadingUpdate4"
                element-loading-text="给我一点时间"
                :data="listUpdate4"
                border
                fit
                highlight-current-row
                style="width: 100%;margin-bottom:100px"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable table-fixed"
              >
                <!-- table表格 -->
                <el-table-column label="序号" align="center" type="index" width="50px" />
                <el-table-column label="采购单号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.buyeCode }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件编号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partCode }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件名称" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件规格" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件品牌" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.brand }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="计量单位" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.unit }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="供应商" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.providerName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="单价" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.price }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="申购数量" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.sumAmount }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="采购数量" min-width="100px" align="center">
                  <template slot-scope="scope">
                    <el-form :model="scope.row" :rules="rules">
                      <el-form-item prop="amount">
                        <el-input
                          v-model="scope.row.amount"
                          style="width:80px;margin-top:25px;height:10px"
                        />
                      </el-form-item>
                    </el-form>
                  </template>
                </el-table-column>
                <el-table-column label="总价" min-width="60px" align="center">
                  <template slot-scope="scope">
                    <span>{{ (parseFloat(scope.row.price) * parseFloat(scope.row.amount)) | keepTwoNum2 }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件图片" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <el-popover placement="right" title="" trigger="hover">
                      <img v-if="scope.row.picpath !==''" :src="scope.row.picpath">
                      <img v-if="scope.row.picpath !==''" slot="reference" :src="scope.row.picpath" :alt="scope.row.srcpath" style="height: 100px;width:100px;">
                    </el-popover>
                  </template>
                </el-table-column>
              </el-table>
              <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:10px">
                <el-button type="primary" :disabled="isokDisable" @click="edit_dialog_save()">确认</el-button>
                <el-button @click="dialogFormVisibleUpdate4 = false;">关闭</el-button>
              </div>
            </div>
          </el-dialog>

          <el-dialog :title="textMap[dialogStatus_Examine]" :visible.sync="dialogFormVisible_Examine" :close-on-click-modal="false" width="30%">
            <div class="app-examine">
              <h3 style="width: 100%;margin:0 0 0 5%;line-height:50px;">请确认审核结果:</h3>
              <el-form ref="examineTemp" :rules="rules" :model="examineTemp" label-position="right" style="width: 50%;margin:0 auto;">
                <el-row style="width:88%;height:150px;margin:0 auto;">
                  <el-col :span="20">
                    <el-form-item>
                      <el-radio-group v-model="examineTemp.SHstatue" @change="changeSHStatue">
                        <el-radio :label="1" checked>通过</el-radio>
                        <el-radio :label="2">不通过</el-radio>
                      </el-radio-group>
                    </el-form-item>
                  </el-col>
                  <el-col v-if="statueReason" :span="20">
                    <el-input v-model="examineTemp.workflowNote" type="textarea" :autosize="{ minRows: 2, maxRows: 4}" placeholder="请输入不通过原因" />
                  </el-col>
                </el-row>
              </el-form>
            </div>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" :disabled="isokDisable" @click="dialogStatus_Examine==='examine'?createExamineData():createExamineData()">确认</el-button>
              <el-button @click="dialogFormVisible_Examine = false;">关闭</el-button>
            </div>
          </el-dialog>

        </div>
      </el-tab-pane>
      <el-tab-pane label="采购单管理" name="second">
        <div class="purchaseOrderManagement">
          <div class="filter-container">
            <el-select v-model="getdataListParm2.parammaps.pastureName" style="width: 140px;" placeholder="牧场" class="filter-item">
              <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
            </el-select>
            <el-input v-model="getdataListParm2.parammaps.buyeCode" placeholder="采购单号" clearable style="width: 200px;" class="filter-item" />
            <el-select v-model="getdataListParm2.parammaps.statu" clearable placeholder="单据状态" class="filter-item" style="width: 120px;">
              <el-option v-for="item in status" :key="item.id" :label="item.name" :value="item.id" />
            </el-select>
            <el-autocomplete v-model="getdataListParm2.parammaps.providerName" value-key="providerName" class="inline-input" :fetch-suggestions="providerSearch" placeholder="供应商" style="width:150px;top:-3px;" @select="handleSelectProvider" />
            <el-date-picker ref="inputDatetime2" v-model="getdataListParm2.parammaps.inputDatetime" class="inputDatetime" type="datetimerange" style="width: 270px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始提交日期" end-placeholder="结束提交日期" />
            <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search2">搜索</el-button>
            <el-button v-waves v-if="isPurchaseSap" class="filter-item" type="primary" @click="sapUpload">SAP上传</el-button>
            <el-button v-waves  v-if="isPurchaseSrm" class="filter-item" type="primary" @click="srmUpload">SRM上传</el-button>
          </div>
          <el-table
            :key="tableKey2"
            v-loading="listLoading2"
            element-loading-text="给我一点时间"
            :data="list2"
            border
            fit
            highlight-current-row
            style="width: 100%;"
            :row-style="rowStyle"
            :cell-style="cellStyle"
            class="elTable table-fixed"
            @sort-change="tableSort"
            @selection-change="change_table_selection"
          >
          <el-table-column type="selection" :selectable="checkboxInit" align="center" width="50" />
            <el-table-column label="序号" align="center" type="index" width="50px">
              <template slot-scope="scope">
                <span>{{ scope.$index + (pageNum2-1) * pageSize2 + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column label="牧场" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.pastureName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="采购单号" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.buyeCode }}</span>
              </template>
            </el-table-column>
            <el-table-column label="供应商" min-width="130px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.providerName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="采购员" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.empname }}</span>
              </template>
            </el-table-column>
            <el-table-column label="提交日期" sortable prop="buyerDate" min-width="110px" align="center" />
            <el-table-column label="最近到货日期" sortable prop="DoneDate" min-width="110px" align="center" />
            <el-table-column label="单据状态" min-width="80px" align="center" :formatter="statu" />
            <el-table-column  prop="sapNumber" label="sap编码" min-width="80px" align="center">
              <template slot-scope="scope">
                <span>{{scope.row.sapNumber}}</span>
              </template>
            </el-table-column>
            <el-table-column   prop
            <el-table-column   prop="sapstatus" label="sap上传状态" min-width="80px" align="center">
              <template slot-scope="scope">
                <span v-show="scope.row.sapstatus == 1">上传失败</span>
                <span v-show="scope.row.sapstatus == -1">未上传</span>
                <span v-show="scope.row.sapstatus == 0">上传成功</span>
              </template>
            </el-table-column>
            <el-table-column   prop="srmstatus" label="srm上传状态" min-width="80px" align="center">
              <template slot-scope="scope">
                <span v-show="scope.row.srmstatus == 1">上传失败</span>
                <span v-show="scope.row.srmstatus == -1">未上传</span>
                <span v-show="scope.row.srmstatus == 0">上传成功</span>
              </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="250px" class-name="small-padding fixed-width" fixed="right">
              <template slot-scope="{row}">
                <el-button v-if="isPurchaseSee" type="primary" size="mini" @click="form_see2(row)">查看</el-button>
                <el-button v-if="(row.statu === 2 || row.statu === 4) && isPurchaseClose" style="display:none" type="danger" size="mini" @click="handleClose2(row)">关闭</el-button>
                <el-button v-else-if="isPurchaseClose" style="display:inline-block" type="danger" size="mini" @click="handleClose2(row)">关闭</el-button>
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total2>0" :total="total2" :page.sync="getdataListParm2.offset" :limit.sync="getdataListParm2.pagecount" @pagination="getList2" />
          <el-dialog :title="textMap[dialogStatusSee2]" :visible.sync="dialogFormVisibleSee2" :close-on-click-modal="false">
            <div class="app-contentSee">
              <el-form
                ref="temp2"
                :rules="rules"
                :model="temp2"
                label-position="right"
                label-width="80px"
                style="width: 800px;margin-bottom:30px"
              >
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="采购单号:" prop="buyeCode">
                      <span>{{ temp2.buyeCode }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="供应商:" prop="providerName">
                      <span>{{ temp2.providerName }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="采购员:" prop="empname">
                      <span>{{ temp2.empname }}</span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="5">
                    <el-form-item label="提交日期:" prop="buyerDate">
                      <span>{{ temp2.buyerDate }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <el-table
                :key="tableKeySee2"
                v-loading="listLoadingSee2"
                element-loading-text="给我一点时间"
                :data="listSee2"
                border
                fit
                highlight-current-row
                style="width: 100%;margin-bottom:100px"
                :row-style="rowStyle"
                :cell-style="cellStyle"
                class="elTable table-fixed"
                @sort-change="tableSort2"
              >
                <el-table-column label="序号" align="center" type="index" width="50px" />
                <el-table-column label="备件编号" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partCode }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件名称" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.partName }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件规格" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.specification }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="备件图片" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <el-popover placement="right" title="" trigger="hover">
                      <img v-if="scope.row.picpath !==''" :src="scope.row.picpath">
                      <img v-if="scope.row.picpath !==''" slot="reference" :src="scope.row.picpath" :alt="scope.row.srcpath" style="height: 100px;width:100px;">
                    </el-popover>
                  </template>
                </el-table-column>
                <el-table-column label="备件品牌" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.brand }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="计量单位" min-width="130px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.unit }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="price" label="单价(元)" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.price }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="sumAmount" label="申购数量" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.sumAmount }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="amount" label="采购数量" min-width="130px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.amount }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="sumPrice" label="总价(元)" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.sumPrice }}</span>
                  </template>
                </el-table-column>
                <el-table-column sortable prop="receiveAmount" label="入库数" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.receiveAmount }}</span>
                  </template>
                </el-table-column>
                <el-table-column prop="SGremark" label="备注" min-width="110px" align="center">
                  <template slot-scope="scope">
                    <span>{{ scope.row.SGremark }}</span>
                  </template>
                </el-table-column>
              </el-table>
              <div class="sum" style="right:30px;position:absolute;bottom:90px">
                <b>总计：{{ temp2.sumPrices }}元</b>
              </div>
              <div class="stuts" style="left:30px;position:absolute;bottom:70px">
                <b>单据状态：{{ temp2.statu }}</b>
                <b v-if="isStatu">关闭原因：{{ temp2.note }}</b>
                <div v-if="isExtensionDays">延期天数：{{ temp2.extensionDays }}</div>
              </div>
              <div
                slot="footer"
                class="dialog-footer"
                style="right:30px;position:absolute;bottom:10px"
              >
                <el-button @click="dialogFormVisibleSee2 = false;getList2()">关闭</el-button>
              </div>
            </div>
          </el-dialog>
          <el-dialog :title="textMap[dialogStatusClose]" :visible.sync="dialogFormVisibleClose" :close-on-click-modal="false" style="width:70%;margin: 0 auto">
            <div class="app-contentClose">
              <el-form
                ref="temp2"
                :rules="rules"
                :model="temp2"
                label-position="right"
                label-width="80px"
                style="width: 300px;margin-bottom:30px"
              >
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="采购单号:" prop="orderNo">
                      <span>{{ temp2.buyeCode }}</span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="" prop="note">
                      <el-input ref="note" v-model="temp2.note" type="textarea" placeholder="请输入关闭该采购单原因" />
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
              <div
                slot="footer"
                class="dialog-footer"
                style="right:30px;position:absolute;bottom:10px"
              >
                <el-button @click="dialogFormVisibleClose = false;getList2();">取消</el-button>
                <el-button type="primary" :disabled="isokDisable" @click="closeData()">确认关闭</el-button>
              </div>
            </div>
          </el-dialog>
        </div>
      </el-tab-pane>
      <el-tab-pane label="采购明细" name="third">
        <div class="procurementDetails">
          <div class="filter-container">
            <el-select v-model="getdataListParm3.parammaps.pastureName" style="width: 140px;" placeholder="牧场" class="filter-item">
              <el-option v-for="item in findAllPasture" :key="item.id" :label="item.name" :value="item.name" />
            </el-select>
            <el-input v-model="getdataListParm3.parammaps.partCode" placeholder="备件编号" style="width: 200px;" class="filter-item" />
            <el-input v-model="getdataListParm3.parammaps.partName" placeholder="备件名称" style="width: 140px;" class="filter-item" />
            <el-autocomplete v-model="getdataListParm3.parammaps.providerName" value-key="providerName" class="inline-input" :fetch-suggestions="providerSearch" placeholder="供应商" style="width:150px;top:-3px;" @select="handleSelectProvider" />
            <el-input v-model="getdataListParm3.parammaps.matchCode" placeholder="配单号" style="width: 140px;" class="filter-item" />
            <el-input v-model="getdataListParm3.parammaps.buyeCode" placeholder="采购单号" style="width: 140px;" class="filter-item" />
            <el-select v-model="getdataListParm3.parammaps.isStorage" clearable placeholder="到货情况" class="filter-item" style="width: 120px;">
              <el-option v-for="item in isStorages" :key="item.id" :label="item.name" :value="item.id" />
            </el-select>
            <el-date-picker ref="inputDatetime3" v-model="getdataListParm3.parammaps.inputDatetime" class="inputDatetime" type="datetimerange" style="width: 270px;top:-3px;" format="yyyy-MM-dd" value-format="yyyy-MM-dd" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" />
            <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="form_search3">搜索</el-button>
            <el-button v-if="isPurchaseExport" class="filter-item" style="margin-left: 10px;" type="success" icon="el-icon-edit" @click="handleDownload3">导出</el-button>
          </div>
          <el-table
            :key="tableKey3"
            v-loading="listLoading3"
            element-loading-text="给我一点时间"
            :data="list3"
            border
            fit
            highlight-current-row
            style="width: 100%;"
            :row-style="rowStyle"
            :cell-style="cellStyle"
            class="elTable table-fixed"
            @sort-change="tableSort"
          >
            <el-table-column label="序号" align="center" type="index" width="50px">
              <template slot-scope="scope">
                <span>{{ scope.$index + (pageNum3-1) * pageSize3 + 1 }}</span>
              </template>
            </el-table-column>
            <el-table-column label="牧场" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.pastureName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="配单号" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.matchCode }}</span>
              </template>
            </el-table-column>
            <el-table-column label="采购单号" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.buyeCode }}</span>
              </template>
            </el-table-column>
            <el-table-column label="备件编号" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.partCode }}</span>
              </template>
            </el-table-column>
            <el-table-column label="备件名称" min-width="130px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.partName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="备件规格" min-width="130px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.specification }}</span>
              </template>
            </el-table-column>
            <el-table-column label="备件品牌" min-width="130px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.brand }}</span>
              </template>
            </el-table-column>
            <el-table-column label="计量单位" min-width="130px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.unit }}</span>
              </template>
            </el-table-column>
            <el-table-column label="供应商" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.providerName }}</span>
              </template>
            </el-table-column>
            <el-table-column sortable prop="price" label="单价" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.price }}</span>
              </template>
            </el-table-column>
            <el-table-column sortable prop="sumAmount" label="申购数量" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.sumAmount }}</span>
              </template>
            </el-table-column>
            <el-table-column sortable prop="amount" label="采购数量" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.amount }}</span>
              </template>
            </el-table-column>
            <el-table-column sortable prop="receiveAmount" label="入库数" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.receiveAmount }}</span>
              </template>
            </el-table-column>
            <el-table-column label="申购部门" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.departmentName }}</span>
              </template>
            </el-table-column>
            <el-table-column label="采购人" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.empname }}</span>
              </template>
            </el-table-column>
            <el-table-column label="配单日期" sortable prop="buyerDate" min-width="110px" align="center" />
            <!-- <el-table-column label="备注" min-width="110px" align="center">
              <template slot-scope="scope">
                <span>{{ scope.row.note }}</span>
              </template>
            </el-table-column> -->
          </el-table>
          <pagination v-show="total3>=0" :total="total3" :page.sync="getdataListParm3.offset" :limit.sync="getdataListParm3.pagecount" @pagination="getList3" />
        </div>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
// 引入
import { GetDataByName, GetDataByNames, ExecDataByConfig, PostDataByName, failproccess, checkButtons, GetAccount,SapOrder,SrmOrder } from '@/api/common'
import waves from '@/directive/waves' // waves directive
import Pagination from '@/components/Pagination' // secondary package based on el-pagination
import Cookies from 'js-cookie'
import { parseTime, sortChange, json2excel } from '@/utils/index.js'
export default {
  name: 'Purchase',
  components: { Pagination },
  directives: { waves },
  filters: {
    keepTwoNum(value) {
      value = Number(value)
      return value.toFixed(3)
    },
    keepTwoNum2(value) {
      value = Number(value)
      return value.toFixed(2)
    }
  },
  data() {
    return {
      isSap:1,
      isSrm:1,
      selectList: [],

      isPurchaseSap: [],isPurchaseSrm: [],
      isPurchaseSee: [], isPurchaseClose: [], isPurchaseExport: [], isDistributionSheet: [], isDistributionManagement: [], isExamineDM: [],
      stripe: true,
      activeName: 'first',
      listLoading1: false,
      tableKey1: 0,
      list1: [],
      confirmationSheetDisabled: false,
      isokDisable: false,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now() // 当天之前的时间可选
        }
      },
      temp: {},
      total: 0,
      total1: 0,
      listParmConfirmation: [],
      listConfirmationSheet: null,
      getParmPurchaseOrderNumber: {
        name: 'autoCreatCode',
        page: 1,
        offset: 1,
        returntype: 'Map',
        parammaps: {
          pastureId: Cookies.get('pastureid'),
          codeType: 'CG'
        }
      },
      postDataPramas: {},
      requestProvider: {
        name: 'getProviderList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {}
      },
      listLoading2: false,
      tableKey2: 0,
      list2: [],
      status2: [
        { id: '0', name: '审核中' },
        { id: '1', name: '审核通过' },
        { id: '2', name: '审核驳回' }
      ],
      status: [
        { id: '0', name: '未到货' },
        { id: '1', name: '部分到货' },
        { id: '2', name: '按时到货' },
        { id: '3', name: '已延期' },
        { id: '4', name: '已关闭' },
        { id: '5', name: '部分到货-延期' },
        { id: '6', name: '全部到货-延期' }
      ],
      isStorages: [
        { id: '0', name: '未入库' },
        { id: '1', name: '已入库' }
      ],
      isStatu: false,
      listLoadingSee2: false,
      tableKeySee2: 0,
      total2: 0,
      total3: 0,
      listLoading3: false,
      tableKey3: 0,
      list3: [],
      findAllEmploye: [],
      findAllPasture: [],
      requestParams: [
        { name: 'findAllEmploye', offset: 0, pagecount: 0, parammaps: { 'pastureId': Cookies.get('pastureid') }},
        { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }}
      ],
      getdataListParm1: {
        name: 'getbuydetailParts',
        page: 1,
        // offset: 1,
        // pagecount: 10,
        returntype: 'Map',
        parammaps: {
          pastureId: Cookies.get('pastureid')
        }
      },
      getdataListPart: {
        name: 'getpartpurchasebg',
        page: 1,
        // offset: 1,
        // pagecount: 10,
        returntype: 'Map',
        parammaps: {
          id: Cookies.get('pastureid')
        }
      },
      partData: [],
      getParmCreateNumber: {
        name: 'autoCreatCode',
        page: 1,
        offset: 1,
        returntype: 'Map',
        parammaps: {
          pastureId: Cookies.get('pastureid'),
          codeType: 'PD'
        }
      },
      pageNum1: 0,
      pageSize1: 0,
      temp1: {
        pastureId: Cookies.get('pastureid'),
        buyerPerson: this.$store.state.user.employeid,
        buyerDate: parseTime(new Date(), '{y}-{m}-{d}')
      },
      getdataListParm2: {
        name: 'getBigbuydetailList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          providerName: '',
          buyeCode: '',
          inputDatetime: '',
          // pastureId: Cookies.get('pastureid'),
          pastureName: Cookies.get('pasturename')
        }
      },
      dialogFormVisibleConfirmation: false,
      dialogStatusConfirmation: '',
      pageNum2: 0,
      pageSize2: 0,
      temp2: {
        note: ''
      },
      getdataListParm3: {
        name: 'getbuydetailList',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          pastureName: Cookies.get('pasturename'),
          providerName: '',
          partCode: '',
          partName: '',
          matchCode: '',
          buyeCode: '',
          isStorage: '',
          startTime: '',
          stopTime: '',
          inputDatetime: ''
        }
      },
      isExtensionDays: false,
      listSee2: [],
      getdataListSee2: {
        name: 'getbuydetailListbyBig',
        returntype: 'Map',
        parammaps: {}
      },
      requestParamStute: {
        name: 'updateBigbuydetailStatu',
        returntype: 'Map',
        parammaps: {}
      },
      pageNum3: 0,
      pageSize3: 0,
      temp3: {},
      dialogFormVisibleSee2: false,
      dialogStatusSee2: '',

      // 配单管理
      listLoading4: false,
      tableKey4: 0,
      list4: [],
      pageNum4: 0,
      pageSize4: 0,
      total4: 0,
      getdataListParm4: {
        name: 'getbigpartdeallist',
        page: 1,
        offset: 1,
        pagecount: 10,
        returntype: 'Map',
        parammaps: {
          pastureName: Cookies.get('pasturename'),
          matchCode: '',
          statue: '',
          inputDatetime: '',
          startTime: '',
          stopTime: ''
        }
      },
      dialogFormVisibleSee4: false,
      dialogStatusSee4: '',
      temp4: {},
      listSee4: [],
      tableKeySee4: 0,
      listLoadingSee4: false,
      getdataListSee4: {
        name: 'getbigpartdealdetiallist',
        returntype: 'Map',
        parammaps: {}
      },
      activeList: [],
      active: 3,

      currentRow:{},

      dialogStatusUpdate4: '',
      dialogFormVisibleUpdate4: false,
      updateTemp4: {},
      listUpdate4: [],
      tableKeyUpdate4: 0,
      listLoadingUpdate4: false,

      dialogFormVisible_Examine: false,
      dialogStatus_Examine: '',
      examineTemp: {
        SHstatue: 1,
        workflowNote: ''
      },
      statueReason: false,
      dialogFormVisibleClose: false,
      dialogStatusClose: '',
      textMap: {
        confirmation: '确认配单',
        see: '查看详情',
        close: '关闭提示',
        examine: '审核',
        update: '编辑'
      },
      // 校验规则
      rules: {
        equipmentName: [{ required: true, message: '必填', trigger: 'blur' }],
        note: [{ required: true, message: '必填', trigger: 'blur' }]
      },
      rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
      cellStyle: { padding: 0 + 'px' },
      buttons: [],
      downloadListParm3: {},
      downloadList3: [],
      isPercentage: false,
      percentage: 1
    }
  },
  created() {
    const that = this
    // GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
    //   that.buttons = response.data.list
    //   that.get_auto_buttons()
    //   if (this.isDistributionSheet == true) {
    //     this.activeName = 'first'
    //     console.log(1, this.isDistributionSheet, this.isDistributionManagement)
    //   } else if (this.isDistributionManagement == true) {
    //     this.activeName = 'fouth'
    //     console.log(2, this.isDistributionSheet, this.isDistributionManagement)
    //   } else if (this.isDistributionSheet == false && this.isDistributionManagement == false) {
    //     this.activeName = 'second'
    //     console.log(3, this.isDistributionSheet, this.isDistributionManagement)
    //   }
    // })
    // this.get_select_list()
    // this.getList1()
    // this.getList2()
    // this.getList3()
    // this.getList4()
    // if (this.$route.query.activeName !== undefined) {
    //   this.activeName = this.$route.query.activeName
    // }


   


      
  },

  methods: {
    tableSort(column) {
      if (this.activeName == 'first') {
        sortChange(column, this.list1)
      } else if (this.activeName == 'second') {
        sortChange(column, this.list2)
      } else if (this.activeName == 'third') {
        sortChange(column, this.list3)
      } else if (this.activeName == 'fouth') {
        sortChange(column, this.list4)
      }
    },
    tableSort2(column) {
      sortChange(column, this.listSee2)
    },
    get_auto_buttons() {
      const DistributionSheet = 'customs:purchase:distributionSheet'
      const isDistributionSheet = checkButtons(this.$store.state.user.buttons, DistributionSheet)
      this.isDistributionSheet = isDistributionSheet

      const PurchaseSee = 'customs:purchase:see'
      const isPurchaseSee = checkButtons(this.$store.state.user.buttons, PurchaseSee)
      this.isPurchaseSee = isPurchaseSee

      const PurchaseClose = 'customs:purchase:close'
      const isPurchaseClose = checkButtons(this.$store.state.user.buttons, PurchaseClose)
      this.isPurchaseClose = isPurchaseClose

      const PurchaseSap = 'customs:purchase:sap'
      const isPurchaseSap = checkButtons(this.$store.state.user.buttons, PurchaseSap)
      this.isPurchaseSap = isPurchaseSap

      const PurchaseSrm = 'customs:purchase:srm'
      const isPurchaseSrm = checkButtons(this.$store.state.user.buttons, PurchaseSrm)
      this.isPurchaseSrm = isPurchaseSrm

      const PurchaseExport = 'customs:purchase:export'
      const isPurchaseExport = checkButtons(this.$store.state.user.buttons, PurchaseExport)
      this.isPurchaseExport = isPurchaseExport

      const ExamineDM = 'customs:purchase:shenhe'
      const isExamineDM = checkButtons(this.$store.state.user.buttons, ExamineDM)
      this.isExamineDM = isExamineDM

      const DistributionManagement = 'customs:purchase:peidanjiemian'
      const isDistributionManagement = checkButtons(this.$store.state.user.buttons, DistributionManagement)
      this.isDistributionManagement = isDistributionManagement
    },
    cellClick(row, column, cell, event) {
      console.log(cell)
      console.log('column', column)
      console.log('行索引', row.id)
      console.log('列索引', column.id)
      return {
        background: '#eceb3c'
      }
      // console.log('event',event)
    },
    tableRowStyle({ row, rowIndex }) {
      console.log(row, row)
      console.log(' row.isParity', row.isParity)
      console.log(parseInt(row.isParity) % 2 == 0)
      if (parseInt(row.isParity) % 2 == 0) {
        return {
          background: '#eee'
        }
      }
      return {
        background: ''
      }
    },
    tableCellStyle({ row, column, rowIndex, columnIndex }) {
      if (row.isNo == 'No' && columnIndex === 10) {
        return {
          background: 'red'
        }
      }
      return {
        background: ''
      }
    },
    handleClick(tab, event) {
      console.log(tab, event)
      if (tab.name === 'first') {
        this.getList1()
      } else if (tab.name === 'fouth') {
        this.getList4()
      } else if (tab.name === 'second') {
        this.getList2()
      } else if (tab.name === 'third') {
        this.getList3()
      }
    },
    get_select_list() {
      GetDataByNames(this.requestParams).then(response => {
        this.findAllEmploye = response.data.findAllEmploye.list
        this.findAllPasture = response.data.findAllPasture.list
      })
    },
    providerSearch(queryString, cb) {
      console.log('供应商模糊查询输入值', queryString)
      this.requestProvider.parammaps['providerName'] = queryString
      GetDataByName(this.requestProvider).then(response => {
        console.log('供应商模糊查询搜索data', response.data.list)
        cb(response.data.list)
      })
    },
    handleSelectProvider(item) {
      console.log('供应商模糊查询选中值', item)
    },
    getList1() {
      this.listLoading1 = true
      GetDataByName(this.getdataListPart).then(response => {
        console.log(response)
        this.partData = response.data.list
      })
      GetDataByName(this.getdataListParm1).then(response => {
        console.log('this.list1', response.data.list)
        if (response.data.list === null) {
          this.list1 = []
          this.confirmationSheetDisabled = true
        } else {
          // eslint-disable-next-line no-unused-vars
          var list1
          list1 = response.data.list
          var result = []
          list1.forEach((i, j) => {
            // eslint-disable-next-line no-irregular-whitespace
            Array.from(new Set(list1.map(function(item) { return item.partCode }))).forEach((x, y) => {
              if (i.partCode === x) {
                result.push({
                  'amount': i.amount,
                  'amountPre': i.amountPre,
                  'bigId': i.bigId,
                  'brand': i.brand,
                  'brandId': i.brandId,
                  'contractCode': i.contractCode,
                  'count': i.count,
                  'enable': i.enable,
                  'id': i.id,
                  'inventoryType': i.inventoryType,
                  'isZeroStock': i.isZeroStock,
                  'orderNumber': i.orderNumber,
                  'partCode': i.partCode,
                  'partId': i.partId,
                  'partName': i.partName,
                  'pastureId': i.pastureId,
                  'pastureName': i.pastureName,
                  'planAmount': i.planAmount,
                  'price': i.price,
                  'providerId': i.providerId,
                  'providerName': i.providerName,
                  'purpose': i.purpose,
                  'remark': i.remark,
                  'specification': i.specification,
                  'sumAmount': i.sumAmount,
                  'unit': i.unit,
                  'isNo': i.isNo,
                  'srcpath': i.srcpath,
                  'picpath': i.picpath,
                  'departmentName': i.departmentName,
                  'isParity': y
                })
              }
            })
          })
          console.log(result)
          if (result !== null) {
            for (let i = 0; i < result.length; i++) {
              console.log(result[i].srcpath)
              if (result[i].srcpath !== null && result[i].picpath !== null && result[i].srcpath !== undefined && result[i].picpath !== undefined) {
                result[i].srcpath = process.env.VUE_APP_BASE_API + result[i].srcpath
                result[i].picpath = process.env.VUE_APP_BASE_API + result[i].picpath
              } else {
                // this.$set(result[i], 'srcpath', '')
                // this.$set(result[i], 'picpath', '')
                result[i].srcpath = ''
                result[i].picpath = ''
              }
            }
          }
          // console.log(result)
          this.list1 = result
          console.log('处理后table数', this.list1)
          this.confirmationSheetDisabled = false
        }
        var tem = ''
        for (var i = 0; i < this.list1.length; i++) {
          if (tem !== this.list1[i].partCode) {
            this.list1[i].amount = this.list1[i].sumAmount
            tem = this.list1[i].partCode
          } else {
            this.list1[i].amount = 0
          }
        }
        // var a = 0
        // var b = 0
        // for (var i = 0; i < this.list1.length; i++) {
        //   if (parseInt(this.list1[i].amountPre) !== 0) {
        //     console.log(parseInt(this.list1[i].amountPre))
        //     if (a <= 0) {
        //       a = this.list1[i].count - 1
        //       if (b === 0) {
        //         b = parseInt(this.list1[i].amountPre)
        //       }
        //     } else {
        //       a--
        //     }
        //     if (b > 0) {
        //       this.list1[i].amount = this.list1[i].amount + 1
        //       b--
        //     }
        //   }
        // }
        if (response.data.total) {
          this.total1 = response.data.total
        }
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading1 = false
        }, 300)
      })
    },
    confirmationSheet() {
      console.log('点击立确认配单')
      this.temp1.matchCode = ''
      console.log(this.list1) // table表格数据
      // -------------------------------------------
      function groupBy1(array, f) {
        var groups1 = {}
        array.forEach(function(o) {
          var group2 = JSON.stringify(f(o))
          console.log("group2",group2)
          groups1[group2] = groups1[group2] || []
          groups1[group2].push(o)
        })
        return Object.keys(groups1).map(function(group2) {
          return groups1[group2]
        })
      }
      var sorted1 = groupBy1(this.list1, function(item) {
        return [item.partCode]
      })
      console.log('表格数据根据供应商分划', sorted1)





      for (var i = 0; i < sorted1.length; i++) {
        var b = 0
        var c = 0
        for (var j = 0; j < sorted1[i].length; j++) {
          // eslint-disable-next-line no-self-compare
          if (sorted1[i][j].partCode === sorted1[i][j].partCode) {
            // console.log(sorted1[i][j])
            var element = sorted1[i][j]
            b += parseInt(element.amount)
            c = parseInt(element.sumAmount)
            // console.log("amount", element.amount);
          }
        }
        if (b > c || b < c) {
          console.log('No')
          console.log(element.id)
          for (var a = 0; a < this.list1.length; a++) {
            if (element.id === this.list1[a].id) {
              console.log(this.list1[a].partCode)
              for (var b = 0; b < this.list1.length; b++) {
                if (this.list1[b].partCode === this.list1[a].partCode) {
                  console.log(this.list1[b])
                  this.$set(this.list1[b], 'isNo', 'No')
                } else {
                  this.$set(this.list1[b], 'isNo', 'Yes')
                }
              }
            } else {
              this.$set(this.list1[a], 'isNo', 'Yes')
            }
          }
          console.log(b)
          this.$message({
            type: 'warning',
            message: '同一备件多个供应商合计采购数量总和等于申购数量'
          })
          return
        } else {
          for (var a = 0; a < this.list1.length; a++) {
            this.$set(this.list1[a], 'isNo', 'Yes')
            var rulesAmount = /^[0-9]\d*$/
            if (!rulesAmount.test(this.list1[a].amount)) {
              this.$message({
                type: 'error',
                message: '采购数量请输入正整数',
                duration: 2000
              })
              return false
            }
          }
          // console.log('Yes')
        }
      }
      this.getCreateNumber()
      // -------------------------------------------
      this.dialogStatusConfirmation = 'confirmation'
      this.dialogFormVisibleConfirmation = true

      console.log('确认配单data------',  JSON.stringify(this.list1) )
      // this.list1 = this.list1.filter(i => parseFloat(i.amount) !== 0)
      console.log(this.list1)
      console.log('根据供应商分类', sorted1)
      console.log('根据供应商分类表格listConfirmationSheet', this.listConfirmationSheet)
      // 处理渲染数据
      var providerNameMap = {}
      var providerNameDest = []

      var departmentNameMap = {}


      



  

      // // eslint-disable-next-line no-redeclare
      // for (var i = 0; i < this.list1.length; i++) {
      //   console.log(this.list1[i])
      //   var ai = this.list1[i]
      //   var price = this.list1[i].price
      //   var amount = this.list1[i].amount
      //   // console.log(price, amount)
      //   var sumPrice = 0
      //   sumPrice = parseFloat(price) * parseFloat(amount)
      //   if (!providerNameMap[ai.providerName]) {


      //       providerNameDest.push({
      //         price: [price],
      //         amount: [amount],
      //         sumPrice: [sumPrice],
      //         providerId: ai.providerId,
      //         providerName: ai.providerName,
      //         purpose: ai.purpose,
      //         list: [ai]
      //       })
      //       providerNameMap[ai.providerName] = ai
      //       providerNameMap[ai.providerId] = ai



      //   } else {
      //     // eslint-disable-next-line no-redeclare
      //     for (var j = 0; j < providerNameDest.length; j++) {
      //       console.log(providerNameDest[j])
      //       var dj = providerNameDest[j]
      //       if (dj.providerName === ai.providerName) {
      //         dj.sumPrice.push(sumPrice)
      //         dj.price.push(price)
      //         // eslint-disable-next-line no-mixed-spaces-and-tabs
      //         dj.amount.push(amount)
      //         dj.list.push(ai)
      //         break
      //       }
      //     }
      //   }
      // }

      // var providerNameArray = []
      // // eslint-disable-next-line no-redeclare
      // for (var i = 0; i < this.list1.length; i++) {
      //   providerNameArray.push(this.list1[i].providerName)
      // }
      // // console.log('原供应商', providerNameArray)
      // function unique(providerNameArray) {
      //   return Array.from(new Set(providerNameArray))
      // }
      // var uniqueProviderNameArray = unique(providerNameArray)
      // console.log('去重后供应商', uniqueProviderNameArray) // ["泰森机电", "浩祥晟机电", "国宇商贸", "赛娜牧业"]
      // // ------------------------------------------

      // var OrderNumberArray = []
      // this.postDataPramas.common = { 'returnmap': '0' }
      // this.postDataPramas.data = []
      // for (var i = 0; i < uniqueProviderNameArray.length; i++) {
      //   this.postDataPramas.data[i] = { 'name': 'autoCreatCode', 'type': 'sm', 'parammaps': {
      //     pastureId: Cookies.get('pastureid'),
      //     codeType: 'CG'
      //   }}
      // }
      // ExecDataByConfig(this.postDataPramas).then(response => {
      //   console.log('采购单请求发送参数', this.postDataPramas)
      //   for (var i = 0; i < response.data.length; i++) {
      //     // console.log(response.data[i].resultmaps[0].orderCode)
      //     OrderNumberArray.push(response.data[i].resultmaps[0].orderCode)
      //   }
      //   console.log(OrderNumberArray)
      //   this.listConfirmationSheet.map((item, index) => {
      //     item.orderNumber = OrderNumberArray[index]
      //     return item
      //   })
      //   this.$forceUpdate()
      // })
      // console.log(OrderNumberArray)
      // this.listConfirmationSheet = providerNameDest
      // // console.log(JSON.stringify(this.listConfirmationSheet))
      // console.log('根据供应商分类表格listConfirmationSheet', this.listConfirmationSheet)





      // var SumArray = []

      // this.listConfirmationSheet.forEach((item, index) => {
      //   console.log(item.sumPrice)
      //   // console.log(item.sumPrice.reduce((count, v) => count + v, 0))
      //   SumArray.push(item.sumPrice.reduce((count, v) => count + v, 0).toFixed(3))
      // })
      // this.listConfirmationSheet.map((item, index) => {
      //   // console.log(item, index)
      //   item.Sum = SumArray[index]
      //   return item
      // })

      // console.log('根据供应商分类表格listConfirmationSheet', this.listConfirmationSheet)
      // -------------------------------------------
    },
    getCreateNumber() {
      GetDataByName(this.getParmCreateNumber).then(response => {
        this.$nextTick(() => {
          this.show = false
          console.log('配单号', response.data.list[0].orderCode)
          this.temp1.matchCode = response.data.list[0].orderCode
          this.$forceUpdate()
        })
      })
    },
    confirmationSheetData() {
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      console.log('点击了确认配单提交')
      this.$refs['temp1'].validate(valid => {
        if (valid) {
          // orderNumber
          if (this.temp1.matchCode == '' || this.temp1.matchCode == null || this.temp1.matchCode == undefined) {
            this.getCreateNumber()
          }
          this.postDataPramas.common = { 'returnmap': '0' }
          this.postDataPramas.data = []
          console.log(this.listConfirmationSheet)
          for (let i = 0; i < this.listConfirmationSheet.length; i++) {
            if (this.listConfirmationSheet[i].orderNumber == null || this.listConfirmationSheet[i].orderNumber == undefined) {
              this.$notify({
                title: '保存失败',
                message: '网络异常未生成采购单，请刷新后重新进行配单',
                type: 'warning',
                duration: 2000
              })
              return false
            }
          }
          var a = this.listConfirmationSheet.length
          this.listConfirmationSheet.forEach((item, index) => {
            console.log(item)
            this.postDataPramas.data[index] = { 'name': 'insertBigbuydetail', 'resultname': 'insertBigbuydetail' + index, 'type': 'e', 'parammaps': {
              pastureId: Cookies.get('pastureid'),
              buyeCode: item.orderNumber,
              providerId: item.providerId,
              buyerPerson: this.temp1.buyerPerson,
              buyerDate: this.temp1.buyerDate,
              matchCode: this.temp1.matchCode
            }}
            this.postDataPramas.data[a] = { 'name': 'insertSpotList', 'resultmaps': { 'list': item.list }}
            this.postDataPramas.data[a].children = []
            this.postDataPramas.data[a].children[0] = { 'name': 'insertbuydetail', 'type': 'e', 'parammaps': {
              bigId: '@insertBigbuydetail' + index + '.LastInsertId',
              pastureId: '@insertSpotList.pastureId',
              contractCode: '@insertSpotList.contractCode',
              amount: '@insertSpotList.amount',
              sumAmount: '@insertSpotList.sumAmount',
              contractId: '@insertSpotList.id',
              departmentName: '@insertSpotList.departmentName',
              remark: '@insertSpotList.purpose'
            }}
            a = a + 1
          })
          this.postDataPramas.data[a] = { 'name': 'insertSpotListbpp', 'resultmaps': { 'list': this.partData }}
          this.postDataPramas.data[a].children = []
          this.postDataPramas.data[a].children[0] = { 'name': 'updateBigpartpurchaseStatu', 'type': 'e', 'parammaps': {
            id: '@insertSpotListbpp.id',
            matchCode: this.temp1.matchCode
          }}
          this.postDataPramas.data.push({ 'name': 'insertbigpartdeal', 'type': 'e', 'parammaps': {
            empId: this.temp1.buyerPerson,
            pastureId: Cookies.get('pastureid'),
            matchCode: this.temp1.matchCode
          }}
          )
          ExecDataByConfig(this.postDataPramas).then(response => {
            if (response.msg === 'fail') {
              var buyeCode = new RegExp('buyeCode')
              if (buyeCode.test(response.data)) {
                this.$notify({
                  title: '',
                  message: '网络异常未生成采购单，请刷新后重新进行配单',
                  type: 'warning',
                  duration: 2000
                })
              } else {
                this.$notify({
                  title: '保存失败',
                  message: response.data,
                  type: 'warning',
                  duration: 2000
                })
              }
            } else {
              this.dialogFormVisibleConfirmation = false
              this.activeName = 'fouth'
              this.getList4()
              this.$notify({
                title: '',
                message: '保存成功',
                type: 'success',
                duration: 2000
              })
            }
          })
        }
      })
    },

    getList2() {
      this.listLoading2 = true
      if (this.$refs['inputDatetime2'] !== undefined && this.$refs['inputDatetime2'].value !== null) {
        this.getdataListParm2.parammaps.startTime = this.$refs['inputDatetime2'].value[0]
        this.getdataListParm2.parammaps.stopTime = this.$refs['inputDatetime2'].value[1]
      } else {
        this.getdataListParm2.parammaps.startTime = ''
        this.getdataListParm2.parammaps.stopTime = ''
      }
      GetDataByName(this.getdataListParm2).then(response => {
        this.list2 = response.data.list
        this.pageNum2 = response.data.pageNum
        this.pageSize2 = response.data.pageSize
        if (response.data.total) {
          this.total2 = response.data.total
        }
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading2 = false
        }, 300)
      })
    },
    form_search2() {
      this.listLoading = true
      if (this.getdataListParm2.parammaps.inputDatetime === null) {
        this.getdataListParm2.parammaps.inputDatetime = ''
      }
      this.getdataListParm2.offset = 1
      this.getList2()
    },
    statu: function(cellValue) {
      if (cellValue.statu === 0) {
        return '未到货'
      } else if (cellValue.statu === 1) {
        return '部分到货'
      } else if (cellValue.statu === 2) {
        return '按时到货'
      } else if (cellValue.statu === 3) {
        return '已延期'
      } else if (cellValue.statu === 4) {
        return '已关闭'
      } else if (cellValue.statu === 5) {
        return '部分到货-延期'
      } else if (cellValue.statu === 6) {
        return '全部到货-延期'
      }
    },
    statue: function(cellValue) {
      if (cellValue.statue === 0) {
        return '审核中'
      } else if (cellValue.statue === 1) {
        return '审核通过'
      } else if (cellValue.statue === 2) {
        return '未通过'
      }
    },
    form_see2(row) {
      this.temp2 = Object.assign({}, row)
      if (this.temp2.statu === 0) {
        this.isStatu = false
        this.temp2.statu = '未到货'
        this.isExtensionDays = false
      } else if (this.temp2.statu === 1) {
        this.isStatu = false
        this.temp2.statu = '部分到货'
        this.isExtensionDays = false
      } else if (this.temp2.statu === 2) {
        this.isStatu = false
        this.temp2.statu = '按时到货'
        this.isExtensionDays = false
      } else if (this.temp2.statu === 3) {
        this.isStatu = false
        this.temp2.statu = '已延期'
        this.isExtensionDays = true
      } else if (this.temp2.statu === 4) {
        this.temp2.statu = '已关闭'
        this.isStatu = true
        this.isExtensionDays = false
      } else if (this.temp2.statu === 5) {
        this.isStatu = false
        this.temp2.statu = '部分到货-延期'
        this.isExtensionDays = true
      } else if (this.temp2.statu === 6) {
        this.isStatu = false
        this.temp2.statu = '全部到货-延期'
        this.isExtensionDays = true
      }
      this.dialogStatusSee2 = 'see'
      this.dialogFormVisibleSee2 = true
      this.getdataListSee2.parammaps.id = row.id
      this.getSeeList2()
    },
    getSeeList2() {
      GetDataByName(this.getdataListSee2).then(response => {
        this.listSee2 = response.data.list
        if (response.data.list !== null) {
          for (let i = 0; i < response.data.list.length; i++) {
            if (response.data.list[i].srcpath !== null && response.data.list[i].picpath !== null && response.data.list[i].srcpath !== undefined && response.data.list[i].picpath !== undefined) {
              this.listSee2[i].srcpath = process.env.VUE_APP_BASE_API + response.data.list[i].srcpath
              this.listSee2[i].picpath = process.env.VUE_APP_BASE_API + response.data.list[i].picpath
            } else {
              this.listSee2[i].srcpath = ''
              this.listSee2[i].picpath = ''
            }
          }
        }
        console.log('查看下方table数据', response.data.list)
        // this.pageNum2 = response.data.pageNum
        // this.pageSize2 = response.data.pageSize
        var sumArray = []
        for (var i = 0; i < this.listSee2.length; i++) {
          console.log()
          sumArray.push(
            this.listSee2[i].sumPrice
          )
        }
        console.log('总价', sumArray)
        var arrvalue = 0
        for (var i = 0; i < sumArray.length; i++) {
          console.log('table内总价每一个值', sumArray[i])
          arrvalue += parseFloat(sumArray[i])// 数组的索引是从0开始的
        }
        this.temp2.sumPrices = arrvalue.toFixed(3)
        setTimeout(() => {
          this.listLoadingSee = false
        }, 100)
      })
    },
    resetCloseTemp() {
      this.temp2.note = ''
    },
    handleClose2(row) {
      this.resetCloseTemp()
      this.temp2 = Object.assign({}, row)
      this.dialogStatusClose = 'close'
      this.dialogFormVisibleClose = true
    },

    handleCurrentChange(val) {
        this.currentRow = val;
        console.log("currentRow",this.currentRow)
  },

    sapUpload(){


      const that = this 
      console.log("currentRow",this.currentRow.sapstatus)

     var send_data = this.selectList

     if(send_data.length == 0){
        that.$notify({ title: '失败', message: '请勾选数据！'  , type: 'error', duration: 2000 })
        return false
      }


      console.log(that.isSap)

      if(that.isSap == 1){

         that.isSap = 0
         SapOrder(send_data).then(response => {
              console.log('response', response)
                
               if (response.msg !== 'fail') {
                that.$notify({ title: '成功', message: '上传成功', type: 'success', duration: 2000 })
                that.selectList = []
                that.getList2()
                 
                } else {
                  that.$notify({ title: '失败', message: '上传失败'  , type: 'error', duration: 2000 })
                }
               
            })
 
            
      } else {

        that.$notify({ title: '失败', message: '正在请求中，请稍等几秒钟后再点击'  , type: 'error', duration: 2000 })
      }

      setTimeout(() => {
              that.isSap = 1
            }, 3000)



           
    
  
      // if(this.currentRow.sapstatus){
   
      //   if(this.currentRow.sapstatus != 0){
      //     const sapArr = this.currentRow.sapbuyeCode.split(",")
      //     console.log("sapArr",sapArr)
      //     sapArr.forEach(function(item){
      //       console.log("sapArr item",item)
      //       var send_data = {
         
      //             "code":item,
      //             "pastureid":Cookies.get('pastureid')
              
      //       }

      //       SapOrder(send_data).then(response => {
      //         console.log('response', response)
                
      //          if (response.msg !== 'fail') {
      //           that.$notify({ title: '成功', message: '上传成功', type: 'success', duration: 2000 })
      //           that.getList()
                 
      //           } else {
      //             that.$notify({ title: '失败', message: '上传失败'  , type: 'error', duration: 2000 })
      //           }
               
      //       })
        
        


      //     })
      //   }
      // }

    },


    checkboxInit(row,index){
      // console.log(row)
      var data1 = new Date(row.creatTime)
        var data2 = new Date('2022-10-25')
        if(data1 > data2){ return 1 } else {return 0}
    },

    //监听 - 表格 - 勾选
    change_table_selection(val) {
      this.selectList = val
      console.log('勾选数据selectList', this.selectList)
    },

    srmUpload(){

      const that = this 
      console.log("currentRow",this.currentRow.srmstatus)
    
      console.log('勾选数据selectList', this.selectList)

      var send_data = this.selectList


      if(send_data.length == 0){
        that.$notify({ title: '失败', message: '请勾选数据！'  , type: 'error', duration: 2000 })
        return false
      }


      console.log(that.isSrm)

      if(that.isSrm == 1){

         that.isSrm = 0
         SrmOrder(send_data).then(response => {
              console.log('response', response)
                
               if (response.msg !== 'fail') {
                that.$notify({ title: '成功', message: '上传成功', type: 'success', duration: 2000 })
                that.selectList = []
                that.getList2()
                
                 
                } else {
                  that.$notify({ title: '失败', message: '上传失败'  , type: 'error', duration: 2000 })
                }
               
            })

 
            
      } else {

        that.$notify({ title: '失败', message: '正在请求中，请稍等几秒钟后再点击'  , type: 'error', duration: 2000 })
      }

      setTimeout(() => {
              that.isSrm = 1
            }, 3000)




   
      // if(this.currentRow.srmstatus){
      //   if(this.currentRow.srmstatus != 0){
      //     const srmArr = this.currentRow.srmbuyeCode.split(",")
      //     console.log("srmArr",srmArr)
      //     srmArr.forEach(function(item){
      //       console.log("srmArr item",item)
      //       var send_data = {
         
      //             "code":item,
      //             "pastureid":Cookies.get('pastureid')
      //       }
      //       SrmOrder(send_data).then(response => {
      //         console.log('response', response)
                
      //          if (response.msg !== 'fail') {
      //           that.$notify({ title: '成功', message: '上传成功', type: 'success', duration: 2000 })
      //           that.getList()
                 
      //           } else {
      //             that.$notify({ title: '失败', message: '上传失败'  , type: 'error', duration: 2000 })
      //           }
               
      //       })
        
        


      //     })
      //   }
      // }



    },
    

    closeData() {
      this.isokDisable = true
      setTimeout(() => {
        this.isokDisable = false
      }, 1000)
      console.log('点击确认关闭', this.temp2)
      this.$refs['temp2'].validate(valid => {
        if (valid) {
          this.requestParamStute.parammaps.id = this.temp2.id
          this.requestParamStute.parammaps.note = this.temp2.note
          PostDataByName(this.requestParamStute).then(response => {
            console.log('新增保存发送参数', this.requestParamStute)
            if (response.msg !== 'fail') {
              this.getList2()
              this.dialogFormVisibleClose = false
              this.$notify({
                title: '成功',
                message: '关闭成功',
                type: 'success',
                duration: 2000
              })
            } else {
              failproccess(response, this.$notify)
            }
          })
        }
      })
    },
    getList3() {
      this.listLoading3 = true
      if (this.$refs['inputDatetime3'] !== undefined && this.$refs['inputDatetime3'].value !== null) {
        this.getdataListParm3.parammaps.startTime = this.$refs['inputDatetime3'].value[0]
        this.getdataListParm3.parammaps.stopTime = this.$refs['inputDatetime3'].value[1]
      } else {
        this.getdataListParm3.parammaps.startTime = ''
        this.getdataListParm3.parammaps.stopTime = ''
      }
      GetDataByName(this.getdataListParm3).then(response => {
        this.list3 = response.data.list
        this.pageNum3 = response.data.pageNum
        this.pageSize3 = response.data.pageSize
        if (response.data.total) {
          this.total3 = response.data.total
        }
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading3 = false
        }, 300)
      })
    },
    form_search3() {
      this.listLoading = true
      if (this.getdataListParm3.parammaps.inputDatetime === null) {
        this.getdataListParm3.parammaps.inputDatetime = ''
      }
      this.getdataListParm3.offset = 1
      this.getList3()
    },
    handleDownload3() {
      console.log('点击了采购明细导出')
      this.$alert('采购明细正在导出中，请勿刷新或离开本页面，若导出时间过长，建议缩小导出数据范围重新导出', {})
      this.isPercentage = true
      this.percentage = 1
      var timer = setInterval(() => {
        this.percentage += 5
        if (this.percentage > 95) {
          this.percentage = 99
          clearInterval(timer)
        }
        this.percentage = this.percentage
      }, 1000)
      this.downloadListParm3.name = this.getdataListParm3.name
      this.downloadListParm3.parammaps = this.getdataListParm3.parammaps
      GetAccount(this.downloadListParm3).then(response => {
        if (response.data.list !== '') {
          this.percentage = 99
          setTimeout(() => {
            this.isPercentage = false
          }, 2000)
        }
        this.downloadList3 = response.data.list
        const elecExcelDatas = [
          {
            tHeader: ['配单号', '采购单号', '备件编号', '备件名称', '备件规格', '备件品牌', '计量单位', '供应商', '单价', '申购数量', '采购数量', '入库数', '申购部门', '采购人', '配单日期'],
            filterVal: ['matchCode', 'buyeCode', 'partCode', 'partName', 'specification', 'brand', 'unit', 'providerName', 'price', 'sumAmount', 'amount', 'receiveAmount', 'departmentName', 'empname', 'buyerDate'],
            tableDatas: this.downloadList3,
            sheetName: '采购明细'
          }
        ]
        json2excel(elecExcelDatas, '采购明细', true, 'xlsx')
      })
    },
    getList4() {
      this.listLoading4 = true
      if (this.$refs['inputDatetime4'] !== undefined && this.$refs['inputDatetime4'].value !== null) {
        this.getdataListParm4.parammaps.startTime = this.$refs['inputDatetime4'].value[0]
        this.getdataListParm4.parammaps.stopTime = this.$refs['inputDatetime4'].value[1]
      } else {
        this.getdataListParm4.parammaps.startTime = ''
        this.getdataListParm4.parammaps.stopTime = ''
      }
      GetDataByName(this.getdataListParm4).then(response => {
        this.list4 = response.data.list
        this.pageNum4 = response.data.pageNum
        this.pageSize4 = response.data.pageSize
        if (response.data.total) {
          this.total4 = response.data.total
        }
        // Just to simulate the time of the request
        setTimeout(() => {
          this.listLoading4 = false
        }, 300)
      })
    },
    form_search4() {
      this.listLoading = true
      if (this.getdataListParm4.parammaps.inputDatetime === null) {
        this.getdataListParm4.parammaps.inputDatetime = ''
      }
      this.getdataListParm4.offset = 1
      this.getList4()
    },
    form_see4(row) {
      this.dialogStatusSee4 = 'see'
      this.dialogFormVisibleSee4 = true
      this.temp4 = Object.assign({}, row)
      this.getdataListSee4.parammaps.matchCode = row.matchCode
      this.getSeeList4()
      var reason = '未通过原因:' + this.temp4.workflowNote
      if (this.temp4.statue === 0) {
        this.activeList = [{ title: '配单', date: this.temp4.dealTime, name: this.temp4.empname }, { title: '办公室主任审核' }]
        this.active = 1
      } else if (this.temp4.statue === 1) {
        this.activeList = [{ title: '配单', date: this.temp4.dealTime, name: this.temp4.empname }, { title: '办公室主任审核', date: this.temp4.chargeDate, name: this.temp4.chargeName }]
        this.active = 2
      } else if (this.temp4.statue === 2) {
        this.activeList = [{ title: '配单', date: this.temp4.dealTime, name: this.temp4.empname }, { title: '办公室主任审核', date: this.temp4.chargeDate, name: this.temp4.chargeName, status: 'error', reason: reason }]
        this.active = 2
      }
    },
    getSeeList4() {
      GetDataByName(this.getdataListSee4).then(response => {
        this.listSee4 = response.data.list
        this.listUpdate4 = response.data.list
        if (response.data.list !== null) {
          for (let i = 0; i < response.data.list.length; i++) {
            console.log(response.data.list[i].srcpath)
            console.log(response.data.list[i].picpath)
            console.log(process.env.VUE_APP_BASE_API + response.data.list[i].srcpath)
            if (response.data.list[i].srcpath !== null && response.data.list[i].picpath !== null && response.data.list[i].srcpath !== undefined && response.data.list[i].picpath !== undefined) {
              if (this.dialogStatusSee4 == 'see') {
                this.listSee4[i].srcpath = process.env.VUE_APP_BASE_API + response.data.list[i].srcpath
                this.listSee4[i].picpath = process.env.VUE_APP_BASE_API + response.data.list[i].picpath
              } else {
                this.listUpdate4[i].srcpath = process.env.VUE_APP_BASE_API + response.data.list[i].srcpath
                this.listUpdate4[i].picpath = process.env.VUE_APP_BASE_API + response.data.list[i].picpath
              }
            } else {
              this.listSee4[i].srcpath = ''
              this.listSee4[i].picpath = ''
              this.listUpdate4[i].srcpath = ''
              this.listUpdate4[i].picpath = ''
            }
          }
        }

        console.log('查看下方table数据', response.data.list)
        this.pageNum4 = response.data.pageNum
        this.pageSize4 = response.data.pageSize
      })
    },
    handleExamine(row) {
      if (row == undefined) {
        this.examineTemp = this.temp4
        this.$set(this.temp4, 'SHstatue', 1)
        this.$set(this.temp4, 'workflowNote', '')
      } else {
        this.examineTemp = Object.assign({}, row)
        this.$set(this.examineTemp, 'SHstatue', 1)
        this.$set(this.examineTemp, 'workflowNote', '')
      }
      this.dialogStatus_Examine = 'examine'
      this.dialogFormVisible_Examine = true
      this.statueReason = false
    },
    changeSHStatue(val) {
      if (val == 2) {
        this.statueReason = true
      } else {
        this.statueReason = false
      }
    },
    createExamineData() {
      console.log(this.examineTemp)
      this.$refs['examineTemp'].validate(valid => {
        if (valid) {
          if (this.examineTemp.SHstatue == 1) {
            console.log('通过')
            this.postDataPramas.common = { 'returnmap': '0' }
            this.postDataPramas.data = []
            this.postDataPramas.data[0] = { 'name': 'partdealCharge', 'type': 'e', 'parammaps': {
              'id': this.examineTemp.id,
              'statue': this.examineTemp.SHstatue,
              'empId': Cookies.get('employeid'),
              'workflowNote': this.examineTemp.workflowNote
            }}

            this.postDataPramas.data[1] = { 'name': 'updatebigbuydetailenable', 'type': 'e', 'parammaps': {
              'matchCode': this.examineTemp.matchCode
            }}
            this.postDataPramas.data[2] = { 'name': 'updatebigbuydetailZero', 'type': 'e', 'parammaps': {
              'matchCode': this.examineTemp.matchCode
            }}
            ExecDataByConfig(this.postDataPramas).then(response => {
              console.log('审核保存发送参数', this.postDataPramas)
              if (response.msg === 'fail') {
                this.$notify({
                  title: '审核失败',
                  message: response.data,
                  type: 'warning',
                  duration: 2000
                })
              } else {
                this.dialogFormVisible_Examine = false
                this.getList4()
                this.$notify({
                  title: '',
                  message: '审核成功',
                  type: 'success',
                  duration: 2000
                })
              }
            })
          } else if (this.examineTemp.SHstatue == 2) {
            console.log('不通过')
            this.postDataPramas.common = { 'returnmap': '0' }
            this.postDataPramas.data = []
            this.postDataPramas.data[0] = { 'name': 'partdealCharge', 'type': 'e', 'parammaps': {
              'id': this.examineTemp.id,
              'statue': this.examineTemp.SHstatue,
              'empId': Cookies.get('employeid'),
              'workflowNote': this.examineTemp.workflowNote
            }}

            // this.postDataPramas.data[1] = { 'name': 'updatepartpurchase', 'type': 'e', 'parammaps': {
            //   'matchCode': this.examineTemp.matchCode
            // }}
            ExecDataByConfig(this.postDataPramas).then(response => {
              console.log('审核保存发送参数', this.postDataPramas)
              if (response.msg === 'fail') {
                this.$notify({
                  title: '审核失败',
                  message: response.data,
                  type: 'warning',
                  duration: 2000
                })
              } else {
                this.dialogFormVisible_Examine = false
                this.getList4()
                this.$notify({
                  title: '',
                  message: '审核成功',
                  type: 'success',
                  duration: 2000
                })
              }
            })
          }
        }
      })
    },
    form_edit(row) {
      this.dialogStatusUpdate4 = 'update'
      this.dialogFormVisibleUpdate4 = true
      this.getdataListSee4.parammaps.matchCode = row.matchCode
      this.updateTemp4 = Object.assign(row, {})
      this.getSeeList4()
    },
    edit_dialog_save() {
      this.$refs['updateTemp4'].validate(valid => {
        if (valid) {
          // for (let i = 0; i < this.listUpdate4.length; i++) {
          //   var rulesAmount = /^\d+$/
          //   if ((this.listUpdate4[i].amount == '' || this.listUpdate4[i].amount == undefined) && parseFloat(this.listUpdate4[i].amount) !== 0) {
          //     this.$message({
          //       type: 'error',
          //       message: '采购数量不可为空',
          //       duration: 2000
          //     })
          //     return false
          //   } else if (!rulesAmount.test(parseFloat(this.listUpdate4[i].amount))) {
          //     this.$message({
          //       type: 'error',
          //       message: '采购数量不可为空',
          //       duration: 2000
          //     })
          //     return false
          //   }
          // }
          for (let i = 0; i < this.listUpdate4.length; i++) {
            console.log(this.listUpdate4[i].amount)
            var rulesAmount = /^\d+$/
            if ((this.listUpdate4[i].amount == '' || this.listUpdate4[i].amount == undefined) && parseFloat(this.listUpdate4[i].amount) !== 0) {
              this.$message({
                type: 'error',
                message: '采购数量不可为空',
                duration: 2000
              })
              return false
            } else if (!rulesAmount.test(parseFloat(this.listUpdate4[i].amount))) {
              this.$message({
                type: 'error',
                message: '采购数量请输入大于等于0的整数',
                duration: 2000
              })
              return false
            } else {
              this.postDataPramas.common = { 'returnmap': '0' }
              this.postDataPramas.data = []
              this.postDataPramas.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.listUpdate4 }}
              this.postDataPramas.data[0].children = []
              this.postDataPramas.data[0].children[0] = { 'name': 'updatePDbuydetail', 'type': 'e', 'parammaps': {
                amount: '@insertSpotList.amount',
                id: '@insertSpotList.id'
              }}
              this.postDataPramas.data[1] = { 'name': 'partdealCharge', 'type': 'e', 'parammaps': {
                id: this.updateTemp4.id,
                statue: '0',
                empId: Cookies.get('employeid')
              }}
            }
          }
          ExecDataByConfig(this.postDataPramas).then(response => {
            console.log('新增保存发送参数', this.postDataPramas)
            if (response.msg === 'fail') {
              this.$notify({
                title: '保存失败',
                message: response.data,
                type: 'warning',
                duration: 2000
              })
            } else {
              this.dialogFormVisibleUpdate4 = false
              this.getdataListParm4.parammaps.inputDatetime = ''
              this.getList4()
              this.$notify({
                title: '',
                message: '保存成功',
                type: 'success',
                duration: 2000
              })
            }
          })
          return true
        }
      })
    }

  }
}
</script>
<style lang="scss" >
.el-table .warning-row {
    background: red;
  }
  .el-table .color-row {
    background: #eee;
  }
</style>
<style lang="scss" scoped>
.app-contentClose .el-form-item__content {
  margin-left: 0 !important;
}
</style>
<style lang="scss" scoped>
.app-contentConfirmationSheet {
  margin-bottom: 50px;
}
.app-content {
  background: #eee;
  margin-bottom: 50px;
  .title {
    line-height: 40px;
    div {
      float: left;
      margin-right: 50px;
      b {
        padding-left: 10px;
      }
    }
  }
  .total {
    margin-left: 80%;
    line-height: 30px;
  }
}
</style>
