|
@@ -20,7 +20,7 @@
|
|
|
class="in"
|
|
|
v-if="option.in"
|
|
|
>
|
|
|
-<!-- <template #trigger>
|
|
|
+ <!-- <template #trigger>
|
|
|
<span class="btn">导入</span>
|
|
|
</template>-->
|
|
|
</el-upload>
|
|
@@ -67,6 +67,16 @@ const props = defineProps({
|
|
|
inName: "",
|
|
|
}),
|
|
|
},
|
|
|
+ //校验区域
|
|
|
+ verifications: {
|
|
|
+ type: Array,
|
|
|
+ default: () => [],
|
|
|
+ },
|
|
|
+ //校验状态
|
|
|
+ checkStatus: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false,
|
|
|
+ },
|
|
|
});
|
|
|
//update:data : v-model表格data ,confirm : 获取此时表格data
|
|
|
const emits = defineEmits(["update:data", "confirm"]);
|
|
@@ -204,6 +214,29 @@ const saveCellData = () => {
|
|
|
};
|
|
|
enter();
|
|
|
};
|
|
|
+//配置单元格校验
|
|
|
+const setVerification = () => {
|
|
|
+ for (let i = 0; i < props.verifications.length; i++) {
|
|
|
+ if (
|
|
|
+ !props.verifications[i].checkStr ||
|
|
|
+ props.verifications[i].checkStr === ""
|
|
|
+ ) {
|
|
|
+ } else {
|
|
|
+ let option = {
|
|
|
+ type: "number",
|
|
|
+ type2: "bw",
|
|
|
+ value1: JSON.parse(props.verifications[i].checkStr).down,
|
|
|
+ value2: JSON.parse(props.verifications[i].checkStr).up,
|
|
|
+ hintShow: true,
|
|
|
+ hintText: `请输入${JSON.parse(props.verifications[i].checkStr).down}-${JSON.parse(props.verifications[i].checkStr).up}的数字`,
|
|
|
+ };
|
|
|
+ luckysheet.setDataVerification(
|
|
|
+ { ...option },
|
|
|
+ { range: props.verifications[i].position }
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
defineExpose({ confirm, reset, saveCellData, getData });
|
|
|
onMounted(() => {
|
|
|
if (props.data == null) {
|
|
@@ -218,6 +251,17 @@ onMounted(() => {
|
|
|
}
|
|
|
luckysheet.create(resetOb.value);
|
|
|
});
|
|
|
+watch(
|
|
|
+ () => props.verifications,
|
|
|
+ () => {
|
|
|
+ nextTick(() => {
|
|
|
+ if (props.checkStatus == true && props.verifications.length > 0) {
|
|
|
+ setVerification();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ { immediate: true }
|
|
|
+);
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|