<template>
   <div class="app-container">
      研发中...
   </div>
</template>

<script setup name="BankingRegulations">
import { listBank, delBank, changeBankStatus } from "@/api/payment/bank";
import { getLocalStorage } from "@/utils/auth";

const { proxy } = getCurrentInstance();

const fileHost = getLocalStorage('fileUrl') || ''; // 文件host
const bankList = ref([]);
const loading = ref(true);
const total = ref(0);
const queryParams = reactive({
   pageNum: 1,
   pageSize: 20,
   currencyType: null,
   bankCode: null,
   status: null
});

// 查询银行管理列表
function getList() {
}

// 新增按钮操作
const addEditStatus = ref('add'), isShowDialog = ref(false), editDataId = ref('');
const handleAdd = () => {
   isShowDialog.value = true;
   addEditStatus.value = 'add';
}

// 修改
const handleUpdate = (row) => {
   editDataId.value = row.id;
   isShowDialog.value = true;
   addEditStatus.value = 'edit';
}

// 关闭新增修改弹窗
const closeDialog = (type) => {
   switch (type) {
      case 'add-edit': // 新增-修改弹窗
         addEditStatus.value = 'add';  // 每次关闭还原为新增模式
         isShowDialog.value = false;
         break
   }

   // 刷新列表
   getList();
}

// 表格中开启状态开关
const switchBeforeChange = () => {
   return false;
}

// 银行启用状态更改
const changeStatus = (row) => { // row.status: 0-停用 1-启用
   proxy.$modal.confirm( proxy.t('确认{}“' + row.bankName + '”？', +row.status === 1 ? '启用' : '停用')).then(() => {
      changeBankStatus({ id: row.id, status: +row.status === 1 ? 0 : 1 }).then(res => {
         proxy.$modal.msgSuccess(proxy.t(row.bankName + ' {}成功！', +row.status === 1 ? '启用' : '停用'));
         getList();
      })
   }).catch(() => { });
}

// 删除
const handleDelete = (row) => {
   proxy.$modal.confirm(proxy.t('确认删除“' + row.bankName + '”的数据？')).then(() => {
      return delBank(row.id);
   }).then(() => {
      getList();
      proxy.$modal.msgSuccess(proxy.t('删除成功！'));
   }).catch(() => { });
}

// 搜索
const handleQuery = () => {
   queryParams.pageNum = 1;
   getList();
}

// 重置
const resetQuery = () => {
   handleQuery();
}

getList();
</script>