<template>
  <div class="app-container">
<!--    <el-card style="max-height:500px;margin-bottom: 20px;overflow: scroll">-->
      <div class="filter-container">
        <el-input
          @keyup.enter.native="searchData"
:size="sizeType"
v-model="search.orderCode"
placeholder="订单单号"
style="width: 200px;"
                  class="filter-item"/>
        <el-select :size="sizeType" v-model="search.dispatchState">
          <el-option
            v-for="item in stateOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"></el-option>
        </el-select>
        <el-date-picker
          :size="sizeType"
          v-model="searchTime"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          value-format="yyyy-MM-dd HH:mm:ss"
          :default-time="['00:00:00', '23:59:59']">
        </el-date-picker>
        <el-button :size="sizeType" class="filter-item"  type="primary" icon="el-icon-search" @click="searchData">
          搜索
        </el-button>
      </div>
      <div class="filter-container">
<!--        <el-button v-if="userInfo.workInState == 0" :size="sizeType" class="filter-item" type="primary"-->
<!--                   @click="goToWork">-->
<!--          上班-->
<!--        </el-button>-->
<!--        <el-button v-if="userInfo.workInState == 1||userInfo.workInState == 2" :size="sizeType" class="filter-item"-->
<!--                   type="warning" @click="goOffWork">-->
<!--          下班-->
<!--        </el-button>-->
        <el-button
v-if="userInfo.workInState == 1"
:size="sizeType"
class="filter-item"
type="danger"
                   @click="showBusy">
          停止接单
        </el-button>
        <el-button
v-if="userInfo.workInState == 2"
:size="sizeType"
class="filter-item"
type="green"
                   @click="showLeisure">
          开始接单
        </el-button>
<!--        <span v-if="userInfo.workInState == 1||userInfo.workInState == 2">上班时间:{{ userInfo.workInTime }}</span>-->
        <span>分配p数:{{ userInfo.workInCount }}</span>
        <el-button style="margin-left: 15px"  type="primary" size="mini" id="sys_fileHandle_refreshBtn" icon="el-icon-refresh" @click="refreshPage">刷新</el-button>
      </div>
      <el-table
        :size="sizeType"
        :data="tableData"
        v-loading="listLoading"
        row-key="id"
        border
        max-height="500px"
        style="margin-top: 10px;"
        ref="orderTable"
        :highlight-current-row="true"
        @row-click="handleClickTableRow"
        default-expand-all>

        <el-table-column
          fixed
          width="320"
          label="操作">
          <template slot-scope="{row}">
            <el-button
              v-show="row.workStatus != 100"
              @click.stop="backBtn(row)"
              type="primary"
              size="mini">
              退回
            </el-button>
<!--            <el-dropdown size="mini" @command="handleCommand" trigger="click">-->
<!--              <el-button size="mini" @click="handleCommandRow(row)" type="warning">下载</el-button>-->
<!--              <el-dropdown-menu slot="dropdown">-->
<!--                <el-dropdown-item  command="2">下载原件</el-dropdown-item>-->
<!--                <el-dropdown-item  command="3">下载样稿</el-dropdown-item>-->
<!--              </el-dropdown-menu>-->
<!--            </el-dropdown>-->
            <el-button size="mini" style="margin-left: 2px" type="warning" @click.stop="downloadFile(row)">原图</el-button>
            <el-button size="mini" style="margin-left: 2px" type="info" @click.stop="downloadproofFile(row)">样稿</el-button>
            <div style="display: inline-block;" @click.stop>
            <el-dropdown style="margin-left: 2px" size="mini" @command="getUploadType($event,row)" trigger="click">
              <el-button size="mini" type="green">{{ row.workStatus == 100?'重传':'完成' }}</el-button>
              <el-dropdown-menu slot="dropdown">
<!--                <el-dropdown-item command="2">传输文件</el-dropdown-item>-->
                <el-dropdown-item command="3">关联文件</el-dropdown-item>
<!--                <el-dropdown-item command="4">直接完成</el-dropdown-item>-->
              </el-dropdown-menu>
            </el-dropdown>
            </div>
            <el-button size="mini" style="margin-left: 2px" type="danger"  v-show="row.workStatus == 100" @click.stop="handleDeleteFile(row.idOrder)">查看小版文件</el-button>
            <el-button size="mini" type="danger" v-show="row.workStatus != 100" @click.stop="commitPDF(row)" style="margin:0">校对</el-button>
          </template>
        </el-table-column>
        <el-table-column
          label="序号"
          fixed
          align="center"
          width="50"
          type="index">
          <template slot-scope="scope">
            <span>{{ (listData.page - 1) * listData.pageSize + scope.$index + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="printOrder.orderCode"
          label="订单编号"
          width="130">
          <template slot-scope="{row}">
            <a href="javascript:;" style="color: #20a0ff" @click.stop="getOrderStep(row)">{{ row.printOrder.orderCode }}
              <span v-if="row.printOrder.businessKind==3"
                    style="display: inline-block;color: red">(补{{ row.printOrder.rePrintIndex }})</span>
              <el-image v-if="row.printOrder.firstOrderFlag == 1" :src="new_badge"></el-image></a>
          </template>
        </el-table-column>
        <el-table-column
          prop="printOrder.orderName"
          label="印品名称"
          width="110"
          show-overflow-tooltip>
          <template slot-scope="{row}">
            <a href="javascript:;" style="color: #20a0ff" @click="openDetail(row)">{{ row.printOrder.orderName}}</a>
          </template>
        </el-table-column>
        <el-table-column
          prop="printOrder.clientName"
          label="客户名称"
          width="100"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="printOrder.orderMoneyTotal"
          label="订单金额"
          width="150">
        </el-table-column>
        <el-table-column
          prop="printOrder.createMan"
          label="制单人"></el-table-column>
        <el-table-column
          prop="printOrder.productName"
          show-overflow-tooltip
          label="产品类型"></el-table-column>
        <el-table-column label="文件描述" show-overflow-tooltip>
          <template slot-scope="{row}">
            <el-link :href="row.printOrder.originFileLink" target="_blank" style="color: #20a0ff">
              {{ row.printOrder.fileDescription }}
            </el-link>
          </template>
        </el-table-column>
        <el-table-column label="样稿文件" show-overflow-tooltip>
          <template slot-scope="{row}">
            <el-link :href="row.printOrder.proofFileLink" target="_blank" style="color: #20a0ff">
              {{ row.printOrder.proofFile }}
            </el-link>
          </template>
        </el-table-column>
        <el-table-column
          prop="processCount"
          label="处理次数"></el-table-column>
        <el-table-column
          prop="processMemo"
          label="校稿退回说明"></el-table-column>
        <el-table-column
          prop="dispatchTime"
          width="120px"
          label="分配时间">
          <template slot-scope="scope">
            <span>{{scope.row.dispatchTime | getTime}}</span>
          </template>
        </el-table-column>
        <el-table-column
          prop="itemKindName"
          width="130px"
          label="P数类型">
        </el-table-column>
        <el-table-column
          width="80px"
          align="center"
          prop="pCount"
          label="订单P数">
          <template slot-scope="scope">
            <span @click.stop="handlePCount(scope.row)" style="width: 80px;display: block;cursor: pointer;color: #409eff">{{scope.row.pCount}}</span>
          </template>
        </el-table-column>
      </el-table>
      <pagination
v-show="listData.total>0"
:total="listData.total"
:page.sync="listData.page"
                  :limit.sync="listData.pageSize"
@pagination="getList"/>
<!--    </el-card>-->
    <el-card v-if="orderDetail != null">
      <p v-for=" (part,index) in orderDetail.partList" :key="index">
        [{{ part.partName }}]
        <template v-for="parameter in part.paramValueList">
          <label style="color: #20a0ff">{{ parameter.parameterName }}:</label>
          <span>{{ parameter.paramDisplay }}</span>&nbsp;
        </template>
        <br>
        <label style="color: #20a0ff">工艺:</label>
        <template v-if="part.processList.length>0" v-for="process in part.processList">
          <span>{{ process.processName }}</span><span v-if="process.materialName">({{process.materialName}},)</span><span v-if="process.processMemo">({{process.processMemo}})</span><span>&nbsp;&nbsp;</span>
        </template>
        <span style="display: block;margin-top: 5px"><span style="color: #20a0ff;font-weight: 700;">展开尺寸：</span>{{part.calcSpreadSize}}</span>
      </p>
      <p>备注：{{orderDetail.orderMemo}}</p>

    </el-card>
    <el-dialog title="分配订单" :close-on-click-modal="false" :visible.sync="distributeDialog" width="800px">
      <el-table
        :data="checkInUserList"
        border
        v-loading="userListLoading">
        <el-table-column label="操作">
          <template slot-scope="{row}">
            <el-button size="medium" type="primary" @click="chooseUser(row)">选择</el-button>
          </template>

        </el-table-column>
        <el-table-column label="用户名" prop="userName"></el-table-column>
        <el-table-column label="上班时间" prop="checkInTime">
          <template slot-scope="{row}">
            <span v-if="row.checkInTime">{{ row.checkInTime | getTime }}</span>
          </template>
        </el-table-column>
        <el-table-column label="工作状态" prop="checkInTime">
          <template slot-scope="{row}">
            <el-tag v-if="row.workInState == 1" type="success">可接单</el-tag>
            <el-tag v-else-if="row.workInState == 2" type="danger">忙碌</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="P数" prop="workInCount">
        </el-table-column>
      </el-table>
      <!--      <pagination v-show="userListData.total>0" :total="userListData.total" :page.sync="userListData.page" :limit.sync="userListData.pageSize" @pagination="getCheckInUser"/>-->
    </el-dialog>
    <el-dialog title="退回" :close-on-click-modal="false" :visible.sync="backDialog" width="500px">
      <el-form label-width="80px" label-position="right">
        <el-form-item label="退回到">
          <el-radio v-model="backInfo.backKind" :label="0">组长</el-radio>
          <el-radio v-model="backInfo.backKind" :label="1">业务员</el-radio>
        </el-form-item>
        <el-form-item label="退回备注">
          <el-input type="textarea" v-model="backInfo.backMemo"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="backDialog = false">取 消</el-button>
        <el-button type="primary" @click="checkBack">确 定</el-button>
      </div>
    </el-dialog>
    <el-drawer
    title="订单脚印"
    :reverse="true"
    :visible.sync="drawer"
    :with-header="false">
    <el-timeline style="width: 90%;margin-top: 20px">
      <el-timeline-item
v-for="step in stepList"
                        :timestamp="timeString ? (step.workTime).substring(0,19):step.workMan+'  '+(step.workTime).substring(0,19)"
                        placement="top">
        <el-card class="stepList">
          <h4 style="margin: 5px 0">{{ step.workMemo }}</h4>
          <p>{{ step.workExplain }}</p>
        </el-card>
      </el-timeline-item>

    </el-timeline>
  </el-drawer>
    <el-dialog title="订单详情" :close-on-click-modal="false" class="orderDetailDialog" :visible.sync="detailVisible" top="10px" width="1200px">
      <order-detail ref="orderDetail"></order-detail>
    </el-dialog>

    <el-dialog size="mini" title="PDF文件列表" :append-to-body="true" :visible.sync="dialogPdfVisible" width="800px">
      <el-table :data="gridDataPdf">
        <el-table-column
          label="#"
          align="center"
          type="index"
          :index="indexMethod">
        </el-table-column>
        <el-table-column
          label="PDF文件名称"
          width="450px"
        >
          <template slot-scope="{row}">
            <a
target="_blank"
:href="row.url"
style="color: #409EFF;cursor: pointer"
                class="ellipsis"> {{ row.fileName }}</a>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="{row}">
            <el-button size="mini" type="danger" @click="deletePdf(row)">删除</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-dialog>

    <cancledialog @tableRefresh="tableRefresh" ref="confirmDialog" :noDoubleClick="true"></cancledialog>
    <pcount-edit @getList="getList" ref="pcountEdit"></pcount-edit>
  </div>
</template>

<script>
import {
  busyCheck,
  clockIn,
  clockOut,
  getSelfPrintOrderList,
  getWorkState,
  relaxedCheck,
  backOrder,
  deleteOrderPDFFile,
  orderCalcSpreadSize,
} from '@/api/specialEdition/fileHandle'
import Cancledialog from '@/components/Dialog/Cancledialog'
import { getDetailPrintOrder } from '@/api/order/orderDetail'
import { getConfigInfo } from '@/api/system/config'
import { getOrderStepList } from '@/api/order/orderList'
import OrderDetail from '@/components/orderDetail/orderDetail'
import pcountEdit from './components/pcountEdit'
import { getOrderPDFFiles } from '@/api/printbill/printbill'
import new_badge from '@/assets/new_badge.gif'
import {getProductPagePriceList} from "@/api/productFile/pagePrice";
export default {
  name: 'FileHandle',
  components: { Cancledialog, OrderDetail,pcountEdit },
  data() {
    return {
      rowId:"",
      dialogFormVisible:false,
      calcSpreadSize:"",
      rowData: {},
      new_badge: new_badge,
      detailVisible: false,
      sizeType: 'mini',
      userInfo: {
        workInState: '',
        workInTime: '',
        workInCount: ''
      },
      form: {
        imgSavePath: ''
      },
      search: {
        orderCode: '',
        dispatchState: 1,
        dispatchBeginTime: '',
        dispatchEndTime: '',
        processBeginTime: '',
        processEndTime: ''
      },
      searchTime: [],

      tableData: [],
      listLoading: false,
      listData: {
        total: 0,
        page: 1,
        pageSize: 20
      },

      stateOptions: [
        {
          label: '未完成',
          value: 1
        },
        {
          label: '已完成',
          value: 100
        }
      ],
      chooseInfo: {
        idOrder: '',
        pCount: ''
      },
      distributeDialog: false,
      checkInUserList: [],
      userListLoading: false,
      userListData: {
        total: 0,
        page: 1,
        pageSize: 10
      },
      orderDetail: null,
      oldActivedId: 0,
      backDialog: false,
      backInfo: {
        idItem: '',
        backKind: 0,
        backMemo: ''
      },
      drawer: false,
      stepList: [],
      timeString: '',

      dialogPdfVisible: false,
      gridDataPdf: []

    }
  },
  mounted() {
    this.getState()
    this.getList()
    this.getConfig('FileUploadServerIp')
    this.getConfig('OrderShareRoot');
    this.getPcountTypeList();
  },
  methods: {
    getPcountTypeList(){
      var _that = this;
      var params = {}
      var page = {
        pageIndex: 1,
        pageSize: 10
      }
      var data = {
        'params': JSON.stringify(params),
        // 'page': JSON.stringify(page)
      }
      // console.log(data);
      getProductPagePriceList(data).then(response => {
        // console.log('基础纸张档案列表',response)
        const data = response.data
        // //  组合表单数据
        _that.pcountTypeList = data
        // console.log(_that.tableData)
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    handlePCount(row){
      var _that = this;


      // _that.rowId = row.id;
      // _that.formData.PCount = row.pCount;
      // _that.pcountType = row.itemKind
      // _that.titlePConut = "修改订单P数"+"("+row.printOrder.orderName+")";
      _that.$refs.pcountEdit.dialogFormVisible = true;
      _that.$refs.pcountEdit.rowId = row.id;
      _that.$refs.pcountEdit.PCount = row.pCount;
      _that.$refs.pcountEdit.pcountType = row.itemKind;
      _that.$refs.pcountEdit.titlePConut = "修改订单P数"+"("+row.printOrder.orderName+")";
      _that.$refs.pcountEdit.getPcountTypeList();

    },
    openDetail(row) {
      var _that = this
      _that.detailVisible = true;
      _that.$nextTick(() => {
        _that.$refs.orderDetail.idOrder = row.printOrder.id
        _that.$refs.orderDetail.getInfo()
      })
    },
    refreshPage() {
      this.getState()
      this.getList()
    },
    getState() {
      const _that = this
      getWorkState({}).then(res => {
        // console.log(res)
        var data = res.data
        _that.userInfo = {
          workInState: data.workInState,
          workInTime: data.workInTime,
          workInCount: data.workInCount
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    getList(type) {
      console.log(type);
      var _that = this;
      if( _that.dispatchState == 1){
        if (_that.searchTime == null || _that.searchTime < 0) {
          _that.search.dispatchBeginTime = ''
          _that.search.dispatchEndTime = ''
        } else {
          _that.search.dispatchBeginTime = _that.searchTime[0]
          _that.search.dispatchEndTime = _that.searchTime[1]
        }
      } else {
        if (_that.searchTime == null || _that.searchTime < 0) {
          _that.search.processBeginTime = ''
          _that.search.processEndTime = ''
        } else {
          _that.search.processBeginTime = _that.searchTime[0]
          _that.search.processEndTime = _that.searchTime[1]
        }
      }
      var params = _that.search
      if(type!=1){
        _that.orderDetail = null
      }

      var page = {
        pageIndex: _that.listData.page,
        pageSize: _that.listData.pageSize
      }
      var data = {
        'params': JSON.stringify(params),
        'page': JSON.stringify(page)
      }
      // console.log(data);
      getSelfPrintOrderList(data).then(response => {
        // console.log(response)
        const data = response.data
        // //  组合表单数据
        _that.tableData = data
        _that.listData.total = response.total
        _that.listLoading = false
      }).catch(err => {
        _that.$message.error(err)
        _that.listLoading = false
      })
    },

    // 搜索
    searchData() {
      this.listData.page = 1
      this.getList()
    },

    // 刷新
    tableRefresh() {
      this.getList()
    },
    // 获取脚印
    getOrderStep(row) {
      const _that = this
      _that.drawer = true
      var data = {
        idOrder: row.printOrder.id
      }
      // console.log(data);
      getOrderStepList(data).then(response => {
        // console.log(response)
        const data = response.data
        _that.stepList = data
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 点击行
    handleClickTableRow(row, event, column) {
      var _that = this;
      if (row.idOrder != _that.oldActivedId) {
        _that.oldActivedId = row.idOrder;
        _that.calcSpreadSize="";
        _that.orderDetail="";
        _that.getOrderDetail(row.idOrder,row)
      }
    },
    getCalcSpreadSize(row,partListRes){
      const _that = this;
      if(partListRes.partSize=="" || partListRes.partSize==undefined || partListRes.partSize==null){
        return
      }
      if(partListRes.holdSize){
        var holdSize = partListRes.holdSize
      }else {
        var holdSize = 0
      }
      var data = {
        'idProduct': row.printOrder.idProduct,
        'holdSize': holdSize,
        'partSize': partListRes.partSize,
      }
      orderCalcSpreadSize(data).then(res => {
        // console.log(res)
        _that.calcSpreadSize = res.data;
        for (let i = 0; i < _that.orderDetail.partList.length; i++) {
          _that.$set(_that.orderDetail.partList[i], 'calcSpreadSize', res.data);
        }


      }).catch(err => {
        _that.$message.error(err)
      })
    },
    getOrderDetail(id,row) {
      const _that = this
      var data = {
        'idOrder': id
      }
      getDetailPrintOrder(data).then(res => {
        // console.log(res)
        _that.orderDetail = res.data;
        for (let i = 0; i < res.data.partList.length; i++) {
          _that.getCalcSpreadSize(row,res.data.partList[i])
        }

      }).catch(err => {
        _that.$message.error(err)
      })
    },

    // 下载原件
    handleCommand(command) {
      var _that = this
      var userAgent = navigator.userAgent
      if (userAgent.indexOf('DnyERPBrowser') > 0){
        if (command == 2) {
          dyERP.sendDownloadFile(_that.rowData.idOrder.toString(), _that.rowData.printOrder.orderCode, _that.rowData.printOrder.originFileLink, '0')
        }else {
          dyERP.sendDownloadFile(_that.rowData.idOrder.toString(), _that.rowData.printOrder.orderCode, _that.rowData.printOrder.proofFileLink, '0')
        }
      }else {
        // alert('请使用开发商提供的ERP客户端')
        _that.$message({
          message: '请使用开发商提供的ERP客户端',
          type: 'warning'
        })
      }
    },
    handleCommandRow(row){
      this.rowData = row;
    },
    // 下载样稿
    downloadFile(row) {
      var _that = this
      var userAgent = navigator.userAgent
      // console.log(_that.item);
      if (userAgent.indexOf('DnyERPBrowser') > 0) {
        dyERP.sendDownloadFile(row.idOrder.toString(), row.printOrder.orderCode, row.printOrder.originFileLink, '0')
      } else {
        // alert('请使用开发商提供的ERP客户端')
        _that.$message({
          message: '请使用开发商提供的ERP客户端',
          type: 'warning'
        })
      }
    },
    // 下载样稿
    downloadproofFile(row) {
      var _that = this
      var userAgent = navigator.userAgent
      // console.log(_that.item);
      if (userAgent.indexOf('DnyERPBrowser') > 0) {
        dyERP.sendDownloadFile(row.idOrder.toString(), row.printOrder.orderCode, row.printOrder.proofFileLink, '0')
      } else {
        // alert('请使用开发商提供的ERP客户端')
        _that.$message({
          message: '请使用开发商提供的ERP客户端',
          type: 'warning'
        })
      }
    },
    // 上班
    goToWork(row) {
      const _that = this

      var data = {}
      clockIn(data).then(res => {
        // console.log(res)
        if (res.httpCode == 200) {
          _that.distributeDialog = false
          _that.$message({
            message: '上班成功',
            type: 'success'
          })
          _that.getState()
          _that.tableRefresh()
        } else {
          _that.$message.error(res.msg)
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 下班
    goOffWork() {
      const _that = this
      var data = {}
      clockOut(data).then(res => {
        // console.log(res)

        if (res.httpCode == 200) {
          _that.distributeDialog = false
          _that.$message({
            message: '下班成功',
            type: 'success'
          })
          _that.getState()
          _that.tableRefresh()
        } else {
          _that.$message.error(res.msg)
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 暂离
    showBusy(row) {
      const _that = this

      var data = {}
      busyCheck(data).then(res => {
        // console.log(res)
        if (res.httpCode == 200) {
          _that.distributeDialog = false
          _that.$message({
            message: '暂离成功',
            type: 'success'
          })
          _that.getState()
          _that.tableRefresh()
        } else {
          _that.$message.error(res.msg)
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 在线
    showLeisure() {
      const _that = this
      var data = {}
      relaxedCheck(data).then(res => {
        // console.log(res)
        if (res.httpCode == 200) {
          _that.distributeDialog = false
          _that.$message({
            message: '在线成功',
            type: 'success'
          })
          _that.getState()
          _that.tableRefresh()
        } else {
          _that.$message.error(res.msg)
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 退回
    backBtn(row) {
      const _that = this
      // console.log(row);
      _that.backDialog = true
      _that.backInfo.backMemo = '';
      _that.backInfo.backKind = 0;
      _that.backInfo.idItem = row.id
    },

    checkBack() {
      var _that = this
      backOrder(_that.backInfo).then(response => {
        // console.log(response)
        if (response.httpCode == 200) {
          _that.backDialog = false
          _that.$message({
            message: '退回成功',
            type: 'success'
          })
          _that.tableRefresh()
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },

    // 获取配置信息
    getConfig(key) {
      const _that = this
      const data = {
        configKey: key
      }
      // console.log(data);
      getConfigInfo(data).then(res => {
        // console.log(res)
        if (key == 'FileUploadServerIp') {
          _that.configValue1 = res.data.configValue1
        } else if (key == 'OrderShareRoot') {
          _that.configValue2 = res.data.configValue1
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 完成
    getUploadType($event, row) {
      const _that = this
      var userAgent = navigator.userAgent
      // console.log(row.idOrder.toString());
      // console.log(row.printOrder.orderCode);
      // console.log(_that.configValue1);
      // console.log(_that.configValue2);
      if ($event == 2) {
        if (userAgent.indexOf('DnyERPBrowser') > 0) {
          dyERP.sendOrderFile(row.idOrder.toString(), row.printOrder.orderCode, _that.configValue1, _that.configValue2, '0', '1', row.id.toString())
        } else {
          // alert('请使用开发商提供的ERP客户端')
          this.$message({
            message: '请使用开发商提供的ERP客户端',
            type: 'warning'
          })
        }
      } else if ($event == 3) {
        if (userAgent.indexOf('DnyERPBrowser') > 0) {
          // alert('关联文件')
          dyERP.sendOrderFile(row.idOrder.toString(), row.printOrder.orderCode, _that.configValue1, _that.configValue2, '1', '1', row.id.toString())
        } else {
          // alert('请使用开发商提供的ERP客户端')
          this.$message({
            message: '请使用开发商提供的ERP客户端',
            type: 'warning'
          })
        }
      }else if ($event == 4){
        var data = {
          idItem: row.id
        }
        var url = '/idp/forceCompleteOrder'
        _that.$refs.confirmDialog.updataClick(data, url)
      }
    },

    // 查看校稿文件
    handleDeleteFile(id) {
      // 查看pdf
      const _that = this
      _that.currentIdOrder = id
      var datas = {
        'idOrder': id
      }
      getOrderPDFFiles(datas).then(response => {
        // console.log(response.data);
        _that.dialogPdfVisible = true
        _that.gridDataPdf = response.data
      }).catch(err => {
        console.log(err)
      })
    },
    deletePdf(row) {
      const _that = this
      _that.$confirm(`确定删除pdf文件？`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        var data = {
          idOrder: _that.currentIdOrder,
          fileName: row.fileName
        }
        // console.log(data)
        // return
        deleteOrderPDFFile(data).then(res => {
          // console.log(res)
          if (res.httpCode == 200) {
            _that.$message({
              message: '删除成功',
              type: 'success'
            })
            _that.handleDeleteFile(_that.currentIdOrder)
          }
        })
      }).catch(() => {
        return
      })
    },
    // 提交校稿
    commitPDF(row) {
      const _that = this
      var userAgent = navigator.userAgent
      if (userAgent.indexOf('DnyERPBrowser') > 0) {
        // alert('关联文件')
        dyERP.sendOrderProofFile(row.idOrder.toString(), row.printOrder.orderCode, _that.configValue1, _that.configValue2, '1', '1', row.id.toString())
      } else {
        // alert('请使用开发商提供的ERP客户端')
        this.$message({
          message: '请使用开发商提供的ERP客户端',
          type: 'warning'
        })
      }
    },
    // 序号
    indexMethod(index) {
      return index + 1
    }
  }
}
</script>

<style lang="scss" scoped>
.filter-container {
  ::v-deep .el-card {
    margin-bottom: 10px;
  }
}
</style>
