OperatorButton.vue 3.74 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
<template>
    <div style="display: inline-block;margin: 0px 5px">
      <el-button type="text" @click="openPurchaseDialog" size="mini">{{getOperatorName()}}</el-button>
      <el-dialog :title="getOperatorName()" :visible.sync="open" width="800px" append-to-body :close-on-click-modal="false" destroy-on-close>
        <component :is="currentTabComponent" :purchaseData="purchaseData" ref="currentCom" v-if="open"></component>
        <div slot="footer" class="dialog-footer" style="text-align: center" v-if="operatorName != 'purchaseDetail'">
          <el-button style="width: 150px;border-color: #1890ff;color: #1890ff;" @click="resetSuggestion">重置意见</el-button>
          <el-button type="primary" style="width: 150px" @click="submitSuggestion">提交</el-button>
        </div>
      </el-dialog>
    </div>
</template>

<script>
  import { getPurchase, updatePurchase, approvalPurchase } from "@/api/transaction/purchase";
  import calculate from "./Calculate";
  import confirm from "./Confirm";
  import purchaseDetail from "./PurchaseDetail";
19
  import { sendNotice, noticeIsReadByRelationId } from "@/api/system/notice";
耿迪迪's avatar
耿迪迪 committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
  export default {
    name: "operator-button",
    components:{
      calculate,
      confirm,
      purchaseDetail
    },
    props:{
      operatorName: {
        type: String
      },
      purchaseInfo: {
        type: Object
      }
    },
    created(){
      this.currentTabComponent = this.operatorName;
    },
    data(){
        return{
          open: false,
          currentTabComponent: "",
          purchaseData: {}
        }
    },
    methods:{
      getOperatorName(){
        switch(this.operatorName){
          case "purchaseDetail":
            return "详情";
          case "confirm" :
            return "部门长审核";
          case "calculate":
            return "核算部审批";
          default:
            return "";
        }
      },
      openPurchaseDialog(){
        getPurchase(this.purchaseInfo.purchaseId).then(res =>{
          if(res.code == 200){
            this.purchaseData = res.data;
            this.open = true;
          }
        })
      },
      //重置意见
      resetSuggestion(){
        this.$refs.currentCom.resetSuggestion();
      },
      //提交
      submitSuggestion(){
        if(this.$refs.currentCom.checkParam()){
          return;
        }

        if("calculate" == this.operatorName){
          approvalPurchase(this.$refs.currentCom.submitSuggestion()).then(res =>{
            if(res.code == 200){
              this.open = false;
              this.$emit("getList");
              this.$message.success("审核成功!");
              if(this.$refs.currentCom.submitSuggestion().purchaseStatus == '3'){
耿迪迪's avatar
耿迪迪 committed
83
                sendNotice({noticeTitle:"您的服务费用申请被驳回",noticeType:"1",noticeContent:"您的服务费用申请被驳回",userId:this.purchaseInfo.handledByUserId,relationType:"3",relationId:this.purchaseInfo.purchaseId});
84
              }else {
耿迪迪's avatar
耿迪迪 committed
85
                noticeIsReadByRelationId({relationId:this.purchaseInfo.purchaseId});
耿迪迪's avatar
耿迪迪 committed
86 87 88 89 90 91 92 93 94 95 96 97 98
              }
            }else{
              this.$message.error("审核失败!");
            }
          });
          return;
        }

        updatePurchase(this.$refs.currentCom.submitSuggestion()).then(res =>{
          if(res.code == 200){
            this.open = false;
            this.$emit("getList");
            this.$message.success("提交成功!");
耿迪迪's avatar
耿迪迪 committed
99
            sendNotice({noticeTitle:"您有新服务费用信息待审批",noticeType:"1",noticeContent:"您有新服务费用信息待审批",roles:"calculator",relationType:"3",relationId:this.purchaseInfo.purchaseId})
耿迪迪's avatar
耿迪迪 committed
100 101 102 103 104 105 106 107 108 109 110 111
          }else{
            this.$message.error("提交失败!");
          }
        })
      },
    }
  }
</script>

<style scoped>

</style>