import html from "html";
import { ref, reactive, watch } from "vue";
import { dayjs } from "element-plus";
export default {
template: html`
{{dayjs(model[prop]).format('YYYY-MM-DD HH:mm:ss')}}
{{dayjs(model[prop]).format('YYYY-MM-DD')}}
{{model[prop]}}
`,
props: ["modelValue", "schema", "prop", "isReadOnly"],
emit: ["update:modelValue"],
async setup(props, context) {
const model = reactive(props.modelValue);
watch(model, (value) => {
context.emit("update:modelValue", value);
});
/*start*/
const getDisabled = () => {
if (props.isReadOnly && props.isReadOnly === true) {
return true;
}
if (props.schema.displayOnly) {
return true;
}
if (props.mode === "update" && props.schema.addOnly) {
return true;
}
return false;
};
const getInput = (schema) => {
return schema.input ?? schema.type;
};
/*end*/
return {
model,
getDisabled,
getInput,
dayjs,
};
},
};