物联设备去掉设备维度
This commit is contained in:
parent
bc297683df
commit
e1248e8e7a
|
|
@ -11,16 +11,7 @@
|
|||
<j-dict-select-tag v-model:value="queryParam.deviceType" :showLabel="false" dictCode="tplink_device_type" placeholder="请选择设备类型" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="dimension">
|
||||
<template #label><span title="设备维度">设备维度</span></template>
|
||||
<a-select v-model:value="queryParam.dimension" placeholder="请选择设备维度" allow-clear>
|
||||
<a-select-option value="机构维度">机构维度</a-select-option>
|
||||
<a-select-option value="区域维度">区域维度</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="10" style="margin-top: 5px;">
|
||||
<a-col :lg="15" style="margin-top: 5px;">
|
||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||
<a-col :lg="6">
|
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<a-row >
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备类型" v-bind="validateInfos.deviceType" id="DeviceConfigForm-deviceType" name="deviceType">
|
||||
<j-dict-select-tag v-model:value="formData.deviceType" :disabled="disabled" :showLabel="false" dictCode="tplink_device_type" placeholder="请选择设备类型" @change="changeType" @upDictCode="upDictCode"/>
|
||||
<j-dict-select-tag v-model:value="formData.deviceType" :disabled="disabled" :showLabel="false" dictCode="tplink_device_type" placeholder="请选择设备类型" @change="getDeviceName" @upDictCode="upDictCode"/>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
|
|
@ -31,16 +31,6 @@
|
|||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row >
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备维度" v-bind="validateInfos.dimension" id="DeviceConfigForm-dimension" name="dimension">
|
||||
<a-select v-model:value="formData.dimension" :disabled="disabled" placeholder="请选择设备维度" allow-clear>
|
||||
<a-select-option value="机构维度">机构维度</a-select-option>
|
||||
<a-select-option value="区域维度">区域维度</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</JFormContainer>
|
||||
|
|
@ -72,7 +62,6 @@ const formData = reactive<Record<string, any>>({
|
|||
deviceTypeLabel: '',
|
||||
deviceModel: '',
|
||||
factory: '',
|
||||
dimension: '机构维度'
|
||||
});
|
||||
const { createMessage } = useMessage();
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
|
|
@ -85,7 +74,6 @@ const validatorRules = reactive({
|
|||
deviceType: [{ required: true, message: '请选择设备类型' }],
|
||||
deviceModel: [{ required: true, message: '请输入规格型号' }],
|
||||
factory: [{ required: true, message: '请输入生产厂家' }],
|
||||
dimension: [{ required: true, message: '请选择设备维度' }],
|
||||
});
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||
|
||||
|
|
@ -106,14 +94,8 @@ function upDictCode(v_) {
|
|||
dictCode.value = v_
|
||||
}
|
||||
|
||||
function changeType(value){
|
||||
formData.deviceTypeLabel = dictCode.value.find(d => d.value == value)?.label || '';
|
||||
getDeviceName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function getDeviceName(){
|
||||
formData.deviceTypeLabel = dictCode.value.find(d => d.value == formData.deviceType)?.label || '';
|
||||
formData.deviceName = formData.deviceTypeLabel+"-"+formData.factory+"["+formData.deviceModel+"]"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,12 +24,6 @@ export const columns: BasicColumn[] = [
|
|||
align: "center",
|
||||
dataIndex: 'deviceModel'
|
||||
},
|
||||
{
|
||||
title: '设备维度',
|
||||
align: "center",
|
||||
dataIndex: 'dimension',
|
||||
width: 120
|
||||
},
|
||||
];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [];
|
||||
|
|
|
|||
|
|
@ -128,7 +128,6 @@
|
|||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
console.log(111111111);
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
</a-spin>
|
||||
<!-- 表单区域 -->
|
||||
<DeviceBatchFormModal ref="deviceBatchDrawer" @success="handleSuccess" />
|
||||
<DepartPreviewModal ref="previewDrawer" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
|
@ -60,14 +59,13 @@ import { columns } from './batch.data';
|
|||
import { batchList, deleteBatch, sendBatch } from './batch.api';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import DeviceBatchFormModal from './DeviceBatchFormModal.vue';
|
||||
import DepartPreviewModal from "../preview/DepartPreviewModal.vue";
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import { changeTheme } from "@/logics/theme";
|
||||
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
const deviceBatchDrawer = ref();
|
||||
const previewDrawer = ref();
|
||||
|
||||
const orgCode = ref<any>('');
|
||||
const departName = ref<any>('');
|
||||
const confirmLoading = ref<any>(false);
|
||||
|
|
@ -128,14 +126,6 @@ function addBatch() {
|
|||
deviceBatchDrawer.value.add(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清单
|
||||
*/
|
||||
function handlePreview(record: Recordable) {
|
||||
previewDrawer.value.disableSubmit = true;
|
||||
previewDrawer.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推送
|
||||
*/
|
||||
|
|
@ -183,15 +173,15 @@ async function handleDelete(record: Recordable) {
|
|||
*/
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '设备清单',
|
||||
onClick: handleDeatail.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: '推送清单',
|
||||
onClick: handleSend.bind(null, record),
|
||||
ifShow: record.izPush == 'N' && record.childrenCn > 0
|
||||
},
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDeatail.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
|
|
|
|||
|
|
@ -3,12 +3,6 @@ import {FormSchema} from '/@/components/Table';
|
|||
|
||||
//列表数据
|
||||
export const deviceColumns: BasicColumn[] = [
|
||||
{
|
||||
title: '设备维度',
|
||||
align: "center",
|
||||
dataIndex: 'dimension',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '设备标识',
|
||||
align: "center",
|
||||
|
|
|
|||
|
|
@ -10,15 +10,6 @@
|
|||
<a-input v-model:value="queryParam.deviceName" placeholder="请输入设备名称" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="dimension">
|
||||
<template #label><span title="设备维度">设备维度</span></template>
|
||||
<a-select v-model:value="queryParam.dimension" placeholder="请选择设备维度" allow-clear>
|
||||
<a-select-option value="机构维度">机构维度</a-select-option>
|
||||
<a-select-option value="区域维度">区域维度</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="deviceType">
|
||||
<template #label><span title="设备类型">设备类型</span></template>
|
||||
|
|
|
|||
|
|
@ -28,12 +28,6 @@ export const columns: BasicColumn[] = [
|
|||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '设备维度',
|
||||
align: "center",
|
||||
dataIndex: 'dimension',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '设备名称',
|
||||
align: "center",
|
||||
|
|
|
|||
|
|
@ -1,214 +0,0 @@
|
|||
<template>
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<JFormContainer :disabled="disabled">
|
||||
<template #detail>
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="选择设备" v-bind="validateInfos.deviceName" id="departPreviewForm-deviceName" name="deviceName">
|
||||
<a-select ref="select" :disabled="isUpdate"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="formData.deviceName" @change="handleChange">
|
||||
<a-select-option :value="item.deviceName" v-for="item in deviceConfigs" :key="item.id">{{item.deviceName}}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备类型" v-bind="validateInfos.deviceType" id="departPreviewForm-deviceType" name="deviceType">
|
||||
<j-dict-select-tag v-model:value="formData.deviceType" dictCode="tplink_device_type" disabled allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="规格型号" v-bind="validateInfos.deviceModel" id="departPreviewForm-deviceModel" name="deviceModel">
|
||||
<a-input v-model:value="formData.deviceModel" :disabled="true"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="生产厂家" v-bind="validateInfos.factory" id="departPreviewForm-factory" name="factory">
|
||||
<a-input v-model:value="formData.factory" :disabled="true"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备维度" v-bind="validateInfos.dimension" id="departPreviewForm-dimension" name="dimension">
|
||||
<a-input v-model:value="formData.dimension" :disabled="true"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="采购数量" v-bind="validateInfos.purchaseQuantity" id="departPreviewForm-purchaseQuantity" name="purchaseQuantity">
|
||||
<a-input-number v-model:value="formData.purchaseQuantity" style="width: 100%"></a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</JFormContainer>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted, unref} from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getValueType } from '/@/utils';
|
||||
import { configList,savePreview } from './preview.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
import {nulist} from "@/views/iotManager/manager.api";
|
||||
const isUpdate = ref<boolean>(false);
|
||||
const orgCode = ref<any>('');
|
||||
const batchNo = ref<any>('');
|
||||
const deviceConfigs = ref([]);
|
||||
const props = defineProps({
|
||||
formDisabled: { type: Boolean, default: false },
|
||||
formData: { type: Object, default: ()=>{} },
|
||||
formBpm: { type: Boolean, default: true }
|
||||
});
|
||||
const formRef = ref();
|
||||
const useForm = Form.useForm;
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
const formData = reactive<Record<string, any>>({
|
||||
id: undefined,
|
||||
orgCode: undefined,
|
||||
batchNo: undefined,
|
||||
deviceName: undefined,
|
||||
deviceType: undefined,
|
||||
deviceModel: undefined,
|
||||
factory: undefined,
|
||||
dimension: "机构维度",
|
||||
purchaseQuantity: undefined
|
||||
});
|
||||
const { createMessage } = useMessage();
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
|
||||
const confirmLoading = ref<boolean>(false);
|
||||
//表单验证
|
||||
const validatorRules = {
|
||||
deviceName: [{ required: true, message: '请选择设备!'},],
|
||||
purchaseQuantity: [{ required: true, message: '请输入采购数量!'},],
|
||||
};
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||
|
||||
// 表单禁用
|
||||
const disabled = computed(()=>{
|
||||
if(props.formBpm === true){
|
||||
if(props.formData.disabled === false){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return props.formDisabled;
|
||||
});
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
async function add(record) {
|
||||
getDeviceConfig();
|
||||
orgCode.value = record.orgCode;
|
||||
batchNo.value = record.batchNo;
|
||||
formData.orgCode = record.orgCode;
|
||||
formData.batchNo = record.batchNo;
|
||||
isUpdate.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function edit(record) {
|
||||
getDeviceConfig();
|
||||
orgCode.value = record.orgCode;
|
||||
batchNo.value = record.batchNo;
|
||||
isUpdate.value = true;
|
||||
nextTick(() => {
|
||||
resetFields();
|
||||
//赋值
|
||||
const tmpData = {};
|
||||
Object.keys(formData).forEach((key) => {
|
||||
if(record.hasOwnProperty(key)){
|
||||
tmpData[key] = record[key]
|
||||
}
|
||||
})
|
||||
//赋值
|
||||
Object.assign(formData, tmpData);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交数据
|
||||
*/
|
||||
async function submitForm() {
|
||||
try {
|
||||
// 触发表单验证
|
||||
await validate();
|
||||
} catch ({ errorFields }) {
|
||||
if (errorFields) {
|
||||
const firstField = errorFields[0];
|
||||
if (firstField) {
|
||||
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}
|
||||
return Promise.reject(errorFields);
|
||||
}
|
||||
confirmLoading.value = true;
|
||||
//时间格式化
|
||||
let model = formData;
|
||||
//循环数据
|
||||
for (let data in model) {
|
||||
//如果该数据是数组并且是字符串类型
|
||||
if (model[data] instanceof Array) {
|
||||
let valueType = getValueType(formRef.value.getProps, data);
|
||||
//如果是字符串类型的需要变成以逗号分割的字符串
|
||||
if (valueType === 'string') {
|
||||
model[data] = model[data].join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
let isUpdateVal = unref(isUpdate);
|
||||
await savePreview(model,isUpdateVal)
|
||||
.then((res) => {
|
||||
emit('ok');
|
||||
})
|
||||
.finally(() => {
|
||||
confirmLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
function getDeviceConfig(){
|
||||
let params = {'dimension': '机构维度'};
|
||||
configList(params)
|
||||
.then((res) => {
|
||||
deviceConfigs.value = res;
|
||||
}).catch(() =>{})
|
||||
.finally(() => {
|
||||
});
|
||||
}
|
||||
|
||||
function handleChange(key,record) {
|
||||
let vo = deviceConfigs.value.filter(item => item.id == record.key);
|
||||
formData.deviceType = vo[0]["deviceType"];
|
||||
formData.deviceModel = vo[0]["deviceModel"];
|
||||
formData.factory = vo[0]["factory"];
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
submitForm,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
<template>
|
||||
<a-drawer :title="title" :width="width" :visible="visible" :closable="true" :footer-style="{ textAlign: 'right' }"
|
||||
:bodyStyle="{ padding: '14px' }" @close="handleCancel">
|
||||
<template #footer>
|
||||
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
|
||||
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
|
||||
</template>
|
||||
<AddDepartPreviewForm v-if="visible" ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit"
|
||||
:formBpm="false">
|
||||
</AddDepartPreviewForm>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineExpose } from 'vue';
|
||||
import AddDepartPreviewForm from './AddDepartPreviewForm.vue'
|
||||
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
|
||||
|
||||
const title = ref<string>('');
|
||||
const width = ref<number>(800);
|
||||
const visible = ref<boolean>(false);
|
||||
const disableSubmit = ref<boolean>(false);
|
||||
const registerForm = ref();
|
||||
const configVisible = ref<boolean>(false);
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add(record) {
|
||||
title.value = '新增机构维度';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.add(record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param record
|
||||
*/
|
||||
function edit(record) {
|
||||
title.value = disableSubmit.value ? '详情' : '编辑机构维度';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.edit(record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定按钮点击事件
|
||||
*/
|
||||
function handleOk() {
|
||||
registerForm.value.submitForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* form保存回调事件
|
||||
*/
|
||||
function submitCallback() {
|
||||
handleCancel();
|
||||
emit('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮回调事件
|
||||
*/
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
disableSubmit,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
/**隐藏样式-modal确定按钮 */
|
||||
.jee-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
||||
|
|
@ -1,234 +0,0 @@
|
|||
<template>
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<JFormContainer :disabled="disabled">
|
||||
<template #detail>
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="选择区域" v-bind="validateInfos.nuId" id="nuPreviewForm-nuId" name="nuId">
|
||||
<a-select ref="select" :disabled="isUpdate"
|
||||
placeholder="请选择区域"
|
||||
v-model:value="formData.nuId">
|
||||
<a-select-option :value="item.nuId" v-for="item in nuInfos" :key="item.nuId">{{item.nuName}}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="选择设备" v-bind="validateInfos.deviceName" id="nuPreviewForm-deviceName" name="deviceName">
|
||||
<a-select ref="select" :disabled="isUpdate"
|
||||
placeholder="请选择设备"
|
||||
v-model:value="formData.deviceName" @change="handleChange">
|
||||
<a-select-option :value="item.deviceName" v-for="item in deviceConfigs" :key="item.id">{{item.deviceName}}</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备类型" v-bind="validateInfos.deviceType" id="nuPreviewForm-deviceType" name="deviceType">
|
||||
<j-dict-select-tag v-model:value="formData.deviceType" dictCode="tplink_device_type" disabled allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="规格型号" v-bind="validateInfos.deviceModel" id="departPreviewForm-deviceModel" name="deviceModel">
|
||||
<a-input v-model:value="formData.deviceModel" :disabled="true"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="生产厂家" v-bind="validateInfos.factory" id="nuPreviewForm-factory" name="factory">
|
||||
<a-input v-model:value="formData.factory" :disabled="true"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备维度" v-bind="validateInfos.dimension" id="nuPreviewForm-dimension" name="dimension">
|
||||
<a-input v-model:value="formData.dimension" :disabled="true"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="采购数量" v-bind="validateInfos.purchaseQuantity" id="nuPreviewForm-purchaseQuantity" name="purchaseQuantity">
|
||||
<a-input-number v-model:value="formData.purchaseQuantity" style="width: 100%"></a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</JFormContainer>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import {ref, reactive, defineExpose, nextTick, defineProps, computed, onMounted, unref} from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getValueType } from '/@/utils';
|
||||
import { nuList,configList,savePreview } from './preview.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
const isUpdate = ref<boolean>(false);
|
||||
const orgCode = ref<any>('');
|
||||
const batchNo = ref<any>('');
|
||||
const deviceConfigs = ref([]);
|
||||
const nuInfos = ref([]);
|
||||
const props = defineProps({
|
||||
formDisabled: { type: Boolean, default: false },
|
||||
formData: { type: Object, default: ()=>{} },
|
||||
formBpm: { type: Boolean, default: true }
|
||||
});
|
||||
const formRef = ref();
|
||||
const useForm = Form.useForm;
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
const formData = reactive<Record<string, any>>({
|
||||
id: undefined,
|
||||
orgCode: undefined,
|
||||
nuId: undefined,
|
||||
batchNo: undefined,
|
||||
deviceName: undefined,
|
||||
deviceType: undefined,
|
||||
deviceModel: undefined,
|
||||
factory: undefined,
|
||||
dimension: "区域维度",
|
||||
purchaseQuantity: undefined
|
||||
});
|
||||
const { createMessage } = useMessage();
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
|
||||
const confirmLoading = ref<boolean>(false);
|
||||
//表单验证
|
||||
const validatorRules = {
|
||||
nuId: [{ required: true, message: '请选择区域!'},],
|
||||
deviceName: [{ required: true, message: '请选择设备!'},],
|
||||
purchaseQuantity: [{ required: true, message: '请输入采购数量!'},],
|
||||
};
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: false });
|
||||
|
||||
// 表单禁用
|
||||
const disabled = computed(()=>{
|
||||
if(props.formBpm === true){
|
||||
if(props.formData.disabled === false){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return props.formDisabled;
|
||||
});
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
async function add(record) {
|
||||
getNuInfos(record);
|
||||
getDeviceConfig();
|
||||
orgCode.value = record.orgCode;
|
||||
batchNo.value = record.batchNo;
|
||||
formData.orgCode = record.orgCode;
|
||||
formData.batchNo = record.batchNo;
|
||||
isUpdate.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function edit(record) {
|
||||
getNuInfos(record);
|
||||
getDeviceConfig();
|
||||
orgCode.value = record.orgCode;
|
||||
batchNo.value = record.batchNo;
|
||||
isUpdate.value = true;
|
||||
nextTick(() => {
|
||||
resetFields();
|
||||
//赋值
|
||||
const tmpData = {};
|
||||
Object.keys(formData).forEach((key) => {
|
||||
if(record.hasOwnProperty(key)){
|
||||
tmpData[key] = record[key]
|
||||
}
|
||||
})
|
||||
//赋值
|
||||
Object.assign(formData, tmpData);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交数据
|
||||
*/
|
||||
async function submitForm() {
|
||||
try {
|
||||
// 触发表单验证
|
||||
await validate();
|
||||
} catch ({ errorFields }) {
|
||||
if (errorFields) {
|
||||
const firstField = errorFields[0];
|
||||
if (firstField) {
|
||||
formRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}
|
||||
return Promise.reject(errorFields);
|
||||
}
|
||||
confirmLoading.value = true;
|
||||
//时间格式化
|
||||
let model = formData;
|
||||
|
||||
//循环数据
|
||||
for (let data in model) {
|
||||
//如果该数据是数组并且是字符串类型
|
||||
if (model[data] instanceof Array) {
|
||||
let valueType = getValueType(formRef.value.getProps, data);
|
||||
//如果是字符串类型的需要变成以逗号分割的字符串
|
||||
if (valueType === 'string') {
|
||||
model[data] = model[data].join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
let isUpdateVal = unref(isUpdate);
|
||||
await savePreview(model,isUpdateVal)
|
||||
.then((res) => {
|
||||
emit('ok');
|
||||
})
|
||||
.finally(() => {
|
||||
confirmLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
function getDeviceConfig(){
|
||||
let params = {'dimension': '区域维度'};
|
||||
configList(params)
|
||||
.then((res) => {
|
||||
deviceConfigs.value = res;
|
||||
}).catch(() =>{})
|
||||
.finally(() => {
|
||||
});
|
||||
}
|
||||
|
||||
function handleChange(key,record) {
|
||||
let vo = deviceConfigs.value.filter(item => item.id == record.key);
|
||||
formData.deviceType = vo[0]["deviceType"];
|
||||
formData.deviceModel = vo[0]["deviceModel"];
|
||||
formData.factory = vo[0]["factory"];
|
||||
}
|
||||
|
||||
async function getNuInfos(record){
|
||||
let params = {'orgCode': record.orgCode };
|
||||
nuInfos.value = await nuList(params);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
submitForm,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
</style>
|
||||
|
|
@ -1,624 +0,0 @@
|
|||
<template>
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-row style="margin-top: -4px;">
|
||||
<a-col v-for="(item, index) in nuInfos" style="padding:7px 7px;" :key="index" :span="24">
|
||||
<a-card :class="['card-3d', { 'card-collapsed': expandedCard !== item.nuId }]"
|
||||
style="height: auto; min-height: 320px;" @click="handleCardClick(item.nuId, $event)">
|
||||
<!-- 卡片头部:可点击展开 -->
|
||||
<div class="card-header">
|
||||
<div class="left-area">
|
||||
<div class="left-area">
|
||||
<div class="region-name">名称:{{ item.nuName }}</div>
|
||||
<div class="region-code">NUID:{{ item.nuId }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 展开时显示收起按钮,收起时显示展开图标 -->
|
||||
<div class="expand-icon" v-if="expandedCard === item.nuId">
|
||||
<span>▲ 收起</span>
|
||||
</div>
|
||||
<div class="expand-icon" v-else>
|
||||
<span>▼ 展开</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 卡片内容:只有展开的卡片才显示 -->
|
||||
<div class="card-content" v-if="expandedCard === item.nuId" @click.stop>
|
||||
<!-- 上半部分:左右布局 -->
|
||||
<div class="top-section">
|
||||
<!-- 右侧:其他内容区域 -->
|
||||
<div class="right-area">
|
||||
<div>基础功能:</div>
|
||||
<span v-for="(item2, index) in areaFuncInfo[item.nuId].children" :key="index">
|
||||
<a-checkbox style="margin-top:10px;" checked readonly disabled>{{ item2.nuName }}</a-checkbox>
|
||||
</span>
|
||||
<span v-for="(item2, index) in areaFuncInfo[item.nuId].children" :key="index">
|
||||
<div v-if="item2.children.length > 0">
|
||||
<div style="margin-top: 20px;">{{ item2.nuName }}:</div>
|
||||
<span v-for="(item3, index) in item2.children" :key="index">
|
||||
<a-checkbox style="margin-top:10px;" checked readonly disabled>{{ item3.nuName }}</a-checkbox>
|
||||
</span>
|
||||
</div>
|
||||
</span>
|
||||
<span v-if="areaFuncInfo[item.nuId].children.length == 0">暂无基础功能</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 下半部分:设备列表(无内部滚动) -->
|
||||
<div class="bottom-section">
|
||||
<div class="section-title">设备配置</div>
|
||||
<div class="device-list">
|
||||
<div v-for="(device, dIndex) in deviceConfigs" :key="dIndex" class="device-item">
|
||||
<div class="device-info">
|
||||
<div class="device-name">{{ device.deviceName }}</div>
|
||||
<div class="device-detail">
|
||||
{{ device.factory }}<span v-if="device.factory && device.deviceModel"> | </span>{{
|
||||
device.deviceModel }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="device-quantity">
|
||||
<a-input-number :value="getQuantity(item.nuId, device.id)"
|
||||
@update:value="(val) => setQuantity(item.nuId, device.id, val)" :min="0" :precision="0" :step="1"
|
||||
:disabled="disabled" :placeholder="'请输入数量'" class="quantity-input" />
|
||||
</div>
|
||||
</div>
|
||||
<a-empty v-if="!deviceConfigs.length" description="暂无设备配置" :image-style="{ height: '60px' }" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</a-card>
|
||||
</a-col>
|
||||
<a-col :span="24" v-if="nuInfos.length == 0" style="margin-top:50px;">
|
||||
<a-empty description="暂无数据" />
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, defineExpose, nextTick, computed } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { nuList, configList, batchSave, queryQuantityByOrgCode, getNuListByOrgCode } from './preview.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
|
||||
// 定义数据类型
|
||||
interface DeviceConfig {
|
||||
id: string;
|
||||
deviceName: string;
|
||||
deviceType: string;
|
||||
deviceModel: string;
|
||||
factory: string;
|
||||
dimension: string;
|
||||
}
|
||||
|
||||
interface NuInfo {
|
||||
nuId: string;
|
||||
nuName: string;
|
||||
}
|
||||
|
||||
interface SavedData {
|
||||
id: string;
|
||||
nuId: string;
|
||||
deviceType: string;
|
||||
purchaseQuantity: number;
|
||||
}
|
||||
|
||||
interface QuantityData {
|
||||
quantity: number;
|
||||
id?: string;
|
||||
}
|
||||
|
||||
const isUpdate = ref<boolean>(false);
|
||||
const orgCode = ref<string>('');
|
||||
const batchNo = ref<string>('');
|
||||
const deviceConfigs = ref<DeviceConfig[]>([]);
|
||||
const nuInfos = ref<NuInfo[]>([]);
|
||||
|
||||
// 当前展开的卡片ID,默认第一个
|
||||
const expandedCard = ref<string>('');
|
||||
|
||||
// 存储每个卡片的采购数量: Map<nuId, Map<deviceId, QuantityData>>
|
||||
const cardQuantities = ref<Map<string, Map<string, QuantityData>>>(new Map());
|
||||
|
||||
const props = defineProps({
|
||||
formDisabled: { type: Boolean, default: false },
|
||||
formData: { type: Object, default: () => ({}) },
|
||||
formBpm: { type: Boolean, default: true }
|
||||
});
|
||||
|
||||
const formRef = ref();
|
||||
const useForm = Form.useForm;
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
|
||||
const formData = reactive<Record<string, any>>({
|
||||
id: undefined,
|
||||
orgCode: undefined,
|
||||
nuId: undefined,
|
||||
batchNo: undefined,
|
||||
deviceName: undefined,
|
||||
deviceType: undefined,
|
||||
deviceModel: undefined,
|
||||
factory: undefined,
|
||||
dimension: "区域维度",
|
||||
purchaseQuantity: undefined
|
||||
});
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
const confirmLoading = ref<boolean>(false);
|
||||
const configData = ref<SavedData[]>([]);
|
||||
const areaFuncInfo = ref()
|
||||
|
||||
// 表单验证
|
||||
const validatorRules = {
|
||||
nuId: [{ required: true, message: '请选择区域!' }],
|
||||
deviceName: [{ required: true, message: '请选择设备!' }],
|
||||
purchaseQuantity: [{ required: true, message: '请输入采购数量!' }],
|
||||
};
|
||||
|
||||
const { resetFields, validate } = useForm(formData, validatorRules, { immediate: false });
|
||||
|
||||
// 表单禁用
|
||||
const disabled = computed(() => {
|
||||
if (props.formBpm === true) {
|
||||
if (props.formData.disabled === false) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return props.formDisabled;
|
||||
});
|
||||
|
||||
// 处理卡片点击(阻止内部元素的冒泡)
|
||||
function handleCardClick(nuId: string, event: Event) {
|
||||
// 检查点击目标是否可能是可交互元素
|
||||
const target = event.target as HTMLElement;
|
||||
const isInputElement = target.tagName === 'INPUT' ||
|
||||
target.tagName === 'BUTTON' ||
|
||||
target.closest('.ant-input-number') ||
|
||||
target.closest('.ant-checkbox-wrapper') ||
|
||||
target.closest('button');
|
||||
|
||||
// 如果点击的是输入框、按钮等交互元素,且当前卡片是展开状态,则不触发展开/收起
|
||||
if (isInputElement && expandedCard.value === nuId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 否则执行展开/收起逻辑
|
||||
expandCard(nuId);
|
||||
}
|
||||
|
||||
// 展开/收起卡片
|
||||
function expandCard(nuId: string) {
|
||||
// 如果点击的是已经展开的卡片,则收起
|
||||
if (expandedCard.value === nuId) {
|
||||
expandedCard.value = '';
|
||||
return;
|
||||
}
|
||||
// 否则展开当前卡片
|
||||
expandedCard.value = nuId;
|
||||
}
|
||||
|
||||
// 获取指定卡片、指定设备的数量
|
||||
function getQuantity(nuId: string, deviceId: string): number {
|
||||
const nuMap = cardQuantities.value.get(nuId);
|
||||
if (!nuMap) return 0;
|
||||
const data = nuMap.get(deviceId);
|
||||
return data?.quantity ?? 0;
|
||||
}
|
||||
|
||||
// 设置指定卡片、指定设备的数量
|
||||
function setQuantity(nuId: string, deviceId: string, value: number | undefined) {
|
||||
const intValue = Math.max(0, Math.floor(value || 0));
|
||||
|
||||
let nuMap = cardQuantities.value.get(nuId);
|
||||
if (!nuMap) {
|
||||
nuMap = new Map();
|
||||
cardQuantities.value.set(nuId, nuMap);
|
||||
}
|
||||
|
||||
const existing = nuMap.get(deviceId);
|
||||
if (existing) {
|
||||
existing.quantity = intValue;
|
||||
} else {
|
||||
nuMap.set(deviceId, {
|
||||
quantity: intValue,
|
||||
id: undefined
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 从已保存配置中填充数量到卡片
|
||||
function fillQuantitiesFromConfig() {
|
||||
if (!configData.value || configData.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 先清空现有数据
|
||||
cardQuantities.value.clear();
|
||||
|
||||
// 遍历已保存的数据
|
||||
for (const savedItem of configData.value) {
|
||||
const { nuId, deviceType, purchaseQuantity, id } = savedItem;
|
||||
|
||||
// 通过 deviceType 找到对应的设备
|
||||
const matchedDevice = deviceConfigs.value.find(device => device.deviceType === deviceType);
|
||||
|
||||
if (matchedDevice && nuId) {
|
||||
let nuMap = cardQuantities.value.get(nuId);
|
||||
if (!nuMap) {
|
||||
nuMap = new Map();
|
||||
cardQuantities.value.set(nuId, nuMap);
|
||||
}
|
||||
|
||||
nuMap.set(matchedDevice.id, {
|
||||
quantity: purchaseQuantity || 0,
|
||||
id: id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log("填充后的 cardQuantities:", cardQuantities.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
async function add(record: any) {
|
||||
await getNuInfos(record);
|
||||
await getDeviceConfig();
|
||||
orgCode.value = record.orgCode;
|
||||
batchNo.value = record.batchNo;
|
||||
formData.orgCode = record.orgCode;
|
||||
formData.batchNo = record.batchNo;
|
||||
isUpdate.value = false;
|
||||
|
||||
// 重置所有卡片的采购数量
|
||||
cardQuantities.value.clear();
|
||||
|
||||
configData.value = await queryQuantityByOrgCodeFunc();
|
||||
console.log("新增 - 已保存数据:", configData.value);
|
||||
|
||||
areaFuncInfo.value = await getNuListByOrgCodeFunc();
|
||||
console.log("🌊 ~ add ~ areaFuncInfo.value:", areaFuncInfo.value);
|
||||
|
||||
// 默认展开第一个卡片
|
||||
if (nuInfos.value.length > 0) {
|
||||
expandedCard.value = nuInfos.value[0].nuId;
|
||||
}
|
||||
|
||||
// 填充已保存的数据到卡片
|
||||
fillQuantitiesFromConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
async function edit(record: any) {
|
||||
await getNuInfos(record);
|
||||
await getDeviceConfig();
|
||||
orgCode.value = record.orgCode;
|
||||
batchNo.value = record.batchNo;
|
||||
isUpdate.value = true;
|
||||
|
||||
nextTick(async () => {
|
||||
resetFields();
|
||||
// 赋值
|
||||
const tmpData: Record<string, any> = {};
|
||||
Object.keys(formData).forEach((key) => {
|
||||
if (record.hasOwnProperty(key)) {
|
||||
tmpData[key] = record[key];
|
||||
}
|
||||
});
|
||||
Object.assign(formData, tmpData);
|
||||
|
||||
configData.value = await queryQuantityByOrgCodeFunc();
|
||||
console.log("编辑 - 已保存数据:", configData.value);
|
||||
|
||||
areaFuncInfo.value = await getNuListByOrgCodeFunc();
|
||||
console.log("🌊 ~ edit ~ areaFuncInfo.value:", areaFuncInfo.value);
|
||||
|
||||
// 默认展开第一个卡片
|
||||
if (nuInfos.value.length > 0) {
|
||||
expandedCard.value = nuInfos.value[0].nuId;
|
||||
}
|
||||
|
||||
// 填充已保存的数据到卡片
|
||||
fillQuantitiesFromConfig();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交数据
|
||||
*/
|
||||
async function submitForm() {
|
||||
if (!deviceConfigs.value.length) {
|
||||
createMessage.warning('请先加载设备配置');
|
||||
return Promise.reject('无设备配置');
|
||||
}
|
||||
|
||||
confirmLoading.value = true;
|
||||
|
||||
try {
|
||||
// 构建提交数据: nu数量 * device数量 = 所有组合
|
||||
const submitRecords: any[] = [];
|
||||
|
||||
for (const nu of nuInfos.value) {
|
||||
for (const device of deviceConfigs.value) {
|
||||
const nuMap = cardQuantities.value.get(nu.nuId);
|
||||
const quantityData = nuMap?.get(device.id);
|
||||
const quantity = quantityData?.quantity ?? 0;
|
||||
const savedId = quantityData?.id;
|
||||
|
||||
submitRecords.push({
|
||||
id: savedId, // 如果有 id 说明是更新,没有则是新增
|
||||
orgCode: formData.orgCode,
|
||||
batchNo: formData.batchNo,
|
||||
nuId: nu.nuId,
|
||||
deviceName: device.deviceName,
|
||||
deviceType: device.deviceType,
|
||||
deviceModel: device.deviceModel,
|
||||
factory: device.factory,
|
||||
dimension: formData.dimension,
|
||||
purchaseQuantity: quantity
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
console.log("提交数据:", submitRecords);
|
||||
console.log("共提交条数:", submitRecords.length);
|
||||
|
||||
await batchSave(submitRecords);
|
||||
emit('ok');
|
||||
} catch (error) {
|
||||
createMessage.error('提交失败');
|
||||
console.error(error);
|
||||
return Promise.reject(error);
|
||||
} finally {
|
||||
confirmLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function getDeviceConfig() {
|
||||
const params = { dimension: '区域维度' };
|
||||
return configList(params)
|
||||
.then((res) => {
|
||||
deviceConfigs.value = res || [];
|
||||
console.log("设备配置:", deviceConfigs.value);
|
||||
})
|
||||
.catch(() => {
|
||||
deviceConfigs.value = [];
|
||||
});
|
||||
}
|
||||
|
||||
function handleChange(key: string, record: any) {
|
||||
const vo = deviceConfigs.value.filter(item => item.id === record.key);
|
||||
if (vo.length) {
|
||||
formData.deviceType = vo[0].deviceType;
|
||||
formData.deviceModel = vo[0].deviceModel;
|
||||
formData.factory = vo[0].factory;
|
||||
}
|
||||
}
|
||||
|
||||
async function getNuInfos(record: any) {
|
||||
const params = { orgCode: record.orgCode };
|
||||
nuInfos.value = await nuList(params);
|
||||
console.log("区域信息:", nuInfos.value);
|
||||
}
|
||||
|
||||
async function queryQuantityByOrgCodeFunc() {
|
||||
return await queryQuantityByOrgCode({ batchNo: formData.batchNo, orgCode: formData.orgCode });
|
||||
}
|
||||
|
||||
async function getNuListByOrgCodeFunc() {
|
||||
return await getNuListByOrgCode({ orgCode: formData.orgCode });
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
submitForm,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
/* 基础卡片样式 */
|
||||
.card-3d {
|
||||
border-radius: 12px;
|
||||
border: 1px solid #e8eef4;
|
||||
background: white;
|
||||
position: relative;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* 鼠标悬停效果 */
|
||||
.card-3d:hover {
|
||||
border-color: #1890ff;
|
||||
box-shadow: 0 4px 12px rgba(24, 144, 255, 0.1);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
/* 收起状态样式 */
|
||||
.card-collapsed {
|
||||
min-height: auto !important;
|
||||
height: auto !important;
|
||||
|
||||
:deep(.ant-card-body) {
|
||||
padding: 16px 20px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 卡片内容区域 */
|
||||
:deep(.ant-card-body) {
|
||||
padding: 16px 20px;
|
||||
transition: padding 0.3s ease;
|
||||
}
|
||||
|
||||
/* 卡片头部的鼠标样式 */
|
||||
.card-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
cursor: inherit;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.card-header .left-area {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
gap: 24px;
|
||||
}
|
||||
|
||||
.region-name {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.region-code {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
color: darkgrey;
|
||||
}
|
||||
|
||||
.expand-icon {
|
||||
font-size: 14px;
|
||||
color: #1890ff;
|
||||
padding: 4px 12px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
span {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.card-header:hover .expand-icon {
|
||||
background-color: rgba(24, 144, 255, 0.1);
|
||||
}
|
||||
|
||||
/* 卡片内容容器 */
|
||||
.card-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
margin-top: 16px;
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid #f0f2f5;
|
||||
}
|
||||
|
||||
/* 上半部分 - 左右布局 */
|
||||
.top-section {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.right-area {
|
||||
flex: 3;
|
||||
background: #ffffff;
|
||||
padding: 12px;
|
||||
border-radius: 10px;
|
||||
box-shadow: -2px 0 8px rgba(0, 0, 0, 0.02);
|
||||
}
|
||||
|
||||
/* 下半部分 - 设备配置(无内部滚动) */
|
||||
.bottom-section {
|
||||
.section-title {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1f2f3d;
|
||||
margin-bottom: 12px;
|
||||
padding-left: 4px;
|
||||
border-left: 3px solid #1890ff;
|
||||
}
|
||||
}
|
||||
|
||||
.device-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.device-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
background: #fafbfc;
|
||||
border-radius: 8px;
|
||||
transition: all 0.2s ease;
|
||||
|
||||
&:hover {
|
||||
background: #f5f8ff;
|
||||
transform: translateX(2px);
|
||||
}
|
||||
}
|
||||
|
||||
.device-info {
|
||||
flex: 1;
|
||||
|
||||
.device-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: #1f2f3d;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.device-detail {
|
||||
font-size: 12px;
|
||||
color: #8a9aa8;
|
||||
line-height: 1.4;
|
||||
}
|
||||
}
|
||||
|
||||
.device-quantity {
|
||||
margin-left: 16px;
|
||||
|
||||
.quantity-input {
|
||||
width: 130px;
|
||||
|
||||
:deep(.ant-input-number-input) {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 响应式调整 */
|
||||
@media (max-width: 768px) {
|
||||
.top-section {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.device-item {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.device-quantity {
|
||||
margin-left: 0;
|
||||
width: 100%;
|
||||
|
||||
.quantity-input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 强制 checkbox 文字显示为黑色 */
|
||||
.right-area {
|
||||
|
||||
:deep(.ant-checkbox-wrapper),
|
||||
:deep(.ant-checkbox-wrapper-disabled),
|
||||
:deep(.ant-checkbox + span),
|
||||
:deep(.ant-checkbox-disabled + span) {
|
||||
color: rgba(0, 0, 0, 0.88) !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
<template>
|
||||
<a-drawer :title="title" :width="width" :visible="visible" :closable="true" :footer-style="{ textAlign: 'right' }"
|
||||
:bodyStyle="{ padding: '14px' }" @close="handleCancel">
|
||||
<template #footer>
|
||||
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
|
||||
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
|
||||
</template>
|
||||
<AddNuPreviewForm v-if="visible" ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit"
|
||||
:formBpm="false">
|
||||
</AddNuPreviewForm>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineExpose } from 'vue';
|
||||
import AddNuPreviewForm from './AddNuPreviewForm.vue'
|
||||
import JModal from '/@/components/Modal/src/JModal/JModal.vue';
|
||||
|
||||
const title = ref<string>('');
|
||||
const width = ref<number>(800);
|
||||
const visible = ref<boolean>(false);
|
||||
const disableSubmit = ref<boolean>(false);
|
||||
const registerForm = ref();
|
||||
const configVisible = ref<boolean>(false);
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add(record) {
|
||||
title.value = '新增区域维度';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.add(record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param record
|
||||
*/
|
||||
function edit(record) {
|
||||
title.value = disableSubmit.value ? '详情' : '编辑区域维度';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.edit(record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定按钮点击事件
|
||||
*/
|
||||
function handleOk() {
|
||||
registerForm.value.submitForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* form保存回调事件
|
||||
*/
|
||||
function submitCallback() {
|
||||
handleCancel();
|
||||
emit('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮回调事件
|
||||
*/
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
disableSubmit,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
/**隐藏样式-modal确定按钮 */
|
||||
.jee-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
||||
|
|
@ -1,226 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<!--查询区域-->
|
||||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form ref="formRef" :model="queryParam" :label-col="labelCol"
|
||||
:wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="dimension">
|
||||
<template #label><span title="设备维度">设备维度</span></template>
|
||||
<a-select v-model:value="queryParam.dimension" placeholder="请选择设备维度" allow-clear>
|
||||
<a-select-option value="机构维度">机构维度</a-select-option>
|
||||
<a-select-option value="区域维度">区域维度</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="deviceType">
|
||||
<template #label><span title="设备类型">设备类型</span></template>
|
||||
<j-dict-select-tag v-model:value="queryParam.deviceType" :showLabel="false" dictCode="tplink_device_type" placeholder="请选择设备类型" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<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">
|
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset"
|
||||
style="margin-left: 8px">重置</a-button>
|
||||
</a-col>
|
||||
</span>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="addDepartDevice" v-if="izPush=='N'"> 机构维度</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="addNuDevice" v-if="izPush=='N'"> 区域维度</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="devicePreview"> 设备管理</a-button>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)"/>
|
||||
</template>
|
||||
<template v-slot:bodyCell="{ column, record, index, text }">
|
||||
</template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<AddDepartPreviewModal ref="addDepartPreviewDrawer" @success="handleSuccess" />
|
||||
<AddNuPreviewModal ref="addNuPreviewDrawer" @success="handleSuccess" />
|
||||
<NuPreviewModal ref="nuPreviewDrawer" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="iotManager-areaList" setup>
|
||||
import {ref, reactive, defineExpose, nextTick, createVNode} from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { departColumns } from './preview.data';
|
||||
import { departPreview } from './preview.api';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import AddDepartPreviewModal from './AddDepartPreviewModal.vue';
|
||||
import AddNuPreviewModal from './AddNuPreviewModal.vue';
|
||||
import NuPreviewModal from './NuPreviewModal.vue';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import {Modal} from "ant-design-vue";
|
||||
import {ExclamationCircleOutlined} from "@ant-design/icons-vue";
|
||||
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
const addDepartPreviewDrawer = ref();
|
||||
const addNuPreviewDrawer = ref();
|
||||
const nuPreviewDrawer = ref();
|
||||
const orgCode = ref<any>('');
|
||||
const batchNo = ref<any>('');
|
||||
const izPush = ref<any>('');
|
||||
const userStore = useUserStore();
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '设备清单',
|
||||
api: departPreview,
|
||||
columns: departColumns,
|
||||
canResize: false,
|
||||
useSearchForm: false,
|
||||
showIndexColumn: true,
|
||||
showActionColumn: false,
|
||||
immediate: false,
|
||||
pagination: {
|
||||
current: 1,
|
||||
pageSize: 15,
|
||||
pageSizeOptions: ['15', '50', '70', '100'],
|
||||
},
|
||||
actionColumn: {
|
||||
width: 180,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: async (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const labelCol = reactive({
|
||||
xs:24,
|
||||
sm:8,
|
||||
xl:8,
|
||||
xxl:8
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: 24,
|
||||
sm: 16,
|
||||
});
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 机构添加设备
|
||||
*/
|
||||
function addDepartDevice(){
|
||||
let record = {
|
||||
orgCode: orgCode.value,
|
||||
batchNo: batchNo.value
|
||||
}
|
||||
addDepartPreviewDrawer.value.disableSubmit = false;
|
||||
addDepartPreviewDrawer.value.add(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 区域添加设备
|
||||
*/
|
||||
function addNuDevice(){
|
||||
let record = {
|
||||
orgCode: orgCode.value,
|
||||
batchNo: batchNo.value
|
||||
}
|
||||
addNuPreviewDrawer.value.disableSubmit = false;
|
||||
addNuPreviewDrawer.value.add(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备预览
|
||||
*/
|
||||
function devicePreview(){
|
||||
let record ={
|
||||
orgCode: orgCode.value,
|
||||
batchNo: batchNo.value,
|
||||
izPush: izPush.value
|
||||
}
|
||||
nuPreviewDrawer.value.disableSubmit = true;
|
||||
nuPreviewDrawer.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function searchQuery() {
|
||||
queryParam.orgCode = orgCode.value;
|
||||
queryParam.batchNo = batchNo.value;
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
formRef.value.resetFields();
|
||||
//刷新数据
|
||||
searchQuery();
|
||||
}
|
||||
|
||||
//初始化
|
||||
function init(record) {
|
||||
orgCode.value = record.orgCode;
|
||||
batchNo.value = record.batchNo;
|
||||
izPush.value = record.izPush;
|
||||
searchQuery();
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
init
|
||||
});
|
||||
|
||||
</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{
|
||||
min-width: 100px !important;
|
||||
}
|
||||
.query-group-split-cust{
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center
|
||||
}
|
||||
.ant-form-item:not(.ant-form-item-with-help){
|
||||
margin-bottom: 16px;
|
||||
height: 32px;
|
||||
}
|
||||
:deep(.ant-picker),:deep(.ant-input-number){
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
<template>
|
||||
<a-drawer :title="title" :width="width" :visible="visible" :closable="true" :footer-style="{ textAlign: 'right' }"
|
||||
:bodyStyle="{ padding: '14px' }" @close="handleCancel">
|
||||
<template #footer>
|
||||
<a-button type="primary" style="margin-right: 8px" @click="handleCancel">关闭</a-button>
|
||||
<a-button type="primary" @click="handleOk" v-if="!disableSubmit">确认</a-button>
|
||||
</template>
|
||||
<DepartPreviewList v-if="visible" ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit"
|
||||
:formBpm="false">
|
||||
</DepartPreviewList>
|
||||
</a-drawer>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineExpose } from 'vue';
|
||||
import DepartPreviewList from './DepartPreviewList.vue'
|
||||
|
||||
const title = ref<string>('');
|
||||
const width = ref<number>(1200);
|
||||
const visible = ref<boolean>(false);
|
||||
const disableSubmit = ref<boolean>(false);
|
||||
const registerForm = ref();
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add() {
|
||||
title.value = '新增';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.add();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param record
|
||||
*/
|
||||
function edit(record) {
|
||||
title.value = disableSubmit.value ? '设备清单' : '设备清单';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.init(record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定按钮点击事件
|
||||
*/
|
||||
function handleOk() {
|
||||
registerForm.value.submitForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* form保存回调事件
|
||||
*/
|
||||
function submitCallback() {
|
||||
handleCancel();
|
||||
emit('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮回调事件
|
||||
*/
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
emit('success');
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
disableSubmit,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
/**隐藏样式-modal确定按钮 */
|
||||
.jee-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
||||
|
|
@ -1,222 +0,0 @@
|
|||
<template>
|
||||
<div>
|
||||
<!--查询区域-->
|
||||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form ref="formRef" :model="queryParam" :label-col="labelCol"
|
||||
:wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="nuName">
|
||||
<template #label><span title="区域名称">区域名称</span></template>
|
||||
<a-input v-model:value="queryParam.nuName" placeholder="请输入区域名称" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="dimension">
|
||||
<template #label><span title="设备维度">设备维度</span></template>
|
||||
<a-select v-model:value="queryParam.dimension" placeholder="请选择设备维度" allow-clear>
|
||||
<a-select-option value="机构维度">机构维度</a-select-option>
|
||||
<a-select-option value="区域维度">区域维度</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="deviceType">
|
||||
<template #label><span title="设备类型">设备类型</span></template>
|
||||
<j-dict-select-tag v-model:value="queryParam.deviceType" :showLabel="false" dictCode="tplink_device_type" placeholder="请选择设备类型" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<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">
|
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset"
|
||||
style="margin-left: 8px">重置</a-button>
|
||||
</a-col>
|
||||
</span>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)"/>
|
||||
</template>
|
||||
<template v-slot:bodyCell="{ column, record, index, text }">
|
||||
</template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<AddDepartPreviewModal ref="addDepartPreviewDrawer" @success="handleSuccess" />
|
||||
<AddNuPreviewModal ref="addNuPreviewDrawer" @success="handleSuccess" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="iotManager-areaList" setup>
|
||||
import {ref, reactive, defineExpose, nextTick, createVNode} from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { nuColumns } from './preview.data';
|
||||
import { nuPreview,deletePreview } from './preview.api';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import AddDepartPreviewModal from './AddDepartPreviewModal.vue';
|
||||
import AddNuPreviewModal from './AddNuPreviewModal.vue';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import {Modal} from "ant-design-vue";
|
||||
import {ExclamationCircleOutlined} from "@ant-design/icons-vue";
|
||||
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
const addDepartPreviewDrawer = ref();
|
||||
const addNuPreviewDrawer = ref();
|
||||
const orgCode = ref<any>('');
|
||||
const batchNo = ref<any>('');
|
||||
const izPush = ref<any>('');
|
||||
const userStore = useUserStore();
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '设备清单',
|
||||
api: nuPreview,
|
||||
columns: nuColumns,
|
||||
canResize: false,
|
||||
useSearchForm: false,
|
||||
showIndexColumn: true,
|
||||
showActionColumn: true,
|
||||
immediate: false,
|
||||
pagination: {
|
||||
current: 1,
|
||||
pageSize: 15,
|
||||
pageSizeOptions: ['15', '50', '70', '100'],
|
||||
},
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: async (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const labelCol = reactive({
|
||||
xs:24,
|
||||
sm:8,
|
||||
xl:8,
|
||||
xxl:8
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: 24,
|
||||
sm: 16,
|
||||
});
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function handleEdit(record) {
|
||||
if(record.dimension =='机构维度'){
|
||||
addDepartPreviewDrawer.value.disableSubmit = false;
|
||||
addDepartPreviewDrawer.value.edit(record);
|
||||
}
|
||||
if(record.dimension =='区域维度'){
|
||||
addNuPreviewDrawer.value.disableSubmit = false;
|
||||
addNuPreviewDrawer.value.edit(record);
|
||||
}
|
||||
}
|
||||
|
||||
// 删除
|
||||
async function handleDelete(record: Recordable) {
|
||||
await deletePreview(record);
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
ifShow: izPush.value == 'N'
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确定删除?',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
ifShow: izPush.value == 'N'
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function searchQuery() {
|
||||
queryParam.orgCode = orgCode.value;
|
||||
queryParam.batchNo = batchNo.value;
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
formRef.value.resetFields();
|
||||
//刷新数据
|
||||
searchQuery();
|
||||
}
|
||||
|
||||
//初始化
|
||||
function init(record) {
|
||||
orgCode.value = record.orgCode;
|
||||
batchNo.value = record.batchNo;
|
||||
izPush.value = record.izPush;
|
||||
searchQuery();
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
init
|
||||
});
|
||||
|
||||
</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{
|
||||
min-width: 100px !important;
|
||||
}
|
||||
.query-group-split-cust{
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center
|
||||
}
|
||||
.ant-form-item:not(.ant-form-item-with-help){
|
||||
margin-bottom: 16px;
|
||||
height: 32px;
|
||||
}
|
||||
:deep(.ant-picker),:deep(.ant-input-number){
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -10,15 +10,6 @@
|
|||
<a-input v-model:value="queryParam.nuName" placeholder="请输入区域名称" allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="dimension">
|
||||
<template #label><span title="设备维度">设备维度</span></template>
|
||||
<a-select v-model:value="queryParam.dimension" placeholder="请选择设备维度" allow-clear>
|
||||
<a-select-option value="机构维度">机构维度</a-select-option>
|
||||
<a-select-option value="区域维度">区域维度</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="deviceType">
|
||||
<template #label><span title="设备类型">设备类型</span></template>
|
||||
|
|
@ -42,12 +33,9 @@
|
|||
<BasicTable @register="registerTable">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="openDepartDrawer"
|
||||
<a-button type="primary" preIcon="ant-design:plus-outlined" @click="openNuDrawer"
|
||||
v-if="!formDisabled && izPush == 'N'">
|
||||
机构维度</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:edit-outlined" @click="openNuDrawer"
|
||||
v-if="!formDisabled && izPush == 'N'">
|
||||
区域维度</a-button>
|
||||
添加清单</a-button>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
|
|
@ -55,74 +43,6 @@
|
|||
</template>
|
||||
</BasicTable>
|
||||
|
||||
<!-- 机构维度抽屉 -->
|
||||
<a-drawer :title="departDrawer.title" :width="departDrawer.width" :visible="departDrawer.visible" :closable="true"
|
||||
:footer-style="{ textAlign: 'right' }" :bodyStyle="{ padding: '14px' }" @close="handleDepartDrawerCancel"
|
||||
:maskClosable="false">
|
||||
<template #footer>
|
||||
<a-button type="primary" style="margin-right: 8px" @click="handleDepartDrawerCancel">关闭</a-button>
|
||||
<a-button type="primary" @click="handleDepartDrawerOk" v-if="!departDrawer.disableSubmit">确认</a-button>
|
||||
</template>
|
||||
|
||||
<a-spin :spinning="departDrawer.confirmLoading">
|
||||
<JFormContainer :disabled="departDrawer.disabled">
|
||||
<template #detail>
|
||||
<a-form ref="departFormRef" class="antd-modal-form" :label-col="labelColJGWD" :wrapper-col="wrapperColJGWD">
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="选择设备" v-bind="departValidateInfos.deviceName">
|
||||
<a-select :disabled="departDrawer.isUpdate" placeholder="请选择设备"
|
||||
v-model:value="departFormData.deviceName" @change="handleDepartDeviceChange">
|
||||
<a-select-option :value="item.deviceName" v-for="item in departDeviceConfigs" :key="item.id">
|
||||
{{ item.deviceName }}
|
||||
</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备类型" v-bind="departValidateInfos.deviceType">
|
||||
<j-dict-select-tag v-model:value="departFormData.deviceType" dictCode="tplink_device_type" disabled
|
||||
allow-clear />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="规格型号" v-bind="departValidateInfos.deviceModel">
|
||||
<a-input v-model:value="departFormData.deviceModel" disabled></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="生产厂家" v-bind="departValidateInfos.factory">
|
||||
<a-input v-model:value="departFormData.factory" disabled></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备维度" v-bind="departValidateInfos.dimension">
|
||||
<a-input v-model:value="departFormData.dimension" disabled></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="采购数量" v-bind="departValidateInfos.purchaseQuantity">
|
||||
<a-input-number v-model:value="departFormData.purchaseQuantity"
|
||||
style="width: 100%"></a-input-number>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</template>
|
||||
</JFormContainer>
|
||||
</a-spin>
|
||||
</a-drawer>
|
||||
|
||||
<!-- 区域维度抽屉 -->
|
||||
<a-drawer :title="nuDrawer.title" :width="nuDrawer.width" :visible="nuDrawer.visible" :closable="true"
|
||||
:footer-style="{ textAlign: 'right' }" :bodyStyle="{ padding: '14px' }" @close="handleNuDrawerCancel"
|
||||
|
|
@ -257,13 +177,6 @@
|
|||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="设备维度">
|
||||
<a-input v-model:value="editNuFormData.dimension" disabled></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</a-row>
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="采购数量" v-bind="editNuValidateInfos.purchaseQuantity">
|
||||
|
|
@ -283,7 +196,7 @@ import { ref, reactive, defineExpose, nextTick, createVNode, computed, onMounted
|
|||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { nuColumns } from './preview.data';
|
||||
import { nuPreview, deletePreview, configList, previewBatchSave, nuList, batchSave, queryQuantityByOrgCode, getNuListByOrgCode } from './preview.api';
|
||||
import { nuPreview, configList, nuList, batchSave, getNuListByOrgCode } from './preview.api';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
|
|
@ -299,7 +212,6 @@ const props = defineProps({
|
|||
const emit = defineEmits(['ok']);
|
||||
const { createMessage } = useMessage();
|
||||
const formRef = ref();
|
||||
const departFormRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
const orgCode = ref<any>('');
|
||||
const batchNo = ref<any>('');
|
||||
|
|
@ -307,50 +219,13 @@ const izPush = ref<any>('');
|
|||
const userStore = useUserStore();
|
||||
|
||||
// ==================== 本地数据存储 ====================
|
||||
// 存储机构维度的数据列表
|
||||
const localDepartList = ref<any[]>([]);
|
||||
// 存储区域维度的数据列表
|
||||
const localNuList = ref<any[]>([]);
|
||||
// 用于编辑时记录的临时ID
|
||||
let tempIdCounter = 1;
|
||||
|
||||
// ==================== 机构维度相关 ====================
|
||||
const departDrawer = reactive({
|
||||
title: '',
|
||||
width: 800,
|
||||
visible: false,
|
||||
disableSubmit: false,
|
||||
confirmLoading: false,
|
||||
isUpdate: false,
|
||||
disabled: false
|
||||
});
|
||||
|
||||
const departFormData = reactive<Record<string, any>>({
|
||||
id: undefined,
|
||||
orgCode: undefined,
|
||||
batchNo: undefined,
|
||||
deviceName: undefined,
|
||||
deviceType: undefined,
|
||||
deviceType_dictText: undefined,
|
||||
deviceModel: undefined,
|
||||
factory: undefined,
|
||||
dimension: "机构维度",
|
||||
purchaseQuantity: undefined
|
||||
});
|
||||
|
||||
const deviceTypeDicts = ref()
|
||||
|
||||
const departDeviceConfigs = ref<any[]>([]);
|
||||
|
||||
const departValidatorRules = {
|
||||
deviceName: [{ required: true, message: '请选择设备!' }],
|
||||
purchaseQuantity: [
|
||||
{ required: true, message: '请输入采购数量!' },
|
||||
{ type: 'number', min: 1, message: '采购数量必须大于0!' }
|
||||
],
|
||||
};
|
||||
|
||||
const { resetFields: resetDepartFields, validate: validateDepart, validateInfos: departValidateInfos } = Form.useForm(departFormData, departValidatorRules, { immediate: false });
|
||||
|
||||
// ==================== 区域维度相关 ====================
|
||||
const nuDrawer = reactive({
|
||||
|
|
@ -371,7 +246,6 @@ interface DeviceConfig {
|
|||
deviceType: string;
|
||||
deviceModel: string;
|
||||
factory: string;
|
||||
dimension: string;
|
||||
}
|
||||
|
||||
interface NuInfo {
|
||||
|
|
@ -449,27 +323,8 @@ function handleSuccess() {
|
|||
function filterLocalData() {
|
||||
const allData = [];
|
||||
|
||||
// 过滤机构维度数据
|
||||
let filteredDepartList = [...localDepartList.value];
|
||||
if (queryParam.dimension && queryParam.dimension !== '') {
|
||||
filteredDepartList = filteredDepartList.filter(item => item.dimension === queryParam.dimension);
|
||||
}
|
||||
if (queryParam.deviceType && queryParam.deviceType !== '') {
|
||||
filteredDepartList = filteredDepartList.filter(item => item.deviceType === queryParam.deviceType);
|
||||
}
|
||||
if (queryParam.nuName && queryParam.nuName !== '') {
|
||||
filteredDepartList = []
|
||||
}
|
||||
// 区域维度数据处理
|
||||
let filteredNuList = [...localNuList.value];
|
||||
if (queryParam.dimension && queryParam.dimension !== '') {
|
||||
filteredNuList = filteredNuList.filter(item => item.dimension === queryParam.dimension);
|
||||
}
|
||||
|
||||
// 添加机构维度数据
|
||||
for (const item of filteredDepartList) {
|
||||
allData.push(item);
|
||||
}
|
||||
|
||||
// 添加区域维度数据(需要按条件过滤 configData 内的设备)
|
||||
for (const item of filteredNuList) {
|
||||
|
|
@ -499,15 +354,6 @@ function filterLocalData() {
|
|||
function loadLocalDataToTable() {
|
||||
const allData = [];
|
||||
|
||||
// 机构维度
|
||||
for (const item of localDepartList.value) {
|
||||
if (item.deviceType && !item.deviceType_dictText) {
|
||||
const match = deviceTypeDicts.value?.find(d => d.value == item.deviceType);
|
||||
item.deviceType_dictText = match ? match.label : item.deviceType;
|
||||
}
|
||||
allData.push(item);
|
||||
}
|
||||
|
||||
// 区域维度
|
||||
for (const item of localNuList.value) {
|
||||
if (item.configData && item.configData.length) {
|
||||
|
|
@ -528,21 +374,10 @@ function loadLocalDataToTable() {
|
|||
|
||||
// 删除本地数据
|
||||
function handleDelete(record: Recordable) {
|
||||
// 1. 机构维度:用 deviceName 作为唯一标识(业务上同一设备名不会重复)
|
||||
if (record.dimension === '机构维度') {
|
||||
const index = localDepartList.value.findIndex(
|
||||
item => item.deviceName === record.deviceName
|
||||
);
|
||||
if (index !== -1) {
|
||||
localDepartList.value.splice(index, 1);
|
||||
}
|
||||
}
|
||||
// 2. 区域维度:用 [nuName + deviceName] 作为唯一标识
|
||||
else if (record.dimension === '区域维度') {
|
||||
for (const nuRecord of localNuList.value) {
|
||||
// 先匹配区域名(nuName)
|
||||
if (nuRecord.nuName !== record.nuName) continue;
|
||||
|
||||
|
||||
if (nuRecord.configData) {
|
||||
// 再匹配设备名(deviceName)
|
||||
const configIndex = nuRecord.configData.findIndex(
|
||||
|
|
@ -559,8 +394,6 @@ function handleDelete(record: Recordable) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 同步更新表格
|
||||
loadLocalDataToTable();
|
||||
}
|
||||
|
|
@ -570,12 +403,7 @@ function getTableAction(record) {
|
|||
{
|
||||
label: '编辑',
|
||||
onClick: () => {
|
||||
if (record.dimension == '机构维度') {
|
||||
openDepartDrawer(record);
|
||||
}
|
||||
if (record.dimension == '区域维度') {
|
||||
openEditNuDrawer(record); // 改成调用新函数
|
||||
}
|
||||
openEditNuDrawer(record); // 改成调用新函数
|
||||
},
|
||||
ifShow: izPush.value == 'N'
|
||||
},
|
||||
|
|
@ -591,18 +419,13 @@ function getTableAction(record) {
|
|||
}
|
||||
|
||||
function handleEdit(record) {
|
||||
if (record.dimension == '机构维度') {
|
||||
openDepartDrawer(record);
|
||||
}
|
||||
if (record.dimension == '区域维度') {
|
||||
openNuDrawer(record);
|
||||
}
|
||||
openNuDrawer(record);
|
||||
}
|
||||
|
||||
function searchQuery() {
|
||||
// 1. 先缓存当前的查询条件(用于后续筛选本地数据)
|
||||
const currentQuery = { ...queryParam };
|
||||
|
||||
|
||||
// 更新必要的参数
|
||||
currentQuery.orgCode = orgCode.value;
|
||||
currentQuery.batchNo = batchNo.value;
|
||||
|
|
@ -618,16 +441,15 @@ function searchQuery() {
|
|||
|
||||
function searchReset() {
|
||||
// 1. 缓存当前状态(重置时查询条件为空)
|
||||
const currentQuery = {
|
||||
orgCode: orgCode.value,
|
||||
batchNo: batchNo.value
|
||||
const currentQuery = {
|
||||
orgCode: orgCode.value,
|
||||
batchNo: batchNo.value
|
||||
// 其他条件都是 undefined
|
||||
};
|
||||
|
||||
// 2. 重置表单
|
||||
formRef.value.resetFields();
|
||||
queryParam.nuName = undefined;
|
||||
queryParam.dimension = undefined;
|
||||
queryParam.deviceType = undefined;
|
||||
|
||||
// 3. 调用接口加载全部数据
|
||||
|
|
@ -645,53 +467,27 @@ function searchReset() {
|
|||
function mergeServerWithFilteredLocal(query: any) {
|
||||
const serverData = JSON.parse(JSON.stringify(getDataSource()));
|
||||
const idMap = new Map();
|
||||
|
||||
|
||||
serverData.forEach(item => {
|
||||
if (item.id != null) idMap.set(item.id, true);
|
||||
});
|
||||
|
||||
let finalData = [...serverData];
|
||||
|
||||
// ===== 机构维度:当有区域名称搜索时,跳过机构数据(已正确) =====
|
||||
if (!query.nuName) {
|
||||
const filteredDepart = localDepartList.value.filter(item => {
|
||||
const matchesDimension = !query.dimension || item.dimension === query.dimension;
|
||||
const matchesDeviceType = !query.deviceType || item.deviceType === query.deviceType;
|
||||
return matchesDimension && matchesDeviceType;
|
||||
});
|
||||
|
||||
filteredDepart.forEach(item => {
|
||||
if (item.id != null) {
|
||||
if (!idMap.has(item.id)) {
|
||||
finalData.push(item);
|
||||
idMap.set(item.id, true);
|
||||
}
|
||||
} else {
|
||||
const tempKey = `temp_${item.deviceName}_${item.dimension}`;
|
||||
if (!idMap.has(tempKey)) {
|
||||
finalData.push(item);
|
||||
idMap.set(tempKey, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ===== 修复点:区域维度必须按名称过滤 =====
|
||||
// 1. 先筛选出符合区域名称的区域
|
||||
let filteredNuList = [...localNuList.value];
|
||||
|
||||
|
||||
// 👇 新增:当存在区域名称查询时,过滤 localNuList
|
||||
if (query.nuName) {
|
||||
filteredNuList = filteredNuList.filter(nuItem =>
|
||||
filteredNuList = filteredNuList.filter(nuItem =>
|
||||
nuItem.nuName.toLowerCase().includes(query.nuName.toLowerCase())
|
||||
);
|
||||
}
|
||||
|
||||
// 2. 再处理筛选后的区域数据
|
||||
filteredNuList.forEach(nuItem => {
|
||||
// 2.1 按维度过滤(保留原有逻辑)
|
||||
if (query.dimension && nuItem.dimension !== query.dimension) return;
|
||||
|
||||
|
||||
// 2.2 筛选区域下的设备配置
|
||||
const filteredConfigs = (nuItem.configData || []).filter(config => {
|
||||
const matchesDeviceType = !query.deviceType || config.deviceType === query.deviceType;
|
||||
|
|
@ -724,7 +520,6 @@ function add(record) {
|
|||
izPush.value = record.izPush;
|
||||
|
||||
// 清空本地数据
|
||||
localDepartList.value = [];
|
||||
localNuList.value = [];
|
||||
|
||||
}
|
||||
|
|
@ -737,7 +532,6 @@ async function edit(record) {
|
|||
queryParam.batchNo = record.batchNo;
|
||||
|
||||
// 清空本地数据
|
||||
localDepartList.value = [];
|
||||
localNuList.value = [];
|
||||
cardQuantities.value.clear();
|
||||
|
||||
|
|
@ -759,20 +553,11 @@ function separateDataFromTable() {
|
|||
if (!tableData || tableData.length === 0) return;
|
||||
|
||||
// 清空现有数据
|
||||
localDepartList.value = [];
|
||||
localNuList.value = [];
|
||||
cardQuantities.value.clear();
|
||||
|
||||
// 遍历表格数据,按 dimension 分离
|
||||
// 遍历表格数据
|
||||
tableData.forEach(item => {
|
||||
if (item.dimension === '机构维度') {
|
||||
// 机构维度数据
|
||||
localDepartList.value.push({
|
||||
...item,
|
||||
dimension: '机构维度'
|
||||
});
|
||||
}
|
||||
else if (item.dimension === '区域维度') {
|
||||
// 区域维度数据:按 nuId 分组
|
||||
let nuRecord = localNuList.value.find(nu => nu.nuId === item.nuId);
|
||||
if (!nuRecord) {
|
||||
|
|
@ -780,7 +565,6 @@ function separateDataFromTable() {
|
|||
id: item.nuId,
|
||||
orgCode: item.orgCode,
|
||||
batchNo: item.batchNo,
|
||||
dimension: '区域维度',
|
||||
nuId: item.nuId,
|
||||
nuName: item.nuName,
|
||||
configData: []
|
||||
|
|
@ -799,8 +583,7 @@ function separateDataFromTable() {
|
|||
deviceType_dictText: item.deviceType_dictText, // 加上这行
|
||||
deviceModel: item.deviceModel,
|
||||
factory: item.factory,
|
||||
purchaseQuantity: item.purchaseQuantity,
|
||||
dimension: '区域维度'
|
||||
purchaseQuantity: item.purchaseQuantity
|
||||
});
|
||||
|
||||
// 填充到 cardQuantities 用于回显
|
||||
|
|
@ -815,173 +598,10 @@ function separateDataFromTable() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// ==================== 机构维度抽屉方法 ====================
|
||||
async function openDepartDrawer(record?: any) {
|
||||
await getDepartDeviceConfig();
|
||||
|
||||
if (record && record.id) {
|
||||
// 编辑模式
|
||||
departDrawer.title = '编辑机构维度';
|
||||
departDrawer.isUpdate = true;
|
||||
departDrawer.disableSubmit = false;
|
||||
|
||||
// 赋值表单数据
|
||||
Object.keys(departFormData).forEach((key) => {
|
||||
if (record.hasOwnProperty(key)) {
|
||||
departFormData[key] = record[key];
|
||||
}
|
||||
});
|
||||
|
||||
// 如果 record 中有 deviceType_dictText 则直接使用
|
||||
// 否则根据 deviceType 值设置对应的文本
|
||||
if (!departFormData.deviceType_dictText && departFormData.deviceType) {
|
||||
// 从设备配置或字典中查找文本
|
||||
const deviceConfig = departDeviceConfigs.value.find(
|
||||
item => item.deviceType === departFormData.deviceType
|
||||
);
|
||||
if (deviceConfig && deviceConfig.deviceTypeText) {
|
||||
departFormData.deviceType_dictText = deviceConfig.deviceTypeText;
|
||||
} else {
|
||||
departFormData.deviceType_dictText = departFormData.deviceType;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 新增模式
|
||||
departDrawer.title = '新增机构维度';
|
||||
departDrawer.isUpdate = false;
|
||||
departDrawer.disableSubmit = false;
|
||||
|
||||
departFormData.orgCode = orgCode.value;
|
||||
departFormData.batchNo = batchNo.value;
|
||||
departFormData.id = undefined;
|
||||
departFormData.deviceName = undefined;
|
||||
departFormData.deviceType = undefined;
|
||||
departFormData.deviceType_dictText = undefined;
|
||||
departFormData.deviceModel = undefined;
|
||||
departFormData.factory = undefined;
|
||||
departFormData.dimension = "机构维度";
|
||||
departFormData.purchaseQuantity = undefined;
|
||||
}
|
||||
|
||||
departDrawer.visible = true;
|
||||
}
|
||||
|
||||
function handleDepartDrawerCancel() {
|
||||
departDrawer.visible = false;
|
||||
resetDepartFields();
|
||||
}
|
||||
|
||||
async function handleDepartDrawerOk() {
|
||||
try {
|
||||
await validateDepart();
|
||||
} catch ({ errorFields }) {
|
||||
if (errorFields) {
|
||||
const firstField = errorFields[0];
|
||||
if (firstField && departFormRef.value) {
|
||||
departFormRef.value.scrollToField(firstField.name, { behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}
|
||||
return Promise.reject(errorFields);
|
||||
}
|
||||
|
||||
departDrawer.confirmLoading = true;
|
||||
|
||||
try {
|
||||
let model = { ...departFormData };
|
||||
if (model.deviceType && !model.deviceType_dictText) {
|
||||
const match = deviceTypeDicts.value?.find(d => d.value == model.deviceType);
|
||||
model.deviceType_dictText = match ? match.label : model.deviceType;
|
||||
}
|
||||
for (let data in model) {
|
||||
if (model[data] instanceof Array) {
|
||||
let valueType = getValueType(departFormRef.value?.getProps, data);
|
||||
if (valueType === 'string') {
|
||||
model[data] = model[data].join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 不再调用后端保存,改为保存到本地列表
|
||||
if (departDrawer.isUpdate || model.id) {
|
||||
// 编辑:更新本地列表中的数据
|
||||
const index = localDepartList.value.findIndex(item => item.id === model.id);
|
||||
if (index !== -1) {
|
||||
localDepartList.value[index] = { ...model };
|
||||
} else {
|
||||
// 如果有 id 但没找到,按新增处理
|
||||
model.id = `temp_depart_${tempIdCounter++}`;
|
||||
localDepartList.value.push(model);
|
||||
}
|
||||
} else {
|
||||
// 新增前检查是否存在同名设备(防止重复)
|
||||
const existingIndex = localDepartList.value.findIndex(
|
||||
item => item.deviceName === model.deviceName && item.dimension === "机构维度"
|
||||
);
|
||||
if (existingIndex !== -1) {
|
||||
// 存在则更新
|
||||
localDepartList.value[existingIndex] = { ...model, id: localDepartList.value[existingIndex].id };
|
||||
} else {
|
||||
// 不存在则新增
|
||||
model.id = `temp_depart_${tempIdCounter++}`;
|
||||
localDepartList.value.push(model);
|
||||
}
|
||||
}
|
||||
|
||||
handleDepartDrawerCancel();
|
||||
loadLocalDataToTable();
|
||||
createMessage.success('操作成功');
|
||||
} catch (error) {
|
||||
createMessage.error('保存失败');
|
||||
console.error(error);
|
||||
} finally {
|
||||
departDrawer.confirmLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function getDepartDeviceConfig() {
|
||||
let params = { 'dimension': '机构维度' };
|
||||
try {
|
||||
departDeviceConfigs.value = await configList(params);
|
||||
} catch (error) {
|
||||
departDeviceConfigs.value = [];
|
||||
}
|
||||
}
|
||||
|
||||
function handleDepartDeviceChange(value, option) {
|
||||
let vo = departDeviceConfigs.value.filter(item => item.deviceName === value);
|
||||
if (vo.length) {
|
||||
departFormData.deviceType = vo[0]["deviceType"];
|
||||
departFormData.deviceModel = vo[0]["deviceModel"];
|
||||
departFormData.factory = vo[0]["factory"];
|
||||
}
|
||||
|
||||
departFormData.deviceType_dictText = deviceTypeDicts.value.filter(item => item.value == departFormData.deviceType)[0]?.label || '';
|
||||
|
||||
// 检查该设备是否已在 localDepartList 中存在
|
||||
const existingItem = localDepartList.value.find(
|
||||
item => item.deviceName === value && item.dimension === "机构维度"
|
||||
);
|
||||
|
||||
if (existingItem) {
|
||||
// 存在则回填采购数量
|
||||
departFormData.purchaseQuantity = existingItem.purchaseQuantity;
|
||||
departFormData.id = existingItem.id;
|
||||
departDrawer.isUpdate = true;
|
||||
departDrawer.title = '编辑机构维度';
|
||||
} else {
|
||||
// 不存在则清空
|
||||
departFormData.purchaseQuantity = undefined;
|
||||
departFormData.id = undefined;
|
||||
departDrawer.isUpdate = false;
|
||||
departDrawer.title = '新增机构维度';
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== 区域维度抽屉方法 ====================
|
||||
async function openNuDrawer(record?: any) {
|
||||
await getNuDeviceConfig();
|
||||
|
|
@ -1052,7 +672,6 @@ async function handleNuDrawerOk() {
|
|||
deviceName: device.deviceName,
|
||||
deviceType: device.deviceType,
|
||||
deviceType_dictText: deviceTypeDicts.value?.find(d => d.value == device.deviceType)?.label || device.deviceType,
|
||||
dimension: '区域维度',
|
||||
deviceModel: device.deviceModel,
|
||||
factory: device.factory,
|
||||
purchaseQuantity: quantity
|
||||
|
|
@ -1070,7 +689,6 @@ async function handleNuDrawerOk() {
|
|||
const existingIndex = localNuList.value.findIndex(
|
||||
item => item.orgCode === orgCode.value &&
|
||||
item.batchNo === batchNo.value &&
|
||||
item.dimension === "区域维度" &&
|
||||
item.nuId === nu.nuId
|
||||
);
|
||||
|
||||
|
|
@ -1084,7 +702,6 @@ async function handleNuDrawerOk() {
|
|||
id: nu.nuId,
|
||||
orgCode: orgCode.value,
|
||||
batchNo: batchNo.value,
|
||||
dimension: "区域维度",
|
||||
nuId: nu.nuId,
|
||||
nuName: nu.nuName,
|
||||
configData: nuConfigData,
|
||||
|
|
@ -1098,7 +715,7 @@ async function handleNuDrawerOk() {
|
|||
const currentNuIds = nuInfos.value.map(n => n.nuId);
|
||||
for (let i = localNuList.value.length - 1; i >= 0; i--) {
|
||||
const item = localNuList.value[i];
|
||||
if (item.dimension === "区域维度" && item.orgCode === orgCode.value && item.batchNo === batchNo.value) {
|
||||
if (item.orgCode === orgCode.value && item.batchNo === batchNo.value) {
|
||||
if (!currentNuIds.includes(item.nuId)) {
|
||||
localNuList.value.splice(i, 1);
|
||||
}
|
||||
|
|
@ -1117,9 +734,8 @@ async function handleNuDrawerOk() {
|
|||
}
|
||||
|
||||
async function getNuDeviceConfig() {
|
||||
const params = { dimension: '区域维度' };
|
||||
try {
|
||||
nuDeviceConfigs.value = await configList(params);
|
||||
nuDeviceConfigs.value = await configList({});
|
||||
} catch (error) {
|
||||
nuDeviceConfigs.value = [];
|
||||
}
|
||||
|
|
@ -1199,17 +815,6 @@ function handleCardClick(nuId: string, event: Event) {
|
|||
* @returns 返回所有需要保存的数据
|
||||
*/
|
||||
async function submitForm() {
|
||||
const departData = localDepartList.value.map(item => ({
|
||||
id: item.id && typeof item.id === 'string' && item.id.startsWith('temp_') ? undefined : item.id,
|
||||
orgCode: item.orgCode,
|
||||
batchNo: item.batchNo,
|
||||
deviceName: item.deviceName,
|
||||
deviceType: item.deviceType,
|
||||
deviceModel: item.deviceModel,
|
||||
factory: item.factory,
|
||||
dimension: item.dimension,
|
||||
purchaseQuantity: item.purchaseQuantity
|
||||
}));
|
||||
|
||||
const nuData: any[] = [];
|
||||
for (const nuRecord of localNuList.value) {
|
||||
|
|
@ -1226,7 +831,6 @@ async function submitForm() {
|
|||
deviceType: config.deviceType,
|
||||
deviceModel: config.deviceModel,
|
||||
factory: config.factory,
|
||||
dimension: "区域维度",
|
||||
purchaseQuantity: config.purchaseQuantity
|
||||
});
|
||||
}
|
||||
|
|
@ -1234,20 +838,11 @@ async function submitForm() {
|
|||
}
|
||||
|
||||
const submitData = {
|
||||
departList: departData,
|
||||
nuList: nuData,
|
||||
batchNo: batchNo.value,
|
||||
orgCode: orgCode.value
|
||||
};
|
||||
|
||||
// 如果 departData 为空,添加一个只包含 orgCode 和 batchNo 的对象
|
||||
if (departData.length === 0) {
|
||||
departData.push({
|
||||
orgCode: orgCode.value,
|
||||
batchNo: batchNo.value
|
||||
});
|
||||
}
|
||||
|
||||
// 如果 nuData 为空,添加一个只包含 orgCode 和 batchNo 的对象
|
||||
if (nuData.length === 0) {
|
||||
nuData.push({
|
||||
|
|
@ -1256,9 +851,6 @@ async function submitForm() {
|
|||
});
|
||||
}
|
||||
|
||||
//机构维度
|
||||
await previewBatchSave(submitData.departList)
|
||||
|
||||
//区域维度
|
||||
await batchSave(submitData.nuList);
|
||||
|
||||
|
|
@ -1272,7 +864,6 @@ async function submitForm() {
|
|||
*/
|
||||
function getAllData() {
|
||||
return {
|
||||
departList: [...localDepartList.value],
|
||||
nuList: [...localNuList.value]
|
||||
};
|
||||
}
|
||||
|
|
@ -1281,7 +872,6 @@ function getAllData() {
|
|||
* 清空所有本地数据
|
||||
*/
|
||||
function clearAllData() {
|
||||
localDepartList.value = [];
|
||||
localNuList.value = [];
|
||||
loadLocalDataToTable();
|
||||
}
|
||||
|
|
@ -1303,7 +893,6 @@ const editNuFormData = reactive({
|
|||
deviceType: undefined,
|
||||
deviceModel: undefined,
|
||||
factory: undefined,
|
||||
dimension: '区域维度',
|
||||
purchaseQuantity: undefined
|
||||
});
|
||||
|
||||
|
|
@ -1334,7 +923,7 @@ async function handleEditNuDrawerOk() {
|
|||
editNuDrawer.confirmLoading = true;
|
||||
|
||||
try {
|
||||
if (editNuFormData.dimension === '区域维度') {
|
||||
|
||||
for (const nuRecord of localNuList.value) {
|
||||
if (nuRecord.configData && nuRecord.configData.length) {
|
||||
const configIndex = nuRecord.configData.findIndex(
|
||||
|
|
@ -1361,7 +950,7 @@ async function handleEditNuDrawerOk() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadLocalDataToTable();
|
||||
handleEditNuDrawerCancel();
|
||||
|
|
@ -1385,7 +974,6 @@ function openEditNuDrawer(record) {
|
|||
editNuFormData.deviceType = record.deviceType;
|
||||
editNuFormData.deviceModel = record.deviceModel;
|
||||
editNuFormData.factory = record.factory;
|
||||
editNuFormData.dimension = '区域维度';
|
||||
editNuFormData.purchaseQuantity = record.purchaseQuantity;
|
||||
}
|
||||
|
||||
|
|
@ -1627,4 +1215,4 @@ defineExpose({
|
|||
color: rgba(0, 0, 0, 0.88) !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,10 @@
|
|||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
departPreview = '/iot/device/manager/departPreview',
|
||||
nuPreview = '/iot/device/manager/nuPreview',
|
||||
configList = '/iot/device/config/queryList',
|
||||
nuList = '/iot/device/manager/nuList',
|
||||
savePreview = '/iot/device/manager/savePreview',
|
||||
updatePreview = '/iot/device/manager/updatePreview',
|
||||
previewBatchSave = '/iot/device/manager/previewBatchSave',
|
||||
deletePreview = '/iot/device/manager/deletePreview',
|
||||
batchSave = '/iot/device/manager/batchSave',
|
||||
queryQuantityByOrgCode = '/iot/device/manager/queryQuantityByOrgCode',
|
||||
getNuListByOrgCode = '/iot/device/manager/getNuListByOrgCode',
|
||||
}
|
||||
|
||||
|
|
@ -18,18 +12,9 @@ enum Api {
|
|||
* 列表
|
||||
* @param params
|
||||
*/
|
||||
export const departPreview = (params) => defHttp.get({ url: Api.departPreview, params });
|
||||
export const nuPreview = (params) => defHttp.get({ url: Api.nuPreview, params });
|
||||
export const configList = (params) => defHttp.get({ url: Api.configList, params });
|
||||
export const nuList = (params) => defHttp.get({ url: Api.nuList, params });
|
||||
/**
|
||||
* 新增机构
|
||||
* @param id
|
||||
*/
|
||||
export const savePreview = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.updatePreview : Api.savePreview;
|
||||
return defHttp.post({ url: url, params });
|
||||
};
|
||||
|
||||
/**
|
||||
* 批量保存
|
||||
|
|
@ -40,20 +25,6 @@ export const batchSave = (params) => {
|
|||
return defHttp.post({ url: Api.batchSave, params }, { isTransformResponse: false });
|
||||
};
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
*/
|
||||
export const deletePreview = (params) => defHttp.post({ url: Api.deletePreview, params });
|
||||
|
||||
export const queryQuantityByOrgCode = (params) => {
|
||||
return defHttp.get({ url: Api.queryQuantityByOrgCode, params });
|
||||
};
|
||||
|
||||
export const getNuListByOrgCode = (params) => {
|
||||
return defHttp.get({ url: Api.getNuListByOrgCode, params });
|
||||
};
|
||||
|
||||
export const previewBatchSave = (params) => {
|
||||
return defHttp.post({ url: Api.previewBatchSave, params }, { isTransformResponse: false });
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,12 +37,6 @@ export const departColumns: BasicColumn[] = [
|
|||
dataIndex: 'factory',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '设备维度',
|
||||
align: "center",
|
||||
dataIndex: 'dimension',
|
||||
width: 80
|
||||
},
|
||||
{
|
||||
title: '采购数量',
|
||||
align: "center",
|
||||
|
|
@ -74,7 +68,6 @@ export const nuColumns: BasicColumn[] = [
|
|||
return record.nuId;
|
||||
}
|
||||
},
|
||||
width: 120
|
||||
},
|
||||
{
|
||||
title: '区域名称',
|
||||
|
|
@ -91,32 +84,22 @@ export const nuColumns: BasicColumn[] = [
|
|||
{
|
||||
title: '设备类型',
|
||||
align: "center",
|
||||
dataIndex: 'deviceType_dictText',
|
||||
width: 150
|
||||
dataIndex: 'deviceType_dictText'
|
||||
},
|
||||
{
|
||||
title: '设备型号',
|
||||
align: "center",
|
||||
dataIndex: 'deviceModel',
|
||||
width: 150
|
||||
dataIndex: 'deviceModel'
|
||||
},
|
||||
{
|
||||
title: '生产厂家',
|
||||
align: "center",
|
||||
dataIndex: 'factory',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
title: '设备维度',
|
||||
align: "center",
|
||||
dataIndex: 'dimension',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '采购数量',
|
||||
align: "center",
|
||||
dataIndex: 'purchaseQuantity',
|
||||
width: 100
|
||||
dataIndex: 'purchaseQuantity'
|
||||
},
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue