feeApplication.vue 9.5 KB
Newer Older
dcy's avatar
dcy committed
1
<template>
2 3 4 5
    <el-dialog :visible.sync="dialogVisible"    width="80%" :before-close="()=>{
    $emit('update:dialogVisible',false)
  }">
    <div class="fee-application">
dcy's avatar
dcy committed
6
      <h1>{{$t('费用申请')}}-{{orderDetails.orderNo}}
7 8 9
      </h1>
      <el-divider></el-divider>
      <el-form label-width="100px" inline>
dcy's avatar
dcy committed
10
        <el-form-item :label="$t('订单号')+':'"><div class="content">
11
          {{orderDetails.orderNo}}
12
        </div></el-form-item>
dcy's avatar
dcy committed
13 14
        <el-form-item :label="$t('发货人')+':'"><div class="content">{{orderDetails.consignorVO ? orderDetails.consignorVO.name :''}}</div></el-form-item>
        <el-form-item :label="$t('唛头')"><div class="content">{{orderDetails.marks}}</div></el-form-item>
15
        <el-form-item> <el-button :disabled="!!processInstanceId || editMode" @click="addCost">{{$t('添加申请')}}</el-button></el-form-item>
16 17
      </el-form>
      <el-table :data="list">
dcy's avatar
dcy committed
18 19
         <el-table-column :label="$t('序号')" type="index"></el-table-column>
         <el-table-column :label="$t('费用类型')">
20
           <template  v-slot:default = "scope">
21
             <dict-selector  :disabled="!scope.row.editMode && !!scope.row.status"  :type="DICT_TYPE.FEE_TYPE" v-model="scope.row.feeType" />
22 23
           </template>
         </el-table-column>
dcy's avatar
dcy committed
24
         <el-table-column :label="$t('金额')">
25
           <template v-slot:default = 'scope'>
26
             <el-input  :disabled="!scope.row.editMode && !!scope.row.status" v-model.number="scope.row.applicationFee" ></el-input>
27 28
           </template>
         </el-table-column>
dcy's avatar
dcy committed
29
         <el-table-column :label="$t('货币类型')">
30
           <template v-slot:default = 'scope'>
31
             <el-select :disabled="!scope.row.editMode && !!scope.row.status"  v-model="scope.row.applicationFeeCurrency">
我在何方's avatar
我在何方 committed
32 33
               <el-option v-for="item in JSON.parse(currencys)" :key="item.id" :label="item.titleZh" :value="item.id" />
             </el-select>
34 35
           </template>
         </el-table-column>
dcy's avatar
dcy committed
36
         <el-table-column :label="$t('付款类型')">
37
           <template v-slot = {row}>
38
             <dict-selector  :disabled="!row.editMode && !!row.status" :type="DICT_TYPE.PAYMENT_TYPE" v-model="row.payType" />
39 40
           </template>
         </el-table-column>
dcy's avatar
dcy committed
41
         <el-table-column :label="$t('备注')">
42
           <template v-slot:default="scope">
43
             <el-input  :disabled="!scope.row.editMode && !!scope.row.status" v-model="scope.row.remarks" type="textarea"></el-input>
44 45
           </template>
         </el-table-column>
dcy's avatar
dcy committed
46
         <el-table-column :label="$t('确认收款')">
47
           <template v-slot:default ="scope">
48
             <dict-tag :type="DICT_TYPE.ECW_RECEIVABLE_STATE" :value="scope.row.receiveFlag" />
49 50
           </template>
         </el-table-column>
dcy's avatar
dcy committed
51
         <el-table-column :label="$t('申请人')">
52
           <template v-slot:default ="scope">
dcy's avatar
dcy committed
53
             {{scope.row.status === 0 ? $t('未提交'): scope.row.applicationAuthor}}
54 55
           </template>
         </el-table-column>
dcy's avatar
dcy committed
56
         <el-table-column :label="$t('操作')">
57
           <template v-slot:default = 'scope'>
58 59 60
             <el-tag v-if="scope.row.status !== 0 && !scope.row.editMode">{{STATUS[scope.row.status]}}</el-tag>
             <!--el-button type="text" v-if="scope.row.status == 1" @click="examineFn">{{$t('审核中')}}</el-button-->
             <el-button type="text" v-if="modifable(scope.$index)" @click="modify(scope.row)">{{$t('修改')}}</el-button>
61
             <el-button type="text" v-if="scope.row.status === 0" @click="del(scope.$index)">删除</el-button>
62 63
           </template>
         </el-table-column>
64 65 66 67 68
      </el-table>
      <div style="padding: 20px">
        <work-flow xmlkey="free_apply" v-model="selectedUsers"  />
      </div>
      <div style="text-align: center;margin-top: 20px;">
69
        <el-button type="primary" v-if="!processInstanceId" style="margin-right: 30px;" :disabled="!feeList.length && !editMode" @click="submit">{{$t('提交')}}</el-button>
70 71
        <el-button type="primary" v-if="processInstanceId" style="margin-right: 30px;" @click="goProcessDetail">{{$t('审核中')}}</el-button>
        <el-button type="primary" v-if="processInstanceId" style="margin-right: 30px;" @click="cancel">{{$t('取消审核')}}</el-button>
dcy's avatar
dcy committed
72
        <el-button @click="$emit('update:dialogVisible',false)">{{$t('返回')}}</el-button>
73
      </div>
dcy's avatar
dcy committed
74
    </div>
75 76
  </el-dialog>

dcy's avatar
dcy committed
77 78 79
</template>

<script>
dcy's avatar
dcy committed
80 81
import {
  getOrder,
82
  feeApplicationCreateBatch,
dcy's avatar
dcy committed
83 84
  ApplicationListByOrderId,
  applicationUpdate,
85 86 87 88 89
  feeApplicationListByOrderId,
  feeApplicationCancel,
  getFeeApplicationApproveByOrderId,
  getBatchFeeByProcessId,
  qetBatchFeeByBusinessId, getBatchFeeByBusinessId
dcy's avatar
dcy committed
90
} from "@/api/ecw/order";
91
import { getDictDatas, DICT_TYPE } from '@/utils/dict';
dcy's avatar
dcy committed
92
import workFlow from "@/components/WorkFlow";
dcy's avatar
dcy committed
93
export default {
94
  name: "feeApplication",
95
  components: {workFlow},
96 97
  props:{
    orderId:[Number, String],
98 99 100
    dialogVisible:{
      type:Boolean,
      default:false,
我在何方's avatar
我在何方 committed
101 102
    },
    currencys:String
103 104 105 106
  },
  data(){
    return {
      orderDetails:{},
107
      // 费用列表
108
      list:[],
109 110 111
      // 审核ID,没有则表示不在审核中
      processInstanceId: null,

112 113
      DICT_TYPE,
      getDictDatas,
dcy's avatar
dcy committed
114
      STATUS:{},
dcy's avatar
dcy committed
115
      selectedUsers:[]
116 117
    }
  },
118 119 120
    computed:{
      feeList(){
          return this.list.filter(item => item.status === 0)
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
      },
      // 正在编辑的费用申请
      currentItem(){
          return this.list.find(item => item.editMode)
      },
      // 是否修改模式
      editMode(){
        return !!this.currentItem
      },
      modifable(){
          return (index) => {
              // 审核中不允许修改
              if(this.processInstanceId) return false
              // 有未提交的不允许修改
              if(this.feeList.length) return false
              // 有修改中的不允许修改
              if(this.list.findIndex(item => item.editMode) > -1) return false
              return true
          }
140 141
      }
    },
142
  created() {
dcy's avatar
dcy committed
143 144
    this.getDictDatas(this.DICT_TYPE.AUDIT_STATUS).forEach( e =>{
      this.STATUS[e.value] = e.label
dcy's avatar
dcy committed
145 146
    })

147 148 149 150
    getOrder(this.orderId).then(res => {
      this.orderDetails = res.data
    })

151 152 153 154 155
      // 查询历史申请
      feeApplicationListByOrderId({orderId: this.orderId}).then(res => {
        this.list = res.data
      })

156 157 158 159
    // 查询是否有审核中的费用申请
    getFeeApplicationApproveByOrderId(this.orderId).then(res => {
      if(res.data.formId){
        this.processInstanceId = res.data.formId
160
        /*getBatchFeeByBusinessId(res.data.orderApprovalId).then(res => {
161
          this.list = res.data
162
        })*/
dcy's avatar
dcy committed
163
      }
164
    })
165 166
  },
  methods:{
167 168 169 170 171
    del(index){
      this.$confirm(this.$t("确定要删除此条费用申请么?")).then(() => {
        this.list.splice(index, 1)
      })
    },
172 173 174 175
    // 修改
    modify(item){
      this.$set(item, 'editMode', true)
    },
176
    addCost(){
177
        this.list.push({
178 179 180 181 182 183 184 185
            orderId:this.orderId,
            feeType:undefined,//费用申请类型
            applicationFee:undefined,//金额
            applicationFeeCurrency:undefined,//	费用申请货币类型
            remarks:undefined,
            receiveFlag:0,
            applicationAuthor:undefined,
            status:0,
dcy's avatar
dcy committed
186 187
          })
    },
188
    submit(){
189 190 191 192 193 194 195
        // 判断费用申请是否有未填项
        const errList = this.feeList.filter(item => {
            return !item['feeType'] || !item['applicationFee'] || !item['applicationFeeCurrency'] || !item['payType']
        })
        if(errList.length){
            return this.$message.error('请填写完整费用申请信息')
        }
196 197 198 199 200 201 202
        if(this.editMode){
            // 要提交status=1,否则保持原状态
            const data = {...this.currentItem,status:1, copyUserId:this.selectedUsers}
            return applicationUpdate(data).then(r => {
                this.$message.success(this.$t('修改成功'));
                this.$emit('update:dialogVisible',false)
            })
dcy's avatar
dcy committed
203
        }
204 205 206 207 208 209 210 211 212 213 214 215

        feeApplicationCreateBatch( {
          orderFeeApplicationCreateReqVOList: this.feeList,
          copyUserId:this.selectedUsers,
          orderId: this.orderId
        }).then(r=>{
          if(r.code === 0){
            this.$emit('update:dialogVisible',false)
            this.$message.success(this.$t('添加成功'));
            this.selectedUsers = [];
          }
        })
dcy's avatar
dcy committed
216
    },
217 218 219
    goProcessDetail(){
      this.$emit('update:dialogVisible',false)
      this.$router.push('/bpm/process-instance/detail?id=' + this.processInstanceId)
220
    },
dcy's avatar
dcy committed
221
    cancel(){
dcy's avatar
dcy committed
222 223 224
      this.$prompt(this.$t('请输入取消原因'), this.$t('提示'), {
        confirmButtonText: this.$t('确定'),
        cancelButtonText: this.$t('取消'),
dcy's avatar
dcy committed
225 226
      }).then(({ value }) => {
        let item =  this.list.find(e => e.status === 1);
227
        feeApplicationCancel({huifu:value,bpmProcessId: this.processInstanceId}).then(r => {
dcy's avatar
dcy committed
228 229
          this.$message({
            type: 'success',
dcy's avatar
dcy committed
230
            message:this.$t('取消成功')
dcy's avatar
dcy committed
231 232 233 234 235 236
          });
          this.$emit('update:dialogVisible',false)
        })
      }).catch(() => {
      });
    }
237 238 239 240 241 242 243 244 245 246 247 248
  },
  watch:{
    dialogVisible(val){
       if(val){
         this.getOrderList()
         getOrder(this.orderId).then(r =>{
           if(r.code === 0){
             this.orderDetails = r.data
           }
         })
       }
    },
249
  }
dcy's avatar
dcy committed
250 251 252 253 254 255 256 257 258 259 260 261 262 263
}
</script>

<style scoped lang="scss">
.fee-application {
  padding: 0 20px;
  h1{
    font-weight: 600;
    font-size: 20px;
  }
  .content{
    width: 200px;
  }
}
264 265 266 267 268 269 270 271
.my-process-designer {
  height: calc(100vh - 200px);
}

.box-card {
  width: 100%;
  margin-bottom: 20px;
}
dcy's avatar
dcy committed
272
</style>