修复已知问题
This commit is contained in:
215
src/views/baocan/notice/components/bc-equipment-edit.vue
Normal file
215
src/views/baocan/notice/components/bc-equipment-edit.vue
Normal file
@@ -0,0 +1,215 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<a-drawer
|
||||
:width="880"
|
||||
:visible="visible"
|
||||
:confirm-loading="loading"
|
||||
:title="isUpdate ? '编辑设备' : '添加设备'"
|
||||
:body-style="{ paddingBottom: '8px' }"
|
||||
:footer-style="{ textAlign: 'right' }"
|
||||
@update:visible="updateVisible"
|
||||
:maskClosable="isUpdate"
|
||||
@ok="save"
|
||||
>
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="设备编码" name="equipmentCode">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入设备编码"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.equipmentCode"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="所属档口" name="gear">
|
||||
<a-radio-group v-model:value="form.gear">
|
||||
<a-radio :value="10">食堂档口</a-radio>
|
||||
<a-radio :value="20">物品档口</a-radio>
|
||||
</a-radio-group>
|
||||
</a-form-item>
|
||||
<a-form-item label="设备描述" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入描述内容"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="启用状态" name="status">-->
|
||||
<!-- <a-switch :checked="form.status === 0" @change="editStatus" />-->
|
||||
<!-- </a-form-item>-->
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-space>
|
||||
<a-button @click="onClose">取消</a-button>
|
||||
<a-button type="primary" @click="save">保存</a-button>
|
||||
</a-space>
|
||||
</template>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { BcEquipment } from '@/api/apps/bc/equipment/model';
|
||||
import { addBcEquipment, updateBcEquipment } from '@/api/apps/bc/equipment';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: BcEquipment | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<BcEquipment>({
|
||||
bcEquipmentId: undefined,
|
||||
equipmentName: undefined,
|
||||
equipmentCode: '',
|
||||
gear: 10,
|
||||
createTime: '',
|
||||
comments: '',
|
||||
sortNumber: 100,
|
||||
status: 0
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
equipmentName: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
equipmentCode: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写设备编号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateBcEquipment(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const equipmentForm = {
|
||||
...form
|
||||
};
|
||||
console.log(equipmentForm, 'equipmentForm');
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateBcEquipment
|
||||
: addBcEquipment;
|
||||
saveOrUpdate(equipmentForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
107
src/views/baocan/notice/components/search.vue
Normal file
107
src/views/baocan/notice/components/search.vue
Normal file
@@ -0,0 +1,107 @@
|
||||
<!-- 搜索表单 -->
|
||||
<template>
|
||||
<a-space>
|
||||
<a-button type="primary" class="ele-btn-icon" @click="add">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
<span>绑定设备</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
danger
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
:v-role="`dev`"
|
||||
@click="removeBatch"
|
||||
:disabled="props.selection.length === 0"
|
||||
>
|
||||
<template #icon>
|
||||
<DeleteOutlined />
|
||||
</template>
|
||||
<span>批量删除</span>
|
||||
</a-button>
|
||||
<!-- <a-input-search-->
|
||||
<!-- allow-clear-->
|
||||
<!-- v-model:value="searchText"-->
|
||||
<!-- placeholder="请输入搜索关键词"-->
|
||||
<!-- @search="search"-->
|
||||
<!-- @pressEnter="search"-->
|
||||
<!-- />-->
|
||||
</a-space>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {
|
||||
PlusOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined
|
||||
} from '@ant-design/icons-vue';
|
||||
import useSearch from '@/utils/use-search';
|
||||
import type { EquipmentParam } from '@/api/apps/equipment/model';
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'search', where?: EquipmentParam): void;
|
||||
(e: 'add'): void;
|
||||
(e: 'remove'): void;
|
||||
}>();
|
||||
|
||||
const props = defineProps<{
|
||||
// 勾选的项目
|
||||
selection?: [];
|
||||
}>();
|
||||
|
||||
// 表单数据
|
||||
const { where } = useSearch<EquipmentParam>({
|
||||
equipmentId: undefined,
|
||||
equipmentName: '',
|
||||
equipmentCode: '',
|
||||
merchantCode: ''
|
||||
});
|
||||
|
||||
// 下来选项
|
||||
const type = ref('equipmentCode');
|
||||
// tabType
|
||||
// const listType = ref('all');
|
||||
// 搜索内容
|
||||
const searchText = ref('');
|
||||
|
||||
/* 搜索 */
|
||||
const search = () => {
|
||||
where.equipmentName = undefined;
|
||||
where.equipmentCode = undefined;
|
||||
where.merchantCode = undefined;
|
||||
if (type.value == 'equipmentName') {
|
||||
where.equipmentName = searchText.value;
|
||||
}
|
||||
if (type.value == 'equipmentCode') {
|
||||
where.equipmentCode = searchText.value;
|
||||
}
|
||||
if (type.value == 'merchantCode') {
|
||||
where.merchantCode = searchText.value;
|
||||
}
|
||||
emit('search', where);
|
||||
};
|
||||
|
||||
// 新增
|
||||
const add = () => {
|
||||
emit('add');
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const removeBatch = () => {
|
||||
emit('remove');
|
||||
};
|
||||
|
||||
/* 重置 */
|
||||
// const reset = () => {
|
||||
// resetFields();
|
||||
// search();
|
||||
// };
|
||||
|
||||
// 监听字典id变化
|
||||
watch(
|
||||
() => props.selection,
|
||||
() => {}
|
||||
);
|
||||
</script>
|
||||
231
src/views/baocan/notice/index.vue
Normal file
231
src/views/baocan/notice/index.vue
Normal file
@@ -0,0 +1,231 @@
|
||||
<!-- 用户编辑弹窗 -->
|
||||
<template>
|
||||
<div class="page">
|
||||
<div class="ele-body">
|
||||
<a-card :bordered="false">
|
||||
<a-form
|
||||
ref="formRef"
|
||||
:label-col="{ md: { span: 8 }, sm: { span: 24 } }"
|
||||
:wrapper-col="{ md: { span: 24 }, sm: { span: 24 } }"
|
||||
layout="vertical"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
>
|
||||
<a-form-item label="标题" name="title">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入标题"
|
||||
:disabled="isUpdate"
|
||||
v-model:value="form.title"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="发送范围" name="channel">
|
||||
<a-input
|
||||
allow-clear
|
||||
placeholder="请输入用户名"
|
||||
v-model:value="form.channel"
|
||||
/>
|
||||
</a-form-item>
|
||||
<a-form-item label="内容" name="comments">
|
||||
<a-textarea
|
||||
:rows="4"
|
||||
:maxlength="200"
|
||||
placeholder="请输入内容"
|
||||
v-model:value="form.comments"
|
||||
/>
|
||||
<a-space>
|
||||
<a-button
|
||||
type="primary"
|
||||
class="ele-btn-icon"
|
||||
style="margin-top: 10px"
|
||||
@click="save"
|
||||
>
|
||||
<span>保存</span>
|
||||
</a-button>
|
||||
<a-button
|
||||
class="ele-btn-icon"
|
||||
style="margin-top: 10px"
|
||||
@click="send"
|
||||
>
|
||||
<span>发送</span>
|
||||
</a-button>
|
||||
</a-space>
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
</a-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, watch } from 'vue';
|
||||
import { message } from 'ant-design-vue';
|
||||
import type { BcEquipment } from '@/api/apps/bc/equipment/model';
|
||||
import {
|
||||
addBcEquipment,
|
||||
updateBcEquipment,
|
||||
addSend
|
||||
} from '@/api/apps/bc/equipment';
|
||||
import { FormInstance, Rule } from 'ant-design-vue/es/form';
|
||||
import useFormData from '@/utils/use-form-data';
|
||||
import { Notice } from '@/api/oa/notice/model';
|
||||
|
||||
const props = defineProps<{
|
||||
// 弹窗是否打开
|
||||
visible: boolean;
|
||||
// 修改回显的数据
|
||||
data?: BcEquipment | null;
|
||||
}>();
|
||||
const emit = defineEmits<{
|
||||
(e: 'done'): void;
|
||||
(e: 'update:visible', visible: boolean): void;
|
||||
}>();
|
||||
|
||||
// 是否是修改
|
||||
const isUpdate = ref(false);
|
||||
|
||||
// 提交状态
|
||||
const loading = ref(false);
|
||||
|
||||
const formRef = ref<FormInstance | null>(null);
|
||||
|
||||
/* 更新visible */
|
||||
const updateVisible = (value: boolean) => {
|
||||
emit('update:visible', value);
|
||||
};
|
||||
|
||||
// 表单数据
|
||||
const { form, resetFields, assignFields } = useFormData<Notice>({
|
||||
title: '通知',
|
||||
channel: 'ZhaiLing',
|
||||
comments: '您的申请已通过',
|
||||
status: 0
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = reactive<Record<string, Rule[]>>({
|
||||
title: [
|
||||
{
|
||||
required: true,
|
||||
message: '请输入设备名称',
|
||||
type: 'string',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
channel: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请选择发布范围',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
comments: [
|
||||
{
|
||||
required: true,
|
||||
type: 'string',
|
||||
message: '请填写内容',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
status: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请选择设备状态',
|
||||
trigger: 'blur'
|
||||
}
|
||||
],
|
||||
sortNumber: [
|
||||
{
|
||||
required: true,
|
||||
type: 'number',
|
||||
message: '请输入排序号',
|
||||
trigger: 'blur'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
/* 控制放店开关 */
|
||||
const editStatus = () => {
|
||||
if (form.status == 0) {
|
||||
form.status = 1;
|
||||
} else {
|
||||
form.status = 0;
|
||||
}
|
||||
updateBcEquipment(form)
|
||||
.then(() => {
|
||||
message.success('操作成功');
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e.message);
|
||||
});
|
||||
};
|
||||
|
||||
const onClose = () => {
|
||||
updateVisible(false);
|
||||
};
|
||||
|
||||
const send = () => {
|
||||
addSend(form).then();
|
||||
};
|
||||
|
||||
/* 保存编辑 */
|
||||
const save = () => {
|
||||
if (!formRef.value) {
|
||||
return;
|
||||
}
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
loading.value = true;
|
||||
const equipmentForm = {
|
||||
...form
|
||||
};
|
||||
console.log(equipmentForm, 'equipmentForm');
|
||||
const saveOrUpdate = isUpdate.value
|
||||
? updateBcEquipment
|
||||
: addBcEquipment;
|
||||
saveOrUpdate(equipmentForm)
|
||||
.then((msg) => {
|
||||
loading.value = false;
|
||||
message.success(msg);
|
||||
updateVisible(false);
|
||||
emit('done');
|
||||
})
|
||||
.catch((e) => {
|
||||
loading.value = false;
|
||||
message.error(e.message);
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => props.visible,
|
||||
(visible) => {
|
||||
if (visible) {
|
||||
if (props.data) {
|
||||
loading.value = false;
|
||||
assignFields({
|
||||
...props.data
|
||||
});
|
||||
isUpdate.value = true;
|
||||
} else {
|
||||
isUpdate.value = false;
|
||||
}
|
||||
} else {
|
||||
resetFields();
|
||||
formRef.value?.clearValidate();
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
||||
<style lang="less">
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
.ml-10 {
|
||||
margin-left: 5px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user