no message
parent
0284e53b77
commit
9f3b8f4af0
|
|
@ -160,7 +160,7 @@
|
|||
const { mode } = unref<Recordable>(getBindValue);
|
||||
let changeValue:any;
|
||||
// 兼容多选模式
|
||||
|
||||
|
||||
//update-begin---author:wangshuai ---date:20230216 for:[QQYUN-4290]公文发文:选择机关代字报错,是因为值改变触发了change事件三次,导致数据发生改变------------
|
||||
//采用一个值,不然的话state值变换触发多个change
|
||||
if (mode === 'multiple') {
|
||||
|
|
@ -181,8 +181,9 @@
|
|||
emit('update:value',changeValue)
|
||||
//update-end---author:wangshuai ---date:20230403 for:【issues/4507】JDictSelectTag组件使用时,浏览器给出警告提示:Expected Function, got Array述------------
|
||||
//update-end---author:wangshuai ---date:20230216 for:[QQYUN-4290]公文发文:选择机关代字报错,是因为值改变触发了change事件三次,导致数据发生改变------------
|
||||
|
||||
|
||||
// nextTick(() => formItemContext.onFieldChange());
|
||||
console.log('变化', changeValue);
|
||||
}
|
||||
|
||||
/** 单选radio的值变化事件 */
|
||||
|
|
|
|||
|
|
@ -9,77 +9,113 @@
|
|||
v-bind="attrs"
|
||||
@change="onSelectChange"
|
||||
/>
|
||||
<a-switch v-else v-model:checked="checked" :disabled="disabled" v-bind="attrs" @change="onSwitchChange" />
|
||||
<a-switch
|
||||
v-else
|
||||
v-model:checked="checked"
|
||||
:disabled="disabled"
|
||||
v-bind="attrs"
|
||||
@change="onSwitchChange"
|
||||
:checked-children="checkedChildren"
|
||||
:un-checked-children="unCheckedChildren"
|
||||
:class="[checked ? 'switch-enabled' : 'switch-disabled']"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
const { prefixCls } = useDesign('j-switch');
|
||||
const props = defineProps({
|
||||
// v-model:value
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.number]),
|
||||
// 取值 options
|
||||
options: propTypes.array.def(() => ['Y', 'N']),
|
||||
// 文本 options
|
||||
labelOptions: propTypes.array.def(() => ['是', '否']),
|
||||
// 是否使用下拉
|
||||
query: propTypes.bool.def(false),
|
||||
// 是否禁用
|
||||
disabled: propTypes.bool.def(false),
|
||||
});
|
||||
const attrs = useAttrs();
|
||||
const emit = defineEmits(['change', 'update:value']);
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { useDesign } from '/@/hooks/web/useDesign';
|
||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
||||
|
||||
const checked = ref<boolean>(false);
|
||||
const [state] = useRuleFormItem(props, 'value', 'change');
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (!props.query) {
|
||||
// update-begin--author:liaozhiyang---date:20231226---for:【QQYUN-7473】options使用[0,1],导致开关无法切换
|
||||
if (!val && !props.options.includes(val)) {
|
||||
checked.value = false;
|
||||
emitValue(props.options[1]);
|
||||
} else {
|
||||
checked.value = props.options[0] == val;
|
||||
}
|
||||
// update-end--author:liaozhiyang---date:20231226---for:【QQYUN-7473】options使用[0,1],导致开关无法切换
|
||||
const { prefixCls } = useDesign('j-switch');
|
||||
const props = defineProps({
|
||||
// v-model:value
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.number]),
|
||||
// 取值 options
|
||||
options: propTypes.array.def(() => ['Y', 'N']),
|
||||
// 文本 options
|
||||
labelOptions: propTypes.array.def(() => ['是', '否']),
|
||||
// 是否使用下拉
|
||||
query: propTypes.bool.def(false),
|
||||
// 是否禁用
|
||||
disabled: propTypes.bool.def(false),
|
||||
// 启用状态显示文本
|
||||
checkedChildren: propTypes.string.def('启用'),
|
||||
// 禁用状态显示文本
|
||||
unCheckedChildren: propTypes.string.def('禁用'),
|
||||
});
|
||||
|
||||
const attrs = useAttrs();
|
||||
const emit = defineEmits(['change', 'update:value']);
|
||||
|
||||
const checked = ref<boolean>(false);
|
||||
const [state] = useRuleFormItem(props, 'value', 'change');
|
||||
|
||||
watch(
|
||||
() => props.value,
|
||||
(val) => {
|
||||
if (!props.query) {
|
||||
// update-begin--author:liaozhiyang---date:20231226---for:【QQYUN-7473】options使用[0,1],导致开关无法切换
|
||||
if (!val && !props.options.includes(val)) {
|
||||
const enabledValue = props.options[0];
|
||||
checked.value = String(val) === String(enabledValue);
|
||||
} else {
|
||||
checked.value = props.options[0] == val;
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
// update-end--author:liaozhiyang---date:20231226---for:【QQYUN-7473】options使用[0,1],导致开关无法切换
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
const selectOptions = computed(() => {
|
||||
let options: any[] = [];
|
||||
options.push({ value: props.options[0], label: props.labelOptions[0] });
|
||||
options.push({ value: props.options[1], label: props.labelOptions[1] });
|
||||
return options;
|
||||
});
|
||||
const selectOptions = computed(() => {
|
||||
let options: any[] = [];
|
||||
options.push({ value: props.options[0], label: props.labelOptions[0] });
|
||||
options.push({ value: props.options[1], label: props.labelOptions[1] });
|
||||
return options;
|
||||
});
|
||||
|
||||
function onSwitchChange(checked) {
|
||||
let flag = checked === false ? props.options[1] : props.options[0];
|
||||
emitValue(flag);
|
||||
}
|
||||
function onSwitchChange(checked) {
|
||||
let flag = checked === false ? props.options[1] : props.options[0];
|
||||
emitValue(flag);
|
||||
}
|
||||
|
||||
function onSelectChange(value) {
|
||||
emitValue(value);
|
||||
}
|
||||
function onSelectChange(value) {
|
||||
emitValue(value);
|
||||
}
|
||||
|
||||
function emitValue(value) {
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
}
|
||||
function emitValue(value) {
|
||||
emit('change', value);
|
||||
emit('update:value', value);
|
||||
console.log('数据:', value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
//noinspection LessUnresolvedVariable
|
||||
@prefix-cls: ~'@{namespace}-j-switch';
|
||||
//noinspection LessUnresolvedVariable
|
||||
@prefix-cls: ~'@{namespace}-j-switch';
|
||||
|
||||
.@{prefix-cls} {
|
||||
.@{prefix-cls} {
|
||||
.switch-enabled {
|
||||
:deep(.ant-switch-inner) {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&:not(.ant-switch-disabled) {
|
||||
background-color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
.switch-disabled {
|
||||
:deep(.ant-switch-inner) {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
&:not(.ant-switch-disabled) {
|
||||
background-color: @error-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ const installOptions = {
|
|||
};
|
||||
|
||||
/** 注册模块 */
|
||||
function use(app: App, pkg) {
|
||||
function use(app: App, pkg: any) {
|
||||
app.use(pkg, installOptions);
|
||||
registerDynamicRouter(pkg.getViews);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,163 @@
|
|||
<!--通用列表显示Switch组件-->
|
||||
<template>
|
||||
<JSwitch
|
||||
:value="currentValue"
|
||||
:options="switchOptions"
|
||||
:checked-children="checkedChildren"
|
||||
:un-checked-children="unCheckedChildren"
|
||||
:disabled="disabled"
|
||||
:loading="loading"
|
||||
:style="{ marginRight: '4px', ...switchStyle }"
|
||||
@change="handleChange"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, computed, watch } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import JSwitch from '/@/components/Form/src/jeecg/components/JSwitch.vue';
|
||||
|
||||
interface Props {
|
||||
// 当前状态值
|
||||
modelValue: string | number;
|
||||
// 记录ID
|
||||
recordId: string | number;
|
||||
// 记录名称(用于提示)
|
||||
recordName?: string;
|
||||
// API更新函数
|
||||
updateApi: (params: any, isUpdate?: boolean) => Promise<any>;
|
||||
// 开关选项
|
||||
switchOptions?: [string | number, string | number];
|
||||
// 启用时显示文字
|
||||
checkedChildren?: string;
|
||||
// 禁用时显示文字
|
||||
unCheckedChildren?: string;
|
||||
// 是否禁用
|
||||
disabled?: boolean;
|
||||
// 自定义样式
|
||||
switchStyle?: object;
|
||||
// 确认提示标题
|
||||
confirmTitle?: string;
|
||||
// 构建请求参数的函数
|
||||
buildParams?: (value: string | number) => Record<string, any>;
|
||||
// 是否为更新操作
|
||||
isUpdate?: boolean;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
switchOptions: () => ['1', '0'],
|
||||
checkedChildren: '启用',
|
||||
unCheckedChildren: '禁用',
|
||||
disabled: false,
|
||||
switchStyle: () => ({}),
|
||||
confirmTitle: '切换状态',
|
||||
buildParams: undefined,
|
||||
isUpdate: true,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: string | number): void;
|
||||
(e: 'success', value: string | number): void;
|
||||
(e: 'cancel', value: string | number): void;
|
||||
}>();
|
||||
|
||||
const { createMessage, createConfirm } = useMessage();
|
||||
const loading = ref(false);
|
||||
const currentValue = ref(props.modelValue);
|
||||
|
||||
// 监听外部值变化
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(val) => {
|
||||
currentValue.value = val;
|
||||
}
|
||||
);
|
||||
|
||||
// 构建提示内容
|
||||
const content = computed(() => {
|
||||
const statusText = currentValue.value == props.switchOptions[0]
|
||||
? `【${props.checkedChildren}】`
|
||||
: `【${props.unCheckedChildren}】`;
|
||||
const recordLabel = props.recordName || props.recordId;
|
||||
return `您要将【${recordLabel}】的状态切换为 ${statusText}吗?`;
|
||||
});
|
||||
|
||||
// 构建请求参数
|
||||
function buildRequestParams(value: string | number): Record<string, any> {
|
||||
let params: any = {
|
||||
id: props.recordId,
|
||||
};
|
||||
|
||||
if (props.buildParams) {
|
||||
params = { ...params, ...props.buildParams(value) };
|
||||
} else {
|
||||
// 使用更合理的默认参数名
|
||||
params.status = value;
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
// 恢复原始值
|
||||
function restoreOriginalValue(originalValue: string | number) {
|
||||
currentValue.value = originalValue;
|
||||
emit('update:modelValue', originalValue);
|
||||
emit('cancel', originalValue);
|
||||
}
|
||||
|
||||
// 处理更新错误
|
||||
function handleUpdateError(originalValue: string | number) {
|
||||
restoreOriginalValue(originalValue);
|
||||
createMessage.error('状态更新失败');
|
||||
}
|
||||
|
||||
// 显示确认对话框
|
||||
async function showConfirmDialog(originalValue: string | number, newValue: string | number): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: props.confirmTitle,
|
||||
content: content.value,
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params = buildRequestParams(newValue);
|
||||
await props.updateApi(params, props.isUpdate);
|
||||
currentValue.value = newValue;
|
||||
emit('update:modelValue', newValue);
|
||||
emit('success', newValue);
|
||||
createMessage.success('状态更新成功');
|
||||
resolve();
|
||||
} catch (error) {
|
||||
handleUpdateError(originalValue);
|
||||
reject(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
onCancel: () => {
|
||||
restoreOriginalValue(originalValue);
|
||||
reject(new Error('cancelled'));
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// 处理状态变更
|
||||
async function handleChange(value: string | number) {
|
||||
try {
|
||||
const originalValue = currentValue.value;
|
||||
currentValue.value = value;
|
||||
|
||||
await showConfirmDialog(originalValue, value);
|
||||
} catch (error) {
|
||||
// 用户取消操作不需要提示错误
|
||||
if (!(error instanceof Error && error.message === 'cancelled')) {
|
||||
console.error('状态切换异常:', error);
|
||||
createMessage.error('操作异常');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from "/@/hooks/web/useMessage";
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/base/area/list',
|
||||
save='/base/area/add',
|
||||
edit='/base/area/edit',
|
||||
save = '/base/area/add',
|
||||
edit = '/base/area/edit',
|
||||
deleteOne = '/base/area/delete',
|
||||
deleteBatch = '/base/area/deleteBatch',
|
||||
importExcel = '/base/area/importExcel',
|
||||
|
|
@ -35,11 +35,11 @@ export const list = (params) => defHttp.get({ url: Api.list, params });
|
|||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const deleteOne = (params,handleSuccess) => {
|
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||
export const deleteOne = (params, handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
|
|
@ -54,12 +54,20 @@ export const batchDelete = (params, handleSuccess) => {
|
|||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
return defHttp
|
||||
.delete(
|
||||
{
|
||||
url: Api.deleteBatch,
|
||||
data: params,
|
||||
},
|
||||
{ joinParamsToUrl: true }
|
||||
)
|
||||
.then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 保存或者更新
|
||||
|
|
@ -67,6 +75,7 @@ export const batchDelete = (params, handleSuccess) => {
|
|||
* @param isUpdate
|
||||
*/
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
const url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url: url, params }, { isTransformResponse: false });
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1,30 @@
|
|||
import {BasicColumn} from '/@/components/Table';
|
||||
import { BasicColumn } from '/@/components/Table';
|
||||
//列表数据
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '库区编码',
|
||||
align: "center",
|
||||
dataIndex: 'areaCode'
|
||||
align: 'center',
|
||||
dataIndex: 'areaCode',
|
||||
},
|
||||
{
|
||||
title: '库区名称',
|
||||
align: "center",
|
||||
dataIndex: 'areaName'
|
||||
align: 'center',
|
||||
dataIndex: 'areaName',
|
||||
},
|
||||
{
|
||||
title: '是否启用',
|
||||
align: 'center',
|
||||
dataIndex: 'izActive',
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
align: "center",
|
||||
align: 'center',
|
||||
dataIndex: 'description',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
align: "center",
|
||||
align: 'center',
|
||||
dataIndex: 'createTime',
|
||||
sorter: true,
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,24 +4,26 @@
|
|||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="areaCode">
|
||||
<template #label><span title="库区编码">库区编码</span></template>
|
||||
<JInput v-model:value="queryParam.areaCode" :type="JInputTypeEnum.JINPUT_RIGHT_LIKE" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="areaName">
|
||||
<template #label><span title="库区名称">库区名称</span></template>
|
||||
<JInput v-model:value="queryParam.areaName" />
|
||||
<JInput v-model:value="queryParam.areaName" :placeholder="'请输入库区名称'" :type="JInputTypeEnum.JINPUT_RIGHT_LIKE" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="createTime">
|
||||
<template #label><span title="创建日期">创建日期</span></template>
|
||||
<JRangeDate v-model:value="queryParam.createTime" />
|
||||
<a-form-item name="izActive">
|
||||
<template #label><span title="是否启用">是否启用</span></template>
|
||||
<JSearchSelect dict="dict_item_status" v-model:value="queryParam.izActive" placeholder="请选择" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<template v-if="toggleSearchStatus">
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="createTime">
|
||||
<template #label><span title="创建日期">创建日期</span></template>
|
||||
<JRangeDate v-model:value="queryParam.createTime" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</template>
|
||||
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||
<a-col :lg="6">
|
||||
|
|
@ -78,18 +80,20 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" name="base-area" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { ref, reactive, h } from 'vue';
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns } from './Area.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Area.api';
|
||||
import AreaModal from './components/AreaModal.vue';
|
||||
import { list, deleteOne, batchDelete, saveOrUpdate, getImportUrl, getExportUrl } from './Area.api';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import JInput from '/@/components/Form/src/jeecg/components/JInput.vue';
|
||||
import JRangeDate from '@/components/Form/src/jeecg/components/JRangeDate.vue';
|
||||
import { getDateByPicker } from '/@/utils';
|
||||
import { JInputTypeEnum } from '@/enums/cpteEnum';
|
||||
import JInput from '/@/components/Form/src/jeecg/components/JInput.vue';
|
||||
import JRangeDate from '@/components/Form/src/jeecg/components/JRangeDate.vue';
|
||||
import AreaModal from './components/AreaModal.vue';
|
||||
import JSearchSelect from '../../../components/Form/src/jeecg/components/JSearchSelect.vue';
|
||||
import SwitchStatus from '/@/views/base/SwitchStatus.vue';
|
||||
|
||||
const fieldPickers = reactive({});
|
||||
const formRef = ref();
|
||||
|
|
@ -98,12 +102,37 @@
|
|||
const registerModal = ref();
|
||||
const userStore = useUserStore();
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
const enhancedColumns = columns.map((col) => {
|
||||
if (col.dataIndex === 'izActive') {
|
||||
return {
|
||||
...col,
|
||||
customRender: ({ record }) => {
|
||||
return h(SwitchStatus, {
|
||||
modelValue: record.izActive,
|
||||
recordId: record.id,
|
||||
recordName: record.areaName,
|
||||
updateApi: saveOrUpdate,
|
||||
switchOptions: ['1', '0'],
|
||||
checkedChildren: '启用',
|
||||
unCheckedChildren: '禁用',
|
||||
buildParams: (value) => ({
|
||||
izActive: value,
|
||||
areaName: record.areaName,
|
||||
}),
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
return col;
|
||||
});
|
||||
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '库区',
|
||||
api: list,
|
||||
columns,
|
||||
columns: enhancedColumns, // 使用增强后的列,
|
||||
canResize: true,
|
||||
useSearchForm: false,
|
||||
actionColumn: {
|
||||
|
|
@ -203,6 +232,13 @@
|
|||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否启用状态取消回调
|
||||
*/
|
||||
function handleCancel(record, originalValue) {
|
||||
record.izActive = originalValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<a-spin :spinning="confirmLoading">
|
||||
<JFormContainer :disabled="disabled">
|
||||
<template #detail>
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="AreaForm">
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="AreaForm">
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="库区编码" v-bind="validateInfos.areaCode" id="AreaForm-areaCode" name="areaCode">
|
||||
|
|
@ -15,10 +15,15 @@
|
|||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="描述" v-bind="validateInfos.description" id="PointForm-description" name="description">
|
||||
<a-form-item label="描述" v-bind="validateInfos.description" id="AreaForm-description" name="description">
|
||||
<a-textarea v-model:value="formData.description" :rows="4" placeholder="请输入描述" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="是否启用" v-bind="validateInfos.izActive" id="AreaForm-izActive" name="izActive">
|
||||
<JSwitch v-model:value="formData.izActive" :options="['1', '0']"></JSwitch>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
|
|
@ -29,10 +34,12 @@
|
|||
<script lang="ts" setup>
|
||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getDateByPicker, getValueType } from '/@/utils';
|
||||
import { getValueType } from '/@/utils';
|
||||
import { saveOrUpdate } from '../Area.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
import { getTenantId } from '@/utils/auth';
|
||||
import JSwitch from '@/components/Form/src/jeecg/components/JSwitch.vue';
|
||||
|
||||
const props = defineProps({
|
||||
formDisabled: { type: Boolean, default: false },
|
||||
|
|
@ -42,12 +49,16 @@
|
|||
const formRef = ref();
|
||||
const useForm = Form.useForm;
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
//仓库 ID
|
||||
let tenantId = getTenantId();
|
||||
const formData = reactive<Record<string, any>>({
|
||||
id: '',
|
||||
areaCode: '',
|
||||
areaName: '',
|
||||
description: '',
|
||||
delFlag: 0,
|
||||
izActive: 1,
|
||||
tenantId: tenantId,
|
||||
});
|
||||
const { createMessage } = useMessage();
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
|
|
@ -58,11 +69,8 @@
|
|||
areaCode: [{ required: true, message: '请输入库区编码!' }],
|
||||
areaName: [{ required: true, message: '请输入库区名称!' }],
|
||||
delFlag: [{ required: true, message: '请输入删除状态!' }],
|
||||
createTime: [{ required: true, message: '请输入创建日期!' }],
|
||||
});
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||
//日期个性化选择
|
||||
const fieldPickers = reactive({});
|
||||
|
||||
// 表单禁用
|
||||
const disabled = computed(() => {
|
||||
|
|
@ -125,8 +133,6 @@
|
|||
}
|
||||
//循环数据
|
||||
for (let data in model) {
|
||||
// 更新个性化日期选择器的值
|
||||
model[data] = getDateByPicker(model[data], fieldPickers[data]);
|
||||
//如果该数据是数组并且是字符串类型
|
||||
if (model[data] instanceof Array) {
|
||||
let valueType = getValueType(formRef.value.getProps, data);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<j-modal :title="title" maxHeight="250px" :width="600" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<j-modal :title="title" :maxHeight="250" :width="600" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<AreaForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></AreaForm>
|
||||
<template #footer>
|
||||
<a-button @click="handleCancel">取消</a-button>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,361 @@
|
|||
<!-- 库区下拉选择-->
|
||||
<template>
|
||||
<a-select
|
||||
v-model:value="selectedValue"
|
||||
showSearch
|
||||
:placeholder="placeholder"
|
||||
:loading="loading"
|
||||
:allowClear="true"
|
||||
:filterOption="filterOption"
|
||||
:notFoundContent="notFoundContent"
|
||||
:mode="multiple ? 'multiple' : 'default'"
|
||||
@change="handleChange"
|
||||
@search="handleSearch"
|
||||
@focus="handleFocus"
|
||||
@popupScroll="handlePopupScroll"
|
||||
:getPopupContainer="getParentContainer"
|
||||
v-bind="attrs"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<a-spin v-if="loading" size="small" />
|
||||
<span v-else>暂无库区数据</span>
|
||||
</template>
|
||||
<a-select-option v-for="option in areaOptions" :key="option.id" :value="getOptionValue(option)">
|
||||
{{ getOptionLabel(option) }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, watch, computed, onMounted } from 'vue';
|
||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||
import { propTypes } from '/@/utils/propTypes';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { setPopContainer } from '/@/utils';
|
||||
import { debounce } from 'lodash-es';
|
||||
|
||||
// 库区数据接口
|
||||
interface Area {
|
||||
id: string;
|
||||
areaCode: string;
|
||||
areaName: string;
|
||||
}
|
||||
|
||||
//响应数据接口
|
||||
interface ResponseData {
|
||||
records: Area[];
|
||||
total: number;
|
||||
size: number;
|
||||
current: number;
|
||||
page: number;
|
||||
}
|
||||
|
||||
export default defineComponent({
|
||||
name: 'AreaSelect',
|
||||
inheritAttrs: false,
|
||||
props: {
|
||||
// 选中值,支持v-model
|
||||
value: propTypes.oneOfType([propTypes.string, propTypes.array, propTypes.object]),
|
||||
// 占位符
|
||||
placeholder: propTypes.string.def('请选择库区'),
|
||||
// 是否多选
|
||||
multiple: propTypes.bool.def(false),
|
||||
// 是否异步加载数据
|
||||
async: propTypes.bool.def(true),
|
||||
// 分页大小
|
||||
pageSize: propTypes.number.def(20),
|
||||
// 弹出层容器
|
||||
popContainer: propTypes.string,
|
||||
// 自定义弹出层容器函数
|
||||
getPopupContainer: {
|
||||
type: Function,
|
||||
default: (node: HTMLElement) => node?.parentNode,
|
||||
},
|
||||
// 是否立即触发change事件
|
||||
immediateChange: propTypes.bool.def(false),
|
||||
// 返回值类型: 'id'(默认) | 'object' | 其他字段名
|
||||
returnValue: propTypes.string.def('id'),
|
||||
//默认启用
|
||||
izActive: propTypes.number.def(1),
|
||||
},
|
||||
emits: ['change', 'update:value', 'optionsLoaded'],
|
||||
setup(props, { emit }) {
|
||||
const areaOptions = ref<Area[]>([]);
|
||||
const loading = ref<boolean>(false);
|
||||
const allAreas = ref<Area[]>([]);
|
||||
const attrs = useAttrs({ excludeDefaultKeys: false });
|
||||
|
||||
// 分页相关
|
||||
const pageNo = ref(1);
|
||||
const isHasData = ref(true);
|
||||
const scrollLoading = ref(false);
|
||||
const searchKeyword = ref('');
|
||||
|
||||
// 选中值
|
||||
const selectedValue = ref<string | string[] | undefined>(undefined);
|
||||
|
||||
// 未找到内容
|
||||
const notFoundContent = computed(() => {
|
||||
return loading.value ? undefined : null;
|
||||
});
|
||||
|
||||
/**
|
||||
* 获取选项显示文本 - 始终显示完整格式
|
||||
*/
|
||||
function getOptionLabel(option: Area) {
|
||||
return `${option.areaCode} - ${option.areaName}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取选项值 - 根据returnValue确定实际存储的值
|
||||
*/
|
||||
function getOptionValue(option: Area) {
|
||||
if (props.returnValue === 'object') {
|
||||
return option.id; // 对于object类型,仍然使用id作为选项值,但在change事件中返回完整对象
|
||||
} else if (props.returnValue === 'id') {
|
||||
return option.id;
|
||||
} else {
|
||||
return option[props.returnValue as keyof Area] as string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取弹出层容器
|
||||
*/
|
||||
function getParentContainer(node: HTMLElement) {
|
||||
if (props.popContainer) {
|
||||
return setPopContainer(node, props.popContainer);
|
||||
} else {
|
||||
if (typeof props.getPopupContainer === 'function') {
|
||||
return props.getPopupContainer(node);
|
||||
} else {
|
||||
return node?.parentNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤选项 - 禁用前端过滤,使用后端搜索
|
||||
*/
|
||||
function filterOption(_input: string, _option: any) {
|
||||
return true; // 禁用前端过滤,完全依赖后端搜索
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取库区数据
|
||||
*/
|
||||
const fetchAreas = async (page = 1, keyword = '', isSearch = false) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
|
||||
const res = await defHttp.get<ResponseData>({
|
||||
url: '/base/area/list',
|
||||
params: {
|
||||
pageSize: props.pageSize,
|
||||
pageNo: page,
|
||||
keyword: keyword,
|
||||
izActive: props.izActive,
|
||||
},
|
||||
});
|
||||
|
||||
console.log('获取库区数据成功:', res);
|
||||
const records = res.records || [];
|
||||
|
||||
if (page === 1 || isSearch) {
|
||||
// 第一页或搜索时,重置数据
|
||||
allAreas.value = records;
|
||||
areaOptions.value = records;
|
||||
} else {
|
||||
// 滚动加载时,追加数据
|
||||
allAreas.value = [...allAreas.value, ...records];
|
||||
areaOptions.value = [...areaOptions.value, ...records];
|
||||
}
|
||||
|
||||
// 修正分页判断逻辑
|
||||
isHasData.value = records.length >= props.pageSize;
|
||||
console.log('是否还有更多数据:', records.length);
|
||||
|
||||
emit('optionsLoaded', allAreas.value);
|
||||
} catch (error) {
|
||||
console.error('获取库区数据失败:', error);
|
||||
if (page === 1) {
|
||||
allAreas.value = [];
|
||||
areaOptions.value = [];
|
||||
}
|
||||
} finally {
|
||||
loading.value = false;
|
||||
scrollLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据选项值找到对应的选项对象
|
||||
*/
|
||||
function findOptionByValue(value: string): Area | undefined {
|
||||
if (props.returnValue === 'object' || props.returnValue === 'id') {
|
||||
return allAreas.value.find((item) => item.id === value);
|
||||
} else {
|
||||
return allAreas.value.find((item) => item[props.returnValue as keyof Area] === value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需要返回的值
|
||||
*/
|
||||
function getReturnValue(value: string | string[]) {
|
||||
if (!value) {
|
||||
return props.multiple ? [] : undefined;
|
||||
}
|
||||
|
||||
// 如果返回整个对象
|
||||
if (props.returnValue === 'object') {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((v) => findOptionByValue(v)).filter(Boolean);
|
||||
} else {
|
||||
return findOptionByValue(value);
|
||||
}
|
||||
}
|
||||
// 如果返回ID(默认情况)
|
||||
else if (props.returnValue === 'id') {
|
||||
return value;
|
||||
}
|
||||
// 如果返回对象中的某个字段
|
||||
else {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((v) => {
|
||||
const option = findOptionByValue(v);
|
||||
return option ? option[props.returnValue as keyof Area] : v;
|
||||
});
|
||||
} else {
|
||||
const option = findOptionByValue(value);
|
||||
return option ? option[props.returnValue as keyof Area] : value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索处理(防抖)
|
||||
*/
|
||||
const handleSearch = debounce(function (value: string) {
|
||||
searchKeyword.value = value;
|
||||
pageNo.value = 1;
|
||||
isHasData.value = true;
|
||||
|
||||
// 直接调用API进行搜索
|
||||
fetchAreas(1, value, true);
|
||||
}, 300);
|
||||
|
||||
/**
|
||||
* 处理焦点事件
|
||||
*/
|
||||
function handleFocus() {
|
||||
// 如果还没有数据,加载数据
|
||||
if (allAreas.value.length === 0 && props.async) {
|
||||
pageNo.value = 1;
|
||||
isHasData.value = true;
|
||||
fetchAreas(1, '');
|
||||
}
|
||||
attrs.onFocus?.();
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理值变化
|
||||
*/
|
||||
function handleChange(value: string | string[]) {
|
||||
selectedValue.value = value;
|
||||
|
||||
// 根据配置返回相应的值
|
||||
const returnValue = getReturnValue(value);
|
||||
console.log('值变化:', returnValue);
|
||||
emit('update:value', returnValue);
|
||||
emit('change', returnValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* 滚动加载处理
|
||||
*/
|
||||
function handlePopupScroll(e: Event) {
|
||||
const target = e.target as HTMLElement;
|
||||
const { scrollTop, scrollHeight, clientHeight } = target;
|
||||
|
||||
if (!scrollLoading.value && isHasData.value && scrollTop + clientHeight >= scrollHeight - 10) {
|
||||
console.log('滚动加载更多');
|
||||
scrollLoading.value = true;
|
||||
pageNo.value++;
|
||||
|
||||
fetchAreas(pageNo.value, searchKeyword.value)
|
||||
.finally(() => {
|
||||
scrollLoading.value = false;
|
||||
})
|
||||
.catch(() => {
|
||||
pageNo.value--;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据选中值初始化显示文本
|
||||
*/
|
||||
const initSelectValue = async () => {
|
||||
if (!props.value) {
|
||||
selectedValue.value = props.multiple ? [] : undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果是异步模式且还没有加载数据,则先加载数据
|
||||
if (props.async && allAreas.value.length === 0) {
|
||||
await fetchAreas();
|
||||
}
|
||||
|
||||
// 根据不同的returnValue设置选中的值
|
||||
if (props.returnValue === 'object') {
|
||||
// 如果返回的是对象,value可能是对象或对象数组
|
||||
if (Array.isArray(props.value)) {
|
||||
selectedValue.value = props.value.map((item: any) => item.id);
|
||||
} else {
|
||||
selectedValue.value = (props.value as any).id;
|
||||
}
|
||||
} else if (props.returnValue === 'id') {
|
||||
selectedValue.value = props.value as string | string[];
|
||||
} else {
|
||||
// 对于其他字段类型,直接使用传入的值
|
||||
selectedValue.value = props.value as string | string[];
|
||||
}
|
||||
};
|
||||
|
||||
// 监听value变化
|
||||
watch(
|
||||
() => props.value,
|
||||
() => {
|
||||
initSelectValue();
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// 组件挂载时初始化
|
||||
onMounted(() => {
|
||||
if (!props.async) {
|
||||
fetchAreas();
|
||||
}
|
||||
});
|
||||
|
||||
return {
|
||||
attrs,
|
||||
areaOptions,
|
||||
loading,
|
||||
selectedValue,
|
||||
notFoundContent,
|
||||
getParentContainer,
|
||||
filterOption,
|
||||
handleChange,
|
||||
handleSearch,
|
||||
handleFocus,
|
||||
getOptionLabel,
|
||||
getOptionValue,
|
||||
handlePopupScroll,
|
||||
};
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped></style>
|
||||
|
|
@ -1,54 +1,56 @@
|
|||
import {BasicColumn} from '/@/components/Table';
|
||||
import {FormSchema} from '/@/components/Table';
|
||||
import { rules} from '/@/utils/helper/validator';
|
||||
import { render } from '/@/utils/common/renderUtils';
|
||||
import { getWeekMonthQuarterYear } from '/@/utils';
|
||||
import { BasicColumn } from '/@/components/Table';
|
||||
import { render } from '@/utils/common/renderUtils';
|
||||
|
||||
//列表数据
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '库区',
|
||||
align: 'center',
|
||||
dataIndex: 'areaId_dictText',
|
||||
},
|
||||
{
|
||||
title: '库位编码',
|
||||
align: "center",
|
||||
dataIndex: 'pointCode'
|
||||
align: 'center',
|
||||
dataIndex: 'pointCode',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
align: 'center',
|
||||
dataIndex: 'status_dictText',
|
||||
customRender: ({ text }) => {
|
||||
const color = text == '占用' ? 'red' : text == '空闲' ? 'green' : 'gray';
|
||||
return render.renderTag(text, color);
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '排',
|
||||
align: "center",
|
||||
dataIndex: 'row'
|
||||
align: 'center',
|
||||
dataIndex: 'row',
|
||||
},
|
||||
{
|
||||
title: '列',
|
||||
align: "center",
|
||||
dataIndex: 'col'
|
||||
align: 'center',
|
||||
dataIndex: 'col',
|
||||
},
|
||||
{
|
||||
title: '层',
|
||||
align: "center",
|
||||
dataIndex: 'layer'
|
||||
align: 'center',
|
||||
dataIndex: 'layer',
|
||||
},
|
||||
{
|
||||
title: '是否启用',
|
||||
align: 'center',
|
||||
dataIndex: 'izActive',
|
||||
},
|
||||
{
|
||||
title: '描述',
|
||||
align: "center",
|
||||
dataIndex: 'description'
|
||||
},
|
||||
{
|
||||
title: '库区ID',
|
||||
align: "center",
|
||||
dataIndex: 'areaId'
|
||||
align: 'center',
|
||||
dataIndex: 'description',
|
||||
},
|
||||
{
|
||||
title: '创建日期',
|
||||
align: "center",
|
||||
dataIndex: 'createTime'
|
||||
align: 'center',
|
||||
dataIndex: 'createTime',
|
||||
sorter: true
|
||||
},
|
||||
];
|
||||
|
||||
// 高级查询数据
|
||||
export const superQuerySchema = {
|
||||
pointCode: {title: '库位编码',order: 0,view: 'text', type: 'string',},
|
||||
row: {title: '排',order: 1,view: 'text', type: 'string',},
|
||||
col: {title: '列',order: 2,view: 'text', type: 'string',},
|
||||
layer: {title: '层',order: 3,view: 'text', type: 'string',},
|
||||
description: {title: '描述',order: 4,view: 'textarea', type: 'string',},
|
||||
areaId: {title: '库区ID',order: 6,view: 'number', type: 'number',},
|
||||
createTime: {title: '创建日期',order: 7,view: 'datetime', type: 'string',},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,25 +5,23 @@
|
|||
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="pointCode">
|
||||
<template #label><span title="库位编码">库位编码</span></template>
|
||||
<a-input placeholder="请输入库位编码" v-model:value="queryParam.pointCode" allow-clear ></a-input>
|
||||
<a-form-item name="areaId">
|
||||
<template #label><span title="库区">库区</span></template>
|
||||
<AreaSelect v-model:value="queryParam.areaId" :area="queryParam" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="areaId">
|
||||
<template #label><span title="库区ID">库区ID</span></template>
|
||||
<a-input-number placeholder="请输入库区ID" v-model:value="queryParam.areaId"></a-input-number>
|
||||
<a-form-item name="pointCode">
|
||||
<template #label><span title="库位编码">库位编码</span></template>
|
||||
<JInput v-model:value="queryParam.pointCode" :placeholder="'请输入库位编码'" :type="JInputTypeEnum.JINPUT_RIGHT_LIKE" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="izActive">
|
||||
<template #label><span title="是否启用">是否启用</span></template>
|
||||
<JSearchSelect dict="dict_item_status" v-model:value="queryParam.izActive" placeholder="请选择" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<template v-if="toggleSearchStatus">
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="createTime">
|
||||
<template #label><span title="创建日期">创建日期</span></template>
|
||||
<a-date-picker showTime valueFormat="YYYY-MM-DD HH:mm:ss" placeholder="请选择创建日期" v-model:value="queryParam.createTime" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</template>
|
||||
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||
<a-col :lg="6">
|
||||
|
|
@ -43,9 +41,11 @@
|
|||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-auth="'base:base_point:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-button type="primary" v-auth="'base:base_point:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||
<j-upload-button type="primary" v-auth="'base:base_point:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||
<a-button type="primary" v-auth="'base:base_point:add'" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增 </a-button>
|
||||
<a-button type="primary" v-auth="'base:base_point:exportXls'" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出 </a-button>
|
||||
<j-upload-button type="primary" v-auth="'base:base_point:importExcel'" preIcon="ant-design:import-outlined" @click="onImportXls"
|
||||
>导入
|
||||
</j-upload-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
|
|
@ -55,19 +55,17 @@
|
|||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button v-auth="'base:base_point:deleteBatch'">批量操作
|
||||
<a-button v-auth="'base:base_point:deleteBatch'"
|
||||
>批量操作
|
||||
<Icon icon="mdi:chevron-down"></Icon>
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
<!-- 高级查询 -->
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
|
||||
</template>
|
||||
<template v-slot:bodyCell="{ column, record, index, text }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
<template v-slot:bodyCell="{ column, record, index, text }"></template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<PointModal ref="registerModal" @success="handleSuccess"></PointModal>
|
||||
|
|
@ -75,20 +73,23 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" name="base-point" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { ref, reactive, h } from 'vue';
|
||||
import { BasicTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns, superQuerySchema } from './Point.data';
|
||||
import { columns } from './Point.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Point.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import PointModal from './components/PointModal.vue'
|
||||
import PointModal from './components/PointModal.vue';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import {useModal} from '/@/components/Modal';
|
||||
import { getDateByPicker } from '/@/utils';
|
||||
import AreaSelect from '@/views/base/area/components/AreaSelect.vue';
|
||||
import { JInputTypeEnum } from '@/enums/cpteEnum';
|
||||
import JInput from '../../../components/Form/src/jeecg/components/JInput.vue';
|
||||
import SwitchStatus from '/@/views/base/SwitchStatus.vue';
|
||||
import { saveOrUpdate } from '@/views/base/area/Area.api';
|
||||
import JSearchSelect from "../../../components/Form/src/jeecg/components/JSearchSelect.vue";
|
||||
|
||||
const fieldPickers = reactive({
|
||||
});
|
||||
const fieldPickers = reactive({});
|
||||
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
|
|
@ -96,13 +97,39 @@
|
|||
const registerModal = ref();
|
||||
const userStore = useUserStore();
|
||||
const { createMessage } = useMessage();
|
||||
|
||||
//将是否启用转换成开关
|
||||
const enhancedColumns = columns.map((col) => {
|
||||
if (col.dataIndex === 'izActive') {
|
||||
return {
|
||||
...col,
|
||||
customRender: ({ record }) => {
|
||||
return h(SwitchStatus, {
|
||||
modelValue: record.izActive,
|
||||
recordId: record.id,
|
||||
recordName: record.pointCode,
|
||||
updateApi: saveOrUpdate,
|
||||
switchOptions: ['1', '0'],
|
||||
checkedChildren: '启用',
|
||||
unCheckedChildren: '禁用',
|
||||
buildParams: (value) => ({
|
||||
izActive: value,
|
||||
pointCode: record.pointCode,
|
||||
}),
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
return col;
|
||||
});
|
||||
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '库位',
|
||||
api: list,
|
||||
columns,
|
||||
canResize:true,
|
||||
columns: enhancedColumns,
|
||||
canResize: true,
|
||||
useSearchForm: false,
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
|
|
@ -118,40 +145,28 @@
|
|||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: "库位",
|
||||
name: '库位',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] =
|
||||
tableContext;
|
||||
const labelCol = reactive({
|
||||
xs:24,
|
||||
sm:4,
|
||||
xl:6,
|
||||
xxl:4
|
||||
xs: 24,
|
||||
sm: 4,
|
||||
xl: 6,
|
||||
xxl: 4,
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: 24,
|
||||
sm: 20,
|
||||
});
|
||||
|
||||
// 高级查询配置
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
/**
|
||||
* 高级查询事件
|
||||
*/
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).map((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
searchQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增事件
|
||||
*/
|
||||
|
|
@ -159,7 +174,7 @@
|
|||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.add();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
|
|
@ -167,7 +182,7 @@
|
|||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
|
|
@ -175,28 +190,28 @@
|
|||
registerModal.value.disableSubmit = true;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除事件
|
||||
*/
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除事件
|
||||
*/
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
|
|
@ -205,11 +220,11 @@
|
|||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
auth: 'base:base_point:edit'
|
||||
auth: 'base:base_point:edit',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 下拉操作栏
|
||||
*/
|
||||
|
|
@ -218,16 +233,17 @@
|
|||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
}, {
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
placement: 'topLeft',
|
||||
},
|
||||
auth: 'base:base_point:delete'
|
||||
}
|
||||
]
|
||||
auth: 'base:base_point:delete',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -236,7 +252,7 @@
|
|||
function searchQuery() {
|
||||
reload();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
|
|
@ -246,35 +262,35 @@
|
|||
//刷新数据
|
||||
reload();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.jeecg-basic-table-form-container {
|
||||
padding: 0;
|
||||
|
||||
.table-page-search-submitButtons {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.query-group-cust{
|
||||
|
||||
.query-group-cust {
|
||||
min-width: 100px !important;
|
||||
}
|
||||
.query-group-split-cust{
|
||||
|
||||
.query-group-split-cust {
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center
|
||||
text-align: center;
|
||||
}
|
||||
.ant-form-item:not(.ant-form-item-with-help){
|
||||
|
||||
.ant-form-item:not(.ant-form-item-with-help) {
|
||||
margin-bottom: 16px;
|
||||
height: 32px;
|
||||
}
|
||||
:deep(.ant-picker),:deep(.ant-input-number){
|
||||
|
||||
:deep(.ant-picker),
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,41 +4,48 @@
|
|||
<template #detail>
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="PointForm">
|
||||
<a-row>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="库位编码" v-bind="validateInfos.pointCode" id="PointForm-pointCode" name="pointCode">
|
||||
<a-input v-model:value="formData.pointCode" placeholder="请输入库位编码" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="排" v-bind="validateInfos.row" id="PointForm-row" name="row">
|
||||
<a-input v-model:value="formData.row" placeholder="请输入排" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="列" v-bind="validateInfos.col" id="PointForm-col" name="col">
|
||||
<a-input v-model:value="formData.col" placeholder="请输入列" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="层" v-bind="validateInfos.layer" id="PointForm-layer" name="layer">
|
||||
<a-input v-model:value="formData.layer" placeholder="请输入层" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="描述" v-bind="validateInfos.description" id="PointForm-description" name="description">
|
||||
<a-textarea v-model:value="formData.description" :rows="4" placeholder="请输入描述" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="库区ID" v-bind="validateInfos.areaId" id="PointForm-areaId" name="areaId">
|
||||
<a-input-number v-model:value="formData.areaId" placeholder="请输入库区ID" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="12">
|
||||
<a-form-item label="创建日期" v-bind="validateInfos.createTime" id="PointForm-createTime" name="createTime">
|
||||
<a-date-picker placeholder="请选择创建日期" v-model:value="formData.createTime" showTime value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="库区" v-bind="validateInfos.areaId" id="PointForm-areaId" name="areaId">
|
||||
<AreaSelect v-model:value="formData.areaId" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="编码" v-bind="validateInfos.pointCode" id="PointForm-pointCode" name="pointCode">
|
||||
<a-input v-model:value="formData.pointCode" placeholder="请输入库位编码" allow-clear></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<a-form-item label="状态" v-bind="validateInfos.status" id="PointForm-status" name="status">
|
||||
<JDictSelectTag type="select" v-model:value="formData.status" dictCode="common_status" placeholder="请选择状态" string-to-number="true" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
|
||||
<a-col :span="24">
|
||||
<a-form-item label="排" v-bind="validateInfos.row" id="PointForm-row" name="row">
|
||||
<a-input v-model:value="formData.row" placeholder="请输入排" allow-clear></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="列" v-bind="validateInfos.col" id="PointForm-col" name="col">
|
||||
<a-input v-model:value="formData.col" placeholder="请输入列" allow-clear></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="层" v-bind="validateInfos.layer" id="PointForm-layer" name="layer">
|
||||
<a-input v-model:value="formData.layer" placeholder="请输入层" allow-clear></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="描述" v-bind="validateInfos.description" id="PointForm-description" name="description">
|
||||
<a-textarea v-model:value="formData.description" :rows="4" placeholder="请输入描述" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="是否启用" v-bind="validateInfos.izActive" id="PointForm-izActive" name="izActive">
|
||||
<JSwitch v-model:value="formData.izActive" :options="['1', '0']"></JSwitch>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
|
|
@ -47,31 +54,39 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getDateByPicker, getValueType } from '/@/utils';
|
||||
import { saveOrUpdate } from '../Point.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
import AreaSelect from '@/views/base/area/components/AreaSelect.vue';
|
||||
import JDictSelectTag from '../../../../components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import JSwitch from '@/components/Form/src/jeecg/components/JSwitch.vue';
|
||||
import { getTenantId } from '@/utils/auth';
|
||||
|
||||
const props = defineProps({
|
||||
formDisabled: { type: Boolean, default: false },
|
||||
formData: { type: Object, default: () => ({})},
|
||||
formBpm: { type: Boolean, default: true }
|
||||
formData: { type: Object, default: () => ({}) },
|
||||
formBpm: { type: Boolean, default: true },
|
||||
});
|
||||
const formRef = ref();
|
||||
const useForm = Form.useForm;
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
//仓库 ID
|
||||
let tenantId = getTenantId();
|
||||
const formData = reactive<Record<string, any>>({
|
||||
id: '',
|
||||
pointCode: '',
|
||||
row: '',
|
||||
col: '',
|
||||
layer: '',
|
||||
description: '',
|
||||
delFlag: undefined,
|
||||
areaId: undefined,
|
||||
createTime: '',
|
||||
pointCode: '',
|
||||
status: 0,
|
||||
row: '00',
|
||||
col: '00',
|
||||
layer: '00',
|
||||
description: '',
|
||||
delFlag: 0,
|
||||
izActive: 1,
|
||||
tenantId: tenantId,
|
||||
});
|
||||
const { createMessage } = useMessage();
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
|
|
@ -79,29 +94,29 @@
|
|||
const confirmLoading = ref<boolean>(false);
|
||||
//表单验证
|
||||
const validatorRules = reactive({
|
||||
pointCode: [{ required: true, message: '请输入库位编码!'},],
|
||||
row: [{ required: true, message: '请输入排!'},],
|
||||
col: [{ required: true, message: '请输入列!'},],
|
||||
layer: [{ required: true, message: '请输入层!'},],
|
||||
areaId: [{ required: true, message: '请选择库区!' }],
|
||||
pointCode: [{ required: true, message: '请输入库位编码!' }],
|
||||
row: [{ required: true, message: '请输入排!' }],
|
||||
col: [{ required: true, message: '请输入列!' }],
|
||||
layer: [{ required: true, message: '请输入层!' }],
|
||||
status: [{ required: true, message: '请选择状态!' }],
|
||||
});
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||
//日期个性化选择
|
||||
const fieldPickers = reactive({
|
||||
});
|
||||
const fieldPickers = reactive({});
|
||||
|
||||
// 表单禁用
|
||||
const disabled = computed(()=>{
|
||||
if(props.formBpm === true){
|
||||
if(props.formData.disabled === false){
|
||||
const disabled = computed(() => {
|
||||
if (props.formBpm === true) {
|
||||
if (props.formData.disabled === false) {
|
||||
return false;
|
||||
}else{
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return props.formDisabled;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
|
|
@ -117,10 +132,10 @@
|
|||
resetFields();
|
||||
const tmpData = {};
|
||||
Object.keys(formData).forEach((key) => {
|
||||
if(record.hasOwnProperty(key)){
|
||||
tmpData[key] = record[key]
|
||||
if (record.hasOwnProperty(key)) {
|
||||
tmpData[key] = record[key];
|
||||
}
|
||||
})
|
||||
});
|
||||
//赋值
|
||||
Object.assign(formData, tmpData);
|
||||
});
|
||||
|
|
@ -176,7 +191,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<j-modal :title="title" maxHeight="500px" :width="896" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<j-modal :title="title" :maxHeight="500" :width="600" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<PointForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></PointForm>
|
||||
<template #footer>
|
||||
<a-button @click="handleCancel">取消</a-button>
|
||||
|
|
@ -25,25 +25,25 @@
|
|||
* 新增
|
||||
*/
|
||||
function add() {
|
||||
title.value = '新增';
|
||||
title.value = '新增库位';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.add();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param record
|
||||
*/
|
||||
function edit(record) {
|
||||
title.value = disableSubmit.value ? '详情' : '编辑';
|
||||
title.value = disableSubmit.value ? '库位详情' : '编辑库位';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.edit(record);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 确定按钮点击事件
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue