| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- /**
- * 生成PC端的录入组件代码
- * @author eden
- * @datetime 2021-02-02 03:20:00
- */
- impls.pc.add = {
- /**
- * 获取代码
- * @param {*} dbObject 对象信息
- * @param {*} columns 对象字段列表
- * @param {*} template 组件模板
- */
- getCode: function (dbObject, columns, template) {
- // 获取服务名
- var serviceName = serviceUtil.getServiceCode(dbObject, "add")[1];
- var action = `@service{name: \`${serviceName}\`, page: \`toTips\` }@`
- // 对象数组
- var objects = getUIObject();
- // 录入框HTML代码
- var code = "";
- for (let index = 0; index < columns.length; index++) {
- const element = columns[index];
- var result = impls.utils.getUICode(element, objects);
- if (!result) {
- result = `
- <p>未获取到${element.column_comment}(${element.column_uiName})的代码<p>
- `;
- }
- code += result;
- }
- // 底部操作按钮HTML代码
- var btn = `
- <el-button type="primary" icon="el-icon-circle-check" :loading="loading" onclick="space.forms.submit();">保存</el-button>
- <el-button icon="el-icon-circle-close" onclick="space.allFunction.closeDialog();">关闭</el-button>
- `;
- var codes = objectToCode(objects);
- // HTML代码替换模板的占位符
- template = template.replace('<code name="fields" />', code);
- template = template.replace('<code name="buttons" />', btn);
- template = template.replace('<code name="service" />', action);
- template = template.replace('<code name="obj" />', codes.obj);
- template = template.replace('<code name="appRules" />', codes.rules);
- template = template.replace('<code name="methods" />', codes.methods);
- template = template.replace('<code name="sources" />', codes.sources);
- template = template.replace('<code name="mounted" />', codes.mounted);
- return template;
- }
- }
|