<!--检斤管理-->
<template>
  <div>
    <BaseHeaderLayout :leftSpan="8">
      <template slot="left">
         <el-upload style="margin-left: 8px;" class="upload-demo inline-block margin-right-10" action=""
          :on-change="importClick" :show-file-list="false"
          accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
          :auto-upload="false">
          <ws-button type="primary">导入(销售)</ws-button>
        </el-upload>
      </template>
      <template slot="left">
         <el-upload style="margin-left: 8px;" class="upload-demo inline-block margin-right-10" action=""
          :on-change="importClickYk" :show-file-list="false"
          accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel"
          :auto-upload="false">
          <ws-button type="primary">导入(移库)</ws-button>
        </el-upload>
      </template>
      <!-- <template slot="left"> </template> -->
      <template slot="right">
        <el-select class='select' filterable  v-model="warehouseName" placeholder="" @change="warehouseNameChange" :value="searchType">
          <el-option v-for="item in warehouseList" :key="item.value" :label="item.value" :value="item.value"
            style="color: #8890b1" />
        </el-select>
        <ws-input class='findinput' @keyup.enter.native="find()" v-model="searchKeyWord" placeholder="可按业务编号、合同编号、车牌号查找"
          clearable maxlength="500" type="input">
        </ws-input>
        <ws-button class="find" type="primary" @click="find()"><img width="16" height="16" style="
              vertical-align: text-top;
              position: relative;
              top: 0px;
              left: -8px;
            " src="../../../public/img/sousuo.png" alt="" /></ws-button>
      </template>
    </BaseHeaderLayout>
    <el-table :data="weighingList" style="width: 100%; margin-top: 20px" ref="weighingList" border height="calc(100% - 110px)">
      <el-table-column type="index" label="序号" width="50">
        <template scope="scope">
          <span v-if="scope.$index < 9">0{{ scope.$index + 1 }}</span>
          <span v-else>{{ scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="inOutTaskNo" label="任务编号" width="170"></el-table-column>
      <el-table-column prop="number" label="业务编号" width="170"></el-table-column>
      <el-table-column prop="contractNo" width="140" label="合同编号/移库编号">
        <template scope="scope">
          <span v-if="scope.row.contractNo">{{ scope.row.contractNo }}</span>
          <span v-else>{{ scope.row.moveTaskNo }}</span>
        </template></el-table-column>
      <el-table-column prop="goodsName" label="货名"></el-table-column>
      <el-table-column prop="carNumber" label="车牌号"></el-table-column>
      <el-table-column prop="grossWeight" label="毛重（公斤）">
      </el-table-column>
      <el-table-column prop="tare" label="皮重（公斤）">
      </el-table-column>
      <el-table-column prop="buckleMiscellaneous" label="扣重（公斤）">
      </el-table-column>
      <el-table-column prop="netWeight" label="净重（公斤）">
      </el-table-column>
      <!-- <el-table-column prop="binNumber" label="仓位号"></el-table-column>
      <el-table-column prop="storageNumber" label="囤位号"></el-table-column> -->
      <el-table-column prop="secretaryWeigher" label="司称员"></el-table-column>
      <el-table-column prop="grossDate" width="140" label="检斤时间">
        <template slot-scope="scope">
          {{scope.row.grossDate}}
          <span v-if="scope.row.grossDate == null">
            {{scope.row.tareDate}}
          </span>
        </template>
      </el-table-column>
      <!-- <el-table-column prop="addressUrl" label="附件">
        <template slot-scope="scope">
          <img width="18" height="20" style="vertical-align: text-top; position: relative; top: -1px"
            src="../../../public/img/fujian.png" @click="fujian(scope.row)" alt="" />
          <span v-if="scope.row.addressUrlArray != null">
            {{scope.row.addressUrlArray.length == 0? "":scope.row.addressUrlArray.length}}
          </span>
        </template>
      </el-table-column> -->
      <el-table-column prop="status" label="状态"></el-table-column>
      <el-table-column width="400" prop="contractNo1" label="操作">
        <template slot-scope="scope">
          <!-- <el-button @click="weighing(scope.row, 1)" v-if="scope.row.status != '已质检'"
            v-hasPermission="`outbound.acquisitionWeightOut.mao`">毛重</el-button>
          <el-button @click="weighing(scope.row, 2)" v-if="scope.row.status == '已称皮重'"
            v-hasPermission="`outbound.acquisitionWeightOut.weight`"> 皮重</el-button> -->
            <el-button @click="print(scope.row)"
            v-hasPermission="`outbound.acquisitionWeightOut.view`">打印</el-button>
          <el-button @click="del(scope.row)" v-if="scope.row.status == '已称皮重'"
            v-hasPermission="`outbound.acquisitionWeightOut.view`">删除</el-button>
             <el-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.huan`" class="putstorage" @click="exchange(scope.row)" v-if="scope.row.status == '已称皮重'">换仓</el-button>
             <el-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.huan`" class="putstorage" @click="exchangeNo(scope.row)" v-if="scope.row.status == '已称皮重'">换任务号</el-button>
             <el-button v-hasPermission="`warehouseManagement.warehouse.warehouseInfo.huan`" class="putstorage" @click="returnBack(scope.row)" v-if="scope.row.status == '已称毛重'">退回</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div style="text-align: center">
      <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage"
        :page-sizes="[20, 30, 50, 100, 500, 1000, 9999]" layout="total, sizes, prev, pager, next, jumper"
        :total="deptBudgetTotal">
      </el-pagination>
    </div>
    <WinseaContentModal v-model="accessoryTFs" :title="$t('system.noticeCircular.information')"
      @on-cancel="handleClose">
      <ws-upload ref="upload" :comp-id="compId" :appendix-ids="appendixIdss" :editable="false"
        accept=".jpg, .jpeg, .png, .pdf, .doc, .zip, .rar" />
    </WinseaContentModal>
    <div class="mask" v-show="isShowPrintType"></div>
    <div class="print-type" v-show="isShowPrintType">
      <div class="print-type-content">
        <div class="print-type-title">请选择打印类型</div>
        <div class="ew-print" v-if="checked||(!ddchecked&&!checked)">
          <div class="row">
           <div>我司发货单位：</div>
            <el-select v-model="companyName" placeholder="请选择" style="width: 75%;">
              <el-option v-for="item in companyNameOptions" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </div>
          <div class="row">
           <div>我司收货单位：</div>
            <el-select v-model="myCompanyCustomer" disabled style="width: 75%;">
             
            </el-select>
          </div>
        </div>
        <div v-if="warehouseName=='鲅鱼圈金信库'||warehouseName=='白城内陆港'||warehouseName=='杜尔伯特家禾库'||warehouseName=='洮南新友谊兴旺库'||warehouseName=='甘南宏旗库'||warehouseName=='哈尔滨依兰库'||warehouseName=='山东园丰库'">
          <div class="print-type-ew">
            <el-checkbox v-model="checked" @change="changeEw">打印额外票据</el-checkbox>
            <el-checkbox v-model="ddchecked" @change="changeEwDD">单独打印额外票据</el-checkbox>
          </div>
          <div class="ew-print" v-if="printSeparately">
            <div class="row">
              <div>额外发货单位：</div>
              <!-- <div>{{companyName}}</div> -->
              <el-select v-model="ewCustomer" placeholder="请选择" style="width: 75%;">
                <el-option v-for="item in ewCustomerOptions" :key="item.value" :label="item.label" :value="item.value">
                </el-option>
              </el-select>
            </div>
            <div class="row">
              <div>额外收货单位：</div>
              <!-- <div>{{companyNameEW}}</div> -->
              <el-select v-model="companyNameEW" placeholder="请选择" style="width: 75%;">
                <el-option v-for="item in companyNameEWOptions" :key="item.value" :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </div>
          </div>
        </div>
      </div>
      <div class="bottom-btn">
        <el-button @click="typePrintClick">确定</el-button>
        <el-button @click="typePrintCannelClick">取消</el-button>
      </div>
    </div>
    <el-dialog
      width="70%"
      class="title_css"
      center
      :visible.sync="isShowPrint"
      title="出库检斤单"
      @opened="opendBtn"
      @close="closeDialog"
      :close-on-click-modal="false"
    >
      <weightCheckPrint :tableData="inspect" ref="saveImg"></weightCheckPrint>
      <div style="text-align: center">
        <el-button type="primary" @click="closePrint">关闭</el-button>
        <el-button type="primary" @click="printSmall">打印小票</el-button>
        <el-button type="primary" @click="printBig">打印单据</el-button>
      </div>
    </el-dialog>
     <el-dialog
          title="提示"
          :visible.sync="dialogVisible"
          width="30%"
          :before-close="handleClose1">
          <div style="text-align:center">
             <el-select filterable clearable v-model="binNumber" placeholder="请选择仓位" class="typeselect"
              @change="binNumberChange">
              <el-option v-for="item in binnumberList" :key="item.binNumber" :label="item.binNumber"
                :value="item.binNumber" />
            </el-select>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogVisibleconfirm">确 定</el-button>
          </span>
        </el-dialog>
        <el-dialog
          title="提示"
          :visible.sync="dialogVisible1"
          width="30%"
          :before-close="handleClose2">
          <div style="text-align:center">
            <el-form ref="form" label-width="110px">
              <el-form-item label="任务编号">
             <el-select filterable clearable v-model="inOutTaskNo" placeholder="请选择任务号" class="typeselect"
              @change="taskNoChange">
              <el-option v-for="item in taskNolist" :key="item.inOutTaskNo" :label="item.inOutTaskNo"
                :value="item.inOutTaskNo" />
            </el-select>
            </el-form-item>
           <el-form-item label="合同编号">
            <el-input v-model="contractNo" placeholder="合同编号" :disabled="disabled" maxlength="15">
            </el-input>
             </el-form-item>
         </el-form>
          </div>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible1 = false">取 消</el-button>
            <el-button type="primary" @click="dialogVisibleconfirm1">确 定</el-button>
          </span>
        </el-dialog>
  </div>
</template>
<script>
  import {
    getweighingList,
    selectWarehouseSelf,
    delelteWeighing,
    getweighing,
    changeNo,
    changeTaskNo,
    importWordSale,
    importWordYk,
    goBack
  } from '@/model/outboundManagement/index'
  import {
    getReceiptTaskNo,
  } from '@/model/warehouse/index'
  import {
    EventBus
  } from 'base-core-lib'
  import {
    getcomp
  } from '@/model/indexRx'
  import WsUpload from '@/components/WsUpload'
  import weightCheckPrint from './component/weightCheckPrint.vue'
  import inspectInfoPrint from './component/inspectInfoPrint.vue'
   import html2canvas from 'html2canvas'
  export default {
    components: {
      WsUpload,
      inspectInfoPrint,
			weightCheckPrint
    },
    data() {
      return {
        //分页
        dialogViewSpareMoney: false,
        currentPage: 1,
        pageSize: 20,
        inspect:{},
        deptCircularPage: {},
        deptBudgetTotal: 0,
        paymentForm: false,
        isShowPrint:false,
        paymentForm1: false,
        weighingList: [],
        searchKeyWord: '',
        searchType: [],
        warehouseName: '',
        isShowPrintType: false,
        value1: '', //选择时间
        warehouseList: [],
        warehouseId: '',
        accessoryTFs: false,
        appendixIdss: [],
        addressUrls: [],
        compId: localStorage.getItem('ws-pf_compId'),
        dialogVisible:false,
        dialogVisible1:false,
        binNumber:'',
        inOutTaskNo:'',
        contractNo:'',
        disabled: true,
        binnumberList:[],
        taskNolist:[],
        cangweiNum:'',
        contractNum:'',
        positionId:'',
        warehouseList1:[],
        
        ewCustomerOptions: [{
          value: '天津建源供应链管理有限公司',
          label: '天津建源供应链管理有限公司'
        },{
          value: '厦门建发物产有限公司',
          label: '厦门建发物产有限公司'
        },{
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        }, {
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        },{
          value: '黑龙江谷香粮食贸易有限公司',
          label: '黑龙江谷香粮食贸易有限公司'
        },{
          value: '黑龙江秋收有限公司',
          label: '黑龙江秋收有限公司'
        }, {
          value: '黑龙江益储益运粮食贸易有限公司',
          label: '黑龙江益储益运粮食贸易有限公司'
        }, {
          value: '黑龙江启兴粮食贸易有限公司',
          label: '黑龙江启兴粮食贸易有限公司'
        }],
        companyNameOptions: [
          {
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        }, {
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        },{
          value: '黑龙江谷香粮食贸易有限公司',
          label: '黑龙江谷香粮食贸易有限公司'
        },{
          value: '黑龙江秋收有限公司',
          label: '黑龙江秋收有限公司'
        },  {
          value: '黑龙江益储益运粮食贸易有限公司',
          label: '黑龙江益储益运粮食贸易有限公司'
        }, {
          value: '黑龙江启兴粮食贸易有限公司',
          label: '黑龙江启兴粮食贸易有限公司'
        }],
        companyNameEWOptions: [{
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        }, {
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        },{
          value: '厦门建发物产有限公司',
          label: '厦门建发物产有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        },{
        value: '天津建源供应链管理有限公司',
        label: '天津建源供应链管理有限公司'
      }],
        companyName: '黑龙江中天昊元贸易有限公司',
        companyNameEW: '黑龙江利润元粮食贸易有限公司',
        ewCustomer: '厦门建发物产有限公司',
        ewradio: '',
        ddchecked: false,
        checked: false,
        myCompanyCustomer:'',
        printSeparately: false,
        
        jjSelectPrintList: [],
      }
    },
    activated() {
      getcomp({userMobilePhone:JSON.parse(localStorage.getItem('ws_login_getTenantInfoByUser')).loginInfo.userMobilePhone}).toPromise().then((res)=>{
        this.compNameoptions=res
    if (this.compNameoptions.length>0) {
      var company=this.compNameoptions
        var extra=company.filter((item)=>{
          return item!='黑龙江中天昊元贸易有限公司'
          &&item!='黑龙江利润元粮食贸易有限公司'
          &&item!= '黑龙江众利合粮食贸易有限公司'
          &&item!='黑龙江鑫满仓粮食贸易有限公司'
          &&item!='黑龙江谷香粮食贸易有限公司'
          &&item!='黑龙江秋收有限公司'
          &&item!= '黑龙江欣洋粮食贸易有限公司'
          &&item!='黑龙江益储益运粮食贸易有限公司'
          &&item!='黑龙江启兴粮食贸易有限公司'
        })
        if(extra.length>0){
          this.companyNameOptions=[
          {
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        }, {
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        },{
          value: '黑龙江谷香粮食贸易有限公司',
          label: '黑龙江谷香粮食贸易有限公司'
        },{
          value: '黑龙江秋收有限公司',
          label: '黑龙江秋收有限公司'
        },  {
          value: '黑龙江益储益运粮食贸易有限公司',
          label: '黑龙江益储益运粮食贸易有限公司'
        }, {
          value: '黑龙江启兴粮食贸易有限公司',
          label: '黑龙江启兴粮食贸易有限公司'
        }]
        
          this.ewCustomerOptions= [
          {
          value: '天津建源供应链管理有限公司',
          label: '天津建源供应链管理有限公司'
        },{
          value: '厦门建发物产有限公司',
          label: '厦门建发物产有限公司'
        },{
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        }, {
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        },{
          value: '黑龙江谷香粮食贸易有限公司',
          label: '黑龙江谷香粮食贸易有限公司'
        },{
          value: '黑龙江秋收有限公司',
          label: '黑龙江秋收有限公司'
        },  {
          value: '黑龙江益储益运粮食贸易有限公司',
          label: '黑龙江益储益运粮食贸易有限公司'
        }, {
          value: '黑龙江启兴粮食贸易有限公司',
          label: '黑龙江启兴粮食贸易有限公司'
        },{
        value: '天津建源供应链管理有限公司',
        label: '天津建源供应链管理有限公司'
      }]
          this.companyNameEWOptions=[
          {
          value: '黑龙江中天昊元贸易有限公司',
          label: '黑龙江中天昊元贸易有限公司'
        }, {
          value: '黑龙江利润元粮食贸易有限公司',
          label: '黑龙江利润元粮食贸易有限公司'
        }, {
          value: '黑龙江众利合粮食贸易有限公司',
          label: '黑龙江众利合粮食贸易有限公司'
        }, {
          value: '黑龙江鑫满仓粮食贸易有限公司',
          label: '黑龙江鑫满仓粮食贸易有限公司'
        },{
          value: '黑龙江欣洋粮食贸易有限公司',
          label: '黑龙江欣洋粮食贸易有限公司'
        },{
          value: '黑龙江谷香粮食贸易有限公司',
          label: '黑龙江谷香粮食贸易有限公司'
        },{
          value: '黑龙江秋收有限公司',
          label: '黑龙江秋收有限公司'
        },  {
          value: '黑龙江益储益运粮食贸易有限公司',
          label: '黑龙江益储益运粮食贸易有限公司'
        }, {
          value: '黑龙江启兴粮食贸易有限公司',
          label: '黑龙江启兴粮食贸易有限公司'
        },{
        value: '天津建源供应链管理有限公司',
        label: '天津建源供应链管理有限公司'
      }]
          this.companyName=extra[0]
          this.companyNameEW=extra[0]
          this.ewCustomer=extra[0]
          for (let i = 0; i < extra.length; i++) {
            this.ewCustomerOptions.push({value: extra[i],label:extra[i]})
            this.companyNameOptions.push({value: extra[i],label:extra[i]})
            this.companyNameEWOptions.push({value: extra[i],label:extra[i]})
          }
        }
      }
    })
      this.selectWarehouse()
      this.showType = this.isShow
    },
    methods: {
      changeEw(e) {
        this.ddchecked = false
        if (e) {
          this.printSeparately = true
        } else {
          this.printSeparately = false
        }
      },
      changeEwDD(e) {
        this.checked = false
        if (e) {
          this.printSeparately = true
        } else {
          this.printSeparately = false
        }
      },
      typePrintCannelClick() {
        this.onePrint = false //单个打印标识
        this.dialogDataList = [] //打个打印取消时数组至空
        this.isShowPrintType = false
      },
      async typePrintClick(type) {
        if (this.onePrint) { //判断是否是单个打印
          getweighing({
              id: this.idPrint
            })
            .toPromise()
            .then((response) => {
              this.dialogDataList = [] //点击确认时先清空要打印的数组
              this.dialogData = response
              if (response.compName == '黑龙江秋收有限公司') {
                this.dialogData.compName = '黑龙江中天昊元贸易有限公司'
              }
              if (this.checked) {
                if(this.dialogData&&!this.dialogData.customer&&this.dialogData.contractManagement){
                  this.dialogData.customer = this.dialogData.contractManagement.seller
                }
                this.dialogDataList.push(this.dialogData)
                var _datas = JSON.stringify(this.dialogData)
                _datas = JSON.parse(_datas)
                _datas.compName =this.ewCustomer
                _datas.customer =  this.companyNameEW
                this.dialogDataList.push(_datas)
                this.printBig('', this.radio)
              } else if (this.ddchecked) {
                _datas = this.dialogData
                _datas.compName = this.companyNameEW;
                _datas.customer = this.ewCustomer
                this.dialogDataList.push(_datas)
                this.printBig(1, this.radio)
              } else {
                this.dialogData.companyName = this.companyName
                if(this.dialogData&&!this.dialogData.customer&&this.dialogData.contractManagement){
                  this.dialogData.customer = this.dialogData.contractManagement.buyer
                }
                this.dialogDataList.push(this.dialogData)
                this.printBig('', this.radio)
              }
            })
            .catch((response) => {
              // EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
            })
        } else {
          //   if (this.isExcelPrint) {
          //   this.printBig(2, this.radio)
          //   this.isExcelPrint = false
          // } else {
          this.jjSelectPrintList = []
          let index1 = 0;
          for (let i = 0; i < this.modification.length; i++) {
            await getweighing({
                id: this.modification[i].id
              })
              .toPromise()
              .then((response) => {
                index1++;
                response.compName = this.companyName
                if (response.compName == '黑龙江秋收有限公司') {
                  response.compName = '黑龙江中天昊元贸易有限公司'
                }
                this.jjSelectPrintList.push(response)
                if (index1 == this.modification.length) {
                  this.printBig(1, this.radio)
                }
              })
              .catch((response) => {})
          }
          // }
        }
      },
      print(row, type, pageType) {
        //打印
        if (type == 1) { //
          if (this.modification.length == 0) {
            this.$message.error('请选择批量打印的条目！')
            return
          }
          for (let _num = 0; _num < this.modification.length; _num++) {
            if (this.modification[_num].serviceManagementType == 1 && (this.warehouseName == '鲅鱼圈金信库' || this.warehouseName == '杜尔伯特家禾库'||this.warehouseName=='洮南新友谊兴旺库'||this.warehouseName=='甘南宏旗库' || this.warehouseName == '白城内陆港' || this.warehouseName == '哈尔滨依兰库'||this.warehouseName=='山东园丰库')) {
              if (this.modification[_num].seller && this.modification[_num].buyer) {
                let cang = {}
                cang.value = this.modification[_num].seller
                cang.label = this.modification[_num].seller
                if (this.check(this.modification[_num].seller, 1)) {
                  this.ewCustomerOptions.push(cang)
                }
                let cang1 = {}
                cang1.value = this.modification[_num].buyer
                cang1.label = this.modification[_num].buyer
                if (this.check(this.modification[_num].buyer, 2)) {
                  this.companyNameEWOptions.push(cang1)
                }
              }
            }
          }
          this.isShowPrintType = true
        } else {
          if (row.serviceManagementType == '2' && (this.warehouseName == '鲅鱼圈金信库' || this.warehouseName == '杜尔伯特家禾库'||this.warehouseName=='洮南新友谊兴旺库'||this.warehouseName=='甘南宏旗库'|| this.warehouseName == '白城内陆港' || this.warehouseName == '哈尔滨依兰库'||this.warehouseName=='山东园丰库')) {
            if (row.seller && row.buyer) {
              let cang = {}
              cang.value = row.seller
              cang.label = row.seller
              if (this.check(row.seller, 1)) {
                this.ewCustomerOptions.push(cang)
              }
              let cang1 = {}
              cang1.value = row.buyer
              cang1.label = row.buyer
              if (this.check(row.buyer, 2)) {
                this.companyNameEWOptions.push(cang1)
              }
              this.myCompanyCustomer = row.buyer
            }
          }
          this.idPrint = row.id
          this.isShowPrintType = true
          this.onePrint = true //单个打印标识
        }

      },
      check(name, type) {
        if (type == 1) {
          for (var _tmp = 0; _tmp < this.ewCustomerOptions.length; _tmp++) {
            if (this.ewCustomerOptions[_tmp].label == name) {
              return false
            }
          }
          return true
        } else if (type == 2) {
          for (var _tmp = 0; _tmp < this.companyNameEWOptions.length; _tmp++) {
            if (this.companyNameEWOptions[_tmp].label == name) {
              return false
            }
          }
          return true

        }

      },
      importClick(file, fileList) {
        this.fileTemp = file.raw
        let fileName = file.raw.name
        let fileType = fileName.substring(fileName.lastIndexOf('.') + 1)
        // 判断上传文件格式
        if (this.fileTemp) {
          if (fileType == 'xlsx' || fileType == 'xls') {
            this.importf(this.fileTemp)
          } else {
            this.$message({
              type: 'warning',
              message: '附件格式错误，请删除后重新上传！',
            })
          }
        } else {
          this.$message({
            type: 'warning',
            message: '请上传附件！',
          })
        }
      },
      importf(obj) {
        this.excelFreightspace = []
        // this.dialogVisible = true;
        let _this = this;
        let inputDOM = this.$refs.inputer; // 通过DOM取文件数据
        this.file = event.currentTarget.files[0];
        var rABS = false; //是否将文件读取为二进制字符串
        var f = this.file;
        var reader = new FileReader();
        //if (!FileReader.prototype.readAsBinaryString) {
        FileReader.prototype.readAsBinaryString = function(f) {
          var binary = '';
          var rABS = false; //是否将文件读取为二进制字符串
          var pt = this;
          var wb; //读取完成的数据
          var outdata;
          var reader = new FileReader();
          reader.onload = function(e) {
            var bytes = new Uint8Array(reader.result);
            var length = bytes.byteLength;
            for (var i = 0; i < length; i++) {
              binary += String.fromCharCode(bytes[i]);
            }
            var XLSX = require('xlsx');
            if (rABS) {
              wb = XLSX.read(btoa(fixdata(binary)), { //手动转化
                type: 'base64',
                cellDates: true
              });
            } else {
              wb = XLSX.read(binary, {
                type: 'binary'
              });
            }
            // outdata就是你想要的东西 excel导入的数据
            outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
            // excel 数据再处理
            let arr = []
            outdata.map(v => {
              // let jsonString = JSON.stringify(v).replace(/\*/g, '').replace(/\s/ig,'');
              let jsonString = JSON.stringify(v).replace(/\//g, '').replace(/\s/ig, '');
              v = JSON.parse(jsonString);
              let obj = {}
              //xxx代表列名
              obj.number = v.业务编号
              obj.inOutTaskNo = v.出库任务编号
              obj.outType = v.运输方式
              obj.carNumber = v.车牌号
              obj.grossWeight = v.毛重
              obj.tare = v.皮重
              obj.netWeight = v.净重
              obj.contractNo = v.销售合同号
              obj.contractPrice = v.销售合同单价
              obj.grossDate = _this.formatDate(v.出库日期, '-')
              obj.settleWeight = v.结算数量
              obj.settlePrice = v.结算单价
              obj.settleDate = v.结算日期
              obj.settleMoney = v.结算金额
              _this.excelFreightspace.push(obj)
            })
            if (_this.excelFreightspace) {
              importWordSale({
                  warehouseName: _this.warehouseName,
                  weighingManagementList: _this.excelFreightspace
                }).toPromise()
                .then((response) => {
                  if (response == 'ok') {
                    this.$notify({
                      title: '成功',
                      message: '导入成功',
                      type: 'success'
                    });
                    _this.getList()
                  }
                })

            }
          }
          reader.readAsArrayBuffer(f);
        }
        if (rABS) {
          reader.readAsArrayBuffer(f);
        } else {
          reader.readAsBinaryString(f);
        }

      },
      importClickYk(file, fileList) {
        this.fileTemp = file.raw
        let fileName = file.raw.name
        let fileType = fileName.substring(fileName.lastIndexOf('.') + 1)
        // 判断上传文件格式
        if (this.fileTemp) {
          if (fileType == 'xlsx' || fileType == 'xls') {
            this.importfYk(this.fileTemp)
          } else {
            this.$message({
              type: 'warning',
              message: '附件格式错误，请删除后重新上传！',
            })
          }
        } else {
          this.$message({
            type: 'warning',
            message: '请上传附件！',
          })
        }
      },
      importfYk(obj) {
        this.excelFreightspace = []
        // this.dialogVisible = true;
        let _this = this;
        let inputDOM = this.$refs.inputer; // 通过DOM取文件数据
        this.file = event.currentTarget.files[0];
        var rABS = false; //是否将文件读取为二进制字符串
        var f = this.file;
        var reader = new FileReader();
        //if (!FileReader.prototype.readAsBinaryString) {
        FileReader.prototype.readAsBinaryString = function(f) {
          var binary = '';
          var rABS = false; //是否将文件读取为二进制字符串
          var pt = this;
          var wb; //读取完成的数据
          var outdata;
          var reader = new FileReader();
          reader.onload = function(e) {
            var bytes = new Uint8Array(reader.result);
            var length = bytes.byteLength;
            for (var i = 0; i < length; i++) {
              binary += String.fromCharCode(bytes[i]);
            }
            var XLSX = require('xlsx');
            if (rABS) {
              wb = XLSX.read(btoa(fixdata(binary)), { //手动转化
                type: 'base64',
                cellDates: true
              });
            } else {
              wb = XLSX.read(binary, {
                type: 'binary'
              });
            }
            // outdata就是你想要的东西 excel导入的数据
            outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);
            // excel 数据再处理
            let arr = []
            outdata.map(v => {
              // let jsonString = JSON.stringify(v).replace(/\*/g, '').replace(/\s/ig,'');
              let jsonString = JSON.stringify(v).replace(/\//g, '').replace(/\s/ig, '');
              v = JSON.parse(jsonString);
              let obj = {}
              //xxx代表列名
              obj.number = v.业务编号
              obj.inOutTaskNo = v.出库任务编号
              obj.outType = v.运输方式
              obj.carNumber = v.车牌号
              obj.grossWeight = v.毛重
              obj.tare = v.皮重
              obj.netWeight = v.净重
              obj.grossDate = _this.formatDate(v.出库日期, '-')
              _this.excelFreightspace.push(obj)
            })
            if (_this.excelFreightspace) {
              importWordYk({
                  warehouseName: _this.warehouseName,
                  weighingManagementList: _this.excelFreightspace
                }).toPromise()
                .then((response) => {
                  if (response == 'ok') {
                    this.$notify({
                      title: '成功',
                      message: '导入成功',
                      type: 'success'
                    });
                    _this.getList()
                  }
                })

            }
          }
          reader.readAsArrayBuffer(f);
        }
        if (rABS) {
          reader.readAsArrayBuffer(f);
        } else {
          reader.readAsBinaryString(f);
        }

      },
      formatDate(numb, format) {
        const old = numb - 1;
        const t = Math.round((old - Math.floor(old)) * 24 * 60 * 60);
        const time = new Date(1900, 0, old, 0, 0, t)
        const year = time.getFullYear();
        const month = time.getMonth() + 1;
        const date = time.getDate();
        return year + format + (month < 10 ? '0' + month : month) + format + (date < 10 ? '0' + date : date) +
          ' 00:00:00'
      },
      returnBack(item){   
          goBack({id:item.id}).toPromise()
						.then((response) => {
              this.$notify.success({
                  title: '成功',
                  message: '退回成功',
                })
                this.getList()
						}) .catch(() => {
            return false
          })
      },
       binNumberChange(e){
        this.binNumber = e
        for(let i = 0 ; i < this.binnumberList.length ; i++){
          if(this.binNumber == this.binnumberList[i].binNumber){
            this.positionId = this.binnumberList[i].id
          }
        }
      },
      taskNoChange(e){
        this.inOutTaskNo = e
        for(let i = 0 ; i < this.taskNolist.length ; i++){
          if(this.inOutTaskNo == this.taskNolist[i].inOutTaskNo){
            if(this.taskNolist[i].contractNo){
              this.contractNo = this.taskNolist[i].contractNo
            }
            else{
              this.contractNo = this.taskNolist[i].moveTaskNo
            }
          }
        }
      },
      handleClose1(){
        this.dialogVisible = false
      },
      handleClose2(){
        this.inOutTaskNo=''
        this.dialogVisible1 = false
      },
      exchange(row){
          for(let i = 0 ; i < this.warehouseList1.length; i++ ){
            if(this.warehouseName == this.warehouseList1[i].warehouseName){
              		this.binnumberList = this.warehouseList1[i].positionInfos
            }
          }
            this.id = row.id
            this.binNumber = row.binNumber
            this.cangweiNum = row.binNumber
            this.dialogVisible = true
       },
       exchangeNo(row){
          getReceiptTaskNo({
            flag: 1,
            warehouseName: this.warehouseName,
          })
          .toPromise()
          .then((response) => {
            this.taskNolist = response
          })
            this.id = row.id
            this.contractNo = row.contractNo
            this.contractNum = row.contractNo
            this.dialogVisible1 = true
       },
       dialogVisibleconfirm(){
        if(this.binNumber == this.cangweiNum){
          this.$message.error('已是该仓位无需修改')
          return
        }
        this.$confirm(`确定修改仓位？`, {
            cancelButtonText: '取消',
            confirmButtonText: '确定',
            type: 'warning',
          })
          .then(() => {
            // let _obj = JSON.parse(this.warehouseInOutDetail)
            // _obj.binNumber = this.binNumber
              changeNo({id:this.id,changePositionId:this.positionId,changeBinNumer:this.binNumber}).toPromise()
						.then((response) => {
              this.$notify.success({
                  title: '成功',
                  message: '修改仓位成功',
                })
                this.getList()
                this.inOutTaskNo=''
                this.dialogVisible=false
						})
          })
          .catch(() => {
            return false
          })
      },
      dialogVisibleconfirm1(){
        // if(this.contractNo == this.contractNum){
        //   this.$message.error('已是该任务号无需修改')
        //   return
        // }
        this.$confirm(`确定修改任务号？`, {
            cancelButtonText: '取消',
            confirmButtonText: '确定',
            type: 'warning',
          })
          .then(() => {
              changeTaskNo({id:this.id,inOutTaskNo:this.inOutTaskNo,contractNo:this.contractNo}).toPromise()
						.then((response) => {
              this.$notify.success({
                  title: '成功',
                  message: '修改任务号成功',
                })
                this.getList()
                this.dialogVisible1=false
						})
          })
          .catch(() => {
            return false
          })
      },
      warehouseNameChange(e) {
        // this.warehouseName = e
        console.log(this.warehouseList)
        for (let i = 0; i < this.warehouseList.length; i++) {
          if (this.warehouseList[i].value == e) {
            this.warehouseId = this.warehouseList[i].warehouseId
          }
        }
        this.getList()
      },
      weighing(row, num) {
        console.log
        this.$router.push({
          path: 'weighing',
          query: {
            typeNo: num,
            id: row.id,
            number: row.number,
            binNumber: row.binNumber,
            customer: row.customer,
            storageNumber: row.storageNumber,
            carNumber: row.carNumber,
            goodsName: row.goodsName,
            grossWeight: row.grossWeight,
            tare: row.tare,
            netWeight: row.netWeight,
            relationId: row.relationId,
            warehouseId: this.warehouseId,
            warehouseName: this.warehouseName,
          },
        })
      },
      // Reacquire() {
      //   //重新获取
      // },
      find() {
        this.getList()
      },
      // dayin(row){
      //   getweighing({
      //     id: row.id
      //     })
      //     .toPromise()
      //     .then((response) => {
      //       this.inspect=response
      //       this.isShowPrint=true
      //     })
      // },
      handleSizeChange(val) {
        console.log(`每页 ${val} 条`)
        this.pageSize = val
        this.getList()
      },
      handleCurrentChange(val) {
        this.currentPage = val
        console.log(`当前页: ${val}`)
        this.getList()
      },
      printSmall() {
         localStorage.setItem('ck_bd_printData1',JSON.stringify(this.inspect))
         window.open('../../../../static/outWeightPrint.html?type=1')
    },
    printBig(type, radioType) {
        //  localStorage.setItem('ck_bd_printData1',JSON.stringify(this.inspect))
        //  window.open('../../../../static/outWeightPrint.html?type=2')
         // 打印额外
        localStorage.removeItem('print_out_data')
        localStorage.removeItem('selectPrint_EWjjSelectPrintList')
        localStorage.removeItem('selectPrint_jjSelectPrintList')
        if (this.checked || this.ddchecked) {
          this.makeEWjjSelectPrintList()
          //  this.selectEW = true;
        }
       
        if (type == 1) {
          localStorage.setItem('selectPrint_jjSelectPrintList', JSON.stringify(this.dialogDataList))
          window.open('../../../../static/weightCheckOutNew.html?type=2&radioType=' + radioType + '&selectEW=' + this
            .checked + '&selectEWDD=' + this.ddchecked)
        } else if (type == 2) {
          localStorage.setItem('selectPrint_jjSelectPrintList', JSON.stringify(this.excelPrintData))
          window.open('../../../../static/weightCheckOutNew.html?type=2&radioType=' + radioType)
        } else {
          console.log(this.dialogDataList)
          localStorage.setItem('print_out_data',JSON.stringify(this.dialogDataList).replace(/%/g, 'baifenhao'))
          window.open('../../../../static/weightCheckOutNew.html?type=2' )
        }
    },
  
    makeEWjjSelectPrintList() {
      let _selectPrint_EWjjSelectPrintList = JSON.parse(JSON.stringify(this.dialogDataList));
      for (let i = 0; i < _selectPrint_EWjjSelectPrintList.length; i++) {
        let _data = _selectPrint_EWjjSelectPrintList[i];
        _data.compName = this.companyNameEW;
        _data.customer = this.ewCustomer
      }
      localStorage.setItem('selectPrint_EWjjSelectPrintList', JSON.stringify(_selectPrint_EWjjSelectPrintList))
    },
    opendBtn() {
      // html2canvas(this.$refs.saveImg.$el).then((canvas) => {
      //   let dataURL = canvas.toDataURL('image/png')
      //   this.imgUrl = dataURL
      //   if (this.imgUrl !== '') {
      //     let b = this.dataURLtoFile(this.imgUrl, 'printImage')
      //     let formdata = new FormData()
      //     formdata.append('file', b)
      //     axios({
      //       method: 'post',
      //       url:this.global.uploadPath,
      //       data: formdata,
      //     }).then((response) => {
      //       //编辑接口
      //       this.weighingList.pictureAddress = response.data.url
      //       tare(this.weighingList)
      //         .toPromise()
      //         .then((response) => {})
      //     })
      //   }
      // })
    },
    closeDialog() {
      html2canvas(this.$refs.saveImg.$el).then((canvas) => {
        let dataURL = canvas.toDataURL('image/png')
        this.imgUrl = dataURL
        if (this.imgUrl !== '') {
          let b = this.dataURLtoFile(this.imgUrl, 'printImage')
          let formdata = new FormData()
          formdata.append('file', b)
          axios({
            method: 'post',
            url:this.global.uploadPath,
            data: formdata,
          }).then((response) => {
            //编辑接口
            this.weighingList.pictureAddress = response.data.url
            tare(this.weighingList)
              .toPromise()
              .then((response) => {})
          })
          this.dialogTableVisible = true
        }
      })
      this.isShowPrint = false
      // this.$router.push({
      //   path: 'weighingManagement'
      // })
    },
    closePrint() {
      this.isShowPrint = false
      // this.$router.push({
      //   path: 'weighingManagement'
      // })
    },
      del(row) {
        this.$confirm(`检斤信息删除后不可恢复，是否确定删除？`, {
            cancelButtonText: '取消',
            confirmButtonText: '确定',
            type: 'warning',
          })
          .then(() => {
            delelteWeighing({
                id: row.id
              })
              .toPromise()
              .then((response) => {
                this.$notify.success({
                  title: '成功',
                  message: '删除成功',
                })
                this.getList()
              })
              .catch((response) => {})
          })
          .catch(() => {
            return false
          })
      },
      selectWarehouse() {
        selectWarehouseSelf({
            compId: localStorage.getItem('ws-pf_compId'),
          })
          .toPromise()
          .then((response) => {
            this.warehouseList1 = response
            this.warehouseList = []
            for (let i = 0; i < response.length; i++) {
              this.warehouseList.push({
                value: response[i].warehouseName,
                warehouseId: response[i].id,
              })
            }
            if(this.$route.query.warehouseName){
              this.warehouseName = this.$route.query.warehouseName
            }else{
                this.warehouseName = response[0].warehouseName
                this.warehouseId = this.warehouseList[0].warehouseId
            }
            
            this.getList()
          })
      },
      getList() {
        getweighingList({
            compId: localStorage.getItem('ws-pf_compId'),
            currentPage: this.currentPage,
            pageSize: this.pageSize,
            searchKeyWord: this.searchKeyWord,
            warehouseName: this.warehouseName,
            managementType: 3,
          })
          .toPromise()
          .then((response) => {
            this.weighingList = response.records
            this.deptBudgetTotal = response.total
            for (var i = 0; i < response.records.length; i++) {
              if (response.records[i].addressUrl != null) {
                if (response.records[i].addressUrl) {
                  response.records[i].addressUrlArray = response.records[i].addressUrl.split(',')
                }
              } else {
                response.records[i].addressUrlArray = []
              }
            }
            for (var i = 0; i < response.records.length; i++) {
              var arr = new Array()
              this.addressUrls[i] = new Array()
              if (this.weighingList.records[i].addressUrl !=
                null) {
                arr = this.weighingList.records[i].addressUrl.split(',')
                this.addressUrls[i] = arr
              }
            }
          })
          .catch((response) => {

          })
      },
      //附件
      fujian(row) {
        if (row.addressUrl === null || row.addressUrl === '') {
          EventBus.$emit(
            'warning',
            this.$t('system.noticeCircular.NoInformation')
          )
        } else {
          this.accessoryTFs = true
        }
        this.appendixIdss = row.addressUrl
      },
      handleClose() {
        this.dialogViewSpareMoney = false
      },
    },
  }
</script>
<style lang="scss" scoped>
  .title {
    font-size: 20px;
    font-weight: 600;
    margin: 20px;
  }

  .ws-info-table {
    border: none;
  }

  .ws-info-table .el-form-item {
    width: 50%;
    border: none;
  }

  .mask {
    background: black;
    width: 100vw;
    height: 100vh;
    position: fixed;
    top: 0;
    z-index: 99;
    opacity: 0.3;
  }

  .print-type-title {
    text-align: center;
    font-size: 18px;
    margin: 20px;
  }

  .bottom-btn {
    display: flex;
    margin-top: 20px;
    justify-content: space-around;
  }

  .print-type-checkbox {
    // padding-left: 20px;
  }

  .print-type {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    margin: auto;
    width: 440px;
    height: 320px;
    background: white;
    border-radius: 10px;
    z-index: 999;
  }

  /deep/.ws-info-table .el-form-item .el-form-item__label {
    width: 30%;
    text-align: center;
    background: #ffffff;
    color: #8890b1;
  }

  /deep/.ws-info-table .el-form-item .el-form-item__content {
    border: none;
  }

  /deep/.el-table .el-table__header .cell,
  .el-table .el-table__body .cell {
    text-align: center;
  }

  /deep/.el-table--enable-row-transition .el-table__body td {
    text-align: center;
  }

  .formItem {
    width: 51% !important;
  }

  /deep/.base_header_layout .find.el-button--primary {
    width: 30px;
    border-top-left-radius: 0px;
    border-bottom-left-radius: 0px;
  }
.findinput{
  margin-left: 20px;
}
  /deep/.base_header_layout .findinput input {
    border-top-right-radius: 0px;
    border-bottom-right-radius: 0px;
  }
   /deep/.title_css .el-dialog__header{
    text-align: center !important;
  }
  .select{
    width:400px;
  }
  .shdw-style {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    margin-top: 20px;
  }
   .ew-print {
    padding: 0 20px;
    margin-top: 10px;
    margin-bottom: 15px;

    // display: flex;
    // justify-content: space-between;
    // align-content: center;
    .row {
      display: flex;
      margin-top: 10px;
      align-items: center;
    }
  }

  .sh-address {
    display: flex;
  }

  .print-type-ew {
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
  }
</style>
