index.vue 16.5 KB
Newer Older
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
1 2 3 4 5
<template>
  <div class="app-container">

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
huyufeng's avatar
huyufeng committed
6
        <el-button type="warning" plain icon="el-icon-plus" size="mini" @click="handleUpdate"
7
                   v-hasPermi="['ecw:currency:update']">{{$t('修改')}}
huyf's avatar
huyf committed
8
        </el-button>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
9 10 11 12 13 14
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list">
15
      <el-table-column :label="$t('金额')" align="center" prop="fromFee">
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
16
        <template slot-scope="scope">
17 18
          <span>{{scope.row.fromFee}}
            <!-- {{ scope.row.fromCurrency | currencyDataFilter(currencyDictDatas) }} -->
19
            {{currencyName(scope.row.fromCurrency)}}
20
          </span>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
21 22
        </template>
      </el-table-column>
huyufeng's avatar
huyufeng committed
23
      <el-table-column label="" align="center">=</el-table-column>
24
      <el-table-column :label="$t('兑换金额')" align="center">
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
25
        <template slot-scope="scope">
huyufeng's avatar
huyufeng committed
26 27
          <el-input v-show="showFlag" v-model="scope.row.toFee" type="text" @blur="updateEcash(scope.row)"></el-input>
          <span v-show="!showFlag">{{ scope.row.toFee}}</span>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
28 29
        </template>
      </el-table-column>
30
      <el-table-column :label="$t('兑换货币类型')" align="center" prop="toCurrency">
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
31
        <template slot-scope="scope">
32
          <!-- <span>{{ scope.row.toCurrency | currencyDataFilter(currencyDictDatas) }}</span> -->
33
          {{currencyName(scope.row.toCurrency)}}
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
34 35 36
        </template>
      </el-table-column>
    </el-table>
huyufeng's avatar
huyufeng committed
37 38
    <el-card>
      <el-form ref="retForm" :model="retForm">
39
        <el-form-item :label="$t('有效时间') + '(' + $t('尼日利亚') + ')'">
huyf's avatar
huyf committed
40
          <el-col :span="3">
huyf's avatar
huyf committed
41 42 43
            <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss"
                            v-model="retForm.nrlyStartTime"
                            style="width: 100%;" @change="changeDictData1"></el-date-picker>
huyf's avatar
huyf committed
44 45 46
          </el-col>
          <el-col :span="1" align="center">-</el-col>
          <el-col :span="3">
huyf's avatar
huyf committed
47 48 49
            <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss"
                            v-model="retForm.nrlyEndTime" @change="changeDictData2"
                            style="width: 100%;"></el-date-picker>
huyf's avatar
huyf committed
50
          </el-col>
huyufeng's avatar
huyufeng committed
51
        </el-form-item>
huyf's avatar
huyf committed
52 53
      </el-form>
      <el-form>
54
        <el-form-item :label="$t('有效时间') +'(' + $t('北京') + ')'">
huyf's avatar
huyf committed
55
          <el-col :span="3">
huyf's avatar
huyf committed
56 57 58
            <el-date-picker type="datetime" :disable="showFlag" value-format="yyyy-MM-dd HH:mm:ss"
                            format="yyyy-MM-dd HH:mm:ss" @change="changeDictData3"
                            v-model="retForm.bjStartTime"
huyf's avatar
huyf committed
59
                            style="width: 100%;"></el-date-picker>
huyf's avatar
huyf committed
60 61 62
          </el-col>
          <el-col align="center" :span="1">-</el-col>
          <el-col :span="3">
huyf's avatar
huyf committed
63 64 65
            <el-date-picker type="datetime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss"
                            v-model="retForm.bjEndTime" @change="changeDictData4"
                            style="width: 100%;"></el-date-picker>
huyf's avatar
huyf committed
66
          </el-col>
huyufeng's avatar
huyufeng committed
67
        </el-form-item>
huyf's avatar
huyf committed
68 69
      </el-form>
      <el-form :inline="true">
70
        <el-form-item :label="$t('过期提示语')" prop="remark">
huyf's avatar
huyf committed
71
          <el-input v-model="retForm.remark" type="textarea" @change="changeDictData5"></el-input>
huyufeng's avatar
huyufeng committed
72 73 74
        </el-form-item>
      </el-form>
    </el-card>
huyf's avatar
huyf committed
75 76 77
    <!--    &lt;!&ndash; 分页组件 &ndash;&gt;-->
    <!--    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"-->
    <!--                @pagination="getList"/>-->
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
78 79

    <!-- 对话框(添加 / 修改) -->
huyufeng's avatar
huyufeng committed
80
    <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
81
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
82 83
        <el-form-item :label="$t('金额')" prop="fromFee">
          <el-input v-model="form.fromFee" :placeholder="$t('请输入金额')"/>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
84
        </el-form-item>
85
        <el-form-item :label="$t('货币类型')" prop="fromCurrency">
86 87 88 89
          <el-select v-model="form.fromCurrency" clearable>
            <el-option v-for="item in currencyList" :key="item.id"
                       :label="$l(item, 'title')" :value="item.id"/>
          </el-select>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
90
        </el-form-item>
91 92
        <el-form-item :label="$t('兑换金额')" prop="toFee">
          <el-input v-model="form.toFee" :placeholder="$t('请输入兑换金额')"/>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
93
        </el-form-item>
94 95
        <!--        <el-form-item :label="$t('状态')" prop="show">-->
        <!--          <el-input v-model="form.show" :placeholder="$t('请输入状态')" />-->
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
96
        <!--        </el-form-item>-->
97
        <el-form-item :label="$t('兑换货币类型')" prop="toCurrency">
huyufeng's avatar
huyufeng committed
98
          <el-select v-model="form.toCurrency" clearable>
99 100
            <el-option v-for="item in currencyList" :key="item.id"
                       :label="$l(item, 'title')" :value="item.id"/>
huyufeng's avatar
huyufeng committed
101 102
          </el-select>
        </el-form-item>
Marcus's avatar
Marcus committed
103
        <el-form-item :label="$t('开始时间(尼日利亚)')" prop="nrlyStartTime">
huyf's avatar
huyf committed
104
          <el-date-picker v-model="form.nrlyStartTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss"
105
                          type="datetime" :placeholder="$t('选择开始时间')"></el-date-picker>
huyufeng's avatar
huyufeng committed
106
        </el-form-item>
Marcus's avatar
Marcus committed
107
        <el-form-item :label="$t('结束时间(尼日利亚)')" prop="nrlyEndTime">
huyf's avatar
huyf committed
108
          <el-date-picker v-model="form.nrlyEndTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss"
109
                          type="datetime" :placeholder="$t('选择结束时间')"></el-date-picker>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
110
        </el-form-item>
Marcus's avatar
Marcus committed
111
        <el-form-item :label="$t('开始时间(北京)')" prop="bjStartTime">
huyf's avatar
huyf committed
112
          <el-date-picker v-model="form.bjStartTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss"
113
                          type="datetime" :placeholder="$t('选择开始时间')"></el-date-picker>
huyufeng's avatar
huyufeng committed
114
        </el-form-item>
Marcus's avatar
Marcus committed
115
        <el-form-item :label="$t('结束时间(北京)')" prop="bjEndTime">
huyf's avatar
huyf committed
116
          <el-date-picker v-model="form.bjEndTime" value-format="yyyy-MM-dd HH:mm:ss" format="yyyy-MM-dd HH:mm:ss"
117
                          type="datetime" :placeholder="$t('选择结束时间')"></el-date-picker>
huyufeng's avatar
huyufeng committed
118
        </el-form-item>
119
        <el-form-item :label="$t('过期提示语')" prop="remark">
huyufeng's avatar
huyufeng committed
120
          <el-input v-model="form.remark" type="textarea"></el-input>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
121 122
        </el-form-item>
        <!--        <el-form-item label="" prop="createAt">-->
123
        <!--          <el-input v-model="form.createAt" :placeholder="$t('请输入')" />-->
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
124 125
        <!--        </el-form-item>-->
        <!--        <el-form-item label="" prop="updateAt">-->
126
        <!--          <el-input v-model="form.updateAt" :placeholder="$t('请输入')" />-->
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
127 128 129
        <!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
Marcus's avatar
Marcus committed
130 131
        <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
        <el-button @click="cancel">{{ $t('取 消') }}</el-button>
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
132 133 134 135 136 137
      </div>
    </el-dialog>
  </div>
</template>

<script>
huyf's avatar
huyf committed
138 139 140 141
    import {
        createCurrencyEcash,
        updateCurrencyEcash,
        deleteCurrencyEcash,
huyf's avatar
huyf committed
142
        updateCurrencyEcashAll,
huyf's avatar
huyf committed
143 144 145 146 147 148
        getCurrencyEcash,
        getCurrencyEcashPage,
        exportCurrencyEcashExcel
    } from "@/api/ecw/currencyEcash";
    import {CommonStatusEnum} from "@/utils/constants";
    import {changeUserStatus} from "@/api/system/user";
huyf's avatar
huyf committed
149
    import {DICT_TYPE, getDictDatas, getDictData} from "@/utils/dict";
150 151
    import { getCurrencyList } from "@/api/ecw/currency";
    import {arrryToKeyedObjectBy} from '@/utils/index'
huyf's avatar
huyf committed
152 153 154
    export default {
        name: "CurrencyEcash",
        components: {},
155
        /* filters: {
huyf's avatar
huyf committed
156
            currencyDataFilter(e, currencyDictDatas) {
157
                if (e) return currencyDictDatas.find(item => item.value == e)
huyf's avatar
huyf committed
158 159
            },
            ecashDataFilter(e, ecashDatas) {
160
                if (e) return ecashDatas.find(item => item.value == e)
huyf's avatar
huyf committed
161
            }
162
        }, */
huyf's avatar
huyf committed
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
        data() {
            return {
                // 遮罩层
                loading: true,
                // 导出遮罩层
                exportLoading: false,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                // E-Cash汇率单位列表
                list: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                dateRangeCreateTime: [],
                showFlag: false,
huyf's avatar
huyf committed
181 182 183 184 185
                nrlyStartTime: getDictData(DICT_TYPE.ECASH_INIT, 1).label,
                nrlyEndTime: getDictData(DICT_TYPE.ECASH_INIT, 2).label,
                bjStartTime: getDictData(DICT_TYPE.ECASH_INIT, 3).label,
                bjEndTime: getDictData(DICT_TYPE.ECASH_INIT, 4).label,
                remark: getDictData(DICT_TYPE.ECASH_INIT, 5).label,
huyf's avatar
huyf committed
186 187 188 189 190 191 192 193 194 195 196 197 198
                startTime: "",
                // 查询参数
                queryParams: {
                    pageNo: 1,
                    pageSize: 10,
                    titleZh: null,
                    titleEn: null,
                    fuhao: null,
                    status: null,
                    huilv: null,
                    aorder: null,
                },
                retForm: {},
huyf's avatar
huyf committed
199
                updForm: {},
huyf's avatar
huyf committed
200 201 202 203
                // 表单参数
                form: {},
                // 表单校验
                rules: {},
204 205
                /* statusDictDatas: getDictDatas(DICT_TYPE.COMMON_STATUS), */
                /* ecashDatas: getDictDatas(DICT_TYPE.ECASH_INIT), */
206
                currencyList: []
huyf's avatar
huyf committed
207 208
            };
        },
209 210 211 212 213 214 215 216 217 218 219 220
        computed:{
          currencyMap(){
            return arrryToKeyedObjectBy(this.currencyList, 'id')
          },
          currencyName(){
            return id => {
              let obj = this.currencyMap[id]
              if(obj) return this.$l(obj, 'title')
              return this.$t('未知')
            }
          }
        },
huyf's avatar
huyf committed
221 222
        created() {
            this.getList();
223 224 225
            getCurrencyList().then(res => {
              this.currencyList = res.data
            })
huyf's avatar
huyf committed
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
        },
        methods: {
            /** 查询列表 */
            getList() {
                this.loading = true;
                // 处理查询参数
                let params = {...this.queryParams};
                this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
                // 执行查询
                getCurrencyEcashPage(params).then(response => {
                    this.list = response.data.list;
                    this.retForm = response.data.list[0];
                    this.total = response.data.total;
                    this.loading = false;
                });
            },
            /** 取消按钮 */
            cancel() {
                this.open = false;
                this.reset();
            },
            /** 表单重置 */
            reset() {
                this.form = {
                    id: undefined,
                    titleZh: undefined,
                    titleEn: undefined,
                    fuhao: undefined,
                    status: undefined,
                    huilv: undefined,
                    aorder: undefined,
                };
                this.resetForm("form");
            },
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNo = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.dateRangeCreateTime = [];
                this.resetForm("queryForm");
                this.handleQuery();
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.reset();
                this.open = true;
275
                this.title = this.$t("添加E-Cash汇率单位");
huyf's avatar
huyf committed
276 277 278 279 280 281 282 283 284 285 286 287 288 289
            },
            /** 修改按钮操作 */
            handleUpdate() {
                this.showFlag = true;
                // this.reset();
                // const id = row.id;
                // getCurrencyEcash(id).then(response => {
                //   this.form = response.data;
                //   this.open = true;
                //   this.title = "修改E-Cash汇率单位";
                // });
            },
            updateEcash(row) {
                updateCurrencyEcash(row).then(response => {
290
                    this.$modal.msgSuccess(this.$t("修改成功"));
huyf's avatar
huyf committed
291 292 293 294
                    this.getList();
                    this.showFlag = false;
                });
            },
huyf's avatar
huyf committed
295 296 297
            changeDictData1(value) {
                this.updForm.nrlyStartTime = value;
                updateCurrencyEcashAll(this.updForm).then(response => {
298
                    this.$modal.msgSuccess(this.$t("修改成功"));
huyf's avatar
huyf committed
299 300 301 302 303 304 305
                    this.getList();
                    this.showFlag = false;
                });
            },
            changeDictData2(value) {
                this.updForm.nrlyEndTime = value;
                updateCurrencyEcashAll(this.updForm).then(response => {
306
                    this.$modal.msgSuccess(this.$t("修改成功"));
huyf's avatar
huyf committed
307 308 309 310 311 312 313
                    this.getList();
                    this.showFlag = false;
                });
            },
            changeDictData3(value) {
                this.updForm.bjStartTime = value;
                updateCurrencyEcashAll(this.updForm).then(response => {
314
                    this.$modal.msgSuccess(this.$t("修改成功"));
huyf's avatar
huyf committed
315 316 317 318 319 320 321
                    this.getList();
                    this.showFlag = false;
                });
            },
            changeDictData4(value) {
                this.updForm.bjEndTime = value;
                updateCurrencyEcashAll(this.updForm).then(response => {
322
                    this.$modal.msgSuccess(this.$t("修改成功"));
huyf's avatar
huyf committed
323 324 325 326 327 328 329
                    this.getList();
                    this.showFlag = false;
                });
            },
            changeDictData5(value) {
                this.updForm.remark = value;
                updateCurrencyEcashAll(this.updForm).then(response => {
330
                    this.$modal.msgSuccess(this.$t("修改成功"));
huyf's avatar
huyf committed
331 332 333 334
                    this.getList();
                    this.showFlag = false;
                });
            },
huyf's avatar
huyf committed
335 336 337 338 339 340 341 342 343
            /** 提交按钮 */
            submitForm() {
                this.$refs["form"].validate(valid => {
                    if (!valid) {
                        return;
                    }
                    // 修改的提交
                    // if (this.form.id != null) {
                    //   updateCurrencyEcash(this.form).then(response => {
344
                    //     this.$modal.msgSuccess(this.$t("修改成功"));
huyf's avatar
huyf committed
345 346 347 348 349 350 351
                    //     this.open = false;
                    //     this.getList();
                    //   });
                    //   return;
                    // }
                    // 添加的提交
                    createCurrencyEcash(this.form).then(response => {
352
                        this.$modal.msgSuccess(this.$t("新增成功"));
huyf's avatar
huyf committed
353 354 355 356 357 358 359 360
                        this.open = false;
                        this.getList();
                    });
                });
            },
            /** 删除按钮操作 */
            handleDelete(row) {
                const id = row.id;
361
                this.$modal.confirm(this.$t('是否确认删除E-Cash汇率单位编号为{id}的数据项?', {id})).then(function () {
huyf's avatar
huyf committed
362 363 364
                    return deleteCurrencyEcash(id);
                }).then(() => {
                    this.getList();
365
                    this.$modal.msgSuccess(this.$t("删除成功"));
huyf's avatar
huyf committed
366 367 368 369 370 371 372 373 374 375 376
                }).catch(() => {
                });
            },
            /** 导出按钮操作 */
            handleExport() {
                // 处理查询参数
                let params = {...this.queryParams};
                params.pageNo = undefined;
                params.pageSize = undefined;
                this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime');
                // 执行导出
377
                this.$modal.confirm(this.$t('是否确认导出所有E-Cash汇率单位数据项?')).then(() => {
huyf's avatar
huyf committed
378 379 380 381 382 383 384 385
                    this.exportLoading = true;
                    return exportCurrencyEcashExcel(params);
                }).then(response => {
                    this.$download.excel(response, '${table.classComment}.xls');
                    this.exportLoading = false;
                }).catch(() => {
                });
            }
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
386
        }
huyf's avatar
huyf committed
387
    };
houjn@hikoon.cn's avatar
houjn@hikoon.cn committed
388
</script>