UclList.vue 6.04 KB
Newer Older
hewei committed
1 2 3 4 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 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
<template>
  <div class="eibs-tab">
    <div style="text-align: right">
      <c-button size="small" type="primary" @click="uclAdd()"> 新增 </c-button>
    </div>

    <el-form-item label="" label-width="0" prop="uclList">
      <c-table :columnsConfig="columns" :list="model.uclList">
        <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="uclInfo(scope.$index, scope.row)"
            >
              <span>详情</span>
            </button>
            <c-button
                style="margin-left: 5px"
                size="small"
                type="primary"
                @click="uclEdit(scope.$index, scope.row)"
            >
              修改
            </c-button>
            <c-button
                style="margin-left: 5px"
                size="small"
                type="primary"
                @click="uclDelete(scope.$index, scope.row)"
            >
              删除
            </c-button>
          </template>
        </c-table-column>
      </c-table>
    </el-form-item>

    <el-dialog
        :title="
        '柜员组信息:' +
        (operate === 'details' ? '详情' : operate === 'edit' ? '修改' : '新增')
      "
        :visible.sync="uclDialog"
        top="10vh"
        width="80%"
        :destroy-on-close="true"
        :before-close="handleClose"
    >
      <m-ucl-inf ref="ucl" :ucl="ucl" :operate="operate"></m-ucl-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="editUcl" v-if="operate === 'edit'"
        >保 存</c-button
        >
        <c-button type="primary" @click="saveUcl" v-if="operate === 'add'"
        >保 存</c-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import UclInfo from "./UclInfo";
import Ucl from "./Ucl";

import {
  addUclData,
  updateUclData,
  deleteUclData,
} from "@/service/test/usr";

export default {
  name: "UclList",
  inject: ["root"],
  props: ["model"],
  components: {
    "m-ucl-inf": UclInfo,
  },
  data() {
    return {
      uclDialog: false,
      ucl: null,
      operate: "",
      operateIdx: 0,
      columns: [
        { label: '默认的机构标志', prop: 'usrdef', width: 'auto' },
        { label: '用户ID', prop: 'usr', width: 'auto' },
        { label: '用户所在机构和用户名称', prop: 'mannam', width: 'auto' },
        { label: '机构INR', prop: 'branchinr', width: 'auto' },
        { label: '用户可作业务的列表', prop: 'objlst', width: 'auto' },
        { label: '是否参与任务分配', prop: 'assignflg', width: 'auto' },
      ],
    };
  },
  methods: {
    /**
     * 信息详情
     */
    uclInfo(index, row) {
      this.ucl = { ...row };
      this.operate = "details";
      this.operateIdx = index;
      this.uclDialog = true;
    },
    /**
     * 新增
     */
    uclAdd() {
      this.ucl = new Ucl().data;
      this.operate = "add";
      this.uclDialog = true;
    },
    /**
     * 修改
     */
    uclEdit(index, row) {
      this.ucl = { ...row };
      this.operate = "edit";
      this.operateIdx = index;
      this.uclDialog = true;
    },
    /**
     * 删除
     */
    uclDelete(index, row) {
      this.$confirm("是否真的删除?", "提示", {
        confirmButtonText: "确认",
        cancelButtonText: "取消",
        type: "warning",
      }).then((res) => {
hewei committed
146 147
        console.log(row.branchinr)
        deleteUclData(row.usr, row.branchinr).then((res) => {
hewei committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
          if (res) {
            this.model.uclList.splice(index, 1);
            this.$message.success("删除成功!");
          } else {
            this.$message.error("删除失败!");
          }
        });
      });
    },
    cancel() {
      this.handleClose();
    },
    editUcl() {
      this.$refs.ucl.$refs.modelForm.validate((validated) => {
        if (validated) {
163
          updateUclData(this.model.inr,this.ucl)
hewei committed
164
              .then((res) => {
165
                if (res) {
hewei committed
166
                  this.$message.success("修改柜员组信息成功!");
167
                  //TODO model.uclList回填
168
                  this.model.uclList = res.uclList;
hewei committed
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
                  this.handleClose();
                }
              })
              .catch((error) => {
                this.$message.error("修改柜员组信息失败!");
              });
        }
      });
    },

    saveUcl() {
      for (const key in this.ucl) {
        if (Object.hasOwnProperty.call(this.ucl, key)) {
          const v = this.ucl[key];
          if (typeof v === 'string' && v === '') {
            this.ucl[key] = " "
          }
        }
      }
      if (this.root.type === "add") {
        this.model.uclList.push(this.ucl);
        this.handleClose();
      } else {
        this.$refs.ucl.$refs.modelForm.validate((validated) => {
          if (validated) {
194
            addUclData(this.model.inr,this.ucl)
hewei committed
195
                .then((res) => {
hewei committed
196 197
                  if (res) {
                    this.$message.success("保存柜员组信息成功!");
198
                    //TODO model.uclList回填
199
                    this.model.uclList = res.uclList;
hewei committed
200 201 202 203
                    this.handleClose();
                  }
                })
                .catch((error) => {
hewei committed
204
                  this.$message.error("保存柜员组信息失败!");
hewei committed
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
                });
          }
        });
      }
    },

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

<style>
</style>