this.fields.get(c) is undefined

本文介绍了一个关于 ExtJS 中 GridPanel 的分组排序问题。作者在使用 GroupingStore 对数据进行分组并尝试排序时遇到错误,因为排序字段“company”并未在数据中定义。文章详细展示了如何配置 GridPanel 和 GroupingStore,以及如何定义 renderer 和 Cls 函数以自定义单元格样式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在做项目的时候碰到这个问题,和大家一起分享:

源代码:大家一定需要注意我的Store中的sortInfo:

<script type="text/javascript">
             Ext.onReady(function(){
                 
                 Ext.QuickTips.init();
                 
                 //别名
                 var xg=Ext.grid;
                 
                 //创建一个ArrayReader
                 var reader=new Ext.data.ArrayReader({},[
                   {name:"name",type:"string"},
                   {name:"age",type:"int"},
                   {name:"empno",type:"int"},
                   {name:"sex",type:"int"},
                   {name:"birthday",type:"date",dateFormat:"n/j h:ia"},
                   {name:"salary",type:"float"},
                   {name:"deptno",type:"int"}
                 ]);
                 
                 //创建一个store
                 var store=new Ext.data.GroupingStore({
                   reader:reader,
                   data:xg.dummyData,
                   sortInfo:{field:"company",direction:"ASC"},
                   groupField:"deptno"  //根据部门来分组
                 });
                 
                 
                 //name的renderer
                 function nameCls(val){
                    if(val.length>2){
                    return "<span stype='color:red;'>"+val+"</span>";
                    }
                    return "<span stype='color:blue;'>"+val+"</span>";
                 }

                //age的Cls
                function agCls(val){
                  if(val>25){
                  return "<span stype='color:red;'>"+val+"</span>";
                  }
                  return "<span stype='color:green;'>"+val+"</span>";
                }                 
                 
                 //创建一个gridPanel
                 var grid=new xg.GridPanel({
                  store:store,
                  columns:[
                     {header:"姓名",width:20,sortable:true,renderer:nameCls,dataIndex:"name"},
                     {header:"年龄",width:40,sortable:true,renderer:agCls,dataIndex:"age"},
                     {id:"empno",header:"编号",width:60,sortable:true,dataIndex:"empno"},
                     {header:"性别",width:20,sortable:true,dataIndex:"sex"},
                     {header:"生日",width:50,sotrable:true,renderer:Ext.util.Format.dateRenderer("m/d/Y"),dataIndex:"birthday"},
                     {header:"工资",width:30,sortable:true,renderer:Ext.util.Format.usMoney,dataIndex:"salary"},
                     {header:"部门编号",width:50,sortable:true,dataIndex:"deptno"}
                  ],
                  view:new Ext.grid.GroupingView({
                      forceFit:true,
                      groupTextTpl:"{text} ({[values.rs.length]} {[values.rs.length>1 ? 'Items' : 'Item']})"
                  }),
                  frame:true,
                  width:700,
                  height:450,
                  collapsible:true,//True表示为面板是可收缩的,并自动渲染一个展开/收缩的轮换按钮在头部工具条。false表示为保持面板为一个静止的尺寸
                  animCollapse:true,//True 表示为面板闭合过程附有动画效果(默认为true,在类 Ext.Fx 可用的情况下)。
                  title:"雇员信息",
                  iconCls:"icon-grid",
                  fbar:["->",{
                    text:"clear Groping",
                    iconCls:"icon-clear-group",
                    handler:function(){
                      store.clearGouping();
                    }
                  }],
                  renderTo:document.body              
                 });
                 
              
             });
             
                //数据
                 Ext.grid.dummyData=[
                ["张三00",12,1001,1,"1990-05-20",3000,50],
                ["张三01",16,1002,0,"1990-05-21",3000,20],
                ["张三02",19,1003,1,"1990-05-22",3000,20],
                ["张三03",25,1004,1,"1990-05-23",3000,10],
                ["张三04",22,1005,1,"1990-05-24",3000,30],
                ["张三05",24,1006,1,"1990-05-25",3000,20],
                ["张三06",23,1007,0,"1990-05-26",3000,60],
                ["张三07",21,1008,0,"1990-05-27",3000,90],
                ["张三08",25,1009,0,"1990-05-28",3000,10],
                ["张三09",28,1010,1,"1990-05-29",6000,20],
                ["张三20",26,1011,0,"1990-05-20",2000,50],
                ["张三21",29,1012,0,"1990-06-20",8000,40],
                ["张三22",22,1013,1,"1990-01-20",3000,50],
                ["张三23",28,1014,0,"1990-02-20",3000,60],
                ["张三24",21,1015,1,"1990-08-20",3000,50]
               ];
                 
        
              		
		</script>

错误就出现在那里,没有company列但是,我却给company列排序所以报错,


找了很长时间,特地贴出来,不知道对大家有没有帮助.


<template> <div> <div class="search-title">查询条件</div> <div class="search-box"> <a-form-model :model="searchForm" layout="inline" ref="searchForm" class="searchForm"> <a-form-model-item label="题库名称" prop="title"> <a-input v-model="searchForm.title" placeholder="请输入题库名称" /> </a-form-model-item> <a-form-model-item class="searchButton"> <a-button type="primary" v-if="QX.read" @click="getSearch">查询</a-button> <a-button type="default" v-if="QX.read" @click="restSearch('searchForm')">重置</a-button> </a-form-model-item> </a-form-model> </div> <div class="table-operation"> <a-button type="primary" @click="addBank" icon="plus" v-if="QX.add">新增</a-button> </div> <a-table :columns="columns" :data-source="dataList" :pagination="false" :loading="loading" rowKey="questionBankId" :scroll="{ y: this.$getViewportSize().height - 300 }" > <span slot="action" slot-scope="text, record"> <a @click="editAuth(record)" v-if="QX.edit"><a-icon class="iconBtn" type="edit" />编辑</a> <a-divider v-if="QX.edit && QX.delete" type="vertical" /> <a-popconfirm title="确认是否删除?" ok-text="是" cancel-text="否" @confirm="removeBank(record)" > <a v-if="QX.delete"><a-icon class="iconBtn" type="delete" />删除</a> </a-popconfirm> </span> </a-table> <template slot="action" slot-scope="text, record, index"> <a @click="removeQuestion(index)">删除</a> </template> <a-pagination show-size-changer :total="totalPage" :current="pageIndex" :pageSize="pageSize" @showSizeChange="onShowSizeChange" @change="onChangePage" style="float: right; margin-top: 15px" /> <a-drawer :closable="true" :title="title" width="auto" :visible="visible" @close="visible = !visible" > <a-spin class="submitLoading" :spinning="submitLoading"> <a-form-model :model="form" :label-col="labelCol" :wrapper-col="wrapperCol" :rules="rules" ref="form" class="lay-drawer-form"> <a-row> <a-col :span="12"> <a-form-model-item label="题库名称" prop="title"> <a-input v-model="form.title" :maxLength="25" placeholder="请输入题库名称" style="width: 380px" /> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item label="关联岗位" prop="positionId"> <a-select v-model="form.positionId" style="width: 380px" placeholder="请选择岗位"> <a-select-option v-for="(label, value) in positionDict" :key="value" :value="value"> {{ label }} </a-select-option> </a-select> </a-form-model-item> </a-col> <a-col :span="12"> <a-form-model-item label="参与PK" prop="participateInPk"> <a-switch v-model="form.participateInPk" :checkedValue="1" :unCheckedValue="0" /> </a-form-model-item> </a-col> </a-row> </a-form-model> <!-- 新增题目区域 --> <div class="question-batch"> <div style="margin: 20px 0; display: flex; justify-content: space-between; align-items: center;"> <a-button type="primary" @click="downloadTemplate">下载模板</a-button> <div class="import-add-buttons"> <a-upload name="file" :showUploadList="false" :beforeUpload="beforeUpload" accept=".xlsx,.xls" :disabled="!importEnabled" > <a-button :disabled="!importEnabled"><a-icon type="upload" /> 导入题目</a-button> </a-upload> <a-button type="dashed" @click="addTopicVisible = true" :disabled="!addEnabled" > <a-icon type="plus" /> 添加题目 </a-button> </div> </div> <!-- 题目列表容器添加样式 --> <div class="topic-list-container"> <!-- 题目列表 --> <div class="topic-grid"> <!-- 题目编号和内容 --> <div v-for="(topic, index) in topicList" :key="topic.topicId" class="topic-item"> <!-- 题目编号和内容 --> <div class="topic-content"> <strong>{{ index + 1 }}. {{ topic.content }}</strong> </div> <!-- 选项列表 --> <div class="options" v-if="topic.topicType === 1"> <label v-for="option in getOptions(topic)" :key="option.key"> <input type="radio" :name="'topic' + topic.topicId" :value="option.key" :checked="topic.correctAnswer === option.key" /> <!-- @change="checkAnswer(topic, option.key)"--> {{ option.key }}. {{ option.value }} </label> </div> <!-- 判断题 --> <div v-if="topic.topicType === 2" class="options"> <label> <input type="radio" :name="'topic' + topic.topicId" value="正确" :checked="topic.correctAnswer === '正确'" /> <!-- @change="checkAnswer(topic, '正确')"--> 正确 </label> <label> <input type="radio" :name="'topic' + topic.topicId" value="错误" :checked="topic.correctAnswer === '错误'" /> <!-- @change="checkAnswer(topic, '错误')"--> 错误 </label> </div> <!-- 删除按钮 --> <div class="topic-delete"> <a @click="removeQuestion(topic.topicId)"> <a-icon type="delete" /> 删除 </a> </div> </div> </div> <!-- 分页组件移到题目列表区域外面 --> <div class="pagination-wrapper"> <a-pagination v-model="topicPageNum" :pageSize="topicPageSize" :total="totalTopicCount" @change="handleTopicPageChange" style="text-align: right;" /> </div> </div> </div> <div :style="{ position: 'absolute', right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '8px 16px', background: '#fff', textAlign: 'right', zIndex: 1, }"> <a-button type="default" @click="visible = !visible" > 取消 </a-button> <a-button type="primary" @click="submitForm" > 确认 </a-button> </div> </a-spin> </a-drawer> <!-- 新增题目抽屉 --> <a-drawer title="新增题目" :visible="addTopicVisible" @close="addTopicVisible = false" width="500" > <a-form-model :model="addTopicForm" layout="vertical" :rules="rulesForAddTopic" ref="addTopicFormRef"> <!-- 题目类型 --> <a-form-model-item label="题目类型" prop="topicType"> <a-select v-model="addTopicForm.topicType" style="width: 100%"> <a-select-option :value="1">选择题</a-select-option> <a-select-option :value="2">判断题</a-select-option> </a-select> </a-form-model-item> <!-- 题目内容 --> <a-form-model-item label="题目内容" prop="content"> <a-input v-model="addTopicForm.content" placeholder="请输入题目内容" /> </a-form-model-item> <!-- 选择题选项 --> <div v-if="addTopicForm.topicType === 1"> <a-form-model-item label="选项A" prop="optionA"> <a-input v-model="addTopicForm.optionA" placeholder="请输入选项A内容" /> </a-form-model-item> <a-form-model-item label="选项B" prop="optionB"> <a-input v-model="addTopicForm.optionB" placeholder="请输入选项B内容" /> </a-form-model-item> <a-form-model-item label="选项C" prop="optionC"> <a-input v-model="addTopicForm.optionC" placeholder="请输入选项C内容" /> </a-form-model-item> <a-form-model-item label="选项D" prop="optionD"> <a-input v-model="addTopicForm.optionD" placeholder="请输入选项D内容" /> </a-form-model-item> <a-form-model-item label="正确答案" prop="correctAnswer"> <a-select v-model="addTopicForm.correctAnswer" style="width: 100%"> <a-select-option value="A">A</a-select-option> <a-select-option value="B">B</a-select-option> <a-select-option value="C">C</a-select-option> <a-select-option value="D">D</a-select-option> </a-select> </a-form-model-item> </div> <!-- 判断题选项 --> <div v-if="addTopicForm.topicType === 2"> <a-form-model-item label="正确答案" prop="correctAnswer"> <a-select v-model="addTopicForm.correctAnswer" style="width: 100%"> <a-select-option value="正确">正确</a-select-option> <a-select-option value="错误">错误</a-select-option> </a-select> </a-form-model-item> </div> <div class="drawer-footer"> <a-button @click="addTopicVisible = false">取消</a-button> <a-button type="primary" @click="saveNewTopic">保存</a-button> </div> </a-form-model> </a-drawer> </div> </template> <script> import { req, fileDownload } from '../../../api/axiosFun'; import preventBack from 'vue-prevent-browser-back'; export default { name: 'Bank', mixins: [preventBack], data() { return { QX: {}, topicQX: {}, topicList: [], totalTopicCount: 0, // 题目总数 topicPageNum: 1, // 当前页码 topicPageSize: 10, // 每页数量 addTopicVisible: false, addTopicForm: { content: '', // 题目内容 topicType: 1, // 题目类型:1=选择题,2=判断题 optionA: '', optionB: '', optionC: '', optionD: '', correctAnswer: '', }, disabled: false, checkedKeys: [], selectAuth: [], treeData: [], positionDict: {}, title: '', labelCol: { span: 4 }, wrapperCol: { span: 20 }, tableHeight: 0, expanded: false, // 筛选条件是否展开 form: { questionBankId: 0, bankCode: '', title: '', positionId: '', participateInPk: true, }, isEdit: false, // 是否是编辑状态 isAdd: false, // 是否是新增状态 importEnabled: false, // 导入题目按钮是否可用 - 默认为不可用 addEnabled: false, // 添加题目按钮是否可用 - 默认为不可用 rules: { positionId: [ { required: true, message: '请选择岗位', trigger: 'blur' }, ], title: [ { required: true, message: '请输入题库名称', trigger: 'blur' }, ], }, rulesForAddTopic: { content: [ { required: true, message: '请输入题目内容', trigger: ['blur', 'change'] }, ], topicType: [ { required: true, message: '请选择题目类型', trigger: 'change' }, ], optionA: [ { required: (rule, value) => this.addTopicForm.topicType === 1, message: '选择题必须输入选项A', trigger: ['blur', 'change'], }, ], optionB: [ { required: (rule, value) => this.addTopicForm.topicType === 1, message: '选择题必须输入选项B', trigger: ['blur', 'change'], }, ], optionC: [ { required: (rule, value) => this.addTopicForm.topicType === 1, message: '选择题必须输入选项C', trigger: ['blur', 'change'], }, ], optionD: [ { required: (rule, value) => this.addTopicForm.topicType === 1, message: '选择题必须输入选项D', trigger: ['blur', 'change'], }, ], correctAnswer: [ { required: true, message: '请选择正确答案', trigger: 'change' }, ], }, searchForm: { title: '', }, visible: false, dataList: [], columns, loading: false, submitLoading: false, pageIndex: 1, pageSize: 10, totalPage: 0, ops: { vuescroll: {}, scrollPanel: {}, rail: { keepShow: true, }, bar: { hoverStyle: true, onlyShowBarOnScroll: false, // 是否只有滚动的时候才显示滚动条 background: '#F5F5F5', // 滚动条颜色 opacity: 1, // 滚动条透明度 'overflow-x': 'hidden', }, }, }; }, watch: { 'addTopicForm.topicType': function (newVal) { // 当题目类型变化时,触发相关字段的验证 this.$nextTick(() => { if (this.$refs.addTopicFormRef) { // 验证选项字段 if (newVal === 1) { this.$refs.addTopicFormRef.validateFields(['optionA', 'optionB', 'optionC', 'optionD']); } else { // 清除非必填字段的验证状态 this.$refs.addTopicFormRef.clearValidate(['optionA', 'optionB', 'optionC', 'optionD']); } } }); }, visible(newVal, oldVal) { if (!newVal) { this.restForm('form'); this.form.questionBankId = 0; this.checkedKeys = []; this.selectAuth = []; this.treeData = []; // 重置状态标志 this.isEdit = false; this.isAdd = false; } else { // 当抽屉打开时强制更新按钮状态 this.$nextTick(() => { this.$forceUpdate(); }); } }, }, mounted() { this.actionTitle = '操作'; this.getDict('position').then(res => { const dictMap = {}; res.data.forEach(item => { dictMap[item.dicValue] = item.dicDisplayName; }); this.positionDict = dictMap; }); this.getBankList(); }, methods: { // 获取字典数据方法 getDict(type) { return req('get', `/dict/getDictItemByNo`, { dicNo: type }) .then((res) => { if (res.result === 'success') { return res; } throw new Error(res.message || '获取字典数据失败'); }) .catch((error) => { console.error(`获取${type}字典失败:`, error); throw error; }); }, /* 新增题库 */ addBank() { this.visible = true; this.disabled = false; this.title = '新增题库'; // 获取功能权限树 req('get', '/bank/getTree', {}).then((res) => { this.treeData = res.data; }); // 初始化题目列表为空 this.topicList = []; this.totalTopicCount = 0; this.topicPageNum = 1; this.isEdit = false; // 不是编辑状态 this.isAdd = true; // 设置为新增状态 // 在新增状态下禁用导入和添加功能 this.importEnabled = false; this.addEnabled = false; // 强制更新按钮状态 this.$nextTick(() => { this.$forceUpdate(); }); }, // 查询 getSearch() { this.pageIndex = 1; this.getBankList(); }, /* 重置查询 */ restSearch(form) { this.restForm(form); this.pageIndex = 1; this.getBankList(); }, /* 删除题库 */ removeBank(record) { this.loading = true; req('post', '/bank/removeBQuestionBank', { questionBankId: record.questionBankId, }).then((res) => { this.loading = false; if (res.result === 'success') { this.$message.success(res.message); this.getBankList(); } }); }, downloadTemplate() { fileDownload('get', '/topic/downloadTemplate', null).then((res) => { const blob = new Blob([res], { type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', }); const link = document.createElement('a'); link.href = window.URL.createObjectURL(blob); link.download = '题库模板.xlsx'; link.click(); window.URL.revokeObjectURL(link.href); }).catch(() => { this.$message.error('下载失败'); }); }, beforeUpload(file) { // 显示加载状态 this.loading = true; const formData = new FormData(); formData.append('file', file); formData.append('questionBankId', this.form.questionBankId); // 添加 questionBankId 字段 req('post', '/topic/import', formData, { headers: { 'Content-Type': 'multipart/form-data', }, }) .then((res) => { // 隐藏加载状态 this.loading = false; if (res.result === 'success') { // 确保在DOM更新后再刷新题目列表 this.$nextTick(() => { // 刷新题目列表 this.getTopicList(this.form.questionBankId, this.topicPageNum, this.topicPageSize) .then(() => { this.$message.success('导入成功'); }) .catch(() => { this.$message.error('刷新题目列表失败'); }); }); } else { this.$message.error(res.message || '导入失败'); } }) .catch((error) => { // 隐藏加载状态 this.loading = false; this.$message.error('导入失败,请重试'); console.error('导入题目出错:', error); }); return false; // 阻止默认上传行为 }, // 获取题库下的题目列表(返回Promise以便链式调用) getTopicList(questionBankId, pageNum = 1, pageSize = 10) { return new Promise((resolve, reject) => { req('post', '/topic/list', { questionBankId, page: pageNum, rows: pageSize, }).then((res) => { if (res.result === 'success') { this.topicQX = res.QX; if (!this.topicQX.edit && !this.topicQX.delete) { this.hideAction(); } else { this.topicList = res.data.map((item, index) => ({ index: (pageNum - 1) * pageSize + index + 1, content: item.content, optionA: item.optionA, optionB: item.optionB, optionC: item.optionC, optionD: item.optionD, topicId: item.topicId, correctAnswer: item.correctAnswer, topicType: item.topicType, })); } // 更新总条数用于分页组件 this.totalTopicCount = res.page.totalResult; resolve(res); } else { this.$message.error(res.message || '获取题目列表失败'); reject(res); } }).catch((error) => { this.$message.error('获取题目列表失败'); reject(error); }); }); }, handleTopicPageChange(page) { this.topicPageNum = page; this.getTopicList(this.form.questionBankId, page, this.topicPageSize); }, // 获取选择题的选项 getOptions(topic) { if (topic.topicType === 1) { // 选择题:返回 A/B/C/D 选项 const options = []; if (topic.optionA) options.push({ key: 'A', value: topic.optionA }); if (topic.optionB) options.push({ key: 'B', value: topic.optionB }); if (topic.optionC) options.push({ key: 'C', value: topic.optionC }); if (topic.optionD) options.push({ key: 'D', value: topic.optionD }); return options; } else if (topic.topicType === 2) { // 判断题:直接返回 正确/错误 return [ { key: '正确', value: '正确' }, { key: '错误', value: '错误' }, ]; } return []; }, checkAnswer(topic, selectedAnswer) { // 仅记录用户选择的答案,不进行是否正确的判断 this.$set(topic, 'userAnswer', selectedAnswer); }, resetAddTopicForm() { this.addTopicForm = { content: '', topicType: 1, optionA: '', optionB: '', optionC: '', optionD: '', correctAnswer: '', }; }, saveNewTopic() { this.$refs.addTopicFormRef.validate((valid, fields) => { if (!valid) { console.log('表单验证失败:', fields); // 找出第一个错误字段并聚焦 const firstErrorField = Object.keys(fields).find(key => fields[key]); if (firstErrorField && this.$refs.addTopicFormRef) { const formItem = this.$refs.addTopicFormRef.$children.find( child => child.prop === firstErrorField, ); if (formItem && formItem.$el) { const input = formItem.$el.querySelector('input, select, textarea'); if (input) input.focus(); } } return; } // 验证通过,处理保存逻辑 const newTopic = { ...this.addTopicForm }; // 发送请求保存题目 req('post', '/topic/add', { questionBankId: this.form.questionBankId, optionA: newTopic.optionA, optionB: newTopic.optionB, optionC: newTopic.optionC, optionD: newTopic.optionD, correctAnswer: newTopic.correctAnswer, content: newTopic.content, topicType: newTopic.topicType, }).then((res) => { if (res.result === 'success') { this.$message.success('题目添加成功'); this.addTopicVisible = false; this.getTopicList(this.form.questionBankId); // 刷新题目列表 } else { this.$message.error(res.message || '保存失败'); } this.resetAddTopicForm(); }).catch((err) => { this.$message.error('网络异常,请重试'); }); }); }, /* 删除题库下的题目 */ removeQuestion(topicId) { this.$confirm({ title: '确认删除该题目?', content: '删除后将无法恢复', okText: '是', cancelText: '否', onOk: () => { req('post', '/topic/removeBTopic', { topicId, questionBankId: this.form.questionBankId, }).then((res) => { if (res.result === 'success') { this.$message.success(res.message); // 刷新题目列表 this.getTopicList(this.form.questionBankId, this.topicPageNum, this.topicPageSize); } else { this.$message.error(res.message || '删除失败'); } }); }, }); }, editAuth(record) { this.loading = true; req('post', '/bank/getBQuestionBank', { questionBankId: record.questionBankId, }).then((res) => { this.loading = false; if (res.result === 'success') { this.visible = true; this.disabled = true; this.title = '修改题库'; this.isEdit = true; // 设置为编辑状态 this.isAdd = false; // 不是新增状态 // 在编辑状态下启用导入和添加功能 this.importEnabled = true; this.addEnabled = true; // 强制更新按钮状态 this.$nextTick(() => { this.$forceUpdate(); }); const bank = res.data; this.$nextTick(() => { this.form.questionBankId = bank.questionBankId; this.form.title = bank.title; this.form.participateInPk = Boolean(bank.participateInPk); this.form.positionId = bank.positionId; this.treeData = bank.treeData; this.checkedKeys = bank.auths; // 获取题目列表 this.topicPageNum = 1; this.getTopicList(bank.questionBankId, this.topicPageNum, this.topicPageSize); }); } }); }, /* 保存or修改题库信息 */ submitForm() { this.$refs.form.validate((valid) => { if (valid) { this.form.participateInPk = this.form.participateInPk ? 1 : 0; const url = this.form.questionBankId ? 'edit' : 'add'; const selectAuth = this.selectAuth; this.form.selectAuth = JSON.stringify(selectAuth); this.submitLoading = true; req('post', `/bank/${url}`, this.form).then((res) => { if (res.result === 'success') { this.visible = false; this.getBankList(); // 如果是新增题库且成功,获取题目列表 if (!this.form.questionBankId && res.data && res.data.questionBankId) { this.form.questionBankId = res.data.questionBankId; this.topicPageNum = 1; this.getTopicList(res.data.questionBankId, this.topicPageNum, this.topicPageSize); // 新增成功后启用导入和添加功能 this.importEnabled = true; this.addEnabled = true; } this.$message.success(res.message); // 重置新增/编辑状态 this.isEdit = false; this.isAdd = false; } this.submitLoading = false; }); } }); }, /* 重置表单 */ restForm(form) { this.$refs[form].resetFields(); }, /* 改变页数事件 */ onChangePage(page, pageSize) { this.pageIndex = page; this.getBankList(); }, /* 改变每页显示条数 */ onShowSizeChange(current, pageSize) { this.pageIndex = 1; this.pageSize = pageSize; this.getBankList(); }, /* 题库信息列表 */ getBankList() { this.loading = true; this.searchForm.page = this.pageIndex; this.searchForm.rows = this.pageSize; req('post', '/bank/list', this.searchForm) .then((res) => { if (res.result === 'success') { this.dataList = res.data; this.QX = res.QX; // 无权限隐藏操作列 if (!this.QX.edit && !this.QX.delete) { this.hideAction(); } else if (columns[columns.length - 1].title != '操作') { columns.push(actionShow); } this.totalPage = res.page.totalResult; } this.loading = false; }).catch((error) => { this.loading = false; }); }, /* 无所有行操作权限时,隐藏操作栏 */ hideAction() { if (columns[columns.length - 1].title == '操作') { columns.splice(columns.length - 1, 1); } }, /* 校验代号类型 */ validCode(value) { if (value.length > 20) { value = value.slice(0, 20); } for (let i = value.length - 1; i >= 0; i--) { const unicode = value.charCodeAt(i); if (unicode > 65280 && unicode < 65375) { value = value.substr(0, i); } } this.value = value; }, }, }; const actionShow = { title: '操作', width: '200px', hide: true, dataIndex: 'action', key: 'action', align: 'center', scopedSlots: { customRender: 'action' }, }; const columns = [ { title: '序号', width: '50px', align: 'center', customRender: (text, row, index) => index + 1, }, { title: '题库名称', align: 'center', dataIndex: 'title', key: 'title', width: '120px', }, { title: '涉及岗位', align: 'center', dataIndex: 'positionName', key: 'positionName', width: '110px', }, { title: '题目数量', dataIndex: 'topicCount', key: 'topicCount', align: 'center', width: '180px', }, { title: '操作', width: '150px', hide: true, dataIndex: 'action', key: 'action', align: 'center', scopedSlots: { customRender: 'action' }, }, ]; </script> <style scoped> .topic-list-container { max-height: calc(100vh - 400px); /* 根据实际布局调整最大高度 */ overflow-y: auto; } .pagination-wrapper { position: sticky; bottom: 0; left: 0; right: 0; background: #fff; padding: 10px; z-index: 1; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); margin-top: 15px; } .topic-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; } .topic-item { border: 1px solid #e8e8e8; padding: 15px; border-radius: 4px; position: relative; /* 为绝对定位的子元素提供定位上下文 */ } .topic-content { font-size: 16px; margin-bottom: 10px; } .options label { display: block; margin: 5px 0; font-size: 14px; } .options input[type="radio"] { margin-right: 5px; } /* 按钮禁用状态样式优化 */ .ant-upload.ant-upload-disabled .ant-upload-list, .ant-btn[disabled] { cursor: not-allowed; opacity: 0.5; } .topic-delete { position: absolute; top: 10px; right: 10px; } </style> <style scoped> @import "../../../assets/css/maincss.css"; </style> 在编辑页面中选择某个题目的选项后,再次打开该题时,默认显示的是上次选择的选项而不是正确答案。修改此问题
07-02
// @ts-nocheck class SweetalertSystem { constructor() { this.fieldRegistry = {}; this.modalRegistry = {}; // 添加模态类型注册表 this.nestedModalStack = []; // 添加嵌套模态栈 this.initCoreComponents(); // 初始化事件处理器映射 this.buttonHandlers = new Map(); this.addEntityButtons = null; } initCoreComponents() { // 注册核心字段类型 this.registerFieldType('text', { render: (config) => { return `<div class="mb-3"> <label class="form-label">${config.label}${config.required ? '*' : ''}</label> <input type="text" class="form-control" name="${config.name}" value="${config.value || ''}" ${config.required ? 'required' : ''} placeholder="${config.placeholder || ''}"> </div>`; } }); this.registerFieldType('select', { render: (config) => { const options = (config.options || []) .map(opt => `<option value="${opt.value}" ${config.value == opt.value ? 'selected' : ''}>${opt.label}</option>`) .join(''); return `<div class="mb-3"> <label class="form-label">${config.label}${config.required ? '*' : ''}</label> <div class="input-group"> <select class="form-select" name="${config.name}" ${config.required ? 'required' : ''}> <option value="">${config.placeholder || '请选择'}</option> ${options} </select> ${config.addButton ? ` <button class="btn btn-outline-secondary add-entity-btn" type="button" data-target-field="${config.name}"> <i class="fa fa-plus"></i> ${config.addButton.label} </button> ` : ''} </div> </div>`; }, // 更新 afterRender 方法 afterRender: (element, config) => { if (config.select2) { const $select = $(element).find('select'); const swalContainer = Swal.getContainer(); this.safeInitSelect2($select, { theme: 'bootstrap', placeholder: config.placeholder || '请选择', allowClear: true, dropdownParent: swalContainer || document.body }); } } }); this.registerFieldType('number', { render: (config) => { return `<div class="mb-3"> <label class="form-label">${config.label}${config.required ? '*' : ''}</label> <input type="number" class="form-control" name="${config.name}" value="${config.value || ''}" ${config.required ? 'required' : ''} step="${config.step || 1}" min="${config.min || 0}"> </div>`; } }); this.registerFieldType('checkbox', { render: (config) => { return `<div class="mb-3 form-check"> <input type="checkbox" class="form-check-input" name="${config.name}" id="${config.name}" ${config.value ? 'checked' : ''}> <label class="form-check-label" for="${config.name}">${config.label}</label> </div>`; } }); } // 修改注册方法 - 接受对象而不是函数 registerFieldType(type, definition) { if (!definition.render || typeof definition.render !== 'function') { throw new Error(`Field type '${type}' must have a render function`); } this.fieldRegistry[type] = definition; } // === 字段渲染方法 === renderTextField(config) { return `<div class="mb-3"> <label class="form-label">${config.label}${config.required ? '*' : ''}</label> <input type="text" class="form-control" name="${config.name}" value="${config.value || ''}" ${config.required ? 'required' : ''} placeholder="${config.placeholder || ''}"> </div>`; } renderSelectField(config) { const options = (config.options || []) .map(opt => `<option value="${opt.value}" ${config.value == opt.value ? 'selected' : ''}>${opt.label}</option>`) .join(''); return `<div class="mb-3"> <label class="form-label">${config.label}${config.required ? '*' : ''}</label> <div class="input-group"> <select class="form-select" name="${config.name}" ${config.required ? 'required' : ''}> <option value="">${config.placeholder || '请选择'}</option> ${options} </select> ${config.addButton ? ` <button class="btn btn-outline-secondary add-entity-btn" type="button" data-target-field="${config.name}"> <i class="fa fa-plus"></i> ${config.addButton.label} </button> ` : ''} </div> </div>`; } renderNumberField(config) { return `<div class="mb-3"> <label class="form-label">${config.label}${config.required ? '*' : ''}</label> <input type="number" class="form-control" name="${config.name}" value="${config.value || ''}" ${config.required ? 'required' : ''} step="${config.step || 1}" min="${config.min || 0}"> </div>`; } renderCheckboxField(config) { return `<div class="mb-3 form-check"> <input type="checkbox" class="form-check-input" name="${config.name}" id="${config.name}" ${config.value ? 'checked' : ''}> <label class="form-check-label" for="${config.name}">${config.label}</label> </div>`; } // === 核心方法 ===// === 核心方法 === /** * 打开表单弹窗(支持多个新建按钮) * @param {Object} config - 配置对象 */ async openForm(config) { const { title, fields, onSubmit, onAddEntity } = config; // 生成表单HTML const formHTML = fields.map(fieldConfig => { if (!fieldConfig.type) return '<div class="error">Missing field type</div>'; const fieldType = this.fieldRegistry[fieldConfig.type]; if (!fieldType) return `<div class="error">Field type '${fieldConfig.type}' not supported</div>`; return fieldType.render(fieldConfig); }).join(''); // 创建弹窗 return new Promise((resolve) => { Swal.fire({ title, html: `<form>${formHTML}</form>`, focusConfirm: false, showCancelButton: true, confirmButtonText: config.confirmButtonText || '保存', cancelButtonText: config.cancelButtonText || '取消', preConfirm: () => this.collectFormData(), // ... 配置 ... didOpen: () => { // 使用 MutationObserver 确保 DOM 完全渲染 const observer = new MutationObserver(() => { if (Swal.getPopup().querySelectorAll('.add-entity-btn').length > 0) { observer.disconnect(); this.setupMultiButtonHandlers(config, onAddEntity); } }); observer.observe(Swal.getPopup(), { childList: true, subtree: true }); }, willClose: () => { this.cleanupMultiButtonHandlers(); this.destroyAllSelect2(); // 确保清理所有 Select2 实例 } }).then((result) => { if (result.isConfirmed) { onSubmit(result.value); resolve(true); } else { resolve(false); } }); }); } collectFormData() { const data = {}; const popup = Swal.getPopup(); const form = popup.querySelector('form'); if (form) { const formData = new FormData(form); for (const [name, value] of formData.entries()) { // 处理多值字段 if (data[name]) { if (!Array.isArray(data[name])) { data[name] = [data[name]]; } data[name].push(value); } else { data[name] = value; } } } return data; } setupEventHandlers(config) { const popup = Swal.getPopup(); // 绑定添加按钮事件 popup.querySelectorAll('.add-entity-btn').forEach(btn => { btn.addEventListener('click', async () => { const targetField = btn.dataset.targetField; if (config.onAddEntity) { const newItem = await config.onAddEntity(targetField); if (newItem) { this.updateSelectField(popup, targetField, newItem); } } }); }); } // === 模态框注册方法 === registerModalType(name, config) { // 添加afterRender处理 const enhancedConfig = { ...config, afterRender: (config, container) => { // 初始化Select2 container.find('.select2-field').each(function() { const $select = $(this); $select.select2({ theme: 'bootstrap', placeholder: $select.attr('placeholder') || '请选择', allowClear: true, dropdownParent: $select.closest('.modal') }); }); // 调用原始afterRender(如果存在) if (config.afterRender) { config.afterRender(config, container); } } }; this.modalRegistry[name] = enhancedConfig; } // 注册实体表单 registerEntityForm(entityType, fields) { this.registerModalType(entityType, { template: `<div class="modal fade" id="${entityType}Modal" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="${entityType}Title"></h5> <button type="button" class="btn-close" data-bs-dismiss="modal"></button> </div> <div class="modal-body" id="${entityType}Body"></div> <div class="modal-footer"> <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button> <button type="button" class="btn btn-primary" id="${entityType}Submit">保存</button> </div> </div> </div> </div>`, render: (config, container) => { container.find(`#${entityType}Title`).text(config.title); let formHTML = ''; // 确保fields是数组 const fields = Array.isArray(config.fields) ? config.fields : []; fields.forEach(fieldConfig => { const fieldType = this.fieldRegistry[fieldConfig.type]; if (fieldType && fieldType.render) { formHTML += fieldType.render(fieldConfig); } }); container.find(`#${entityType}Body`).html(formHTML); }, getFormData: (container) => { const formData = {}; container.find('input, select, textarea').each(function() { const $el = $(this); const name = $el.attr('name'); if (!name) return; if ($el.attr('type') === 'checkbox') { formData[name] = $el.is(':checked'); } else { formData[name] = $el.val(); } }); return formData; }, bindEvents: (config, container, onSubmit) => { container.find(`#${entityType}Submit`).off('click').on('click', () => { const formData = this.getFormData(container); onSubmit(formData); }); } }); } // 打开模态框 open(modalType, config, callbacks = {}) { // 如果当前有激活的弹窗,先隐藏它 if (this.nestedModalStack.length > 0) { const currentModal = this.nestedModalStack[this.nestedModalStack.length - 1]; currentModal.hide(); } // 检查模态类型是否注册 if (!this.modalRegistry[modalType]) { console.error(`未注册的模态类型: ${modalType}`); return null; } const modalConfig = this.modalRegistry[modalType]; const modalId = `${modalType}Modal`; let $modal = $(`#${modalId}`); // 如果模态框不存在则创建 if ($modal.length === 0) { $modal = $(modalConfig.template); $('body').append($modal); } // 清除之前的模态框实例 if ($modal.data('bs.modal')) { $modal.data('bs.modal').dispose(); } // 渲染模态内容 modalConfig.render(config, $modal); // 绑定事件 if (modalConfig.bindEvents) { modalConfig.bindEvents(config, $modal, callbacks.onSubmit || (() => {})); } // 创建模态实例 const modalInstance = new bootstrap.Modal($modal[0]); // 执行afterRender回调 if (modalConfig.afterRender) { modalConfig.afterRender(config, $modal); } // 初始化Select2 $modal.find('.select2-field').each(function() { const $select = $(this); $select.select2({ theme: 'bootstrap', placeholder: $select.attr('placeholder') || '请选择', allowClear: true, dropdownParent: $select.closest('.modal') }); }); // 显示弹窗 modalInstance.show(); // 将新弹窗加入栈 const modalObj = { hide: () => modalInstance.hide(), show: () => modalInstance.show(), getElement: () => $modal[0], config }; this.nestedModalStack.push(modalObj); // 使用延迟确保 DOM 完全渲染 setTimeout(() => { // 安全初始化 Select2 $modal.find('.select2-field').each((index, element) => { const $select = $(element); this.safeInitSelect2($select, { theme: 'bootstrap', placeholder: $select.attr('placeholder') || '请选择', allowClear: true, dropdownParent: $modal }); }); // 绑定新建按钮事件 $modal.find('.add-entity-btn').on('click', async () => { const entityType = $(this).data('entityType'); const targetField = $(this).data('targetField'); if (callbacks.onAddEntity) { const newItem = await callbacks.onAddEntity(entityType, targetField); if (newItem) { this.updateSelectField($modal[0], targetField, newItem); } } }); }, 50); // 返回包含关闭方法的实例对象 return modalObj; } // 关闭当前弹窗并显示上一个 closeCurrentModal() { if (this.nestedModalStack.length > 0) { const currentModal = this.nestedModalStack.pop(); currentModal.hide(); // 如果有上一个弹窗,显示它 if (this.nestedModalStack.length > 0) { const prevModal = this.nestedModalStack[this.nestedModalStack.length - 1]; prevModal.show(); } } } // 获取表单数据 getFormData(container) { const formData = {}; container.find('input, select, textarea').each(function() { const $el = $(this); const name = $el.attr('name'); if (!name) return; if ($el.attr('type') === 'checkbox') { formData[name] = $el.is(':checked'); } else if ($el.attr('type') === 'radio') { if ($el.is(':checked')) { formData[name] = $el.val(); } } else { formData[name] = $el.val(); } }); return formData; } /** * 设置多个按钮的事件处理 * @param {Object} config - 配置对象 * @param {Function} onAddEntity - 添加实体的回调函数 */ setupMultiButtonHandlers(config, onAddEntity) { const popup = Swal.getPopup(); // 确保弹窗存在 if (!popup) { console.warn('弹窗不存在,无法绑定事件'); return; } // 移除旧的事件监听器(防止重复绑定) this.cleanupMultiButtonHandlers(); // 绑定所有添加按钮事件 this.addEntityButtons = Array.from(popup.querySelectorAll('.add-entity-btn')); this.addEntityButtons.forEach(btn => { const handler = async () => { const targetField = btn.dataset.targetField; const entityType = btn.dataset.entityType; if (onAddEntity) { const newItem = await onAddEntity(entityType, targetField); if (newItem) { this.updateSelectField(popup, targetField, newItem); } } }; btn.addEventListener('click', handler); // 保存处理器以便后续清理 this.buttonHandlers.set(btn, handler); }); } /** * 清理按钮事件处理器 */ cleanupMultiButtonHandlers() { if (this.addEntityButtons) { this.addEntityButtons.forEach(btn => { const handler = this.buttonHandlers.get(btn); if (handler) { btn.removeEventListener('click', handler); this.buttonHandlers.delete(btn); } }); this.addEntityButtons = null; } } /** * 更新下拉框选项 * @param {HTMLElement} popup - 弹窗元素 * @param {string} fieldName - 字段名 * @param {Object} newItem - 新选项 {value, label} */ updateSelectField(popup, fieldName, newItem) { // 确保弹窗仍然存在 if (!popup || !popup.isConnected) { console.warn('弹窗已关闭,无法更新字段'); return; } const select = popup.querySelector(`select[name="${fieldName}"]`); if (select) { // 添加新选项 const option = document.createElement('option'); option.value = newItem.value; option.textContent = newItem.label; option.selected = true; select.appendChild(option); // 如果使用Select2,刷新组件 if ($(select).hasClass('select2-hidden-accessible')) { $(select).trigger('change'); } } } // 安全初始化 Select2 safeInitSelect2($select, options) { try { // 检查是否已初始化 if ($select.data('select2')) { this.safeDestroySelect2($select); } // 设置 dropdownParent 确保在模态框内正确显示 const dropdownParent = options.dropdownParent || Swal.getPopup() || document.body; $select.select2({ ...options, dropdownParent }); $select.addClass('select2-initialized'); return true; } catch (error) { console.error('Select2 initialization failed:', error); return false; } } // 安全销毁 Select2 safeDestroySelect2($select) { try { if ($select.data('select2')) { $select.select2('destroy'); } $select.removeClass('select2-initialized'); return true; } catch (error) { console.error('Select2 destruction failed:', error); return false; } } // 清理所有 Select2 实例 destroyAllSelect2() { const popup = Swal.getPopup(); if (popup) { $(popup).find('.select2-initialized').each((index, element) => { this.safeDestroySelect2($(element)); }); } } } export default SweetalertSystem; SweetalertSystem2.js:472 Uncaught TypeError: Cannot read properties of null (reading ‘querySelectorAll’) at SweetalertSystem.open (SweetalertSystem2.js:472:20) at HTMLButtonElement.showDingdanModal (tianjia3.js:316:55) at HTMLButtonElement.dispatch (jquery-3.2.1.min.js:
最新发布
07-04
return Array.from(sectionMap).map(([name, settings]) => ({ sectionName: name, settings }));这里有报错:Destructuring parameter declarations are not supported (arkts-no-destruct-params) <ArkTSCheck> ; const value = rawItem[key]; 这里 Use explicit types instead of "any", "unknown" (arkts-no-any-unknown) <ArkTSCheck> Indexed access is not supported for fields (arkts-no-props-by-index) <ArkTSCheck> , value: value.map((nestedItem: any) => {:Use explicit types instead of "any", "unknown" (arkts-no-any-unknown) <ArkTSCheck> ; const titles: Partial<Record<SettingKeys, string>> = { :Some of utility types are not supported (arkts-no-utility-types) <ArkTSCheck> ,Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck>;return titles[key] || key.toString(); :Indexed access is not supported for fields (arkts-no-props-by-index) <ArkTSCheck> ; private getTypeByKey(key: SettingKeys): UISettingItem['type'] { :Indexed access types are not supported (arkts-no-aliases-by-index) <ArkTSCheck> ; const descriptions: Partial<Record<SettingKeys, string>> = { captureLinkage: '抓拍时自动生成一段关联视频', speedOsd: '数据来源于GPS,设备需内置或扩展GPS模块', parkingMonitoringEnable: '停车后自动启动监控功能', parkingSensitivity: '灵敏度设置越高,监测越敏感但电池消耗更快', ADAS: '高级驾驶辅助系统设置', GPS: '全球定位系统配置', cellular: '移动网络配置', parkingMonitoringTime: '设置停车监控的最长持续时间', cloudBox: '云存储服务设置' }; return descriptions[key]; :Some of utility types are not supported (arkts-no-utility-types) <ArkTSCheck> Indexed access is not supported for fields (arkts-no-props-by-index) <ArkTSCheck> ; const newSections = this.sections.map(section => ({ ...section, settings: section.settings.map(item => item.key === key ? { ...item, value } : item :Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck> ,It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread) <ArkTSCheck> ; Section({ :Cannot find name 'Section'. Did you mean 'section'? <ArkTSCheck> ; this.SettingGroup({ title: item.title, description: item.description, items: item.value as UISettingItem[] }) Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck>;:Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck> ; this.SettingItem({ item: item, onChange: (value) => this.handleSettingChange(item.key, value) }) 'this.SettingItem({ item: item, onChange: (value) => this.handleSettingChange(item.key, value) })' does not comply with the UI component syntax. <ArkTSCheck> Property 'SettingItem' does not exist on type 'Configure'. <ArkTSCheck> ,请帮我修改,并给我完整代码
06-11
String.prototype.trim = function(){return this.replace(/(^[\s]*)|([\s]*$)/g, "");}; String.prototype.lTrim = function(){return this.replace(/(^[\s]*)/g, "");}; String.prototype.rTrim = function(){return this.replace(/([\s]*$)/g, "");}; if(typeof Array.indexOf != "function") Array.prototype.indexOf = function(arg, n){ var i = isNaN(n) || n < 0 ? 0 : n; for(; i < this.length; i++) if(this[i] == arg) return i; return -1; }; var AsControl = { _getDefaultOpenStyle:function() { return "width="+screen.availWidth+"px,height="+screen.availHeight+"px,top=0,left=0,toolbar=no,scrollbars=yes,resizable=yes,status=no,menubar=no"; }, _getDefaultDialogStyle:function() { return "dialogWidth:"+screen.availWidth+"px;dialogHeight:"+screen.availHeight+"px;resizable:yes;maximize:yes;help:no;status:no;"; }, _getDialogStyle:function(sStyle) { if(typeof(sStyle)=="undefined" || sStyle=="") return this._getDefaultDialogStyle(); else return sStyle; }, _getParaString:function(sPara) { if(typeof(sPara)=="undefined" || sPara=="") { return ""; } else if (sPara.substring(0,1)=="&") { return encodeURI(encodeURI(sPara)); } else { return "&"+encodeURI(encodeURI(sPara)); } }, randomNumber:function() { return Math.abs(Math.sin(new Date().getTime())).toString().substr(2); } }; AsControl.OpenObjectTab = function(sPara){ if(sPara.indexOf("ObjectType=")<0){ alert("参数串必须有ObjectType定义!"); return; } if(sPara.indexOf("ObjectNo=")<0){ alert("参数串必须有ObjectNo定义!"); return; } /*if(sPara.indexOf("ViewID=")<0){ alert("参数串必须有ViewID定义!"); return; }*/ this.PopView("/Frame/ObjectTab.jsp", sPara); }; AsControl.OpenObject = function(sObjectType,sObjectNo,sViewID,sStyle){ return OpenObject(sObjectType,sObjectNo,sViewID,sStyle); // }; AsControl.PopObject = function(sObjectType,sObjectNo,sViewID,sDialogStyle,sDialogParas){ return PopObject(sObjectType,sObjectNo,sViewID,sDialogStyle,sDialogParas); // }; AsControl.OpenPage = function(sURL,sPara,sTargetWindow,sStyle) { if(typeof(sURL)=="undefined" || sURL=="") { alert("系统繁忙,请关掉窗口或刷新后重试!"); return false; } if(sURL.indexOf("?")>=0){ alert("URL中存在\"?\"!"); return false; } if(sTargetWindow=="_blank") { alert("弹出的页面不能使用OpenPage函数!"); return false; } var temp_targetWindow=""; try{ temp_targetWindow = Layout.getRegionName(sTargetWindow); sTargetWindow=temp_targetWindow; }catch(e){ } var sWindowToUnload; if(sTargetWindow==null || sTargetWindow=="_self"){ sWindowToUnload="self"; }else if(sTargetWindow=="_top"){ sWindowToUnload="top"; }else if(sTargetWindow=="_blank"){ sWindowToUnload=""; }else if(sTargetWindow=="_parent"){ sWindowToUnload="parent"; }else sWindowToUnload=sTargetWindow; try{ oWindow = eval(sWindowToUnload); }catch(e){ } if(window.checkOpenUrlModified != false){ try{ oWindow = eval(sWindowToUnload); if(!oWindow.checkModified()) return; }catch(e){ try{if(!parent.frames[sWindowToUnload].checkModified()) return;}catch(e2){} } } var sPageURL=sWebRootPath+sURL; if(sURL.indexOf("?")<0) {sPageURL = sPageURL+"?"; } else if (sURL.substr(sURL.length-1)!="?"){sPageURL = sPageURL+"&";} sPageURL = sPageURL + "CompClientID="+sCompClientID+this._getParaString(sPara)+"&randp="+this.randomNumber(); this.switchDiv(sTargetWindow); if(typeof(sStyle)=="undefined") sStyle=AsControl._getDefaultOpenStyle(); window.open(sPageURL,sTargetWindow,sStyle); }; AsControl.OpenCompNewWin = function(sURL,sPara,sStyle) { if(sURL.indexOf("?")>=0) { alert("URL中存在\"?\"!"); return false; } var sCompPara = sPara; while(sCompPara.indexOf("&")>=0) sCompPara = sCompPara.replace("&","$[and]"); var sPageURL = sWebRootPath+"/RedirectorDialog?&TargetWindow=_blank&DiaglogURL=/Frame/page/control/OpenCompDialog.jsp&ComponentURL="+sURL+this._getParaString("CompPara="+sCompPara); window.open(sPageURL,"_blank",this._getDefaultOpenStyle()); }; AsControl.OpenComp = function(sURL,sPara,sTargetWindow,sStyle) { if(sURL.indexOf("?")>=0) { alert("URL中存在\"?\"!"); return false; } sTargetWindow = Layout.getRegionName(sTargetWindow); var sToDestroyClientID=""; var sWindowToUnload = sTargetWindow; if(sTargetWindow=="_blank") { return this.PopComp(sURL,sPara); }else{ if(sTargetWindow==null || sTargetWindow=="_self") sWindowToUnload="self"; else if(sTargetWindow=="_top") sWindowToUnload="top"; try{ oWindow = eval(sWindowToUnload); sToDestroyClientID = oWindow.sCompClientID; if (sWindowToUnload !="self" && sWindowToUnload !="top" && sToDestroyClientID==sCompClientID) sToDestroyClientID = ""; }catch(e){ sToDestroyClientID = ""; } if(window.checkOpenUrlModified != false){ try{if(!oWindow.checkModified()) return;}catch(e1){ try{if(!parent.frames[sWindowToUnload].checkModified()) return;}catch(e2){} } } } if(typeof(sToDestroyClientID)=="undefined" || sToDestroyClientID=="") {sToDestroyClientID="&TargetWindow="+sTargetWindow;} else {sToDestroyClientID="&TargetWindow="+sTargetWindow+"&ToDestroyClientID="+sToDestroyClientID;} var sPageURL = sWebRootPath + "/Redirector?OpenerClientID="+sCompClientID+sToDestroyClientID+"&ComponentURL="+sURL+this._getParaString(sPara); this.switchDiv(sTargetWindow); this._OpenIFrame(sPageURL,sTargetWindow); }; AsControl._OpenIFrame = function(sPageURL,sIFrame) { if (!document.body) { window.open(sPageURL,sIFrame); return; } var a = document.createElement('a'); a.setAttribute('href', sPageURL); a.setAttribute('target',sIFrame); a.setAttribute('id', "ID_"+sIFrame); document.body.appendChild(a); a.click(); document.body.removeChild(a); } /** * 校验窗口内所有页面是否都未做修改 * @param win 被校验的窗口对象,如window、self、top或frames[name]等 * @returns {boolean} true 校验通过,false 校验不通过 */ AsControl.CheckWindowModified = function(win){ try{ if(typeof win.checkModified == "function" && !win.checkModified()) return false; } catch (e) {return true;} for(var i = 0; i < win.frames.length; i++){ if(!AsControl.CheckWindowModified(win.frames[i])) return false; } return true; }; /** * 根据iFrame的字符串名字获取iFrame对象 * @param sFrame iFrame的字符串名字 * @returns iFrame对象 */ AsControl.getOFrame = function(sFrame) { var frame = null; if(typeof sFrame !== "string") return frame; if(sFrame === "_top"){ frame = top; }else if(sFrame == self.name || sFrame === "_self"){ frame = window; }else{ var win = window; while(true){ try {frame = win.frames[sFrame];} catch(e){break;} if(frame) break; if(win.parent === win) break; win = win.parent; } } return frame; } AsControl.switchDiv = function(sTargetWindow) { if(window.showDiv==false) return; var frame = AsControl.getOFrame(sTargetWindow); if(!frame) return; try {frame.document;} catch(e){return;} var doc = frame.document; if(!doc || !doc.body) return; try { var switch_mask_div = doc.getElementById("switch_page_mask"); if (switch_mask_div) { switch_mask_div.style.display="block"; return; } var sm_child_div_span = doc.createElement("span"); sm_child_div_span.style.cssText = "color:#772200;display:block;font-size:14px"; sm_child_div_span.textContent="页面切换中,请等待......"; var sm_child_count_span = doc.createElement("span"); sm_child_count_span.id = "switch_page_mask_count"; sm_child_div_span.appendChild(sm_child_count_span); var sm_child_div = doc.createElement("div"); sm_child_div.style.cssText = "position:absolute;left:0;top:0;width:100%;height:100%;background:#e8e8e8;filter:alpha(opacity=60);opacity:0.6;z-index:-1;"; var width = Math.max(doc.body.scrollWidth, doc.documentElement.scrollWidth)-20; var height = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight)-20; var sm_div = doc.createElement("div"); sm_div.id = "switch_page_mask"; sm_div.style.cssText = "position:absolute;left:0;top:0;width:"+width+"px;height:"+height+"px;text-align:center;z-index:9999;"; if(!doc || !doc.body) return; sm_div.appendChild(sm_child_div); sm_div.appendChild(sm_child_div_span); doc.body.appendChild(sm_div); } catch (e) {}; var mask_timer = setTimeout(function(){ try{ if(!frame||!doc || !doc.body) {clearTimeout(mask_timer);return;} frame.switchDivFlag=true; var mask_interval= setInterval(function(){ try{ if(!frame||!doc || !doc.body) {clearInterval(mask_interval);return;} var switch_page_mask_count = doc.getElementById("switch_page_mask_count"); if (!switch_page_mask_count) {clearInterval(mask_ierval);return;} var time = parseInt(switch_page_mask_count.textContext||switch_page_mask_count.innerText, 10); if(isNaN(time)) time = 0; switch_page_mask_count.textContent =""+ (++time); //console.log("time:"+time+"switch_page_mask_count.textContent:"+switch_page_mask_count.textContent+"switchDivFlag:"+frame.switchDivFlag); //console.trace(); if (time > 60 || !frame.switchDivFlag) {clearInterval(mask_interval);return;} }catch(e){clearInterval(mask_interval);} }, 1000); }catch(e){} }, 100); } ; AsControl.showReadyMessage = function(msg) { var top =AsDialog._getTop(); try {top.document;} catch(e){return;} var doc = top.document; if(!doc || !doc.body) return; try { var switch_mask_div = doc.getElementById("page_ready_mask"); if (switch_mask_div) { switch_mask_div.style.display="block"; return; } var sm_child_div_span = doc.createElement("span"); sm_child_div_span.style.cssText = "color:#668800;display:block;font-size:14px;padding:100px"; sm_child_div_span.textContent="页面正在初始化,请稍等......"; if (msg ) sm_child_div_span.textContent=msg; var sm_child_div = doc.createElement("div"); sm_child_div.style.cssText = "position:absolute;left:0;top:0;width:100%;height:100%;background:#e8e8e8;filter:alpha(opacity=60);opacity:0.6;z-index:-1;"; var width = Math.max(doc.body.scrollWidth, doc.documentElement.scrollWidth); var height = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight); var sm_div = doc.createElement("div"); sm_div.id = "page_ready_mask"; sm_div.style.cssText = "position:absolute;display:block;left:0;top:0;width:"+width+"px;height:"+height+"px;text-align:center;z-index:10001;"; sm_div.appendChild(sm_child_div); sm_div.appendChild(sm_child_div_span); doc.body.appendChild(sm_div); switch_mask_div = doc.getElementById("page_ready_mask"); } catch (e) {}; } ; AsControl.hideReadyMessage = function() { var top =AsDialog._getTop(); try {top.document;} catch(e){return;} var doc = top.document; if(!doc || !doc.body) return; try { var switch_mask_div = doc.getElementById("page_ready_mask"); if (switch_mask_div) { switch_mask_div.style.display="none"; return; } } catch (e) {}; } ; AsControl.PopPage = function(sURL,sPara,sStyle,dialogArgs){ if(sURL.indexOf("?")>=0){ alert("错误:页面URL中存在\"?\"。请将页面参数在第二个参数中传入!"); return false; } var sDialogStyle = this._getDialogStyle(sStyle); var sPageURL = sWebRootPath+"/RedirectorDialog?DiaglogURL="+sURL+"&OpenerClientID="+sCompClientID+"&ComponentURL="+sURL+this._getParaString(sPara); if (!window.showModalDialog) {alert("本功能PopPage暂时只支持IE11!"); console.trace();return;} if (typeof(dialogArgs) == "undefined" ) dialogArgs=self; return window.showModalDialog(sPageURL,dialogArgs,sDialogStyle); }; AsControl.PopPageEx = function(sURL,sPara,oTarget,sStyle){ if(sURL.indexOf("?")>=0){ alert("错误:页面URL中存在\"?\"。请将页面参数在第二个参数中传入!"); return false; } var sDialogStyle = this._getDialogStyle(sStyle); var sPageURL = sWebRootPath+"/RedirectorDialog?DiaglogURL="+sURL+"&OpenerClientID="+sCompClientID+"&ComponentURL="+sURL+this._getParaString(sPara); if (!window.showModalDialog) {alert("本功能showModalDialog暂时只支持IE11!"); console.trace();return;} return window.showModalDialog(sPageURL,oTarget,sDialogStyle); }; AsControl.PopComp = function(sURL,sPara,sStyle,dialogArgs){ if(sURL.indexOf("?")>=0) { alert("URL中存在\"?\"!"); return false; } var sDialogStyle = this._getDialogStyle(sStyle); var sCompPara = sPara; while(sCompPara.indexOf("&")>=0) sCompPara = sCompPara.replace("&","$[and]"); var sPageURL = sWebRootPath+"/RedirectorDialog?DiaglogURL=/Frame/page/control/OpenCompDialog.jsp&OpenerClientID="+sCompClientID+"&ComponentURL="+sURL+this._getParaString("CompPara="+sCompPara); if (!window.showModalDialog) {alert("本功能PopComp暂时只支持IE11!"); console.trace();return;} if (typeof(dialogArgs) == "undefined" ) dialogArgs=self; return window.showModalDialog(sPageURL,dialogArgs,sDialogStyle); }; AsControl.OpenPageOld = function(sURL,sTargetWindow,sStyle) { if(sTargetWindow=="_blank") { alert("弹出的页面不能使用OpenPage函数!");} var sPageURL=sURL; var sPara = ""; if(sURL.indexOf("?")>0) { sPageURL = sURL.substring(0,sURL.indexOf("?")); sPara = sURL.substring(sURL.indexOf("?")+1); } this.OpenPage(sPageURL, sPara, sTargetWindow,sStyle); }; AsControl.PopPageOld = function(sURL,sStyle){ var sPageURL=sURL; var sPara = ""; if(sURL.indexOf("?")>0) { sPageURL = sURL.substring(0,sURL.indexOf("?")); sPara = sURL.substring(sURL.indexOf("?")+1); } return this.PopPage(sPageURL, sPara, sStyle); }; AsControl.OpenView = function(sURL,sPara,sTargetWindow,sStyle){ return this.OpenComp(sURL,sPara,sTargetWindow,sStyle);}; AsControl.PopView = function(sURL, sPara, sStyle, dialogArgs){ return this.PopComp(sURL, sPara, sStyle, dialogArgs);}; AsControl.DestroyComp = function (ToDestroyClientID) { $.ajax({url: sWebRootPath+"/Frame/page/control/DestroyCompAction.jsp?ToDestroyClientID="+ToDestroyClientID,async: false}); }; AsControl.RunJavaMethod = function (ClassName,MethodName,Args) { return AsControl.GetJavaMethodReturn(AsControl.CallJavaMethod(ClassName,MethodName,Args,""),ClassName); }; AsControl.RunJavaMethodSqlca = function (ClassName,MethodName,Args) { return AsControl.GetJavaMethodReturn(AsControl.CallJavaMethod(ClassName,MethodName,Args,"&ArgsObject=Sqlca"),ClassName); }; AsControl.RunJavaMethodTrans = function (ClassName,MethodName,Args) { return AsControl.GetJavaMethodReturn(AsControl.CallJavaMethod(ClassName,MethodName,Args,"&ArgsObject=Trans"),ClassName); }; AsControl.ExportFinanceReport = function(sObjectType, sObjectNo, sReportScope, sReportDate){ var sParam; if(arguments.length == 1) sParam = "ReportNo="+arguments[0]; else sParam = "ObjectType="+ObjectType+",ObjectNo="+sObjectNo+",ReportScope="+sReportScope+",ReportDate="+sReportDate; var sReportExcelPath = AsControl.RunJavaMethodSqlca("com.amarsoft.biz.finance.ExportExcel", "run", sParam); if(!sReportExcelPath) return; if(!frames["exportfsframe"]) $("<iframe name='exportfsframe' style='display:none;'></iframe>").appendTo("body"); window.open(sWebRootPath+"/servlet/view/file?CompClientID="+sCompClientID+"&filename="+sReportExcelPath+"&viewtype=download", "exportfsframe"); }; AsControl.CallJavaMethodJSP = function (ClassName,MethodName,Args,ArgsObjectText) { return $.ajax({ url: sWebRootPath+"/Frame/page/sys/tools/RunJavaMethod.jsp?ClassName="+ClassName+"&MethodName="+MethodName+this._getParaString("Args="+Args)+ArgsObjectText, async: false }).responseText.trim(); }; AsControl.CallJavaMethod = function (ClassName,MethodName,Args,ArgsObjectText) { return $.ajax({ type: "POST", url: sWebRootPath+"/servlet/run?1=1"+ArgsObjectText, data : { "ClassName":ClassName, "MethodName":MethodName, // FIXME 加号替换,请修改为特殊字符,见com.amarsoft.awe.control.RunJavaMethodServlet.doGet "Args":encodeURI(Args.replace(/\+/g, 'Ж').replace(/\%/g, 'ё')) }, async: false }).responseText.trim(); }; AsControl.GetJavaMethodReturn = function (sReturnText,ClassName) { /*window.onerror = function(msg, url, line) { if(msg.indexOf("AWS0003")>0||msg.indexOf("!DOCTYP")>0){ alert("运行异常:【操作超时】:可能是网络故障或您的电脑长时间未操作造成的页面超时,请重新登录!") return ; } console.trace(); alert("运行异常: " + msg + "\n"); //alert("JS异常: " + msg + "\n" + goUrlName(sWebRootPath,url) + ":" + line); return true; }; */ if (typeof(sReturnText)=='undefined' || sReturnText.length<8) { var msg="【AWES0007】后台服务调用出错!\n【"+ClassName+"】"; alert("运行异常: " + msg + "\n"); throw new Error(msg); } if(sReturnText.indexOf("AWES0003")>0 || sReturnText.indexOf("!DOCTYP")>0){ alert("运行异常:【操作超时】:可能是网络故障或您的电脑长时间未操作造成的页面超时,请重新登录!"); AsControl.OpenPage("/Frame/page/sys/SessionExpire.jsp", "", "_top", ""); return ; } var rCode = sReturnText.substring(0,8); if (rCode != '00000000') { var msg="【"+rCode+"】"+sReturnText.substring(8)+"\n【"+ClassName+"】"; alert("运行异常: " + msg + "\n"); throw new Error(msg); } sReturnText = sReturnText.substring(8); if(sReturnText.length>0 && sReturnText.substring(0,1)=="{") return eval("("+ sReturnText +")"); else{ sReturnText=this.clearString(sReturnText); return sReturnText; } }; AsControl.clearString=function(sReturnText){ try{ if(typeof(sReturnText)!="undefined"){ if(sReturnText.indexOf("系统错误")>0){ var tempText=sReturnText.split("系统错误"); sReturnText=tempText[tempText.length-1]; sReturnText=this.replaceAll(sReturnText,":",""); sReturnText=this.replaceAll(sReturnText,"执行script时出错",""); sReturnText=this.replaceAll(sReturnText,"com.amarsoft.app.als.sys.function.action.BizFunctionAction",""); sReturnText=this.replaceAll(sReturnText,"执行Bizlet时出错",""); sReturnText=this.replaceAll(sReturnText,"Bizlet",""); sReturnText=this.replaceAll(sReturnText,"。",""); sReturnText=this.replaceAll(sReturnText,":",""); sReturnText=this.replaceAll(sReturnText,":",""); sReturnText=this.replaceAll(sReturnText,":[",""); sReturnText=this.replaceAll(sReturnText,"]]",""); sReturnText=this.replaceAll(sReturnText,"]]",""); sReturnText=this.replaceAll(sReturnText,"[[",""); sReturnText=this.replaceAll(sReturnText,"[[",""); sReturnText=this.replaceAll(sReturnText,"FinishPutOut",""); sReturnText=this.replaceAll(sReturnText,"[]",""); sReturnText=this.replaceAll(sReturnText,"com.amarsoft.app.als.sys.function.action.BizFunctionAction",""); sReturnText=this.replaceAll(sReturnText,"执行Function错误","交易失败!"); return sReturnText; } } }catch(e){ alert(e.message); } return sReturnText; }; AsControl.replaceAll=function(sSource,sOldString,sNewString){ try{ if(typeof(sSource)!='string') return sSource; var iPosBegin = 0; sReturn = sSource; //alert(sReturn+"\r\n"+sOldString+"\r\n"+sNewString); iPosBegin = sReturn.indexOf(sOldString,iPosBegin); while(iPosBegin>=0){ //sReturn = sReturn.replace(sOldString,sNewString); sReturn = sReturn.substring(0,iPosBegin)+sNewString+sReturn.substring(iPosBegin+sOldString.length); iPosBegin = sReturn.indexOf(sOldString,iPosBegin+sNewString.length); } return sReturn; }catch(e){ alert(e.name+" "+e.number+" :"+e.message); } }; AsControl.RunJsp = function(sURL,sPara,fun) { if(sURL.indexOf("?")>=0){ alert("错误:页面URL中存在\"?\"。请将页面参数在第二个参数中传入!"); return false; } var sPageURL = sWebRootPath+sURL+"?CompClientID="+sCompClientID+this._getParaString(sPara); if(typeof fun == "function"){ return $.ajax({url:sPageURL,type:"POST",processData:false,async:true,success:fun}); }else{ return $.ajax({url:sPageURL,async:false}).responseText.trim(); } }; AsControl.RunJspOne = function(sURL) { var sPageURL=sURL; var sPara = ""; if(sURL.indexOf("?")>0) { sPageURL = sURL.substring(0,sURL.indexOf("?")); sPara = sURL.substring(sURL.indexOf("?")+1); } return this.RunJsp(sPageURL, sPara); }; AsControl.RunASMethod = function(ClassName,MethodName,Args) { return this.RunJsp("/Common/ToolsB/RunMethodAJAX.jsp","ClassName="+ClassName+"&MethodName="+MethodName+"&Args="+Args); }; AsControl.getErrMsg = function (MsgNo) { var ClassName="com.amarsoft.awe.res.ErrMsgManager"; var MethodName="getText"; var Args="MsgNo="+MsgNo; return AsControl.GetJavaMethodReturn(AsControl.CallJavaMethod(ClassName,MethodName,Args,""),ClassName); }; var OpenStyle=AsControl._getDefaultOpenStyle(); function randomNumber() { return AsControl.randomNumber();} function OpenComp(sCompID,sCompURL,sPara,sTargetWindow,sStyle) {return AsControl.OpenComp(sCompURL,sPara,sTargetWindow,sStyle);} function openComp(sCompID,sCompURL,sPara,sTargetWindow,sStyle) {return AsControl.OpenComp(sCompURL,sPara,sTargetWindow,sStyle);} function PopComp(sComponentID,sComponentURL,sParaString,sStyle) {return AsControl.PopComp(sComponentURL,sParaString,sStyle);} function popComp(sComponentID,sComponentURL,sParaString,sStyle) {return AsControl.PopComp(sComponentURL,sParaString,sStyle);} function PopPage(sURL,sTargetWindow,sStyle) {return AsControl.PopPageOld(sURL,sStyle);} function OpenPage(sURL,sTargetWindow,sStyle) {return AsControl.OpenPageOld(sURL,sTargetWindow,sStyle);} function RunJavaMethod(ClassName,MethodName,Args) {return AsControl.RunJavaMethod(ClassName,MethodName,Args);} function RunJavaMethodSqlca(ClassName,MethodName,Args) {return AsControl.RunJavaMethodSqlca(ClassName,MethodName,Args);} function RunJavaMethodTrans(ClassName,MethodName,Args) {return AsControl.RunJavaMethodTrans(ClassName,MethodName,Args);} function PopPageAjax(sURL,sTargetWindow,sStyle){return AsControl.RunJspOne(sURL);} function RunJspAjax(sURL,sTargetWindow,sStyle){return AsControl.RunJspOne(sURL);} function RunMethod(ClassName,MethodName,Args){return AsControl.RunASMethod(ClassName,MethodName,Args); } function getMessageText(iNo) { return AsControl.getErrMsg(iNo);} function openObjectInFrame(sObjectType,sObjectNo,sViewID,sFrameID){ AsControl.OpenComp("/Frame/ObjectViewer.jsp","ObjectType="+sObjectType+"&ObjectNo="+sObjectNo+"&ViewID="+sViewID,sFrameID,""); } function openObject(sObjectType,sObjectNo,sViewID,sStyle){ AsControl.PopComp("/Frame/ObjectViewer.jsp","ObjectType="+sObjectType+"&ObjectNo="+sObjectNo+"&ViewID="+sViewID,sStyle); } function openObjectNewWin(sObjectType,sObjectNo,sViewID,sStyle){ AsControl.OpenCompNewWin("/Frame/ObjectViewer.jsp","ObjectType="+sObjectType+"&ObjectNo="+sObjectNo+"&ViewID="+sViewID,sStyle); } function OpenObject(sObjectType,sObjectNo,sViewID,sStyle){ openObject(sObjectType,sObjectNo,sViewID,sStyle); } function popObject(sObjectType,sObjectNo,sViewID,sDialogStyle){ AsControl.PopComp("/Frame/ObjectViewer.jsp","ObjectType="+sObjectType+"&ObjectNo="+sObjectNo+"&ViewID="+sViewID,sDialogStyle); } function PopObject(sObjectType,sObjectNo,sViewID,sDialogStyle){ popObject(sObjectType,sObjectNo,sViewID,sDialogStyle); } function setWindowTitle(sTitle) { top.document.title=sTitle+"                                                                                                                                                          "; } function setDialogTitle(sTitle) { var tempWindow = self; do{ var title=getDialogTitle(); if(typeof(title)!="undefined" && title.length>0) return ; if(typeof tempWindow.setTopTitle == "function"){ tempWindow.setTopTitle(sTitle); break; } if(tempWindow == tempWindow.parent) break; tempWindow = tempWindow.parent; }while(true); } function getDialogTitle(){ var tempWindow = self; do{ if(typeof tempWindow.getTopTitle == "function"){ return tempWindow.getTopTitle(); } if(tempWindow == tempWindow.parent) break; tempWindow = tempWindow.parent; }while(true); } var AsDialog = { OpenSelector : function(sObjectType,sParaString,sStyle){ return selectObjectValue(sObjectType,sParaString,sStyle); //使用在SELECT_CATALOG中自定义查询选择信息 }, OpenSelectorCB : function(sObjectType,sParaString,sStyle, resolve){ AsDialog.selectCatalogDialog(sObjectType,sParaString,sStyle,resolve); }, SelectGridValue : function(sDoNo, sArgs, sFields, aSelected, isMulti, sStyle){ if(!sStyle) sStyle = "dialogWidth:700px;dialogHeight:500px;resizable:no;maximize:yes;help:no;status:no;"; if(sFields.indexOf("=") > -1){ return this.SetGridValue(sDoNo, sArgs, sFields, aSelected, sStyle); } var sPageURL = sWebRootPath+"/RedirectorDialog?DiaglogURL=/Frame/page/control/OpenCompDialog.jsp&OpenerClientID="+sCompClientID+"&ComponentURL=/Frame/page/tools/SelectDialog.jsp"+AsControl._getParaString("CompPara=SelectDialogUrl=/Frame/page/tools/SelectGridDialog.jsp&DoNo="+sDoNo+"&Parameters="+sArgs+"&Fields="+sFields+"&IsMulti="+isMulti); if (!window.showModalDialog) {alert("本功能SelectGridValue暂时只支持IE11!"); console.trace();return;} return window.showModalDialog(sPageURL,aSelected,sStyle); }, SelectGridValueCB : function(sDoNo, sArgs, sFields, aSelected, isMulti, sStyle, callback){ if(!sStyle) sStyle = "dialogWidth:700px;dialogHeight:500px;resizable:no;maximize:yes;help:no;status:no;"; var sSelected = aSelected; if ($.isArray(aSelected)) {sSelected = aSelected.join("@");} var sURL = "/Frame/page/tools/SelectDialog.jsp"; var sPara ="SelectDialogUrl=/Frame/page/tools/SelectGridDialog.jsp&DoNo="+sDoNo+"&Parameters="+sArgs+"&Fields="+sFields+"&IsMulti="+isMulti+"&ASelected="+sSelected; this.PopView(sURL,sPara,sStyle,callback); }, SetGridValue : function(sDoNo, sArgs, sFieldValues, aSelected, sStyle){ if(sFieldValues.indexOf("=") < 0){ return this.SelectGridValue(sDoNo, sArgs, sFieldValues, aSelected, false, sStyle); } var fieldValues = sFieldValues.split("@"); var fields = ""; var terminis = new Array(); var keyValue; for(var i = 0; i < fieldValues.length; i++){ if(fieldValues[i].indexOf("=") < 0) continue; keyValue = fieldValues[i].split("="); if(keyValue.length < 2 || keyValue[0] == "" || keyValue[1] == "") continue; terminis[terminis.length] = keyValue[0]; if(fields != "") fields += "@"; fields += keyValue[1]; } var sReturn = this.SelectGridValue(sDoNo, sArgs, fields, aSelected, false); if(!sReturn) return; if(sReturn == "_CLEAR_"){ if(typeof setItemValue == "function" && typeof getRow == "function"){ for(var i = 0; i < terminis.length; i++){ setItemValue(0, getRow(), terminis[i], ""); } } }else{ if(typeof setItemValue == "function" && typeof getRow == "function"){ var values = sReturn.split("@"); for(var i = 0; i < terminis.length; i++){ setItemValue(0, getRow(), terminis[i], values[i]); } } } return sReturn; }, SetGridValueCB : function(sDoNo, sArgs, sFieldValues, aSelected, sStyle,callback){ if(sFieldValues.indexOf("=") < 0){ return this.SelectGridValueCB(sDoNo, sArgs, sFieldValues, aSelected, false, sStyle,callback); } var fieldValues = sFieldValues.split("@"); var terminis = new Array(); // 接收字段 var fields = ""; // 返回字段 for(var i = 0; i < fieldValues.length; i++){ if(fieldValues[i].indexOf("=") < 0) continue; var keyValue = fieldValues[i].split("="); if(keyValue.length < 2 || keyValue[0] == "" || keyValue[1] == "") continue; terminis[terminis.length] = keyValue[0]; if(fields != "") fields += "@"; fields += keyValue[1]; } this.SelectGridValueCB(sDoNo, sArgs, fields, aSelected, false, sStyle, function(sObjectNoString){ AsDialog._setItemValues(terminis,sObjectNoString,false); if (jQuery.isFunction(callback)) {callback(sObjectNoString);} }); }, _getTop:function() { var mytop=window; var exttest=false; try{ !top.contentDocument; mytop = top; if (mytop.location.host != window.location.host) {exttest=true;} }catch(er){exttest=true;} if (exttest) { var mywin=window; mytop = window; while(true){ try { mytop = mytop.parent; if (mytop.location.host != window.location.host) {mytop = mywin; break;} !mytop.contentDocument; mywin = mytop; }catch(er){mytop = mywin; break;} } } if (!mytop.dialog) { AsDialog.InitDialog(mytop); } return mytop; }, InitDialog : function(mytop){ if (typeof(mytop.$)!="undefined") { mytop.$("head").append('<script type="text/javascript" charset="UTF-8" src="'+sWebRootPath+'/Frame/resources/js/dialog/dialog-min.js"></script>'); mytop.$("head").append('<link rel="stylesheet" type="text/css" href="'+sWebRootPath+'/Frame/page/resources/css/dialog.css">'); } }, _PopupPage : function(pageinfo,callback){ if (!$.isPlainObject(pageinfo)) {alert("Arguments is not fit!");return;} var sURL=pageinfo.url; var sPageURL = sWebRootPath + "/RedirectorDialog?DiaglogURL="+sURL+"&OpenerClientID="+sCompClientID+"&TargetWindow=Popup&ComponentURL="+sURL+AsControl._getParaString(pageinfo.para); var top =AsDialog._getTop(); var maxWidth=top.document.body.offsetWidth-2; var maxHeight=top.document.body.offsetHeight-2; if (pageinfo.width >maxWidth) pageinfo.width=maxWidth; if (pageinfo.height >maxHeight) pageinfo.height=maxHeight; var d = top.dialog({ width:pageinfo.width, height:pageinfo.height, cancel: function() { if(window.checkOpenUrlModified != false){ try{if(!AsControl.CheckWindowModified(top)) return false;}catch(e1){ } } }, cancelDisplay:false, resize:true, url:sPageURL }); if (pageinfo.title) d.title(pageinfo.title); d.addEventListener('close', function () { var sReturnValue=this.returnValue; //jQuery.ajax({url: sWebRootPath+"/Frame/page/control/DestroyCompAction.jsp?ToDestroyClientID="+sCompClientID+"&TargetWindow=Popup",async: false}); var did = this.id; this.remove(); var dels=top.document.getElementsByName(did); if (dels.length >0) { dels[0].parentNode.removeChild(dels[0]); } if (jQuery.isFunction(callback)) { setTimeout(function(){callback(sReturnValue);}); } else { alert("You Selected is \n\r["+sReturnValue+"]\n\rPlease set callback Function to handled!"); } }); d.returnValue=undefined; d.showModal(); }, /** * 通用的选择器,内嵌的SelectDialogUrl页面需实现doSure()方法,并将返回值以parent.closeDialog(返回值);的形式返回给选择器 * @param dialoginfo * @param callback */ SelectCommonDialog : function(dialoginfo,callback){ if (!jQuery.isFunctionPlainObject(dialoginfo)) {alert("Arguments is not fit!");return;} var pageinfo = { width: dialoginfo.width, height:dialoginfo.height, title: dialoginfo.title, para: dialoginfo.para.indexOf("SelectDialogUrl")<0 ? "SelectDialogUrl="+dialoginfo.para : dialoginfo.para, url:"/Frame/page/tools/dialog/SelectDialog.jsp" }; this._PopupPage(pageinfo,callback); }, selectCatalogDialog:function(sObjectType,sParaString,sStyle,callback){ var pageinfo = { width:this._getStyleDialogWidth(sStyle,700), height:this._getStyleDialogHeight(sStyle,540), url:"/Frame/DialogSelect.jsp", para:"SelName="+sObjectType+"&ParaString="+sParaString, title: '请选择:' }; this._PopupPage(pageinfo,callback); }, selectObjectInfo:function(sObjectType,sParaString,sStyle,callback){ var pageinfo = { width:this._getStyleDialogWidth(sStyle,700), height:this._getStyleDialogHeight(sStyle,540), url:"/Frame/page/tools/dialog/SelectObject.jsp", para:"ObjectType="+sObjectType+"&ParaString="+sParaString, title: '请选择:' }; this._PopupPage(pageinfo,callback); }, setObjectInfo:function(sObjectType,sValueString,iArgDW,iArgRow,sStyle,callback){ if(typeof(sStyle)=="undefined" || sStyle=="") sStyle = "dialogWidth:700px;dialogHeight:540px;"; if (jQuery.isFunction(sStyle)) {callback=sStyle; sStyle = "dialogWidth:700px;dialogHeight:540px;"} var iDW = iArgDW; if(iDW == null) iDW=0; var iRow = iArgRow; if(iRow == null) iRow=0; var sValues = sValueString.split("@"); var sParaString = sValues[0]; var i=sValues.length; i=i-1; if (i%2!=0){ alert("setObjectInfo()返回参数设定有误!\r\n格式为:@ID列名@ID在返回串中的位置..."); return; }else{ var j=i/2,m,sColumn,iID; this.selectObjectInfo(sObjectType,sParaString,sStyle,function(sObjectNoString){ if(typeof(sObjectNoString)=="undefined" || sObjectNoString=="null" || sObjectNoString==null || sObjectNoString=="_CANCEL_"){ return; }else if(sObjectNoString=="_CLEAR_"){ for(m=1;m<=j;m++){ sColumn = sValues[2*m-1]; if(sColumn!="") setItemValue(iDW,iRow,sColumn,""); } }else if(sObjectNoString!="_NONE_" && sObjectNoString!="undefined"){ sObjectNos = sObjectNoString.split("@"); for(m=1;m<=j;m++){ sColumn = sValues[2*m-1]; iID = parseInt(sValues[2*m],10); if(sColumn!="") setItemValue(iDW,iRow,sColumn,sObjectNos[iID]); } if (jQuery.isFunction(callback)) {callback(sObjectNoString); } return sObjectNoString; }else{ //alert("选取对象编号失败!对象类型:"+sObjectType); return; } return sObjectNoString; } ); } }, /**主要是使用在select_catalog中自定义查询选择信息 * sObjectType:对象类型 * sValueString格式: 传入参数 @ ID列名 @ ID在返回串中的位置 @ Name列名 @ Name在返回串中的位置 * iArgDW: 第几个DW,默认为0 * iArgRow: 第几行,默认为0 */ setObjectValue:function(sObjectType,sParaString,sValueString,iArgDW,iArgRow,sStyle,callback){ var i=sValueString.split("@").length-1; if (i%2!=0){ alert("setObjectValue()返回参数设定有误!\r\n格式为:@ID列名@ID在返回串中的位置..."); return; }else{ this.selectCatalogDialog(sObjectType,sParaString,sStyle,function(sObjectNoString){ var i=sValueString.split("@").length-1; var sValues = sValueString.split("@"); var iDW = iArgDW; if(isNaN(iDW)) iDW=0; var iRow = iArgRow; if(isNaN(iRow)) iRow=0; var j=i/2,m,sColumn,iID; if(typeof(sObjectNoString)=="undefined" || sObjectNoString=="null" || sObjectNoString==null || sObjectNoString=="_CANCEL_" ){ return; }else if(sObjectNoString=="_CLEAR_"){ for(var m=1;m<=j;m++){ sColumn = sValues[2*m-1]; if(sColumn!="") setItemValue(iDW,iRow,sColumn,""); } }else if(sObjectNoString!="_NONE_" && sObjectNoString!="undefined"){ var sObjectNos = sObjectNoString.split("@"); for(var m=1;m<=j;m++){ sColumn = sValues[2*m-1]; iID = parseInt(sValues[2*m],10); if(sColumn!="") setItemValue(iDW,iRow,sColumn,sObjectNos[iID]); } if (jQuery.isFunction(callback)) {callback(sObjectNoString); } return sObjectNoString; }else{ return; } }); } }, /** * 弹出配置树图选择器,并返回选择内容字符串 * @param sCodeNo 配置树图编号 必须 * @param sReturnFields 返回字段,以@符号分隔 必须 * * @param aSelected {Array} 默认选择数据 字段对应的值 ["F1V1,F1V2,...,F1VN","F2V1,F2V2,...,F2VN",...,"FNV1,FNV2,...,F1VN"] * @param isMulti 选择器树图多选标记,true 多选,否则 单选 * @param onlyLeaf 选择器树图只选功能节点 false 可选文件夹节点 否则 只能选末端叶子节点 * @param sStyle 选择器窗体外观特征,默认宽度为700像素,高度为500像素,不能自由拉伸窗体,不显示状态栏、帮助问号 * * @returns 选择器返回的字符串 单选:F1V@F2V@...@FNV 多选:F1V1@F2V1@...@FNV1~F1V2@F2V2@...@FNV2~F1VN@F2VN@...@FNVN * @belong AsDialog */ SelectConfigTreeValue : function(sCodeNo, sReturnFields, aSelected, isMulti, onlyLeaf, sStyle,callback){ if(sReturnFields.indexOf("=") > -1){ return this.SetConfigTreeValue(sCodeNo, sReturnFields, aSelected, isMulti, onlyLeaf, sStyle); } var sSelected = aSelected; if ($.isArray(aSelected)) {sSelected = aSelected.join("@");} var pageinfo = { width:this._getStyleDialogWidth(sStyle,700), height:this._getStyleDialogHeight(sStyle,500), url:"/Frame/page/tools/dialog/SelectDialog.jsp", para:"SelectDialogUrl=/Frame/page/tools/dialog/SelectCodeTreeDialog.jsp&CodeNo="+sCodeNo+"&ReturnFields="+sReturnFields+"&IsMulti="+isMulti+"&OnlyLeaf="+onlyLeaf+"&ASelected="+sSelected, title: '请选择:' }; this._PopupPage(pageinfo,callback); }, /** * 弹出配置树图选择器,并以选择内容字符串给对应字段赋值 * @param sCodeNo 配置树图编号 必须 * @param sReturnFields 返回并设置字段,FK1=FV1@FK2=FV2@...@FKN=FVN (当前显示模板字段=选择器字段) * @param aSelected {Array} 默认选择数据 字段对应的值 ["F1V1,F1V2,...,F1VN","F2V1,F2V2,...,F2VN",...,"FNV1,FNV2,...,F1VN"] * @param isMulti 选择器树图多选标记,true 多选,否则 单选 * @param onlyLeaf 选择器树图只选功能节点 false 可选文件夹节点 否则 只能选末端叶子节点 * @param sStyle 选择器窗体外观特征,默认宽度为700像素,高度为500像素,不能自由拉伸窗体,不显示状态栏、帮助问号 * @belong AsDialog */ SetConfigTreeValue : function(sCodeNo, sReturnFields, aSelected, isMulti, onlyLeaf, sStyle){ if(sReturnFields.indexOf("=") < 0){ return this.SelectConfigTreeValue(sCodeNo, sReturnFields, aSelected, isMulti, onlyLeaf, sStyle); } var fieldValues = sReturnFields.split("@"); var terminis = new Array(); // 接收字段 var fields = ""; // 返回字段 for(var i = 0; i < fieldValues.length; i++){ if(fieldValues[i].indexOf("=") < 0) continue; var keyValue = fieldValues[i].split("="); if(keyValue.length < 2 || keyValue[0] == "" || keyValue[1] == "") continue; terminis[terminis.length] = keyValue[0]; if(fields != "") fields += "@"; fields += keyValue[1]; } this.SelectConfigTreeValue(sCodeNo, fields, aSelected, isMulti, onlyLeaf, sStyle, function(sObjectNoString){ AsDialog._setItemValues(terminis,sObjectNoString,isMulti); }); }, /** * 弹出树图选择器,并返回选择内容字符串 * @param sDoNo 预定义显示模型编号 必须 * @param sArgs 预定义显示模型参数,规则同OW页面,以“,”分隔 * @param sReturnFields 返回字段,以@符号分隔 必须 * @param sSortField 节点排序字段 必须 * @param sTextField 节点显示字段 必须 * * @param aSelected {Array} 默认选择数据 字段对应的值 ["F1V1,F1V2,...,F1VN","F2V1,F2V2,...,F2VN",...,"FNV1,FNV2,...,F1VN"] * @param isMulti 选择器树图多选标记,true 多选,否则 单选 * @param onlyLeaf 选择器树图只选功能节点 false 可选文件夹节点 否则 只能选末端叶子节点 * @param sStyle 选择器窗体外观特征,默认宽度为700像素,高度为500像素,不能自由拉伸窗体,不显示状态栏、帮助问号 * * @returns 选择器返回的字符串 单选:F1V@F2V@...@FNV 多选:F1V1@F2V1@...@FNV1~F1V2@F2V2@...@FNV2~F1VN@F2VN@...@FNVN * @belong AsDialog */ SelectTreeValue : function(sDoNo, sArgs, sReturnFields, sSortField, sTextField, aSelected, isMulti, onlyLeaf, sStyle,callback){ var sSelected = aSelected; if ($.isArray(aSelected)) {sSelected = aSelected.join("@");} var pageinfo = { width:this._getStyleDialogWidth(sStyle,700), height:this._getStyleDialogHeight(sStyle,500), url:"/Frame/page/tools/dialog/SelectDialog.jsp", para:"SelectDialogUrl=/Frame/page/tools/dialog/SelectTreeDialog.jsp&DoNo="+sDoNo+"&Parameters="+sArgs+"&SortField="+sSortField+"&TextField="+sTextField+"&ReturnFields="+sReturnFields+"&IsMulti="+isMulti+"&OnlyLeaf="+onlyLeaf+"&ASelected="+sSelected, title: '请选择:' }; this._PopupPage(pageinfo,callback); }, /** * 弹出树图选择器,以选择内容字符串给对应字段赋值 * @param sDoNo 预定义显示模型编号 必须 * @param sArgs 预定义显示模型参数,规则同OW页面,以“,”分隔 * @param sReturnFields 返回并设置字段,FK1=FV1@FK2=FV2@...@FKN=FVN (当前显示模板字段=选择器显示模板字段) * @param sSortField 节点排序字段 必须 * @param sTextField 节点显示字段 必须 * @param aSelected {Array} 默认选择数据 字段对应的值 ["F1V1,F1V2,...,F1VN","F2V1,F2V2,...,F2VN",...,"FNV1,FNV2,...,F1VN"] * @param isMulti 选择器树图多选标记,true 多选,否则 单选 * @param onlyLeaf 选择器树图只选功能节点 false 可选文件夹节点 否则 只能选末端叶子节点 * @param sStyle 选择器窗体外观特征,默认宽度为700像素,高度为500像素,不能自由拉伸窗体,不显示状态栏、帮助问号 * @belong AsDialog */ SetTreeValue : function(sDoNo, sArgs, sReturnFields, sSortField, sTextField, aSelected, isMulti, onlyLeaf, sStyle){ if(sReturnFields.indexOf("=") < 0){ return this.SelectTreeValue(sDoNo, sArgs, sReturnFields, sSortField, sTextField, aSelected, isMulti, onlyLeaf, sStyle); } var fieldValues = sReturnFields.split("@"); var terminis = new Array(); // 接收字段 var fields = ""; // 返回字段 for(var i = 0; i < fieldValues.length; i++){ if(fieldValues[i].indexOf("=") < 0) continue; var keyValue = fieldValues[i].split("="); if(keyValue.length < 2 || keyValue[0] == "" || keyValue[1] == "") continue; terminis[terminis.length] = keyValue[0]; if(fields != "") fields += "@"; fields += keyValue[1]; } this.SelectTreeValue(sDoNo, sArgs, fields, sSortField, sTextField, aSelected, isMulti, onlyLeaf, sStyle, function(sObjectNoString){ AsDialog._setItemValues(terminis,sObjectNoString,isMulti); }); }, PopPage : function(sURL,sPara,objectStyle,callback){ var width = 700; var height = 500; var title = "&nbsp"; if ($.isPlainObject(objectStyle)) { if (objectStyle.width) width = objectStyle.width; if (objectStyle.height) height = objectStyle.height; title = objectStyle.title; } else if (typeof objectStyle=="string") { width = this._getStyleDialogWidth(objectStyle,width); height = this._getStyleDialogHeight(objectStyle,height); } var pageinfo = { width:width, height:height, title:title, url:sURL, para:sPara }; this._PopupPage(pageinfo,callback); }, OpenObject:function(sObjectType,sObjectNo,sViewID,objectStyle,callback){ if (!objectStyle) objectStyle =$.parseJSON(RunJspAjax("/Frame/page/tools/object/GetObjectInfo.jsp?ObjectType="+sObjectType+"&ObjectNo="+sObjectNo+"&ViewID="+sViewID)); this.PopView("/Frame/page/tools/object/ObjectViewer.jsp","ObjectType="+sObjectType+"&ObjectNo="+sObjectNo+"&ViewID="+sViewID,objectStyle,callback); }, PopView : function(sURL,sPara,objectStyle,callback){ var top =AsDialog._getTop(); var width = top.document.body.offsetWidth-2; var height = top.document.body.offsetHeight-2; var title = ""; if ($.isPlainObject(objectStyle)) { if (objectStyle.width) width = objectStyle.width; if (objectStyle.height) height = objectStyle.height; title = objectStyle.title; } else if (typeof objectStyle=="string") { width = this._getStyleDialogWidth(objectStyle,width); height = this._getStyleDialogHeight(objectStyle,height); } var maxWidth=top.document.body.offsetWidth-2; var maxHeight=top.document.body.offsetHeight-2; if (width >maxWidth) width=maxWidth; if (height >maxHeight) height=maxHeight; var initMax=0; if(width==maxWidth&&height==maxHeight) { initMax=1; } var sDialogPara = sPara; while(sDialogPara.indexOf("&")>=0) sDialogPara = sDialogPara.replace("&","$[and]"); var sPageURL = sWebRootPath+"/RedirectorDialog?DiaglogURL=/Frame/page/control/DialogFrame.jsp&OpenerClientID="+sCompClientID+AsControl._getParaString("&DialogTitle="+title)+"&DialogURL="+sURL+AsControl._getParaString("DialogPara="+sDialogPara); if(initMax==0){ var d = top.dialog({ width:width, height:height, cancelDisplay:false, //title:"<span style=\"\color:red\"\>点击此处拖动弹窗</span>", title:"<span class=\"\btn_text\"\>点击此处拖动弹窗</span>", drag:true, fixed:true, url:sPageURL }); }else{ var d = top.dialog({ width:width*0.8, height:height*0.8, cancelDisplay:false, drag:true, fixed:true, url:sPageURL }); } d.addEventListener('close', function () { var sReturnValue=this.returnValue; var did = this.id; this.remove(); var dels=top.document.getElementsByName(did); if (dels.length >0) { dels[0].parentNode.removeChild(dels[0]); } if (jQuery.isFunction(callback)) { setTimeout(function(){callback(sReturnValue);}); } }); d.returnValue=undefined; d.showModal(); }, SetDialogTitle : function(sTitle){ var top =AsDialog._getTop(); var d = top.dialog.getCurrent(); if (d) d.title(sTitle); }, ClosePage : function(sReturnValue){ var top =AsDialog._getTop(); var d = top.dialog.getCurrent();if (!d && top.dialog.list){for (var i in top.dialog.list) {d=top.dialog.list[i];}} if (d) { if (jQuery.isFunction(top.hideButtonTips)){top.hideButtonTips();} d.close(sReturnValue) ; } else { try { if(typeof(top.sObjectInfo)!="undefined" && typeof top.closeAndReturn == "function") { top.sObjectInfo = sReturnValue; top.closeAndReturn(); return; } else if (typeof top.dialogArguments !='undefined' && top==self){ if (typeof(sReturnValue)!="undefined") { top.returnValue=sReturnValue; } top.close(); return; } }catch (e) {alert("e"+e);} } }, RefreshMe : function(){ var top =AsDialog._getTop(); var d = top.dialog.getCurrent();if (!d && top.dialog.list){for (var i in top.dialog.list) {d=top.dialog.list[i];}} if (d) { if (d.iframeNode && d.iframeNode.contentWindow && d.iframeNode.contentWindow.refreshMe) { d.iframeNode.contentWindow.refreshMe(); } } else { try { if(typeof top.refreshMe == "function") { top.refreshMe(); return; } }catch (e) {alert("e"+e);} } }, ResizeDialog : function(){ var top =AsDialog._getTop(); var width = top.document.body.offsetWidth-2; var height = top.document.body.offsetHeight-2; var d = top.dialog.getCurrent(); d.width(width+"px"); d.height(height+"px"); }, _getStyleDialogWidth : function(sStyle, sDefaultValue){ if (!sDefaultValue ) sDefaultValue = 640; if (!sStyle) return sDefaultValue; var aMatch=sStyle.match(/dialogWidth[\s]*[:=][\s]*([\d]+)px/i); if (aMatch) return parseInt(aMatch[1]); aMatch=sStyle.match(/dialogWidth[\s]*[:=][\s]*([\d]+);/i); if (aMatch) return parseInt(aMatch[1]*16); else return sDefaultValue; }, _getStyleDialogHeight : function(sStyle, sDefaultValue){ if (!sDefaultValue ) sDefaultValue = 480; if (!sStyle) return sDefaultValue; var aMatch=sStyle.match(/dialogHeight[\s]*[:=][\s]*([\d]+)px/i); if (aMatch) return parseInt(aMatch[1]); aMatch=sStyle.match(/dialogHeight[\s]*[:=][\s]*([\d]+);/i); if (aMatch) return parseInt(aMatch[1]*16); else return sDefaultValue; }, _setItemValues : function(aField, sValues, isMulti){ if(typeof setItemValue != "function" && typeof getRow != "function") return; if(!sValues) return; if(sValues == "_CLEAR_"){ for(var i = 0; i < aField.length; i++){ setItemValue(0, getRow(), aField[i], ""); } return; }else{ if(typeof setItemValue == "function" && typeof getRow == "function"){ if(isMulti){ var aReturn = sValues.split("~"); var aValues = new Array(); for(var i = 0; i < aReturn.length; i++){ var vs = aReturn[i].split("@"); for(var j = 0; j < aField.length; j++){ if(i == 0) aValues[j] = ""; else aValues[j] += ","; aValues[j] += vs[j]; if(i == aReturn.length - 1) setItemValue(0, getRow(0), aField[j], aValues[j]); } } }else{ var aValues = sValues.split("@"); for(var i = 0; i < aField.length; i++){ setItemValue(0, getRow(), aField[i], aValues[i]); } } } } }, OpenCalender : function(obj,strFormat,startDate,endDate,postEvent,x,y){ if(typeof obj == "string") obj = document.getElementById(obj); if(!obj) return; var today = new Date();//.format(strFormat); //alert([getDate(startDate),getDate(endDate)]); SelectDate(obj,strFormat,getDate(startDate),getDate(endDate),postEvent,x,y); function getDate(sDate){ if(typeof sDate == "string" && sDate.toUpperCase() == "TODAY") return today; if(typeof sDate == "number"){ return new Date(today.getFullYear(), today.getMonth(), today.getDate()+parseInt(sDate, 10)); } return sDate; } } }; if(window == AsDialog._getTop()){ if (typeof($)!="undefined" && typeof(dialog)=="undefined") { $("head").append('<script type="text/javascript" charset="UTF-8" src="'+sWebRootPath+'/Frame/resources/js/dialog/dialog-min.js"></script>'); $("head").append('<link rel="stylesheet" type="text/css" href="'+sWebRootPath+'/Frame/page/resources/css/dialog.css">'); } } if(navigator.appName!="Microsoft Internet Explorer") { if (top && AsDialog) { AsDialog.srctop=top; AsDialog.mytop=AsDialog._getTop(); window.top = AsDialog.mytop; if (window == AsDialog.mytop) { window.parent=AsDialog.mytop}; } } if(navigator.appName!="Microsoft Internet Explorer") { if (Date.prototype.getFullYear) Date.prototype.getYear=Date.prototype.getFullYear; $(document).ready(function() { if (typeof(document.getElementByIdSrc)=="undefined") { document.getElementByIdSrc = document.getElementById; document.getElementById = function (idName) { var obj; try { obj = document.getElementByIdSrc(idName); } catch (e){} if (!obj) { obj = document.getElementsByName(idName)[0]; } return obj; } } }); } 请分析这段代码,然后如何在title里面加入缩放和扩大的按钮
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值