1 line
9.7 KiB
JSON
1 line
9.7 KiB
JSON
{"remainingRequest":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\babel-loader\\lib\\index.js!D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\eslint-loader\\index.js??ref--13-0!D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\src\\views\\system\\build\\generator\\js.js","dependencies":[{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\src\\views\\system\\build\\generator\\js.js","mtime":1732871026723},{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\babel.config.js","mtime":1732871025888},{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\cache-loader\\dist\\cjs.js","mtime":1732872824662},{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\babel-loader\\lib\\index.js","mtime":1732872825017},{"path":"D:\\data\\hanguodoushan\\acs2\\nladmin-ui\\node_modules\\eslint-loader\\index.js","mtime":1732872823677}],"contextDependencies":[],"result":["\"use strict\";\n\nvar _interopRequireDefault = require(\"D:/data/hanguodoushan/acs2/nladmin-ui/node_modules/@babel/runtime/helpers/interopRequireDefault.js\");\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.makeUpJs = makeUpJs;\nrequire(\"core-js/modules/es6.object.keys\");\nrequire(\"core-js/modules/web.dom.iterable\");\nvar _util = require(\"util\");\nvar _index = require(\"../utils/index\");\nvar _ruleTrigger = _interopRequireDefault(require(\"./ruleTrigger\"));\nvar units = {\n KB: '1024',\n MB: '1024 / 1024',\n GB: '1024 / 1024 / 1024'\n};\nvar confGlobal;\nvar inheritAttrs = {\n file: '',\n dialog: 'inheritAttrs: false,'\n};\n\n/**\r\n * 组装js 【入口函数】\r\n * @param {Object} formConfig 整个表单配置\r\n * @param {String} type 生成类型,文件或弹窗等\r\n */\nfunction makeUpJs(formConfig, type) {\n confGlobal = formConfig = (0, _index.deepClone)(formConfig);\n var dataList = [];\n var ruleList = [];\n var optionsList = [];\n var propsList = [];\n var methodList = mixinMethod(type);\n var uploadVarList = [];\n var created = [];\n formConfig.fields.forEach(function (el) {\n buildAttributes(el, dataList, ruleList, optionsList, methodList, propsList, uploadVarList, created);\n });\n var script = buildexport(formConfig, type, dataList.join('\\n'), ruleList.join('\\n'), optionsList.join('\\n'), uploadVarList.join('\\n'), propsList.join('\\n'), methodList.join('\\n'), created.join('\\n'));\n confGlobal = null;\n return script;\n}\n\n// 构建组件属性\nfunction buildAttributes(scheme, dataList, ruleList, optionsList, methodList, propsList, uploadVarList, created) {\n var config = scheme.__config__;\n var slot = scheme.__slot__;\n buildData(scheme, dataList);\n buildRules(scheme, ruleList);\n\n // 特殊处理options属性\n if (scheme.options || slot && slot.options && slot.options.length) {\n buildOptions(scheme, optionsList);\n if (config.dataType === 'dynamic') {\n var model = \"\".concat(scheme.__vModel__, \"Options\");\n var options = (0, _index.titleCase)(model);\n var methodName = \"get\".concat(options);\n buildOptionMethod(methodName, model, methodList, scheme);\n callInCreated(methodName, created);\n }\n }\n\n // 处理props\n if (scheme.props && scheme.props.props) {\n buildProps(scheme, propsList);\n }\n\n // 处理el-upload的action\n if (scheme.action && config.tag === 'el-upload') {\n uploadVarList.push(\"\".concat(scheme.__vModel__, \"Action: '\").concat(scheme.action, \"',\\n \").concat(scheme.__vModel__, \"fileList: [],\"));\n methodList.push(buildBeforeUpload(scheme));\n // 非自动上传时,生成手动上传的函数\n if (!scheme['auto-upload']) {\n methodList.push(buildSubmitUpload(scheme));\n }\n }\n\n // 构建子级组件属性\n if (config.children) {\n config.children.forEach(function (item) {\n buildAttributes(item, dataList, ruleList, optionsList, methodList, propsList, uploadVarList, created);\n });\n }\n}\n\n// 在Created调用函数\nfunction callInCreated(methodName, created) {\n created.push(\"this.\".concat(methodName, \"()\"));\n}\n\n// 混入处理函数\nfunction mixinMethod(type) {\n var list = [];\n var minxins = {\n file: confGlobal.formBtns ? {\n submitForm: \"submitForm() {\\n this.$refs['\".concat(confGlobal.formRef, \"'].validate(valid => {\\n if(!valid) return\\n // TODO \\u63D0\\u4EA4\\u8868\\u5355\\n })\\n },\"),\n resetForm: \"resetForm() {\\n this.$refs['\".concat(confGlobal.formRef, \"'].resetFields()\\n },\")\n } : null,\n dialog: {\n onOpen: 'onOpen() {},',\n onClose: \"onClose() {\\n this.$refs['\".concat(confGlobal.formRef, \"'].resetFields()\\n },\"),\n close: \"close() {\\n this.$emit('update:visible', false)\\n },\",\n handelConfirm: \"handelConfirm() {\\n this.$refs['\".concat(confGlobal.formRef, \"'].validate(valid => {\\n if(!valid) return\\n this.close()\\n })\\n },\")\n }\n };\n var methods = minxins[type];\n if (methods) {\n Object.keys(methods).forEach(function (key) {\n list.push(methods[key]);\n });\n }\n return list;\n}\n\n// 构建data\nfunction buildData(scheme, dataList) {\n var config = scheme.__config__;\n if (scheme.__vModel__ === undefined) return;\n var defaultValue = JSON.stringify(config.defaultValue);\n dataList.push(\"\".concat(scheme.__vModel__, \": \").concat(defaultValue, \",\"));\n}\n\n// 构建校验规则\nfunction buildRules(scheme, ruleList) {\n var config = scheme.__config__;\n if (scheme.__vModel__ === undefined) return;\n var rules = [];\n if (_ruleTrigger.default[config.tag]) {\n if (config.required) {\n var type = (0, _util.isArray)(config.defaultValue) ? 'type: \\'array\\',' : '';\n var message = (0, _util.isArray)(config.defaultValue) ? \"\\u8BF7\\u81F3\\u5C11\\u9009\\u62E9\\u4E00\\u4E2A\".concat(config.label) : scheme.placeholder;\n if (message === undefined) message = \"\".concat(config.label, \"\\u4E0D\\u80FD\\u4E3A\\u7A7A\");\n rules.push(\"{ required: true, \".concat(type, \" message: '\").concat(message, \"', trigger: '\").concat(_ruleTrigger.default[config.tag], \"' }\"));\n }\n if (config.regList && (0, _util.isArray)(config.regList)) {\n config.regList.forEach(function (item) {\n if (item.pattern) {\n rules.push(\"{ pattern: \".concat(eval(item.pattern), \", message: '\").concat(item.message, \"', trigger: '\").concat(_ruleTrigger.default[config.tag], \"' }\"));\n }\n });\n }\n ruleList.push(\"\".concat(scheme.__vModel__, \": [\").concat(rules.join(','), \"],\"));\n }\n}\n\n// 构建options\nfunction buildOptions(scheme, optionsList) {\n if (scheme.__vModel__ === undefined) return;\n // el-cascader直接有options属性,其他组件都是定义在slot中,所以有两处判断\n var options = scheme.options;\n if (!options) options = scheme.__slot__.options;\n if (scheme.__config__.dataType === 'dynamic') {\n options = [];\n }\n var str = \"\".concat(scheme.__vModel__, \"Options: \").concat(JSON.stringify(options), \",\");\n optionsList.push(str);\n}\nfunction buildProps(scheme, propsList) {\n var str = \"\".concat(scheme.__vModel__, \"Props: \").concat(JSON.stringify(scheme.props.props), \",\");\n propsList.push(str);\n}\n\n// el-upload的BeforeUpload\nfunction buildBeforeUpload(scheme) {\n var config = scheme.__config__;\n var unitNum = units[config.sizeUnit];\n var rightSizeCode = '';\n var acceptCode = '';\n var returnList = [];\n if (config.fileSize) {\n rightSizeCode = \"let isRightSize = file.size / \".concat(unitNum, \" < \").concat(config.fileSize, \"\\n if(!isRightSize){\\n this.$message.error('\\u6587\\u4EF6\\u5927\\u5C0F\\u8D85\\u8FC7 \").concat(config.fileSize).concat(config.sizeUnit, \"')\\n }\");\n returnList.push('isRightSize');\n }\n if (scheme.accept) {\n acceptCode = \"let isAccept = new RegExp('\".concat(scheme.accept, \"').test(file.type)\\n if(!isAccept){\\n this.$message.error('\\u5E94\\u8BE5\\u9009\\u62E9\").concat(scheme.accept, \"\\u7C7B\\u578B\\u7684\\u6587\\u4EF6')\\n }\");\n returnList.push('isAccept');\n }\n var str = \"\".concat(scheme.__vModel__, \"BeforeUpload(file) {\\n \").concat(rightSizeCode, \"\\n \").concat(acceptCode, \"\\n return \").concat(returnList.join('&&'), \"\\n },\");\n return returnList.length ? str : '';\n}\n\n// el-upload的submit\nfunction buildSubmitUpload(scheme) {\n var str = \"submitUpload() {\\n this.$refs['\".concat(scheme.__vModel__, \"'].submit()\\n },\");\n return str;\n}\nfunction buildOptionMethod(methodName, model, methodList, scheme) {\n var config = scheme.__config__;\n var str = \"\".concat(methodName, \"() {\\n // \\u6CE8\\u610F\\uFF1Athis.$axios\\u662F\\u901A\\u8FC7Vue.prototype.$axios = axios\\u6302\\u8F7D\\u4EA7\\u751F\\u7684\\n this.$axios({\\n method: '\").concat(config.method, \"',\\n url: '\").concat(config.url, \"'\\n }).then(resp => {\\n var { data } = resp\\n this.\").concat(model, \" = data.\").concat(config.dataPath, \"\\n })\\n },\");\n methodList.push(str);\n}\n\n// js整体拼接\nfunction buildexport(conf, type, data, rules, selectOptions, uploadVar, props, methods, created) {\n var str = \"\".concat(_index.exportDefault, \"{\\n \").concat(inheritAttrs[type], \"\\n components: {},\\n props: [],\\n data () {\\n return {\\n \").concat(conf.formModel, \": {\\n \").concat(data, \"\\n },\\n \").concat(conf.formRules, \": {\\n \").concat(rules, \"\\n },\\n \").concat(uploadVar, \"\\n \").concat(selectOptions, \"\\n \").concat(props, \"\\n }\\n },\\n computed: {},\\n watch: {},\\n created () {\\n \").concat(created, \"\\n },\\n mounted () {},\\n methods: {\\n \").concat(methods, \"\\n }\\n}\");\n return str;\n}",null]} |