| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- //公共初始化页面vue表单元素组件js,放在所有vue表单元素之后引入 Ben(20251217)
- const data = {};
- if (window.SS.dom.formElemConfig) {
- Object.entries(window.SS.dom.formElemConfig).forEach(([key, config]) => {
- data[key] = config.val;
- // 处理 objPicker
- if (config.type === window.SS.dom.TYPE.OBJPICKER) {
- data[key + "ObjPicker"] = true;
- data[key + "Option"] = [];
- data[key + "Url"] = config.url;
- }
- // 处理datepicker
- if (config.type === window.SS.dom.TYPE.DATE) {
- data[key + "Mode"] = config.mode
- console.log(data[key + "Mode"]);
- }
- // 处理富文本编辑器
- if (config.type === window.SS.dom.TYPE.RICHTEXT) {
- data[key + "Url"] = config.val;
- data[key + "editor"] = config.val;
- }
- // 处理onoff
- if (config.type === window.SS.dom.TYPE.ONOFFBTN) {
- data[key] = config.val.split('|');
- }
- if (config.type === window.SS.dom.TYPE.IMG) {
- data[key + "showUrl"] = config.showUrl;
- data[key + "uploadUrl"] = config.uploadUrl;
- }
- });
- }
- // console.log("data",data);
- SS.ready(function () {
- if(ss.dom.formVmConfig)//加判断条件,页面有校验配置时,才运行下面的 Ben(20251206)
- for (let i = 0; i < ss.dom.formVmConfig.length; i++) {
- const item = ss.dom.formVmConfig[i];
- // 处理每个元素
- let rule = item.rule;
- let field = item.field;
- let param = item.param;
- window.ssVm.add(rule, field, param);
- }
- // 在这里直接初始化,不需要等待 load 事件
- window.SS.dom.initializeFormApp({
- el: "#app",
- data(){
- return data;
- },
- mounted() {
- const self = this;
- // 在这里可以使用 Vue 实例
- Object.entries(this.$data).forEach(([key, value]) => {
- // 处理 objPicker
- if (key.includes('ObjPicker')) {
- }
- // 处理 CCPSINGLE
- if (key.includes('CCPSINGLE')) {
- const originalKey = key.replace('CCPSINGLE', '');
- const self = this;
- // 只有第一个字段需要自动加载
- if (this[originalKey + "InitLoad"]) {
- ccpsingleFirstLoad(this[originalKey + "Url"], key).then(result =>{
- this[originalKey+'Option'] = result;
- })
- }
- // 绑定 change 事件
- this[originalKey + 'Change'] = async function(value) {
- const objP = self[originalKey + "objP"] || [];
- const currentIndex = objP.indexOf(originalKey);
- const children = currentIndex < 0 || currentIndex >= objP.length - 1 ? [] : objP.slice(currentIndex + 1);
- await doCascade({
- children,
- value,
- vm: self,
- loadData: (value) => getCcpsingleValue(children,value),
- });
- };
- }
- // 如果是 CCPSINGLE 类型
- if (key.includes('CCPMUTIPLE')) {
- const originalKey = key.replace('CCPMUTIPLE', '');
- const self = this;
- // 只有第一个字段需要自动加载
- if (this[originalKey + "InitLoad"]) {
- ccpsingleFirstLoad(this[originalKey + "Url"], key).then(result =>{
- this[originalKey+'Option'] = result;
- })
- }
- // 绑定 change 事件
- this[originalKey + 'Change'] = async function(value) {
- const objP = self[originalKey + "objP"] || [];
- const currentIndex = objP.indexOf(originalKey);
- const children = currentIndex < 0 || currentIndex >= objP.length - 1 ? [] : objP.slice(currentIndex + 1);
- await doCascade({
- children,
- value,
- vm: self,
- loadData: (value) => getCcpsingleValue(children,value),
- });
- };
- }
- });
- }
- })
- });
|