123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 |
- <template>
- <div class="form">
- <van-nav-bar :title="$t('account.' + route.query.type)" :left-text="$t('common.back')" left-arrow @click-left="onClickLeft"> </van-nav-bar>
- <testForm v-model="formData.data" :formOption="formOption" :formConfig="formConfig" :rules="rules" @onSubmit="onSubmit" ref="formDom"> </testForm>
- </div>
- </template>
- <script setup>
- import { ref, getCurrentInstance, onMounted, reactive } from "vue";
- import { showSuccessToast, showFailToast } from "vant";
- import { useRoute } from "vue-router";
- import { getUserInfo } from "@/utils/auth";
- import testForm from "@/components/testForm/index.vue";
- const proxy = getCurrentInstance().proxy;
- const onClickLeft = () => history.back();
- const route = useRoute();
- const getDict = () => {
- proxy
- .post("/dictTenantData/page", {
- pageNum: 1,
- pageSize: 999,
- dictCode: "account_currency",
- tenantId: getUserInfo().tenantId,
- })
- .then((res) => {
- if (res.data.rows && res.data.rows.length > 0) {
- formOption.btnConfig.listConfig[0].data = res.data.rows.map((item) => {
- return {
- text: item.dictValue,
- value: item.dictKey,
- };
- });
- }
- });
- proxy.post("/corporation/page", { pageNum: 1, pageSize: 9999 }).then((res) => {
- if (res.data.rows && res.data.rows.length > 0) {
- formConfig[0].data = res.data.rows.map((item) => {
- return {
- ...item,
- label: item.name,
- value: item.id,
- };
- });
- }
- });
- };
- getDict();
- const formData = reactive({
- data: {
- corporationId: null,
- alias: null,
- name: null,
- openingBank: null,
- accountOpening: null,
- interbankNumber: null,
- beneficiaryName: null,
- beneficiaryBank: null,
- beneficiaryBankAddress: null,
- beneficiaryAccountNumber: null,
- swiftCode: null,
- beneficiaryAddress: null,
- accountRemainderList: [],
- },
- });
- const formDom = ref(null);
- const formOption = reactive({
- readonly: false, //用于控制整个表单是否只读
- disabled: false,
- labelAlign: "top",
- scroll: true,
- labelWidth: "62pk",
- hiddenSubmitBtn: false,
- btnConfig: {
- isNeed: true,
- prop: "accountRemainderList",
- plain: true,
- listTitle: proxy.t("account.accountBalance"),
- listConfig: [
- {
- type: "picker",
- label: proxy.t("account.currency"),
- prop: "currency",
- itemType: "onePicker",
- showPicker: false,
- readonly: false,
- fieldNames: {
- text: "text",
- value: "value",
- },
- data: [],
- },
- {
- type: "input",
- label: proxy.t("account.remainder"),
- prop: "remainder",
- itemType: "number",
- },
- ],
- clickFn: () => {
- if (formData.data.accountRemainderList && formData.data.accountRemainderList.length > 0) {
- formData.data.accountRemainderList.push({
- currency: null,
- remainder: null,
- });
- } else {
- formData.data.accountRemainderList = [
- {
- currency: null,
- remainder: null,
- },
- ];
- }
- },
- },
- });
- const formConfig = reactive([
- {
- type: "picker",
- label: proxy.t("account.company"),
- prop: "corporationId",
- itemType: "onePicker",
- showPicker: false,
- fieldNames: {
- text: "label",
- value: "value",
- },
- data: [],
- },
- {
- type: "input",
- label: proxy.t("account.alias"),
- prop: "alias",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.openingBank"),
- prop: "openingBank",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.accountName"),
- prop: "name",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.accountOpening"),
- prop: "accountOpening",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.interbankNumber"),
- prop: "interbankNumber",
- itemType: "text",
- },
- {
- type: "title",
- title: proxy.t("account.foreignExchange"),
- },
- {
- type: "input",
- label: proxy.t("account.beneficiaryName"),
- prop: "beneficiaryName",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.beneficiaryBank"),
- prop: "beneficiaryBank",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.beneficiaryBankAddress"),
- prop: "beneficiaryBankAddress",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.beneficiaryAccountNumber"),
- prop: "beneficiaryAccountNumber",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.swiftCode"),
- prop: "swiftCode",
- itemType: "text",
- },
- {
- type: "input",
- label: proxy.t("account.beneficiaryAddress"),
- prop: "beneficiaryAddress",
- itemType: "text",
- },
- ]);
- const rules = {
- corporationId: [{ required: true, message: proxy.t("account.companyMsg") }],
- alias: [{ required: true, message: proxy.t("account.aliasMsg") }],
- openingBank: [{ required: true, message: proxy.t("account.openingBankMsg") }],
- name: [{ required: true, message: proxy.t("account.accountNameMsg") }],
- accountOpening: [{ required: true, message: proxy.t("account.accountOpeningMsg") }],
- currency: [{ required: true, message: proxy.t("account.currencyMsg") }],
- remainder: [{ required: true, message: proxy.t("account.remainderMsg") }],
- };
- const isRepeat = (arr) => {
- var hash = {};
- for (var i in arr) {
- if (hash[arr[i].currency]) return true;
- hash[arr[i].currency] = true;
- }
- return false;
- };
- const onSubmit = () => {
- if (formData.data.accountRemainderList && formData.data.accountRemainderList.length > 0) {
- if (isRepeat(formData.data.accountRemainderList)) {
- showFailToast(proxy.t("account.submitMsgTwo"));
- } else {
- proxy.post("/accountManagement/" + route.query.type, formData.data).then(() => {
- showSuccessToast(proxy.t("common.addSuccess"));
- setTimeout(() => {
- history.back();
- }, 500);
- });
- }
- } else {
- showFailToast(proxy.t("account.submitMsgOne"));
- }
- };
- onMounted(() => {
- if (route.query.id) {
- proxy.post("/accountManagement/detail", { id: route.query.id }).then((res) => {
- formData.data = res.data;
- if (formData.data.accountRemainderList && formData.data.accountRemainderList.length > 0) {
- for (let i = 0; i < formData.data.accountRemainderList.length; i++) {
- let data = formOption.btnConfig.listConfig[0].data.filter((item) => item.value === formData.data.accountRemainderList[i].currency);
- if (data && data.length > 0) {
- formData.data.accountRemainderList[i].currencyName = data[0].text;
- }
- }
- }
- });
- }
- });
- </script>
|