specialNeeds.vue 4.84 KB
Newer Older
1 2
<template>
<div>
3
  <el-dialog :before-close="()=>{$emit('update:show',false)
4
  }" center width="80%"  :visible.sync="show">
5
    <div class="content">
dcy's avatar
dcy committed
6
      <h1>{{orderNo}} 特需</h1>
7
      <el-form label-width="180px" label-position="left">
Marcus's avatar
Marcus committed
8
        <el-form-item :label="$t('特殊要求')">
dcy's avatar
dcy committed
9 10
          <el-checkbox-group v-model="advanceType" >
            <el-checkbox @click="change(item)" v-for="(item) in getDictDatas(DICT_TYPE.ORDER_SPECIAL_NEEDS)"  :label="item.value" >{{item.label}}</el-checkbox>
dcy's avatar
dcy committed
11
          </el-checkbox-group>
12
        </el-form-item>
Marcus's avatar
Marcus committed
13
        <el-form-item :label="$t('特殊要求备注')"><el-input  type="textarea" style="width: 300px;" v-model="todoDetail"></el-input></el-form-item>
dcy's avatar
dcy committed
14 15
        <el-form-item v-for="(item,index) in  this.getDictDatas(this.DICT_TYPE.ORDER_SPECIAL_NEEDS)" v-if="advanceType.indexOf(item.value) > -1" :key="item.value" :label="item.label + '预计金额'">
          <el-input style="width: 300px;" v-model="specialNeedsList[index].transFee">
16
            <div style="width: 100px;" slot="append" >
我在何方's avatar
我在何方 committed
17 18 19
              <el-select   v-model="specialNeedsList[index].transCurrency">
                <el-option v-for="item in JSON.parse(currency)" :key="item.id" :label="item.titleZh" :value="item.id" />
              </el-select>
20 21
            </div>
          </el-input>
dcy's avatar
dcy committed
22
           <div style="display: inline-block;margin-left: 20px;">
Marcus's avatar
Marcus committed
23 24
             <span style="margin-right: 10px;">{{ $t('付款类型') }}</span>
             <dict-selector  :placeholder="$t('请选择付款类型')"  v-model="specialNeedsList[index].payType"  :type="DICT_TYPE.PAYMENT_TYPE" ></dict-selector>
dcy's avatar
dcy committed
25
           </div>
26 27 28 29
        </el-form-item>
      </el-form>
    </div>
    <div  slot="footer" class="dialog-footer">
Marcus's avatar
Marcus committed
30 31
      <el-button type="primary" @click="submit">{{ $t('提交') }}</el-button>
      <el-button @click="$emit('update:show',false)">{{ $t('取消') }}</el-button>
32 33 34 35 36 37
    </div>
  </el-dialog>
</div>
</template>

<script>
38
import { getDictDatas, DICT_TYPE } from '@/utils/dict';
dcy's avatar
dcy committed
39
import {specialNeedCreate,getSpecialListByOrderId} from "@/api/ecw/order";
我在何方's avatar
我在何方 committed
40

41 42
export default {
  name: "specialNeeds",
43 44 45 46
  props:{
    orderId:{
      type:[String,Number],
    },
dcy's avatar
dcy committed
47
    orderNo:[String,Number],
48
    show:Boolean,
我在何方's avatar
我在何方 committed
49
    currency:String
dcy's avatar
dcy committed
50 51
  },
  computed:{
dcy's avatar
dcy committed
52

53
  },
54 55
  data(){
    return{
56 57 58
      getDictDatas,
      DICT_TYPE,
      form:{},
dcy's avatar
dcy committed
59 60
      advanceType:[],
      specialNeedsList:[],
61
      todoDetail:'',
dcy's avatar
dcy committed
62
      echoList:[],
我在何方's avatar
我在何方 committed
63

64 65
    }
  },
我在何方's avatar
我在何方 committed
66

67 68
  methods:{
    submit(){
69 70 71
      this.specialNeedsList.forEach(i => {
        i.todoDetail = this.todoDetail
      })
dcy's avatar
dcy committed
72
      let p = this.specialNeedsList.filter(i => this.advanceType.indexOf(i.advanceType) > -1)
dcy's avatar
dcy committed
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
      let p1 = []
      //获取新增的和修改的
      p.forEach(item => {
        if(this.echoList.find( i => item.id === i.id)){
        p1.push(item)
        }else {
          item.oper = 'add'
          p1.push(item)
        }
      })
      //获取删除的
      this.echoList.forEach(item => {
       if(!(p.find(i => i.id === item.id))){
         item.oper = 'del'
          p1.push(item)
       }
      })
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
     let p2 =  p1.filter(i => Number(i.transFee) > 0)
      if(p2.every(i => !!i.payType)){
        specialNeedCreate(p1).then(r=>{
          if(r.code === 0){
            this.$emit('update:show',false)
            this.$emit('determine')
            this.$message.success('提交成功');
          }
        })
      }else {
       let v = p2.map(i => i.advanceType);
       console.log(this.getDictDatas(this.DICT_TYPE.ORDER_SPECIAL_NEEDS),'this.getDictDatas(this.DICT_TYPE.ORDER_SPECIAL_NEEDS)')
        let v2 = this.getDictDatas(this.DICT_TYPE.ORDER_SPECIAL_NEEDS).filter(i => v.includes(i.value))
        this.$modal.notifyWarning(`请选择"${ v2.map(i => i.label).join('')}"的付款类型。`)
      }
105 106 107
    },
  },
  watch:{
dcy's avatar
dcy committed
108 109 110 111 112 113 114
    show(val){
      if(val){
         this.getDictDatas(this.DICT_TYPE.ORDER_SPECIAL_NEEDS).forEach(r => {
             this.specialNeedsList.push({
               advanceType:r.value,
               orderId:this.orderId,
               transFee:'',//预计金额
115
               transCurrency:1,//运输费币种
116
               payType:''
dcy's avatar
dcy committed
117 118
               })
         })
dcy's avatar
dcy committed
119 120
        //特需回显
        getSpecialListByOrderId(this.orderId).then(r => {
dcy's avatar
dcy committed
121
          this.echoList = r.data;
dcy's avatar
dcy committed
122 123 124 125 126 127 128 129 130 131 132 133
          r.data.forEach(i => {
            this.advanceType.push(i.advanceType)
           let index = this.specialNeedsList.findIndex(item => i.advanceType == item.advanceType)
            this.specialNeedsList.splice(index,1, {  advanceType:i.advanceType,
              orderId:this.orderId,
              id:i.id,
              transFee:i.transFee,//预计金额
              transCurrency:i.transCurrency,//运输费币种
              payType:i.payType})
          })

        })
dcy's avatar
dcy committed
134 135 136 137
      }else {
        this.specialNeedsList = []
        this.advanceType = []
      }
138 139 140 141 142 143 144 145
    }
  }
}
</script>

<style scoped lang="scss">

</style>