<template>
  <div class="mod-config">
    <el-form :inline="true"  label-position="top" label-width="100px" >
      <el-form-item :label="'派工单号：'">
        <el-input v-model="searchData.seqNo" type="number" style="width: 80px"></el-input>
      </el-form-item>
      <el-form-item :label="'反馈日期：'">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.startDate"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item style="margin-top: 23px;">
        <laber style="margin-left: -9px;font-size: 19px">&#10142</laber>
      </el-form-item>
      <el-form-item :label="' '">
        <el-date-picker
          style="width: 120px"
          v-model="searchData.endDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="异常情况原因：" >
        <el-select v-model="searchData.abnormalCode" style="width: 120px">
          <el-option label="全部" value="" ></el-option>
          <el-option
            v-for="(item,index) in abnormalList"
            :key="index"
            :label="item.abnormalDesc"
            :value="item.abnormalCode"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="状态：" >
        <el-select v-model="searchData.status" style="width: 120px">
          <el-option label="全部" value=""></el-option>
          <el-option label="已录入" value="已录入"></el-option>
          <el-option label="已填写紧急处理" value="已填写紧急处理"></el-option>
          <el-option label="已填写长久处理" value="已填写长久处理"></el-option>
          <el-option label="已完结" value="已完结"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item :label="'操作员姓名：'">
        <el-input v-model="searchData.operatorDesc"  style="width: 80px"></el-input>
      </el-form-item>
      <el-form-item :label="'物料规格型号：'">
        <el-input v-model="searchData.partDesc"  style="width: 80px"></el-input>
      </el-form-item>
      <el-form-item label=" " >
      <el-button @click="search()" style="margin-left: 0px;margin-top: 0px" type="primary">查询</el-button>
        <el-button @click="addAbnormal()" style="margin-left: 0px;margin-top: 0px" type="primary">新增</el-button>
        <download-excel
          :fields="exportDataStandard"
          :data="tableData"
          type="xlsx"
          :name="exportName"
          :header="exportHeader"
          :footer="exportFooter"
          :defaultValue="exportDefaultValue"
          :fetch="createExportData"
          :before-generate="startDownload"
          :before-finish="finishDownload"
          worksheet="导出信息"
          class="el-button el-button--primary el-button--medium">
          {{'导出'}}
        </download-excel>
      </el-form-item>
    </el-form>
    <el-table
      :height="height"
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="site"
        header-align="center"
        align="left"
        width="60"
        label="工厂编号">
      </el-table-column>
      <el-table-column
        prop="orderNo"
        header-align="center"
        align="left"
        width="80"
        label="生产订单">
      </el-table-column>
      <el-table-column
        prop="seqNo"
        header-align="center"
        align="left"
        width="60"
        label="派工单号">
      </el-table-column>
      <el-table-column
        prop="partNo"
        header-align="center"
        align="left"
        width="60"
        label="物料编码">
      </el-table-column>
      <el-table-column
        prop="partDesc"
        header-align="center"
        align="left"
        width="140"
        label="规格型号">
      </el-table-column>
      <el-table-column
        prop="operatorDesc"
        header-align="center"
        align="left"
        width="60"
        label="操作员">
      </el-table-column>
      <el-table-column
        prop="productionLineDesc"
        header-align="center"
        align="left"
        width="60"
        label="生产线">
      </el-table-column>
      <el-table-column
        prop="feedbackDate"
        header-align="center"
        align="left"
        width="130"
        label="反馈时间">
      </el-table-column>
      <el-table-column
        prop="feedbackBy"
        header-align="center"
        align="left"
        width="80"
        label="反馈人">
      </el-table-column>
      <el-table-column
        prop="status"
        header-align="center"
        align="left"
        width="100"
        label="状态">
      </el-table-column>
      <el-table-column
        prop="abnormalDesc"
        header-align="center"
        align="left"
        width="100"
        label="异常原因">
      </el-table-column>
      <el-table-column
        prop="abnormalQty"
        header-align="center"
        align="right"
        width="100"
        label="异常数量">
      </el-table-column>
      <el-table-column
        prop="abnormalInfluence"
        header-align="center"
        align="left"
        width="120"
        label="异常情况影响分析">
      </el-table-column>
      <el-table-column
        prop="abnormalRemark"
        header-align="center"
        align="left"
        min-width="300"
        label="异常描述">
      </el-table-column>
      <el-table-column
        fixed="right"
        header-align="center"
        align="center"
        width="300"
        label="操作">
        <template slot-scope="scope">
          <a type="text" size="small" @click="getFileModel(scope.row)">附件</a>
          <a type="text" size="small" @click="getDetailModel(scope.row)">查看</a>
          <a type="text" size="small" @click="doPrint(scope.row)">打印</a>
          <a type="text" size="small" v-if="scope.row.status!='已完结'" @click="getDetailModel2(scope.row)">紧急处理方式</a>
          <a type="text" size="small" v-if="scope.row.status!='已完结'" @click="getDetailModel3(scope.row)">长久处理方式</a>
          <a type="text" size="small" v-if="scope.row.status!='已录入'&&scope.row.status!='已完结'&&isAuth('sys:abnormal:close')" @click="closeFeedBack(scope.row)">结束</a>
          <a type="text" size="small" v-if="scope.row.status=='已完结'" @click="openFeedBack(scope.row)">开启</a>
        </template>
      </el-table-column>
    </el-table>
    <el-dialog title="新增反馈" :close-on-click-modal="false" v-drag :visible.sync="addModalFlag" width="620px" >
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <el-form-item :label="'异常原因：'">
          <el-select v-model="addData.abnormalCode"  style="width: 120px">
            <el-option
              v-for="(item,index) in abnormalList"
              :key="index"
              :label="item.abnormalDesc"
              :value="item.abnormalCode"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item :label="'派工单号：'">
          <el-input v-model="addData.seqNo" type="number" @blur="seqNoCheck()" style="width: 85px"></el-input>
        </el-form-item>
        <el-form-item :label="'生产订单：'">
          <el-input v-model="addData.orderNo" disabled style="width: 100px"></el-input>
        </el-form-item>
        <el-form-item :label="'机台：'">
          <el-input v-model="addData.resourceDesc" disabled style="width: 100px"></el-input>
        </el-form-item>
        <el-form-item :label="'班次：'">
          <el-input v-model="addData.shiftNo" disabled style="width: 100px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item :label="'异常数量：'">
          <el-input v-model="addData.abnormalQty"  type="number" style="width: 85px"></el-input>
        </el-form-item>
        <el-form-item :label="'异常情况影响分析：'">
          <el-input v-model="addData.abnormalInfluence"  style="width: 463px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="异常情况描述(派工单0:表示混炼胶异常反馈;-1:表示产品发货异常反馈;-2:客户投诉异常反馈;-3:设备维修保养;-4:工具维修保养)">
          <el-input v-model="addData.abnormalRemark" type="textarea"  :rows="3" resize='none' style="width: 562px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 50px;">
        <el-upload drag :file-list="fileList"
                   action="javascript:void(0);" ref="uploadFile"
                   :on-change="onChange"
                   multiple :auto-upload="false"
                   style="text-align: left;">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        </el-upload>
      </el-form>
      <el-footer style="height:30px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveAbnormalData()" >保存</el-button>
        <el-button type="primary" @click="addModalFlag = false">取消</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="异常反馈" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="650px" >
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: -5px;">
        <span style="font-size: 12px">异常原因:</span>
        <el-input v-model="abnormalFeedBackData.abnormalDesc"  disabled style="width: 180px"></el-input>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="异常情况描述">
        <el-input v-model="abnormalFeedBackData.abnormalRemark" type="textarea" :disabled="disableFlag1" :rows="3" resize='none' style="width: 562px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 40px;">
        <el-form-item label="报废状态1">
          <el-select filterable v-model="abnormalFeedBackData.scrapType1" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapTypeList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报废状态2">
          <el-select filterable v-model="abnormalFeedBackData.scrapType2" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapTypeList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报废状态3">
          <el-select filterable v-model="abnormalFeedBackData.scrapType3" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapTypeList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报废状态4">
          <el-select filterable v-model="abnormalFeedBackData.scrapType4" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapTypeList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报废状态5">
          <el-select filterable v-model="abnormalFeedBackData.scrapType5" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapTypeList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="报废原因1">
          <el-select filterable v-model="abnormalFeedBackData.scrapReason1" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapReasonList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报废原因2">
          <el-select filterable v-model="abnormalFeedBackData.scrapReason2" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapReasonList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报废原因3">
          <el-select filterable v-model="abnormalFeedBackData.scrapReason3" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapReasonList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报废原因4">
          <el-select filterable v-model="abnormalFeedBackData.scrapReason4" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapReasonList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="报废原因5">
          <el-select filterable v-model="abnormalFeedBackData.scrapReason5" clearable style="width: 95px">
            <el-option :label="item.label" :value="item.label" v-for="(item,index) in scrapReasonList "
                       :key="index"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;">
        <el-form-item label="紧急处理方式">
          <el-input v-model="abnormalFeedBackData.treatmentTemporary" type="textarea" :disabled="disableFlag2" :rows="3" resize='none' style="width: 562px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 40px;">
        <el-form-item label="临时性措施结论">
          <el-input v-model="abnormalFeedBackData.temporaryConclusion" type="textarea" :disabled="disableFlag2" :rows="3" resize='none' style="width: 562px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 40px;">
        <span style="font-size: 12px">工艺变更记录:</span>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <span style="font-size: 12px">&nbsp温度&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.temperatureTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
        <span style="font-size: 12px">压力&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.pressureTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
        <span style="font-size: 12px">时间&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.timeTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
        <span style="font-size: 12px">投料量</span> <el-input v-model="abnormalFeedBackData.feedingTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
        <span style="font-size: 12px">机台&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.resourceTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <span style="font-size: 12px">&nbsp功率&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.efficiencyTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
        <span style="font-size: 12px">速度&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.speedTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
        <span style="font-size: 12px">材料&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.materialTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
        <span style="font-size: 12px">模具&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.mouldTemporary" :disabled="disableFlag2" style="width: 70px;margin-left: 2px"></el-input>
        <span style="font-size: 12px">工装&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.workClothesTemporary" :disabled="disableFlag2" style="width: 70px"></el-input>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-form-item label="根本原因分析">
          <el-input v-model="abnormalFeedBackData.rootCause" type="textarea" :disabled="disableFlag3" :rows="3" resize='none' style="width: 562px"></el-input>
        </el-form-item>
        <el-form-item label="长久处理方式" style="margin-top: 40px;">
          <el-input v-model="abnormalFeedBackData.treatment" type="textarea" :disabled="disableFlag3" :rows="3" resize='none' style="width: 562px"></el-input>
        </el-form-item>
        <el-form-item label="效果验证结论" style="margin-top: 40px;">
          <el-input v-model="abnormalFeedBackData.permanentConclusion" type="textarea" :disabled="disableFlag3" :rows="3" resize='none' style="width: 562px"></el-input>
        </el-form-item>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 40px;">
        <span style="font-size: 12px">工艺变更记录:</span>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <span style="font-size: 12px">&nbsp温度&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.temperature" :disabled="disableFlag3" style="width: 70px"></el-input>
        <span style="font-size: 12px">压力&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.pressure" :disabled="disableFlag3" style="width: 70px"></el-input>
        <span style="font-size: 12px">时间&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.time" :disabled="disableFlag3" style="width: 70px"></el-input>
        <span style="font-size: 12px">投料量</span> <el-input v-model="abnormalFeedBackData.feeding" :disabled="disableFlag3" style="width: 70px"></el-input>
        <span style="font-size: 12px">机台&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.resource" :disabled="disableFlag3" style="width: 70px"></el-input>
      </el-form>
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <span style="font-size: 12px">&nbsp功率&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.efficiency" :disabled="disableFlag3" style="width: 70px"></el-input>
        <span style="font-size: 12px">速度&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.speed" :disabled="disableFlag3" style="width: 70px"></el-input>
        <span style="font-size: 12px">材料&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.material" :disabled="disableFlag3" style="width: 70px"></el-input>
        <span style="font-size: 12px">模具&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.mould" :disabled="disableFlag3" style="width: 70px;margin-left: 2px"></el-input>
        <span style="font-size: 12px">工装&nbsp&nbsp&nbsp</span> <el-input v-model="abnormalFeedBackData.workClothes" :disabled="disableFlag3" style="width: 70px"></el-input>
      </el-form>
      <el-footer style="height:30px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="saveAbnormalDetail()" v-if="disableFlag4">保存</el-button>
        <el-button type="primary" @click="modalFlag = false">取消</el-button>
      </el-footer>
    </el-dialog>
    <el-dialog title="附件" :close-on-click-modal="false" v-drag :visible.sync="fileModalFlag" width="650px" >
      <el-form label-position="top" style="margin-top: 1px; margin-left: 0px;">
        <el-form :inline="true" label-position="top" style="margin-top: 0px">
          <el-button type="primary" @click="addUploadFileModal">上传文件</el-button>
        </el-form>
      </el-form>
      <el-table
        :data="fileData"
        height="240"
        border
        v-loading="false"
        style="width: 100%; ">
        <el-table-column
          v-for="(item,index) in columnFileContentArray" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed==''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden"> {{ scope.row[item.columnProp] }}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]"
                                               style="width: 100px; height: 80px"/></span>
          </template>
        </el-table-column>
        <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          width="100"
          label="操作">
          <template slot-scope="scope">
            <!--              <a :href="'http://192.168.1.130:80/file/'+scope.row.url" :download="scope.row.fileName">下载</a>-->
            <a  @click="downloadFile(scope.row)" >下载</a>
            <a type="text" size="small"  @click="deleteHandle(scope.row.id)">删除</a>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>
    <el-dialog title="上传附件" :close-on-click-modal="false" v-drag :visible.sync="upLoadModalFlag" width="400px" >
      <el-form :inline="true" label-position="top" style="margin-left: 7px;margin-top: 0px;">
        <el-upload drag :file-list="fileList"
                   action="javascript:void(0);" ref="uploadFile"
                   :on-change="onChange"
                   multiple :auto-upload="false"
                   style="text-align: left;">
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        </el-upload>
      </el-form>
      <el-footer style="height:30px;margin-top: 10px;text-align:center">
        <el-button type="primary" @click="upLoadFiles()" >保存</el-button>
        <el-button type="primary" @click="upLoadModalFlag = false">取消</el-button>
      </el-footer>
    </el-dialog>
  </div>
</template>

<script>
  import {
    getAbnormalCodeList,
    getShopOrderData,
    getAbnormalFeedBackList,
    saveAbnormalData,
    saveAbnormalDetail,
    openFeedBack,
    closeFeedBack,
  } from "@/api/abnormal.js"
  import {
    getSOScheduleRoutingDataForShiyanshi,
    downLoadProjectFile,
    upLoadAbnormalFiles,
  } from '@/api/production/inspect.js'
  import {
    printABLabel,
  } from "@/views/modules/print/print_Abnormal_label.js"
  import {ossListForOther} from '@/api/ftp/oss.js'
  export default {
    name: 'AbnormalFeedBack',
    data () {
      return {
        upLoadModalFlag:false,
        fileModalFlag:false,
        folder: 'abnormal',
        fileList: [],
        fileData: [],
        searchData:{
          userId:this.$store.state.user.name,
          startDate:'',
          endDate:'',
          abnormalCode:'',
          site:'',
          status:'',
          operatorDesc:'',
          partDesc:'',
          id:'',
        },
        upLoadData: {
          id:0,
          site:'',
        },
        fileContentList: [],
        // 导出 start
        exportData: [],
        exportDataStandard: {
          "工厂编号": "site",
          "生产订单": "orderNo",
          "派工单号": "seqNo",
          "物料编码": "partNo",
          "规格型号": "partDesc",
          "操作员": "operatorDesc",
          "生产线": "productionLineDesc",
          "反馈时间": "feedbackDate",
          "反馈人": "feedbackBy",
          "状态": "status",
          "异常原因": "abnormalDesc",
          "异常数量": "abnormalQty",
          "异常情况影响分析": "abnormalInfluence",
          "异常描述": "abnormalRemark",
          "报废状态1": "scrapType1",
          "报废原因1": "scrapReason1",
          "报废状态2": "scrapType2",
          "报废原因2": "scrapReason2",
          "报废状态3": "scrapType3",
          "报废原因3": "scrapReason3",
          "报废状态4": "scrapType4",
          "报废原因4": "scrapReason4",
          "报废状态5": "scrapType5",
          "报废原因5": "scrapReason5",
          "紧急处理方式": "treatmentTemporary",
          "临时性措施结论": "temporaryConclusion",
          "温度": "temperatureTemporary",
          "压力": "pressureTemporary",
          "时间": "timeTemporary",
          "投料量": "feedingTemporary",
          "机台": "resourceTemporary",
          "功率": "efficiencyTemporary",
          "速度": "speedTemporary",
          "材料": "materialTemporary",
          "模具": "mouldTemporary",
          "工装": "workClothesTemporary",
          "根本原因分析": "rootCause",
          "长久处理方式": "treatment",
          "效果验证结论": "permanentConclusion",
          "温度 ": "temperature",
          "压力 ": "pressure",
          "时间 ": "time",
          "投料量 ": "feeding",
          "机台 ": "resource",
          "功率 ": "efficiency",
          "速度 ": "speed",
          "材料 ": "material",
          "模具 ": "mould",
          "工装 ": "workClothes",
        },
        exportName: "异常反馈清单"+this.getStrDate(),
        exportHeader: ["异常反馈清单"],
        exportFooter: [],
        exportDefaultValue: "",
        // 导出 end
        dataListLoading:false,
        // 导出 end
        height:200,
        fileSearchData:{
          fileTypeCode:'Abnormal',
          orderRef1:'',
          orderRef2:''
        },
        tableData:[],
        addData:{
          site:'',
          seqNo:'',
          orderNo:'',
          shiftNo:'',
          resourceDesc:'',
          feedbackBy:this.$store.state.user.name,
          abnormalCode:'',
          abnormalRemark:'',
          abnormalInfluence:'',
          abnormalQty:'',
        },

        addModalFlag:false,
        modalFlag:false,
        disableFlag4:false,
        disableFlag1:false,
        disableFlag2:false,
        disableFlag3:false,
        abnormalList:[],
        abnormalFeedBackData:{

        },
        scrapTypeList:[
          {label:'缺料'},
          {label:'气泡'},
          {label:'断裂'},
          {label:'窝气'},
          {label:'粘模'},
          {label:'熟料'},
          {label:'杂质'},
          {label:'烧边'},
          {label:'错位'},
          {label:'脱胶'},
          {label:'表面缺陷'},
        ],
        scrapReasonList:[
          {label:'材料问题'},
          {label:'人员操作'},
          {label:'设备问题'},
          {label:'模具问题'},
          {label:'工艺问题'},
        ],
        columnFileContentArray: [
          {
            columnProp: 'fileName',
            headeralign: 'left',
            align: 'left',
            columnLabel: '文件名称',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: false

          }, {
            columnProp: 'createDate',
            headeralign: 'left',
            align: 'left',
            columnLabel: '上传时间',
            columnHidden: false,
            columnImage: false,
            columnSortable: true,
            sortLv: 0,
            status: true,
            fixed: false

          },
        ],
      }
    },
    mounted() {
      this.$nextTick(()=>{
        this.height = window.innerHeight - 210;
      })
    },
    watch: {
      '$route'(to, from) {
        if (localStorage.getItem('feedBackId') !== undefined) {
          let data = JSON.parse(localStorage.getItem('feedBackId'));
          console.log(data)
          if (data) {
            this.searchData.id = data.id
            getAbnormalFeedBackList(this.searchData).then(({data}) => {
              this.tableData = data.rows;
              this.getDetailModel2(data.rows[0])
            })
            setTimeout(() => {
              this.searchData.id = null
            },1000)
          }
          localStorage.removeItem('feedBackId');
        }
      }
    },
    methods: {
      getAllAbnormalItem(){
        getAbnormalCodeList().then(({data}) => {
          this.abnormalList = data.rows;
        })
      },
      search(){
        getAbnormalFeedBackList(this.searchData).then(({data}) => {
          this.tableData = data.rows;
        })
      },
      /*选择上传文件时*/
      onChange(file,fileList){
        this.fileList = fileList;
      },
      addAbnormal(){
        this.addData.seqNo='',
          this.addData.shiftNo='',
          this.addData.site='',
          this.addData.resourceDesc='',
          this.addData.orderNo='',
          this.addData.abnormalRemark='',
          this.addData.abnormalCode='',
        this.getAllAbnormalItem();
        this.fileList = [];
        this.addModalFlag=true;
      },
      seqNoCheck(){
        let inData={
          seqNo:this.addData.seqNo
        }
        getShopOrderData(inData).then(({data}) => {
          let rows=data.rows;
          if(rows.length==0){
            this.addData.seqNo='',
            this.addData.shiftNo='',
            this.addData.site='',
            this.addData.resourceDesc='',
            this.addData.orderNo='',
            this.$alert('该派工单不存在！', '错误', {
              confirmButtonText: '确定'
            })
            return false
          }else {
            this.addData.shiftNo=data.rows[0].sShiftNo
            this.addData.site=data.rows[0].site
            this.addData.resourceDesc=data.rows[0].resourceDesc
            this.addData.orderNo=data.rows[0].orderNo
          }
        })
      },
      saveAbnormalData(){
        if( this.addData.seqNo==null||this.addData.seqNo==''){
          this.$alert("请输入派工单号", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if( this.addData.abnormalCode==null||this.addData.abnormalCode==''){
          this.$alert("请选择异常原因", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if( this.addData.abnormalRemark==null||this.addData.abnormalRemark==''){
          this.$alert("请输入描述", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        const formData = new FormData();
        //片接文件
        for (let i = 0; i < this.fileList.length; i++) {
          formData.append("file",this.fileList[i].raw)
        }
        formData.append("folder", this.folder);
        formData.append("site", this.addData.site);
        formData.append("seqNo", this.addData.seqNo);
        formData.append("orderNo", this.addData.orderNo);
        formData.append("shiftNo", this.addData.shiftNo);
        formData.append("resourceDesc", this.addData.resourceDesc);
        formData.append("feedbackBy", this.addData.feedbackBy);
        formData.append("abnormalCode", this.addData.abnormalCode);
        formData.append("abnormalRemark", this.addData.abnormalRemark);
        formData.append("abnormalInfluence", this.addData.abnormalInfluence);
        formData.append("abnormalQty", this.addData.abnormalQty);
        saveAbnormalData(formData).then(({data}) => {
          if (data && data.code === 0) {
            this.$refs.uploadFile.clearFiles();
            this.fileList = [];
            this.addModalFlag=false
            this.search()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
              }
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      getDetailModel(row){
        this.abnormalFeedBackData=JSON.parse(JSON.stringify(row));
        this.disableFlag1=true;
        this.disableFlag2=true;
        this.disableFlag3=true;
        this.disableFlag4=false;
        this.modalFlag=true;
      },
      getDetailModel2(row){
        this.abnormalFeedBackData=JSON.parse(JSON.stringify(row));
        if(this.abnormalFeedBackData.status=='已录入'){
          this.abnormalFeedBackData.status='已填写紧急处理'
        }
        this.disableFlag1=true;
        this.disableFlag2=false;
        this.disableFlag3=true;
        this.disableFlag4=true;
        this.modalFlag=true;
      },
      getDetailModel3(row){
        this.abnormalFeedBackData=JSON.parse(JSON.stringify(row));
        if(this.abnormalFeedBackData.status=='已录入'||this.abnormalFeedBackData.status=='已填写紧急处理'){
          this.abnormalFeedBackData.status='已填写长久处理'
        }
        this.disableFlag1=true;
        this.disableFlag2=true;
        this.disableFlag3=false;
        this.disableFlag4=true;
        this.modalFlag=true;
      },
      saveAbnormalDetail(){
        if( this.disableFlag2==false&&(this.abnormalFeedBackData.treatmentTemporary==null||this.abnormalFeedBackData.treatmentTemporary=='')){
          this.$alert("请填写处理方式", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if( this.disableFlag3==false&&(this.abnormalFeedBackData.treatment==null||this.abnormalFeedBackData.treatment=='')){
          this.$alert("请填写处理方式", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if( this.disableFlag3==false&&(this.abnormalFeedBackData.rootCause==null||this.abnormalFeedBackData.rootCause=='')){
          this.$alert("请填写根本原因分析", '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        saveAbnormalDetail(this.abnormalFeedBackData).then(({data}) => {
          if (data && data.code === 0) {
            this.modalFlag=false
            this.search()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
              }
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
      closeFeedBack(row){
        this.$confirm(`是否关闭此反馈单?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          closeFeedBack(row).then(({data}) => {
            if (data && data.code === 0) {
              this.search()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                }
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },
      openFeedBack(row){
        this.$confirm(`是否开启此反馈单?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          openFeedBack(row).then(({data}) => {
            if (data && data.code === 0) {
              this.search()
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                }
              })
            } else {
              this.$alert(data.msg, '错误', {
                confirmButtonText: '确定'
              })
            }
          })
        }).catch(() => {
        })
      },
      createExportData() {

        return this.tableData;
      },
      startDownload() {
        //  this.exportData = this.dataList

      },
      finishDownload() {

      },
      getStrDate() {
        let dd = new Date();
        let Y = dd.getFullYear();
        let M = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1);//获取当前月份的日期，不足10补0
        let D = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();//获取当前几号，不足10补0
        let H = dd.getHours() < 10 ? "0" + dd.getHours() : dd.getHours();
        let MM = dd.getMinutes() < 10 ? "0" + dd.getMinutes() : dd.getMinutes();
        let S = dd.getSeconds() < 10 ? "0" + dd.getSeconds() : dd.getSeconds();
        return Y + M + D + H + MM + S;

      },
      doPrint(row){
        let inData={
          seqNo:row.seqNo
        }
        getSOScheduleRoutingDataForShiyanshi(inData).then(({data})=>{
          data.rows[0].abnormalDesc=row.abnormalDesc
          data.rows[0].abnormalRemark=row.abnormalRemark
          printABLabel(data.rows);
        })
      },
      downloadFile(row){

        downLoadProjectFile(row)
          .then(({data}) => {
            // 不限制文件下载类型
            const blob = new Blob([data], {type: 'application/octet-stream;charset=utf-8'})
            // 下载文件名称
            const fileName = row.fileName
            // a标签下载
            const linkNode = document.createElement('a')
            linkNode.download = fileName // a标签的download属性规定下载文件的名称
            linkNode.style.display = 'none'
            linkNode.href = URL.createObjectURL(blob) // 生成一个Blob URL
            console.log(linkNode)
            // if(val == 'Y'){
            //   this.pdfVisible = true
            //   this.pdfUrl = linkNode.href
            // }else {
            document.body.appendChild(linkNode)
            linkNode.click() // 模拟在按钮上的一次鼠标单击
            URL.revokeObjectURL(linkNode.href) // 释放URL 对象
            document.body.removeChild(linkNode)
          })
      },
      getFileModel(row){
        this.fileSearchData={
          fileTypeCode:'Abnormal',
          orderRef1:row.site,
          orderRef2:row.id,
        }
        this.getFileList()
        this.fileModalFlag=true;
      },
      getFileList(){
        ossListForOther(this.fileSearchData).then(({data}) => {
          if (data && data.code == 0) {
            this.fileData = data.data
          } else {
            this.fileData = []
          }
        })
      },
      deleteHandle(id) {
        let ids = [id]
        this.$confirm(`确定进行[删除]操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl('/sys/oss/delete'),
            method: 'post',
            data: this.$http.adornData(ids, false)
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message.success('操作成功')
              this.getFileList()
            } else {
              this.$message.error(data.msg)
            }
          })
        }).catch(() => {
        })
      },
      addUploadFileModal(){
        this.upLoadData.site=this.fileSearchData.orderRef1
        this.upLoadData.id=this.fileSearchData.orderRef2
        this.fileList=[]
        this.upLoadModalFlag=true;
      },
      upLoadFiles(){
        if(null == this.fileList || 0 === this.fileList.length){
          this.$alert('未选择附件上传！', '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }

        const formData = new FormData();
        //片接文件
        for (let i = 0; i < this.fileList.length; i++) {
          formData.append("file",this.fileList[i].raw)
        }

        formData.append("site", this.upLoadData.site);
        formData.append("folder", this.folder);
        formData.append("projectId", this.upLoadData.id);

        upLoadAbnormalFiles(formData).then(({data}) => {
          if (data && data.code === 0) {
            this.$refs.uploadFile.clearFiles();
            this.fileList = [];
            this.upLoadModalFlag=false
            this.getFileList()
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
              }
            })
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })
      },
    },

    created() {
      this.getAllAbnormalItem();
      if (localStorage.getItem('feedBackId') !== undefined) {
        let data = JSON.parse(localStorage.getItem('feedBackId'));
        console.log(data)
        if (data) {
          this.searchData.id = data.id
          getAbnormalFeedBackList(this.searchData).then(({data}) => {
            this.tableData = data.rows;
            this.getDetailModel2(data.rows[0])
          })
          setTimeout(() => {
            this.searchData.id = null
          },1000)
        }
        localStorage.removeItem('feedBackId');
      }
    }
  }
</script>

<style scoped>

</style>
