123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- <!-- 币别及汇率 -->
- <template>
- <div>
- <basic-container v-show="isShow" class="page-crad">
- <avue-crud ref="crud" :option="option" :data="dataList" :before-open="beforeOpen" id="out-table"
- :header-cell-class-name="headerClassName" :page.sync="page" :search.sync="search" @search-change="searchChange"
- @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad"
- :table-loading="loading" @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 305)"
- @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 305)" @selection-change="selectionChange"
- :cell-style="cellStyle" @search-criteria-switch="searchCriteriaSwitch">
- <template slot="code" slot-scope="scope">
- <avue-text-ellipsis :text="scope.row.code" :height="30" use-tooltip placement="top">
- <small slot="more">...</small>
- </avue-text-ellipsis>
- </template>
- <template slot="cnName" slot-scope="scope">
- <avue-text-ellipsis :text="scope.row.cnName" :height="30" use-tooltip placement="top">
- <small slot="more">...</small>
- </avue-text-ellipsis>
- </template>
- <template slot="enName" slot-scope="scope">
- <avue-text-ellipsis :text="scope.row.enName" :height="30" use-tooltip placement="top">
- <small slot="more">...</small>
- </avue-text-ellipsis>
- </template>
- <template slot-scope="{ row }" slot="updateUser">
- <span>{{ row.updateUserName }}</span>
- </template>
- <template slot="menuLeft">
- <!--<el-button type="danger" size="small" icon="el-icon-delete" plain @click="handleDelete">删 除-->
- <!--</el-button>-->
- </template>
- <template slot-scope="{ row, index }" slot="menu">
- <el-button icon="el-icon-edit" type="text" size="small" @click.stop="editOpen(row, 1)">
- 编辑
- </el-button>
- <!--<el-button icon="el-icon-delete" type="text" size="small" @click.stop="rowDel(row, index)">-->
- <!-- 删除-->
- <!--</el-button>-->
- <el-button v-if="row.status == 1" type="text" icon="el-icon-turn-off" style="color: #85e967" size="small"
- @click.stop="statusfun(row.id,0)">
- 启用
- </el-button>
- <el-button v-if="row.status == 0" type="text" icon="el-icon-turn-off" style="color: #e83c3a" size="small"
- @click.stop="statusfun(row.id,1)">
- 停用
- </el-button>
- </template>
- </avue-crud>
- </basic-container>
- <detailPage v-if="!isShow" ref="detail" @goBack="goBack" :detailData="detailData"></detailPage>
- </div>
- </template>
- <script>
- import detailPage from "./detailsPage";
- import {getRateList, deleteDetails, dataDetail,typeSave} from "@/api/iosBasicData/rateManagement";
- export default {
- name: "index",
- components: {
- detailPage
- },
- data() {
- return {
- selectionList: [],
- form: {},
- dataList: [],
- loading: false,
- isShow: true,
- detailData: {},
- search: {},
- page: {
- pageSize: 10,
- currentPage: 1,
- pageSizes: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500]
- },
- option: {},
- optionBack: {
- searchShow: true,
- searchMenuSpan: 6,
- align: "center",
- border: true,
- index: true,
- viewBtn: false,
- editBtn: false,
- delBtn: false,
- tip: false,
- selection: true,
- searchIcon: true,
- searchIndex: 3,
- calcHeight: 30,
- addBtnText: "新建币别及汇率",
- addBtn:false,
- stripe: true,
- menuWidth:140,
- column: [
- {
- label: "编码",
- prop: "code",
- width: "180",
- overHidden: true,
- search: true
- },
- {
- label: "中文名称",
- prop: "cnName",
- width: "180",
- overHidden: true,
- search: true
- },
- {
- label: "英文名称",
- prop: "enName",
- width: "180",
- overHidden: true,
- search: true
- },
- {
- label: "国际三字码",
- prop: "unCode",
- overHidden: true,
- search: true
- },
- {
- label: "货币符号",
- prop: "symbol",
- overHidden: true
- },
- {
- label: "是否本币",
- prop: "isLocal",
- dicData: [{
- label: '非本币',
- value: 0
- }, {
- label: '本币',
- value: 1
- }],
- overHidden: true
- },
- {
- label: "对本币汇率",
- prop: "exrate",
- overHidden: true
- },
- {
- label: "国家编码",
- prop: "cntyCode",
- overHidden: true
- },
- {
- label: "国家名称",
- prop: "cntyName",
- overHidden: true
- },
- {
- label: "状态",
- prop: "status",
- type: "select",
- dicData: [{
- label: '启用',
- value: 0
- }, {
- label: '停用',
- value: 1
- }],
- value: 0,
- overHidden: true
- }
- ]
- }
- };
- },
- async created() {
- this.option.height = window.innerHeight - 210;
- this.option = await this.getColumnData(this.getColumnName(305), this.optionBack);
- },
- activated() {
- if (this.$route.query.check) {
- this.isShow = true;
- setTimeout(() => {
- this.editOpen({ id: this.$route.query.check.billId }, 1);
- }, 100);
- }
- },
- methods: {
- // 禁用启用按钮
- statusfun(id,status){
- this.$confirm("确定将选择数据更改状态?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(()=>{
- dataDetail(id).then(res=>{
- let obj = res.data.data;
- obj.status = status
- typeSave(obj).then(()=>{
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- })
- })
- })
- },
- searchCriteriaSwitch(type) {
- if (type) {
- this.option.height = this.option.height - 46;
- } else {
- this.option.height = this.option.height + 46;
- }
- this.$refs.crud.getTableHeight();
- },
- cellStyle() {
- return "padding:0;height:40px;";
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- //点击搜索按钮触发
- searchChange(params, done) {
- this.page.currentPage = 1;
- this.onLoad(this.page, params);
- done();
- },
- refreshChange() {
- this.onLoad(this.page, this.search);
- },
- currentChange(val) {
- this.page.currentPage = val;
- },
- sizeChange(val) {
- this.page.currentPage = 1;
- this.page.pageSize = val;
- },
- onLoad(page, params = {}) {
- this.loading = true;
- let queryParams = {
- ...params,
- ...this.search,
- size: page.pageSize,
- current: page.currentPage
- };
- getRateList(queryParams)
- .then(res => {
- this.dataList = res.data.data.records ? res.data.data.records : [];
- this.page.total = res.data.data.total;
- })
- .finally(() => {
- this.loading = false;
- });
- },
- //新增跳转页面
- beforeOpen() {
- this.isShow = false;
- },
- editOpen(row, status) {
- this.detailData = {
- id: row.id,
- status: status
- };
- this.isShow = false;
- },
- rowDel(row, index, done) {
- if (row.status === 1) {
- this.$confirm("确定删除数据?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(() => {
- deleteDetails(row.id).then(res => {
- if (res.data.code == 200) {
- this.$message({
- type: "success",
- message: "删除成功!"
- });
- this.onLoad(this.page, this.search);
- }
- });
- });
- } else {
- this.$message({
- message: '非禁用状态无法删除',
- type: 'warning'
- });
- }
- },
- goBack() {
- if (this.$route.query.check) {
- this.$router.$avueRouter.closeTag(this.$route.fullPath);
- this.$router.push({
- path: "/iosBasicData/rateManagement/index"
- });
- }
- this.detailData = this.$options.data().detailData;
- this.onLoad(this.page, this.search);
- this.isShow = true;
- },
- handleDelete() {
- if (this.selectionList.length === 0) {
- this.$message.warning("请选择至少一条数据");
- return;
- }
- for (const selection of this.selectionList) {
- if (selection.status == 0) {
- this.$message.warning("选中的数据中有启用数据,启用数据不可删除!");
- return;
- }
- }
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return deleteDetails(this.ids);
- })
- .then(() => {
- this.onLoad(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.$refs.crud.toggleSelection();
- });
- },
- //自定义列保存
- async saveColumnTwo(ref, option, optionBack, code) {
- /**
- * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
- * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
- * 一定要执行异步操作,要等接口成功返回,才能执行下一行编码
- */
- const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs[ref].$refs.dialogColumn.columnBox = false;
- }
- },
- //自定义列重置
- async resetColumnTwo(ref, option, optionBack, code) {
- this[option] = this[optionBack];
- const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
- if (inSave) {
- this.$message.success("重置成功");
- this.$refs[ref].$refs.dialogColumn.columnBox = false;
- }
- },
- // 更改表格颜色
- headerClassName(tab) {
- //颜色间隔
- let back = ""
- if (tab.columnIndex >= 0 && tab.column.level === 1) {
- if (tab.columnIndex % 2 === 0) {
- back = "back-one"
- } else if (tab.columnIndex % 2 === 1) {
- back = "back-two"
- }
- }
- return back;
- },
- }
- };
- </script>
- <style lang="scss" scoped>
- .page-crad ::v-deep .basic-container__card {
- height: 94.2vh;
- }
- ::v-deep#out-table .back-one {
- background: #ecf5ff !important;
- }
- ::v-deep#out-table .back-two {
- background: #ecf5ff !important;
- }
- /deep/ .el-col-md-8 {
- width: 24.33333%;
- }
- </style>
|