Infsea.vue 19.1 KB
Newer Older
fukai 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 146 147 148 149 150 151 152 153 154 155 156 157 158 159 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 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541
<template>
  <div class="eibs-tab">
    <!-- ======-左=======-->
    <c-col :span="12" class="col-left">
      <c-col :span="24">
        <el-form-item label="币种名称">
          <c-select v-model="model.cod" placeholder="请输入币种名称" dbCode="CURTXT" sort="SRT" :isShowKeyAndLabel="true"
            :isCache="false" style="width: 100%" ref="selectCur">
          </c-select>
        </el-form-item>
      </c-col>
    </c-col>

    <c-col :span="24">
      <span style="float: left">
        <el-button size="small" ref="curInsertBtn" type="primary" v-if="isShowAddBtn" @click="toBbacur">新增</el-button>
      </span>
      <span style="float: right">
        <el-button size="small" @click="handleReset">重置</el-button>
        <el-button type="primary" icon="el-icon-search" size="small" :loading="searchLoading" @click="onSearch()">查询
        </el-button>
      </span>
    </c-col>

    <c-col :span="24">
      <c-paging-table :data="curData" :columns="curColumns" :pageNumber="model.pageNum" :pageSize="model.pageSize"
        :total="model.total" v-on:queryFunc="queryFunc" :border="true">
        <c-table-column fixed="right" prop="op" label="操作" width="240px">
          <template slot-scope="{ scope }">
            <c-button style="margin-left: 5px" size="small" ref="curDisplayBtn" type="info"
              @click="curDisplay(scope.row)">详情
            </c-button>
            <c-button style="margin-left: 5px" size="small" v-if="isShowUpdBtn" ref="curUpdateBtn" type="primary"
              @click="curEdit(scope.row)">修改
            </c-button>
            <c-button style="margin-left: 5px" size="small" v-if="isShowDelBtn" ref="curDeleteBtn" type="danger"
              @click="curDelete(scope.row)">删除</c-button>
          </template>
        </c-table-column>
      </c-paging-table>
    </c-col>

    <el-dialog :title="dialogNam[curtyp]" :visible.sync="dialogAdd" :modal-append-to-body="false"
      :close-on-click-modal="false" width="70%" destroy-on-close>
      <el-form ref="modelForm" :model="form" label-suffix=":" :rules="rules" :disabled="isDisabled">
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="币种代码" :label-width="formLabelWidth" prop="cod">
              <c-input v-model="form.cod" style="width: 100%" placeholder="请输入币种代码" @change="onChange"
                :disabled="curtyp == 'edit'"></c-input>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="币种名称" :label-width="formLabelWidth" prop="curnam">
              <c-input v-model="form.curnam" placeholder="请输入币种名称" @change="onChange2">
              </c-input>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="货币数字代号" :label-width="formLabelWidth" prop="altcod">
              <c-input v-model="form.altcod" placeholder="请输入货币数字代号"></c-input>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="币种小数位" :label-width="formLabelWidth" prop="dec">
              <c-input type="number" v-model="form.dec" placeholder="请输入币种小数位" min="0" max="9"></c-input>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="买价/卖价汇差" :label-width="formLabelWidth" prop="bsrmar">
              <c-input-number v-model="form.bsrmar" placeholder="请输入买价/卖价汇差">
              </c-input-number>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="币种四舍五入精度" :label-width="formLabelWidth" prop="rndunt">
              <c-input-number v-model="form.rndunt" placeholder="请输入币种四舍五入精度">
              </c-input-number>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="内部汇率汇差" prop="sqrmar" :label-width="formLabelWidth">
              <c-input-number v-model="form.sqrmar" placeholder="请输入内部汇率汇差">
              </c-input-number>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="报表折算汇率汇差" :label-width="formLabelWidth" prop="glbrat">
              <c-input-number v-model="form.glbrat" placeholder="请输入报表折算汇率汇差">
              </c-input-number>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="汇率折算单位" :label-width="formLabelWidth" prop="bas">
              <c-input v-model="form.bas" placeholder="请输入汇率折算单位">
              </c-input>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="汇率最大浮动值" :label-width="formLabelWidth" prop="dif">
              <c-input v-model="form.dif" placeholder="请输入汇率最大浮动值">
              </c-input>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="生效日期" prop="begdat" :label-width="formLabelWidth">
              <c-date-picker v-model="form.begdat" type="date" :picker-options="startDatePicker" placeholder="请输入生效日期">
              </c-date-picker>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="失效日期" prop="enddat" :label-width="formLabelWidth">
              <c-date-picker type="date" v-model="form.enddat" :picker-options="endDatePicker" placeholder="请输入失效日期">
              </c-date-picker>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="借记到账天数" :label-width="formLabelWidth" prop="dbtday">
              <c-input v-model="form.dbtday" placeholder="请输入借记到账天数">
              </c-input>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="贷记到账天数" :label-width="formLabelWidth" prop="cdtday">
              <c-input v-model="form.cdtday" placeholder="请输入贷记到账天数">
              </c-input>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="存储利率的上限币种" prop="maxcur" :label-width="formLabelWidth">
              <c-select v-model="form.maxcur" placeholder="请选择币种" dbCode="CURTXT" :isShowKeyAndLabel="true"
                :isCache="false" sort="SRT">
              </c-select>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="存储利率的上限金额" prop="maxamt" :label-width="formLabelWidth">
              <c-input type="number" v-model="form.maxamt" min="0" :precision="3" :step="0.001" autocomplete="off"
                placeholder="请输入最大金额">
              </c-input>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="货币兑换时的账号" :label-width="formLabelWidth" prop="acc1">
              <el-input v-model="form.acc1" placeholder="请输入货币兑换时的账号" maxlength="16">
              </el-input>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="货币兑换时的对应账号" :label-width="formLabelWidth" prop="acc2">
              <el-input v-model="form.acc2" placeholder="请输入货币兑换时的对应账号" maxlength="16">
              </el-input>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="批量维护牌价时的顺序" :label-width="formLabelWidth" prop="seq">
              <c-select v-model="form.seq" placeholder="请选择批量维护牌价时的顺序" dbCode="CURSEQ" :isShowKeyAndLabel="true"
                sort="SRT" @change="changeNewCur()">
              </c-select>
            </el-form-item>
          </c-col>
          <c-col :span="12">
            <el-form-item label="替换的货币代号" :label-width="formLabelWidth" prop="newcur"
              :rules="(form.seq == '-1') ? rules.newcur : [{required: false}]">
              <c-select v-model="form.newcur" placeholder="请选择替换的货币代号" dbCode="CURTXT" :isShowKeyAndLabel="true"
                :isCache="false" sort="SRT" :disabled="form.seq != '-1'"></c-select>
            </el-form-item>
          </c-col>
        </c-col>
        <c-col :span="24">
          <c-col :span="12">
            <el-form-item label="透支天数" :label-width="formLabelWidth" prop="odrintday">
              <c-input type="number" v-model="form.odrintday" placeholder="请选择透支天数" min="0">
              </c-input>
            </el-form-item>
          </c-col>
        </c-col>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="commitAdd" v-if="curtyp == 'add'">提 交</el-button>
        <el-button type="primary" @click="commitEdit" v-if="curtyp == 'edit'">提 交</el-button>
        <el-button @click="dialogAdd = false">返 回</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import Utils from "~/utils";
  import {
    queryByPage,
    deleteById,
    curInfo,
    add,
    edit,
    queryCod
  } from "~/service/manage/cur.js";
  import Cur, {
    Pattern
  } from "../Dblcur/Cur.js";

  import commonFunctions from "~/mixin/commonFunctions.js";

  export default {
    mixins: [commonFunctions],
    name: "",
    props: ["model"],
    inject: [],
    data() {
      return {
        rules: Pattern,
        curData: [],
        curColumns: [{
            label: '币种代码',
            prop: 'cod',
            width: 'auto'
          },
          {
            label: '币种名称',
            prop: 'curnam',
            width: 'auto'
          },
        ],
        dialogNam: {
          'add': '币种信息--新增',
          'edit': '币种信息--编辑',
          'info': '币种信息--查看',
        },
        isDisabled: false,
        isShowUpdBtn: false,
        isShowDelBtn: false,
        isShowAddBtn: false,
        isShowDisplayBtn: false,
        searchLoading: false,
        dialogAdd: false,
        form: new Cur().data,
        curtyp: "",
        formLabelWidth: "150px",
        startDatePicker: this.beginDate(),
        endDatePicker: this.processDate(),
      };
    },
    activated() {
      const {
        update
      } = this.$route.params
      if (update) {
        this.onSearch();
      }
    },
    created() {
      this.onInfcurSearch();
    },
    mounted() {
      this.getHiddenButtonVue();
    },
    methods: {
      getHiddenButtonVue() {
        const loading = this.loading();
        this.$buttonControlService.hiddenBtnList()
          .then((res) => {
            // 【xq】按钮
            let hasDisplay = res.some((item) => {
              return item.ITEMID === 'curDisplayBtn';
            })
            if (hasDisplay) {
              this.isShowDisplayBtn = false;
            } else {
              this.isShowDisplayBtn = true;
            }

            // 【新增】按钮
            let hasInsert = res.some((item) => {
              return item.ITEMID === 'curInsertBtn';
            })
            if (hasInsert) {
              this.isShowAddBtn = false;
            } else {
              this.isShowAddBtn = true;
            }
            // 【修改】按钮
            let hasUpdate = res.some((item) => {
              return item.ITEMID === 'curUpdateBtn';
            })
            if (hasUpdate) {
              this.isShowUpdBtn = false;
            } else {
              this.isShowUpdBtn = true;
            }
            // 【删除】按钮
            let hasDelete = res.some((item) => {
              return item.ITEMID === 'curDeleteBtn';
            })
            if (hasDelete) {
              this.isShowDelBtn = false;
            } else {
              this.isShowDelBtn = true;
            }
            loading.close();
          })
      },
      changeNewCur() {
        if (this.form.seq != '-1') {
          this.form.newcur = '';
        }
      },
      beginDate() {
        const self = this
        return {
          disabledDate(time) {
            if (self.form.enddat) { //如果结束时间不为空,则小于结束时间
              return new Date(self.form.enddat).getTime() < time.getTime()
            } else {
              // return time.getTime() > Date.now()//开始时间不选时,结束时间最大值小于等于当天
            }
          }
        }
      },
      processDate() {
        const self = this
        return {
          disabledDate(time) {
            if (self.form.begdat) { //如果开始时间不为空,则结束时间大于开始时间
              return new Date(self.form.begdat).getTime() > time.getTime()
            } else {
              // return time.getTime() > Date.now()//开始时间不选时,结束时间最大值小于等于当天
            }
          }
        }
      },
      toBbacur() {
        this.dialogAdd = true;
        this.isDisabled = false;
        this.curtyp = "add";
        this.form = new Cur().data;
      },
      async handleReset() {
        this.model.cod = ""
        this.model.curnam = ""
      },
      onSearch() {
        this.model.pageSize = PageSize;
        this.model.pageNum = 1;
        this.onInfcurSearch();
      },
      onInfcurSearch() {
        this.searchLoading = true;
        delete this.model.isModify;
        delete this.model.modifySet;
        queryByPage(this.model).then(res => {
          if (res.respCode == SUCCESS) {
            const list = res.data.list
            this.curData = list
            this.model.pageNum = res.data.pageNumber
            this.model.pageSize = res.data.pageSize
            this.model.total = res.data.total
            this.searchLoading = false;
          } else {
            this.searchLoading = false;
            this.$notify.error("查询失败");
          }
        })
      },
      commitAdd() {
        this.$refs.modelForm.validate((validated) => {
          if (validated) {
            delete this.form.isModify;
            delete this.form.modifySet;
            queryCod(this.form)
              .then(((res) => {
                if (!res.data && res.respCode == SUCCESS) {
                  add(this.form)
                    .then((res) => {
                      if (res.errorCode == "AAAAAA" || res.respCode == "AAAAAA") {
                        this.$notify.success("新增成功!");
                        this.dialogAdd = false;
                        //此方法为了刷新dbCode列表数据
                        this.$refs.selectCur.init();
                        this.onInfcurSearch();
                      } else {
                        this.$notify.error(res.respMsg);
                      }
                    })
                    .catch((err) => {
                      this.$notify.error("新增失败!");
                    });
                } else {
                  return this.$notify.error("币种代码重复")
                }
              }))
          } else {
            this.$notify.error({
              title: '失败',
              message: '请检查必输项!'
            });
          }
        });
      },
      commitEdit() {
        this.$refs.modelForm.validate((validated) => {
          if (validated) {
            delete this.form.isModify;
            delete this.form.modifySet;
            edit(this.form)
              .then((res) => {
                if (res.errorCode == "AAAAAA" || res.respCode == "AAAAAA") {
                  this.$notify.success("保存成功!");
                  this.dialogAdd = false;
                  this.$refs.selectCur.init();
                  this.onInfcurSearch();
                } else {
                  this.$notify.error(res.respMsg);
                }
              })
              .catch((err) => {
                this.$notify.error("保存失败!");
              });
          } else {
            this.$notify.error({
              title: '失败',
              message: '请检查必输项!'
            });
          }
        });
      },
      queryFunc(pageNumber, pageSize) {
        this.model.pageNum = pageNumber
        this.model.pageSize = pageSize
        this.onInfcurSearch()
      },
      onChange() {
        this.form.cod = this.form.cod.trim()
        if (this.form.cod != "") {
          delete this.form.isModify;
          delete this.form.modifySet;
          queryCod(this.form).then((res) => {
            if (res.respCode == "AAAAAA") {
              if (res.data) {
                this.$notify.error("币种代码已存在,请修改")
              }
            } else {
              this.$notify.error("检验唯一性失败")
            }
          });
        }
      },
      onChange2() {
        this.form.curnam = this.form.curnam.trim()
      },
      curDisplay(row) {
        curInfo(row).then((res) => {
          if (res.respCode == SUCCESS) {
            if (res.data.inr) {
              this.form = res.data;
              this.isDisabled = true;
              this.curtyp = "info";
              this.dialogAdd = true;
            }
          } else {
            this.$notify.error("币种不存在")
          }
        });
      },
      curEdit(row) {
        curInfo(row).then((res) => {
          if (res.respCode == SUCCESS) {
            if (res.data.inr) {
              this.isDisabled = false;
              this.form = res.data;
              this.curtyp = "edit";
              this.dialogAdd = true;
            }
          } else {
            this.$notify.error("币种不存在")
          }
        });
      },
      curDelete(row) {
        this.$confirm("是否确认删除?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
          .then(() => {
            deleteById(row)
              .then((res) => {
                if (res.errorCode == "AAAAAA" || res.respCode == "AAAAAA") {
                  this.$notify.success("删除成功!");
                  this.$refs.selectCur.init();
                  this.onInfcurSearch();
                } else {
                  this.$notify.error("删除失败!");
                }
              })
              .catch((err) => {
                this.$notify.error("删除失败!");
              });
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消删除",
            });
          });
      },
    },
  };
</script>

<style scoped>
  .table-button-item-list {
    padding: 0;
    margin: 0;
  }

  .table-button-item-list li {
    list-style: none;
    padding: 5px 0;
    text-align: center;
    color: #606266;
    cursor: pointer;
  }
</style>