<template>
  <div class="app-container">
    <div class="filter-container">
      <el-input :size="sizeType" v-model="search.keyWord" placeholder="关键字" style="width: 200px;" class="filter-item"/>
      <el-select :size="sizeType" v-model="search.comPageState">
        <el-option label="待组版" :value="1"></el-option>
        <el-option label="已组版" :value="2"></el-option>
        <el-option label="全部" :value="0"></el-option>
      </el-select>
      <el-button :size="sizeType" class="filter-item" type="primary" icon="el-icon-search" @click="searchData">
        搜索
      </el-button>
      <!--      <el-button :size="sizeType" type="green">批量下单</el-button>-->
      <div class="top-right-btn">
        <el-tooltip class="item" effect="dark" content="刷新" placement="top">
          <el-button size="mini" circle icon="el-icon-refresh" @click="getList"/>
        </el-tooltip>
      </div>
    </div>
    <el-table
      :size="sizeType"
      :data="tableData"
      stripe
      v-loading="listLoading"
      row-key="id"
      border
      style="margin-top: 10px"
      @selection-change="handleSelectionChange"
      default-expand-all>
      <!--      <el-table-column-->
      <!--        type="selection"-->
      <!--        fixed="left"-->
      <!--        width="55">-->
      <!--      </el-table-column>-->
      <el-table-column fixed label="操作" align="center" width="250px" class-name="small-padding fixed-width">
        <template slot-scope="{row}">
          <el-dropdown
            v-if="permissionFlag1 || permissionFlag2 || permissionFlag3 || permissionFlag4 || permissionFlag5"
            size="mini" @command="orderUpdate($event,row)" trigger="click">
            <el-button size="mini" type="primary" class="iconfont"> &#xe615;</el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="1" v-if="permissionFlag1">修改部件工艺</el-dropdown-item>
              <el-dropdown-item command="2" v-if="permissionFlag2">修改交货日期</el-dropdown-item>
              <el-dropdown-item command="3" v-if="permissionFlag3">强制发货完成</el-dropdown-item>
              <el-dropdown-item command="4" v-if="permissionFlag4">修改订单金额</el-dropdown-item>
              <el-dropdown-item command="5" v-if="permissionFlag5">修改订单信息</el-dropdown-item>
              <el-dropdown-item command="6" v-if="permissionFlag6">修改部件参数</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
          <!--          <el-button-->
          <!--            v-if="permissionFlag1"-->
          <!--            title="修改部件工艺"-->
          <!--            @click="openEditPartProcess(row)"-->
          <!--            class="iconfont"-->
          <!--            type="primary"-->
          <!--            size="mini">-->
          <!--            &#xe615;-->
          <!--          </el-button>-->
          <!--          <el-button-->
          <!--            v-if="permissionFlag2"-->
          <!--            title="修改交货日期"-->
          <!--            class="iconfont"-->
          <!--            @click="openEditDeliverDate(row)"-->
          <!--            type="success"-->
          <!--            size="mini">-->
          <!--            &#xe600;-->
          <!--          </el-button>-->
          <!--          <el-button v-if="permissionFlag3" size="mini" type="danger" class="iconfont" title="强制发货完成" @click="enforceFinish(row)">&#xe60c;</el-button>-->
          <el-dropdown v-if="row.originFileLink == null || row.originFileLink == '' " size="mini"
                       @command="getUploadType($event,row)" trigger="click">
            <el-button size="mini" type="warning" icon="el-icon-upload"></el-button>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="1">上传文件（云）</el-dropdown-item>
              <!--              <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" type="info" class="iconfont" title="退回" @click="openBackOrder(row)">&#xe60a;
          </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>
      <template v-for="column in defaultItem">
        <el-table-column
          v-if="column.id == 3"
          :prop="column.field"
          :label="column.name"
          :width="column.width"
          sortable="custom"
          fixed
          show-overflow-tooltip>
          <template slot-scope="{row}">
            <a href="javascript:;" style="color: #20a0ff" @click="getOrderStep(row)">{{ row[column.field] }}
              <span v-if="row.businessKind==3" style="display: inline-block;color: red">(补{{ row.rePrintIndex}})</span>
              <el-image v-if="row.firstOrderFlag == 1" :src="new_badge"></el-image></a>
          </template>
        </el-table-column>
        <el-table-column
          v-else-if="column.id == 23"
          :prop="column.field"
          :label="column.name"
          :width="column.width"
          fixed
          show-overflow-tooltip>
          <template slot-scope="{row}">
            <a v-if="row.idProduct<=0" href="javascript:;" style="color: #20a0ff"
               @click="openMaterialDetail(row)">{{ row[column.field] }}</a>
            <a v-else href="javascript:;" style="color: #20a0ff" @click="openDetail(row)">{{ row[column.field] }}</a>
          </template>
        </el-table-column>
        <el-table-column
          v-else-if="column.id == 2"
          :prop="column.field"
          :label="column.name"
          :width="column.width"
          show-overflow-tooltip>
          <template slot-scope="{row}">
            <el-tag size="mini" v-if="row[column.field] == '待编辑'" type="info">{{ row[column.field] }}</el-tag>
            <el-tag size="mini" v-else-if="row[column.field] == '待审核'" type="success">{{ row[column.field] }}</el-tag>
            <el-tag size="mini" v-else-if="row[column.field] == '待组版'">{{ row[column.field] }}</el-tag>
            <el-tag size="mini" v-else-if="row[column.field] == '已组版'" type="danger">{{ row[column.field] }}</el-tag>
            <el-tag size="mini" v-else-if="row[column.field] == '生产中'" type="danger">{{ row[column.field] }}</el-tag>
            <el-tag size="mini" v-else-if="row[column.field] == '待入库'" type="green">{{ row[column.field] }}</el-tag>
            <el-tag size="mini" v-else-if="row[column.field] == '待发货'">{{ row[column.field] }}</el-tag>
            <el-tag size="mini" v-else-if="row[column.field] == '已发货'" type="info">{{ row[column.field] }}</el-tag>
            <el-tag size="mini" v-else-if="row[column.field] == '文件待处理'" type="warning">{{ row[column.field] }}</el-tag>
            <el-button size="mini" class="button-new-tag" v-else>{{ row[column.field] }}</el-button>
          </template>
        </el-table-column>
        <el-table-column
          v-else-if="column.id == 19"
          :prop="column.field"
          :label="column.name"
          :width="column.width"
          show-overflow-tooltip>
          <template slot-scope="{row}">
            <el-tag v-if="row[column.field] >0" size="mini" type="success">已处理</el-tag>
            <el-tag v-else-if="row[column.field] <=0" size="mini" type="warning">未处理</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          v-else-if="column.id == 21"
          :prop="column.field"
          :label="column.name"
          :width="column.width">
          <template slot-scope="{row}">
            <el-tag v-if="row[column.field] == 0">初始</el-tag>
            <el-tag v-else-if="row[column.field] == 1" type="success">待审核</el-tag>
            <el-tag v-else-if="row[column.field] == 2" type="danger">待入账</el-tag>
            <el-tag v-else-if="row[column.field] == 3" type="warning">已入账</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          v-else-if="column.id == 6"
          header-align="center"
          :prop="column.field"
          :label="column.name"
          show-overflow-tooltip
          :width="column.width">
          <template slot-scope="{row}">
            <template v-if="row.orderMessage">
              <el-button size="mini" circle icon="el-icon-plus" @click="openMessage(row)"></el-button>
              <a href="javascript:;" style="color: #20a0ff" @click="openMessage(row)">{{ row.orderMessage }}</a>
            </template>
            <template v-else>
              <el-button size="mini" circle icon="el-icon-plus" @click="openMessage(row)"></el-button>
            </template>
          </template>
        </el-table-column>
        <el-table-column
          v-else-if="column.id == 25"
          align="center"
          header-align="center"
          :prop="column.field"
          :label="column.name"
          :width="column.width"
        >
          <template slot-scope="{row}">
            <el-tag size="mini" type="primary" v-if="row[column.field] == 0">正常业务</el-tag>
            <el-tag size="mini" type="warning" v-else-if="row[column.field]== 1">外协订单</el-tag>
            <el-tag size="mini" type="success" v-else-if="row[column.field] == 2">物料订单</el-tag>
            <el-tag size="mini" type="danger" v-else-if="row[column.field] == 3">补印订单</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          v-else-if="column.id == 22 || column.id == 21"
          header-align="center"
          :prop="column.field"
          :label="column.name"
          :width="column.width"
        >
          <template slot-scope="{row}">
            <span v-if="row[column.field]">{{ row[column.field] | getTime }}</span>
          </template>
        </el-table-column>
        <el-table-column
          v-else-if="column.id == 11"
          header-align="center"
          :prop="column.field"
          :label="column.name"
          :width="column.width"
          show-overflow-tooltip
        >
          <template slot-scope="{row}">
            <el-link :href="row.originFileLink" target="_blank" style="color: #20a0ff">{{ row[column.field] }}</el-link>
          </template>
        </el-table-column>
        <el-table-column
          v-else
          :prop="column.field"
          :label="column.name"
          :width="column.width"
          show-overflow-tooltip>
        </el-table-column>
      </template>
    </el-table>
    <pagination v-show="listData.total>0" :total="listData.total" :page.sync="listData.page"
                :limit.sync="listData.pageSize" @pagination="getList"/>

    <el-drawer
      title="订单消息"
      :reverse="true"
      :visible.sync="memoDrawer"
      size="600px">
      <order-message ref="orderMessage"></order-message>
    </el-drawer>
    <el-dialog title="退回订单" :visible.sync="voidVisible" width="500px">
      <el-form label-width="80px" label-position="right">
        <el-form-item label="退回备注">
          <el-input type="textarea" v-model="sMemo"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="voidVisible = false">取 消</el-button>
        <el-button type="primary" @click="backOrderBtn">确 定</el-button>
      </div>
    </el-dialog>
    <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>
    <cancledialog @tableRefresh="tableRefresh" ref="confirmDialog" :noDoubleClick="true"></cancledialog>
    <order-step ref="orderStep"></order-step>
    <el-dialog title="修改部件工艺" :close-on-click-modal="false" :visible.sync="editPartDialog" width="1200px">
      <el-card v-for="(part,partIndex) in partInfoList">
        <span>部件名称:{{ part.partName }}</span>
        <span>部件尺寸:{{ part.partSize }}</span>
        <br>
        <el-button type="green" size="small" @click="addProcess(partIndex)">增加工序</el-button>
        <el-table
          ref="partProcess"
          border
          size="mini"
          :data="part.processList"
          highlight-current-row
          class="tb-edit">
          <el-table-column
            label="工序"
            width="120"
            prop="processName">
            <template scope="scope">
              <span>{{ scope.row.processName }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="processMemo"
            label="工序说明"
            show-overflow-tooltip>
            <template scope="scope">
              <el-input
                size="mini"
                v-model="scope.row.processMemo"></el-input>
              <span>{{ scope.row.processMemo }}</span>
            </template>
          </el-table-column>
          <el-table-column
            prop="idMaterial"
            label="工序物料">
            <template scope="scope">
              <el-button size="mini" @click="processChoose(partIndex,scope.$index,scope.row)">
                {{ scope.row.materialName ? scope.row.materialName : '请选择辅料' }}
              </el-button>
              <el-button size="mini" v-if="scope.row.idMaterial" type="danger"
                         @click="scope.row.materialName='';scope.row.idMaterial=''">取消选择
              </el-button>
            </template>
          </el-table-column>
          <el-table-column
            prop="obvRevId"
            label="工序位置"
            show-overflow-tooltip>
            <template scope="scope">
              <el-select size="mini" v-model="scope.row.obvRevId" placeholder="请选择">
                <el-option
                  v-for="item in obvRevIdOptions"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>

              <template v-if="scope.row.obvRevId == 1">
                <span>正面</span>
              </template>
              <template v-else-if="scope.row.obvRevId == 2">
                <span>反面</span>
              </template>
            </template>
          </el-table-column>
          <!--        <el-table-column-->
          <!--          prop="processMoney"-->
          <!--          label="工序价格"-->
          <!--          show-overflow-tooltip>-->
          <!--          <template scope="scope">-->
          <!--            <el-input-->
          <!--              size="small"-->
          <!--              v-model="scope.row.processMoney"></el-input>-->
          <!--            <span>{{ scope.row.processMoney }}</span>-->
          <!--          </template>-->
          <!--        </el-table-column>-->
          <!--        <el-table-column-->
          <!--          prop="processPrice"-->
          <!--          label="工序单价"-->
          <!--          show-overflow-tooltip>-->
          <!--          <template scope="scope">-->
          <!--            <el-input-->
          <!--              size="small"-->
          <!--              v-model="scope.row.processPrice"></el-input>-->
          <!--            <span>{{ scope.row.processPrice }}</span>-->
          <!--          </template>-->
          <!--        </el-table-column>-->
          <!--        <el-table-column-->
          <!--          prop="processRule"-->
          <!--          label="工序规格"-->
          <!--          show-overflow-tooltip>-->
          <!--          <template scope="scope">-->
          <!--            <el-input-->
          <!--              size="small"-->
          <!--              v-model="scope.row.processRule"></el-input>-->
          <!--            <span>{{ scope.row.processRule }}</span>-->
          <!--          </template>-->
          <!--        </el-table-column>-->
          <el-table-column
            prop="processQty"
            label="工序数量"
            show-overflow-tooltip>
            <template scope="scope">
              <el-input
                size="small"
                oninput = "value=Number(value.replace(/[^\d.]/g,''))"
                v-model="scope.row.processQty"></el-input>
              <span>{{ scope.row.processQty }}</span>
            </template>
          </el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button size="mini" type="danger" @click="deleteProcess(partIndex,scope.$index)">删除</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-card>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editPartDialog = false">取 消</el-button>
        <el-button type="primary" :disabled="clickLoading" @click="editPart()">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog width="900px" :close-on-click-modal="false" title="选择工艺辅料" :visible.sync="processChooseVisible"
               top='50px' class="accInfo">
      <!--      <accessoriesInfo :is-choose="true" @chooseAccessories='chooseAccessories'></accessoriesInfo>-->
      <select-accessories :is-choose="true" @chooseAccessories='chooseAccessories'></select-accessories>
    </el-dialog>
    <!--增加工序弹窗开始-->
    <el-dialog title="增加工序" width="750px" :visible.sync="processVisible">
      <div style="margin-bottom: 10px">
        <el-input v-model="processSearch.keyWord" placeholder="关键字" style="width: 200px;"
                  @keyup.enter.native="processSearchData"/>

        <el-button class="filter-item" type="primary" icon="el-icon-search" @click="processSearchData">
          搜索
        </el-button>
      </div>
      <el-table
        :data="processList"
        v-loading="listLoading"
        max-height="600px"
        row-key="id"
        border
        default-expand-all>
        <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width">
          <template slot-scope="{row}">
            <el-button @click="addThis(row)" type="primary" size="mini">
              选择
            </el-button>
          </template>
        </el-table-column>
        <el-table-column
          prop="processName"
          label="工序名称">
        </el-table-column>
      </el-table>
      <pagination
        v-show="processListData.total>0"
        :total="processListData.total"
        :page.sync="processListData.page"
        :limit.sync="processListData.pageSize"
        style="margin-top: 10px"
        @pagination="getProcessList"/>
    </el-dialog>
    <!--增加工艺弹窗结束-->

    <el-dialog title="修改交货日期" :visible.sync="editDeliverDateDialog" width="400px">
      <el-form>
        <el-form-item label="交货日期">
          <el-date-picker
            v-model="deliverDate"
            type="datetime"
            value-format='yyyy-MM-dd HH:mm:ss'
            placeholder="选择日期时间"
            align="right"
            :picker-options="pickerOptions"
            style="margin-top: 5px">
          </el-date-picker>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editDeliverDateDialog = false">取 消</el-button>
        <el-button type="primary" :disabled="clickLoading" @click="editDeliverDate()">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="修改订单金额" :visible.sync="editOrderMoneyDialog" width="400px">
      <el-form>
        <el-form-item label="订单金额">
          <el-input
            v-model="orderMoney"
            type="number">
          </el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editOrderMoneyDialog = false">取 消</el-button>
        <el-button type="primary" :disabled="clickLoading" @click="editOrderMoney()">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog title="修改订单基础信息" :visible.sync="editOrderBaseInfoDialog" width="800px">
      <el-row :gutter="20">
        <el-form label-width="100px" size="mini">
          <el-col :span="12">
            <el-form-item label="产品类型">
              <el-input v-model="orderBaseInfo.productName" disabled></el-input><!--新建时下拉选择，其他时候不能编辑-->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="客户名称">
              <el-input v-model="orderBaseInfo.clientName" disabled class="input-with-select">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="印品名称">
              <el-input v-model="orderBaseInfo.orderName"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="款数">
              <el-input type="number" @keyup.native="proving($event)" v-model="orderBaseInfo.kindCount"></el-input>
            </el-form-item>

          </el-col>
          <el-col :span="12">
            <el-form-item label="印刷要求">
              <el-select
                multiple
                style="width: 100%"
                v-model="printRequireOption">
                <el-option
                  v-for="item in printRequireOptions"
                  :key="item.id"
                  :label="item.dictLabel"
                  :value="item.dictValue">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="成品裁切" prop="cutKind">
              <el-select
                style="width: 100%;"
                collapse-tags
                v-model="orderBaseInfo.cutKind">
                <el-option
                  v-for="item in orderPrintOptions"
                  :key="item.id"
                  :label="item.dictLabel"
                  :value="item.dictValue">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="生产备注">
              <el-input type="textarea" :rows='6' v-model="orderBaseInfo.orderMemo"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="包装要求" prop="boxRequire">
              <el-select
                style="width: 100%;"
                collapse-tags
                v-model="orderBaseInfo.boxRequire">
                <el-option
                  v-for="item in packingMethodOptions"
                  :key="item.id"
                  :label="item.dictLabel"
                  :value="item.dictValue">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="打包方式">
              <el-select
                style="width: 100%;"
                collapse-tags
                v-model="orderBaseInfo.packKind">
                <el-option
                  label="均匀打包"
                  :value="0">
                </el-option>
                <el-option
                  label="按要求打包"
                  :value="1">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12" v-if="orderBaseInfo.packKind == 1">
            <el-form-item label="打包要求">
              <el-button size="mini" type="green" @click="addPackRequire">增加</el-button>
              <el-table border :data="packrequireList" size="mini">
                <el-table-column label="包数" prop="packNum">
                  <template slot-scope="{row}">
                    <el-input
                      type="number"
                      @keyup.native="proving($event)"
                      v-model="row.packNum"
                      size="mini"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="每包数量" prop="countNum">
                  <template slot-scope="{row}">
                    <el-input
                      @keyup.native="proving($event)"
                      type="number"
                      v-model="row.countNum"
                      size="mini"></el-input>
                  </template>
                </el-table-column>
                <el-table-column label="总数">
                  <template slot-scope="{row}">
                    <span>{{ parseInt(row.packNum) * parseInt(row.countNum) }}</span>
                  </template>
                </el-table-column>
              </el-table>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="订单金额">
              <el-input disabled v-model="orderBaseInfo.orderMoneyTotal"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="付款方式">
              <el-table
                :data="payType"
                ref="payTypeTable"
                class="tb-edit"
                size="mini"
                style="width: 450px;margin-top: 5px"
                :show-summary="true"
                :summary-method="getSummaries"
                border
                highlight-current-row>
                <el-table-column
                  label="付款方式"
                  width="120"
                  prop="name">
                </el-table-column>
                <el-table-column
                  prop="value"
                  label="金额"
                  width="120">
                  <template scope="scope">
                    <el-input
                      size="small"
                      type="number"
                      v-model="scope.row.value"></el-input>
                    <span>{{ scope.row.value }}</span>
                  </template>
                </el-table-column>
                <el-table-column
                  prop="guarantee"
                  label="担保人">
                  <template scope="scope">
                    <el-input
                      size="small"
                      v-model="scope.row.guarantee"></el-input>
                    <span>{{ scope.row.guarantee }}</span>
                  </template>
                </el-table-column>
              </el-table>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editOrderBaseInfoDialog = false">取 消</el-button>
        <el-button type="primary" :disabled="clickLoading" @click="editOrderBaseInfo()">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog title="修改部件参数" :close-on-click-modal="false" :visible.sync="editPartParameterDialog" width="1200px">
      <el-form :inline="true" size="mini">
        <el-form-item label="修改描述">
          <el-input type="textarea" v-model="inputMemo" style="width: 500px;"></el-input>
        </el-form-item>
      </el-form>
      <el-card v-for="(part,index1) in partParameterList">
        <el-form :inline="true" size="mini">
          <el-form-item label="部件名称">
            <el-input v-model="part.partName"></el-input>
          </el-form-item>
          <el-form-item label="出血">
            <el-input v-model="part.bloodValue" type="number" style="width: 80%"></el-input>
            (mm)
          </el-form-item>
        </el-form>
        <el-table
          :header-cell-style="{background:'#eef1f6',color:'#606266'}"
          :data="[1]"
          size="small"
          style="width: 100%"
          border>
          <template v-for="(parameter,index2) in part.paramValueList">
            <template>
              <el-table-column
                :key="index2"
                :label="parameter.parameterName">
                <template scope="scope">
                  <template v-if="parameter.selectKind == 0">
                    <template v-if="parameter.productParameter.fieldType == 2">
                      <el-input size="small" type="number" v-model="parameter.paramValue"></el-input>
                    </template>
                    <template v-else-if="parameter.productParameter.fieldType == 3">
                      <el-input size="small" type="number" v-model="parameter.paramValue"></el-input>
                    </template>
                    <template v-else-if="parameter.productParameter.fieldType == 6">
                      <el-input size="small" v-model="parameter.paramValue"
                                @blur="verifies1(parameter.paramValue)"></el-input>
                    </template>
                    <template v-else-if="parameter.productParameter.fieldType == 7">
                      <el-input size="small" v-model="parameter.paramValue"
                                @blur="verifies2(parameter.paramValue)"></el-input>
                    </template>
                    <template v-else>
                      <el-input size="small" v-model="parameter.paramValue"></el-input>
                    </template>
                  </template>
                  <template v-if="parameter.selectKind == 2">
                    <el-select
                      v-model="parameter.paramValue"
                      filterable
                      :placeholder="parameter.placeHolder"
                      @input.native="selectBlur1($event,index1,index2)">
                      <el-option
                        v-for="item in parameter.itemList"
                        :key="item.id"
                        :label="item.itemName"
                        :value="item.itemValue"></el-option>
                    </el-select>
                  </template>
                  <template v-if="parameter.selectKind == 3">
                    <el-select v-model="parameter.paramValue" placeholder="请选择"
                               @change="parameterSelect($event,index1,index2)">
                      <el-option
                        v-for="item in parameter.itemList"
                        :key="item.id"
                        :label="item.itemName"
                        :value="item.itemValue"></el-option>
                    </el-select>
                  </template>
                  <template v-if="parameter.selectKind == 4">
                    <template v-if="parameter.productParameter.fieldType == 4">
                      <!--弹窗选择纸张档案-->
                      <el-button @click="parameterChoose(index1,index2,1,'选择纸张档案')">
                        {{ parameter.paramDisplay ? parameter.paramDisplay : '选择纸张档案' }}
                      </el-button>
                    </template>
                    <template v-else-if="parameter.productParameter.fieldType == 5">
                      <!--弹窗选择辅料档案-->
                      <el-button @click="parameterChoose(index1,index2,2,'选择辅料档案')">
                        {{ parameter.paramDisplay ? parameter.paramDisplay : '选择辅料档案' }}
                      </el-button>
                    </template>
                  </template>
                </template>
              </el-table-column>
            </template>
          </template>
        </el-table>
      </el-card>
      <div slot="footer" class="dialog-footer">
        <el-button @click="editPartParameterDialog = false">取 消</el-button>
        <el-button type="primary" :disabled="clickLoading" @click="editPartParameter()">确 定</el-button>
      </div>
    </el-dialog>
    <!--部件参数选择弹窗开始-->
    <el-dialog width="850px" :close-on-click-modal="false" :title="dialogTitle" :visible.sync="parameterChooseVisible">

      <paper-quote
        v-if="parameterChooseType == 1"
        :is-choose="true"
        @choosePaper='choosePaper'
        :partId="partId"
        :productId="partParameterList.idProduct"
        :parameterId='parameterId'
        :key="timer"></paper-quote>
      <accessoriesInfo
        v-if="parameterChooseType == 2"
        :is-choose="true"
        @chooseAccessories='chooseAccessoriesByParameter'></accessoriesInfo>
    </el-dialog>
    <!--部件参数选择弹窗结束-->
    <material-detail ref="materialDetail"></material-detail>

  </div>

</template>

<script>
import {backPrintOrder, getOrderList} from '@/api/order/tobeReviewed'
import {
  getOrderPartList,
  updateOrderBaseInfo,
  updateOrderDeliverDate,
  updateOrderPartInfo,
  updateOrderPartProcess,
  updateOrderTotalMoney
} from '@/api/order/tobeAssembled'
import orderMessage from '@/components/orderMessage/orderMessage'
import Cancledialog from '@/components/Dialog/Cancledialog.vue'
import OrderDetail from '@/components/orderDetail/orderDetail'
import OrderStep from '@/components/orderStep/orderStep'
import {getConfigInfo} from '@/api/system/config'
import AccessoriesInfo from '@/views/baseInfo/accessories/accessoriesInfo'
import {getDetailPrintOrder, getWorkProcessList} from '@/api/order/orderDetail'
import {ifPermission} from '@/api/order/orderList'
import {getDictTypeInfo} from '@/api/productFile/partWorkProcessInfo'
import PaperQuote from "@/views/baseInfo/paperQuote/paperQuote";
import SelectAccessories from "@/views/select/accessoriesInfo";
import new_badge from '@/assets/new_badge.gif'
import MaterialDetail from "@/components/materialDetail/materialDetail";

const defaultItems = [
  {
    name: '订单编号', id: 3, field: 'orderCode', width: '132px'
  },
  {
    name: '印品名称', id: 23, field: 'orderName', width: '130px'
  },
  {
    name: '施工单号', id: 24, field: 'printBillCode', width: '130px'
  },
  {
    name: '产品类型', id: 1, field: 'productName', width: '130px'
  },
  {
    name: '业务类型', id: 25, field: 'businessKind', width: '130px'
  },
  {
    name: '制单时间', id: 22, field: 'createTime', width: '160'
  },
  {
    name: '订单状态', id: 2, field: 'stateMemo', width: ''
  },
  {
    name: '文件处理', id: 19, field: 'idFileProcessMan', width: ''
  },
  {
    name: '订单消息', id: 6, field: 'orderMessage', width: '170'
  }, {
    name: '客户编码', id: 7, field: 'clientCode', width: '100'
  }, {
    name: '客户名称', id: 8, field: 'clientName', width: '120'
  },
  {
    name: '文件描述', id: 11, field: 'fileDescription', width: '190px'
  },
  {
    name: '订单审核人', id: 12, field: 'auditMan', width: '75'
  },
  {
    name: '审核时间', id: 4, field: 'auditDate', width: '160'
  },
  {
    name: '文件处理人', id: 5, field: 'fileProcessMan', width: '75'
  },
  {
    name: '文件处理时间', id: 21, field: 'fileProcessdate', width: '160'
  },
  {
    name: '制单人', id: 13, field: 'createMan', width: '75'
  },
  {
    name: '订单印量', id: 14, field: 'orderQty', width: '120'
  },
  {
    name: '定金', id: 16, field: 'orderMoneyPre', width: '100'
  }, {
    name: '总金额', id: 17, field: 'orderMoneyTotal', width: '120'
  }, {
    name: '已收金额', id: 18, field: 'payMoney', width: '120'
  },
  {
    name: '平台单号', id: 20, field: 'platformOrderID', width: '220px'
  }
]
const packrequire = {
  packNum: 0,
  countNum: 0
}
export default {
  name: 'TobeAssembled',
  components: {
    MaterialDetail,
    SelectAccessories,
    PaperQuote,
    AccessoriesInfo,
    OrderStep,
    OrderDetail,
    orderMessage, Cancledialog
  },
  data() {
    return {
      sizeType: 'mini',
      new_badge: new_badge,
      detailVisible: false,
      pluploadVisible: false,
      memoDrawer: false,
      clickLoading: false, // 双击等待
      defaultItem: Object.assign([], defaultItems), // 默认列
      orderStatus: '',
      search: {
        keyWord: '',
        orderState: '',
        comPageState: 1
      },
      tableData: [],
      listLoading: false,
      listData: {
        total: 0,
        page: 1,
        pageSize: 20
      },
      voidVisible: false,
      sMemo: '',
      orderId: '',
      versionCode: '',

      // 上传文件
      showUpload: true,
      files: [],
      upIdOrder: '',
      upOrderCode: '',
      confirmdialog: false,

      // 修改部件工艺
      editPartDialog: false,
      partInfoList: [],
      // 面数选项
      obvRevIdOptions: [{
        value: 1,
        label: '正面'
      }, {
        value: 2,
        label: '反面'
      }],
      processChooseVisible: false, // 工序辅料选择弹窗
      partIndex: '',
      processIndex: '',
      processVisible: false, // 增加工序弹窗
      processList: [],
      processSearch: {
        keyWord: '',
        specialFlag: 1,
        voidFlag: 0
      },
      processListData: {
        total: 0,
        page: 1,
        pageSize: 10
      },
      permissionFlag1: false,
      permissionFlag2: false,
      permissionFlag3: false,
      permissionFlag4: false,
      permissionFlag5: false,
      permissionFlag6: false,

      // 交货日期
      editDeliverDateDialog: false,
      deliverDate: '',

      // 订单金额
      editOrderMoneyDialog: false,
      orderMoney: '',

      // 订单基础信息
      editOrderBaseInfoDialog: false,
      orderBaseInfo: {},
      printRequireOptions: [],
      printRequireOption: [],
      orderPrintOptions: [],
      packingMethodOptions: [],
      packrequireList: [], // 打包要求列表

      // 付款方式
      payType: [
        {
          id: 0,
          name: '现金收款',
          value: '0',
          guarantee: ''
        },
        {
          id: 1,
          name: '物流代收',
          value: '0',
          guarantee: ''
        },
        {
          id: 2,
          name: '担保人',
          value: '0',
          guarantee: ''
        },
        {
          id: 3,
          name: '预存',
          value: '0',
          guarantee: ''
        },
        {
          id: 4,
          name: '预收款',
          value: '0',
          guarantee: ''
        }
      ],
      sums: '',

      // 订单不见参数
      editPartParameterDialog: false,
      partParameterList: [],
      inputMemo: '',
      parameterIndex1: 0,
      parameterIndex2: 0,
      parameterChooseVisible: false, // 参数选择弹窗
      parameterChooseType: 1,
      dialogTitle: '',
      timer: '',
      partId: '',
      parameterId: '',

      // 时间选项快捷方式
      pickerOptions: {
        shortcuts: [{
          text: '今天',
          onClick(picker) {
            picker.$emit('pick', new Date())
          }
        }, {
          text: '明天',
          onClick(picker) {
            const date = new Date()
            date.setTime(date.getTime() + 3600 * 1000 * 24)
            picker.$emit('pick', date)
          }
        }],
        disabledDate(time) {
          // 如果没有后面的-8.64e7就是不可以选择今天的
          return time.getTime() < Date.now() - 8.64e7
        }
      }
    }
  },
  watch: {
    memoDrawer(val) {
      // console.log(val)
      if (!val) {
        this.getList()
      }
    },
    // 印刷要求
    printRequireOption(value) {
      this.orderBaseInfo.printRequire = value.join(',')
    }

  },
  created() {
    // this.search.orderState = this.$route.path.split('/').slice(-1)[0]
    this.getList()
    this.getConfig('FileUploadServerIp')
    this.getConfig('OrderShareRoot')
    this.getConfig('OrderUpdateWebUrl')
    this.getDictInfo('PrintRequire')
    this.getDictInfo('OrderPrintDesc')
    this.getDictInfo('PackingMethod')
    this.checkPermission('order:orderPart:admin')
    this.checkPermission('order:deliverDate:admin')
    this.checkPermission('delivery:enforce:admin')
    this.checkPermission('order:orderMoney:admin')
    this.checkPermission('order:orderBaseInfo:admin')
    this.checkPermission('order:forceOrderPart:admin')
  },
  methods: {

    // 判断权限
    checkPermission(perString) {
      const _that = this
      var data = {
        permission: perString
      }
      ifPermission(data).then(res => {
        // console.log(res)
        if (res.data == 1) {
          if (perString == 'order:orderPart:admin') {
            _that.permissionFlag1 = true
          }
          if (perString == 'order:deliverDate:admin') {
            _that.permissionFlag2 = true
          }
          if (perString == 'delivery:enforce:admin') {
            _that.permissionFlag3 = true
          }
          if (perString == 'order:orderMoney:admin') {
            _that.permissionFlag4 = true
          }
          if (perString == 'order:orderBaseInfo:admin') {
            _that.permissionFlag5 = true
          }
          if (perString == 'order:forceOrderPart:admin') {
            _that.permissionFlag6 = true
          }
        }
      })
    },
    // 获取配置信息
    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
        } else if (key == 'OrderUpdateWebUrl') {
          _that.configValue3 = res.data.configValue1
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    getList() {
      var _that = this
      var params = _that.search
      var page = {
        pageIndex: _that.listData.page,
        pageSize: _that.listData.pageSize
      }
      var data = {
        'params': JSON.stringify(params),
        'page': JSON.stringify(page)
      }
      if (_that.listData.pageSize == 10) {
        _that.sizeType = 'medium'
      } else {
        _that.sizeType = 'mini'
      }
      // console.log(data);
      getOrderList(data).then(response => {
        console.log(response)
        const data = response.data
        // //  组合表单数据
        _that.tableData = data
        _that.listData.total = response.total
        // console.log(_that.tableData)
        _that.listLoading = false
      }).catch(err => {
        _that.$message.error(err)
        _that.listLoading = false
      })
    },
    // 搜索
    searchData() {
      this.listData.page = 1
      this.getList()
    },
    handleSelectionChange(val) {
      console.log(val)
    },
    // 获取脚印
    getOrderStep(row) {
      const _that = this
      _that.$refs.orderStep.idOrder = row.id
      _that.$refs.orderStep.getOrderStep()
    },
    openDetail(row) {
      var _that = this
      _that.detailVisible = true
      _that.$nextTick(() => {
        _that.$refs.orderDetail.idOrder = row.id
        _that.$refs.orderDetail.getInfo()
      })
    },
    openMaterialDetail(row) {
      const _that = this
      // _that.timer = new Date().getTime()
      _that.$nextTick(function () {
        _that.$refs.materialDetail.materialDialog = true
        _that.$refs.materialDetail.seeFlag = true
        _that.$refs.materialDetail.idOrder = row.id
        _that.$refs.materialDetail.getOrderInfo()
      })
    },
    // 订单消息
    openMessage(row) {
      var _that = this
      _that.memoDrawer = true
      _that.$nextTick(function () {
        // console.log(_that.$refs.orderMemo);
        _that.$refs.orderMessage.idOrder = row.id
        _that.$refs.orderMessage.getList()
      })
    },
    // 刷新变革
    tableRefresh() {
      // 刷新变革
      this.getList()
    },
    // 上传文件方式选择
    getUploadType($event, row) {
      const _that = this
      var userAgent = navigator.userAgent
      if ($event == 1) {
        _that.openFileDialog(row)
      } else if ($event == 2) {
        if (_that.configValue1 == undefined) {
          _that.configValue1 = ''
        }
        if (_that.configValue2 == undefined) {
          _that.configValue2 = ''
        }
        if (userAgent.indexOf('DnyERPBrowser') > 0) {
          dyERP.sendOrderFile(row.id.toString(), row.orderCode, _that.configValue1, _that.configValue2, '0', '0', '0')
        } else {
          // alert('请使用开发商提供的ERP客户端')
          this.$message({
            message: '请使用开发商提供的ERP客户端',
            type: 'warning'
          })
        }
      } else if ($event == 3) {
        if (userAgent.indexOf('DnyERPBrowser') > 0) {
          // alert('关联文件')
          dyERP.sendOrderFile(row.id.toString(), row.orderCode, _that.configValue1, _that.configValue2, '1', '0', '0')
        } else {
          // alert('请使用开发商提供的ERP客户端')
          this.$message({
            message: '请使用开发商提供的ERP客户端',
            type: 'warning'
          })
        }
      }
    },

    // 上传文件
    openFileDialog(row) {
      const _that = this
      // window.open('/#/upload?id=' + row.id + '&orderCode=' + row.orderCode + '&orderName=' + row.orderName+ '&type=1', '_blank')
      window.open(_that.configValue3 + '?id=' + row.id + '&orderCode=' + row.orderCode + '&orderName=' + row.orderName + '&type=1&idUser=' + _that.$store.state.user.user.id + '&supplierCode=' + _that.$store.state.user.indexInfo.supplierCode + '&dataSourceId=' + _that.$store.state.user.indexInfo.dataSourceId, '_blank')
    },

    // 退回订单
    openBackOrder(row) {
      this.orderId = row.id
      this.orderState = row.orderState
      this.sMemo = ''
      this.voidVisible = true
      this.versionCode = row.versionCode
    },
    backOrderBtn() {
      var _that = this
      var data = {
        'id': _that.orderId,
        'sMemo': _that.sMemo,
        'orderState': _that.orderState,
        'versionCode': _that.versionCode
      }
      backPrintOrder(data).then(response => {
        console.log(response)
        if (response.httpCode == 200) {
          _that.voidVisible = false
          _that.$message({
            message: '退回成功',
            type: 'success'
          })
          _that.tableRefresh()
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },

    // 订单修改
    orderUpdate($event, row) {
      const _that = this
      if ($event == 1) {
        _that.openEditPartProcess(row)
      } else if ($event == 2) {
        _that.openEditDeliverDate(row)
      } else if ($event == 3) {
        _that.enforceFinish(row)
      } else if ($event == 4) {
        _that.openUpdateMoney(row)
      } else if ($event == 5) {
        _that.openUpdateBaseInfo(row)
      } else if ($event == 6) {
        _that.openEditPartParameter(row)
      }
    },

    // 唤起修改交货日期
    openEditDeliverDate(row) {
      this.editDeliverDateDialog = true
      this.currentIdOrder = row.id
      this.deliverDate = row.deliverDate
    },

    editDeliverDate() {
      const _that = this
      _that.editDeliverDateDialog = true
      _that.clickLoading = true
      var data = {
        'id': _that.currentIdOrder,
        'deliverDate': _that.deliverDate
      }
      updateOrderDeliverDate(data).then(res => {
        console.log(res)

        if (res.httpCode == 200) {
          _that.clickLoading = false
          _that.$message({
            message: '修改成功',
            type: 'success'
          })
          _that.editDeliverDateDialog = false
          _that.tableRefresh()
        }
      }).catch(err => {

        _that.clickLoading = false
      })
    },
    // 唤起修改工艺
    openEditPartProcess(row) {
      const _that = this
      _that.editPartDialog = true
      var data = {
        'idOrder': row.id
      }
      getOrderPartList(data).then(res => {
        console.log(res)
        _that.partInfoList = res.data
      })
    },
    // 删除工艺
    deleteProcess(partIndex, index) {
      this.partInfoList[partIndex].processList.splice(index, 1)
    },
    // 工序辅料选择弹窗
    processChoose(partIndex, processIndex, row) {
      // console.log(row)
      const _that = this
      _that.dialogTitle = '选择辅料'
      _that.processChooseVisible = true
      _that.partIndex = partIndex
      _that.processIndex = processIndex
    },
    // 选择工序辅料档案
    chooseAccessories(row) {
      var _that = this
      _that.processChooseVisible = false
      _that.partInfoList[_that.partIndex].processList[_that.processIndex].materialName = row.materialName
      _that.partInfoList[_that.partIndex].processList[_that.processIndex].idMaterial = row.id
    },

    // 增加工序
    addProcess(partIndex) {
      // console.log(index1);
      var _that = this
      _that.processVisible = true
      _that.processListData.page = 1

      _that.processSearch.keyWord = ''

      _that.partIndex = partIndex
      _that.getProcessList()
    },
    // 工序搜索
    processSearchData() {
      this.processListData.page = 1
      this.getProcessList()
    },

    // 获取工序列表
    getProcessList() {
      var _that = this
      var params = _that.processSearch
      var page = {
        pageIndex: _that.processListData.page,
        pageSize: _that.processListData.pageSize
      }
      var data = {
        'params': JSON.stringify(params),
        'page': JSON.stringify(page)
      }
      getWorkProcessList(data).then(response => {
        // console.log(response)
        const data = response.data
        _that.processList = data
        _that.processListData.total = response.total
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 选择此行工序
    addThis(row) {
      var _that = this
      console.log(row)
      console.log(_that.partInfoList[_that.partIndex])
      var processList = _that.partInfoList[_that.partIndex].processList
      console.log(processList)
      if (row.workProcessList.length > 0) {
        var list = row.workProcessList
        list.forEach(item => {
          var addState = processList.some(process => {
            if (process.idProcess == item.id) {
              return true
            }
          })
          _that.addworkProcessFun(item, addState)
        })
      }
      var result = processList.some(item => {
        if (item.idProcess == row.id) {
          return true
        }
      })

      _that.addworkProcessFun(row, result)

      _that.processVisible = false
    },
    addworkProcessFun(item, state) {
      var _that = this
      var processItem = {
        'isRequired': 1,
        'idProcess': item.id,
        'processName': item.processName,
        'processMemo': '',
        'obvRevId': 1,
        'processPrice': '', // 工序单价、
        'processQty': '',
        'processMoney': '',
        'processRule': '',
        'idMaterial': '',
        'materialName': ''
      }

      if (!state) {
        _that.partInfoList[_that.partIndex].processList.push(processItem)
      } else {
        _that.$message.error('已有' + item.processName)
      }
    },
    editPart() {
      const _that = this
      _that.clickLoading = true
      var data = JSON.stringify(_that.partInfoList)
      // console.log(data);
      // return
      updateOrderPartProcess(data).then(res => {
        console.log(res)
        if (res.httpCode == 200) {
          _that.clickLoading = false
          _that.$message({
            message: '修改成功',
            type: 'success'
          })
          _that.editPartDialog = false
          _that.tableRefresh()
        }
      }).catch(err => {
        _that.clickLoading = false
      })
    },

    // 强制发货完成
    enforceFinish(row) {
      var _that = this
      var params = {
        'idOrder': row.id
      }

      var url = '/delivery/enforceFinishDelivery'
      _that.$refs.confirmDialog.updataClick(params, url)
    },

    // 修改订单金额
    openUpdateMoney(row) {
      this.editOrderMoneyDialog = true
      this.currentIdOrder = row.id
      this.orderMoney = row.orderMoneyTotal
    },
    editOrderMoney() {
      const _that = this
      _that.clickLoading = true
      var data = {
        printOrder: {
          'id': _that.currentIdOrder,
          'orderMoneyTotal': _that.orderMoney
        }
      }
      updateOrderTotalMoney(data).then(res => {
        console.log(res)

        if (res.httpCode == 200) {
          _that.clickLoading = false
          _that.$message({
            message: '修改成功',
            type: 'success'
          })
          _that.editOrderMoneyDialog = false

          _that.tableRefresh()
        }
      }).catch(err => {
        _that.clickLoading = false
      })
    },

    // 修改订单基础信息
    openUpdateBaseInfo(row) {
      const _that = this
      _that.editOrderBaseInfoDialog = true
      _that.payType = [
        {
          id: 0,
          name: '现金收款',
          value: '0',
          guarantee: ''
        },
        {
          id: 1,
          name: '物流代收',
          value: '0',
          guarantee: ''
        },
        {
          id: 2,
          name: '担保人',
          value: '0',
          guarantee: ''
        },
        {
          id: 3,
          name: '预存',
          value: '0',
          guarantee: ''
        }, {
          id: 4,
          name: '预收款',
          value: '0',
          guarantee: ''
        }
      ]
      var data = {
        'idOrder': row.id
      }
      getDetailPrintOrder(data).then(response => {
        var data = response.data
        _that.orderBaseInfo = response.data
        _that.orderBaseInfo.cutKind = (data.cutKind).toString()
        if (data.printRequire != '' && data.printRequire != null) {
          _that.printRequireOption = data.printRequire.split(',')
        } else {
          _that.printRequireOption = []
        }
        if (data.packRequire) {
          var packrequire = data.packRequire.split('+')
          // console.log(packrequire);
          var packrequireList = []
          packrequire.forEach(item => {
            var packrequireItem = {
              packNum: item.split('*')[0],
              countNum: item.split('*')[1]
            }
            packrequireList.push(packrequireItem)
          })
          _that.packrequireList = packrequireList
        }
        // 付款方式
        if (data.payKind) {
          var paykindString = data.payKind
          var paykindList = paykindString.split('+')
          paykindList.forEach(item => {
            var itemList = item.split(':')
            _that.payType[itemList[0]].value = itemList[2]
            // if (itemList[0] == 2) {//by夏玉
            //   _that.payType[itemList[0]].guarantee = itemList[3]
            // }
            _that.payType[itemList[0]].guarantee = itemList[3]
          })
        }
      })
    },
    // 获取字典
    getDictInfo(typeText) {
      const _that = this
      var data = {
        'dictTypeText': typeText
      }

      // console.log(data)
      getDictTypeInfo(data).then(response => {
        // console.log(response)
        const data = response.data
        if (typeText == 'PrintRequire') {
          _that.printRequireOptions = data
        } else if (typeText == 'OrderPrintDesc') {
          _that.orderPrintOptions = data
        } else if (typeText == 'PackingMethod') {
          _that.packingMethodOptions = data
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },

    // 添加打包要求
    addPackRequire() {
      const _that = this
      var packrequireItem = Object.assign({}, packrequire)
      _that.packrequireList.push(packrequireItem)
    },
    // 禁止输入小数，负数
    proving(e) {
      var keynum = window.event ? e.keyCode : e.which // 获取键盘码
      if (keynum == 189 || keynum == 109) { // 禁止输入负数
        this.$message.warning('禁止输入负数')
        e.target.value = 0
      }
      if (keynum == 110 || keynum == 190) { // 禁止输入负数
        this.$message.warning('禁止输入小数')
        e.target.value = ''
      }
    },

    // 表格合计
    getSummaries(param) {
      const {columns, data} = param
      const sums = []
      columns.forEach((column, index) => {
        // 如果是第一列，则最后一行展示为“总计”两个字
        if (index === 0) {
          sums[index] = '总计'
          // 如果是最后一列，索引为列数-1，则显示计算总和
        } else if (index === 1) {
          const values = data.map(item => Number(item[column.property]))
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr)
              if (!isNaN(value)) {
                return prev + curr
              } else {
                return prev
              }
            }, 0)
          } else {
            sums[index] = 'N/A'
          }
          // 如果是除了第一列和最后一列的其他列，则显示为空
        } else {
          sums[index] = ''
        }
      })
      // console.log(sums)
      this.sums = sums[1]
      return sums
    },

    editOrderBaseInfo() {
      const _that = this
      var packrequireArr = []
      _that.packrequireList.forEach(item => {
        if (parseInt(item.packNum) && parseInt(item.countNum)) {
          var packrequire = item.packNum + '*' + item.countNum
          packrequireArr.push(packrequire)
        }
      })
      _that.orderBaseInfo.packRequire = packrequireArr.join('+')
      // 付款方式
      var selectionArr = []
      for (let j = 0; j < _that.payType.length; j++) {
        if (_that.payType[j].value > 0) {
          if (_that.payType[j].id == 2) {
            if (!_that.payType[j].guarantee) {
              _that.$message.error('担保人不能为空')
              return
            }
          }
          var selectionString = ''
          selectionString = _that.payType[j].id + ':' + _that.payType[j].name + ':' + _that.payType[j].value + ':' + _that.payType[j].guarantee
          selectionArr.push(selectionString)
        }
      }
      _that.orderBaseInfo.payKind = selectionArr.join('+')
      _that.clickLoading = true
      var data = {
        updateMap: JSON.stringify({
          id: _that.orderBaseInfo.id,
          orderName: _that.orderBaseInfo.orderName,
          kindCount: _that.orderBaseInfo.kindCount,
          printRequire: _that.orderBaseInfo.printRequire,
          cutKind: _that.orderBaseInfo.cutKind,
          orderMemo: _that.orderBaseInfo.orderMemo,
          boxRequire: _that.orderBaseInfo.boxRequire,
          packKind: _that.orderBaseInfo.packKind,
          packRequire: _that.orderBaseInfo.packRequire,
          payKind: _that.orderBaseInfo.payKind
        })
      }
      // console.log(data);
      // return
      updateOrderBaseInfo(data).then(res => {
        if (res.httpCode == 200) {

          _that.clickLoading = false
          _that.$message({
            message: '修改成功',
            type: 'success'
          })
          _that.editOrderBaseInfoDialog = false
          _that.tableRefresh()
        }
      }).catch(err => {
        _that.clickLoading = false
      })
    },
    // 唤起修改部件参数
    openEditPartParameter(row) {
      const _that = this
      _that.editPartParameterDialog = true
      var data = {
        'idOrder': row.id
      }
      getDetailPrintOrder(data).then(res => {
        console.log(res)
        _that.partParameterList = res.data.partList
      })
    },
    selectBlur1(e, index1, index2) {
      var _that = this
      if (e.target != undefined) {
        _that.partParameterList[index1].paramValueList[index2].paramDisplay = e.target.value
        _that.partParameterList[index1].paramValueList[index2].paramValue = e.target.value
      }
    },
    parameterSelect(e, index1, index2) {
      const _that = this
      _that.partParameterList[index1].paramValueList[index2].itemList.forEach(item => {
        if (item.itemValue == e) {
          _that.partParameterList[index1].paramValueList[index2].paramDisplay = item.itemName
        }
      })
    },
    // 参数选择弹窗
    parameterChoose(index1, index2, type, name) {
      const _that = this
      _that.dialogTitle = name
      _that.parameterChooseVisible = true
      _that.timer = new Date().getTime()
      _that.parameterChooseType = type
      _that.partId = _that.partParameterList[index1].idPart
      _that.parameterId = _that.partParameterList[index1].paramValueList[index2].idParameter
      _that.parameterIndex1 = index1
      _that.parameterIndex2 = index2
    },
    // 选择纸张档案
    choosePaper(row) {
      var _that = this
      _that.parameterChooseVisible = false
      _that.partParameterList[_that.parameterIndex1].paramValueList[_that.parameterIndex2].paramDisplay = row.paperQuoteName
      _that.partParameterList[_that.parameterIndex1].paramValueList[_that.parameterIndex2].paramValue = row.id
    },
    // 选择参数辅料档案
    chooseAccessoriesByParameter(row) {
      var _that = this
      _that.parameterChooseVisible = false
      // console.log(row)
      _that.partParameterList[_that.parameterIndex1].paramValueList[_that.parameterIndex2].paramDisplay = row.materialName
      _that.partParameterList[_that.parameterIndex1].paramValueList[_that.parameterIndex2].paramValue = row.id
    },

    editPartParameter() {
      const _that = this
      if (_that.inputMemo == null || _that.inputMemo == '') {
        _that.$message.warning('请填写修改描述')
        return
      }
      for (var i = 0; i < _that.partParameterList.length; i++) {
        for (var j = 0; j < _that.partParameterList[i].paramValueList.length; j++) {
          var param = _that.partParameterList[i].paramValueList[j]
          if ((param.paramValue == '' || param.paramValue == null) && (param.fieldType != 6) && (param.fieldType != 7) && (param.fieldType != 3)) {
            _that.$message.error(param.parameterName + '为必填项')
            return
          }
          if (param.fieldType == 3) {
            var reg = new RegExp("^[0-9]*$");
            if(!reg.test(param.paramValue)){
              _that.$message.error('请输入正确的' + param.parameterName)
              return
            }
          }
          if (param.fieldType == 6) {
            var reg = /^(\d+([.]\d+)?)\*(\d+([.]\d+)?)$/;
            // console.log(param.fieldType,reg.test(param.paramValue));
            if(!reg.test(param.paramValue)){
              _that.$message.error('请输入正确的' + param.parameterName)
              return
            }
          }

          if (param.fieldType == 7) {
            var reg =  /^(\d+([.]\d+)?)\*(\d+([.]\d+)?)\*(\d+([.]\d+)?)$/;
            // console.log(param.fieldType,reg.test(param.paramValue));
            if(!reg.test(param.paramValue)){
              _that.$message.error('请输入正确的' + param.parameterName)
              return
            }
          }

        }
      }
      _that.clickLoading = true
      var data = JSON.stringify(_that.partParameterList)
      // console.log(data);
      // return
      updateOrderPartInfo(data, _that.inputMemo).then(res => {
        // console.log(res)
        if (res.httpCode == 200) {
          _that.clickLoading = false
          _that.$message({
            message: '修改成功',
            type: 'success'
          })
          _that.editPartParameterDialog = false
          _that.tableRefresh()
        }
      }).catch(err => {
        _that.clickLoading = false
      })
    },
  }
}
</script>
<style>
/*1.显示滚动条：当内容超出容器的时候，可以拖动：*/
.el-drawer__body {
  overflow: auto;
}

.stepList .el-card__body {
  padding: 10px;
}

:focus {
  outline: 0;
}

/*.el-dialog__body{*/
/*  padding: 0;*/
/*}*/
</style>

<style lang="scss" scoped>
.accInfo {
  ::v-deep .el-dialog__body {
    padding-top: 0px;
  }
}

::v-deep .el-button + .el-button {
  margin-left: 0;
}

.filter-container {
  margin-bottom: 15px;
}

.tb-edit .el-select, .tb-edit .el-checkbox {
  display: inline-block;
}

.tb-edit .el-input, .tb-edit .el-select, .tb-edit .el-cascader, .tb-edit .el-checkbox {
  display: none
}

.tb-edit .current-row .el-input, .tb-edit .current-row .el-checkbox, .tb-edit .current-row .el-select, .tb-edit .current-row .el-cascader {
  display: block
}

.tb-edit .current-row .el-input + span, .tb-edit .current-row .el-checkbox + span, .tb-edit .current-row .el-select + span, .tb-edit .current-row .el-cascader + span {
  display: none
}
</style>
