no message
parent
0284e53b77
commit
9f3b8f4af0
|
|
@ -183,6 +183,7 @@
|
||||||
//update-end---author:wangshuai ---date:20230216 for:[QQYUN-4290]公文发文:选择机关代字报错,是因为值改变触发了change事件三次,导致数据发生改变------------
|
//update-end---author:wangshuai ---date:20230216 for:[QQYUN-4290]公文发文:选择机关代字报错,是因为值改变触发了change事件三次,导致数据发生改变------------
|
||||||
|
|
||||||
// nextTick(() => formItemContext.onFieldChange());
|
// nextTick(() => formItemContext.onFieldChange());
|
||||||
|
console.log('变化', changeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 单选radio的值变化事件 */
|
/** 单选radio的值变化事件 */
|
||||||
|
|
|
||||||
|
|
@ -9,77 +9,113 @@
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
@change="onSelectChange"
|
@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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, watch } from 'vue';
|
import { computed, ref, watch } from 'vue';
|
||||||
import { propTypes } from '/@/utils/propTypes';
|
import { propTypes } from '/@/utils/propTypes';
|
||||||
import { useAttrs } from '/@/hooks/core/useAttrs';
|
import { useAttrs } from '/@/hooks/core/useAttrs';
|
||||||
import { useDesign } from '/@/hooks/web/useDesign';
|
import { useDesign } from '/@/hooks/web/useDesign';
|
||||||
import { useRuleFormItem } from '/@/hooks/component/useFormItem';
|
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']);
|
|
||||||
|
|
||||||
const checked = ref<boolean>(false);
|
const { prefixCls } = useDesign('j-switch');
|
||||||
const [state] = useRuleFormItem(props, 'value', 'change');
|
const props = defineProps({
|
||||||
watch(
|
// v-model:value
|
||||||
() => props.value,
|
value: propTypes.oneOfType([propTypes.string, propTypes.number]),
|
||||||
(val) => {
|
// 取值 options
|
||||||
if (!props.query) {
|
options: propTypes.array.def(() => ['Y', 'N']),
|
||||||
// update-begin--author:liaozhiyang---date:20231226---for:【QQYUN-7473】options使用[0,1],导致开关无法切换
|
// 文本 options
|
||||||
if (!val && !props.options.includes(val)) {
|
labelOptions: propTypes.array.def(() => ['是', '否']),
|
||||||
checked.value = false;
|
// 是否使用下拉
|
||||||
emitValue(props.options[1]);
|
query: propTypes.bool.def(false),
|
||||||
} else {
|
// 是否禁用
|
||||||
checked.value = props.options[0] == val;
|
disabled: propTypes.bool.def(false),
|
||||||
}
|
// 启用状态显示文本
|
||||||
// update-end--author:liaozhiyang---date:20231226---for:【QQYUN-7473】options使用[0,1],导致开关无法切换
|
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;
|
||||||
}
|
}
|
||||||
},
|
// update-end--author:liaozhiyang---date:20231226---for:【QQYUN-7473】options使用[0,1],导致开关无法切换
|
||||||
{ immediate: true }
|
}
|
||||||
);
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
const selectOptions = computed(() => {
|
const selectOptions = computed(() => {
|
||||||
let options: any[] = [];
|
let options: any[] = [];
|
||||||
options.push({ value: props.options[0], label: props.labelOptions[0] });
|
options.push({ value: props.options[0], label: props.labelOptions[0] });
|
||||||
options.push({ value: props.options[1], label: props.labelOptions[1] });
|
options.push({ value: props.options[1], label: props.labelOptions[1] });
|
||||||
return options;
|
return options;
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSwitchChange(checked) {
|
function onSwitchChange(checked) {
|
||||||
let flag = checked === false ? props.options[1] : props.options[0];
|
let flag = checked === false ? props.options[1] : props.options[0];
|
||||||
emitValue(flag);
|
emitValue(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelectChange(value) {
|
function onSelectChange(value) {
|
||||||
emitValue(value);
|
emitValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function emitValue(value) {
|
function emitValue(value) {
|
||||||
emit('change', value);
|
emit('change', value);
|
||||||
emit('update:value', value);
|
emit('update:value', value);
|
||||||
}
|
console.log('数据:', value);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less">
|
||||||
//noinspection LessUnresolvedVariable
|
//noinspection LessUnresolvedVariable
|
||||||
@prefix-cls: ~'@{namespace}-j-switch';
|
@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>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ const installOptions = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 注册模块 */
|
/** 注册模块 */
|
||||||
function use(app: App, pkg) {
|
function use(app: App, pkg: any) {
|
||||||
app.use(pkg, installOptions);
|
app.use(pkg, installOptions);
|
||||||
registerDynamicRouter(pkg.getViews);
|
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 { defHttp } from '/@/utils/http/axios';
|
||||||
import { useMessage } from "/@/hooks/web/useMessage";
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
|
||||||
const { createConfirm } = useMessage();
|
const { createConfirm } = useMessage();
|
||||||
|
|
||||||
enum Api {
|
enum Api {
|
||||||
list = '/base/area/list',
|
list = '/base/area/list',
|
||||||
save='/base/area/add',
|
save = '/base/area/add',
|
||||||
edit='/base/area/edit',
|
edit = '/base/area/edit',
|
||||||
deleteOne = '/base/area/delete',
|
deleteOne = '/base/area/delete',
|
||||||
deleteBatch = '/base/area/deleteBatch',
|
deleteBatch = '/base/area/deleteBatch',
|
||||||
importExcel = '/base/area/importExcel',
|
importExcel = '/base/area/importExcel',
|
||||||
|
|
@ -35,11 +35,11 @@ export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||||
* @param params
|
* @param params
|
||||||
* @param handleSuccess
|
* @param handleSuccess
|
||||||
*/
|
*/
|
||||||
export const deleteOne = (params,handleSuccess) => {
|
export const deleteOne = (params, handleSuccess) => {
|
||||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
|
||||||
handleSuccess();
|
handleSuccess();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
|
|
@ -54,12 +54,20 @@ export const batchDelete = (params, handleSuccess) => {
|
||||||
okText: '确认',
|
okText: '确认',
|
||||||
cancelText: '取消',
|
cancelText: '取消',
|
||||||
onOk: () => {
|
onOk: () => {
|
||||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
return defHttp
|
||||||
handleSuccess();
|
.delete(
|
||||||
});
|
{
|
||||||
}
|
url: Api.deleteBatch,
|
||||||
|
data: params,
|
||||||
|
},
|
||||||
|
{ joinParamsToUrl: true }
|
||||||
|
)
|
||||||
|
.then(() => {
|
||||||
|
handleSuccess();
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存或者更新
|
* 保存或者更新
|
||||||
|
|
@ -67,6 +75,7 @@ export const batchDelete = (params, handleSuccess) => {
|
||||||
* @param isUpdate
|
* @param isUpdate
|
||||||
*/
|
*/
|
||||||
export const saveOrUpdate = (params, 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 });
|
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[] = [
|
export const columns: BasicColumn[] = [
|
||||||
{
|
{
|
||||||
title: '库区编码',
|
title: '库区编码',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'areaCode'
|
dataIndex: 'areaCode',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '库区名称',
|
title: '库区名称',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'areaName'
|
dataIndex: 'areaName',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '是否启用',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'izActive',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '描述',
|
title: '描述',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'description',
|
dataIndex: 'description',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '创建时间',
|
title: '创建时间',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'createTime',
|
dataIndex: 'createTime',
|
||||||
|
sorter: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,24 +4,26 @@
|
||||||
<div class="jeecg-basic-table-form-container">
|
<div class="jeecg-basic-table-form-container">
|
||||||
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||||
<a-row :gutter="24">
|
<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-col :lg="6">
|
||||||
<a-form-item name="areaName">
|
<a-form-item name="areaName">
|
||||||
<template #label><span title="库区名称">库区名称</span></template>
|
<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-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :lg="6">
|
<a-col :lg="6">
|
||||||
<a-form-item name="createTime">
|
<a-form-item name="izActive">
|
||||||
<template #label><span title="创建日期">创建日期</span></template>
|
<template #label><span title="是否启用">是否启用</span></template>
|
||||||
<JRangeDate v-model:value="queryParam.createTime" />
|
<JSearchSelect dict="dict_item_status" v-model:value="queryParam.izActive" placeholder="请选择" allow-clear />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</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">
|
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||||
<a-col :lg="6">
|
<a-col :lg="6">
|
||||||
|
|
@ -78,18 +80,20 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" name="base-area" setup>
|
<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 { BasicTable, TableAction } from '/@/components/Table';
|
||||||
import { useListPage } from '/@/hooks/system/useListPage';
|
import { useListPage } from '/@/hooks/system/useListPage';
|
||||||
import { columns } from './Area.data';
|
import { columns } from './Area.data';
|
||||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Area.api';
|
import { list, deleteOne, batchDelete, saveOrUpdate, getImportUrl, getExportUrl } from './Area.api';
|
||||||
import AreaModal from './components/AreaModal.vue';
|
|
||||||
import { useUserStore } from '/@/store/modules/user';
|
import { useUserStore } from '/@/store/modules/user';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
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 { getDateByPicker } from '/@/utils';
|
||||||
import { JInputTypeEnum } from '@/enums/cpteEnum';
|
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 fieldPickers = reactive({});
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
|
|
@ -98,12 +102,37 @@
|
||||||
const registerModal = ref();
|
const registerModal = ref();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const { createMessage } = useMessage();
|
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数据
|
//注册table数据
|
||||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
tableProps: {
|
tableProps: {
|
||||||
title: '库区',
|
title: '库区',
|
||||||
api: list,
|
api: list,
|
||||||
columns,
|
columns: enhancedColumns, // 使用增强后的列,
|
||||||
canResize: true,
|
canResize: true,
|
||||||
useSearchForm: false,
|
useSearchForm: false,
|
||||||
actionColumn: {
|
actionColumn: {
|
||||||
|
|
@ -203,6 +232,13 @@
|
||||||
(selectedRowKeys.value = []) && reload();
|
(selectedRowKeys.value = []) && reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否启用状态取消回调
|
||||||
|
*/
|
||||||
|
function handleCancel(record, originalValue) {
|
||||||
|
record.izActive = originalValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 操作栏
|
* 操作栏
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
<a-spin :spinning="confirmLoading">
|
<a-spin :spinning="confirmLoading">
|
||||||
<JFormContainer :disabled="disabled">
|
<JFormContainer :disabled="disabled">
|
||||||
<template #detail>
|
<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-row>
|
||||||
<a-col :span="24">
|
<a-col :span="24">
|
||||||
<a-form-item label="库区编码" v-bind="validateInfos.areaCode" id="AreaForm-areaCode" name="areaCode">
|
<a-form-item label="库区编码" v-bind="validateInfos.areaCode" id="AreaForm-areaCode" name="areaCode">
|
||||||
|
|
@ -15,10 +15,15 @@
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="24">
|
<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-textarea v-model:value="formData.description" :rows="4" placeholder="请输入描述" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</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-row>
|
||||||
</a-form>
|
</a-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -29,10 +34,12 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed } from 'vue';
|
import { ref, reactive, defineExpose, nextTick, defineProps, computed } from 'vue';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { getDateByPicker, getValueType } from '/@/utils';
|
import { getValueType } from '/@/utils';
|
||||||
import { saveOrUpdate } from '../Area.api';
|
import { saveOrUpdate } from '../Area.api';
|
||||||
import { Form } from 'ant-design-vue';
|
import { Form } from 'ant-design-vue';
|
||||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.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({
|
const props = defineProps({
|
||||||
formDisabled: { type: Boolean, default: false },
|
formDisabled: { type: Boolean, default: false },
|
||||||
|
|
@ -42,12 +49,16 @@
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const useForm = Form.useForm;
|
const useForm = Form.useForm;
|
||||||
const emit = defineEmits(['register', 'ok']);
|
const emit = defineEmits(['register', 'ok']);
|
||||||
|
//仓库 ID
|
||||||
|
let tenantId = getTenantId();
|
||||||
const formData = reactive<Record<string, any>>({
|
const formData = reactive<Record<string, any>>({
|
||||||
id: '',
|
id: '',
|
||||||
areaCode: '',
|
areaCode: '',
|
||||||
areaName: '',
|
areaName: '',
|
||||||
description: '',
|
description: '',
|
||||||
delFlag: 0,
|
delFlag: 0,
|
||||||
|
izActive: 1,
|
||||||
|
tenantId: tenantId,
|
||||||
});
|
});
|
||||||
const { createMessage } = useMessage();
|
const { createMessage } = useMessage();
|
||||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||||
|
|
@ -58,11 +69,8 @@
|
||||||
areaCode: [{ required: true, message: '请输入库区编码!' }],
|
areaCode: [{ required: true, message: '请输入库区编码!' }],
|
||||||
areaName: [{ required: true, message: '请输入库区名称!' }],
|
areaName: [{ required: true, message: '请输入库区名称!' }],
|
||||||
delFlag: [{ required: true, message: '请输入删除状态!' }],
|
delFlag: [{ required: true, message: '请输入删除状态!' }],
|
||||||
createTime: [{ required: true, message: '请输入创建日期!' }],
|
|
||||||
});
|
});
|
||||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||||
//日期个性化选择
|
|
||||||
const fieldPickers = reactive({});
|
|
||||||
|
|
||||||
// 表单禁用
|
// 表单禁用
|
||||||
const disabled = computed(() => {
|
const disabled = computed(() => {
|
||||||
|
|
@ -125,8 +133,6 @@
|
||||||
}
|
}
|
||||||
//循环数据
|
//循环数据
|
||||||
for (let data in model) {
|
for (let data in model) {
|
||||||
// 更新个性化日期选择器的值
|
|
||||||
model[data] = getDateByPicker(model[data], fieldPickers[data]);
|
|
||||||
//如果该数据是数组并且是字符串类型
|
//如果该数据是数组并且是字符串类型
|
||||||
if (model[data] instanceof Array) {
|
if (model[data] instanceof Array) {
|
||||||
let valueType = getValueType(formRef.value.getProps, data);
|
let valueType = getValueType(formRef.value.getProps, data);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<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>
|
<AreaForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></AreaForm>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<a-button @click="handleCancel">取消</a-button>
|
<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 { BasicColumn } from '/@/components/Table';
|
||||||
import {FormSchema} from '/@/components/Table';
|
import { render } from '@/utils/common/renderUtils';
|
||||||
import { rules} from '/@/utils/helper/validator';
|
|
||||||
import { render } from '/@/utils/common/renderUtils';
|
|
||||||
import { getWeekMonthQuarterYear } from '/@/utils';
|
|
||||||
//列表数据
|
//列表数据
|
||||||
export const columns: BasicColumn[] = [
|
export const columns: BasicColumn[] = [
|
||||||
|
{
|
||||||
|
title: '库区',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'areaId_dictText',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: '库位编码',
|
title: '库位编码',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'pointCode'
|
dataIndex: 'pointCode',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '状态',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'status_dictText',
|
||||||
|
customRender: ({ text }) => {
|
||||||
|
const color = text == '占用' ? 'red' : text == '空闲' ? 'green' : 'gray';
|
||||||
|
return render.renderTag(text, color);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '排',
|
title: '排',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'row'
|
dataIndex: 'row',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '列',
|
title: '列',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'col'
|
dataIndex: 'col',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '层',
|
title: '层',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'layer'
|
dataIndex: 'layer',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '是否启用',
|
||||||
|
align: 'center',
|
||||||
|
dataIndex: 'izActive',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '描述',
|
title: '描述',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'description'
|
dataIndex: 'description',
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '库区ID',
|
|
||||||
align: "center",
|
|
||||||
dataIndex: 'areaId'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: '创建日期',
|
title: '创建日期',
|
||||||
align: "center",
|
align: 'center',
|
||||||
dataIndex: 'createTime'
|
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-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||||
<a-row :gutter="24">
|
<a-row :gutter="24">
|
||||||
<a-col :lg="6">
|
<a-col :lg="6">
|
||||||
<a-form-item name="pointCode">
|
<a-form-item name="areaId">
|
||||||
<template #label><span title="库位编码">库位编码</span></template>
|
<template #label><span title="库区">库区</span></template>
|
||||||
<a-input placeholder="请输入库位编码" v-model:value="queryParam.pointCode" allow-clear ></a-input>
|
<AreaSelect v-model:value="queryParam.areaId" :area="queryParam" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :lg="6">
|
<a-col :lg="6">
|
||||||
<a-form-item name="areaId">
|
<a-form-item name="pointCode">
|
||||||
<template #label><span title="库区ID">库区ID</span></template>
|
<template #label><span title="库位编码">库位编码</span></template>
|
||||||
<a-input-number placeholder="请输入库区ID" v-model:value="queryParam.areaId"></a-input-number>
|
<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-form-item>
|
||||||
</a-col>
|
</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">
|
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||||
<a-col :lg="6">
|
<a-col :lg="6">
|
||||||
|
|
@ -43,9 +41,11 @@
|
||||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||||
<!--插槽:table标题-->
|
<!--插槽:table标题-->
|
||||||
<template #tableTitle>
|
<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: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>
|
<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>
|
<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">
|
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||||
<template #overlay>
|
<template #overlay>
|
||||||
<a-menu>
|
<a-menu>
|
||||||
|
|
@ -55,19 +55,17 @@
|
||||||
</a-menu-item>
|
</a-menu-item>
|
||||||
</a-menu>
|
</a-menu>
|
||||||
</template>
|
</template>
|
||||||
<a-button v-auth="'base:base_point:deleteBatch'">批量操作
|
<a-button v-auth="'base:base_point:deleteBatch'"
|
||||||
|
>批量操作
|
||||||
<Icon icon="mdi:chevron-down"></Icon>
|
<Icon icon="mdi:chevron-down"></Icon>
|
||||||
</a-button>
|
</a-button>
|
||||||
</a-dropdown>
|
</a-dropdown>
|
||||||
<!-- 高级查询 -->
|
|
||||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
|
||||||
</template>
|
</template>
|
||||||
<!--操作栏-->
|
<!--操作栏-->
|
||||||
<template #action="{ record }">
|
<template #action="{ record }">
|
||||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
|
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||||
</template>
|
|
||||||
<template v-slot:bodyCell="{ column, record, index, text }">
|
|
||||||
</template>
|
</template>
|
||||||
|
<template v-slot:bodyCell="{ column, record, index, text }"></template>
|
||||||
</BasicTable>
|
</BasicTable>
|
||||||
<!-- 表单区域 -->
|
<!-- 表单区域 -->
|
||||||
<PointModal ref="registerModal" @success="handleSuccess"></PointModal>
|
<PointModal ref="registerModal" @success="handleSuccess"></PointModal>
|
||||||
|
|
@ -75,20 +73,23 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" name="base-point" setup>
|
<script lang="ts" name="base-point" setup>
|
||||||
import { ref, reactive } from 'vue';
|
import { ref, reactive, h } from 'vue';
|
||||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
import { BasicTable, TableAction } from '/@/components/Table';
|
||||||
import { useListPage } from '/@/hooks/system/useListPage';
|
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 { 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 { useUserStore } from '/@/store/modules/user';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import {useModal} from '/@/components/Modal';
|
|
||||||
import { getDateByPicker } from '/@/utils';
|
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 formRef = ref();
|
||||||
const queryParam = reactive<any>({});
|
const queryParam = reactive<any>({});
|
||||||
|
|
@ -96,13 +97,39 @@
|
||||||
const registerModal = ref();
|
const registerModal = ref();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const { createMessage } = useMessage();
|
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数据
|
//注册table数据
|
||||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||||
tableProps: {
|
tableProps: {
|
||||||
title: '库位',
|
title: '库位',
|
||||||
api: list,
|
api: list,
|
||||||
columns,
|
columns: enhancedColumns,
|
||||||
canResize:true,
|
canResize: true,
|
||||||
useSearchForm: false,
|
useSearchForm: false,
|
||||||
actionColumn: {
|
actionColumn: {
|
||||||
width: 120,
|
width: 120,
|
||||||
|
|
@ -118,40 +145,28 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
exportConfig: {
|
exportConfig: {
|
||||||
name: "库位",
|
name: '库位',
|
||||||
url: getExportUrl,
|
url: getExportUrl,
|
||||||
params: queryParam,
|
params: queryParam,
|
||||||
},
|
},
|
||||||
importConfig: {
|
importConfig: {
|
||||||
url: getImportUrl,
|
url: getImportUrl,
|
||||||
success: handleSuccess
|
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({
|
const labelCol = reactive({
|
||||||
xs:24,
|
xs: 24,
|
||||||
sm:4,
|
sm: 4,
|
||||||
xl:6,
|
xl: 6,
|
||||||
xxl:4
|
xxl: 4,
|
||||||
});
|
});
|
||||||
const wrapperCol = reactive({
|
const wrapperCol = reactive({
|
||||||
xs: 24,
|
xs: 24,
|
||||||
sm: 20,
|
sm: 20,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 高级查询配置
|
|
||||||
const superQueryConfig = reactive(superQuerySchema);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级查询事件
|
|
||||||
*/
|
|
||||||
function handleSuperQuery(params) {
|
|
||||||
Object.keys(params).map((k) => {
|
|
||||||
queryParam[k] = params[k];
|
|
||||||
});
|
|
||||||
searchQuery();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增事件
|
* 新增事件
|
||||||
*/
|
*/
|
||||||
|
|
@ -205,7 +220,7 @@
|
||||||
{
|
{
|
||||||
label: '编辑',
|
label: '编辑',
|
||||||
onClick: handleEdit.bind(null, record),
|
onClick: handleEdit.bind(null, record),
|
||||||
auth: 'base:base_point:edit'
|
auth: 'base:base_point:edit',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
@ -218,16 +233,17 @@
|
||||||
{
|
{
|
||||||
label: '详情',
|
label: '详情',
|
||||||
onClick: handleDetail.bind(null, record),
|
onClick: handleDetail.bind(null, record),
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
label: '删除',
|
label: '删除',
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: '是否确认删除',
|
title: '是否确认删除',
|
||||||
confirm: handleDelete.bind(null, record),
|
confirm: handleDelete.bind(null, record),
|
||||||
placement: 'topLeft',
|
placement: 'topLeft',
|
||||||
},
|
},
|
||||||
auth: 'base:base_point:delete'
|
auth: 'base:base_point:delete',
|
||||||
}
|
},
|
||||||
]
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -246,35 +262,35 @@
|
||||||
//刷新数据
|
//刷新数据
|
||||||
reload();
|
reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less" scoped>
|
<style lang="less" scoped>
|
||||||
.jeecg-basic-table-form-container {
|
.jeecg-basic-table-form-container {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
||||||
.table-page-search-submitButtons {
|
.table-page-search-submitButtons {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 24px;
|
margin-bottom: 24px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
.query-group-cust{
|
|
||||||
|
.query-group-cust {
|
||||||
min-width: 100px !important;
|
min-width: 100px !important;
|
||||||
}
|
}
|
||||||
.query-group-split-cust{
|
|
||||||
|
.query-group-split-cust {
|
||||||
width: 30px;
|
width: 30px;
|
||||||
display: inline-block;
|
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;
|
margin-bottom: 16px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
:deep(.ant-picker),:deep(.ant-input-number){
|
|
||||||
|
:deep(.ant-picker),
|
||||||
|
:deep(.ant-input-number) {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,41 +4,48 @@
|
||||||
<template #detail>
|
<template #detail>
|
||||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="PointForm">
|
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="PointForm">
|
||||||
<a-row>
|
<a-row>
|
||||||
<a-col :span="12">
|
<a-col :span="24">
|
||||||
<a-form-item label="库位编码" v-bind="validateInfos.pointCode" id="PointForm-pointCode" name="pointCode">
|
<a-form-item label="库区" v-bind="validateInfos.areaId" id="PointForm-areaId" name="areaId">
|
||||||
<a-input v-model:value="formData.pointCode" placeholder="请输入库位编码" allow-clear ></a-input>
|
<AreaSelect v-model:value="formData.areaId" />
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
<a-col :span="24">
|
||||||
<a-form-item label="排" v-bind="validateInfos.row" id="PointForm-row" name="row">
|
<a-form-item label="编码" v-bind="validateInfos.pointCode" id="PointForm-pointCode" name="pointCode">
|
||||||
<a-input v-model:value="formData.row" placeholder="请输入排" allow-clear ></a-input>
|
<a-input v-model:value="formData.pointCode" placeholder="请输入库位编码" allow-clear></a-input>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-col>
|
</a-col>
|
||||||
<a-col :span="12">
|
|
||||||
<a-form-item label="列" v-bind="validateInfos.col" id="PointForm-col" name="col">
|
<a-col :span="24">
|
||||||
<a-input v-model:value="formData.col" placeholder="请输入列" allow-clear ></a-input>
|
<a-form-item label="状态" v-bind="validateInfos.status" id="PointForm-status" name="status">
|
||||||
</a-form-item>
|
<JDictSelectTag type="select" v-model:value="formData.status" dictCode="common_status" placeholder="请选择状态" string-to-number="true" />
|
||||||
</a-col>
|
</a-form-item>
|
||||||
<a-col :span="12">
|
</a-col>
|
||||||
<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-col :span="24">
|
||||||
</a-form-item>
|
<a-form-item label="排" v-bind="validateInfos.row" id="PointForm-row" name="row">
|
||||||
</a-col>
|
<a-input v-model:value="formData.row" placeholder="请输入排" allow-clear></a-input>
|
||||||
<a-col :span="12">
|
</a-form-item>
|
||||||
<a-form-item label="描述" v-bind="validateInfos.description" id="PointForm-description" name="description">
|
</a-col>
|
||||||
<a-textarea v-model:value="formData.description" :rows="4" placeholder="请输入描述" />
|
<a-col :span="24">
|
||||||
</a-form-item>
|
<a-form-item label="列" v-bind="validateInfos.col" id="PointForm-col" name="col">
|
||||||
</a-col>
|
<a-input v-model:value="formData.col" placeholder="请输入列" allow-clear></a-input>
|
||||||
<a-col :span="12">
|
</a-form-item>
|
||||||
<a-form-item label="库区ID" v-bind="validateInfos.areaId" id="PointForm-areaId" name="areaId">
|
</a-col>
|
||||||
<a-input-number v-model:value="formData.areaId" placeholder="请输入库区ID" style="width: 100%" />
|
<a-col :span="24">
|
||||||
</a-form-item>
|
<a-form-item label="层" v-bind="validateInfos.layer" id="PointForm-layer" name="layer">
|
||||||
</a-col>
|
<a-input v-model:value="formData.layer" placeholder="请输入层" allow-clear></a-input>
|
||||||
<a-col :span="12">
|
</a-form-item>
|
||||||
<a-form-item label="创建日期" v-bind="validateInfos.createTime" id="PointForm-createTime" name="createTime">
|
</a-col>
|
||||||
<a-date-picker placeholder="请选择创建日期" v-model:value="formData.createTime" showTime value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" allow-clear />
|
<a-col :span="24">
|
||||||
</a-form-item>
|
<a-form-item label="描述" v-bind="validateInfos.description" id="PointForm-description" name="description">
|
||||||
</a-col>
|
<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-row>
|
||||||
</a-form>
|
</a-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -47,31 +54,39 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted } from 'vue';
|
import { ref, reactive, defineExpose, nextTick, defineProps, computed } from 'vue';
|
||||||
import { defHttp } from '/@/utils/http/axios';
|
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
import { getDateByPicker, getValueType } from '/@/utils';
|
import { getDateByPicker, getValueType } from '/@/utils';
|
||||||
import { saveOrUpdate } from '../Point.api';
|
import { saveOrUpdate } from '../Point.api';
|
||||||
import { Form } from 'ant-design-vue';
|
import { Form } from 'ant-design-vue';
|
||||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.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({
|
const props = defineProps({
|
||||||
formDisabled: { type: Boolean, default: false },
|
formDisabled: { type: Boolean, default: false },
|
||||||
formData: { type: Object, default: () => ({})},
|
formData: { type: Object, default: () => ({}) },
|
||||||
formBpm: { type: Boolean, default: true }
|
formBpm: { type: Boolean, default: true },
|
||||||
});
|
});
|
||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const useForm = Form.useForm;
|
const useForm = Form.useForm;
|
||||||
const emit = defineEmits(['register', 'ok']);
|
const emit = defineEmits(['register', 'ok']);
|
||||||
|
//仓库 ID
|
||||||
|
let tenantId = getTenantId();
|
||||||
const formData = reactive<Record<string, any>>({
|
const formData = reactive<Record<string, any>>({
|
||||||
id: '',
|
id: '',
|
||||||
pointCode: '',
|
|
||||||
row: '',
|
|
||||||
col: '',
|
|
||||||
layer: '',
|
|
||||||
description: '',
|
|
||||||
delFlag: undefined,
|
|
||||||
areaId: undefined,
|
areaId: undefined,
|
||||||
createTime: '',
|
pointCode: '',
|
||||||
|
status: 0,
|
||||||
|
row: '00',
|
||||||
|
col: '00',
|
||||||
|
layer: '00',
|
||||||
|
description: '',
|
||||||
|
delFlag: 0,
|
||||||
|
izActive: 1,
|
||||||
|
tenantId: tenantId,
|
||||||
});
|
});
|
||||||
const { createMessage } = useMessage();
|
const { createMessage } = useMessage();
|
||||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||||
|
|
@ -79,29 +94,29 @@
|
||||||
const confirmLoading = ref<boolean>(false);
|
const confirmLoading = ref<boolean>(false);
|
||||||
//表单验证
|
//表单验证
|
||||||
const validatorRules = reactive({
|
const validatorRules = reactive({
|
||||||
pointCode: [{ required: true, message: '请输入库位编码!'},],
|
areaId: [{ required: true, message: '请选择库区!' }],
|
||||||
row: [{ required: true, message: '请输入排!'},],
|
pointCode: [{ required: true, message: '请输入库位编码!' }],
|
||||||
col: [{ required: true, message: '请输入列!'},],
|
row: [{ required: true, message: '请输入排!' }],
|
||||||
layer: [{ 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 { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||||
//日期个性化选择
|
//日期个性化选择
|
||||||
const fieldPickers = reactive({
|
const fieldPickers = reactive({});
|
||||||
});
|
|
||||||
|
|
||||||
// 表单禁用
|
// 表单禁用
|
||||||
const disabled = computed(()=>{
|
const disabled = computed(() => {
|
||||||
if(props.formBpm === true){
|
if (props.formBpm === true) {
|
||||||
if(props.formData.disabled === false){
|
if (props.formData.disabled === false) {
|
||||||
return false;
|
return false;
|
||||||
}else{
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return props.formDisabled;
|
return props.formDisabled;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增
|
* 新增
|
||||||
*/
|
*/
|
||||||
|
|
@ -117,10 +132,10 @@
|
||||||
resetFields();
|
resetFields();
|
||||||
const tmpData = {};
|
const tmpData = {};
|
||||||
Object.keys(formData).forEach((key) => {
|
Object.keys(formData).forEach((key) => {
|
||||||
if(record.hasOwnProperty(key)){
|
if (record.hasOwnProperty(key)) {
|
||||||
tmpData[key] = record[key]
|
tmpData[key] = record[key];
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
//赋值
|
//赋值
|
||||||
Object.assign(formData, tmpData);
|
Object.assign(formData, tmpData);
|
||||||
});
|
});
|
||||||
|
|
@ -176,7 +191,6 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
add,
|
add,
|
||||||
edit,
|
edit,
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<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>
|
<PointForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></PointForm>
|
||||||
<template #footer>
|
<template #footer>
|
||||||
<a-button @click="handleCancel">取消</a-button>
|
<a-button @click="handleCancel">取消</a-button>
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
* 新增
|
* 新增
|
||||||
*/
|
*/
|
||||||
function add() {
|
function add() {
|
||||||
title.value = '新增';
|
title.value = '新增库位';
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
registerForm.value.add();
|
registerForm.value.add();
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
* @param record
|
* @param record
|
||||||
*/
|
*/
|
||||||
function edit(record) {
|
function edit(record) {
|
||||||
title.value = disableSubmit.value ? '详情' : '编辑';
|
title.value = disableSubmit.value ? '库位详情' : '编辑库位';
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
registerForm.value.edit(record);
|
registerForm.value.edit(record);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue