补充缺失文件
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
VITE_APP_NAME=后台管理(开发环境)
|
VITE_APP_NAME=后台管理(开发环境)
|
||||||
VITE_API_URL=http://127.0.0.1:9200/api
|
#VITE_API_URL=http://127.0.0.1:9200/api
|
||||||
|
|||||||
@@ -71,7 +71,8 @@
|
|||||||
style="margin-left: 10px; width: 137px"
|
style="margin-left: 10px; width: 137px"
|
||||||
@click="openMapPicker"
|
@click="openMapPicker"
|
||||||
>
|
>
|
||||||
<AimOutlined />选取
|
<AimOutlined/>
|
||||||
|
选取
|
||||||
</a-button>
|
</a-button>
|
||||||
</div>
|
</div>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
@@ -124,306 +125,311 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { ref, reactive, watch } from 'vue';
|
import {ref, reactive, watch} from 'vue';
|
||||||
import { Form, message } from 'ant-design-vue';
|
import {Form, message} from 'ant-design-vue';
|
||||||
import { assignObject, uuid } from 'ele-admin-pro';
|
import {assignObject, uuid} from 'ele-admin-pro';
|
||||||
import { addHjmCar, updateHjmCar } from '@/api/hjm/hjmCar';
|
import {addHjmCar, updateHjmCar} from '@/api/hjm/hjmCar';
|
||||||
import { HjmCar } from '@/api/hjm/hjmCar/model';
|
import {HjmCar} from '@/api/hjm/hjmCar/model';
|
||||||
import { useThemeStore } from '@/store/modules/theme';
|
import {useThemeStore} from '@/store/modules/theme';
|
||||||
import { storeToRefs } from 'pinia';
|
import {storeToRefs} from 'pinia';
|
||||||
import { ItemType } from 'ele-admin-pro/es/ele-image-upload/types';
|
import {ItemType} from 'ele-admin-pro/es/ele-image-upload/types';
|
||||||
import { FormInstance } from 'ant-design-vue/es/form';
|
import {FormInstance} from 'ant-design-vue/es/form';
|
||||||
import { FileRecord } from '@/api/system/file/model';
|
import {FileRecord} from '@/api/system/file/model';
|
||||||
import { AimOutlined } from '@ant-design/icons-vue';
|
import {AimOutlined} from '@ant-design/icons-vue';
|
||||||
import { CenterPoint } from 'ele-admin-pro/es/ele-map-picker/types';
|
import {CenterPoint} from 'ele-admin-pro/es/ele-map-picker/types';
|
||||||
import OrgSelect from '@/views/system/user/components/org-select.vue';
|
import OrgSelect from '@/views/system/user/components/org-select.vue';
|
||||||
import { Organization } from '@/api/system/organization/model';
|
import {Organization} from '@/api/system/organization/model';
|
||||||
import { User } from '@/api/system/user/model';
|
import {User} from '@/api/system/user/model';
|
||||||
import { pageUsers } from '@/api/system/user';
|
import {pageUsers} from '@/api/system/user';
|
||||||
import { listOrganizations } from '@/api/system/organization';
|
import {listOrganizations} from '@/api/system/organization';
|
||||||
import { toTreeData } from 'ele-admin-pro/es';
|
import {toTreeData} from 'ele-admin-pro/es';
|
||||||
import { DictData } from '@/api/system/dict-data/model';
|
import {DictData} from '@/api/system/dict-data/model';
|
||||||
import { HjmFence } from '@/api/hjm/hjmFence/model';
|
import {HjmFence} from '@/api/hjm/hjmFence/model';
|
||||||
|
|
||||||
// 是否是修改
|
// 是否是修改
|
||||||
const isUpdate = ref(false);
|
const isUpdate = ref(false);
|
||||||
const useForm = Form.useForm;
|
const useForm = Form.useForm;
|
||||||
// 是否开启响应式布局
|
// 是否开启响应式布局
|
||||||
const themeStore = useThemeStore();
|
const themeStore = useThemeStore();
|
||||||
const { styleResponsive } = storeToRefs(themeStore);
|
const {styleResponsive} = storeToRefs(themeStore);
|
||||||
const { darkMode } = storeToRefs(themeStore);
|
const {darkMode} = storeToRefs(themeStore);
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
// 弹窗是否打开
|
// 弹窗是否打开
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
// 修改回显的数据
|
// 修改回显的数据
|
||||||
data?: HjmCar | null;
|
data?: HjmCar | null;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
(e: 'done'): void;
|
(e: 'done'): void;
|
||||||
(e: 'update:visible', visible: boolean): void;
|
(e: 'update:visible', visible: boolean): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
// 提交状态
|
// 提交状态
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
// 是否显示最大化切换按钮
|
// 是否显示最大化切换按钮
|
||||||
const maxable = ref(true);
|
const maxable = ref(true);
|
||||||
// 表格选中数据
|
// 表格选中数据
|
||||||
const formRef = ref<FormInstance | null>(null);
|
const formRef = ref<FormInstance | null>(null);
|
||||||
const images = ref<ItemType[]>([]);
|
const images = ref<ItemType[]>([]);
|
||||||
// 是否显示地图选择弹窗
|
// 是否显示地图选择弹窗
|
||||||
const showMap = ref(false);
|
const showMap = ref(false);
|
||||||
const users = ref<User[]>([]);
|
const users = ref<User[]>([]);
|
||||||
const organizationId = ref<number>();
|
const organizationId = ref<number>();
|
||||||
const organizations = ref<Organization[]>([]);
|
const organizations = ref<Organization[]>([]);
|
||||||
|
|
||||||
// 用户信息
|
// 用户信息
|
||||||
const form = reactive<HjmCar>({
|
const form = reactive<HjmCar>({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
name: undefined,
|
name: undefined,
|
||||||
image: undefined,
|
image: undefined,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
kuaidi: undefined,
|
kuaidi: undefined,
|
||||||
kuaidiAdmin: undefined,
|
kuaidiAdmin: undefined,
|
||||||
code: undefined,
|
code: undefined,
|
||||||
driverId: undefined,
|
driverId: undefined,
|
||||||
driver: undefined,
|
driver: undefined,
|
||||||
driverPhone: undefined,
|
driverPhone: undefined,
|
||||||
insuranceStatus: undefined,
|
insuranceStatus: undefined,
|
||||||
gpsNo: undefined,
|
gpsNo: undefined,
|
||||||
fenceId: undefined,
|
fenceId: undefined,
|
||||||
fenceName: undefined,
|
fenceName: undefined,
|
||||||
fence: undefined,
|
fence: undefined,
|
||||||
location: undefined,
|
location: undefined,
|
||||||
longitude: undefined,
|
longitude: undefined,
|
||||||
latitude: undefined,
|
latitude: undefined,
|
||||||
district: undefined,
|
district: undefined,
|
||||||
address: undefined,
|
address: undefined,
|
||||||
organizationId: undefined,
|
organizationId: undefined,
|
||||||
organizationParentId: undefined,
|
organizationParentId: undefined,
|
||||||
userId: undefined,
|
userId: undefined,
|
||||||
toUser: undefined,
|
toUser: undefined,
|
||||||
comments: undefined,
|
comments: undefined,
|
||||||
status: 0,
|
status: 0,
|
||||||
deleted: undefined,
|
deleted: undefined,
|
||||||
tenantId: undefined,
|
tenantId: undefined,
|
||||||
createTime: undefined,
|
createTime: undefined,
|
||||||
sortNumber: 100
|
sortNumber: 100
|
||||||
});
|
});
|
||||||
|
|
||||||
/* 更新visible */
|
/* 更新visible */
|
||||||
const updateVisible = (value: boolean) => {
|
const updateVisible = (value: boolean) => {
|
||||||
emit('update:visible', value);
|
emit('update:visible', value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
const rules = reactive({
|
const rules = reactive({
|
||||||
organizationId: [
|
organizationId: [
|
||||||
{
|
{
|
||||||
required: true,
|
required: true,
|
||||||
type: 'number',
|
type: 'number',
|
||||||
message: '请选择车辆所属站点',
|
message: '请选择车辆所属站点',
|
||||||
trigger: 'blur'
|
trigger: 'blur'
|
||||||
}
|
|
||||||
],
|
|
||||||
code: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
type: 'string',
|
|
||||||
message: '请填写车辆编号',
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
fenceName: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
type: 'string',
|
|
||||||
message: '请选择电子围栏',
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
insuranceStatus: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
type: 'string',
|
|
||||||
message: '请选择保险状态',
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
sortNumber: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
type: 'number',
|
|
||||||
message: '请填写排序号',
|
|
||||||
trigger: 'blur'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
// driver: [
|
|
||||||
// {
|
|
||||||
// required: true,
|
|
||||||
// type: 'any',
|
|
||||||
// message: '请绑定操作员',
|
|
||||||
// trigger: 'blur'
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
});
|
|
||||||
|
|
||||||
const chooseInsuranceStatus = (item: DictData) => {
|
|
||||||
form.insuranceStatus = item.dictDataCode;
|
|
||||||
};
|
|
||||||
|
|
||||||
const updateFence = (item: HjmFence) => {
|
|
||||||
form.fenceName = item.name;
|
|
||||||
form.fenceId = item.id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 打开位置选择 */
|
|
||||||
const openMapPicker = () => {
|
|
||||||
showMap.value = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
/* 地图选择后回调 */
|
|
||||||
const onDone = (location: CenterPoint) => {
|
|
||||||
if (location) {
|
|
||||||
console.log(location);
|
|
||||||
form.location = `${location.lat},${location.lng}`;
|
|
||||||
form.longitude = `${location.lng}`;
|
|
||||||
form.latitude = `${location.lat}`;
|
|
||||||
form.address = `${location.address}`;
|
|
||||||
form.district = `${location.city?.district}`;
|
|
||||||
}
|
}
|
||||||
showMap.value = false;
|
],
|
||||||
};
|
code: [
|
||||||
|
{
|
||||||
const onOrganization = (index: number) => {
|
required: true,
|
||||||
form.driver = undefined;
|
type: 'string',
|
||||||
users.value = [];
|
message: '请填写车辆编号',
|
||||||
organizations.value?.map((item) => {
|
trigger: 'blur'
|
||||||
if (
|
|
||||||
item.children?.map((d) => {
|
|
||||||
const find = organizations.value?.find(
|
|
||||||
(i) => i.organizationId == d.parentId
|
|
||||||
);
|
|
||||||
if (find) {
|
|
||||||
if (d.value == index) {
|
|
||||||
form.code = `${find.organizationCode}`;
|
|
||||||
form.organizationParentId = find.organizationId;
|
|
||||||
form.organizationId = d.organizationId;
|
|
||||||
organizationId.value = find.organizationId;
|
|
||||||
getUsers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
if (index == item.value) {
|
|
||||||
form.kuaidi = item.organizationName;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const getUsers = () => {
|
|
||||||
pageUsers({ organizationId: organizationId.value }).then((res) => {
|
|
||||||
users.value =
|
|
||||||
res?.list.map((d) => {
|
|
||||||
d.label = d.realName || d.nickname;
|
|
||||||
d.value = d.userId;
|
|
||||||
return d;
|
|
||||||
}) || [];
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const chooseImage = (data: FileRecord) => {
|
|
||||||
images.value.push({
|
|
||||||
uid: data.id,
|
|
||||||
url: data.path,
|
|
||||||
status: 'done'
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const onDeleteItem = (index: number) => {
|
|
||||||
images.value.splice(index, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
const { resetFields } = useForm(form, rules);
|
|
||||||
|
|
||||||
/* 保存编辑 */
|
|
||||||
const save = () => {
|
|
||||||
if (!formRef.value) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
formRef.value
|
],
|
||||||
.validate()
|
fenceName: [
|
||||||
.then(() => {
|
{
|
||||||
loading.value = true;
|
required: true,
|
||||||
const formData = {
|
type: 'string',
|
||||||
...form,
|
message: '请选择电子围栏',
|
||||||
image: JSON.stringify(images.value)
|
trigger: 'blur'
|
||||||
};
|
}
|
||||||
const saveOrUpdate = isUpdate.value ? updateHjmCar : addHjmCar;
|
],
|
||||||
saveOrUpdate(formData)
|
insuranceStatus: [
|
||||||
.then((msg) => {
|
{
|
||||||
loading.value = false;
|
required: true,
|
||||||
message.success(msg);
|
type: 'string',
|
||||||
updateVisible(false);
|
message: '请选择保险状态',
|
||||||
emit('done');
|
trigger: 'blur'
|
||||||
})
|
}
|
||||||
.catch((e) => {
|
],
|
||||||
loading.value = false;
|
sortNumber: [
|
||||||
message.error(e.message);
|
{
|
||||||
});
|
required: true,
|
||||||
})
|
type: 'number',
|
||||||
.catch(() => {});
|
message: '请填写排序号',
|
||||||
};
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
// driver: [
|
||||||
|
// {
|
||||||
|
// required: true,
|
||||||
|
// type: 'any',
|
||||||
|
// message: '请绑定操作员',
|
||||||
|
// trigger: 'blur'
|
||||||
|
// }
|
||||||
|
// ]
|
||||||
|
});
|
||||||
|
|
||||||
watch(
|
const chooseInsuranceStatus = (item: DictData) => {
|
||||||
() => props.visible,
|
form.insuranceStatus = item.dictDataCode;
|
||||||
(visible) => {
|
};
|
||||||
if (visible) {
|
|
||||||
images.value = [];
|
const updateFence = (item: HjmFence) => {
|
||||||
// 加载机构
|
form.fenceName = item.name;
|
||||||
listOrganizations()
|
form.fenceId = item.id;
|
||||||
.then((list) => {
|
};
|
||||||
loading.value = false;
|
|
||||||
list.forEach((d) => {
|
/* 打开位置选择 */
|
||||||
d.key = d.organizationId;
|
const openMapPicker = () => {
|
||||||
d.value = d.organizationId;
|
showMap.value = true;
|
||||||
d.title = d.organizationName;
|
};
|
||||||
});
|
|
||||||
organizations.value = toTreeData({
|
/* 地图选择后回调 */
|
||||||
data: list,
|
const onDone = (location: CenterPoint) => {
|
||||||
idField: 'organizationId',
|
if (location) {
|
||||||
parentIdField: 'parentId'
|
console.log(location);
|
||||||
});
|
form.location = `${location.lat},${location.lng}`;
|
||||||
})
|
form.longitude = `${location.lng}`;
|
||||||
.catch((e) => {
|
form.latitude = `${location.lat}`;
|
||||||
loading.value = false;
|
form.address = `${location.address}`;
|
||||||
message.error(e.message);
|
form.district = `${location.city?.district}`;
|
||||||
});
|
}
|
||||||
if (props.data) {
|
showMap.value = false;
|
||||||
assignObject(form, props.data);
|
};
|
||||||
if (props.data.image) {
|
|
||||||
const arr = JSON.parse(props.data.image);
|
const onOrganization = (index: number) => {
|
||||||
arr.map((item) => {
|
form.driver = undefined;
|
||||||
images.value.push({
|
users.value = [];
|
||||||
uid: uuid(),
|
organizations.value?.map((item) => {
|
||||||
url: item.url,
|
if (
|
||||||
status: 'done'
|
item.children?.map((d) => {
|
||||||
});
|
const find = organizations.value?.find(
|
||||||
});
|
(i) => i.organizationId == d.parentId
|
||||||
}
|
);
|
||||||
if (props.data.organizationParentId) {
|
if (find) {
|
||||||
organizationId.value = props.data.organizationParentId;
|
if (d.value == index) {
|
||||||
|
form.code = `${find.organizationCode}`;
|
||||||
|
form.organizationParentId = find.organizationId;
|
||||||
|
form.organizationId = d.organizationId;
|
||||||
|
organizationId.value = find.organizationId;
|
||||||
getUsers();
|
getUsers();
|
||||||
}
|
}
|
||||||
isUpdate.value = true;
|
|
||||||
} else {
|
|
||||||
isUpdate.value = false;
|
|
||||||
}
|
}
|
||||||
} else {
|
})
|
||||||
resetFields();
|
)
|
||||||
|
if (index == item.value) {
|
||||||
|
form.kuaidi = item.organizationName;
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
{ immediate: true }
|
};
|
||||||
);
|
|
||||||
|
const getUsers = () => {
|
||||||
|
pageUsers({organizationId: organizationId.value}).then((res) => {
|
||||||
|
users.value =
|
||||||
|
res?.list.map((d) => {
|
||||||
|
d.label = d.realName || d.nickname;
|
||||||
|
d.value = d.userId;
|
||||||
|
return d;
|
||||||
|
}) || [];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const chooseImage = (data: FileRecord) => {
|
||||||
|
images.value.push({
|
||||||
|
uid: data.id,
|
||||||
|
url: data.path,
|
||||||
|
status: 'done'
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const onDeleteItem = (index: number) => {
|
||||||
|
images.value.splice(index, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
const {resetFields} = useForm(form, rules);
|
||||||
|
|
||||||
|
/* 保存编辑 */
|
||||||
|
const save = () => {
|
||||||
|
if (!formRef.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (form.code == '' || !form.code) {
|
||||||
|
message.error('所属站点下的节点不能为空!');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
formRef.value
|
||||||
|
.validate()
|
||||||
|
.then(() => {
|
||||||
|
loading.value = true;
|
||||||
|
const formData = {
|
||||||
|
...form,
|
||||||
|
image: JSON.stringify(images.value)
|
||||||
|
};
|
||||||
|
const saveOrUpdate = isUpdate.value ? updateHjmCar : addHjmCar;
|
||||||
|
saveOrUpdate(formData)
|
||||||
|
.then((msg) => {
|
||||||
|
loading.value = false;
|
||||||
|
message.success(msg);
|
||||||
|
updateVisible(false);
|
||||||
|
emit('done');
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
loading.value = false;
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.visible,
|
||||||
|
(visible) => {
|
||||||
|
if (visible) {
|
||||||
|
images.value = [];
|
||||||
|
// 加载机构
|
||||||
|
listOrganizations()
|
||||||
|
.then((list) => {
|
||||||
|
loading.value = false;
|
||||||
|
list.forEach((d) => {
|
||||||
|
d.key = d.organizationId;
|
||||||
|
d.value = d.organizationId;
|
||||||
|
d.title = d.organizationName;
|
||||||
|
});
|
||||||
|
organizations.value = toTreeData({
|
||||||
|
data: list,
|
||||||
|
idField: 'organizationId',
|
||||||
|
parentIdField: 'parentId'
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
loading.value = false;
|
||||||
|
message.error(e.message);
|
||||||
|
});
|
||||||
|
if (props.data) {
|
||||||
|
assignObject(form, props.data);
|
||||||
|
if (props.data.image) {
|
||||||
|
const arr = JSON.parse(props.data.image);
|
||||||
|
arr.map((item) => {
|
||||||
|
images.value.push({
|
||||||
|
uid: uuid(),
|
||||||
|
url: item.url,
|
||||||
|
status: 'done'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (props.data.organizationParentId) {
|
||||||
|
organizationId.value = props.data.organizationParentId;
|
||||||
|
getUsers();
|
||||||
|
}
|
||||||
|
isUpdate.value = true;
|
||||||
|
} else {
|
||||||
|
isUpdate.value = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resetFields();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{immediate: true}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user