|
@@ -10,12 +10,17 @@ import {
|
|
|
} from "@/api/ca/ca-api";
|
|
|
import XEUtils from "xe-utils";
|
|
|
import { BizException, ExceptionEnum } from "@/utils/BizException";
|
|
|
-import { Row } from "vxe-pc-ui";
|
|
|
import { CyMessageBox } from "@/utils/cy-message-box";
|
|
|
|
|
|
-const props = defineProps<{ data: any[]; patNo: string }>();
|
|
|
+const props = withDefaults(
|
|
|
+ defineProps<{ data: any[]; patNo?: string; isEdit?: boolean }>(),
|
|
|
+ {
|
|
|
+ isEdit: true,
|
|
|
+ }
|
|
|
+);
|
|
|
|
|
|
const tableRef = useVxeTableRef<PatientIdCardType>();
|
|
|
+const emits = defineEmits<UseDialogType.Emits>();
|
|
|
|
|
|
async function handleAdd() {
|
|
|
const caType = selectData[2];
|
|
@@ -34,7 +39,6 @@ async function handleAdd() {
|
|
|
}
|
|
|
|
|
|
async function handleDel(row, index: number) {
|
|
|
- console.log(row);
|
|
|
await CyMessageBox.confirm({
|
|
|
message: "删除后无法恢复",
|
|
|
type: "delete",
|
|
@@ -63,17 +67,25 @@ function handleSelect(row, val) {
|
|
|
XEUtils.find(selectData, item => item.code === val)?.name ?? "未知";
|
|
|
}
|
|
|
|
|
|
+function cellClick({ row }) {
|
|
|
+ emits("cyDialogConfirm", row);
|
|
|
+}
|
|
|
+
|
|
|
defineExpose<UseDialogType.Expose>({
|
|
|
async confirm() {
|
|
|
- const insertRecords = tableRef.value.getInsertRecords();
|
|
|
- const editRecord = tableRef.value.getUpdateRecords();
|
|
|
+ if (props.isEdit) {
|
|
|
+ const insertRecords = tableRef.value.getInsertRecords();
|
|
|
+ const editRecord = tableRef.value.getUpdateRecords();
|
|
|
|
|
|
- const errMap = await tableRef.value.validate(true);
|
|
|
- if (errMap) {
|
|
|
- BizException(ExceptionEnum.MESSAGE_ERROR, "校验不通过!");
|
|
|
+ const errMap = await tableRef.value.validate(true);
|
|
|
+ if (errMap) {
|
|
|
+ BizException(ExceptionEnum.MESSAGE_ERROR, "校验不通过!");
|
|
|
+ }
|
|
|
+ await savePatientIdCardType(insertRecords, editRecord, props.patNo);
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return tableRef.value.getCurrentRecord();
|
|
|
}
|
|
|
- await savePatientIdCardType(insertRecords, editRecord, props.patNo);
|
|
|
- return true;
|
|
|
},
|
|
|
});
|
|
|
</script>
|
|
@@ -81,10 +93,12 @@ defineExpose<UseDialogType.Expose>({
|
|
|
<template>
|
|
|
<vxe-table
|
|
|
ref="tableRef"
|
|
|
+ :row-config="{ isCurrent: !props.isEdit }"
|
|
|
keep-source
|
|
|
+ @cell-click="cellClick"
|
|
|
:data="data"
|
|
|
:edit-rules="validRules"
|
|
|
- :edit-config="editorConfig"
|
|
|
+ :edit-config="props.isEdit ? editorConfig : null"
|
|
|
>
|
|
|
<vxe-column :edit-render="{}" title="名字" field="name">
|
|
|
<template #edit="{ row }">
|
|
@@ -116,5 +130,3 @@ defineExpose<UseDialogType.Expose>({
|
|
|
</vxe-column>
|
|
|
</vxe-table>
|
|
|
</template>
|
|
|
-
|
|
|
-<style lang="scss"></style>
|