index.vue 8.97 KB
<!-- 特殊银行账号 - 列表 -->
<template>
  <d2-container>
    <div>
      <div slot="header" class=" header">
        <d2-search ref="showSearch"
                   :form-data="showFormData"
                   :search-form="searchForm">
        </d2-search>
        <div class="up-btns">
          <el-button :id="tableParams.btnId"
                     size="small"
                     type="primary">
            查询
          </el-button>
          <el-button size="small" @click="handleReset">
            重置
          </el-button>
        </div>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header>
        <auth-button category="Button" />
      </d2-table-header>
      <d2-table ref="merchantTable"
                :before-search-fn="beforeSearchFn"
                :get-list-api="getListApi"
                :has-num="false"
                :search-form="searchFormSearch"
                :table-params="tableParams">
        <auth-button slot="auth-button"
                     slot-scope="scope"
                     :data="scope.scope" />
      </d2-table>
    </div>
    <d2-dialog :btn-ok-label="bankOprType == 'detail' ? '关闭' : '保存'"
               :is-visible.sync="bankVisible"
               :title="modeDialogConfig.config.title"
               :width="modeDialogConfig.config.width"
               @closeDialog="handleBankClose"
               @confirmDialog="handleBankConfirm">
      <EditBankDialog v-if="bankVisible"
                      ref="editBankAccountRef"
                      :merchant-row="merchantRow"
                      :opr-type="bankOprType"
                      @handleBankClose="handleBankClose" />
    </d2-dialog>
  </d2-container>
</template>

<script>
import { deleteBankAccount, getListApi } from "@api/specialBankAccount";
import { mapActions, mapState } from "vuex";
import { deepClone, Util } from "@/common/util";
import reportTrackFunMixin from "@/mixins/reportTrackFunMixin";
import EditBankDialog from "./components/EditBankDialog.vue";

export default {
	name: "specialBankAccount",
	components: {
		EditBankDialog,
	},
	mixins: [reportTrackFunMixin], // 导入混入
	data() {
		return {
			bankVisible: false,
			merchantRow: {},
			bankOprType: "add",
			// 搜索
			merchantLevelVal: [],
			searchForm: {
				accountType: "",
				merchantName: "",
				openAccBankName: "",
				bankAccountNo: "",
				bankAccountName: "",
				enterDate: [],
				remark: "",
			},
			searchFormSearch: {},
			showFormData: [{
				label: "账号类型",
				name: "accountType",
				type: "select",
				optionId: "value",
				optionLabel: "name",
				optionList: [],
				optionsName: "accountTypeList",
			}, {
				label: "商户名称",
				name: "merchantName",
				type: "input",
				maxlength: "20",
				isClear: true,
				keyFn: this.keyDowmGetList,
			}, {
				label: "开户银行",
				name: "openAccBankName",
				type: "input",
				maxlength: "20",
				isClear: true,
				keyFn: this.keyDowmGetList,
			}, {
				label: "银行账号",
				name: "bankAccountNo",
				type: "input",
				maxlength: "20",
				isClear: true,
				keyFn: this.keyDowmGetList,
			}, {
				label: "账户名称",
				name: "bankAccountName",
				type: "input",
				maxlength: "20",
				isClear: true,
				keyFn: this.keyDowmGetList,
			}, {
				label: "录入时间",
				name: "enterDate",
				type: "datePicker",
				isClear: true,
				// pickerOptions: "rangePickerOptions",
			}, {
				label: "备注",
				name: "remark",
				type: "input",
				maxlength: "20",
				isClear: true,
				keyFn: this.keyDowmGetList,
			}],
			// 表格
			getListApi,
			tableParams: {
				btnId: new Date().getTime() + Number.parseInt(Math.random() * 1000),
				listName: "list",
				tableOption: true,
				mutiSelectUniqueKey: "merchantId",
				mutiSelectName: "merchantId",
				tableColumns: [{
					label: "账号类型",
					prop: "",
					formatter: (cellValue) => {
						return this.baseData.accountTypeShow[cellValue.accountType] || "";
					},
				}, {
					label: "商户名称",
					prop: "merchantName",
				}, {
					label: "开户银行",
					prop: "openAccBankName",
				}, {
					label: "银行账号",
					prop: "bankAccountNo",
				}, {
					label: "账户名称",
					prop: "bankAccountName",
				}, {
					label: "录入时间",
					prop: "createdDate",
					formatter: (cellValue) => {
						return Util.dateFormate(cellValue.createdDate, "YYYY-MM-DD HH:mm:ss");
					},
				}, {
					label: "备注",
					prop: "remark",
				}],
			},
			baseData: {
				accountTypeList: [{
					name: "灵工平台",
					value: "1",
				}, {
					name: "个体工商户",
					value: "2",
				}, {
					name: "其他",
					value: "3",
				}],
				accountTypeShow: {
					1: "灵工平台",
					2: "个体工商户",
					3: "其他",
				},
			},
			modeDialogConfig: {
				config: {
					title: "新增特殊银行账号",
					width: "1080px",
				},
			},
		};
	},

	mounted() {
		this.getOptionsList("showFormData");
		this.onPageShow();
	},
	beforeDestroy() {
		this.onPageHide();
	},

	computed: {
		...mapState({
			dowloadList: state => state.d2admin.user.dowloadList,
		}),
	},

	methods: {
		...mapActions("d2admin/user", ["actionSetDownloadList"]),

		getOptionsList(formName, hasAll = true, refreshSigle) {
			if (refreshSigle) {
				let item = this[formName].find(k => k.name == refreshSigle);
				let index = this[formName].findIndex(k => k.name == refreshSigle);
				this.$set(this[formName][index], "optionList", deepClone(this.baseData[item.optionsName]));
				if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== "全部") {
					const temp = {};
					temp[this[formName][index].optionId] = "";
					temp[this[formName][index].optionLabel] = "全部";
					this[formName][index].optionList.unshift(temp);
				}
			} else {
				this[formName].forEach((item, index) => {
					if (item.type === "select" && this.baseData[item.optionsName].length) {
						this.$set(this[formName][index], "optionList", deepClone(this.baseData[item.optionsName]));
						if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== "全部") {
							const temp = {};
							temp[this[formName][index].optionId] = "";
							temp[this[formName][index].optionLabel] = "全部";
							this[formName][index].optionList.unshift(temp);
						}
					}
				});
			}
		},

		openDialog(title, type, row = null) {
			this.modeDialogConfig.config.title = title;
			this.bankOprType = type;
			this.merchantRow = row;
			this.handleBankClose();
		},
		handleAdd() {
			this.openDialog("新增特殊银行账号", "add");
		},

		handleDetail(row) {
			this.openDialog("查看特殊银行账号", "detail", row);
		},

		// 修改特殊银行账号
		handleEdit(row) {
			this.openDialog("修改特殊银行账号", "edit", row);
		},

		// 修改到账模式确认
		handleBankConfirm() {
			this.$refs.editBankAccountRef.submitForm();
		},
		handleBankClose(isRefreshTable = false) {
			this.bankVisible = !this.bankVisible;
			if (isRefreshTable) {
				this.$refs.merchantTable.resetRefreshTable();
			}
		},
		handleReset() {
			this.searchForm = {
				accountType: "",
				merchantName: "",
				openAccBankName: "",
				bankAccountNo: "",
				bankAccountName: "",
				enterDate: [],
				remark: "",
			};
			this.merchantLevelVal = [];
			this.$refs.merchantTable.resetRefreshTable();
		},

		getParams() {
			let params = deepClone(this.searchForm);
			const dateFormatList = [{
				attr: "enterDate",
				startAttr: "startCreatedTime",
				endAttr: "endCreatedTime",
			}];
			dateFormatList.forEach((item) => {
				if (params[item.attr] && params[item.attr].length) {
					params[item.startAttr] = Util.dateFormate(params[item.attr][0], "YYYY-MM-DD 00:00:00");
					params[item.endAttr] = Util.dateFormate(params[item.attr][1], "YYYY-MM-DD 23:59:59");
				}
				delete params[item.attr];
			});
			return params;
		},

		beforeSearchFn() {
			return new Promise((resolve) => {
				this.searchFormSearch = this.getParams();
				resolve();
			});
		},

		keyDowmGetList() {
			this.$refs.merchantTable.refreshTable();
		},

		handleDelete(row) {
			this.$confirm("删除后不可恢复,确认是否删除?", "提示", {
				confirmButtonText: "确定",
				cancelButtonText: "取消",
				type: "warning",
			}).then(() => {
				const params = { id: row.id };
				deleteBankAccount(params).then((res) => {
					this.$message.success("删除成功");
					this.handleReset();
				});
			}).catch(() => { });
		},

		handleExport() {
			const params = {};
			params.method = "dj.api.smartcarlife.specialBankAccount.export.async";
			const list = [
				...this.dowloadList,
				{
					name: "特殊银行账号",
					exportParam: JSON.stringify(params),
					status: "waiting",
					timeid: new Date().getTime(),
				},
			];
			this.actionSetDownloadList({ list, type: "dowloadList" });
		},
	},
};
</script>

<style>
.header {
	background-color: #fff;
}

.el-cascader-panel .el-cascader-menu {
	width: 260px;
}
.btnClass span {
	margin-right: 5px;
}
</style>