@ -0,0 +1,82 @@ | |||||
import { defHttp } from '/@/utils/http/axios'; | |||||
import { useMessage } from '/@/hooks/web/useMessage'; | |||||
const { createConfirm } = useMessage(); | |||||
enum Api { | |||||
list = '/order/appOrder/list', | |||||
save = '/order/appOrder/add', | |||||
edit = '/order/appOrder/edit', | |||||
deleteOne = '/order/appOrder/delete', | |||||
deleteBatch = '/order/appOrder/deleteBatch', | |||||
importExcel = '/order/appOrder/importExcel', | |||||
exportXls = '/order/appOrder/exportXls', | |||||
appOrderCarList = '/order/appOrder/queryAppOrderCarByMainId', | |||||
appOrderVoucherList = '/order/appOrder/queryAppOrderVoucherByMainId', | |||||
appOrderFinanceList = '/order/appOrder/queryAppOrderFinanceByMainId', | |||||
} | |||||
/** | |||||
* 导出api | |||||
* @param params | |||||
*/ | |||||
export const getExportUrl = Api.exportXls; | |||||
/** | |||||
* 导入api | |||||
*/ | |||||
export const getImportUrl = Api.importExcel; | |||||
/** | |||||
* 查询子表数据 | |||||
* @param params | |||||
*/ | |||||
export const appOrderCarList = Api.appOrderCarList; | |||||
/** | |||||
* 查询子表数据 | |||||
* @param params | |||||
*/ | |||||
export const appOrderVoucherList = Api.appOrderVoucherList; | |||||
/** | |||||
* 查询子表数据 | |||||
* @param params | |||||
*/ | |||||
export const appOrderFinanceList = Api.appOrderFinanceList; | |||||
/** | |||||
* 列表接口 | |||||
* @param params | |||||
*/ | |||||
export const list = (params) => defHttp.get({ url: Api.list, params }); | |||||
/** | |||||
* 删除单个 | |||||
*/ | |||||
export const deleteOne = (params, handleSuccess) => { | |||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => { | |||||
handleSuccess(); | |||||
}); | |||||
}; | |||||
/** | |||||
* 批量删除 | |||||
* @param params | |||||
*/ | |||||
export const batchDelete = (params, handleSuccess) => { | |||||
createConfirm({ | |||||
iconType: 'warning', | |||||
title: '确认删除', | |||||
content: '是否删除选中数据', | |||||
okText: '确认', | |||||
cancelText: '取消', | |||||
onOk: () => { | |||||
return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => { | |||||
handleSuccess(); | |||||
}); | |||||
}, | |||||
}); | |||||
}; | |||||
/** | |||||
* 保存或者更新 | |||||
* @param params | |||||
*/ | |||||
export const saveOrUpdate = (params, isUpdate) => { | |||||
const url = isUpdate ? Api.edit : Api.save; | |||||
return defHttp.post({ url: url, params }); | |||||
}; |
@ -0,0 +1,722 @@ | |||||
import { BasicColumn } from '/@/components/Table'; | |||||
import { FormSchema } from '/@/components/Table'; | |||||
import { rules } from '/@/utils/helper/validator'; | |||||
import { render } from '/@/utils/common/renderUtils'; | |||||
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types'; | |||||
import { getWeekMonthQuarterYear } from '/@/utils'; | |||||
//列表数据 | |||||
export const columns: BasicColumn[] = [ | |||||
{ | |||||
title: '产品服务名称', | |||||
align: 'center', | |||||
dataIndex: 'productName', | |||||
}, | |||||
{ | |||||
title: '服务年限', | |||||
align: 'center', | |||||
dataIndex: 'productServiceYear', | |||||
}, | |||||
{ | |||||
title: '销售金额', | |||||
align: 'center', | |||||
dataIndex: 'productMoney', | |||||
}, | |||||
{ | |||||
title: '经销商', | |||||
align: 'center', | |||||
dataIndex: 'storeName', | |||||
}, | |||||
{ | |||||
title: '客户姓名', | |||||
align: 'center', | |||||
dataIndex: 'custName', | |||||
}, | |||||
{ | |||||
title: '客户地址', | |||||
align: 'center', | |||||
dataIndex: 'custAddress', | |||||
}, | |||||
{ | |||||
title: '客户证件号', | |||||
align: 'center', | |||||
dataIndex: 'custCardNo', | |||||
}, | |||||
{ | |||||
title: '客户联系电话', | |||||
align: 'center', | |||||
dataIndex: 'custPhone', | |||||
}, | |||||
{ | |||||
title: '销售端口', | |||||
align: 'center', | |||||
dataIndex: 'salePort_dictText', | |||||
}, | |||||
{ | |||||
title: '销售顾问', | |||||
align: 'center', | |||||
dataIndex: 'saleName', | |||||
}, | |||||
{ | |||||
title: '付款方式', | |||||
align: 'center', | |||||
dataIndex: 'payType', | |||||
}, | |||||
{ | |||||
title: '客户类型', | |||||
align: 'center', | |||||
dataIndex: 'custType_dictText', | |||||
}, | |||||
{ | |||||
title: '身份证正面照', | |||||
align: 'center', | |||||
dataIndex: 'certFront', | |||||
customRender: render.renderImage, | |||||
}, | |||||
{ | |||||
title: '身份证反面照', | |||||
align: 'center', | |||||
dataIndex: 'certBack', | |||||
customRender: render.renderImage, | |||||
}, | |||||
{ | |||||
title: '车辆合格证', | |||||
align: 'center', | |||||
dataIndex: 'carPic', | |||||
customRender: render.renderImage, | |||||
}, | |||||
{ | |||||
title: '营业执照', | |||||
align: 'center', | |||||
dataIndex: 'busLicense', | |||||
customRender: render.renderImage, | |||||
}, | |||||
{ | |||||
title: '创建日期', | |||||
align: 'center', | |||||
dataIndex: 'createTime', | |||||
}, | |||||
{ | |||||
title: '订单状态', | |||||
align: 'center', | |||||
dataIndex: 'status_dictText', | |||||
}, | |||||
{ | |||||
title: '订单合同', | |||||
align: 'center', | |||||
dataIndex: 'contractUrl', | |||||
}, | |||||
{ | |||||
title: '收款方', | |||||
align: 'center', | |||||
dataIndex: 'payee', | |||||
}, | |||||
{ | |||||
title: '收款时间', | |||||
align: 'center', | |||||
dataIndex: 'payeeTime', | |||||
}, | |||||
{ | |||||
title: '支付凭证', | |||||
align: 'center', | |||||
dataIndex: 'payVoucherUrl', | |||||
customRender: render.renderImage, | |||||
}, | |||||
{ | |||||
title: '订单编号', | |||||
align: 'center', | |||||
dataIndex: 'orderNum', | |||||
}, | |||||
]; | |||||
//查询数据 | |||||
export const searchFormSchema: FormSchema[] = [ | |||||
{ | |||||
label: '产品服务名称', | |||||
field: 'productName', | |||||
component: 'JInput', | |||||
}, | |||||
{ | |||||
label: '经销商', | |||||
field: 'storeName', | |||||
component: 'JInput', | |||||
}, | |||||
{ | |||||
label: '客户姓名', | |||||
field: 'custName', | |||||
component: 'JInput', | |||||
}, | |||||
{ | |||||
label: '客户证件号', | |||||
field: 'custCardNo', | |||||
component: 'Input', | |||||
//colProps: {span: 6}, | |||||
}, | |||||
{ | |||||
label: '客户联系电话', | |||||
field: 'custPhone', | |||||
component: 'Input', | |||||
//colProps: {span: 6}, | |||||
}, | |||||
{ | |||||
label: '销售端口', | |||||
field: 'salePort', | |||||
component: 'JSelectMultiple', | |||||
componentProps: { | |||||
dictCode: 'order_sale_port', | |||||
}, | |||||
//colProps: {span: 6}, | |||||
}, | |||||
{ | |||||
label: '付款方式', | |||||
field: 'payType', | |||||
component: 'Input', | |||||
//colProps: {span: 6}, | |||||
}, | |||||
{ | |||||
label: '客户类型', | |||||
field: 'custType', | |||||
component: 'JSelectMultiple', | |||||
componentProps: { | |||||
dictCode: 'customer_type', | |||||
}, | |||||
//colProps: {span: 6}, | |||||
}, | |||||
{ | |||||
label: '创建日期', | |||||
field: 'createTime', | |||||
component: 'RangePicker', | |||||
componentProps: { | |||||
valueType: 'Date', | |||||
showTime: true, | |||||
}, | |||||
//colProps: {span: 6}, | |||||
}, | |||||
{ | |||||
label: '订单状态', | |||||
field: 'status', | |||||
component: 'JSelectMultiple', | |||||
componentProps: {}, | |||||
//colProps: {span: 6}, | |||||
}, | |||||
{ | |||||
label: '订单编号', | |||||
field: 'orderNum', | |||||
component: 'Input', | |||||
//colProps: {span: 6}, | |||||
}, | |||||
]; | |||||
//表单数据 | |||||
export const formSchema: FormSchema[] = [ | |||||
{ | |||||
label: '产品服务名称', | |||||
field: 'productName', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入产品服务名称!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '服务年限', | |||||
field: 'productServiceYear', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入服务年限!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '销售金额', | |||||
field: 'productMoney', | |||||
component: 'InputNumber', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入销售金额!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '经销商', | |||||
field: 'storeName', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入经销商!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '客户姓名', | |||||
field: 'custName', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入客户姓名!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '客户地址', | |||||
field: 'custAddress', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入客户地址!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '客户证件号', | |||||
field: 'custCardNo', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入客户证件号!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '客户联系电话', | |||||
field: 'custPhone', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入客户联系电话!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '销售端口', | |||||
field: 'salePort', | |||||
component: 'JDictSelectTag', | |||||
componentProps: { | |||||
dictCode: 'order_sale_port', | |||||
}, | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入销售端口!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '销售顾问', | |||||
field: 'saleName', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入销售顾问!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '付款方式', | |||||
field: 'payType', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入付款方式!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '客户类型', | |||||
field: 'custType', | |||||
component: 'JDictSelectTag', | |||||
componentProps: { | |||||
dictCode: 'customer_type', | |||||
}, | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入客户类型!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '身份证正面照', | |||||
field: 'certFront', | |||||
component: 'JImageUpload', | |||||
componentProps: { | |||||
fileMax: 0, | |||||
}, | |||||
}, | |||||
{ | |||||
label: '身份证反面照', | |||||
field: 'certBack', | |||||
component: 'JImageUpload', | |||||
componentProps: { | |||||
fileMax: 0, | |||||
}, | |||||
}, | |||||
{ | |||||
label: '车辆合格证', | |||||
field: 'carPic', | |||||
component: 'JImageUpload', | |||||
componentProps: { | |||||
fileMax: 0, | |||||
}, | |||||
}, | |||||
{ | |||||
label: '营业执照', | |||||
field: 'busLicense', | |||||
component: 'JImageUpload', | |||||
componentProps: { | |||||
fileMax: 0, | |||||
}, | |||||
}, | |||||
{ | |||||
label: '订单状态', | |||||
field: 'status', | |||||
component: 'JDictSelectTag', | |||||
componentProps: { | |||||
dictCode: '', | |||||
}, | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入订单状态!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '订单合同', | |||||
field: 'contractUrl', | |||||
component: 'JUpload', | |||||
componentProps: {}, | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入订单合同!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '收款方', | |||||
field: 'payee', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入收款方!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '收款时间', | |||||
field: 'payeeTime', | |||||
component: 'DatePicker', | |||||
componentProps: { | |||||
showTime: true, | |||||
valueFormat: 'YYYY-MM-DD HH:mm:ss', | |||||
}, | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入收款时间!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '支付凭证', | |||||
field: 'payVoucherUrl', | |||||
component: 'JImageUpload', | |||||
componentProps: { | |||||
fileMax: 0, | |||||
}, | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入支付凭证!' }]; | |||||
}, | |||||
}, | |||||
// TODO 主键隐藏字段,目前写死为ID | |||||
{ | |||||
label: '', | |||||
field: 'id', | |||||
component: 'Input', | |||||
show: false, | |||||
}, | |||||
]; | |||||
//子表单数据 | |||||
export const appOrderCarFormSchema: FormSchema[] = [ | |||||
{ | |||||
label: '车牌车系', | |||||
field: 'carSeries', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入车牌车系!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '车架号', | |||||
field: 'vin', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入车架号!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '车辆类型', | |||||
field: 'carType', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入车辆类型!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '使用性质', | |||||
field: 'useType', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入使用性质!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '是否新车', | |||||
field: 'newCar', | |||||
component: 'InputNumber', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入是否新车!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '车辆型号', | |||||
field: 'carModel', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入车辆型号!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '车牌号', | |||||
field: 'carNo', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入车牌号!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '发动机号', | |||||
field: 'engineNo', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入发动机号!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '里程', | |||||
field: 'mileage', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入里程!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '购车时间', | |||||
field: 'buyTime', | |||||
component: 'DatePicker', | |||||
componentProps: { | |||||
showTime: true, | |||||
valueFormat: 'YYYY-MM-DD HH:mm:ss', | |||||
}, | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入购车时间!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '车辆购置价', | |||||
field: 'buyMoney', | |||||
component: 'InputNumber', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入车辆购置价!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '车辆购置税', | |||||
field: 'buyTax', | |||||
component: 'InputNumber', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入车辆购置税!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '', | |||||
field: 'id', | |||||
component: 'Input', | |||||
show: false, | |||||
}, | |||||
]; | |||||
export const appOrderVoucherFormSchema: FormSchema[] = [ | |||||
{ | |||||
label: '第一受益人', | |||||
field: 'firstBeneficiary', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入第一受益人!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '服务费', | |||||
field: 'serviceMoney', | |||||
component: 'InputNumber', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入服务费!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '生效时间', | |||||
field: 'effectiveTime', | |||||
component: 'DatePicker', | |||||
componentProps: { | |||||
showTime: true, | |||||
valueFormat: 'YYYY-MM-DD HH:mm:ss', | |||||
}, | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入生效时间!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '服务年限', | |||||
field: 'serviceYear', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入服务年限!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '权益套餐', | |||||
field: 'equityPackage', | |||||
component: 'Input', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入权益套餐!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '套餐价', | |||||
field: 'packageMoney', | |||||
component: 'InputNumber', | |||||
dynamicRules: ({ model, schema }) => { | |||||
return [{ required: true, message: '请输入套餐价!' }]; | |||||
}, | |||||
}, | |||||
{ | |||||
label: '商业险编号', | |||||
field: 'carInsuranceNo', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '上牌城市', | |||||
field: 'registeredCity', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '保险公司', | |||||
field: 'insuranceName', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '受让人名称', | |||||
field: 'assigneeName', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '受让人电话', | |||||
field: 'assigneePhone', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '受让人身份证', | |||||
field: 'assigneeCardNo', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '支付时间', | |||||
field: 'payTime', | |||||
component: 'DatePicker', | |||||
componentProps: { | |||||
valueFormat: 'YYYY-MM-DD', | |||||
}, | |||||
}, | |||||
{ | |||||
label: '经销商地址', | |||||
field: 'dealerAddress', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '', | |||||
field: 'id', | |||||
component: 'Input', | |||||
show: false, | |||||
}, | |||||
]; | |||||
export const appOrderFinanceFormSchema: FormSchema[] = [ | |||||
{ | |||||
label: '贷款机构', | |||||
field: 'lender', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '贷款金额', | |||||
field: 'lenderMoney', | |||||
component: 'InputNumber', | |||||
}, | |||||
{ | |||||
label: '贷款年限', | |||||
field: 'lenderYear', | |||||
component: 'Input', | |||||
}, | |||||
{ | |||||
label: '', | |||||
field: 'id', | |||||
component: 'Input', | |||||
show: false, | |||||
}, | |||||
]; | |||||
//子表表格配置 | |||||
// 高级查询数据 | |||||
export const superQuerySchema = { | |||||
productName: { title: '产品服务名称', order: 0, view: 'text', type: 'string' }, | |||||
productServiceYear: { title: '服务年限', order: 1, view: 'text', type: 'string' }, | |||||
productMoney: { title: '销售金额', order: 2, view: 'number', type: 'number' }, | |||||
storeName: { title: '经销商', order: 3, view: 'text', type: 'string' }, | |||||
custName: { title: '客户姓名', order: 4, view: 'text', type: 'string' }, | |||||
custAddress: { title: '客户地址', order: 5, view: 'text', type: 'string' }, | |||||
custCardNo: { title: '客户证件号', order: 6, view: 'text', type: 'string' }, | |||||
custPhone: { title: '客户联系电话', order: 7, view: 'text', type: 'string' }, | |||||
salePort: { title: '销售端口', order: 8, view: 'list', type: 'string', dictCode: 'order_sale_port' }, | |||||
saleName: { title: '销售顾问', order: 9, view: 'text', type: 'string' }, | |||||
payType: { title: '付款方式', order: 10, view: 'text', type: 'string' }, | |||||
custType: { title: '客户类型', order: 11, view: 'number', type: 'number', dictCode: 'customer_type' }, | |||||
certFront: { title: '身份证正面照', order: 12, view: 'image', type: 'string' }, | |||||
certBack: { title: '身份证反面照', order: 13, view: 'image', type: 'string' }, | |||||
carPic: { title: '车辆合格证', order: 14, view: 'image', type: 'string' }, | |||||
busLicense: { title: '营业执照', order: 15, view: 'image', type: 'string' }, | |||||
createTime: { title: '创建日期', order: 16, view: 'datetime', type: 'string' }, | |||||
status: { title: '订单状态', order: 17, view: 'number', type: 'number', dictCode: '' }, | |||||
contractUrl: { title: '订单合同', order: 18, view: 'file', type: 'string' }, | |||||
payee: { title: '收款方', order: 19, view: 'text', type: 'string' }, | |||||
payeeTime: { title: '收款时间', order: 20, view: 'datetime', type: 'string' }, | |||||
payVoucherUrl: { title: '支付凭证', order: 21, view: 'image', type: 'string' }, | |||||
orderNum: { title: '订单编号', order: 22, view: 'text', type: 'string' }, | |||||
//子表高级查询 | |||||
appOrderCar: { | |||||
title: '订单车辆信息', | |||||
view: 'table', | |||||
fields: { | |||||
carSeries: { title: '车牌车系', order: 0, view: 'text', type: 'string' }, | |||||
vin: { title: '车架号', order: 1, view: 'text', type: 'string' }, | |||||
carType: { title: '车辆类型', order: 2, view: 'text', type: 'string' }, | |||||
useType: { title: '使用性质', order: 3, view: 'text', type: 'string' }, | |||||
newCar: { title: '是否新车', order: 4, view: 'number', type: 'number' }, | |||||
carModel: { title: '车辆型号', order: 5, view: 'text', type: 'string' }, | |||||
carNo: { title: '车牌号', order: 6, view: 'text', type: 'string' }, | |||||
engineNo: { title: '发动机号', order: 7, view: 'text', type: 'string' }, | |||||
mileage: { title: '里程', order: 8, view: 'text', type: 'string' }, | |||||
buyTime: { title: '购车时间', order: 9, view: 'datetime', type: 'string' }, | |||||
buyMoney: { title: '车辆购置价', order: 10, view: 'number', type: 'number' }, | |||||
buyTax: { title: '车辆购置税', order: 11, view: 'number', type: 'number' }, | |||||
createTime: { title: '创建日期', order: 12, view: 'datetime', type: 'string' }, | |||||
}, | |||||
}, | |||||
appOrderVoucher: { | |||||
title: '订单凭证信息', | |||||
view: 'table', | |||||
fields: { | |||||
firstBeneficiary: { title: '第一受益人', order: 0, view: 'text', type: 'string' }, | |||||
serviceMoney: { title: '服务费', order: 1, view: 'number', type: 'number' }, | |||||
effectiveTime: { title: '生效时间', order: 2, view: 'datetime', type: 'string' }, | |||||
serviceYear: { title: '服务年限', order: 3, view: 'text', type: 'string' }, | |||||
equityPackage: { title: '权益套餐', order: 4, view: 'text', type: 'string' }, | |||||
packageMoney: { title: '套餐价', order: 5, view: 'number', type: 'number' }, | |||||
carInsuranceNo: { title: '商业险编号', order: 6, view: 'text', type: 'string' }, | |||||
registeredCity: { title: '上牌城市', order: 7, view: 'text', type: 'string' }, | |||||
insuranceName: { title: '保险公司', order: 8, view: 'text', type: 'string' }, | |||||
assigneeName: { title: '受让人名称', order: 9, view: 'text', type: 'string' }, | |||||
assigneePhone: { title: '受让人电话', order: 10, view: 'text', type: 'string' }, | |||||
assigneeCardNo: { title: '受让人身份证', order: 11, view: 'text', type: 'string' }, | |||||
payTime: { title: '支付时间', order: 12, view: 'date', type: 'string' }, | |||||
dealerAddress: { title: '经销商地址', order: 13, view: 'text', type: 'string' }, | |||||
}, | |||||
}, | |||||
appOrderFinance: { | |||||
title: '订单金融信息', | |||||
view: 'table', | |||||
fields: { | |||||
lender: { title: '贷款机构', order: 0, view: 'text', type: 'string' }, | |||||
lenderMoney: { title: '贷款金额', order: 1, view: 'number', type: 'number' }, | |||||
lenderYear: { title: '贷款年限', order: 2, view: 'text', type: 'string' }, | |||||
}, | |||||
}, | |||||
}; | |||||
/** | |||||
* 流程表单调用这个方法获取formSchema | |||||
* @param param | |||||
*/ | |||||
export function getBpmFormSchema(_formData): FormSchema[] { | |||||
// 默认和原始表单保持一致 如果流程中配置了权限数据,这里需要单独处理formSchema | |||||
return formSchema; | |||||
} |
@ -0,0 +1,200 @@ | |||||
<template> | |||||
<div> | |||||
<!--引用表格--> | |||||
<BasicTable @register="registerTable" :rowSelection="rowSelection"> | |||||
<!--插槽:table标题--> | |||||
<template #tableTitle> | |||||
<a-button type="primary" v-auth="'order:app_order:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> | |||||
<a-button type="primary" v-auth="'order:app_order:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button> | |||||
<j-upload-button type="primary" v-auth="'order:app_order:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls" | |||||
>导入</j-upload-button | |||||
> | |||||
<a-dropdown v-if="selectedRowKeys.length > 0"> | |||||
<template #overlay> | |||||
<a-menu> | |||||
<a-menu-item key="1" @click="batchHandleDelete"> | |||||
<Icon icon="ant-design:delete-outlined" /> | |||||
删除 | |||||
</a-menu-item> | |||||
</a-menu> | |||||
</template> | |||||
<a-button v-auth="'order:app_order:deleteBatch'" | |||||
>批量操作 | |||||
<Icon icon="mdi:chevron-down" /> | |||||
</a-button> | |||||
</a-dropdown> | |||||
<!-- 高级查询 --> | |||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" /> | |||||
</template> | |||||
<!--操作栏--> | |||||
<template #action="{ record }"> | |||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" /> | |||||
</template> | |||||
<!--字段回显插槽--> | |||||
<template #bodyCell="{ column, record, index, text }"> | |||||
<template v-if="column.dataIndex === 'contractUrl'"> | |||||
<!--文件字段回显插槽--> | |||||
<span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span> | |||||
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)" | |||||
>下载</a-button | |||||
> | |||||
</template> | |||||
</template> | |||||
</BasicTable> | |||||
<!-- 表单区域 --> | |||||
<AppOrderModal @register="registerModal" @success="handleSuccess" /> | |||||
</div> | |||||
</template> | |||||
<script lang="ts" name="order-appOrder" setup> | |||||
import { ref, reactive, computed, unref } from 'vue'; | |||||
import { BasicTable, useTable, TableAction } from '/@/components/Table'; | |||||
import { useListPage } from '/@/hooks/system/useListPage'; | |||||
import { useModal } from '/@/components/Modal'; | |||||
import AppOrderModal from './components/AppOrderModal.vue'; | |||||
import { columns, searchFormSchema, superQuerySchema } from './AppOrder.data'; | |||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './AppOrder.api'; | |||||
import { downloadFile } from '/@/utils/common/renderUtils'; | |||||
import { useUserStore } from '/@/store/modules/user'; | |||||
const queryParam = reactive<any>({}); | |||||
const checkedKeys = ref<Array<string | number>>([]); | |||||
const userStore = useUserStore(); | |||||
//注册model | |||||
const [registerModal, { openModal }] = useModal(); | |||||
//注册table数据 | |||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({ | |||||
tableProps: { | |||||
title: '合同订单表', | |||||
api: list, | |||||
columns, | |||||
canResize: false, | |||||
formConfig: { | |||||
//labelWidth: 120, | |||||
schemas: searchFormSchema, | |||||
autoSubmitOnEnter: true, | |||||
showAdvancedButton: true, | |||||
fieldMapToNumber: [], | |||||
fieldMapToTime: [['createTime', ['createTime_begin', 'createTime_end'], 'YYYY-MM-DD HH:mm:ss']], | |||||
}, | |||||
actionColumn: { | |||||
width: 120, | |||||
fixed: 'right', | |||||
}, | |||||
beforeFetch: (params) => { | |||||
return Object.assign(params, queryParam); | |||||
}, | |||||
}, | |||||
exportConfig: { | |||||
name: '合同订单表', | |||||
url: getExportUrl, | |||||
params: queryParam, | |||||
}, | |||||
importConfig: { | |||||
url: getImportUrl, | |||||
success: handleSuccess, | |||||
}, | |||||
}); | |||||
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext; | |||||
// 高级查询配置 | |||||
const superQueryConfig = reactive(superQuerySchema); | |||||
/** | |||||
* 高级查询事件 | |||||
*/ | |||||
function handleSuperQuery(params) { | |||||
Object.keys(params).map((k) => { | |||||
queryParam[k] = params[k]; | |||||
}); | |||||
reload(); | |||||
} | |||||
/** | |||||
* 新增事件 | |||||
*/ | |||||
function handleAdd() { | |||||
openModal(true, { | |||||
isUpdate: false, | |||||
showFooter: true, | |||||
}); | |||||
} | |||||
/** | |||||
* 编辑事件 | |||||
*/ | |||||
function handleEdit(record: Recordable) { | |||||
openModal(true, { | |||||
record, | |||||
isUpdate: true, | |||||
showFooter: true, | |||||
}); | |||||
} | |||||
/** | |||||
* 详情 | |||||
*/ | |||||
function handleDetail(record: Recordable) { | |||||
openModal(true, { | |||||
record, | |||||
isUpdate: true, | |||||
showFooter: false, | |||||
}); | |||||
} | |||||
/** | |||||
* 删除事件 | |||||
*/ | |||||
async function handleDelete(record) { | |||||
await deleteOne({ id: record.id }, handleSuccess); | |||||
} | |||||
/** | |||||
* 批量删除事件 | |||||
*/ | |||||
async function batchHandleDelete() { | |||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess); | |||||
} | |||||
/** | |||||
* 成功回调 | |||||
*/ | |||||
function handleSuccess() { | |||||
(selectedRowKeys.value = []) && reload(); | |||||
} | |||||
/** | |||||
* 操作栏 | |||||
*/ | |||||
function getTableAction(record) { | |||||
return [ | |||||
{ | |||||
label: '编辑', | |||||
onClick: handleEdit.bind(null, record), | |||||
auth: 'order:app_order:edit', | |||||
}, | |||||
]; | |||||
} | |||||
/** | |||||
* 下拉操作栏 | |||||
*/ | |||||
function getDropDownAction(record) { | |||||
return [ | |||||
{ | |||||
label: '详情', | |||||
onClick: handleDetail.bind(null, record), | |||||
}, | |||||
{ | |||||
label: '删除', | |||||
popConfirm: { | |||||
title: '是否确认删除', | |||||
confirm: handleDelete.bind(null, record), | |||||
placement: 'topLeft', | |||||
}, | |||||
auth: 'order:app_order:delete', | |||||
}, | |||||
]; | |||||
} | |||||
</script> | |||||
<style lang="less" scoped> | |||||
:deep(.ant-picker), | |||||
:deep(.ant-input-number) { | |||||
width: 100%; | |||||
} | |||||
</style> |
@ -0,0 +1,80 @@ | |||||
<template> | |||||
<BasicForm @register="registerForm" name="AppOrderCarForm" class="basic-modal-form" /> | |||||
</template> | |||||
<script lang="ts"> | |||||
import { defineComponent } from 'vue'; | |||||
import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
import { appOrderCarFormSchema } from '../AppOrder.data'; | |||||
import { defHttp } from '/@/utils/http/axios'; | |||||
import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils'; | |||||
export default defineComponent({ | |||||
name: 'AppOrderCarForm', | |||||
components: { BasicForm }, | |||||
props: { | |||||
disabled: { | |||||
type: Boolean, | |||||
default: false, | |||||
}, | |||||
}, | |||||
emits: ['register'], | |||||
setup(props, { emit }) { | |||||
const [registerForm, { setProps, resetFields, setFieldsValue, getFieldsValue, validate, scrollToField }] = useForm({ | |||||
schemas: appOrderCarFormSchema, | |||||
showActionButtonGroup: false, | |||||
baseColProps: { span: 12 }, | |||||
}); | |||||
/** | |||||
*初始化加载数据 | |||||
*/ | |||||
function initFormData(url, id) { | |||||
if (id) { | |||||
defHttp.get({ url, params: { id } }, { isTransformResponse: false }).then((res) => { | |||||
res.success && setFieldsValue({ ...res.result[0] }); | |||||
}); | |||||
} | |||||
setProps({ disabled: props.disabled }); | |||||
} | |||||
/** | |||||
*获取表单数据 | |||||
*/ | |||||
function getFormData() { | |||||
let formData = getFieldsValue(); | |||||
Object.keys(formData).map((k) => { | |||||
if (formData[k] instanceof Array) { | |||||
formData[k] = formData[k].join(','); | |||||
} | |||||
}); | |||||
return [formData]; | |||||
} | |||||
/** | |||||
*表单校验 | |||||
*/ | |||||
function validateForm(index) { | |||||
return new Promise((resolve, reject) => { | |||||
// 验证子表表单 | |||||
validate() | |||||
.then(() => { | |||||
return resolve(); | |||||
}) | |||||
.catch(({ errorFields }) => { | |||||
return reject({ error: VALIDATE_FAILED, index, errorFields: errorFields, scrollToField: scrollToField }); | |||||
}); | |||||
}); | |||||
} | |||||
return { | |||||
registerForm, | |||||
resetFields, | |||||
initFormData, | |||||
getFormData, | |||||
validateForm, | |||||
}; | |||||
}, | |||||
}); | |||||
</script> | |||||
<style lang="less" scoped> | |||||
.basic-modal-form { | |||||
overflow: auto; | |||||
height: 340px; | |||||
} | |||||
</style> |
@ -0,0 +1,80 @@ | |||||
<template> | |||||
<BasicForm @register="registerForm" name="AppOrderFinanceForm" class="basic-modal-form" /> | |||||
</template> | |||||
<script lang="ts"> | |||||
import { defineComponent } from 'vue'; | |||||
import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
import { appOrderFinanceFormSchema } from '../AppOrder.data'; | |||||
import { defHttp } from '/@/utils/http/axios'; | |||||
import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils'; | |||||
export default defineComponent({ | |||||
name: 'AppOrderFinanceForm', | |||||
components: { BasicForm }, | |||||
props: { | |||||
disabled: { | |||||
type: Boolean, | |||||
default: false, | |||||
}, | |||||
}, | |||||
emits: ['register'], | |||||
setup(props, { emit }) { | |||||
const [registerForm, { setProps, resetFields, setFieldsValue, getFieldsValue, validate, scrollToField }] = useForm({ | |||||
schemas: appOrderFinanceFormSchema, | |||||
showActionButtonGroup: false, | |||||
baseColProps: { span: 12 }, | |||||
}); | |||||
/** | |||||
*初始化加载数据 | |||||
*/ | |||||
function initFormData(url, id) { | |||||
if (id) { | |||||
defHttp.get({ url, params: { id } }, { isTransformResponse: false }).then((res) => { | |||||
res.success && setFieldsValue({ ...res.result[0] }); | |||||
}); | |||||
} | |||||
setProps({ disabled: props.disabled }); | |||||
} | |||||
/** | |||||
*获取表单数据 | |||||
*/ | |||||
function getFormData() { | |||||
let formData = getFieldsValue(); | |||||
Object.keys(formData).map((k) => { | |||||
if (formData[k] instanceof Array) { | |||||
formData[k] = formData[k].join(','); | |||||
} | |||||
}); | |||||
return [formData]; | |||||
} | |||||
/** | |||||
*表单校验 | |||||
*/ | |||||
function validateForm(index) { | |||||
return new Promise((resolve, reject) => { | |||||
// 验证子表表单 | |||||
validate() | |||||
.then(() => { | |||||
return resolve(); | |||||
}) | |||||
.catch(({ errorFields }) => { | |||||
return reject({ error: VALIDATE_FAILED, index, errorFields: errorFields, scrollToField: scrollToField }); | |||||
}); | |||||
}); | |||||
} | |||||
return { | |||||
registerForm, | |||||
resetFields, | |||||
initFormData, | |||||
getFormData, | |||||
validateForm, | |||||
}; | |||||
}, | |||||
}); | |||||
</script> | |||||
<style lang="less" scoped> | |||||
.basic-modal-form { | |||||
overflow: auto; | |||||
height: 340px; | |||||
} | |||||
</style> |
@ -0,0 +1,139 @@ | |||||
<template> | |||||
<div> | |||||
<BasicForm @register="registerForm" ref="formRef" /> | |||||
<!-- 子表单区域 --> | |||||
<a-tabs v-model:activeKey="activeKey" animated @change="handleChangeTabs"> | |||||
<a-tab-pane tab="订单车辆信息" key="appOrderCar" :forceRender="true"> | |||||
<AppOrderCarForm ref="appOrderCarForm" :disabled="formDisabled" /> | |||||
</a-tab-pane> | |||||
<a-tab-pane tab="订单凭证信息" key="appOrderVoucher" :forceRender="true"> | |||||
<AppOrderVoucherForm ref="appOrderVoucherForm" :disabled="formDisabled" /> | |||||
</a-tab-pane> | |||||
<a-tab-pane tab="订单金融信息" key="appOrderFinance" :forceRender="true"> | |||||
<AppOrderFinanceForm ref="appOrderFinanceForm" :disabled="formDisabled" /> | |||||
</a-tab-pane> | |||||
</a-tabs> | |||||
<div style="width: 100%; text-align: center" v-if="!formDisabled"> | |||||
<a-button @click="handleSubmit" pre-icon="ant-design:check" type="primary">提 交</a-button> | |||||
</div> | |||||
</div> | |||||
</template> | |||||
<script lang="ts"> | |||||
import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
import { computed, defineComponent, reactive, ref, unref } from 'vue'; | |||||
import { defHttp } from '/@/utils/http/axios'; | |||||
import { propTypes } from '/@/utils/propTypes'; | |||||
import { useJvxeMethod } from '/@/hooks/system/useJvxeMethods'; | |||||
import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils'; | |||||
import AppOrderCarForm from './AppOrderCarForm.vue'; | |||||
import AppOrderVoucherForm from './AppOrderVoucherForm.vue'; | |||||
import AppOrderFinanceForm from './AppOrderFinanceForm.vue'; | |||||
import { getBpmFormSchema } from '../AppOrder.data'; | |||||
import { saveOrUpdate, appOrderCarList, appOrderVoucherList, appOrderFinanceList } from '../AppOrder.api'; | |||||
export default defineComponent({ | |||||
name: 'AppOrderForm', | |||||
components: { | |||||
BasicForm, | |||||
AppOrderCarForm, | |||||
AppOrderVoucherForm, | |||||
AppOrderFinanceForm, | |||||
}, | |||||
props: { | |||||
formData: propTypes.object.def({}), | |||||
formBpm: propTypes.bool.def(true), | |||||
}, | |||||
setup(props) { | |||||
const [registerForm, { setFieldsValue, setProps }] = useForm({ | |||||
labelWidth: 150, | |||||
schemas: getBpmFormSchema(props.formData), | |||||
showActionButtonGroup: false, | |||||
baseColProps: { span: 12 }, | |||||
}); | |||||
const formDisabled = computed(() => { | |||||
if (props.formData.disabled === false) { | |||||
return false; | |||||
} | |||||
return true; | |||||
}); | |||||
const refKeys = ref(['appOrderCar', 'appOrderVoucher', 'appOrderFinance']); | |||||
const activeKey = ref('appOrderCar'); | |||||
const appOrderCarForm = ref(); | |||||
const appOrderVoucherForm = ref(); | |||||
const appOrderFinanceForm = ref(); | |||||
const tableRefs = {}; | |||||
const [handleChangeTabs, handleSubmit, requestSubTableData, formRef] = useJvxeMethod( | |||||
requestAddOrEdit, | |||||
classifyIntoFormData, | |||||
tableRefs, | |||||
activeKey, | |||||
refKeys, | |||||
validateSubForm | |||||
); | |||||
function classifyIntoFormData(allValues) { | |||||
let main = Object.assign({}, allValues.formValue); | |||||
return { | |||||
...main, // 展开 | |||||
appOrderCarList: appOrderCarForm.value.getFormData(), | |||||
appOrderVoucherList: appOrderVoucherForm.value.getFormData(), | |||||
appOrderFinanceList: appOrderFinanceForm.value.getFormData(), | |||||
}; | |||||
} | |||||
//校验所有一对一子表表单 | |||||
function validateSubForm(allValues) { | |||||
return new Promise((resolve, _reject) => { | |||||
Promise.all([appOrderCarForm.value.validateForm(0), appOrderVoucherForm.value.validateForm(1), appOrderFinanceForm.value.validateForm(2)]) | |||||
.then(() => { | |||||
resolve(allValues); | |||||
}) | |||||
.catch((e) => { | |||||
if (e.error === VALIDATE_FAILED) { | |||||
// 如果有未通过表单验证的子表,就自动跳转到它所在的tab | |||||
activeKey.value = e.index == null ? unref(activeKey) : refKeys.value[e.index]; | |||||
} else { | |||||
console.error(e); | |||||
} | |||||
}); | |||||
}); | |||||
} | |||||
//表单提交事件 | |||||
async function requestAddOrEdit(values) { | |||||
await saveOrUpdate(values, true); | |||||
} | |||||
const queryByIdUrl = '/order/appOrder/queryById'; | |||||
async function initFormData() { | |||||
let params = { id: props.formData.dataId }; | |||||
const data = await defHttp.get({ url: queryByIdUrl, params }); | |||||
//设置表单的值 | |||||
await setFieldsValue({ ...data }); | |||||
appOrderCarForm.value.initFormData(appOrderCarList, data.id); | |||||
appOrderVoucherForm.value.initFormData(appOrderVoucherList, data.id); | |||||
appOrderFinanceForm.value.initFormData(appOrderFinanceList, data.id); | |||||
//默认是禁用 | |||||
await setProps({ disabled: formDisabled.value }); | |||||
} | |||||
initFormData(); | |||||
return { | |||||
registerForm, | |||||
formDisabled, | |||||
formRef, | |||||
handleSubmit, | |||||
activeKey, | |||||
handleChangeTabs, | |||||
appOrderCarForm, | |||||
appOrderVoucherForm, | |||||
appOrderFinanceForm, | |||||
}; | |||||
}, | |||||
}); | |||||
</script> |
@ -0,0 +1,145 @@ | |||||
<template> | |||||
<BasicModal v-bind="$attrs" @register="registerModal" destroyOnClose :title="title" :width="896" @ok="handleSubmit"> | |||||
<BasicForm @register="registerForm" ref="formRef" name="AppOrderForm" /> | |||||
<!-- 子表单区域 --> | |||||
<a-tabs v-model:activeKey="activeKey" animated @change="handleChangeTabs"> | |||||
<a-tab-pane tab="订单车辆信息" key="appOrderCar" :forceRender="true"> | |||||
<AppOrderCarForm ref="appOrderCarForm" :disabled="formDisabled" /> | |||||
</a-tab-pane> | |||||
<a-tab-pane tab="订单凭证信息" key="appOrderVoucher" :forceRender="true"> | |||||
<AppOrderVoucherForm ref="appOrderVoucherForm" :disabled="formDisabled" /> | |||||
</a-tab-pane> | |||||
<a-tab-pane tab="订单金融信息" key="appOrderFinance" :forceRender="true"> | |||||
<AppOrderFinanceForm ref="appOrderFinanceForm" :disabled="formDisabled" /> | |||||
</a-tab-pane> | |||||
</a-tabs> | |||||
</BasicModal> | |||||
</template> | |||||
<script lang="ts" setup> | |||||
import { ref, computed, unref, reactive } from 'vue'; | |||||
import { BasicModal, useModalInner } from '/@/components/Modal'; | |||||
import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
import { JVxeTable } from '/@/components/jeecg/JVxeTable'; | |||||
import { useJvxeMethod } from '/@/hooks/system/useJvxeMethods.ts'; | |||||
import AppOrderCarForm from './AppOrderCarForm.vue'; | |||||
import AppOrderVoucherForm from './AppOrderVoucherForm.vue'; | |||||
import AppOrderFinanceForm from './AppOrderFinanceForm.vue'; | |||||
import { formSchema } from '../AppOrder.data'; | |||||
import { saveOrUpdate, appOrderCarList, appOrderVoucherList, appOrderFinanceList } from '../AppOrder.api'; | |||||
import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils'; | |||||
// Emits声明 | |||||
const emit = defineEmits(['register', 'success']); | |||||
const isUpdate = ref(true); | |||||
const formDisabled = ref(false); | |||||
const refKeys = ref(['appOrderCar', 'appOrderVoucher', 'appOrderFinance']); | |||||
const activeKey = ref('appOrderCar'); | |||||
const appOrderCarForm = ref(); | |||||
const appOrderVoucherForm = ref(); | |||||
const appOrderFinanceForm = ref(); | |||||
const tableRefs = {}; | |||||
//表单配置 | |||||
const [registerForm, { setProps, resetFields, setFieldsValue, validate }] = useForm({ | |||||
schemas: formSchema, | |||||
showActionButtonGroup: false, | |||||
baseColProps: { span: 12 }, | |||||
}); | |||||
//表单赋值 | |||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { | |||||
//重置表单 | |||||
await reset(); | |||||
setModalProps({ confirmLoading: false, showCancelBtn: data?.showFooter, showOkBtn: data?.showFooter }); | |||||
isUpdate.value = !!data?.isUpdate; | |||||
formDisabled.value = !data?.showFooter; | |||||
if (unref(isUpdate)) { | |||||
//表单赋值 | |||||
await setFieldsValue({ | |||||
...data.record, | |||||
}); | |||||
appOrderCarForm.value.initFormData(appOrderCarList, data?.record?.id); | |||||
appOrderVoucherForm.value.initFormData(appOrderVoucherList, data?.record?.id); | |||||
appOrderFinanceForm.value.initFormData(appOrderFinanceList, data?.record?.id); | |||||
} | |||||
// 隐藏底部时禁用整个表单 | |||||
setProps({ disabled: !data?.showFooter }); | |||||
}); | |||||
//方法配置 | |||||
const [handleChangeTabs, handleSubmit, requestSubTableData, formRef] = useJvxeMethod( | |||||
requestAddOrEdit, | |||||
classifyIntoFormData, | |||||
tableRefs, | |||||
activeKey, | |||||
refKeys, | |||||
validateSubForm | |||||
); | |||||
//设置标题 | |||||
const title = computed(() => (!unref(isUpdate) ? '新增' : !unref(formDisabled) ? '编辑' : '详情')); | |||||
async function reset() { | |||||
await resetFields(); | |||||
activeKey.value = 'appOrderCar'; | |||||
appOrderCarForm.value.resetFields(); | |||||
appOrderVoucherForm.value.resetFields(); | |||||
appOrderFinanceForm.value.resetFields(); | |||||
} | |||||
function classifyIntoFormData(allValues) { | |||||
let main = Object.assign({}, allValues.formValue); | |||||
return { | |||||
...main, // 展开 | |||||
appOrderCarList: appOrderCarForm.value.getFormData(), | |||||
appOrderVoucherList: appOrderVoucherForm.value.getFormData(), | |||||
appOrderFinanceList: appOrderFinanceForm.value.getFormData(), | |||||
}; | |||||
} | |||||
//校验所有一对一子表表单 | |||||
function validateSubForm(allValues) { | |||||
return new Promise((resolve, reject) => { | |||||
Promise.all([appOrderCarForm.value.validateForm(0), appOrderVoucherForm.value.validateForm(1), appOrderFinanceForm.value.validateForm(2)]) | |||||
.then(() => { | |||||
resolve(allValues); | |||||
}) | |||||
.catch((e) => { | |||||
if (e.error === VALIDATE_FAILED) { | |||||
// 如果有未通过表单验证的子表,就自动跳转到它所在的tab | |||||
activeKey.value = e.index == null ? unref(activeKey) : refKeys.value[e.index]; | |||||
if (e.errorFields) { | |||||
const firstField = e.errorFields[0]; | |||||
if (firstField) { | |||||
e.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' }); | |||||
} | |||||
} | |||||
} else { | |||||
console.error(e); | |||||
} | |||||
}); | |||||
}); | |||||
} | |||||
//表单提交事件 | |||||
async function requestAddOrEdit(values) { | |||||
try { | |||||
setModalProps({ confirmLoading: true }); | |||||
//提交表单 | |||||
await saveOrUpdate(values, isUpdate.value); | |||||
//关闭弹窗 | |||||
closeModal(); | |||||
//刷新列表 | |||||
emit('success'); | |||||
} finally { | |||||
setModalProps({ confirmLoading: false }); | |||||
} | |||||
} | |||||
</script> | |||||
<style lang="less" scoped> | |||||
/** 时间和数字输入框样式 */ | |||||
:deep(.ant-input-number) { | |||||
width: 100%; | |||||
} | |||||
:deep(.ant-calendar-picker) { | |||||
width: 100%; | |||||
} | |||||
</style> |
@ -0,0 +1,80 @@ | |||||
<template> | |||||
<BasicForm @register="registerForm" name="AppOrderVoucherForm" class="basic-modal-form" /> | |||||
</template> | |||||
<script lang="ts"> | |||||
import { defineComponent } from 'vue'; | |||||
import { BasicForm, useForm } from '/@/components/Form/index'; | |||||
import { appOrderVoucherFormSchema } from '../AppOrder.data'; | |||||
import { defHttp } from '/@/utils/http/axios'; | |||||
import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils'; | |||||
export default defineComponent({ | |||||
name: 'AppOrderVoucherForm', | |||||
components: { BasicForm }, | |||||
props: { | |||||
disabled: { | |||||
type: Boolean, | |||||
default: false, | |||||
}, | |||||
}, | |||||
emits: ['register'], | |||||
setup(props, { emit }) { | |||||
const [registerForm, { setProps, resetFields, setFieldsValue, getFieldsValue, validate, scrollToField }] = useForm({ | |||||
schemas: appOrderVoucherFormSchema, | |||||
showActionButtonGroup: false, | |||||
baseColProps: { span: 12 }, | |||||
}); | |||||
/** | |||||
*初始化加载数据 | |||||
*/ | |||||
function initFormData(url, id) { | |||||
if (id) { | |||||
defHttp.get({ url, params: { id } }, { isTransformResponse: false }).then((res) => { | |||||
res.success && setFieldsValue({ ...res.result[0] }); | |||||
}); | |||||
} | |||||
setProps({ disabled: props.disabled }); | |||||
} | |||||
/** | |||||
*获取表单数据 | |||||
*/ | |||||
function getFormData() { | |||||
let formData = getFieldsValue(); | |||||
Object.keys(formData).map((k) => { | |||||
if (formData[k] instanceof Array) { | |||||
formData[k] = formData[k].join(','); | |||||
} | |||||
}); | |||||
return [formData]; | |||||
} | |||||
/** | |||||
*表单校验 | |||||
*/ | |||||
function validateForm(index) { | |||||
return new Promise((resolve, reject) => { | |||||
// 验证子表表单 | |||||
validate() | |||||
.then(() => { | |||||
return resolve(); | |||||
}) | |||||
.catch(({ errorFields }) => { | |||||
return reject({ error: VALIDATE_FAILED, index, errorFields: errorFields, scrollToField: scrollToField }); | |||||
}); | |||||
}); | |||||
} | |||||
return { | |||||
registerForm, | |||||
resetFields, | |||||
initFormData, | |||||
getFormData, | |||||
validateForm, | |||||
}; | |||||
}, | |||||
}); | |||||
</script> | |||||
<style lang="less" scoped> | |||||
.basic-modal-form { | |||||
overflow: auto; | |||||
height: 340px; | |||||
} | |||||
</style> |