feat: 代客下单优惠券更新,挂账更新
This commit is contained in:
@@ -1,3 +0,0 @@
|
||||
<template>
|
||||
<div></div>
|
||||
</template>
|
||||
80
src/views/data/credit/config/add.ts
Normal file
80
src/views/data/credit/config/add.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import creditApi from "@/api/order/credit";
|
||||
import { returnOptions } from "./config";
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
|
||||
const modalConfig: IModalConfig = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "创建挂账人",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
form: {
|
||||
labelWidth: 140,
|
||||
},
|
||||
formAction: function (data) {
|
||||
return creditApi.add({ ...data });
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
type: 'switch',
|
||||
attrs: {
|
||||
activeText: '开启',
|
||||
inactiveText: '关闭',
|
||||
activeValue: 1,
|
||||
inactiveValue: 0
|
||||
},
|
||||
initialValue: 1
|
||||
},
|
||||
|
||||
{
|
||||
label: "挂账人",
|
||||
prop: "debtor",
|
||||
rules: [{ required: true, message: "请输入挂账人", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "手机号",
|
||||
prop: "mobile",
|
||||
rules: [{ required: true, message: "请输入挂账人手机号", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人手机号",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "职务",
|
||||
prop: "position",
|
||||
rules: [{ required: false, message: "请输入挂账人职务", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人职务",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "挂账额度",
|
||||
prop: "creditAmount",
|
||||
type: "input-number",
|
||||
rules: [{ required: true, message: "请输入挂账额度", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账额度",
|
||||
},
|
||||
initialValue: 0
|
||||
},
|
||||
{
|
||||
label: "还款方式",
|
||||
prop: "repaymentMethod",
|
||||
type: "radio-button",
|
||||
options: returnOptions('repaymentMethod'),
|
||||
initialValue: returnOptions('repaymentMethod')[0].value
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
26
src/views/data/credit/config/config.ts
Normal file
26
src/views/data/credit/config/config.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
const options: Record<string, { label: string; value: string; }[]> = {
|
||||
repaymentMethod: [
|
||||
{ label: '按总金额还款', value: "total" },
|
||||
{ label: '按订单还款', value: "order" },
|
||||
]
|
||||
};
|
||||
|
||||
export function returnOptions(type: keyof typeof options) {
|
||||
return options[type];
|
||||
}
|
||||
|
||||
export function returnOptionsLabel(optionsType: optionsType, value: string | number) {
|
||||
const options = returnOptions(optionsType);
|
||||
if (!options) {
|
||||
return "";
|
||||
}
|
||||
const option = options.find((item) => item.value === value);
|
||||
return option ? option.label : "";
|
||||
}
|
||||
|
||||
export interface options {
|
||||
label: string;
|
||||
value: string | number;
|
||||
[property: string]: any;
|
||||
}
|
||||
102
src/views/data/credit/config/content.ts
Normal file
102
src/views/data/credit/config/content.ts
Normal file
@@ -0,0 +1,102 @@
|
||||
import creditApi from "@/api/order/credit";
|
||||
import type { IContentConfig } from "@/components/CURD/types";
|
||||
|
||||
const contentConfig: IContentConfig = {
|
||||
pageName: "sys:user",
|
||||
table: {
|
||||
border: true,
|
||||
highlightCurrentRow: true,
|
||||
},
|
||||
pagination: {
|
||||
background: true,
|
||||
layout: "prev,pager,next,jumper,total,sizes",
|
||||
pageSize: 20,
|
||||
pageSizes: [10, 20, 30, 50],
|
||||
},
|
||||
indexAction: function (params) {
|
||||
return creditApi.getList(params);
|
||||
},
|
||||
deleteAction: creditApi.delete,
|
||||
// modifyAction: function (data) {
|
||||
// // return creditApi.edit(data);
|
||||
// },
|
||||
pk: "id",
|
||||
toolbar: ["add"],
|
||||
defaultToolbar: ["refresh", "filter", "search"],
|
||||
cols: [
|
||||
{
|
||||
label: "挂账编码",
|
||||
align: "center",
|
||||
prop: "id",
|
||||
},
|
||||
{
|
||||
label: "状态",
|
||||
align: "center",
|
||||
prop: "status",
|
||||
templet: 'custom',
|
||||
slotName: 'status',
|
||||
width: 120,
|
||||
},
|
||||
{
|
||||
label: "挂账人",
|
||||
align: "center",
|
||||
prop: "debtor",
|
||||
},
|
||||
{
|
||||
label: "手机号",
|
||||
align: "center",
|
||||
prop: "mobile",
|
||||
},
|
||||
{
|
||||
label: "挂账额度(元)",
|
||||
align: "center",
|
||||
prop: "creditAmount",
|
||||
},
|
||||
{
|
||||
label: "已挂账金额(元)",
|
||||
align: "center",
|
||||
prop: "owedAmount",
|
||||
},
|
||||
{
|
||||
label: "剩余挂账额度(元)",
|
||||
align: "center",
|
||||
prop: "owedAmount",
|
||||
},
|
||||
{
|
||||
label: "账户余额",
|
||||
align: "center",
|
||||
prop: "accountBalance",
|
||||
},
|
||||
{
|
||||
label: "操作",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 300,
|
||||
templet: "tool",
|
||||
operat: [
|
||||
{
|
||||
text: "查看明细",
|
||||
name: 'detail'
|
||||
},
|
||||
{
|
||||
text: "编辑",
|
||||
name: 'edit'
|
||||
},
|
||||
{
|
||||
text: "还款",
|
||||
name: 'huankuan'
|
||||
},
|
||||
{
|
||||
text: "还款记录",
|
||||
name: 'huankuan_detail'
|
||||
},
|
||||
{
|
||||
text: "删除",
|
||||
name: 'delete'
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default contentConfig;
|
||||
80
src/views/data/credit/config/edit.ts
Normal file
80
src/views/data/credit/config/edit.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
import creditApi from "@/api/order/credit";
|
||||
import { returnOptions } from "./config";
|
||||
import type { IModalConfig } from "@/components/CURD/types";
|
||||
|
||||
const modalConfig: IModalConfig = {
|
||||
pageName: "sys:user",
|
||||
dialog: {
|
||||
title: "编辑挂账人",
|
||||
width: 800,
|
||||
draggable: true,
|
||||
},
|
||||
form: {
|
||||
labelWidth: 140,
|
||||
},
|
||||
formAction: function (data) {
|
||||
return creditApi.edit({ ...data });
|
||||
},
|
||||
beforeSubmit(data) {
|
||||
console.log("提交之前处理", data);
|
||||
},
|
||||
formItems: [
|
||||
{
|
||||
label: "状态",
|
||||
prop: "status",
|
||||
type: 'switch',
|
||||
attrs: {
|
||||
activeText: '开启',
|
||||
inactiveText: '关闭',
|
||||
activeValue: 1,
|
||||
inactiveValue: 0
|
||||
},
|
||||
initialValue: 1
|
||||
},
|
||||
|
||||
{
|
||||
label: "挂账人",
|
||||
prop: "debtor",
|
||||
rules: [{ required: true, message: "请输入挂账人", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "手机号",
|
||||
prop: "mobile",
|
||||
rules: [{ required: true, message: "请输入挂账人手机号", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人手机号",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "职务",
|
||||
prop: "position",
|
||||
rules: [{ required: false, message: "请输入挂账人职务", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人职务",
|
||||
},
|
||||
},
|
||||
{
|
||||
label: "挂账额度",
|
||||
prop: "creditAmount",
|
||||
type: "input-number",
|
||||
rules: [{ required: true, message: "请输入挂账额度", trigger: "blur" }],
|
||||
attrs: {
|
||||
placeholder: "请输入挂账额度",
|
||||
},
|
||||
initialValue: 0
|
||||
},
|
||||
{
|
||||
label: "还款方式",
|
||||
prop: "repaymentMethod",
|
||||
type: "radio-button",
|
||||
options: returnOptions('repaymentMethod'),
|
||||
initialValue: returnOptions('repaymentMethod')[0].value
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// 如果有异步数据会修改配置的,推荐用reactive包裹,而纯静态配置的可以直接导出
|
||||
export default reactive(modalConfig);
|
||||
39
src/views/data/credit/config/search.ts
Normal file
39
src/views/data/credit/config/search.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import type { ISearchConfig } from "@/components/CURD/types";
|
||||
|
||||
const searchConfig: ISearchConfig = {
|
||||
pageName: "sys:user",
|
||||
formItems: [
|
||||
{
|
||||
type: "input",
|
||||
label: "挂账人",
|
||||
prop: "keywords",
|
||||
attrs: {
|
||||
placeholder: "请输入挂账人或手机号",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
type: "select",
|
||||
label: "还款状态",
|
||||
prop: "repaymentStatus",
|
||||
attrs: {
|
||||
placeholder: "请选择还款状态",
|
||||
clearable: true,
|
||||
style: {
|
||||
width: "200px",
|
||||
},
|
||||
},
|
||||
initialValue: '',
|
||||
options: [
|
||||
{ label: "未还款", value: 'unpaid' },
|
||||
{ label: "部分还款", value: 'partial' },
|
||||
{ label: "已还清", value: 'paid' },
|
||||
],
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default searchConfig;
|
||||
131
src/views/data/credit/index.vue
Normal file
131
src/views/data/credit/index.vue
Normal file
@@ -0,0 +1,131 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 列表 -->
|
||||
<!-- 搜索 -->
|
||||
<page-search
|
||||
ref="searchRef"
|
||||
:search-config="searchConfig"
|
||||
@query-click="handleQueryClick"
|
||||
@reset-click="handleResetClick"
|
||||
/>
|
||||
<!-- 列表 -->
|
||||
<page-content
|
||||
ref="contentRef"
|
||||
:content-config="contentConfig"
|
||||
@add-click="handleAddClick"
|
||||
@edit-click="handleEditClick"
|
||||
@export-click="handleExportClick"
|
||||
@search-click="handleSearchClick"
|
||||
@toolbar-click="handleToolbarClick"
|
||||
@operat-click="handleOperatClick"
|
||||
@filter-change="handleFilterChange"
|
||||
>
|
||||
<template #status="scope">
|
||||
<el-tag :type="scope.row[scope.prop] == 1 ? 'success' : 'info'">
|
||||
{{ scope.row[scope.prop] == 1 ? "启用" : "禁用" }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template #options="scope">
|
||||
{{ returnOptionsLabel(scope.prop, scope.row[scope.prop]) }}
|
||||
</template>
|
||||
<template #gender="scope">
|
||||
<DictLabel v-model="scope.row[scope.prop]" code="gender" />
|
||||
</template>
|
||||
<template #mobile="scope">
|
||||
<el-text>{{ scope.row[scope.prop] }}</el-text>
|
||||
<copy-button
|
||||
v-if="scope.row[scope.prop]"
|
||||
:text="scope.row[scope.prop]"
|
||||
style="margin-left: 2px"
|
||||
/>
|
||||
</template>
|
||||
</page-content>
|
||||
|
||||
<!-- 新增 -->
|
||||
<page-modal
|
||||
ref="addModalRef"
|
||||
@form-data-change="handleFormDataChange"
|
||||
:modal-config="addModalConfig"
|
||||
@submit-click="handleSubmitClick"
|
||||
>
|
||||
<template #formFooter>
|
||||
<el-form-item label="" label-width="140">
|
||||
<p>一经创建无法更改还款方式</p>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</page-modal>
|
||||
|
||||
<!-- 编辑 -->
|
||||
<page-modal
|
||||
ref="editModalRef"
|
||||
:modal-config="editModalConfig"
|
||||
@submit-click="handleSubmitClick"
|
||||
></page-modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import creditApi from "@/api/order/credit";
|
||||
import type { IObject, IOperatData } from "@/components/CURD/types";
|
||||
import usePage from "@/components/CURD/usePage";
|
||||
import addModalConfig from "./config/add";
|
||||
import contentConfig from "./config/content";
|
||||
import editModalConfig from "./config/edit";
|
||||
import searchConfig from "./config/search";
|
||||
import { returnOptionsLabel } from "./config/config";
|
||||
|
||||
let version = ref<string | number>("");
|
||||
function handleFormDataChange(type: string, value: string | number) {
|
||||
version.value = value;
|
||||
if (type === "version" && value !== "") {
|
||||
addModalConfig.formItems[5].hidden = false;
|
||||
return;
|
||||
}
|
||||
if (type === "version" && value == "") {
|
||||
addModalConfig.formItems[5].hidden = true;
|
||||
}
|
||||
}
|
||||
|
||||
const refVersionFile = ref<any>();
|
||||
const {
|
||||
searchRef,
|
||||
contentRef,
|
||||
addModalRef,
|
||||
editModalRef,
|
||||
handleQueryClick,
|
||||
handleResetClick,
|
||||
// handleAddClick,
|
||||
// handleEditClick,
|
||||
handleSubmitClick,
|
||||
handleExportClick,
|
||||
handleSearchClick,
|
||||
handleFilterChange,
|
||||
} = usePage();
|
||||
|
||||
// 新增
|
||||
async function handleAddClick() {
|
||||
addModalRef.value?.setModalVisible();
|
||||
// addModalConfig.formItems[2]!.attrs!.data =
|
||||
}
|
||||
// 编辑
|
||||
async function handleEditClick(row: IObject) {
|
||||
editModalRef.value?.handleDisabled(false);
|
||||
editModalRef.value?.setModalVisible();
|
||||
// 根据id获取数据进行填充
|
||||
// const data = await creditApi.getFormData(row.id);
|
||||
console.log({ ...row });
|
||||
editModalRef.value?.setFormData({ ...row, url: [row.url] });
|
||||
}
|
||||
1;
|
||||
// 其他工具栏
|
||||
function handleToolbarClick(name: string) {
|
||||
console.log(name);
|
||||
if (name === "custom1") {
|
||||
ElMessage.success("点击了自定义1按钮");
|
||||
}
|
||||
}
|
||||
// 其他操作列
|
||||
async function handleOperatClick(data: IOperatData) {
|
||||
console.log(data);
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user