UbrList.vue 6.45 KB
Newer Older
hewei committed
1 2 3
<template>
  <div class="eibs-tab">
    <div style="text-align: right">
hewei committed
4
      <c-button size="small" type="primary" @click="ubrAdd()" :disabled="false"> 新增 </c-button>
hewei committed
5 6 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 71 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
    </div>
    <el-form-item label="" label-width="0" prop="ubrList">
      <c-table :columnsConfig="columns" :list="model.ubrList">
        <c-table-column fixed="right" prop="op" label="操作" width="200px">
          <template slot-scope="{ scope }">
            <button
                class="el-button el-button--default el-button--small"
                style="margin-left: 0"
                size="small"
                :disabled="false"
                @click.prevent="ubrInfo(scope.$index, scope.row)"
            >
              <span>详情</span>
            </button>
            <c-button
                style="margin-left: 5px"
                size="small"
                type="primary"
                @click="ubrEdit(scope.$index, scope.row)"
            >
              修改
            </c-button>
            <c-button
                style="margin-left: 5px"
                size="small"
                type="primary"
                @click="ubrDelete(scope.$index, scope.row)"
            >
              删除
            </c-button>
          </template>
        </c-table-column>
      </c-table>
    </el-form-item>

    <el-dialog
        :title="
        '柜员权限信息:' +
        (operate === 'details' ? '详情' : operate === 'edit' ? '修改' : '新增')
      "
        :visible.sync="ubrDialog"
        top="10vh"
        width="80%"
        :destroy-on-close="true"
        :before-close="handleClose"
    >
      <m-ubr-inf ref="ubr" :ubr="ubr" :operate="operate"></m-ubr-inf>
      <span slot="footer" class="dialog-footer">
        <button
            class="el-button el-button--default el-button--small"
            style="margin-left: 0"
            size="small"
            :disabled="false"
            @click.prevent="cancel"
        >
          <span>取 消</span>
        </button>
        <c-button type="primary" @click="cancel" v-if="operate === 'details'"
        >确 定</c-button
        >
        <c-button type="primary" @click="editUbr" v-if="operate === 'edit'"
        >保 存</c-button
        >
        <c-button type="primary" @click="saveUbr" v-if="operate === 'add'"
        >保 存</c-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import Ubr from "./Ubr";
import UbrInfo from "./UbrInfo";

import {
  addUbrData,
  updateUbrData,
  deleteUbrData,
} from "~/service/test/usr";

export default {
  name: "UbrList",
  props: ["model"],
  inject: ["root"],
  components: {
    "m-ubr-inf": UbrInfo,
  },
  data() {
    return {
      ubrDialog: false,
      ubr: null,
      operate: "",
      operateIdx: 0,
      columns: [
        //  表结构说明:
        // { label: '唯一ID', prop: 'inr', width: 'auto' },
        { label: '用户ID', prop: 'usrinr', width: 'auto' },
        { label: '交易名', prop: 'bussec', width: 'auto' },
        { label: '授权币种', prop: 'relcur', width: 'auto' },
        { label: '授权金额', prop: 'relamt', width: 'auto' },
        { label: '第二授权金额', prop: 'relamt2nd', width: 'auto' },
        { label: '授权状态', prop: 'relgrp', width: 'auto' },
        { label: '交易代码', prop: 'trncod', width: 'auto' },
        { label: '交易所属机构', prop: 'branchinr', width: 'auto' },
        { label: '一次性授权', prop: 'autcur', width: 'auto' },
        { label: '一次性释放授权', prop: 'autamt', width: 'auto' },
      ],
    };
  },

  methods: {
    /**
     * 详情
     */
    ubrInfo(index, row) {
      this.ubr = { ...row };
      this.operate = "details";
      this.operateIdx = index;
      this.ubrDialog = true;
    },
    /**
     * 新增
     */
    ubrAdd() {
      this.ubr = new Ubr().data;
131
      this.ubr.usrinr=this.model.inr;
hewei committed
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
      this.operate = "add";
      this.ubrDialog = true;
    },
    /**
     * 修改
     */
    ubrEdit(index, row) {
      this.ubr = { ...row };
      this.operate = "edit";
      this.operateIdx = index;
      this.ubrDialog = true;
    },
    /**
     * 删除
     */
    ubrDelete(index, row) {
      this.$confirm("是否真的删除?", "提示", {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: "warning",
      }).then((res) => {
hewei committed
153
        deleteUbrData(row.inr).then((res) => {
hewei committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
          if (res) {
            this.model.ubrList.splice(index, 1);
            this.$message.success("删除成功!");
          } else {
            this.$message.error("删除失败!");
          }
        });
      });
    },
    cancel() {
      this.handleClose();
    },
    editUbr() {
      this.$refs.ubr.$refs.modelForm.validate((validated) => {
        if (validated) {
hewei committed
169
          updateUbrData(this.ubr)
hewei committed
170
              .then((res) => {
hewei committed
171
                if (res) {
hewei committed
172
                  this.$message.success("修改柜员权限信息成功!");
173
                  //TODO model.uclList回填
174
                  this.model.ubrList = res.ubrList;
hewei committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
                  this.handleClose();
                }
              })
              .catch((error) => {
                this.$message.error("修改柜员权限信息失败!");
              });
        }
      });
    },

    saveUbr() {
      for (const key in this.ubr) {
        if (Object.hasOwnProperty.call(this.ubr, key)) {
          const v = this.ubr[key];
          if (typeof v === 'string' && v === '') {
            this.ubr[key] = " "
          }
        }
      }
      if (this.root.type === "add") {
        this.model.ubrList.push(this.ubr);
        this.handleClose();
      } else {
        this.$refs.ubr.$refs.modelForm.validate((validated) => {
          if (validated) {
hewei committed
200 201
            // this.ubr.inr = this.model.inr
                addUbrData(this.ubr)
hewei committed
202
                .then((res) => {
hewei committed
203 204
                  if (res) {
                    this.$message.success("保存柜员权限信息成功!");
205 206
                    //TODO model.uclList回填
                    // this.model.ubrList = res.ubrList;
207
                    this.model.ubrList = res.ubrList;
hewei committed
208 209 210 211
                    this.handleClose();
                  }
                })
                .catch((error) => {
hewei committed
212
                  this.$message.error("保存柜员权限信息失败!");
hewei committed
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
                });
          }
        });
      }
    },

    handleClose(done) {
      this.ubrDialog = false;
      if (done && typeof done === "function") {
        done();
      }
    },
  },
};
</script>

<style>
</style>