添加电能表同步功能及对应的同步日志
This commit is contained in:
parent
fc25437dc3
commit
f5474a28a3
|
@ -55,6 +55,7 @@
|
|||
<DepartUtilsList ref="departUtilsModal" @success="handleParams"></DepartUtilsList>
|
||||
<HldyUtilsModal ref="hldyUtilsModal" @success="handleHldyParams" ></HldyUtilsModal>
|
||||
<ApiLogModal ref="apiLogModal"></ApiLogModal>
|
||||
<NuIotTqElectricitySyncLogListModal ref="syncLogModal"></NuIotTqElectricitySyncLogListModal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -71,11 +72,13 @@
|
|||
import DepartUtilsList from "@/views/utils/departUtils/DepartUtilsModal.vue";
|
||||
import HldyUtilsModal from "@/views/utils/nuUtils/HldyUtilsModal.vue";
|
||||
import ApiLogModal from "@/views/iot/tq/electricity/apilog/ApiLogModal.vue";
|
||||
import NuIotTqElectricitySyncLogListModal from "/@/views/iot/tq/nuIotTqElectricitySyncLog/NuIotTqElectricitySyncLogListModal.vue";
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
const queryParam = reactive<any>({});
|
||||
const departUtilsModal = ref();
|
||||
const apiLogModal = ref();
|
||||
const syncLogModal = ref();
|
||||
const hldyUtilsModal = ref();
|
||||
//注册model
|
||||
const [registerModal, {openModal}] = useModal();
|
||||
|
@ -116,6 +119,7 @@ import { defHttp } from '/@/utils/http/axios';
|
|||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
//机构回调
|
||||
function handleParams(params){
|
||||
console.log("🚀 ~ handleParams ~ params:", params)
|
||||
defHttp.post({
|
||||
|
@ -126,7 +130,7 @@ import { defHttp } from '/@/utils/http/axios';
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
//护理单元回调
|
||||
function handleHldyParams(params){
|
||||
console.log("🚀 ~ handleParams ~ params:", params)
|
||||
defHttp.post({
|
||||
|
@ -136,7 +140,11 @@ import { defHttp } from '/@/utils/http/axios';
|
|||
console.log("🚀 ~ getTableAction ~ res:", res)
|
||||
})
|
||||
}
|
||||
|
||||
//同步
|
||||
function handleSync(record: Recordable){
|
||||
syncLogModal.value.disableSubmit = true;
|
||||
syncLogModal.value.init(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
|
@ -163,6 +171,10 @@ import { defHttp } from '/@/utils/http/axios';
|
|||
placement: 'topLeft',
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '同步',
|
||||
onClick: handleSync.bind(null, record),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,72 @@
|
|||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from "/@/hooks/web/useMessage";
|
||||
|
||||
const { createConfirm } = useMessage();
|
||||
|
||||
enum Api {
|
||||
list = '/nuIotTqElectricitySyncLog/nuIotTqElectricitySyncLog/list',
|
||||
save='/nuIotTqElectricitySyncLog/nuIotTqElectricitySyncLog/add',
|
||||
edit='/nuIotTqElectricitySyncLog/nuIotTqElectricitySyncLog/edit',
|
||||
deleteOne = '/nuIotTqElectricitySyncLog/nuIotTqElectricitySyncLog/delete',
|
||||
deleteBatch = '/nuIotTqElectricitySyncLog/nuIotTqElectricitySyncLog/deleteBatch',
|
||||
importExcel = '/nuIotTqElectricitySyncLog/nuIotTqElectricitySyncLog/importExcel',
|
||||
exportXls = '/nuIotTqElectricitySyncLog/nuIotTqElectricitySyncLog/exportXls',
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出api
|
||||
* @param params
|
||||
*/
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
/**
|
||||
* 导入api
|
||||
*/
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
/**
|
||||
* 列表接口
|
||||
* @param params
|
||||
*/
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
/**
|
||||
* 删除单个
|
||||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const deleteOne = (params,handleSuccess) => {
|
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
createConfirm({
|
||||
iconType: 'warning',
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或者更新
|
||||
* @param params
|
||||
* @param isUpdate
|
||||
*/
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url: url, params }, { isTransformResponse: false });
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
import {BasicColumn} from '/@/components/Table';
|
||||
import {FormSchema} from '/@/components/Table';
|
||||
import { rules} from '/@/utils/helper/validator';
|
||||
import { render } from '/@/utils/common/renderUtils';
|
||||
import { getWeekMonthQuarterYear } from '/@/utils';
|
||||
//列表数据
|
||||
export const columns: BasicColumn[] = [
|
||||
{
|
||||
title: '同步时间',
|
||||
align: "center",
|
||||
dataIndex: 'createTime'
|
||||
},
|
||||
{
|
||||
title: '同步类型',
|
||||
align: "center",
|
||||
dataIndex: 'syncType'
|
||||
},
|
||||
{
|
||||
title: '原机构名称',
|
||||
align: "center",
|
||||
dataIndex: 'orgName'
|
||||
},
|
||||
{
|
||||
title: '原机构编码',
|
||||
align: "center",
|
||||
dataIndex: 'orgCode',
|
||||
defaultHidden: true
|
||||
},
|
||||
{
|
||||
title: '新机构名称',
|
||||
align: "center",
|
||||
dataIndex: 'newOrgName'
|
||||
},
|
||||
{
|
||||
title: '新机构编码',
|
||||
align: "center",
|
||||
dataIndex: 'newOrgCode',
|
||||
defaultHidden: true
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
align: "center",
|
||||
dataIndex: 'status'
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
align: "center",
|
||||
dataIndex: 'content'
|
||||
},
|
||||
{
|
||||
title: '服务类型',
|
||||
align: "center",
|
||||
dataIndex: 'serverType'
|
||||
},
|
||||
];
|
||||
|
||||
// 高级查询数据
|
||||
export const superQuerySchema = {
|
||||
mainName: {title: '主表名称',order: 0,view: 'text', type: 'string',},
|
||||
syncType: {title: '同步类型',order: 1,view: 'text', type: 'string',},
|
||||
orgName: {title: '原机构名称',order: 2,view: 'text', type: 'string',},
|
||||
orgCode: {title: '原机构编码',order: 3,view: 'text', type: 'string',},
|
||||
newOrgName: {title: '新机构名称',order: 4,view: 'text', type: 'string',},
|
||||
newOrgCode: {title: '新机构编码',order: 5,view: 'text', type: 'string',},
|
||||
status: {title: '状态',order: 6,view: 'text', type: 'string',},
|
||||
content: {title: '备注',order: 7,view: 'text', type: 'string',},
|
||||
serverType: {title: '服务类型',order: 8,view: 'text', type: 'string',},
|
||||
};
|
|
@ -0,0 +1,169 @@
|
|||
<template>
|
||||
<div class="p-2">
|
||||
<!--查询区域-->
|
||||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="syncType">
|
||||
<template #label><span title="同步类型">同步类型</span></template>
|
||||
<a-input placeholder="请输入同步类型" v-model:value="queryParam.syncType" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :lg="6">
|
||||
<a-form-item name="status">
|
||||
<template #label><span title="状态">状态</span></template>
|
||||
<a-input placeholder="请输入状态" v-model:value="queryParam.status" allow-clear ></a-input>
|
||||
</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" @click="handleSync" preIcon="ant-design:sync-outlined"> 同步</a-button>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
|
||||
</template>
|
||||
<template v-slot:bodyCell="{ column, record, index, text }">
|
||||
</template>
|
||||
</BasicTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="nuIotTqElectricitySyncLog-nuIotTqElectricitySyncLog" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns, superQuerySchema } from './NuIotTqElectricitySyncLog.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './NuIotTqElectricitySyncLog.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import NuIotTqElectricitySyncLogModal from './components/NuIotTqElectricitySyncLogModal.vue'
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
const syncInfo = ref<any>({});
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const userStore = useUserStore();
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '同步日志',
|
||||
api: list,
|
||||
columns,
|
||||
canResize:false,
|
||||
useSearchForm: false,
|
||||
immediate: false,
|
||||
showIndexColumn: true,
|
||||
showActionColumn: false,
|
||||
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:4,
|
||||
xl:6,
|
||||
xxl:4
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: 24,
|
||||
sm: 20,
|
||||
});
|
||||
|
||||
/**
|
||||
* 同步事件
|
||||
*/
|
||||
function handleSync() {
|
||||
defHttp.post({
|
||||
url: '/iot/tq/electricityMeter/syncElectricity',
|
||||
params: syncInfo.value,
|
||||
}).then((res) => {
|
||||
reload();
|
||||
});
|
||||
|
||||
}
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function searchQuery() {
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
formRef.value.resetFields();
|
||||
selectedRowKeys.value = [];
|
||||
//刷新数据
|
||||
reload();
|
||||
}
|
||||
|
||||
|
||||
//初始化
|
||||
function init(record){
|
||||
console.log("🚀 ~ init ~ record:", record)
|
||||
syncInfo.value = record;
|
||||
queryParam.mainId = record.id;
|
||||
reload();
|
||||
}
|
||||
|
||||
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>
|
|
@ -0,0 +1,66 @@
|
|||
<template>
|
||||
<j-modal :title="title" width="80%" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<NuIotTqElectricitySyncLogList ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></NuIotTqElectricitySyncLogList>
|
||||
</j-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineExpose } from 'vue';
|
||||
import NuIotTqElectricitySyncLogList from './NuIotTqElectricitySyncLogList.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 emit = defineEmits(['register', 'success']);
|
||||
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param record
|
||||
*/
|
||||
function init(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;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
init,
|
||||
disableSubmit,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
/**隐藏样式-modal确定按钮 */
|
||||
.jee-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
||||
<style lang="less" scoped></style>
|
|
@ -0,0 +1,187 @@
|
|||
<template>
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<JFormContainer :disabled="disabled">
|
||||
<template #detail>
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" name="NuIotTqElectricitySyncLogForm">
|
||||
<a-row>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="主表名称" v-bind="validateInfos.mainName" id="NuIotTqElectricitySyncLogForm-mainName" name="mainName">
|
||||
<a-input v-model:value="formData.mainName" placeholder="请输入主表名称" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="同步类型" v-bind="validateInfos.syncType" id="NuIotTqElectricitySyncLogForm-syncType" name="syncType">
|
||||
<a-input v-model:value="formData.syncType" placeholder="请输入同步类型" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="原机构名称" v-bind="validateInfos.orgName" id="NuIotTqElectricitySyncLogForm-orgName" name="orgName">
|
||||
<a-input v-model:value="formData.orgName" placeholder="请输入原机构名称" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="原机构编码" v-bind="validateInfos.orgCode" id="NuIotTqElectricitySyncLogForm-orgCode" name="orgCode">
|
||||
<a-input v-model:value="formData.orgCode" placeholder="请输入原机构编码" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="新机构名称" v-bind="validateInfos.newOrgName" id="NuIotTqElectricitySyncLogForm-newOrgName" name="newOrgName">
|
||||
<a-input v-model:value="formData.newOrgName" placeholder="请输入新机构名称" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="新机构编码" v-bind="validateInfos.newOrgCode" id="NuIotTqElectricitySyncLogForm-newOrgCode" name="newOrgCode">
|
||||
<a-input v-model:value="formData.newOrgCode" placeholder="请输入新机构编码" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="状态" v-bind="validateInfos.status" id="NuIotTqElectricitySyncLogForm-status" name="status">
|
||||
<a-input v-model:value="formData.status" placeholder="请输入状态" allow-clear ></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="备注" v-bind="validateInfos.content" id="NuIotTqElectricitySyncLogForm-content" name="content">
|
||||
<a-input v-model:value="formData.content" placeholder="请输入备注" allow-clear ></a-input>
|
||||
</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 } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { getValueType } from '/@/utils';
|
||||
import { saveOrUpdate } from '../NuIotTqElectricitySyncLog.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
import JFormContainer from '/@/components/Form/src/container/JFormContainer.vue';
|
||||
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: '',
|
||||
mainName: '',
|
||||
syncType: '',
|
||||
orgName: '',
|
||||
orgCode: '',
|
||||
newOrgName: '',
|
||||
newOrgCode: '',
|
||||
status: '',
|
||||
content: '',
|
||||
});
|
||||
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 = reactive({
|
||||
});
|
||||
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;
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add() {
|
||||
edit({});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function edit(record) {
|
||||
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;
|
||||
const isUpdate = ref<boolean>(false);
|
||||
//时间格式化
|
||||
let model = formData;
|
||||
if (model.id) {
|
||||
isUpdate.value = true;
|
||||
}
|
||||
//循环数据
|
||||
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(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
await saveOrUpdate(model, isUpdate.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
createMessage.success(res.message);
|
||||
emit('ok');
|
||||
} else {
|
||||
createMessage.warning(res.message);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
confirmLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
submitForm,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.antd-modal-form {
|
||||
padding: 14px;
|
||||
}
|
||||
</style>
|
|
@ -0,0 +1,77 @@
|
|||
<template>
|
||||
<j-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<NuIotTqElectricitySyncLogForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></NuIotTqElectricitySyncLogForm>
|
||||
</j-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineExpose } from 'vue';
|
||||
import NuIotTqElectricitySyncLogForm from './NuIotTqElectricitySyncLogForm.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 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.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>
|
Loading…
Reference in New Issue