- 更新 lodash.template 修复脚本以处理 assignWith 函数的自定义器参数 - 在多个处方组件中引入 drord_doctor_type 字典用于动态生成医嘱类型列表 - 修复手术类型(adviceType=6)的特殊处理逻辑,包括类型映射和字段过滤 - 调整后端医嘱保存服务中的类型分类逻辑,正确处理手术类型 - 更新数据库查询映射以支持手术类型的正确显示和数据传输 - 修复费用对话框和订单表单中的相关类型显示问题
79 lines
2.4 KiB
JavaScript
79 lines
2.4 KiB
JavaScript
/**
|
|
* Fix lodash.template assignWith issue - Manual fix script
|
|
* Run this after npm/yarn install and before build
|
|
*
|
|
* Usage: node fix-lodash-manual.js
|
|
*/
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const lodashTemplatePath = path.join(__dirname, 'node_modules', 'lodash.template', 'index.js');
|
|
|
|
if (!fs.existsSync(lodashTemplatePath)) {
|
|
console.error('❌ lodash.template not found at:', lodashTemplatePath);
|
|
console.error('Please run npm install or yarn install first');
|
|
process.exit(1);
|
|
}
|
|
|
|
let content = fs.readFileSync(lodashTemplatePath, 'utf8');
|
|
|
|
// Check if already patched with new version
|
|
if (content.includes('/* LODASH_TEMPLATE_PATCHED_V2 */')) {
|
|
console.log('✓ lodash.template already patched with v2');
|
|
process.exit(0);
|
|
}
|
|
|
|
// Remove old patch if exists
|
|
if (content.includes('/* LODASH_TEMPLATE_PATCHED */')) {
|
|
console.log('🔄 Removing old patch...');
|
|
content = content.replace(/\/\* LODASH_TEMPLATE_PATCHED \*\/\n.*assignWith[\s\S]*?^\}/m, '');
|
|
}
|
|
|
|
console.log('🔧 Patching lodash.template with v2...');
|
|
|
|
// Correct assignWith implementation that handles undefined customizer
|
|
const assignWithImpl = `/* LODASH_TEMPLATE_PATCHED_V2 */
|
|
// assignWith polyfill for lodash.template - Fixed version
|
|
function assignWith(object, source, customizer) {
|
|
if (object == null) return object;
|
|
if (typeof customizer !== 'function') {
|
|
customizer = function(objValue, srcValue) {
|
|
return srcValue;
|
|
};
|
|
}
|
|
var props = Object.keys(Object(source));
|
|
for (var i = 0; i < props.length; i++) {
|
|
var key = props[i];
|
|
var value = source[key];
|
|
var assignedValue = customizer(object[key], value, key, object, source);
|
|
if (assignedValue !== undefined) {
|
|
object[key] = assignedValue;
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
`;
|
|
|
|
// Find first line break after comments
|
|
let insertPos = 0;
|
|
const lines = content.split('\n');
|
|
for (let i = 0; i < lines.length; i++) {
|
|
if (lines[i].trim() === ' */' || lines[i].trim() === '*/') {
|
|
insertPos = content.indexOf('\n', content.indexOf(lines[i])) + 1;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (insertPos === 0) {
|
|
insertPos = content.indexOf('\n') + 1;
|
|
}
|
|
|
|
const before = content.substring(0, insertPos);
|
|
const after = content.substring(insertPos);
|
|
|
|
content = before + '\n' + assignWithImpl + after;
|
|
|
|
fs.writeFileSync(lodashTemplatePath, content);
|
|
console.log('✅ Successfully patched lodash.template with assignWith function (v2)');
|
|
console.log(' File:', lodashTemplatePath);
|