
<template>
  <div class="app-container">
    <el-form :model="form" :rules="rules" ref="form" label-width="100px" label-position="right" size="mini">
      <div class="filter-container clearfix">
        <template v-if="orderCategory == 1">
          <el-button type="success" size="mini" @click="save(1)" :disabled="clickLoading">新建保存</el-button>
        </template>
        <template v-else>
          <el-button type="primary" size="mini" @click="editOrder(1)" :disabled="clickLoading">修改保存</el-button>
        </template>
        <el-select
          size="mini"
          v-model="form.orderState"
          placeholder="请选择订单状态">
          <el-option
            label="待审核"
            value="0">
          </el-option>
          <el-option
            label="已审核"
            value="1">
          </el-option>
        </el-select>
        <span v-if="idOrder">
          订单编号：{{ orderCode }}
        </span>
<!--        <template v-if="orderCategory != 1">-->
<!--            <span v-if="form.originFileLink"><el-link-->
<!--              :href="form.originFileLink"-->
<!--              target="_blank">{{ form.fileDescription }}</el-link></span>-->
<!--          <span v-else style="color: red;font-weight: 700">订单未上传原图文件</span>-->
<!--        </template>-->
      </div>
      <el-row :gutter="0" type="flex" >
        <el-col :span="24">
          <div class="tip">基本信息</div>
        </el-col>
      </el-row>
      <el-row :gutter="0">
        <el-col :span="4">
          <el-form-item  size="small" label="下单客户">
            <el-input
              v-model="form.clientName"
              disabled
              class="input-with-select"
              @click.native="createInnerVisible = true;innerType = 2;innerTitle ='选择客户'"
            >
              <el-button
                slot="append"
                @click="createInnerVisible = true;innerType = 2;innerTitle ='选择客户'">选择
              </el-button>
            </el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item  label-width="75px" size="small" label="产品类型">
            <el-select
              filterable
              v-model="form.productName">
              <el-option
                v-for="item in productNameOptions"
                :key="item.id"
                :label="item.dictLabel"
                :value="item.dictValue">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item label-width="75px"  size="small" label="产品名称">
            <el-input v-model="form.orderName" ></el-input><!--新建时下拉选择，其他时候不能编辑-->
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label-width="50px"  size="small" label="联数">
            <el-select
              filterable
              v-model="form.receiptsCount">
              <el-option
                v-for="item in receiptsCountOptions"
                :key="item.id"
                :label="item.dictLabel"
                :value="item.dictValue">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item  label-width="75px"  size="small" label="材料类型">
            <el-select
              filterable
              allow-create
              v-model="form.paperName"
            @input.native="selectBlur1($event)">
              <el-option
                v-for="item in paperNameOptions"
                :key="item.id"
                :label="item.dictLabel"
                :value="item.dictValue">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label-width="75px"  size="small" label="每本页数">
            <el-select
              filterable
              allow-create
              v-model="form.pageCount"
              @input.native="selectBlur2($event)">
              <el-option
                v-for="item in pageCountOptions"
                :key="item.id"
                :label="item.dictLabel"
                :value="item.dictValue">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item label-width="75px"  size="small" label="印刷颜色">
            <el-select
              filterable
              allow-create
              v-model="form.printColor"
              @input.native="selectBlur3($event)">
              <el-option
                v-for="item in printColorOptions"
                :key="item.id"
                :label="item.dictLabel"
                :value="item.dictValue">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="10">
          <el-form-item  size="small" label="生产工艺">
            <el-checkbox v-model="form.printCodeFlag" :true-label="1" :false-label="0">打码</el-checkbox>
            <el-checkbox v-model="form.printCoverFlag" :true-label="1" :false-label="0">封面</el-checkbox>
            <el-checkbox v-model="form.printMatFlag" :true-label="1" :false-label="0">加垫</el-checkbox>
            <el-checkbox v-model="form.printNotCodeFlag" :true-label="1" :false-label="0">不打码</el-checkbox>
            <el-checkbox v-model="form.printAllCoverFlag" :true-label="1" :false-label="0">封面全包</el-checkbox>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="0">
        <el-col :span="24">
          <div class="tip2">报价信息</div>
        </el-col>
      </el-row>
      <el-row :gutter="24" type="flex" justify="left">
        <el-col :span="5">
          <el-form-item size="small" label="数量">
            <el-input type="number"  v-model="form.printQty" placeholder="数量" style="width: 53%" @input="calculatePrintMoneyTotal"></el-input>
            <el-input v-model="form.printQtyUnit" placeholder="单位" style="width: 20%"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item size="small" label="单价">
            <el-input type="number" v-model="form.printPrice" @input="calculatePrintMoneyTotal"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item size="small" label="总金额">
            <el-input type="number" v-model="form.printMoneyTotal" @input="calculatePrintPrice"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="3">
          <el-form-item size="small" label="已收金额" class="item">
            <el-input type="number" v-model="form.payMoney"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24" type="flex" justify="left">
        <el-col :span="5">
          <el-form-item size="small" label="送货方式">
            <el-select
              filterable
              allow-create
              v-model="form.sendKind">
              <el-option
                v-for="item in sendKindOptions"
                :key="item.id"
                :label="item.dictLabel"
                :value="item.dictValue">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="9">
          <el-form-item size="small" label="送货地址">
            <el-input v-model="form.sendAddress"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24" type="flex" justify="left">
        <el-col :span="14">
          <el-form-item size="small" label="备注">
            <el-input type="textarea" :rows="2"  v-model="form.orderMemo"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
<!--      <el-row :gutter="0" type="flex" justify="left">-->
<!--        <el-col :span="4">-->
<!--          <el-form-item size="small" label="上传图片">-->
<!--            <el-button size="mini" type="success" round>选择</el-button>-->
<!--            <el-button size="mini" type="primary" round>查看</el-button>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--        <el-col :span="4">-->
<!--          <el-form-item size="small" label="上传附件">-->
<!--            <el-button size="mini" type="success" round>选择</el-button>-->
<!--            <el-button size="mini" type="primary" round>查看</el-button>-->
<!--          </el-form-item>-->
<!--        </el-col>-->
<!--      </el-row>-->
      <el-row :gutter="0" type="flex" justify="left">
            <el-col :span="24">
              <div class="tip3">外发信息</div>
        </el-col>
      </el-row>
      <el-row :gutter="2" type="flex" justify="left">
        <el-col :span="15">
          <el-form-item size="small" label="">
            <el-radio-group v-model="form.orderKind">
              <el-radio :label="0">常规</el-radio>
              <el-radio :label="1">销售</el-radio>
              <el-radio :label="2">自产</el-radio>
              <el-radio :label="3">外发</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24" type="flex" justify="left">
        <el-col :span="4">
          <el-form-item size="small" label="部门">
            <el-input v-model="form.outWorkDept"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item size="small" label="供货商">
            <el-input v-model="form.outWorkFactory"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24" type="flex">
        <el-col :span="4">
          <el-form-item size="small" label="数量">
            <el-input type="number" v-model="form.outQty" @input="calculateOutMoneyTotal"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item size="small" label="单价">
            <el-input type="number" v-model="form.outPrice" @input="calculateOutMoneyTotal"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item size="small" label="金额">
            <el-input type="number" style="width: 145%" v-model="form.outMoneyTotal" @input="calculateOutPrice"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item size="small" label="运费">
            <el-input type="number" v-model="form.outSendMoney" @input="calculateOrderGrossProfitRate"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item size="small" label="交期">
            <el-date-picker
              v-model.trim="form.sendDate"
              type="date"
              :editable="false"
              value-format='yyyy-MM-dd'
              placeholder="选择日期"
              align="right"
              :picker-options="pickerOptions"
              style="width: 140px">
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item size="small" label="提点">
            <el-input v-model="form.outAddress"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="24" type="flex" justify="left">
        <el-col :span="13">
          <el-form-item size="small" label="外发备注">
            <el-input type="textarea" :rows="2"  v-model="form.outMemo"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="0" type="flex" justify="left">
          <el-col :span="24">
            <div class="tip4">成本信息</div>
          </el-col>
      </el-row>
      <el-row :gutter="2" type="flex" justify="left">
        <el-col :span="4">
          <el-form-item size="small" label="合计成本">
            <el-input type="number" v-model="form.orderCost" @input="calculateOrderGrossProfitRate"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item size="small" label="毛利">
            <el-input type="number" :disabled="true" v-model="form.orderGrossProfit"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="4">
          <el-form-item size="small" label="毛利率">
            <el-input type="number" :disabled="true" v-model="form.orderGrossProfitRate">
              <template slot="append">%</template>
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <el-dialog :title="innerTitle" :append-to-body="true" :visible.sync="createInnerVisible">
      <clientInfo v-if="innerType == 2" :is-choose="true" @chooseClient='chooseClient'></clientInfo>
    </el-dialog>
  </div>
</template>

<script>
import {
  addPrintOrder, updatePrintOrder,
  reprintOrder, orderFormToken,
  getPrintOrderInfo
} from '@/api/order/orderDetail.js'
import Pagination from '@/components/Pagination'
import { regionData, CodeToText, TextToCode } from 'element-china-area-data'
import { getDictTypeInfo } from '@/api/productFile/partWorkProcessInfo'
import Addressdny from '@/components/Dialog/Addressdny'
import { checkCompleteDispatchOrder } from '@/api/order/tobeReviewed'
import DeliveryNotice from '@/components/deliveryNotice/deliveryNotice';
import clientInfo from '@/views/doc/client/clientList'

const form = {
  /* 订单信息*/
  orderState: '0',
  idClient: '',
  clientName: '',
  productName: '',
  orderName: '',
  receiptsCount: '',
  paperName: '',
  pageCount: '',
  printColor: '',
  printCodeFlag: '',
  printCoverFlag: '',
  printMatFlag: '',
  printNotCodeFlag: '',
  printAllCoverFlag: '',
  printQty: 0,
  printQtyUnit: '',
  printPrice: 0,
  printMoneyTotal: 0,
  payMoney: 0,
  sendKind: '',
  sendAddress: '',
  orderMemo: '',
  orderKind: '',
  outWorkDept: '',
  outWorkFactory: '',
  outQty: 0,
  outPrice: 0,
  outMoneyTotal: 0,
  outSendMoney: 0,
  sendDate: '',
  sendDatelong: '',
  outAddress: '',
  outMemo: '',
  orderCost: '',
  orderGrossProfit: '',
  orderGrossProfitRate: '',
  versionCode: ''
}

export default {
  components: {
    Addressdny,
    Pagination, clientInfo
  },
  props: {
    isEdit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    // 验证金额
    const validateMoney = (rule, value, callback) => {
      // console.log(rule)
      // console.log(value)
      if (value == null) {
        callback(new Error('金额不能为空'))
      } else if ((value + '').indexOf('.') == -1) {
        if (typeof value === 'string') {
          value = Number(value)
        }
        value = (value).toFixed(2) // 不足补位
        var name = rule.fullField
        this.form[name] = value
        callback()
      } else if (value.split('.').length > 2) {
        callback(new Error('输入正确格式的金额')) // 防止输入多个小数点
      } else {
        value = Math.round(value * Math.pow(10, 2)) / Math.pow(10, 2) // 四舍五入
        value = Number(value).toFixed(2) // 不足补位
        var name = rule.fullField
        this.form[name] = value
        callback()
      }
    }
    return {
      balanceSpan: false,
      balanceMoney: '',
      innerTitle: '',
      innerType: 2,
      createInnerVisible: false,
      PriceInfo: '',
      valueTime: '',
      formToken: '',
      orderCategory: 1, // 1.新建，2.修改
      editType: 1, //1 正常，2补印
      versionCode: '',
      pageFrom: 0, //0普通 1待编辑页面 2待审核页面
      baseInfo: {},
      idOrder: '',
      dialogStatus: 1, // 1增加，2修改
      dialogTitle: '',
      listLoading: false,
      packrequireList: [], // 打包要求列表
      // 基本信息
      form: Object.assign({}, form),
      orderPrintOptions: [],
      productNameOptions: [], //产品类型
      productNameOption: [],
      receiptsCountOptions: [], //联数
      receiptsCountOption: [],
      paperNameOptions: [],  //材料类型
      paperNameOption: [],
      pageCountOptions: [],  //每本页数
      pageCountOption: [],
      printColorOptions: [],  //印刷颜色
      printColorOption: [],
      printQtyOptions: [],  //数量
      printQtyOption: [],
      sendKindOptions: [],  //送货方式
      sendKindOption: [],
      packingMethodOptions: [],
      parameterChooseVisible: false, // 参数选择弹窗
      parameterChooseType: 1,
      parameterList: [],
      parametersearch: {
        keyWord: ''
      },

      processChooseVisible: false, // 工序辅料选择弹窗
      materialTypeIds: '',
      processVisible: false, // 增加工序弹窗
      processList: [],
      processSearch: {
        keyWord: '',
        specialFlag: 1,
        voidFlag: 0
      },

      copeNumVisible: false, // 复制部件数量弹窗
      copeNum: '',
      copeIndex: '', // 复制部件的index值

      // 部件角标
      parameterIndex1: 0,
      parameterIndex2: 0,
      partId: '',
      parameterId: '',
      // 工序
      processIndex: 0,

      name: '',
      // activeNames: ['0_1', '0_2'],
      sums: '',

      // 时间选项快捷方式
      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
        }
      },

      addressType: 1,

      // 省市区选项
      addressOption: [],
      // 发货方式
      sendKinds: [],
      // 发货区域
      shipAreaList: [],
      option: regionData,
      selectedOptions: '',
      addressVisible: false,

      /* 新建订单*/
      // 部件信息
      productInfo: [], // 产品信息
      partListNew: [],
      partProcessList: [], // 部件参数列表
      selectedProcessList: [], // 选中部件参数列表
      bInRemoving: false, // 是否在删除部件事件中

      // 文件上传
      files: [],
      fileList: [],
      fileKind: 0,
      fileDescription: '',
      showUpload: true,

      // 点击等待
      clickLoading: false,

      timer: '',

      commitVisible: false,
      commitInfo: {
        needImageProcess: 1,
        infoList: []
      },
      hasFile: false,
      jsTotalMoney: 0,

      // 验证规则
      rules: {
        orderName: [{ required: true, trigger: 'blur', message: '请填写订单名称' }],
        cutKind: [{ required: true, trigger: 'blur', message: '请选择' }],
        boxRequire: [{ required: true, trigger: 'blur', message: '请选择' }],
        orderMoneyTotal: [{ required: true, trigger: 'blur', validator: validateMoney }],
        orderMoneyPre: [{ trigger: 'blur', validator: validateMoney }],
        orderMoneyPrint: [{ trigger: 'blur', validator: validateMoney }],
        orderMoneyProcess: [{ trigger: 'blur', validator: validateMoney }],
        deliverDate: [{ required: true, trigger: 'blur', message: '请选择交货时间' }]
      }
    }
  },
  created() {
    this.idOrder = this.$route.query.id
    this.orderCode = this.$route.query.orderCode
    this.editType = this.$route.query.editType
    this.versionCode = this.$route.query.versionCode
    this.pageFrom = this.$route.query.pageFrom
    this.orderCategory = this.$route.query.orderCategory
  },
  mounted() {
    // console.log(this.$route.params.info);
    this.tempRoute = Object.assign({}, this.$route)
    this.init()
    if (this.orderCategory != 1) {
      this.setTagsViewTitle()
    }
    this.getToken()
  },
  watch: {
  },
  methods: {
    loadNumber: function(event) {
      var el = event.currentTarget;
      var elValue = el.value;
      var reg = /^((?!0)\d{1,2}|100)$/;
      if (!elValue.match(reg)) {
        elValue = '';
        return false;
      } else {
        return true;
      }

    },
    calculatePrintMoneyTotal() {
      const _that = this;
      let printQty = _that.form.printQty;
      let printPrice = _that.form.printPrice;
      let printMoneyTotal = 0;
      if (printQty === null || printPrice === null ||printQty === '' || printPrice === '') {
        return;
      } else {
        printMoneyTotal = printQty * printPrice;
        _that.form.printMoneyTotal = printMoneyTotal.toFixed(2);
        if (_that.form.printMoneyTotal <= 0 ) {
        this.$message.warning('请注意，订单总金额是0');
          }
        _that.calculateOrderGrossProfitRate();
      }
    },
    calculatePrintPrice() {
      const _that = this;
      let printQty = _that.form.printQty;
      let printPrice = 0;
      printPrice = _that.form.printMoneyTotal / printQty;
      _that.form.printPrice = printPrice.toFixed(2);
      _that.calculateOrderGrossProfitRate();
    },
    calculateOutMoneyTotal() {
      const _that = this;
      let outQty = _that.form.outQty;
      let outPrice = _that.form.outPrice;
      if (outQty === null || outPrice === null ||outQty === '' || outPrice === '') {
        return;
      } else {
      _that.form.outMoneyTotal = (outQty * outPrice).toFixed(2);
      if (_that.form.outMoneyTotal <= 0 ) {
        this.$message.warning('请注意，外协费用是0');
      }
      _that.calculateOrderGrossProfitRate();
      }
    },
    calculateOutPrice() {
      const _that = this;
      let outQty = _that.form.outQty;
      let outPrice = 0;
      outPrice = _that.form.outMoneyTotal / outQty;
      _that.form.outPrice = outPrice.toFixed(2);
      _that.calculateOrderGrossProfitRate();
    },
    calculateOrderGrossProfitRate() {
      const _that = this;
      let outSendMoney = _that.form.outSendMoney;
      let orderGrossProfitRate = '';
      if (_that.form.printMoneyTotal === null || _that.form.printMoneyTotal === '' || _that.form.outMoneyTotal ===null || _that.form.outMoneyTotal ==='') {
        return;
      } else {
      _that.form.orderGrossProfit = _that.form.printMoneyTotal - _that.form.outMoneyTotal - outSendMoney;
      orderGrossProfitRate = _that.form.orderGrossProfit / _that.form.printMoneyTotal;
      orderGrossProfitRate = orderGrossProfitRate.toFixed(2);
      orderGrossProfitRate = (orderGrossProfitRate * 100).toFixed(0);
      _that.form.orderGrossProfitRate = orderGrossProfitRate;
      }
    },
    chooseClient(data) {
      this.createInnerVisible = false
      // console.log(data);
      this.form.clientName = data.clientName
      this.form.idClient = data.id
      this.form.sendAddress = data.province + data.city + data.area + data.address
    },
    chooseClientByPay(data) {
      this.createInnerVisible = false
      // console.log(data);
      this.form.clientName = data.clientName;
      this.form.idClient = data.id;
    },
    handleGet(data) {
      var _that = this
      _that.form.deliverDate = data.slice(0, 10);
      _that.form.deliverTime = data.slice(11, 19);
    },
    mentChange() {
      var _that = this
      _that.$nextTick(function() {
        // console.log(_that.getNewDate());
        _that.form.sendDate = _that.getNewDate();
      })
    },
    getNewDate() {
      //获取当前时间
      var _this = this;
      let yy = new Date().getFullYear();
      let mm = new Date().getMonth() + 1;
      let dd = new Date().getDate();
      let hh = new Date().getHours();
      let mf = new Date().getMinutes() < 10 ? '0' + new Date().getMinutes() : new Date().getMinutes();
      let ss = new Date().getSeconds() < 10 ? '0' + new Date().getSeconds() : new Date().getSeconds();
      if (hh < 10) {
        return '0' + hh + ':' + mf + ':' + '00';
      } else {
        return hh + ':' + mf + ':' + '00';
      }

    },
    // 设置标签名称
    setTagsViewTitle() {
      const title = this.tempRoute.meta.title
      // console.log("tempRoute2",this.tempRoute);
      const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.orderCode}` })
      // console.log("route",route)
      this.$store.dispatch('tagsView/updateVisitedView', route)
    },
    getToken() {
      const _that = this;
      orderFormToken().then(res => {
        // console.log(res);
        _that.formToken = res.data
      })
    },
    // 初始化页面
    init() {
      var _that = this

      if (_that.orderCategory == 1) {
      } else {
        _that.getInfo()
      }
      _that.balanceMoney = 0;
      _that.balanceSpan = false;
      _that.getDictInfo('printQty')
      _that.getDictInfo('printColor')
      _that.getDictInfo('pageCount')
      _that.getDictInfo('paperName')
      _that.getDictInfo('receiptsCount')
      _that.getDictInfo('productName')
      _that.getDictInfo('sendKind')
    },

    // 获取订单详情
    getInfo() {
      const _that = this
      if (!_that.idOrder) {
        return
      }
      if (_that.idOrder == undefined) {
        return
      }
      if (_that.idOrder <= 0) {
        return
      }
      var dataParams = {
        'idOrder': _that.idOrder
      }
      getPrintOrderInfo(dataParams).then(response => {
        // console.log('order', response)
        var data = response.data

        // if (data.originFileLink) {
        //   _that.hasFile = true
        // } else {
        //   _that.hasFile = false
        // }
        _that.form = data
        _that.form.orderState = data.orderState.toString()
      }).catch(err => {
        // console.log(err)

        _that.$message.error(err)
      })
    },
    // 勾选置灰
    checkSelectable(row) {
      // console.log(row);
      if (row.isRequired == 0) {
        return false
      } else {
        return true
      }
    },

    // 获取字典
    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 == 'productName') {
          _that.productNameOptions = data
        } else if (typeText == 'receiptsCount') {
          _that.receiptsCountOptions = data
        } else if (typeText == 'paperName') {
          _that.paperNameOptions = data
        } else if (typeText == 'pageCount') {
          _that.pageCountOptions = data
        } else if (typeText == 'printColor') {
          _that.printColorOptions = data
        } else if (typeText == 'printQty') {
          _that.printQtyOptions = data
        } else if (typeText == 'sendKind') {
          _that.sendKindOptions = data
        }
      }).catch(err => {
        _that.$message.error(err)
      })
    },
    // 禁止输入小数，负数
    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 = ''
      }
    },

    // 下拉框可输入
    selectBlur1(e) {
      var _that = this
      if (e.target != undefined) {
        _that.form.paperName = e.target.value
      }
    },
    selectBlur2(e) {
      var _that = this
      if (e.target != undefined) {
        _that.form.pageCount = e.target.value
      }
    },
    selectBlur3(e) {
      var _that = this
      if (e.target != undefined) {
        _that.form.printColor = e.target.value
      }
    },
    // 保存
    save(type) {
      var _that = this
      this.$refs['form'].validate(async(valid) => {
        if (valid) {
          _that.saveBtn()
        }
      })
    },
    saveBtn() {
      var _that = this
      _that.clickLoading = true
      var data = JSON.stringify(_that.form)
      addPrintOrder(data, _that.formToken).then(response => {
        // console.log('addPrintOrder',response)
        if (response.httpCode == 200) {
          _that.clickLoading = false
          _that.$store.dispatch('tagsView/delView', _that.tempRoute).then(() => {
            _that.$router.push({ path: '/order/orderList' })
          })
        } else if (response.httpCode != 409) {
          _that.getToken()
        }
      }).catch(err => {
        _that.clickLoading = false
        if (err.name != 409) {
          _that.getToken()
        }
        // _that.$message.error(err)
      })
    },
    // 修改保存
    editOrder(type) {
      var _that = this
      this.$refs['form'].validate((valid) => {
        if (valid) {
          _that.editBtn()
        }
      })
    },
    editBtn() {
      var _that = this
      _that.clickLoading = true
      _that.form.id = _that.idOrder
      var data = JSON.stringify(_that.form)
      if (_that.editType == 1) {
        updatePrintOrder(data).then(response => {
          // console.log(response)
          if (response.httpCode == 200) {
            _that.clickLoading = false
            _that.$store.dispatch('tagsView/delView', _that.tempRoute).then(() => {
                _that.$router.push({ path: '/order/orderList' })
            })
          }
        }).catch(err => {
          _that.clickLoading = false
          // console.log(err)
          // _that.$message.error(err)
        })
      } else {
        //nothing do here
      }
    },

    handleCurrentChange(row, event, column) {
      // console.log(row, event, column, event.currentTarget)
    },
    handleEdit(index, row) {
      // console.log(index, row);
    }
  }
}
</script>
<style>

.el-card__header {
  padding: 5px 20px;
}

.el-form-item--mini.el-form-item, .el-form-item--small.el-form-item {
  margin-bottom: 10px;
}

.el-input__inner {
  padding: 0 10px;
}

.itemlabel .el-form-item__label {
  margin-top: 5px;
}
.item .el-form-item__label {
  color: red;
}

</style>
<style scoped>
.filter-container {
  margin-bottom: 10px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}

.clearfix:after {
  clear: both
}

.show {
  display: none;
}

.hideContent {
  padding: 0;
}

.box-card {
  margin-bottom: 10px;
}

.box-header-title {
  line-height: 36px;
  font-size: 17px;
  color: #666;
}

.box-header-right {
  float: right;
  color: #20a0ff;
  line-height: 36px;
  cursor: pointer;
  margin-right: 10px;
}

.tip {
  padding: 8px 16px;
  background-color: #ecf8ff;
  border-radius: 4px;
  border-left: 5px solid #50bfff;
  margin: 8px 0;
}
.tip2 {
  padding: 8px 16px;
  background-color: #ffeeec;
  border-radius: 4px;
  border-left: 5px solid #ff5050;
  margin: 8px 0;
}
.tip3 {
  padding: 8px 16px;
  background-color: #fffcec;
  border-radius: 4px;
  border-left: 5px solid #fff050;
  margin: 8px 0;
}
.tip4 {
  padding: 8px 16px;
  background-color: #ecffee;
  border-radius: 4px;
  border-left: 5px solid #a5ff50;
  margin: 8px 0;
}

.box-header-icon {
  float: right;
  color: #20a0ff;
  line-height: 36px;
  cursor: pointer;
}

.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
}

.processDialog ::v-deep .el-dialog__body {
  padding: 0;
}

::v-deep .el-card__body {
  padding: 10px;
}
/*去除 el- input 当type = 'number 时 输入框里的恶心上下箭头*/
::v-deep input::-webkit-outer-spin-button,::v-deep input::-webkit-inner-spin-button{
  -webkit-appearance: none !important;
}
::v-deep input[type = 'number']{
  -moz-appearance: textfield !important;
}
/*去除 el- input 当type = 'number 时 输入框里的恶心上下箭头*/
</style>
