查询默认值
This commit is contained in:
@@ -169,6 +169,23 @@ const summaryMethod1=({columns,data})=>{
|
|||||||
})
|
})
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
function getCurrentDate() {
|
||||||
|
const now = new Date();
|
||||||
|
// 补零函数:小于10则前面加0
|
||||||
|
const padZero = (num) => num.toString().padStart(2, '0');
|
||||||
|
|
||||||
|
const year = now.getFullYear();
|
||||||
|
const month = padZero(now.getMonth() + 1);
|
||||||
|
const day = padZero(now.getDate());
|
||||||
|
|
||||||
|
// 返回格式化后的字符串或对象,按需选择
|
||||||
|
return {
|
||||||
|
year,
|
||||||
|
month,
|
||||||
|
day,
|
||||||
|
fullDate: `${year}-${month}-${day}` // 拼接成 2026-02-24 格式
|
||||||
|
};
|
||||||
|
}
|
||||||
const initTable = async () => {
|
const initTable = async () => {
|
||||||
isInit.value = false
|
isInit.value = false
|
||||||
loading.value = true
|
loading.value = true
|
||||||
@@ -248,7 +265,17 @@ const initTable = async () => {
|
|||||||
_hasChildConfig: childFieldConfigs.has(item.fieldCode),
|
_hasChildConfig: childFieldConfigs.has(item.fieldCode),
|
||||||
_childConfigs: childFieldConfigs.get(item.fieldCode) || []
|
_childConfigs: childFieldConfigs.get(item.fieldCode) || []
|
||||||
}
|
}
|
||||||
|
if(!!item.searchDefaultValue){
|
||||||
|
if(['年','年度','年份'].includes(item.fieldName)&&item.searchDefaultValue=='本年'){
|
||||||
|
tableSearch.value[config.prop]=getCurrentDate().year
|
||||||
|
}else if( ['月','月度','月份'].includes(item.fieldName)&&item.searchDefaultValue=='本月'){
|
||||||
|
tableSearch.value[config.prop]=new Date().getMonth() + 1
|
||||||
|
}else if(item.fieldType=='Date'&&item.searchDefaultValue=='当日'){
|
||||||
|
tableSearch.value[config.prop]=getCurrentDate().fullDate
|
||||||
|
}else{
|
||||||
|
tableSearch.value[config.prop]=item.searchDefaultValue
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!!item.isAmount){
|
if(!!item.isAmount){
|
||||||
index==0?amountFieds.value.fistField=config.prop:''
|
index==0?amountFieds.value.fistField=config.prop:''
|
||||||
amountFieds.value[item.isAmount]=config
|
amountFieds.value[item.isAmount]=config
|
||||||
|
|||||||
@@ -95,7 +95,9 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
}
|
}
|
||||||
|
.width-50{
|
||||||
|
width: 50% !important;
|
||||||
|
}
|
||||||
/* nprogress 适配 element-plus 的主题色 */
|
/* nprogress 适配 element-plus 的主题色 */
|
||||||
#nprogress {
|
#nprogress {
|
||||||
& .bar {
|
& .bar {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import dayjs from 'dayjs'
|
|||||||
import type { TableColumnCtx } from 'element-plus'
|
import type { TableColumnCtx } from 'element-plus'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 日期快捷选项适用于 el-date-picker
|
* 日期快捷选项适用于 -picker
|
||||||
*/
|
*/
|
||||||
export const defaultShortcuts = [
|
export const defaultShortcuts = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -74,6 +74,75 @@ export const useRenderVxeColumn = (useType = 'table') => {
|
|||||||
return <el-input class="my-cell" text="text" v-model={row[prop]} placeholder={placeholder ? placeholder : '请输入 ' + column.title} />
|
return <el-input class="my-cell" text="text" v-model={row[prop]} placeholder={placeholder ? placeholder : '请输入 ' + column.title} />
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
LowInputDefualt: {
|
||||||
|
default: (renderOpts, { row, column, fieldProp }, isStop) => {
|
||||||
|
const prop = fieldProp || column.field
|
||||||
|
if (isStop) return (<div> <span>{row[prop]}</span> {stopIcon} </div>)
|
||||||
|
return <span>{row[prop]}</span>
|
||||||
|
},
|
||||||
|
edit: (renderOpts, { row, column, fieldProp ,rowIndex}) => {
|
||||||
|
const { placeholder } = renderOpts
|
||||||
|
const prop = fieldProp || column.field
|
||||||
|
const dicData=[]
|
||||||
|
if(['年','年度','年份'].includes(row.fieldName)){
|
||||||
|
dicData.push({label:'本年',value:'本年'})
|
||||||
|
dicData.push({label:'指定年份',value:'指定'})
|
||||||
|
}else if( ['月','月度','月份'].includes(row.fieldName)){
|
||||||
|
dicData.push({label:'本月',value:'本月'})
|
||||||
|
dicData.push({label:'指定月份',value:'指定'})
|
||||||
|
}else if(row.fieldType=='Date'){
|
||||||
|
dicData.push({label:'当日',value:'当日'})
|
||||||
|
dicData.push({label:'指定日期',value:'指定'})
|
||||||
|
}
|
||||||
|
if(dicData.length){
|
||||||
|
return [
|
||||||
|
<avue-select
|
||||||
|
popper-class="vxe-table--ignore-clear"
|
||||||
|
v-model={row.defaultSelect}
|
||||||
|
placeholder={'请选择'}
|
||||||
|
class={row.defaultSelect=="指定"?'width-50':''}
|
||||||
|
dic={dicData}
|
||||||
|
clearable={true}
|
||||||
|
onChange={({value}) => {
|
||||||
|
if(value!=='指定') row[prop]=value
|
||||||
|
else row[prop]=''
|
||||||
|
// 再触发自定义事件
|
||||||
|
if (renderOpts.events && renderOpts.events.change) {
|
||||||
|
renderOpts.events.change(row, column.field, rowIndex)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
onClear={() => {
|
||||||
|
// 触发清空事件
|
||||||
|
if (renderOpts.events && renderOpts.events.clear) {
|
||||||
|
renderOpts.events.clear(row, column.field, rowIndex)
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
row.defaultSelect === "指定"&&row.fieldType!=='Date' && (
|
||||||
|
<el-input
|
||||||
|
class={row.defaultSelect?'my-cell width-50':'my-cell'}
|
||||||
|
type="text"
|
||||||
|
v-model={row[prop]}
|
||||||
|
placeholder={placeholder || `请输入 ${column.title}`}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
row.defaultSelect === "指定"&&row.fieldType=='Date' && (
|
||||||
|
<el-date-picker
|
||||||
|
class={row.defaultSelect?'my-cell width-50':'my-cell'}
|
||||||
|
v-model={row[prop]}
|
||||||
|
placeholder={placeholder || `请输入 ${column.title}`}
|
||||||
|
format={'YYYY-MM-DD'}
|
||||||
|
valueFormat={'YYYY-MM-DD'}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return <el-input class="my-cell" text="text" v-model={row[prop]} placeholder={placeholder ? placeholder : '请输入 ' + column.title} />
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
LowNumber: {
|
LowNumber: {
|
||||||
default: (renderOpts, { row, column }, isStop) => {
|
default: (renderOpts, { row, column }, isStop) => {
|
||||||
if (isStop) return (<div> <span>{row[column.field]}</span> {stopIcon} </div>)
|
if (isStop) return (<div> <span>{row[column.field]}</span> {stopIcon} </div>)
|
||||||
|
|||||||
@@ -164,6 +164,11 @@ const fieldList = computed(() => {
|
|||||||
value: item.fieldCode,
|
value: item.fieldCode,
|
||||||
type: item.fieldType
|
type: item.fieldType
|
||||||
})
|
})
|
||||||
|
if(item.searchDefaultValue&&['当日','本月','本年'].includes(item.searchDefaultValue)){
|
||||||
|
item.defaultSelect=item.searchDefaultValue
|
||||||
|
}else if(item.searchDefaultValue){
|
||||||
|
item.defaultSelect='指定'
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return dicData
|
return dicData
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -158,6 +158,8 @@ const infoColumn = {
|
|||||||
fixedColumnValue: { title: '固定列内容', width: 110, align: "center", editRender: { name: 'LowButton', disabled: (row) => row.isFixedColumn !== 'Y', buttonText: '配置内容', buttonType: 'primary', buttonSize: 'small', events: {} } },
|
fixedColumnValue: { title: '固定列内容', width: 110, align: "center", editRender: { name: 'LowButton', disabled: (row) => row.isFixedColumn !== 'Y', buttonText: '配置内容', buttonType: 'primary', buttonSize: 'small', events: {} } },
|
||||||
queryIsDb: { title: '接口查询', width: 75, align: "center", editRender: { name: 'LowCheckbox' } },
|
queryIsDb: { title: '接口查询', width: 75, align: "center", editRender: { name: 'LowCheckbox' } },
|
||||||
queryIsWeb: { title: '查询控件', width: 75, align: "center", editRender: { name: 'LowCheckbox' } },
|
queryIsWeb: { title: '查询控件', width: 75, align: "center", editRender: { name: 'LowCheckbox' } },
|
||||||
|
searchDefaultValue: { title: '默认值', width: 180, align: "center", editRender: { name: 'LowInputDefualt' , verifyEdit: true} },
|
||||||
|
|
||||||
queryMode: { title: '查询模式', width: 130, editRender: { name: 'LowSelect', verifyEdit: true, dicData: dicObj.queryMode, dicObj: getDicObj('queryMode') } },
|
queryMode: { title: '查询模式', width: 130, editRender: { name: 'LowSelect', verifyEdit: true, dicData: dicObj.queryMode, dicObj: getDicObj('queryMode') } },
|
||||||
dictCode: { title: '字典Code', width: 180, editRender: { name: 'LowSelect', verifyEdit: true, filterable: true, noStop: true, dicData: [] } },
|
dictCode: { title: '字典Code', width: 180, editRender: { name: 'LowSelect', verifyEdit: true, filterable: true, noStop: true, dicData: [] } },
|
||||||
isExport: { title: '是否可导出', width: 90, align: "center", editRender: { name: 'LowCheckbox' } },
|
isExport: { title: '是否可导出', width: 90, align: "center", editRender: { name: 'LowCheckbox' } },
|
||||||
|
|||||||
Reference in New Issue
Block a user