index.vue 4.92 KB
Newer Older
潘际乾 committed
1 2 3 4 5
<template>
  <div class="eContainer">
    <c-page :title="title">
      <el-form
        ref="modelForm"
6
        label-width="160px"
潘际乾 committed
7 8 9 10 11 12 13 14 15 16 17 18 19 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
        size="small"
        label-position="right"
        :model="model"
        :rules="rules"
        :validate-on-rule-change="false"
        :disabled="isDisabled"
      >
        <c-tabs v-model="tabVal" ref="elment" type="card">
          <el-tab-pane label="基本信息" name="pty">
            <c-content>
              <m-pty-info :model="model" />
            </c-content>
          </el-tab-pane>
          <el-tab-pane label="地址信息" name="pta,adr">
            <c-content>
              <m-adr-list :model="model" />
            </c-content>
          </el-tab-pane>
          <el-tab-pane label="账号信息" name="act">
            <c-content>
              <m-act-info :model="model" />
            </c-content>
          </el-tab-pane>
          <el-tab-pane label="联系人信息" name="ptc">
            <c-content>
              <m-ptc-info :model="model" />
            </c-content>
          </el-tab-pane>
          <el-tab-pane label="汇率/费率信息" name="ptyrat,fec,fee">
            <c-content>
              <m-rat-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>
潘际乾 committed
71
import Utils from "~/utils";
潘际乾 committed
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
import Pty, { Pattern } from "./Pty.js";

import PtyInfo from "./PtyInfo.vue";
import AdrList from "./AdrList.vue";
import ActInfo from "./ActInfo.vue";
import PtcInfo from "./PtcInfo.vue";
import RatInfo from "./RatInfo.vue";

import { queryDetailById, add, edit, deleteById } from "~/service/test/pty.js";

export default {
  name: "StaticsDbipty",
  components: {
    "m-pty-info": PtyInfo,
    "m-adr-list": AdrList,
    "m-act-info": ActInfo,
    "m-ptc-info": PtcInfo,
    "m-rat-info": RatInfo,
  },
  provide() {
    return {
      root: this,
    };
  },
  props: {
		type: {
			type: String,
			default: "info"
		},
		title: {
			type: String,
			default: "dbipty"
		}
	},
  data() {
    return {
      model: new Pty().data,
      tabVal: "pty",
      rules: Pattern,
    };
  },
  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 {
          this.$message.error("客户不存在")
        }
      });
    }
  },
  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("保存失败!");
            });
潘际乾 committed
142 143
        } else {
          Utils.formValidateTips(this.$refs.modelForm.fields)
潘际乾 committed
144 145 146 147 148 149 150 151 152 153 154 155 156 157
        }
      });
    },
    commitEdit() {
      this.$refs.modelForm.validate((validated) => {
        if (validated) {
          edit(this.model)
            .then((res) => {
              this.$message.success("保存成功!");
              this.goBack()
            })
            .catch((err) => {
              this.$message.error("保存失败!");
            });
潘际乾 committed
158 159
        } else {
          Utils.formValidateTips(this.$refs.modelForm.fields)
潘际乾 committed
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
        }
      });
    },
    commitDelete() {
      this.$confirm("是否确认删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          deleteById(this.model.inr)
            .then((res) => {
              this.$message.success("删除成功!");
              this.goBack(true)
            })
            .catch((err) => {
              this.$message.error("删除失败!");
            });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    /**
     * update 是否更新infpty的查询列表
     */
    goBack(update) {
      this.$store.dispatch("TagsView/delView", this.$route);
      this.$router.push({ name: "StaticsInfpty", params: { update } });
    },
潘际乾 committed
193

潘际乾 committed
194 195 196 197 198 199
  },
};
</script>

<style>
</style>