// 完善入库信息
<template>
  <div class="container">
    <el-row>
      <el-col :span="20">
        <h2 class="bg-left title">完善入库登记</h2>
      </el-col>
      <el-col :span="4" class="bg-right">
        <el-button
          class="bg-bottom"
          type="primary"
          size="small"
          @click="revert()"
          ><img
            width="6"
            height="10"
            style="vertical-align: bottom; margin-right: 3px"
            src="../../../public/img/lujing.png"
            alt=""
          />返回</el-button
        >
      </el-col>
    </el-row>

    <ws-form ref="dataList" :model="dataList" :rules="rules">
      <div class="basicInformation">
        <h2>
          {{ deptBudgetList1.warehouseName }}库
          <span class="position" v-show="this.$route.query.warehouseType == 1"> {{ deptBudgetList1.binNumber }}仓位 </span>
          <span v-show="this.$route.query.warehouseType == 2">(临)</span>
        </h2>
        <div class="small-title">基本信息</div>
        <ws-info-table>
          <!-- 货名 -->
          <ws-form-item label="货名" span="1">
            <ws-select
              v-model="dataList.goodsName"
              placeholder=""
              class="typeselect"
              @change="selectgoodsName"
            >
              <ws-option
                v-for="item in goodnameList"
                :key="item.constKey"
                :label="item.constValue"
                :value="item.constValue"
              />
            </ws-select>
          </ws-form-item>
          <!--毛重（吨）-->
          <ws-form-item label="毛重（吨）" span="1" prop="grossWeight">
            <ws-input
              @input="grossWeightchange"
              v-model="dataList.grossWeight"
              placeholder="请输入毛重"
              maxlength="20"
              size="small"
            />
          </ws-form-item>

          <!--皮重（吨）-->
          <ws-form-item
            label="皮重（吨）"
            span="1"
            prop="tare"
            class="readonly"
          >
            <ws-input
              @input="tarechange"
              v-model="dataList.tare"
              placeholder="请输入皮重"
              maxlength="100"
              size="small"
            />
          </ws-form-item>

          <!--净重（吨）-->
          <ws-form-item label="净重（吨）" span="1" prop="netWeight">
            <ws-input
              :readonly="readonly"
              v-model.number="dataList.netWeight"
              placeholder="不可编辑，自动计算"
              type="number"
              maxlength="120"
              size="small"
            />
          </ws-form-item>
          <!-- 品级 -->
          <ws-form-item label="品级" span="1" class="readonly">
            <ws-select
              v-model="dataList.grade"
              placeholder=""
              class="typeselect"
              @change="selectpackingMethod"
            >
              <ws-option
                v-for="item in gradeList"
                :key="item.constKey"
                :label="item.constValue"
                :value="item.constValue"
              />
            </ws-select>
          </ws-form-item>

         <!--经办人-->
          <ws-form-item label="经办人" span="1" prop="agent">
            <el-select
              v-model="dataList.agent"
              placeholder="请选择经办人"
              filterable
              :filter-method="dataFilter"
              @change="selectstaff"
            >
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.staffName"
                :value="item.staffName"
              />
            </el-select>
          </ws-form-item>
          <!--入库日期-->
          <ws-form-item
            label="入库日期"
            span="1"
            prop="inOutDate"
            class="deliverydate"
          >
            <ws-date-picker
              v-model="dataList.inOutDate"
              type="date"
              placeholder="请选择入库日期"
              value-format="yyyy-MM-dd"
            />
          </ws-form-item>
          <!-- 入库类型 -->
          <ws-form-item label="入库类型" span="1">
            <ws-select
              v-model="dataList.inOutType"
              placeholder=""
              class="typeselect"
              @change="selectstorageType"
            >
              <ws-option
                v-for="item in storageType"
                :key="item.constKey"
                :label="item.constValue"
                :value="item.constValue"
              />
            </ws-select>
          </ws-form-item>

          <!--车牌号-->
          <ws-form-item label="车牌号" span="1" prop="sourceGoods">
            <ws-input
              v-model="dataList.carNo"
              placeholder="请输入车牌号"
              maxlength="20"
              size="small"
            />
          </ws-form-item>

          <!--合同编号-->
          <!-- <ws-form-item label="合同编号" span="1" prop="contractNo">
            <ws-input
              v-model="dataList.contractNo"
              placeholder="请输入合同编号"
              maxlength="100"
              size="small"
            />
          </ws-form-item> -->
           <ws-form-item label="合同编号" span="1">
              <ws-select
                v-model="dataList.contractNo"
                placeholder="请选择合同编号"
                class="typeselect"
              >
                <ws-option
                  v-for="item in outContractNo"
                  :key="item.constKey"
                  :label="item.contractNo"
                  :value="item.contractNo"
                />
              </ws-select>
           </ws-form-item>
        </ws-info-table>
        <div warehouseType>
          <el-checkbox v-model="checked" checked>退库并出库</el-checkbox>
          <ws-info-table
            v-show="checked == true">
            <!-- 出库类型 -->
            <ws-form-item label="出库类型" span="1">
              <ws-select
                v-model="deptBudgetList.deliveryType"
                placeholder=""
                class="typeselect"
              >
                <ws-option
                  v-for="item in deliveryType"
                  :key="item.constKey"
                  :label="item.constValue"
                  :value="item.constValue"
                />
              </ws-select>
            </ws-form-item>
            <!-- 出库合同编号 -->
            <ws-form-item label="出库合同编号" span="1">
              <ws-select
                v-model="dataList.contractNo"
                placeholder="请选择合同编号或移库任务编号"
                class="typeselect"
              >
                <ws-option
                  v-for="item in outContractNo"
                  :key="item.constKey"
                  :label="item.contractNo"
                  :value="item.contractNo"
                />
              </ws-select>
            </ws-form-item>
          </ws-info-table>
        </div>
      </div>
      <div class="small-title">上传仓库照片</div>
      <ws-upload
        ref="upload"
        table-name="maintain_work_order"
        oss-key="mainPlan"
        :comp-id="compId"
        :appendix-ids="appendixIdsAdd"
        :vesselId="dataList.addressUrl"
        :size-limit="size"
        @uploadSuccess="uploadSuccess"
        @onChange="onChange"
        accept=".jpg, .jpeg, .png, .pdf, .doc, .zip, .rar"
      />
      <div class="small-title">化验数据（选填）</div>
      <div class="inspector">
        <!--质检员-->
        <ws-form-item label="质检员" span="1" prop="qualityInspector">
          <ws-input
            v-model="dataList.warehouseInOutDetail.qualityInspector"
            placeholder="请输入质检员姓名"
            maxlength="120"
            size="small"
          />
        </ws-form-item>
      </div>
      <div class="neifor">
        <ws-info-table>
          <!--水分（%）<=-->
          <ws-form-item label="水分（%）<=" span="1" prop="waterContent">
            <ws-input
              v-model="dataList.warehouseInOutDetail.waterContent"
              placeholder="请输入水分占比"
              maxlength="120"
              size="small"
            />
          </ws-form-item>
          <!--杂质（%）<=-->
          <ws-form-item label="杂质（%）<=" span="1" prop="impurity">
            <ws-input
              v-model="dataList.warehouseInOutDetail.impurity"
              placeholder="请输入杂质占比"
              maxlength="120"
              size="small"
            />
          </ws-form-item>
          <!--容重（克/升）>=-->
          <ws-form-item label="容重（克/升）>=" span="1" prop="bulkDensity">
            <ws-input
              v-model="dataList.warehouseInOutDetail.bulkDensity"
              placeholder="请输入容重"
              maxlength="120"
              size="small"
            />
          </ws-form-item>
          <!--霉变粒（%）<=-->
          <ws-form-item label="霉变粒（%）<=" span="1" prop="mildewGrain">
            <ws-input
              v-model="dataList.warehouseInOutDetail.mildewGrain"
              placeholder="请输入霉变粒占比"
              maxlength="120"
              size="small"
            />
          </ws-form-item>
          <!--热损伤（%）<=-->
          <ws-form-item label="热损伤（%）<=" span="1" prop="jiaorenli">
            <ws-input
              v-model="dataList.warehouseInOutDetail.jiaorenli"
              placeholder="请输入热损伤占比"
              maxlength="120"
              size="small"
            />
          </ws-form-item>
          <!--不完整粒（%）<=-->
          <ws-form-item label="不完整粒（%）<=" span="1" prop="imperfectGrain">
            <ws-input
              v-model="dataList.warehouseInOutDetail.imperfectGrain"
              placeholder="请输入不完整粒占比"
              maxlength="120"
              size="small"
            />
          </ws-form-item>
        </ws-info-table>
      </div>
      <div style="text-align: right; padding: 10px">
        <el-button
          class="bg-bottom-up"
          type="primary"
          size="small"
          @click="temporaryStorage()"
          >暂存</el-button
        >
        <el-button
          class="bg-bottom-up"
          type="primary"
          size="small"
          @click="submit()"
          >提交</el-button
        >
      </div>
    </ws-form>
  </div>
</template>
<script>
import {
  pullDown,
  addstorageputList,
  xialaNo,
  getstaff,
} from '@/model/warehouse/index'
import { downloadFile } from '@/utils/batchDown'
import Pagination from '@/components/Pagination'
import { mapActions, mapGetters, mapState } from 'vuex'
import WsUpload from '@/components/WsUpload'
// import { dayjs, fmoney, EventBus } from 'base-core-lib'
import { dayjs, EventBus } from 'base-core-lib'
export default {
  name: 'viewSpareMoney',
  components: {
    WsUpload,
    Pagination,
  },
  watch: {
    // vesselId(val) {
    //   this.getList()
    // },
    isShow(val) {
      this.showType = val
    },
  },
  computed: {
    ...mapGetters(['deptBudgetList']),
  },
  data() {
    return {
      //弹出框
      dialogViewSpareMoney: false,
      dialogApproveFormVisible: false,
      // 船舶类型
      monetaryKey: null,
      // 表格显示数据
      tableDate: [],
      // 是否显示
      showType: true,
      // 年
      year: '',
      deptBudgetTotal: 0,
      readonly: true,
      currentPage: 1,
      pageSize: 10,
      searchType: 1,
      searchKeyWord: '',
      contractType: 2,
      startDate: null,
      endDate: null,
      goodnameList: {},
      checked: true,

      staffList: [],
      options: [],
      storageType: [],
      deliveryType: [],
      outContractNo: [],
      // 提交类型
      submitType: true,
      storageType: [],
      appendixIdsAdd: '',
      uploadSuccess: {},
      warehouseInOutDetail: {},
      onChange: {},
      deptBudgetList1: [],
      gradeList: [],
      rules: {
        netWeight: [
          {
            required: true,
            type: 'number',
            message: '请输入活动名称',
            trigger: 'blur',
          },
        ],
      },
      size: 10,
      compId: sessionStorage.getItem('ws-pf_compId'),
      deptCircularPage: {},
      packtypeList: {},
      date: {
        year: dayjs().format('YYYY'),
        month: dayjs().format('MM'),
      },
      contractList: [],
      dataList: {
        id: '',
        grossWeight: '',
        contractNo: '',
        tare: '',
        netWeight: '',
        grade: '',
        agent: '',
        carNo: '',
        inOutDate: '',
        inOutType: '',
        goodsName: '',
        warehouseInOutDetail: {},
      },
      historyList: [],
      pickerBeginDateBefore: {
        disabledDate: (time) => {
          return time.getTime() > Date.now()
        },
      },
      accessoryTFs: false,
    }
  },
  activated() {
    this.deptBudgetList1.warehouseName = this.$route.query.warehouseName
    this.deptBudgetList1.binNumber = this.$route.query.binNumber
    this.getList()
    this.dataList.id = this.$route.query.id
    this.dataList.grossWeight = this.$route.query.grossWeight
    this.dataList.contractNo = this.$route.query.contractNo
    this.dataList.baseId = this.$route.query.baseId
    this.dataList.positionId = this.$route.query.positionId
    this.dataList.warehouseName = this.$route.query.warehouseName
    this.dataList.binNumber = this.$route.query.binNumber
    this.dataList.tare = this.$route.query.tare
    this.dataList.netWeight = this.$route.query.netWeight
    this.dataList.grade = this.$route.query.grade
    this.dataList.agent = this.$route.query.agent
    this.dataList.carNo = this.$route.query.carNo
    this.dataList.inOutDate = this.$route.query.inOutDate
    this.dataList.contractNo = this.$route.query.contractNo
    this.dataList.inOutType = this.$route.query.inOutType
    this.dataList.compId = this.$route.query.compId
    this.dataList.goodsName = this.$route.query.goodsName
    this.dataList.goodsNameKey = Number(this.$route.query.goodsNameKey)
    this.dataList.inOutFlag = this.$route.inOutFlag
    this.dataList.inOutTypeKey = Number(this.$route.query.inOutTypeKey)
    this.dataList.statusFlag = this.$route.statusFlag
    this.dataList.warehouseInOutDetail = this.$route.query.warehouseInOutDetail
    this.deptBudgetList.warehouseType = this.$route.query.warehouseType
  },
  methods: {
    //返回按钮
    revert() {
      this.$router.go(-1)
    },
    dataFilter(val) {
      // console.log(val,"名")
      this.deptBudgetList.staffList = val
      if (val) {
        //val存在
        this.options = this.staffList.filter((item) => {
          if (
            !!~item.staffName.indexOf(val) ||
            !!~item.staffName.toUpperCase().indexOf(val.toUpperCase())
          ) {
            return true
          }
        })
      } else {
        //val为空时，还原数组
        this.options = this.staffList
      }
    },
    selectstaff(e) {
      for (var i = 0; i < this.staffList.length; i++) {
        if (this.staffList[i].staffName == e) {
          this.deptBudgetList.personChargeKey = this.staffList[i].staffId
        }
      }
    },
    //暂存按钮
    temporaryStorage() {
      this.$confirm(`暂存后可在待完成页面查看，确定暂存`, {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        type: 'warning',
      })
        .then(() => {
          this.$refs.dataList.validate((valid) => {
            if (valid) {
              this.dataList.compId = sessionStorage.getItem('ws-pf_compId')
              this.dataList.inOutFlag = 2
              this.dataList.statusFlag = 1
              addstorageputList(this.dataList)
                .toPromise()
                .then((response) => {
                  this.$message.success('暂存成功')
                  this.$router.push({ path: 'warehouseManagementList' })
                })
            } else {
              EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
              return false
            }
          })
        })
        .catch(() => {
          return false
        })
    },
    //提交按钮
    submit() {
      if (!this.dataList.goodsName) {
        this.$message({
          message: '货名不能为空',
          type: 'warning',
        })
        return
      }
      if (!this.dataList.grossWeight) {
        this.$message({
          message: '毛重不能为空',
          type: 'warning',
        })
        return
      }
      if (
        this.dataList.grossWeight <= 0 ||
        this.dataList.grossWeight > 10000 ||
        (String(this.dataList.grossWeight).indexOf('.') != -1 &&
          String(this.dataList.grossWeight).length -
            (String(this.dataList.grossWeight).indexOf('.') + 1) >
            3)
      ) {
        this.$message({
          message: '毛重输入错误',
          type: 'warning',
        })
        return
      }

      if (
        this.dataList.tare < 0 ||
        this.dataList.tare > 10000 ||
        (String(this.dataList.tare).indexOf('.') != -1 &&
          String(this.dataList.tare).length -
            (String(this.dataList.tare).indexOf('.') + 1) >
            3)
      ) {
        this.$message({
          message: '皮重输入错误',
          type: 'warning',
        })
        return
      }
      if (!this.dataList.agent) {
        this.$message({
          message: '经办人不能为空',
          type: 'warning',
        })
        return
      }
      if (this.dataList.agent.length < 2 || this.dataList.agent.length > 10) {
        this.$message({
          message: '经办人输入有误',
          type: 'warning',
        })
        return
      }
      if (!this.dataList.grade) {
        this.$message({
          message: '品级不能为空！',
          type: 'warning',
        })
        return
      }
      if (!this.dataList.inOutDate) {
        this.$message({
          message: '入库日期不能为空！',
          type: 'warning',
        })
        return
      }
      if (!this.dataList.inOutType) {
        this.$message({
          message: '入库类型不能为空！',
          type: 'warning',
        })
        return
      }
      if (!this.dataList.carNo) {
        this.$message({
          message: '车牌号不能为空',
          type: 'warning',
        })
        return
      }
      if (this.dataList.carNo.length > 7) {
        this.$message({
          message: '车牌号输入错误,请输入7个字符之内',
          type: 'warning',
        })
        return
      }
      if (!this.dataList.contractNo) {
        this.$message({
          message: '合同编号不能为空',
          type: 'warning',
        })
        return
      }
      if (
        this.dataList.contractNo.length < 6 ||
        this.dataList.contractNo.length > 20
      ) {
        this.$message({
          message: '合同编号长度不符合要求,请输入6-20个字符之内',
          type: 'warning',
        })
        return
      }

      if (this.dataList.netWeight > this.$route.query.capacity) {
        this.$message({
          message: '入库量大于该仓库容量！',
          type: 'warning',
        })
        return
      }
      //自检员
      if (this.dataList.warehouseInOutDetail.qualityInspector) {
        if (
          this.dataList.warehouseInOutDetail.qualityInspector.length < 2 ||
          this.dataList.warehouseInOutDetail.qualityInspector.length > 10
        ) {
          this.$message({
            message: '质检员姓名长度错误！',
            type: 'warning',
          })
          return
        }
      }
      if (this.dataList.warehouseInOutDetail.waterContent) {
        if (isNaN(this.dataList.warehouseInOutDetail.waterContent)) {
          this.$message({
            message: '水分（%）非数字!',
            type: 'warning',
          })
          return
        }
        if (
          this.dataList.warehouseInOutDetail.waterContent < 1 ||
          this.dataList.warehouseInOutDetail.waterContent > 40 ||
          (String(this.dataList.warehouseInOutDetail.waterContent).indexOf(
            '.'
          ) != -1 &&
            String(this.dataList.warehouseInOutDetail.waterContent).length -
              (String(this.dataList.warehouseInOutDetail.waterContent).indexOf(
                '.'
              ) +
                1) >
              2)
        ) {
          this.$message({
            message: '水分（%）输入错误! 取值范围1-40之间且可以保留2小数',
            type: 'warning',
          })
          return
        }
      }

      //杂质
      if (this.dataList.warehouseInOutDetail.impurity) {
        if (isNaN(this.dataList.warehouseInOutDetail.impurity)) {
          this.$message({
            message: '杂质（%）非数字!',
            type: 'warning',
          })
          return
        }
        if (
          this.dataList.warehouseInOutDetail.impurity < 1 ||
          this.dataList.warehouseInOutDetail.impurity > 40 ||
          (String(this.dataList.warehouseInOutDetail.impurity).indexOf('.') !=
            -1 &&
            String(this.dataList.warehouseInOutDetail.impurity).length -
              (String(this.dataList.warehouseInOutDetail.impurity).indexOf(
                '.'
              ) +
                1) >
              2)
        ) {
          this.$message({
            message: '杂质（%）输入错误! 取值范围1-40之间且可以保留2小数',
            type: 'warning',
          })
          return
        }
      }
      //霉变
      if (this.dataList.warehouseInOutDetail.mildewGrain) {
        if (isNaN(this.dataList.warehouseInOutDetail.mildewGrain)) {
          this.$message({
            message: '霉变粒（%）非数字!',
            type: 'warning',
          })
          return
        }
        if (
          this.dataList.warehouseInOutDetail.mildewGrain < 1 ||
          this.dataList.warehouseInOutDetail.mildewGrain > 40 ||
          (String(this.dataList.warehouseInOutDetail.mildewGrain).indexOf(
            '.'
          ) != -1 &&
            String(this.dataList.warehouseInOutDetail.mildewGrain).length -
              (String(this.dataList.warehouseInOutDetail.mildewGrain).indexOf(
                '.'
              ) +
                1) >
              2)
        ) {
          this.$message({
            message: '霉变粒（%）输入错误! 取值范围1-40之间且可以保留2小数',
            type: 'warning',
          })
          return
        }
      }

      //热损伤
      if (this.dataList.warehouseInOutDetail.jiaorenli) {
        if (isNaN(this.dataList.warehouseInOutDetail.jiaorenli)) {
          this.$message({
            message: '热损伤（%）非数字!',
            type: 'warning',
          })
          return
        }
        if (
          this.dataList.warehouseInOutDetail.jiaorenli < 1 ||
          this.dataList.warehouseInOutDetail.jiaorenli > 40 ||
          (String(this.dataList.warehouseInOutDetail.jiaorenli).indexOf('.') !=
            -1 &&
            String(this.dataList.warehouseInOutDetail.jiaorenli).length -
              (String(this.dataList.warehouseInOutDetail.jiaorenli).indexOf(
                '.'
              ) +
                1) >
              2)
        ) {
          this.$message({
            message: '热损伤（%）输入错误! 取值范围1-40之间且可以保留2小数',
            type: 'warning',
          })
          return
        }
      }

      //不完整粒（%）
      if (this.dataList.warehouseInOutDetail.imperfectGrain) {
        if (isNaN(this.dataList.warehouseInOutDetail.imperfectGrain)) {
          this.$message({
            message: '不完整粒（%）非数字!',
            type: 'warning',
          })
          return
        }
        if (
          this.dataList.warehouseInOutDetail.imperfectGrain < 1 ||
          this.dataList.warehouseInOutDetail.imperfectGrain > 40 ||
          (String(this.dataList.warehouseInOutDetail.imperfectGrain).indexOf(
            '.'
          ) != -1 &&
            String(this.dataList.warehouseInOutDetail.imperfectGrain).length -
              (String(
                this.dataList.warehouseInOutDetail.imperfectGrain
              ).indexOf('.') +
                1) >
              2)
        ) {
          this.$message({
            message: '不完整粒（%）输入错误! 取值范围1-40之间且可以保留2小数',
            type: 'warning',
          })
          return
        }
      }
      //容重
      if (this.dataList.warehouseInOutDetail.bulkDensity) {
        if (isNaN(this.dataList.warehouseInOutDetail.bulkDensity)) {
          this.$message({
            message: '容重（克/升）非数字!',
            type: 'warning',
          })
          return
        }
        if (
          this.dataList.warehouseInOutDetail.bulkDensity < 1 ||
          this.dataList.warehouseInOutDetail.bulkDensity > 40 ||
          (String(this.dataList.warehouseInOutDetail.bulkDensity).indexOf(
            '.'
          ) != -1 &&
            String(this.dataList.warehouseInOutDetail.bulkDensity).length -
              (String(this.dataList.warehouseInOutDetail.bulkDensity).indexOf(
                '.'
              ) +
                1) >
              0)
        ) {
          this.$message({
            message: '容重（克/升）输入错误! 取值范围1-40之间且是整数',
            type: 'warning',
          })
          return
        }
      }
      this.$confirm(`确定提交入库信息`, {
        cancelButtonText: '取消',
        confirmButtonText: '确定',
        type: 'warning',
      })
        .then(() => {
          this.$refs.dataList.validate((valid) => {
            if (valid) {
              this.dataList.compId = sessionStorage.getItem('ws-pf_compId')
              this.dataList.inOutFlag = 2
              this.dataList.statusFlag = 3
              addstorageputList(this.dataList)
                .toPromise()
                .then((response) => {
                  this.$message.success('添加成功')
                  this.$router.push({ path: 'warehouseManagementList' })
                })
            } else {
              EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
              return false
            }
          })
        })
        .catch(() => {
          return false
        })
    },
    //暂存按钮
    returnWarehouse() {
      this.$refs.dataList.validate((valid) => {
        if (valid) {
          this.dataList.compId = sessionStorage.getItem('ws-pf_compId')
          this.dataList.statusFlag = 1
          addstorageputList(this.dataList)
            .toPromise()
            .then((response) => {
              this.$message.success('添加成功')
              this.$router.push({ path: 'warehouseManagementList' })
            })
        } else {
          EventBus.$emit('error', this.$t('showMessage.asteriskRequired'))
          return false
        }
      })
    },
    tarechange(e) {
      if (this.dataList.grossWeight && this.dataList.tare) {
        this.dataList.netWeight = Number(
          this.dataList.grossWeight - this.dataList.tare
        )
      }
    },
    grossWeightchange(e) {
      if (this.dataList.grossWeight && this.dataList.tare) {
        this.dataList.netWeight = Number(
          this.dataList.grossWeight - this.dataList.tare
        )
      }
    },
    selectgoodsName(e) {
      for (var i = 0; i < this.goodnameList.length; i++) {
        if (this.goodnameList[i].constValue == e) {
          this.dataList.goodsNameKey = this.goodnameList[i].constKey
        }
      }
    },
    selectpackingMethod(e) {
      for (var i = 0; i < this.packtypeList.length; i++) {
        if (this.packtypeList[i].constValue == e) {
          this.dataList.packingMethodKey = this.packtypeList[i].constKey
        }
      }
    },
    selectstorageType(e) {
      for (var i = 0; i < this.storageType.length; i++) {
        if (this.storageType[i].constValue == e) {
          this.dataList.inOutTypeKey = this.storageType[i].constKey
        }
      }
    },
    handleClose() {
      this.accessoryTFs = false
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`)
      this.pageSize = val
      this.getList()
    },
    handleCurrentChange(val) {
      this.currentPage = val
      console.log(`当前页: ${val}`)
      this.getList()
    },
    getList() {
      // 货名
      pullDown({ constId: 'CON2' })
        .toPromise()
        .then((response) => {
          this.goodnameList = response
        })
      // 品级
      pullDown({ constId: 'CON3' })
        .toPromise()
        .then((response) => {
          this.gradeList = response
        })
      // 类型
      if (this.$route.query.warehouseType == '1') {
        pullDown({ constId: 'CON5' })
          .toPromise()
          .then((response) => {
            this.storageType = response
          })
      } else if (this.$route.query.warehouseType == '2') {
    
        //临时库入库类型
        pullDown({ constId: 'WARE1' })
          .toPromise()
          .then((response) => {
            this.storageType = response
          })
        //临时库出库类型
        pullDown({ constId: 'WARE2' })
          .toPromise()
          .then((response) => {
            this.deliveryType = response
          })
      }
      //合同编号
      xialaNo({ compId: sessionStorage.getItem('ws-pf_compId') })
        .toPromise()
        .then((response) => {
          this.outContractNo = response
        })
      //经办人
      getstaff({ compId: sessionStorage.getItem('ws-pf_compId') })
        .toPromise()
        .then((response) => {
          this.options = response
          this.staffList = response
          //  this.agent = response
        })
    },
    selecttaskType(e) {
      for (var i = 0; i < this.taskTypeList.length; i++) {
        if (this.taskTypeList[i].value == e) {
          this.searchType = this.taskTypeList[i].type
        }
      }
    },
    fujian(row) {
      if (
        row.receiveAttachmentPath === null ||
        row.receiveAttachmentPath === ''
      ) {
        EventBus.$emit(
          'warning',
          this.$t('system.noticeCircular.NoInformation')
        )
      } else {
        this.accessoryTFs = true
      }
      this.appendixIdss = row.receiveAttachmentPath
    },
    handleExamine(row) {
      this.$router.push({
        name: 'salesContractExamine',
        query: { id: row.id },
      })
    },

    // 关闭 dialog时 处理文件url 初始化upload组件
    handleCloe() {
      this.dialogViewSpareMoney = false
    },
    history(row) {
      console.log(row)
      billoperatehis({ id: row.id })
        .toPromise()
        .then((response) => {
          this.historyList = response
        })
    },

    async exportlist() {
      const { data } = await export1(
        {
          compId: sessionStorage.getItem('ws-pf_compId'),
          contractType: this.contractType,
          currentPage: this.currentPage,
          pageSize: this.pageSize,
          searchType: this.searchType,
          searchKeyWord: this.searchKeyWord,
          startDate: this.startDate,
          endDate: this.endDate,
        },
        {},
        { responseType: 'blob' }
      ).toPromise()
      downloadFile({
        res: data,
        fileName: `${
          this.date.year + (this.date.month ? `-${this.date.month}` : '')
        }_采购合同`,
        type: 'xls',
      })
    },

    // deletecontract(){},
    //删除
    approve() {},
    listQuery() {},
    total() {},
    clearfiltQuery() {},
    selectCrtDuty() {},
  },
}
</script>
<style lang="scss" scoped>
/deep/.basicInformation {
  .ws-info-table {
    border: none;
  }
  .el-form-item {
    width: 33.3333%;
    border: none;
    .el-form-item__label {
      background: transparent;
      border: none;
    }
    .el-form-item__content {
      border: none;
    }
  }
}
.title {
  position: relative;
  padding-left: 10px;
}
.title::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 30px;
  background: #5473e8;
  position: absolute;
  left: 0;
}
.el-form {
  padding: 0 10%;
}
.el-button--primary {
  background-color: #5878e8;
  border-color: #5878e8;
}
.el-col {
  background: #f6f7fc;
}
.bg-right {
  text-align: right;
  padding: 16px 20px;
}
.center {
  position: relative;
  top: 50px;
  width: 40%;
  height: 2000px;
  margin: 0 auto;
}
/deep/.el-form-item__label {
  width: 160px;
}
.inspector {
  width: 50%;
}
//质检员
/deep/[data-v-58803672] .el-form-item__label {
  width: 60px;
}
[data-v-58803672] .el-form-item__label {
  width: 60px;
}
//选填
/deep/.el-form-item {
  width: 50%;
}
.container {
  overflow: scroll;
  height: 120vh;
}
/deep/.ws-info-table .el-form-item .el-form-item__label {
  text-align: center;
}
.deliverydate {
  display: inline-block;
  width: 10%;
}
.center {
  margin-top: -60px;
  width: 80%;
}
//仓位
.position {
  width: 52px;
  height: 20px;
  background: #afb5cb;
  border-radius: 2px;
  font-size: 12px;
  font-family: PingFangSC-Medium, PingFang SC;
  color: #ffffff;
  line-height: 20px;
}
//表格文字
/deep/.ws-info-table .el-form-item .el-form-item__label {
  text-align: left;
  font-size: 14px;
  font-family: PingFangSC-Regular, PingFang SC;
  font-weight: 400;
  color: #8890b1;
  line-height: 16px;
}
//质检员
.inspector .el-form-item__content {
  text-align: left;
  margin-left: 0px;
}
.small-title {
  position: relative;
  padding: 10px;
  font-weight: 600;
}
.small-title::before {
  position: absolute;
  content: '';
  display: block;
  background: #5473e8;
  width: 4px;
  height: 14px;
  left: 0px;
  top: 13px;
}
//下面列表
.neifor {
  width: 80%;
  background-color: #f6f7fc;
}
/deep/.neifor .ws-info-table .el-form-item .el-form-item__label {
  width: 35%;
  text-align: center;
}
/deep/.neifor .ws-info-table .el-form-item .el-form-item__content {
  width: 60%;
  background-color: #f6f7fc;
}
/deep/.neifor .el-input--small .el-input__inner {
  width: 100%;
}
.el-input__inner {
  width: 150px;
}
</style>
