|
|
@ -3,50 +3,87 @@ |
|
|
|
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
<a-row> |
|
|
|
<a-col :span="12"> |
|
|
|
<a-form-item label="设备Id" v-bind="validateInfos.deviceId"> |
|
|
|
<a-input v-model:value="formData.deviceId" placeholder="请输入设备Id" :disabled="disabled"></a-input> |
|
|
|
<a-form-item label="申请设备" v-bind="validateInfos.deviceId"> |
|
|
|
<a-tree-select |
|
|
|
ref="deviceTree" |
|
|
|
v-model:value="formData.deviceId" |
|
|
|
allow-clear |
|
|
|
:treeData="nodeTree" |
|
|
|
:disabled="disabled" |
|
|
|
placeholder="请选择申请设备" |
|
|
|
@change="handleChange" |
|
|
|
> |
|
|
|
</a-tree-select> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="12"> |
|
|
|
<a-form-item label="设备名称" v-bind="validateInfos.deviceName"> |
|
|
|
<a-input v-model:value="formData.deviceName" placeholder="请输入设备名称" :disabled="disabled"></a-input> |
|
|
|
<a-form-item label="设备编码"> |
|
|
|
<a-input v-model:value="deviceCode" :disabled="true" placeholder="未选择申请设备"></a-input> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="12"> |
|
|
|
<a-form-item label="设备类型" v-bind="validateInfos.deviceType"> |
|
|
|
<j-dict-select-tag v-model:value="formData.deviceType" dictCode="ms_device_type" placeholder="请选择设备类型" |
|
|
|
:disabled="disabled" :getPopupContainer="(triggerNode: any) => triggerNode.parentNode" |
|
|
|
:string-to-number="true" /> |
|
|
|
<a-form-item label="部署位置"> |
|
|
|
<a-input v-model:value="devicePosition" :disabled="true" placeholder="未选择申请设备"></a-input> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="12"> |
|
|
|
<!-- <a-col :span="12"> |
|
|
|
<a-form-item label="设备类型" v-bind="validateInfos.deviceType"> |
|
|
|
<j-dict-select-tag |
|
|
|
v-model:value="formData.deviceType" |
|
|
|
dictCode="ms_device_type" |
|
|
|
placeholder="请选择设备类型" |
|
|
|
:disabled="disabled" |
|
|
|
:getPopupContainer="(triggerNode: any) => triggerNode.parentNode" |
|
|
|
:string-to-number="true" |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-col> --> |
|
|
|
<!-- <a-col :span="12"> |
|
|
|
<a-form-item label="入网时间" v-bind="validateInfos.importDate"> |
|
|
|
<a-date-picker placeholder="请选择入网时间" v-model:value="formData.importDate" showTime |
|
|
|
value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="disabled" /> |
|
|
|
<a-date-picker |
|
|
|
placeholder="请选择入网时间" |
|
|
|
v-model:value="formData.importDate" |
|
|
|
showTime |
|
|
|
value-format="YYYY-MM-DD HH:mm:ss" |
|
|
|
style="width: 100%" |
|
|
|
:disabled="disabled" |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="12"> |
|
|
|
<a-form-item label="状态" v-bind="validateInfos.status"> |
|
|
|
<j-dict-select-tag type="list" v-model:value="formData.status" dictCode="ms_approval_status" |
|
|
|
:string-to-number="true" placeholder="请选择状态" :disabled="disabled" /> |
|
|
|
<j-dict-select-tag |
|
|
|
type="list" |
|
|
|
v-model:value="formData.status" |
|
|
|
dictCode="ms_approval_status" |
|
|
|
:string-to-number="true" |
|
|
|
placeholder="请选择状态" |
|
|
|
:disabled="disabled" |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="12"> |
|
|
|
<a-form-item label="许可证编号" v-bind="validateInfos.licenseNo"> |
|
|
|
<a-input v-model:value="formData.licenseNo" placeholder="请输入许可证编号" :disabled="disabled"></a-input> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="12"> |
|
|
|
</a-col> --> |
|
|
|
<!-- <a-col :span="12"> |
|
|
|
<a-form-item label="审批人" v-bind="validateInfos.auditManid"> |
|
|
|
<a-input v-model:value="formData.auditManid" placeholder="请输入审批人" :disabled="disabled"></a-input> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="12"> |
|
|
|
</a-col> --> |
|
|
|
<!-- <a-col :span="12"> |
|
|
|
<a-form-item label="审批时间" v-bind="validateInfos.auditDate"> |
|
|
|
<a-date-picker placeholder="请选择审批时间" v-model:value="formData.auditDate" showTime |
|
|
|
value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" :disabled="disabled" /> |
|
|
|
<a-date-picker |
|
|
|
placeholder="请选择审批时间" |
|
|
|
v-model:value="formData.auditDate" |
|
|
|
showTime |
|
|
|
value-format="YYYY-MM-DD HH:mm:ss" |
|
|
|
style="width: 100%" |
|
|
|
:disabled="disabled" |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
</a-col> --> |
|
|
|
<a-col :span="12"> |
|
|
|
<a-form-item label="备注" v-bind="validateInfos.remark"> |
|
|
|
<a-input v-model:value="formData.remark" placeholder="请输入备注" :disabled="disabled"></a-input> |
|
|
@ -58,154 +95,304 @@ |
|
|
|
</template> |
|
|
|
|
|
|
|
<script lang="ts" setup> |
|
|
|
import { ref, reactive, nextTick, computed, onMounted, watch } from 'vue'; |
|
|
|
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue'; |
|
|
|
import { defHttp } from '/@/utils/http/axios'; |
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
|
|
import { getValueType } from '/@/utils'; |
|
|
|
import { saveOrUpdate } from '../MsIotImportLicense.api'; |
|
|
|
import { Form } from 'ant-design-vue'; |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import { ref, reactive, nextTick, computed, onMounted, watch } from 'vue'; |
|
|
|
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue'; |
|
|
|
import { defHttp } from '/@/utils/http/axios'; |
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
|
|
import { getValueType } from '/@/utils'; |
|
|
|
import { saveOrUpdate } from '../MsIotImportLicense.api'; |
|
|
|
import { Form } from 'ant-design-vue'; |
|
|
|
import dayjs from 'dayjs'; |
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
formDisabled: { type: Boolean, default: false }, |
|
|
|
formData: { type: Object, default: () => { } }, |
|
|
|
formBpm: { type: Boolean, default: true }, |
|
|
|
//补充信息 部分字段禁用 |
|
|
|
supplement: { |
|
|
|
type: Boolean, |
|
|
|
default: false, |
|
|
|
required: false, |
|
|
|
}, |
|
|
|
}); |
|
|
|
const formRef = ref(); |
|
|
|
const useForm = Form.useForm; |
|
|
|
const emit = defineEmits(['register', 'ok']); |
|
|
|
const formData = reactive<Record<string, any>>({ |
|
|
|
id: '', |
|
|
|
deviceId: '', |
|
|
|
deviceName: '', |
|
|
|
deviceType: undefined, |
|
|
|
licenseNo: '', |
|
|
|
importDate: '', |
|
|
|
status: undefined, |
|
|
|
auditManid: '', |
|
|
|
auditDate: '', |
|
|
|
remark: '', |
|
|
|
}); |
|
|
|
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 = { |
|
|
|
deviceId: [{ required: true, message: '请输入设备Id!' },], |
|
|
|
deviceName: [{ required: true, message: '请输入设备名称!' },], |
|
|
|
deviceType: [{ required: true, message: '请选择设备类型!' },], |
|
|
|
licenseNo: [{ required: true, message: '请输入许可证编号!' },], |
|
|
|
importDate: [{ required: true, message: '请输入入网时间!' },], |
|
|
|
status: [{ required: true, message: '请选择状态!' }], |
|
|
|
auditManid: [{ required: true, message: '请输入审批人!' },], |
|
|
|
auditDate: [{ required: true, message: '请输入审批时间!' },], |
|
|
|
}; |
|
|
|
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true }); |
|
|
|
// 登录用户信息 |
|
|
|
import { useUserStore } from '/@/store/modules/user'; |
|
|
|
const userStore = useUserStore(); |
|
|
|
// 获取当前权限下的场景id |
|
|
|
const sceneId = userStore.userInfo?.sceneId; |
|
|
|
// 场景列表 |
|
|
|
const sceneList: any = []; |
|
|
|
// 防区列表 |
|
|
|
const areaList: any = []; |
|
|
|
// 站点列表 |
|
|
|
const stationList: any = []; |
|
|
|
// 设备列表 |
|
|
|
const newDeviceList: any = []; |
|
|
|
// 获取当前场景及子场景信息 |
|
|
|
function getCurrentScene() { |
|
|
|
return defHttp.get( |
|
|
|
{ url: '/military/msMapScene/list', params: { sceneId: sceneId + '*', pageNo: 1, pageSize: 9999 } }, |
|
|
|
{ isTransformResponse: false } |
|
|
|
); |
|
|
|
} |
|
|
|
// 获取当前场景(包括其子场景)下的所有防区 |
|
|
|
function getCurrentSceneArea() { |
|
|
|
return defHttp.get({ url: '/military/msMapLine/list', params: { pageNo: 1, pageSize: 9999 } }, { isTransformResponse: false }); |
|
|
|
} |
|
|
|
// 获取当前防区下的所有站点 |
|
|
|
function getCurrentAreaStation() { |
|
|
|
return defHttp.get({ url: '/military/camera/site/list', params: { pageNo: 1, pageSize: 9999 } }, { isTransformResponse: false }); |
|
|
|
} |
|
|
|
// 获取当前站点下的所有未通过许可设备 |
|
|
|
function getCurrentStationDevice() { |
|
|
|
return defHttp.get({ url: '/military/dtDeviceInfo/list', params: { isAudit: 0, pageNo: 1, pageSize: 9999 } }, { isTransformResponse: false }); |
|
|
|
} |
|
|
|
|
|
|
|
// 表单禁用 |
|
|
|
const disabled = computed(() => { |
|
|
|
if (props.formBpm === true) { |
|
|
|
if (props.formData.disabled === false) { |
|
|
|
return false; |
|
|
|
// 树状设备数据 |
|
|
|
const nodeTree: any = ref([]); |
|
|
|
// 设备编码 |
|
|
|
const deviceCode: any = ref(''); |
|
|
|
// 部署位置 |
|
|
|
const devicePosition: any = ref(''); |
|
|
|
|
|
|
|
// 获取申请设备其他信息 |
|
|
|
function handleChange(value, label, extra) { |
|
|
|
if (value) { |
|
|
|
defHttp |
|
|
|
.get({ url: '/military/dtDeviceInfo/queryById', params: { id: value, pageNo: 1, pageSize: 9999 } }, { isTransformResponse: false }) |
|
|
|
.then((res) => { |
|
|
|
let deviceData = res.result; |
|
|
|
deviceCode.value = deviceData.deviceCode; |
|
|
|
devicePosition.value = deviceData.devicePosition; |
|
|
|
formData.deviceName = deviceData.deviceName; |
|
|
|
}); |
|
|
|
} else { |
|
|
|
return true; |
|
|
|
deviceCode.value = ''; |
|
|
|
devicePosition.value = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
return props.formDisabled; |
|
|
|
}); |
|
|
|
//补充信息 部分字段禁用 |
|
|
|
const supplementDisable = computed(() => { |
|
|
|
return props.supplement; |
|
|
|
}); |
|
|
|
|
|
|
|
watch(() => formData.status, (val) => { |
|
|
|
if (val == 2) { |
|
|
|
formData.licenseNo = null |
|
|
|
} |
|
|
|
else if (val == 1) { |
|
|
|
formData.licenseNo = new Date().getTime() + Math.floor(Math.random() * 100) //自动注入许可证编号 |
|
|
|
onMounted(() => { |
|
|
|
// 将数据转化为树状结构 |
|
|
|
getCurrentScene().then((res) => { |
|
|
|
sceneList.value = res.result.records; |
|
|
|
getCurrentSceneArea().then((res1) => { |
|
|
|
areaList.value = res1.result.records; |
|
|
|
getCurrentAreaStation().then((res2) => { |
|
|
|
stationList.value = res2.result.records; |
|
|
|
getCurrentStationDevice().then((res3) => { |
|
|
|
newDeviceList.value = res3.result.records; |
|
|
|
|
|
|
|
// 定义一个空数组作为树状数组的根节点 |
|
|
|
const tree: any = []; |
|
|
|
//遍历场景列表,查找当前场景(及子场景)数据 |
|
|
|
sceneList.value.forEach((row) => { |
|
|
|
const node = { title: row.sceneName, value: row.sceneId, children: [] }; |
|
|
|
tree.push(node); |
|
|
|
}); |
|
|
|
// 遍历防区列表,查找对应场景下的数据 |
|
|
|
areaList.value.forEach((row) => { |
|
|
|
const parentNode = tree.find((node) => node.value === row.sceneId); |
|
|
|
if (parentNode) { |
|
|
|
const node = { title: row.name, value: row.id, children: [] }; |
|
|
|
parentNode.children.push(node); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 遍历站点列表,查找对应防区下的数据 |
|
|
|
stationList.value.forEach((row) => { |
|
|
|
const parentNodes = tree.map((node) => node.children).flat(); |
|
|
|
const parentNode = parentNodes.find((node) => node.value === row.lineId); |
|
|
|
if (parentNode) { |
|
|
|
const node = { title: row.sitename, value: row.id, children: [] }; |
|
|
|
parentNode.children.push(node); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 遍历相机列表,查找对应站点下的数据 |
|
|
|
newDeviceList.value.forEach((row) => { |
|
|
|
// 筛选孙子节点 |
|
|
|
const parentNodes = tree.flatMap((node) => node.children).flatMap((node) => node.children); |
|
|
|
const parentNode = parentNodes.find((node) => node.value === row.deviceOwnerId); |
|
|
|
if (parentNode) { |
|
|
|
const node = { title: row.deviceName, value: row.id, children: null }; |
|
|
|
parentNode.children.push(node); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 转化为ant tree-select结构 |
|
|
|
nodeTree.value = handleCameraTree(tree); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// 处理相机树状数据 |
|
|
|
function handleCameraTree(data, index = undefined) { |
|
|
|
let arr: any = []; |
|
|
|
for (let i = 0; i < data.length; i++) { |
|
|
|
let obj: any = {}; |
|
|
|
let item = data[i]; |
|
|
|
obj.title = item.title; |
|
|
|
obj.value = obj.key = item.value; |
|
|
|
obj.disabled = item.children?.length >= 0 ? true : false; |
|
|
|
if (item.children && item.children.length > 0) { |
|
|
|
obj.children = []; |
|
|
|
let indexValue: any = index ? index + '-' + (i + 1) : i + 1; |
|
|
|
obj.children = handleCameraTree(item.children, indexValue); |
|
|
|
} |
|
|
|
arr.push(obj); |
|
|
|
} |
|
|
|
return arr; |
|
|
|
} |
|
|
|
}) |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增 |
|
|
|
*/ |
|
|
|
function add() { |
|
|
|
edit({}); |
|
|
|
} |
|
|
|
const props = defineProps({ |
|
|
|
formDisabled: { type: Boolean, default: false }, |
|
|
|
formData: { type: Object, default: () => {} }, |
|
|
|
formBpm: { type: Boolean, default: true }, |
|
|
|
//补充信息 部分字段禁用 |
|
|
|
supplement: { |
|
|
|
type: Boolean, |
|
|
|
default: false, |
|
|
|
required: false, |
|
|
|
}, |
|
|
|
}); |
|
|
|
const formRef = ref(); |
|
|
|
const useForm = Form.useForm; |
|
|
|
const emit = defineEmits(['register', 'ok']); |
|
|
|
const formData = reactive<Record<string, any>>({ |
|
|
|
id: '', |
|
|
|
deviceId: undefined, |
|
|
|
deviceName: '', |
|
|
|
deviceType: undefined, |
|
|
|
licenseNo: '', |
|
|
|
importDate: '', |
|
|
|
status: undefined, |
|
|
|
auditManid: '', |
|
|
|
auditDate: '', |
|
|
|
remark: '', |
|
|
|
}); |
|
|
|
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 = { |
|
|
|
deviceId: [{ required: true, message: '请选择申请设备!', trigger: 'blur' }], |
|
|
|
// deviceName: [{ required: true, message: '请输入设备名称!' }], |
|
|
|
// deviceType: [{ required: true, message: '请选择设备类型!' }], |
|
|
|
// licenseNo: [{ required: true, message: '请输入许可证编号!' }], |
|
|
|
// importDate: [{ required: true, message: '请输入入网时间!' }], |
|
|
|
// status: [{ required: true, message: '请选择状态!' }], |
|
|
|
// auditManid: [{ required: true, message: '请输入审批人!' }], |
|
|
|
// auditDate: [{ required: true, message: '请输入审批时间!' }], |
|
|
|
}; |
|
|
|
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true }); |
|
|
|
|
|
|
|
/** |
|
|
|
* 编辑 |
|
|
|
*/ |
|
|
|
function edit(record) { |
|
|
|
nextTick(() => { |
|
|
|
resetFields(); |
|
|
|
//赋值 |
|
|
|
Object.assign(formData, record); |
|
|
|
// formData.licenseNo = new Date().getTime() + Math.floor(Math.random() * 100) //自动注入许可证编号 |
|
|
|
formData.auditDate = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss') //自动注入审批时间 |
|
|
|
// formData.status = 1 //自动注入审批状态 |
|
|
|
// 表单禁用 |
|
|
|
const disabled = computed(() => { |
|
|
|
if (props.formBpm === true) { |
|
|
|
if (props.formData.disabled === false) { |
|
|
|
return false; |
|
|
|
} else { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return props.formDisabled; |
|
|
|
}); |
|
|
|
//补充信息 部分字段禁用 |
|
|
|
const supplementDisable = computed(() => { |
|
|
|
return props.supplement; |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交数据 |
|
|
|
*/ |
|
|
|
async function submitForm() { |
|
|
|
// 触发表单验证 |
|
|
|
await validate(); |
|
|
|
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(','); |
|
|
|
watch( |
|
|
|
() => formData.status, |
|
|
|
(val) => { |
|
|
|
if (val == 2) { |
|
|
|
formData.licenseNo = null; |
|
|
|
} else if (val == 1) { |
|
|
|
formData.licenseNo = new Date().getTime() + Math.floor(Math.random() * 100); //自动注入许可证编号 |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增 |
|
|
|
*/ |
|
|
|
function add() { |
|
|
|
edit({ |
|
|
|
status: 0, |
|
|
|
}); |
|
|
|
} |
|
|
|
await saveOrUpdate(model, isUpdate.value) |
|
|
|
.then((res) => { |
|
|
|
if (res.success) { |
|
|
|
createMessage.success(res.message); |
|
|
|
emit('ok'); |
|
|
|
} else { |
|
|
|
createMessage.warning(res.message); |
|
|
|
|
|
|
|
/** |
|
|
|
* 编辑 |
|
|
|
*/ |
|
|
|
function edit(record) { |
|
|
|
nextTick(() => { |
|
|
|
resetFields(); |
|
|
|
//赋值 |
|
|
|
Object.assign(formData, record); |
|
|
|
formData.auditDate = dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'); //自动注入审批时间 |
|
|
|
// 是否为新增 |
|
|
|
if (formData.id) { |
|
|
|
// 是否选择设备 |
|
|
|
if (formData.deviceId) { |
|
|
|
defHttp |
|
|
|
.get( |
|
|
|
{ url: '/military/dtDeviceInfo/queryById', params: { id: formData.deviceId, pageNo: 1, pageSize: 9999 } }, |
|
|
|
{ isTransformResponse: false } |
|
|
|
) |
|
|
|
.then((res) => { |
|
|
|
let deviceData = res.result; |
|
|
|
deviceCode.value = deviceData.deviceCode; |
|
|
|
devicePosition.value = deviceData.devicePosition; |
|
|
|
formData.deviceName = deviceData.deviceName; |
|
|
|
}); |
|
|
|
} else { |
|
|
|
deviceCode.value = ''; |
|
|
|
devicePosition.value = ''; |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
confirmLoading.value = false; |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交数据 |
|
|
|
*/ |
|
|
|
async function submitForm() { |
|
|
|
// 触发表单验证 |
|
|
|
await validate(); |
|
|
|
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, |
|
|
|
}); |
|
|
|
defineExpose({ |
|
|
|
add, |
|
|
|
edit, |
|
|
|
submitForm, |
|
|
|
}); |
|
|
|
</script> |
|
|
|
|
|
|
|
<style lang="less" scoped> |
|
|
|
.antd-modal-form { |
|
|
|
min-height: 500px !important; |
|
|
|
overflow-y: auto; |
|
|
|
padding: 24px 24px 24px 24px; |
|
|
|
} |
|
|
|
.antd-modal-form { |
|
|
|
min-height: 500px !important; |
|
|
|
overflow-y: auto; |
|
|
|
padding: 24px 24px 24px 24px; |
|
|
|
} |
|
|
|
</style> |
|
|
|