<template>
  <div class="mod-config">
    <el-form :inline="true" label-position="top" style="margin-top: 1px; margin-left: 0px;" >
      <el-row :gutter="20">
        <el-col :span="18">
          <el-form-item label="物料编码/Part No.">
            <el-input v-model="bomData.partNo" readonly style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item label="BOM类型/BOM Type">
            <el-input v-model="bomData.bomType" readonly style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item label="BOM版本/BOM Rev.">
            <el-input v-model="bomData.engChgLevel" readonly style="width: 120px"></el-input>
          </el-form-item>
          <el-form-item label="替代编码/Alternative No.">
            <el-input v-model="bomData.alternativeNo" readonly style="width: 130px"></el-input>
          </el-form-item>
<!--          <el-form-item label="URL文件号/UL Product Model">-->
<!--            <dict-data-select :site="searchData.site" v-if="searchData.site" v-model="bomData.urlFile" style="width: 240px" dict-type="bm_url_file"></dict-data-select>-->
<!--          </el-form-item>-->
<!--          <el-form-item prop="urlFile" :rules="componentRules.urlFile">-->
<!--            <span style="cursor: pointer" slot="label" @click="queryUrlFile"><a herf="#">URL文件号/UL Product Model</a></span>-->
<!--            <el-input v-model="bomData.urlFile" style="width: 103px"></el-input>-->
<!--          </el-form-item>-->

          <el-form-item
            prop="urlFile"
            :rules="componentRules.urlFile"
            label="UL文件号/UL Product Model"
          >
            <span slot="label">
              <a href="javascript:void(0)" @click="queryUrlFile" style=" text-decoration: none;">UL文件号/UL Product Model</a>
            </span>
            <el-input v-model="bomData.urlFile" style="width: 370px" />
          </el-form-item>
          <el-form-item label=" ">
            <el-button type="primary" @click="searchTable(true)" >刷新</el-button>
            <el-button type="primary" v-if="((!ifDisableFlag && spForm.sp.includes(searchData.username) && baseForm.status === 'spz') || baseForm.status === 'cg' || superAdmin)" @click="changeBomRev()">变更</el-button>
            <el-button type="primary" @click="jumpBom()">跳转至BOM</el-button>
            <el-button type="primary" v-if="(!ifDisableFlag && isAuth('103002:bmSave') && spForm.sp.includes(searchData.username) && baseForm.status === 'spz') || baseForm.status === 'cg' || superAdmin" @click="updateBMProcess()" >保存数据</el-button>
            <el-button v-if="baseForm.status === 'spz' && ((!ifDisableFlag && spForm.sp.includes(searchData.username)) || (superAdmin))" type="primary" @click="agreeSubmit">同意</el-button>
            <el-button v-if="baseForm.status === 'spz' && ((baseForm.isReject === 'Y' && !ifDisableFlag && spForm.sp.includes(searchData.username)) || (superAdmin))" type="primary" @click="submitDataModal">驳回</el-button>
    <!--        <el-button type="primary" @click="newData()" v-if="!ifDisableFlag">新增</el-button>-->
          </el-form-item>
        </el-col>
        <el-col :span="3"><div class="grid-content bg-purple">
          <el-form-item label="当前节点/Status" style="width: 100%">
            <el-input v-model="spForm.nodeName" disabled></el-input>
          </el-form-item>
        </div>
        </el-col>
        <el-col :span="3"><div class="grid-content bg-purple">
          <el-form-item label="当前节点审批人/Authorizer" style="width: 100%">
            <el-input v-model="spForm.sp" disabled></el-input>
          </el-form-item>
        </div>
        </el-col>
      </el-row>
      <el-table
        :data="bomList"
        :height="height"
        border
        ref="componentTable"
        style="width:100%">
<!--        <el-table-column-->
<!--          v-for="(item,index) in columnList1" :key="index"-->
<!--          :sortable="item.columnSortable"-->
<!--          :prop="item.columnProp"-->
<!--          :header-align="item.headerAlign"-->
<!--          :show-overflow-tooltip="item.showOverflowTooltip"-->
<!--          :align="item.align"-->
<!--          :fixed="item.fixed == ''?false:item.fixed"-->
<!--          :min-width="item.columnWidth"-->
<!--          :label="item.columnLabel">-->
<!--          <template slot-scope="scope">-->
<!--            <span v-if="!item.columnHidden">{{scope.row[item.columnProp]}}</span>-->
<!--            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>-->
<!--          </template>-->
<!--        </el-table-column>-->
        <el-table-column label="序号" header-align="center">
          <el-table-column
            prop="lineSequence"
            header-align="center"
            align="center"
            min-width="60"
            label="Item No.">
          </el-table-column>
        </el-table-column>
        <el-table-column label="装配件料号" header-align="center">
          <el-table-column
            prop="componentPart"
            header-align="center"
            align="center"
            min-width="120"
            label="Component Part">
          </el-table-column>
        </el-table-column>
        <el-table-column label="描述" header-align="center">
          <el-table-column
            prop="componentPartDesc"
            header-align="center"
            align="left"
            min-width="160"
            label="Description">
          </el-table-column>
        </el-table-column>
        <el-table-column label="单位用量" header-align="center">
          <el-table-column
            prop="qtyPerAssembly"
            header-align="center"
            align="right"
            min-width="140"
            label="Quantity Per Assembly">
          </el-table-column>
        </el-table-column>
        <el-table-column label="调机料" header-align="center">
          <el-table-column
            prop="componentScrap"
            header-align="center"
            align="right"
            min-width="100"
            label="Component Scrap">
          </el-table-column>
        </el-table-column>
        <el-table-column label="损耗率" header-align="center">
          <el-table-column
            prop="shrinkageFactor"
            header-align="center"
            align="right"
            min-width="100"
            label="Scrap Factor(%)">
          </el-table-column>
        </el-table-column>
        <el-table-column label="单位" header-align="center">
          <el-table-column
            prop="printUnit"
            header-align="center"
            align="center"
            min-width="60"
            label="Unit">
          </el-table-column>
        </el-table-column>
        <el-table-column label="发料方式" header-align="center">
          <el-table-column
            prop="issueType"
            header-align="center"
            align="center"
            min-width="80"
            label="Reserve/Issue Method">
          </el-table-column>
        </el-table-column>
        <el-table-column label="工序号" header-align="center">
          <el-table-column
            prop="operationId"
            header-align="center"
            align="center"
            min-width="80"
            label="Operation">
          </el-table-column>
        </el-table-column>
        <el-table-column label="发料库位" header-align="center">
          <el-table-column
            prop="issueToLocName"
            header-align="center"
            align="center"
            min-width="100"
            label="Issue From Loc.">
          </el-table-column>
        </el-table-column>
        <el-table-column label="备注" header-align="center">
          <el-table-column
            prop="noteText"
            header-align="center"
            align="left"
            min-width="150"
            label="Comments">
          </el-table-column>
        </el-table-column>
        <el-table-column
          fixed="right"
          header-align="center"
          align="center"
          width="90"
          label="操作">
          <template slot-scope="scope">
            <a type="text" v-if="scope.row.ifHasPeifang==='Y'" size="small" @click="jumpPeifang(scope.row)">跳转配方</a>
          </template>
        </el-table-column>
      </el-table>
    </el-form>

    <el-dialog title="变更BOM" :close-on-click-modal="false" v-drag :visible.sync="modalFlag" width="750px">
      <el-table
        :data="bomDetailList"
        height="300"
        border
        highlight-current-row
        onclick=""
        @row-click="getRow"
        ref="componentTable"
        style="width:100%">
        <el-table-column
          prop="partNo"
          header-align="left"
          align="left"
          min-width="80"
          label="物料编码">
        </el-table-column>
        <el-table-column
          prop="bomType"
          header-align="left"
          align="left"
          min-width="80"
          label="BOM类型">
        </el-table-column>
        <el-table-column
          prop="engChgLevel"
          header-align="left"
          align="left"
          min-width="80"
          label="BOM版本">
        </el-table-column>
        <el-table-column
          prop="alternativeNo"
          header-align="left"
          align="left"
          min-width="80"
          label="替代编码">
        </el-table-column>
        <el-table-column
          prop="alternativeDescription"
          header-align="left"
          align="left"
          min-width="80"
          label="替代名称">
        </el-table-column>
        <el-table-column
          prop="status"
          header-align="left"
          align="left"
          min-width="60"
          label="状态">
        </el-table-column>
        <el-table-column
          prop="effPhaseInDate"
          header-align="left"
          align="left"
          min-width="80"
          label="生效日期">
        </el-table-column>
        <el-table-column
          prop="effPhaseOutDate"
          header-align="left"
          align="left"
          min-width="80"
          label="失效日期">
        </el-table-column>
      </el-table>
      <el-footer style="height:30px;margin-top:20px;text-align:center">
        <el-button type="primary" @click="updateBMBomRev()">确定</el-button>
        <el-button type="primary" @click="modalFlag=false">取消</el-button>
      </el-footer>
    </el-dialog>
    <!-- 提交 -->
    <el-dialog title="驳回" top="30vh" :close-on-click-modal="false" v-drag :visible.sync="submitModalFlag" width="500px">
      <el-form :inline="true" label-position="top">
        <el-form-item :label="'驳回意见'">
          <el-input type="textarea" v-model="rejectOpinion" :rows="3" resize='none' show-word-limit style="width: 479px;height: 30px"></el-input>
        </el-form-item>
      </el-form>
      <el-footer style="height:30px;margin-top: 50px;text-align:center">
        <el-button type="primary" @click="rejectSubmit">确定</el-button>
        <el-button type="primary" @click="submitModalFlag = false">取消</el-button>
      </el-footer>
    </el-dialog>

    <el-dialog title="UL文件号/UL Product Model" top="17vh" :close-on-click-modal="false" v-drag :visible.sync="urlFileFlag" width="700px">
      <el-form :inline="true" label-position="top" :model="searchData">
        <el-form-item :label="'名称'">
          <el-input v-model="bomData.urlFile" clearable style="width: 370px"></el-input>
        </el-form-item>
        <el-form-item :label="' '">
          <el-button type="primary" @click="queryUrlFile">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table
        :height="250"
        :data="urlFileList"
        border
        @row-dblclick="getRowData"
        style="width: 100%;">
        <el-table-column
          v-for="(item,index) in urlFileColumnList" :key="index"
          :sortable="item.columnSortable"
          :prop="item.columnProp"
          :header-align="item.headerAlign"
          :show-overflow-tooltip="item.showOverflowTooltip"
          :align="item.align"
          :fixed="item.fixed==''?false:item.fixed"
          :min-width="item.columnWidth"
          :label="item.columnLabel">
          <template slot-scope="scope">
            <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
            <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页插件 -->
      <el-pagination
        style="margin-top: 5px"
        @size-change="sizeChangeHandle"
        @current-change="currentChangeHandle"
        :current-page="pageIndex"
        :page-sizes="[20, 50, 100, 200, 500]"
        :page-size="pageSize"
        :total="totalPage"
        layout="total, sizes, prev, pager, next, jumper">
      </el-pagination>
      <el-footer style="height:35px;margin-top:10px;text-align:center">
        <el-button type="primary" @click="urlFileFlag = false">关闭</el-button>
      </el-footer>
    </el-dialog>

    <Chooselist ref="baseList"  @getBaseData="getBaseData"></Chooselist>
  </div>
</template>

<script>
  import {
    searchBMBom,
    searchBMBomDetail,
    updateBMBomRev,
    tsdBasicInformationSearch,
    getBMStatusDesc,
    submitChange, // 提交
    getOADetailForBM,
    updateBMProcessBom, // 保存数据
  } from "@/api/sampleManagement/technicalSpecificationList.js"
  import {
    getNodeAuthority, // 获取节点权限
  } from '@/api/changeManagement/changeManagement.js'
  import Chooselist from '@/views/modules/common/Chooselist'
  import DictDataSelect from "../../sys/dict-data-select-highlight";
  import {verifyData} from "../../../../api/chooselist/chooselist";
  import {queryWorkCenterList} from "../../../../api/part/workCenter";
  import {
    queryFileUrl,
    queryUrlFile,
    queryUrlFileList
  } from "../../../../api/sampleManagement/technicalSpecificationList";
  export default {
    components: {
      DictDataSelect,
      Chooselist
    },

    data() {
      return {
        pageIndex: 1,
        pageSize: 20,
        totalPage: 0,
        superAdmin:false,
        modalFlag:false,
        bomFlag:false,
        urlFileFlag:false,
        height:200,
        searchData: {
          site: '',
          username: this.$store.state.user.name,
          codeNo: '',
          buNo:'',
          fieldId:'',
          dictLabel: '',
          dictType: ''
        },
        bomData:{
          site: '',
          partNo:'',
          alternativeNo:'',
          bomType:'',
          engChgLevel:'',
          urlFile: ''
        },
        componentRules:{
          urlFile: [
            {
              required: true,
              message: ' ',
              trigger: ['blur', 'change']
            }
          ],
        },
        currentRow:"",
        bomList:[],
        urlFileList:[],
        bomDetailList:[],
        columnList1: [
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2LineSequence',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'lineSequence',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '序号/Item No.',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2ComponentPart',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'componentPart',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '装配件料号/Component Part',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 120
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2ComponentPartDesc',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'componentPartDesc',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '描述/Description',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 160
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2QtyPerAssembly',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'qtyPerAssembly',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '单位用量/Quantity Per Assembly',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 140
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2ComponentScrap',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'componentScrap',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '调机料/Component Scrap',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2ShrinkageFactor',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'shrinkageFactor',
            headerAlign: 'center',
            align: 'right',
            columnLabel: '损耗率/Scrap Factor(%)',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2PrintUnitName',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'printUnit',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '单位/Unit',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 60
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2IssueType',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'issueType',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '发料方式/Reserve/Issue Method',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2OperationDesc',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'operationId',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '工序号/Operation',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2IssueToLoc',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'issueToLocName',
            headerAlign: 'center',
            align: 'center',
            columnLabel: '发料库位/Issue From Loc.',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 80
          },
          {
            userId: this.$store.state.user.name,
            functionId: 104002,
            serialNumber: '104002Table2NoteText',
            tableId: '104002Table2',
            tableName: 'BOM子物料表',
            columnProp: 'noteText',
            headerAlign: 'center',
            align: 'left',
            columnLabel: '备注/Comments',
            columnHidden: false,
            columnImage: false,
            columnSortable: false,
            sortLv: 0,
            status: true,
            fixed: '',
            columnWidth: 150
          },
        ],
        urlFileColumnList: [
          {
            userId: this.$store.state.user.name,
            tableName: '字典数据表',
            columnProp: 'dictLabel',
            headerAlign: "center",
            align: "left",
            columnLabel: '名称',
            columnHidden: false,
            columnImage: false,
            status: true,
            fixed: '',
            columnWidth: 100
          },
          // {
          //   userId: this.$store.state.user.name,
          //   tableName: '字典数据表',
          //   columnProp: 'dictValue',
          //   headerAlign: "center",
          //   align: "left",
          //   columnLabel: '值',
          //   columnHidden: false,
          //   columnImage: false,
          //   status: true,
          //   fixed: '',
          //   columnWidth: 100
          // },
        ],
        baseForm:{
          status:'',
          isReject:'',
        },

        spForm:{
          sp:'',
          nodeName:'',
        },
        ifDisableFlag:false,
        rejectOpinion: '',
        submitModalFlag: false,
      }
    },
    mounted () {
      this.$nextTick(() => {
        this.height = window.innerHeight - 100
      })
    },
    methods: {
      // 获取基础数据列表S
      getBaseList (val, type) {
        this.tagNo = val
        this.tagNo1 = type
        this.$nextTick(() => {
          let strVal = ''
          if (val === 1013) {
            if(type==1) {
              strVal = this.dataForm.partType
            }
          }
          this.$refs.baseList.init(val, strVal)
        })
      },
      /* 列表方法的回调 */
      getBaseData (val) {
        if (this.tagNo === 1013) {
          if(this.tagNo1==1) {
            this.dataForm.partType = val.Base_id
            this.dataForm.partTypeDesc = val.Base_desc
          }
        }
      },

      choosePart(row){
        this.dataForm.erpPartNo=row.erpPartNo
        this.dataForm.familyId=row.familyId
        this.dataForm.familyName=row.familyName
        this.dataForm.partDesc=row.partDesc
        this.dataForm.spec=row.spec
        this.partModelFlag=false;
      },

      //初始化组件的参数
      init (inData) {
        if (this.searchData.codeNo != null && this.searchData.codeNo != '') {
          return false;
        }
        // 初始化参数
        this.searchData = JSON.parse(JSON.stringify(inData))
        if (this.searchData.ifDisableFlag) {
          this.ifDisableFlag = true
        }
        // 刷新表格
        this.searchTable()
      },

      searchTable (type) {
        getOADetailForBM(this.searchData).then(({data}) => {
          this.spForm.nodeName = data.row.nodeName
          this.spForm.sp = data.row.sp == null ? '' : data.row.sp
        })
        searchBMBom(this.searchData).then(({data}) => {
          if (data&& data.code === 0) {
            this.bomList = data.rows
            this.bomData = data.row
            if (type) {
              this.$message.success( '操作成功')
            }
          } else {
            this.$message.error(data.msg)
          }
        })
        tsdBasicInformationSearch(this.searchData).then(({data}) => {
          this.baseForm=data.row;
          this.bomData.site=data.row.site
          this.bomData.partNo=data.row.finalPartNo
          this.bomData.urlFile=data.row.urlFile
          this.getNodeAuthority(data.row)
        })
      },

      searchDetailTable () {
        searchBMBomDetail(this.bomData).then(({data}) => {
          this.bomDetailList = data.rows
        })
      },

      changeBomRev () {
        this.searchDetailTable()
        this.currentRow = null
        this.modalFlag = true
      },

      getRow (row) {
        this.currentRow = row
      },

      updateBMBomRev () {
        if (this.currentRow == null) {
          this.$alert('请点击选择BOM版本！', '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        if (this.currentRow.status !== 'Buildable') {
          this.$alert('只有Buildable状态的可以保存！', '错误', {
            confirmButtonText: '确定'
          })
          return false;
        }
        let inData = {
          site: this.bomData.site,
          codeNo: this.searchData.codeNo,
          bomType: this.currentRow.bomType,
          engChgLevel: this.currentRow.engChgLevel,
          bomAlternativeNo: this.currentRow.alternativeNo,
          urlFile: this.currentRow.urlFile,
        }
        updateBMBomRev(inData).then(({data})=>{
          if(data&& data.code===0){
            this.searchTable();
            this.modalFlag=false;
            this.$message.success( '操作成功')
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      jumpBom () {
        if (this.bomData.engChgLevel != null || this.bomData.engChgLevel !== '') {
          this.$message.error("bom明细不存在")
        }
        let inData = {
          site: this.searchData.site,
          partNo: this.bomData.partNo,
          bomType: this.bomData.bomType,
          engChgLevel: this.bomData.engChgLevel,
          urlFile: this.bomData.urlFile,
        }
        localStorage.setItem('bomData', JSON.stringify(inData))
        window.open('#/part-bomManagement')
      },

      jumpPeifang (row) {
        let inData = {
          site: row.site,
          partNo: row.componentPart,
          bomType: 'Manufacturing',

        }
        localStorage.setItem('recipeData', JSON.stringify(inData))
        window.open('#/part-recipeManagement')
      },

      // 获取流程的配置权限
      getNodeAuthority (row) {
        getBMStatusDesc(this.searchData).then(({data}) => {
          this.superAdmin=data.superAdmin
          if(data.superAdmin){
            this.ifDisableFlag = false
            return false
          }
          if (data.status === '已完成' || data.status === '已升版' || data.status === 'Dead') {
            this.ifDisableFlag = true
            return false
          }
          if(data.status === '审批中') {
            let tempData = {
              site: row.site,
              stepId: row.stepId,
              menuId: '103002'
            }
            getNodeAuthority(tempData).then(({data}) => {
              if (data && data.code === 0) {
                this.ifDisableFlag = true
                let plmStepRoleBaseBm = data.rows.plm_stepRole_base_bm
                let arr = plmStepRoleBaseBm.filter(a => a.fieldId === this.searchData.fieldId)
                if (arr.length > 0) {
                  if (arr[0].updateFlag === 'N') {
                    this.ifDisableFlag = true
                  } else {
                    this.ifDisableFlag = false
                  }
                } else {
                  this.ifDisableFlag = true
                }
              }
            })
          }
        })
      },

      // 修改表单数据
      updateBMProcess () {
        let inData = {
          site: this.bomData.site,
          codeNo: this.searchData.codeNo,
          urlFile: this.bomData.urlFile
        }
        updateBMProcessBom(inData).then(({data})=>{
          if (data&& data.code === 0) {
            this.searchTable()
            this.$message.success( '操作成功')
          } else {
            this.$message.error(data.msg)
          }
        })
      },

      // 同意提交
      agreeSubmit () {
        this.$confirm(`是否确认提交?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let tempData = {
            site: this.searchData.site,
            userName: this.$store.state.user.name,
            codeNo: this.searchData.codeNo,
            menuId: '103002',
            nodeConclusion: 'Y'
          }
          this.submitData(tempData)
        })
      },

      // 驳回提交
      rejectSubmit () {
        this.$confirm(`是否确认驳回?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          let tempData = {
            site: this.searchData.site,
            userName: this.$store.state.user.name,
            codeNo: this.searchData.codeNo,
            menuId: '103002',
            nodeConclusion: 'N',
            rejectOpinion : this.rejectOpinion
          }
          this.submitData(tempData)
        })
      },
      submitData (tempData) {
        submitChange(tempData).then(({data}) => {
          if (data && data.code === 0) {
            this.submitModalFlag = false
            // this.searchTable();
            window.location.reload();
            this.$message({message: '操作成功', type: 'success'})
          } else {
            this.$alert(data.msg, '错误', {
              confirmButtonText: '确定'
            })
          }
        })

      },
      // 打开提交模态框
      submitDataModal () {
        this.rejectOpinion = ''
        this.submitModalFlag = true
      },

      queryUrlFile(){
        this.searchData.limit = this.pageSize
        this.searchData.page = this.pageIndex
        this.searchData.dictType = 'bm_url_file'
        this.searchData.dictLabel = this.bomData.urlFile
        queryUrlFileList(this.searchData).then(({data}) => {
          if (data && data.code === 0) {
            this.urlFileList = data.page.list
            this.pageIndex = 1
            this.pageSize = data.page.pageSize
            this.totalPage = data.page.totalCount
          } else {
            this.urlFileList = []
          }
        })
        this.urlFileFlag = true
      },

      sizeChangeHandle(val) {
        this.pageSize = val
        this.pageIndex = 1
        this.queryUrlFile()
      },

      currentChangeHandle(val) {
        this.pageIndex = val
        this.queryUrlFile()
      },

      getRowData(row) {
      this.bomData.urlFile = row.dictLabel
      this.urlFileFlag = false
      },
    },
  }
</script>

<style scoped>
input[readonly] {
  cursor: text;
}
</style>
