This commit is contained in:
2023-05-30 13:37:17 +08:00
parent ac6ec65bcc
commit 0474ca3578
33 changed files with 4043 additions and 405 deletions

View File

@ -84,8 +84,8 @@ const props = defineProps({
modelValue: Object,
labelWidth: {
type: Number,
default: 120
}
default: 120,
},
});
const { modelValue, labelWidth } = toRefs(props);
const formRef = ref(null);
@ -95,13 +95,15 @@ const districtSelectList = ref([]); // 区\
const data = reactive({
rules: {
provinceCode: [
{ required: true, message: "请选择", trigger: ["change", "blue"] }
{ required: true, message: "请选择", trigger: ["change", "blue"] },
],
cityCode: [
{ required: true, message: "请选择", trigger: ["change", "blue"] },
],
cityCode: [{ required: true, message: "请选择", trigger: ["change", "blue"] }],
areaCode: [
{ required: true, message: "请选择", trigger: ["change", "blue"] }
]
}
{ required: true, message: "请选择", trigger: ["change", "blue"] },
],
},
});
const { rules } = toRefs(data);
// 获取 省列表
@ -117,7 +119,7 @@ const getCityListByProvinceId = async (provinceId) => {
citySelectList.value = data.map((el) => {
return {
...el,
cityCode: el.cityCode.toString()
cityCode: el.cityCode.toString(),
};
});
};
@ -127,14 +129,16 @@ const getAreaListByCityId = async (cityId) => {
districtSelectList.value = data.map((el) => {
return {
...el,
areaCode: el.areaCode.toString()
areaCode: el.areaCode.toString(),
};
});
};
// 当省改变时
const provinceChanged = (val) => {
if (val) {
modelValue.value.provinceName = provinceSelectList.value.find(el => el.provinceCode === val)?.provinceName;
modelValue.value.provinceName = provinceSelectList.value.find(
(el) => el.provinceCode === val
)?.provinceName;
} else {
modelValue.value.provinceName = undefined;
}
@ -148,7 +152,9 @@ const provinceChanged = (val) => {
// 当市改变时
const cityChanged = (val) => {
if (val) {
modelValue.value.cityName = citySelectList.value.find(el => el.cityCode === val)?.cityName;
modelValue.value.cityName = citySelectList.value.find(
(el) => el.cityCode === val
)?.cityName;
} else {
modelValue.value.cityName = undefined;
}
@ -158,7 +164,9 @@ const cityChanged = (val) => {
};
const areaChanged = (val) => {
if (val) {
modelValue.value.areaName = districtSelectList.value.find(el => el.areaCode === val)?.areaName;
modelValue.value.areaName = districtSelectList.value.find(
(el) => el.areaCode === val
)?.areaName;
} else {
modelValue.value.areaName = undefined;
}
@ -171,7 +179,6 @@ const validateForm = async () => {
}
};
watch(
() => modelValue.value.provinceCode,
(val) => {
@ -179,7 +186,7 @@ watch(
val && getCityListByProvinceId(val);
},
{
immediate: true
immediate: true,
}
);
@ -190,13 +197,13 @@ watch(
val && getAreaListByCityId(val);
},
{
immediate: true
immediate: true,
}
);
getProvinceList();
defineExpose({
validateForm
validateForm,
});
</script>

View File

@ -272,6 +272,8 @@ const getUnreadCount = async () => {
};
onMounted(() => {
// TODO:disable notice
return;
getUnreadCount();
if (userStore.userId) {
let wsUrl;

View File

@ -7,6 +7,7 @@
>
<el-row>
<el-table
class="select-table"
ref="tableRef"
v-loading="loading"
:data="dataList"
@ -147,7 +148,16 @@ const cancel = () => {
const handleSelectChange = (selection) => {};
const handleRowClick = (row, _, event) => {
event.target?.parentNode?.parentNode?.firstElementChild?.firstElementChild?.firstElementChild?.click();
const rowIndex = dataList.value.findIndex(
(el) => el[props.selectKey] === row[props.selectKey]
);
document
.querySelector(
`.select-table .el-table__body tbody > .el-table__row:nth-child(${
rowIndex + 1
}) .el-table-column--selection .el-checkbox`
)
.click();
};
/*监听单选事件*/
const handleSelect = (selection, row) => {