|
|
@@ -25,12 +25,10 @@
|
|
|
<el-form-item label="密码:" prop="password">
|
|
|
<el-input v-model="formParams.password" placeholder="请输入设备密码" type="password" show-password />
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="使用场景:" prop="workshopList">
|
|
|
+ <!-- <el-form-item label="使用场景:" prop="workshopList">
|
|
|
<el-tree-select class="temp" v-model="workLocations" :data="locationOptions" multiple
|
|
|
:render-after-expand="false" placeholder="请选择使用该NVR的车间" @change="handleCascaderChange" />
|
|
|
- <!-- <el-cascader v-model="workLocations" :options="locationOptions" :props="ismultiple" collapse-tags
|
|
|
- collapse-tags-tooltip clearable placeholder="请选择使用该NVR的车间" @change="handleCascaderChange" /> -->
|
|
|
- </el-form-item>
|
|
|
+ </el-form-item> -->
|
|
|
<el-form-item label="负责人:" prop="principal">
|
|
|
<el-input v-model="formParams.principal" placeholder="请输入设备安装负责人" />
|
|
|
</el-form-item>
|
|
|
@@ -61,8 +59,8 @@ import {
|
|
|
} from '@/api/camera/camera-nvr';
|
|
|
|
|
|
interface Props {
|
|
|
- title: String,
|
|
|
-};
|
|
|
+ title: String;
|
|
|
+}
|
|
|
const props = defineProps<Props>();
|
|
|
const emit = defineEmits(['form-submit', 'form-edit']);
|
|
|
|
|
|
@@ -70,7 +68,7 @@ const isDrawer = ref(false);
|
|
|
const formRef: any = ref(null);
|
|
|
// const ismultiple = { multiple: true };
|
|
|
|
|
|
-const { locationOptions, getLocationOptions, getWorkLocation } = useWorkLocation();
|
|
|
+const { getLocationOptions } = useWorkLocation();
|
|
|
// const workLocations = ref<[number | undefined, number | undefined] | []>([]);
|
|
|
const workLocations = ref<number[]>([]);
|
|
|
|
|
|
@@ -85,26 +83,31 @@ const initFormNvr = () => ({
|
|
|
nvrPort: '',
|
|
|
username: '',
|
|
|
password: '',
|
|
|
- workshopList: [],
|
|
|
principal: '',
|
|
|
remark: '',
|
|
|
});
|
|
|
const formParams = ref<NVRListItem>(initFormNvr());
|
|
|
|
|
|
const deleteKey = (obj, ...args) => {
|
|
|
- args.forEach(v => { delete obj[v] });
|
|
|
+ args.forEach((v) => {
|
|
|
+ delete obj[v];
|
|
|
+ });
|
|
|
return obj;
|
|
|
-}
|
|
|
+};
|
|
|
const openDrawer = (row: NVRListItemAll) => {
|
|
|
isDrawer.value = true;
|
|
|
if (row) {
|
|
|
formParams.value = Object.assign(formParams.value, row);
|
|
|
- deleteKey(formParams.value, 'createdAt', 'isDeleted', 'tenantId', 'updatedAt', 'workshopName');
|
|
|
- formParams.value.workshopList.map((item, index) => {
|
|
|
- workLocations.value[index] = getWorkLocation(item, locationOptions.value)
|
|
|
- });
|
|
|
+ deleteKey(
|
|
|
+ formParams.value,
|
|
|
+ 'createdAt',
|
|
|
+ 'isDeleted',
|
|
|
+ 'tenantId',
|
|
|
+ 'updatedAt',
|
|
|
+ 'workshopName',
|
|
|
+ );
|
|
|
return;
|
|
|
- };
|
|
|
+ }
|
|
|
};
|
|
|
|
|
|
const closeDrawer = () => {
|
|
|
@@ -122,7 +125,11 @@ const rules: FormRules = {
|
|
|
name: { required: true, message: '设备名称不能为空', trigger: 'blur' },
|
|
|
code: [
|
|
|
{ required: true, message: '设备编号不能为空', trigger: 'change' },
|
|
|
- { pattern: /^[a-zA-Z0-9-_]+$/, message: '请输入大小写字母、数字、-、_的组合', trigger: 'change' }
|
|
|
+ {
|
|
|
+ pattern: /^[a-zA-Z0-9-_]+$/,
|
|
|
+ message: '请输入大小写字母、数字、-、_的组合',
|
|
|
+ trigger: 'change',
|
|
|
+ },
|
|
|
],
|
|
|
nvrType: { required: true, message: '设备品牌不能为空', trigger: 'change' },
|
|
|
nvrIp: { required: true, message: '设备IP不能为空', trigger: 'change' },
|
|
|
@@ -132,22 +139,17 @@ const rules: FormRules = {
|
|
|
workshopList: { required: true, message: '使用场景不能为空', trigger: 'change' },
|
|
|
};
|
|
|
|
|
|
-const handleCascaderChange = () => {
|
|
|
- formParams.value.workshopList = workLocations.value;
|
|
|
-};
|
|
|
-
|
|
|
const formSubmit = () => {
|
|
|
const errorText = ref('');
|
|
|
// 捕获当前表单中是否有el-form-item__error即错误信息
|
|
|
const errorTipElements = document.querySelectorAll('.el-form-item__error');
|
|
|
errorTipElements.forEach((element) => {
|
|
|
- if (element.textContent)
|
|
|
- errorText.value = element.textContent;
|
|
|
+ if (element.textContent) errorText.value = element.textContent;
|
|
|
});
|
|
|
|
|
|
if (errorText.value === '') {
|
|
|
- codeError.value = '';
|
|
|
- ipError.value = '';
|
|
|
+ // codeError.value = '';
|
|
|
+ // ipError.value = '';
|
|
|
formRef.value.validate((valid) => {
|
|
|
if (valid) {
|
|
|
const nvrData = {
|
|
|
@@ -158,30 +160,29 @@ const formSubmit = () => {
|
|
|
nvrPort: formParams.value.nvrPort,
|
|
|
username: formParams.value.username,
|
|
|
password: formParams.value.password,
|
|
|
- workshopList: formParams.value.workshopList,
|
|
|
principal: formParams.value.principal,
|
|
|
remark: formParams.value.remark,
|
|
|
};
|
|
|
|
|
|
if (isAddUser.value) {
|
|
|
- addNVRListItem(nvrData).then((res) => {
|
|
|
- if (Object.getOwnPropertyNames(res).length != 0) {
|
|
|
- codeError.value = res.code;
|
|
|
- ipError.value = res.nvrIp;
|
|
|
- } else {
|
|
|
- emit('form-submit');
|
|
|
- closeDrawer();
|
|
|
- }
|
|
|
+ addNVRListItem(nvrData).then(() => {
|
|
|
+ emit('form-submit');
|
|
|
+ closeDrawer();
|
|
|
+ // if (Object.getOwnPropertyNames(res).length != 0) {
|
|
|
+ // codeError.value = res.code;
|
|
|
+ // ipError.value = res.nvrIp;
|
|
|
+ // } else {
|
|
|
+ // }
|
|
|
});
|
|
|
} else {
|
|
|
- updateNVRListItem(formParams.value).then((res) => {
|
|
|
- if (Object.getOwnPropertyNames(res).length != 0) {
|
|
|
- codeError.value = res.code;
|
|
|
- ipError.value = res.nvrIp;
|
|
|
- } else {
|
|
|
- emit('form-edit');
|
|
|
- closeDrawer();
|
|
|
- }
|
|
|
+ updateNVRListItem(formParams.value).then(() => {
|
|
|
+ emit('form-edit');
|
|
|
+ closeDrawer();
|
|
|
+ // if (Object.getOwnPropertyNames(res).length != 0) {
|
|
|
+ // codeError.value = res.code;
|
|
|
+ // ipError.value = res.nvrIp;
|
|
|
+ // } else {
|
|
|
+ // }
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
@@ -196,14 +197,14 @@ defineExpose({
|
|
|
|
|
|
onMounted(() => {
|
|
|
getLocationOptions();
|
|
|
-})
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
:deep(.el-drawer__header) {
|
|
|
position: relative;
|
|
|
|
|
|
- >:first-child {
|
|
|
+ > :first-child {
|
|
|
margin-left: 32px;
|
|
|
font-weight: 600;
|
|
|
font-size: 16px;
|
|
|
@@ -217,7 +218,7 @@ onMounted(() => {
|
|
|
}
|
|
|
|
|
|
:deep(.el-drawer__body) {
|
|
|
- border-top: 1px solid #0000000F;
|
|
|
+ border-top: 1px solid #0000000f;
|
|
|
}
|
|
|
|
|
|
:deep(.el-form-item__label) {
|
|
|
@@ -241,4 +242,4 @@ onMounted(() => {
|
|
|
max-height: 55px;
|
|
|
overflow: auto;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|