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