|
@@ -0,0 +1,230 @@
|
|
|
+<template>
|
|
|
+ <div class="form">
|
|
|
+ <van-nav-bar
|
|
|
+ :title="$t('claim.name')"
|
|
|
+ :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, reactive, getCurrentInstance, onMounted } from "vue";
|
|
|
+import { showSuccessToast, showFailToast } from "vant";
|
|
|
+import { useRoute } from "vue-router";
|
|
|
+import testForm from "@/components/testForm/index.vue";
|
|
|
+const proxy = getCurrentInstance().proxy;
|
|
|
+const route = useRoute();
|
|
|
+const formDom = ref(null);
|
|
|
+const formData = reactive({
|
|
|
+ data: {},
|
|
|
+});
|
|
|
+const rules = {
|
|
|
+ contractId: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: proxy.t("claim.contractCanNotBeEmpty"),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ money: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: proxy.t("claim.relatedAmountCanNotBeEmpty"),
|
|
|
+ },
|
|
|
+ ],
|
|
|
+};
|
|
|
+const formOption = reactive({
|
|
|
+ readonly: false, //用于控制整个表单是否只读
|
|
|
+ disabled: false,
|
|
|
+ labelAlign: "top",
|
|
|
+ scroll: true,
|
|
|
+ labelWidth: "62pk",
|
|
|
+ submitBtnText: proxy.t("common.submit"),
|
|
|
+ btnConfig: {
|
|
|
+ isNeed: true,
|
|
|
+ listTitle: proxy.t("claim.relatedContract"),
|
|
|
+ prop: "claimContractList",
|
|
|
+ plain: true,
|
|
|
+ listConfig: [
|
|
|
+ {
|
|
|
+ type: "picker",
|
|
|
+ label: proxy.t("claim.contractCode"),
|
|
|
+ prop: "contractId",
|
|
|
+ itemType: "onePicker",
|
|
|
+ showPicker: false,
|
|
|
+ readonly: false,
|
|
|
+ fieldNames: {
|
|
|
+ text: "code",
|
|
|
+ value: "id",
|
|
|
+ },
|
|
|
+ data: [],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ itemType: "number",
|
|
|
+ label: proxy.t("claim.relatedAmount"),
|
|
|
+ prop: "money",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ clickFn: () => {
|
|
|
+ if (
|
|
|
+ formData.data.claimContractList &&
|
|
|
+ formData.data.claimContractList.length > 0
|
|
|
+ ) {
|
|
|
+ formData.data.claimContractList.push({
|
|
|
+ contractId: "",
|
|
|
+ contractCode: "",
|
|
|
+ money: "",
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ formData.data.claimContractList = [
|
|
|
+ {
|
|
|
+ contractId: "",
|
|
|
+ contractCode: "",
|
|
|
+ money: "",
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ },
|
|
|
+ },
|
|
|
+});
|
|
|
+const formConfig = reactive([
|
|
|
+ {
|
|
|
+ type: "title",
|
|
|
+ title: proxy.t("claim.accountInfo"),
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ label: proxy.t("claim.accountName"),
|
|
|
+ prop: "accountManagementName",
|
|
|
+ itemType: "text",
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ label: proxy.t("claim.accountTime"),
|
|
|
+ prop: "transactionTime",
|
|
|
+ itemType: "text",
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "input",
|
|
|
+ label: proxy.t("claim.accountAmount"),
|
|
|
+ prop: "currencyMoney",
|
|
|
+ itemType: "text",
|
|
|
+ readonly: true,
|
|
|
+ },
|
|
|
+]);
|
|
|
+const onClickLeft = () => history.back();
|
|
|
+const getDict = () => {
|
|
|
+ proxy
|
|
|
+ .post("/contract/page", {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 9999,
|
|
|
+ status: "30",
|
|
|
+ refundStatusNew: "0,10",
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ formOption.btnConfig.listConfig[0].data = res.data.rows;
|
|
|
+ });
|
|
|
+};
|
|
|
+onMounted(() => {
|
|
|
+ getDict();
|
|
|
+ if (route.query.isClaim != "1") {
|
|
|
+ proxy
|
|
|
+ .get(`/claim/sumClaimMoney?businessId=${route.query.id}`)
|
|
|
+ .then((res) => {
|
|
|
+ let waitAmount = Number(route.query.amount) - Number(res.data);
|
|
|
+ formData.data = {
|
|
|
+ businessId: route.query.id,
|
|
|
+ status: route.query.status + "",
|
|
|
+ currency: route.query.currency,
|
|
|
+ waitAmount,
|
|
|
+ accountManagementId: route.query.accountManagementId,
|
|
|
+ accountManagementName: route.query.accountManagementName,
|
|
|
+ currencyMoney: route.query.currency + " " + parseFloat(waitAmount),
|
|
|
+ transactionTime: route.query.transactionTime,
|
|
|
+ claimContractList: [],
|
|
|
+ };
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ formOption.btnConfig.isNeed = false;
|
|
|
+ formOption.readonly = true;
|
|
|
+ formOption.submitBtnText = proxy.t("claim.cancelClaim");
|
|
|
+ proxy.post("/claim/claimRecord", { businessId: route.query.id }).then(
|
|
|
+ (res) => {
|
|
|
+ formData.data = {
|
|
|
+ accountManagementName: route.query.accountManagementName,
|
|
|
+ currencyMoney: route.query.currency + " " + route.query.amount,
|
|
|
+ transactionTime: route.query.transactionTime,
|
|
|
+ claimContractList: res.data,
|
|
|
+ };
|
|
|
+ // formDom.value.formDataListShowLabelOne();
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ return showFailToast(err.message);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const onSubmit = () => {
|
|
|
+ if (route.query.isClaim != "1") {
|
|
|
+ if (formData.data.claimContractList.length > 0) {
|
|
|
+ let list = formData.data.claimContractList;
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ const e = list[i];
|
|
|
+ if (!(Number(e.money) > 0)) {
|
|
|
+ return showFailToast(
|
|
|
+ proxy.t("claim.relatedAmountMustBeGreaterThanZero")
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const total = list.reduce((total, x) => (total += Number(x.money)), 0);
|
|
|
+ if (total > Number(formData.data.waitAmount)) {
|
|
|
+ return showFailToast(
|
|
|
+ proxy.t("claim.relatedAmountTotalNotBeGreaterThanAccountAmount")
|
|
|
+ );
|
|
|
+ }
|
|
|
+ formData.data.amount = total;
|
|
|
+ proxy.post("/claim/add", formData.data).then(
|
|
|
+ () => {
|
|
|
+ showSuccessToast(proxy.t("common.operationSuccessful"));
|
|
|
+ setTimeout(() => {
|
|
|
+ onClickLeft();
|
|
|
+ }, 500);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ return showFailToast(err.message);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ return showFailToast(proxy.t("claim.addDetails"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ proxy.post("/claim/delete", { id: route.query.id }).then(
|
|
|
+ () => {
|
|
|
+ showSuccessToast(proxy.t("common.operationSuccessful"));
|
|
|
+ setTimeout(() => {
|
|
|
+ onClickLeft();
|
|
|
+ }, 500);
|
|
|
+ },
|
|
|
+ (err) => {
|
|
|
+ return showFailToast(err.message);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+</style>
|