yanzhen-design-vue
Version:
123 lines (122 loc) • 5.2 kB
JavaScript
"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const vue = require("vue");
const core = require("@vueuse/core");
const utilsBizObject = require("@yanzhen-libs/utils-biz-object");
const lodashEs = require("lodash-es");
const index = require("../../form-provider-item/index.cjs");
const otherTable = require("./other-table.cjs");
require("./hooks/index.cjs");
const common = require("./constants/common.cjs");
const useOtherTableApis = require("./hooks/use-other-table-apis.cjs");
const useOtherTableConfig = require("./hooks/use-other-table-config.cjs");
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
...{ name: otherTable.otherTableName },
__name: "other-table",
props: otherTable.otherTableProps,
emits: otherTable.otherTableEmits,
setup(__props, { emit: __emit }) {
const RELEVANCE = common.OTHER_TABLES_RELEVANCE;
const otherTableType = common.OTHER_TABLE_TYPE;
const { ns } = otherTable.otherTableOptions;
const props = __props;
const emit = __emit;
const _modelValue = core.useVModel(props, "value", emit);
const schemaBody = vue.ref({});
const { getBizObjectParams } = useOtherTableApis.provideOtherTableBizObjectParamsApi(props);
const getSchema = async () => {
const result = await getBizObjectParams({
data: {
bizObjectModelCode: props.relBizObjectModelCode
}
});
const originAttributes = props.originAttributes;
if (originAttributes) {
originAttributes.disabled = true;
}
const elementObjet = {
Attributes: originAttributes,
columnBizType: String(originAttributes == null ? void 0 : originAttributes.relBizObjectColumnBizType),
noData: false,
orderNo: originAttributes == null ? void 0 : originAttributes.orderNo,
type: "ClTable"
};
const nowField = result == null ? void 0 : result.data.find(
(item) => item.columnCode === props.relBizObjectColumnCode
);
const options = {
fields: [nowField],
elements: [elementObjet],
widthRatio: 1
};
const { _schema } = utilsBizObject.useBizObject(null, options);
vue.watch(_schema, (val) => {
if (val.body.length > 0) {
const body = val.body[0];
body.field.label = "";
schemaBody.value = body;
}
});
return _schema;
};
const cx1IsUpload = vue.computed(() => {
var _a;
const { image, file } = common.COLUMN_BIZ_TYPE;
return [image, file].includes((_a = props.originAttributes) == null ? void 0 : _a.relBizObjectColumnBizType);
});
const isSourceBizObject = vue.computed(() => {
return props.sourceBizObjectModelCode !== props.relBizObjectModelCode;
});
const config = useOtherTableConfig.useOtherTablesConfig();
const onMaskingClick = () => {
var _a, _b;
const associationModalRef = (_a = vue.unref(config)) == null ? void 0 : _a.associationModalRef;
const provideProps = (_b = vue.unref(config)) == null ? void 0 : _b.provideProps;
if (lodashEs.isFunction(associationModalRef == null ? void 0 : associationModalRef.value.openModal)) {
const { sceneID, bizObjectModelCode } = provideProps;
const clickItemData = provideProps.elements.find(
(item) => {
var _a2;
return item.Attributes.id === ((_a2 = props.originAttributes) == null ? void 0 : _a2.columnCode);
}
);
const { id, relBizObjectStorageMode } = clickItemData.Attributes;
const selectType = [RELEVANCE.CX2, RELEVANCE.KZ].includes(relBizObjectStorageMode) ? otherTableType.CHECKBOX : otherTableType.RADIO;
let selectedRowKeys = "";
if ([RELEVANCE.CX1, RELEVANCE.CX2].includes(relBizObjectStorageMode)) {
const CX1PrimaryCode = provideProps.model.CX1PrimaryCode ?? {};
const transData = provideProps.model ?? {};
selectedRowKeys = CX1PrimaryCode[id] || transData[id] || "";
}
const option = {
clickItemData: vue.unref(clickItemData),
sceneID,
bizObjectModelCode,
selectType,
selectedRowKeys
};
associationModalRef.value.openModal(option);
}
};
vue.onMounted(() => {
getSchema();
});
return (_ctx, _cache) => {
return vue.openBlock(), vue.createElementBlock("div", {
class: vue.normalizeClass([vue.unref(ns).b()])
}, [
!isSourceBizObject.value ? (vue.openBlock(), vue.createElementBlock("div", {
key: 0,
class: vue.normalizeClass(["cx1-masking", { "cx1-masking-upload": cx1IsUpload.value }]),
onClick: onMaskingClick
}, null, 2)) : vue.createCommentVNode("", true),
vue.createVNode(vue.unref(index.YzFormProviderItem), {
modelValue: vue.unref(_modelValue),
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => vue.isRef(_modelValue) ? _modelValue.value = $event : null),
schema: schemaBody.value
}, null, 8, ["modelValue", "schema"])
], 2);
};
}
});
exports.default = _sfc_main;