index.vue 5.2 KB
Newer Older
tianxinyu committed
1 2 3 4 5
<template>
  <div class="eContainer">
    <c-page :title="title">
      <el-form
        ref="modelForm"
6
        label-width="180px"
tianxinyu committed
7 8 9 10 11 12 13
        size="small"
        label-position="right"
        :model="model"
        :rules="rules"
        :validate-on-rule-change="false"
        :disabled="isDisabled"
      >
tianxinyu committed
14
        <c-tabs v-model="tabVal" ref="elment" type="card" @tab-click="changePosition">
tianxinyu committed
15
          <el-tab-pane label="费用代码" name="fec">
tianxinyu committed
16 17 18 19
            <c-content>
              <m-fec-info :model="model" />
            </c-content>
          </el-tab-pane>
tianxinyu committed
20
          <el-tab-pane label="费率信息" name="fee">
tianxinyu committed
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
            <c-content>
              <m-fee-info :model="model" />
            </c-content>
          </el-tab-pane>
        </c-tabs>
      </el-form>
      <div style="text-align: center">
        <c-button
          type="primary"
          style="margin-right: 10px"
          @click="commitAdd"
          v-if="type === 'add'"
          >提 交</c-button
        >
        <c-button
          type="primary"
          style="margin-right: 10px"
          @click="commitEdit"
          v-if="type === 'edit'"
          >提 交</c-button
        >
        <c-button
          type="primary"
          style="margin-right: 10px"
          @click="commitDelete"
          v-if="type === 'delete'"
          >提 交</c-button
        >
        <c-button type="primary" @click="goBack">返 回</c-button>
      </div>
    </c-page>
  </div>
</template>

<script>
import Utils from "~/utils";
import Fec, { Pattern } from "./Fec.js";

import FecInfo from "./FecInfo.vue";
import FeeInfo from "./FeeInfo.vue";

tianxinyu committed
62
import { queryDetailById, add, edit, deleteById,editFeeData,deleteFeeData } from "~/service/test/fec.js";
tianxinyu committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89

export default {
  name: "StaticsDbifec",
  components: {
    "m-fec-info": FecInfo,
    "m-fee-info": FeeInfo,
  },
  provide() {
    return {
      root: this,
    };
  },
  props: {
		type: {
			type: String,
			default: "info"
		},
		title: {
			type: String,
			default: "dbifec"
		}
	},
  data() {
    return {
      model: new Fec().data,
      tabVal: "fec",
      rules: Pattern,
tianxinyu committed
90
      tabPosition:"tab-fec",
tianxinyu committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104
    };
  },
  computed: {
    isDisabled() {
      return this.type === "info" || this.type === "delete";
    },
  },
  created() {
    if (this.type !== "add") {
      const inr = this.$route.params.inr;
      queryDetailById(inr).then((res) => {
        if (res.inr) {
          this.model = res;
        } else {
tianxinyu committed
105
          this.$message.error("费用代码不存在")
tianxinyu committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
        }
      });
    }
  },
  methods: {
    commitAdd() {
      this.$refs.modelForm.validate((validated) => {
        if (validated) {
          add(this.model)
            .then((res) => {
              this.$message.success("保存成功!");
              this.goBack(true)
            })
            .catch((err) => {
              this.$message.error("保存失败!");
            });
        } else {
          Utils.formValidateTips(this.$refs.modelForm.fields)
        }
      });
    },
    commitEdit() {
      this.$refs.modelForm.validate((validated) => {
        if (validated) {
tianxinyu committed
130
          if(this.tabPosition===`tab-fec`){
tianxinyu committed
131 132
          edit(this.model)
            .then((res) => {
tianxinyu committed
133
              this.$message.success("费用代码修改保存成功!");
tianxinyu committed
134 135 136
              this.goBack()
            })
            .catch((err) => {
tianxinyu committed
137
              this.$message.error("费用代码修改保存失败!");
tianxinyu committed
138 139 140
            });}else{
              editFeeData(this.model.inr,this.model)
            .then((res) => {
tianxinyu committed
141
              this.$message.success("费率修改保存成功!");
tianxinyu committed
142 143 144
              this.goBack()
            })
            .catch((err) => {
tianxinyu committed
145
              this.$message.error("费率修改保存失败!");
tianxinyu committed
146
            });
tianxinyu committed
147
            }
tianxinyu committed
148 149 150 151 152 153 154 155 156 157 158 159
        } else {
          Utils.formValidateTips(this.$refs.modelForm.fields)
        }
      });
    },
    commitDelete() {
      this.$confirm("是否确认删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
tianxinyu committed
160
          if(this.tabPosition===`tab-fec`){
tianxinyu committed
161 162
          deleteById(this.model.inr)
            .then((res) => {
tianxinyu committed
163
              this.$message.success("费用代码信息删除成功!");
tianxinyu committed
164 165 166
              this.goBack(true)
            })
            .catch((err) => {
tianxinyu committed
167
              this.$message.error("费用代码信息删除失败!");
tianxinyu committed
168 169 170
            })}else{
              deleteFeeData(this.model)
            .then((res) => {
tianxinyu committed
171
              this.$message.success("费率信息删除成功!");
tianxinyu committed
172 173 174
              this.goBack(true)
            })
            .catch((err) => {
tianxinyu committed
175
              this.$message.error("费率信息删除失败!");
tianxinyu committed
176 177
            })
            };
tianxinyu committed
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    /**
     * update 是否更新inffec的查询列表
     */
    goBack(update) {
      this.$store.dispatch("TagsView/delView", this.$route);
      this.$router.push({ name: "StaticsInffec", params: { update } });
    },
tianxinyu committed
193 194 195 196
    changePosition(tab,event){
      this.tabPosition=event.target.getAttribute('id');
      console.log(this.tabPosition)
    },
tianxinyu committed
197 198 199 200 201 202
  },
};
</script>

<style>
</style>