import detailMethods from './detailMethods.js'; //ä¸šåŠ¡å¤„ç†æ–¹æ³•,全部å¯ä»¥ç”±å¼€å‘覆盖 import serviceFilter from './serviceFilter.js'; let methods = { //å½“æ·»åŠ æ‰©å±•ç»„ä»¶gridHeader/gridBody/gridFooteråŠæ˜Žç»†modelHeader/modelBody/modelFooter时, //如果è¦èŽ·å–父级Vue对象,è¯·ä½¿ç”¨æ¤æ–¹æ³•进行回调 parentCall(fun) { if (typeof fun != 'function') { return console.log('扩展组件需è¦ä¼ 入一个回调方法æ‰èƒ½èŽ·å–父级Vue对象'); } fun(this); }, getCurrentAction() { if (this.currentReadonly) { return ''; } return '--' + (this.currentAction == this.const.ADD ? '新增' : '编辑'); }, quickSearchKeyPress($event) { //æŸ¥è¯¢å—æ®µä¸ºinput时,按回车查询 if ($event.keyCode == 13) { if (this.searchFormFields[this.singleSearch.field] != '') { this.search(); } } }, getButtons() { //生æˆViewGrid界é¢çš„æ“ä½œæŒ‰é’®åŠæ›´å¤šé€‰é¡¹ let searchIndex = this.buttons.findIndex((x) => { return x.value == 'Search'; }); //æ·»åŠ é«˜çº§æŸ¥è¯¢ let hasOneFormItem = this.searchFormOptions.length == 1 && this.searchFormOptions[0].length == 1; if (searchIndex != -1 && !hasOneFormItem) { this.buttons.splice(searchIndex + 1, 0, { icon: this.fiexdSearchForm ? 'el-icon-refresh-left' : 'el-icon-search', name: this.fiexdSearchForm ? 'é‡ç½®' : '高级查询', plain: true, type: this.buttons[searchIndex].type, onClick: () => { if (this.fiexdSearchForm) { return this.resetSearch(); } this.searchBoxShow = !this.searchBoxShow; } }); } if (hasOneFormItem) { this.fiexdSearchForm = false; } this.maxBtnLength += searchIndex == -1 ? 0 : 1; // if (this.buttons.length <= this.maxBtnLength) { // return this.buttons; // } // let btns = this.buttons.slice(0, this.maxBtnLength); // btns[this.maxBtnLength - 1].last = true; // return btns; }, extendBtn(btns, source) { //btnsæƒé™æŒ‰é’®ï¼Œsource为扩展按钮 if (!btns || !(source && source instanceof Array)) { return; } //source通过在表的扩展js文件ä¸buttons对应按钮的属性index决定按钮所放ä½ç½® source.forEach((x) => { //通过按钮的Index属性,放到指定的ä½ç½® btns.splice(x.index == undefined ? btns.length : x.index, 0, x); }); // if (this.extend.buttons.view) { // this.extend.buttons.view.forEach((x) => { // //通过按钮的Index属性,放到指定的ä½ç½® // this.buttons.splice(x.index == undefined ? this.buttons.length : x.index, 0, x); // }) // } }, initBoxButtons() { //åˆå§‹åŒ–ViewGird与弹出框/明细表按钮 let path = this.$route.path; //通过èœå•获å–用户所对应èœå•éœ€è¦æ˜¾ç¤ºçš„æŒ‰é’® let permissionButtons = this.permission.getButtons( path, null, this.extend.tableAction, this.table.name ); if (permissionButtons) { //2020.03.31æ·»åŠ æ·±æ‹·è´æŒ‰é’®ç»„ permissionButtons.forEach((p) => { let _obj = {}; for (const key in p) { _obj[key] = p[key]; } this.buttons.push(_obj); }); // this.buttons.push(...permissionButtons); } if (!this.extend) { this.extend = {}; } if (!this.extend.buttons) { this.extend.buttons = {}; } //æŸ¥è¯¢ç•Œé¢æ‰©å±•按钮(扩展按钮å¯è‡ªè¡Œé€šè¿‡è®¾ç½®æŒ‰é’®çš„Index属性显示到具体ä½ç½®) if (this.extend.buttons.view) { this.extendBtn(this.buttons, this.extend.buttons.view); } //弹出框按钮 let boxButtons = []; let saveBtn = this.buttons.some((x) => { if ( x.value && (x.value.toLowerCase() == this.const.ADD.toLowerCase() || x.value.toLowerCase() == this.const.EDIT.toLowerCase()) ) return true; }); this.currentReadonly = !saveBtn; //ä»Žè¡¨è¡¨æ ¼æ“作按钮 let detailGridButtons = { name: '刷新', type: 'info', icon: 'el-icon-refresh', onClick() { //如果明细表当å‰çš„状æ€ä¸ºæ–°å»ºæ—¶ï¼Œç¦æ¢åˆ·æ–° if (this.currentAction == this.const.ADD) { return; } this.refreshRow(); } }; let importExcel = this.buttons.some((x) => { if (x.value == this.const.IMPORT) return true; }); //如果有导入æƒé™,则需è¦åˆå§‹åŒ–导入组件 if (importExcel) { this.upload.url = this.getUrl(this.const.IMPORT); //定义下载模æ¿çš„æ–‡ä»¶å this.upload.template.fileName = this.table.cnName; //定义下载模æ¿çš„Url路径 this.upload.template.url = this.http.ipAddress + this.getUrl(this.const.DOWNLOADTEMPLATE, true); } // disabled //如果当å‰è§’è‰²æ²¡æœ‰ç¼–è¾‘æˆ–æ–°å»ºåŠŸèƒ½ï¼ŒæŸ¥çœ‹æ˜Žç»†æ—¶å—æ®µè®¾ç½®å…¨éƒ¨åªè¯» //åªæœ‰æ˜Žç»†è¡¨ï¼Œå°†æ˜Žç»†è¡¨ä¹Ÿè®¾ç½®ä¸ºä¸å¯èƒ½ç¼–è¾‘ï¼Œå¹¶ä¸”ä¸æ˜¾ç¤ºæ·»åŠ è¡Œã€åˆ 除行 if (!saveBtn) { this.editFormOptions.forEach((row) => { row.forEach((x) => { x.disabled = true; }); }); //没有新增编辑æƒé™çš„,弹出框都设置为åªè¯» this.detail.columns.forEach((column) => { if (column.hasOwnProperty('edit')) { column.readonly = true; // row['edit'] = false; } }); //弹出框扩展按钮 this.extendBtn(boxButtons, this.extend.buttons.box); //弹出弹框按钮(2020.04.21),没有编辑或新建æƒé™æ—¶ï¼Œä¹Ÿå¯ä»¥é€šè¿‡buttonså±žæ€§æ·»åŠ è‡ªå®šä¹‰å¼¹å‡ºæ¡†æŒ‰é’® this.boxButtons.push(...boxButtons); this.detailOptions.buttons.push(detailGridButtons); this.detailOptions.buttons.forEach((button) => { if (!button.hasOwnProperty('hidden')) { button.hidden = false; } }); //弹出框扩展明细表按钮 this.extendBtn(this.detailOptions.buttons, this.extend.buttons.detail); return boxButtons; } this.detailOptions.edit = true; boxButtons.push( ...[ { name: 'ä¿ å˜', icon: 'el-icon-check', type: 'danger', disabled: false, value: 'save', onClick() { this.save(); } } // { // name: 'é‡ ç½®', // icon: 'el-icon-refresh-right', // type: 'primary', // disabled: false, // onClick() { // this.resetEdit(); // } // } ] ); //ä»Žè¡¨è¡¨æ ¼æ“作按钮 this.detailOptions.buttons.push( ...[ { name: 'æ·»åŠ è¡Œ', icon: 'el-icon-plus', type: 'primary', hidden: false, plain: true, onClick() { this.addRow(); } }, { type: 'danger', plain: true, name: 'åˆ é™¤è¡Œ', hidden: false, icon: 'el-icon-delete', onClick() { this.delRow(); } }, //2022.01.08å¢žåŠ æ˜Žç»†è¡¨å¯¼å…¥å¯¼å‡ºåŠŸèƒ½ //注æ„需è¦é‡å†™åŽå°æ˜Žç»†è¡¨æŽ¥å£çš„导入与下载模æ¿ã€å¯¼å‡ºçš„æƒé™,Sys_DictionaryListController.cs/SellOrderListController.cs { type: 'danger', plain: true, name: '导入', value: 'import', hidden: false, icon: 'el-icon-upload2', onClick() { this.upload.url = `${this.http.ipAddress}api/${this.detail.table}/${this.const.IMPORT}?table=1`; this.upload.template.url = `${this.http.ipAddress}api/${this.detail.table}/${this.const.DOWNLOADTEMPLATE}`; //定义下载模æ¿çš„æ–‡ä»¶å this.upload.template.fileName = this.detail.cnName; this.upload.excel = true; } }, { type: 'danger', plain: true, name: '导出', value: 'export', icon: 'el-icon-download', hidden: false, onClick() { this.export(true); } } ] ); this.detailOptions.buttons.forEach((button) => { if (button.hasOwnProperty('hidden')) { button.hidden = false; } }); //弹出框扩展按钮 this.extendBtn(boxButtons, this.extend.buttons.box); //弹出框扩展明细表按钮 this.detailOptions.buttons.push(detailGridButtons); this.extendBtn(this.detailOptions.buttons, this.extend.buttons.detail); //弹出弹框按钮 this.boxButtons.push(...boxButtons); }, onClick(click) { click.apply(this); }, changeDropdown(btnName, v1) { let button = this.buttons.filter((x) => { return x.name == btnName; }); if (button && button.length > 0) { button[0].onClick.apply(this); } }, emptyValue(value) { if (typeof value == 'string' && value.trim() === '') { return true; } if (value instanceof Array && !value.length) { return true; } return value === null || value === undefined || value === ''; }, getSearchParameters() { //èŽ·å–æŸ¥è¯¢å‚æ•° // 2020.09.11å¢žåŠ å›ºå®šæŸ¥è¯¢è¡¨å•,如果设置固定了查询表å•,点击查询时,ä¸å†å…³é— if (!this.fiexdSearchForm) { this.searchBoxShow = false; } let query = { wheres: [] }; for (const key in this.searchFormFields) { let value = this.searchFormFields[key]; if (this.emptyValue(value)) continue; if (typeof value == 'number') { value = value + ''; } let displayType = this.getSearchItem(key); //è”级åªä¿ç•™é€‰ä¸èŠ‚ç‚¹çš„æœ€åŽä¸€ä¸ªå€¼ if (displayType == 'cascader') { //æŸ¥è¯¢ä¸‹é¢æ‰€æœ‰çš„å节点,如:选ä¸çš„æ˜¯çˆ¶èŠ‚ç‚¹ï¼Œåº”è¯¥æŸ¥è¯¢ä¸‹é¢æ‰€æœ‰çš„节点数æ®--待完 value = value.length ? value[value.length - 1] + '' : ''; } //2021.05.02å¢žåŠ åŒºé—´æŸ¥è¯¢ if ( typeof value == 'string' || ['date', 'datetime', 'range'].indexOf(displayType) == -1 ) { query.wheres.push({ name: key, value: typeof value == 'string' ? (value + '').trim() : value.join(','), displayType: displayType }); continue; } for (let index = 0; index < value.length; index++) { if (!this.emptyValue(value[index])) { query.wheres.push({ name: key, value: (value[index] + '').trim(), displayType: (() => { if (['date', 'datetime', 'range'].indexOf(displayType) != -1) { return index ? 'lessorequal' : 'thanorequal'; } return displayType; })() }); } } } return query; }, search() { //查询 // let query = this.getSearchParameters(); // this.$refs.table.load(query, true); this.$refs.table.load(null, true); }, loadTableBefore(param, callBack) { //查询å‰è®¾ç½®æŸ¥è¯¢æ¡ä»¶åŠåˆ†é¡µä¿¡æ¯ let query = this.getSearchParameters(); if (query) { param = Object.assign(param, query); } if (this.$route.query.viewflow && this.$route.query.id) { param.wheres.push({ name: this.table.key, value: this.$route.query.id }); } // if (this.isViewFlow() && data && data.length) { // let query = JSON.parse(JSON.stringify(this.$route.query)); // query.viewflow = 0; // this.$router.replace({ path: this.$route.path, query: query }); // this.$nextTick(() => { // this.getWorkFlowSteps(data[0]); // }); // } let status = this.searchBefore(param); callBack(status); }, loadTableAfter(data, callBack, result) { //æŸ¥è¯¢åŽ //2020.10.30å¢žåŠ æŸ¥è¯¢åŽè¿”å›žæ‰€æœ‰çš„æŸ¥è¯¢ä¿¡æ¯ let status = this.searchAfter(data, result); callBack(status); //自动弹出框审批详情 }, loadDetailTableBefore(param, callBack) { //æ˜Žç»†æŸ¥è¯¢å‰ //æ–°å»ºæ—¶ç¦æ¢åŠ è½½æ˜Žç»† if (this.currentAction == this.const.ADD) { callBack(false); return false; } let status = this.searchDetailBefore(param); callBack(status); }, loadDetailTableAfter(data, callBack) { //æ˜Žç»†æŸ¥è¯¢åŽ let status = this.searchDetailAfter(data); callBack(status); }, getSearchItem(field) { //èŽ·å–æŸ¥è¯¢çš„傿•° let data; for (let index = 0; index < this.searchFormOptions.length; index++) { if (data) return data.type; const item = this.searchFormOptions[index]; data = item.find((x) => { return x.field == field; }); } return (data || {}).type; }, resetSearch() { //é‡ç½®æŸ¥è¯¢å¯¹è±¡ this.resetSearchForm(); //2020.10.17å¢žåŠ é‡ç½®åŽæ–¹æ³• this.resetSearchFormAfter && this.resetSearchFormAfter(); }, resetEdit() { //é‡ç½®ç¼–è¾‘çš„æ•°æ® let isEdit = this.currentAction != this.const.ADD; //é‡ç½®ä¹‹å‰ if (!this[isEdit ? 'resetUpdateFormBefore' : 'resetAddFormBefore']()) { return; } let objKey = {}; //编辑状æ€ä¸‹,ä¸éœ€è¦é‡ç½®ä¸»é”®,创建时间创建人 if (isEdit) { objKey[this.table.key] = this.editFormFields[this.table.key]; } this.resetEditForm(objKey); //é‡ç½®ä¹‹åŽ if (!this[isEdit ? 'resetUpdateFormAfter' : 'resetAddFormAfter']()) { return; } }, resetSearchForm(sourceObj) { //é‡ç½®æŸ¥è¯¢è¡¨ this.resetForm('searchForm', sourceObj); }, resetEditForm(sourceObj) { if (this.hasDetail && this.$refs.detail) { // this.$refs.detail.rowData.splice(0); this.$refs.detail.reset(); } this.resetForm('form', sourceObj); if (this.$refs.form && this.$refs.form.$refs.volform) { setTimeout(() => { this.$refs.form.$refs.volform.clearValidate(); }, 100); } }, getKeyValueType(formData, isEditForm) { try { let keyLeft = (isEditForm ? 'e' : 's') + '_b_'; formData.forEach((item) => { item.forEach((x) => { if (this.keyValueType.hasOwnProperty(keyLeft + x.field)) { return true; } let data; if (x.type == 'switch') { this.keyValueType[x.field] = 1; } else if (x.bind && x.bind.data) { data = x.bind.data; } else if (x.data) { if (x.data instanceof Array) { data = x.data; } else if (x.data.data && x.data.data instanceof Array) { data = x.data.data; } } if ( data && data.length > 0 && !this.keyValueType.hasOwnProperty(x.field) ) { this.keyValueType[x.field] = data[0].key; this.keyValueType[keyLeft + x.field] = x.type; } }); }); } catch (error) { console.log(error.message); } }, resetForm(formName, sourceObj) { // return; //é‡ç½®è¡¨å•æ•°æ® if (this.$refs[formName]) { this.$refs[formName].reset(); } if (!sourceObj) return; let form, keyLeft; if (formName == 'searchForm') { form = this.searchFormFields; keyLeft = 's' + '_b_'; } else { form = this.editFormFields; keyLeft = 'e' + '_b_'; } //èŽ·å–æ•°æ®æºçš„data类型,å¦åˆ™å¦‚æžœæ•°æ®æºdataçš„key是数å—,é‡ç½®çš„值是å—ç¬¦ä¸²å°±æ— æ³•ç»‘å®šå€¼ if (!this.keyValueType._dinit) { this.getKeyValueType(this.editFormOptions, true); this.getKeyValueType(this.searchFormOptions, false); this.keyValueType._dinit = true; } var _cascaderParentTree; for (const key in form) { if (sourceObj.hasOwnProperty(key)) { let newVal = sourceObj[key]; let kv_type = this.keyValueType[keyLeft + key]; if ( kv_type == 'selectList' || kv_type == 'checkbox' || kv_type == 'cascader' || kv_type == 'treeSelect' ) { // 2020.05.31å¢žåŠ iview组件Cascader // 2020.11.01å¢žåŠ iview组件Cascader表å•é‡ç½®æ—¶æŸ¥è¯¢æ‰€æœ‰çš„父节点 if (kv_type == 'cascader' || kv_type == 'treeSelect') { var treeDic = this.dicKeys.find((dic) => { return dic.fileds && dic.fileds.indexOf(key) != -1; }); if (treeDic && treeDic.orginData && treeDic.orginData.length) { let keyIsNum = typeof treeDic.orginData[0].id == 'number'; if (kv_type == 'cascader') { newVal = keyIsNum ? newVal * 1 || 0 : newVal + ''; if (kv_type == 'cascader') { _cascaderParentTree = this.base.getTreeAllParent( newVal, treeDic.orginData ); if (_cascaderParentTree) { newVal = _cascaderParentTree.map((x) => { return x.id; }); } } } else { if (newVal === null || newVal === undefined) { newVal = []; } else if (typeof newVal == 'string') { newVal = newVal.split(','); } if (keyIsNum) { if (Array.isArray(newVal)) { newVal = newVal.map((x) => { return x * 1 || 0; }); } } else if (typeof newVal == 'number') { newVal = [newVal + '']; } } } else { newVal = [newVal]; } } else if ( newVal != '' && newVal != undefined && typeof newVal == 'string' ) { newVal = newVal.split(','); } else if (kv_type == 'checkbox') { newVal = []; } } else if ( this.keyValueType.hasOwnProperty(key) && typeof this.keyValueType[key] == 'number' && newVal * 1 == newVal ) { newVal = newVal * 1; } else { if (newVal == null || newVal == undefined) { newVal = ''; } else if (this.numberFields.indexOf(key) != -1) { newVal = newVal * 1 || 0; } else { newVal += ''; } } if (newVal instanceof Array) { if (form[key]) { form[key] = []; } form[key] = newVal; } else { form[key] = newVal; } } else { form[key] = form[key] instanceof Array ? [] : ''; } } }, onBtnClick(param) { this[param.method](param.data); }, refresh() { //刷新 this.search(); // this.$refs.table.load(); }, saveBefore(formData) { return true; }, saveAfter(formData, result) { return true; }, save() { //新增或编辑时ä¿å˜ // if (!this.$refs.form.validate()) return; this.$refs.form.validate((result) => { if (result) { this.saveExecute(); } }); }, async saveExecute() { let editFormFields = {}; //ä¸Šä¼ æ–‡ä»¶ä»¥é€—å·éš”å¼€ for (const key in this.editFormFields) { if ( this.uploadfiled && this.uploadfiled.length > 0 && this.uploadfiled.indexOf(key) != -1 && this.editFormFields[key] instanceof Array ) { let allPath = this.editFormFields[key].map((x) => { return x.path; }); editFormFields[key] = allPath.join(','); } else if (typeof this.editFormFields[key] == 'function') { try { editFormFields[key] = this.editFormFields[key](); } catch (error) { } } else { //2021.05.30ä¿®å¤ä¸‹æ‹‰æ¡†æ¸…除数æ®åŽåŽå°ä¸èƒ½ä¿å˜çš„问题 if ( this.editFormFields[key] === undefined && this.dicKeys.some((x) => { return x.fileds && x.fileds.indexOf(key) != -1; }) ) { editFormFields[key] = null; } else { editFormFields[key] = this.editFormFields[key]; } } } //å°†æ•°ç»„è½¬æ¢æˆstring //2020.11.01å¢žåŠ çº§è”å¤„ç† for (const key in editFormFields) { if (editFormFields[key] instanceof Array) { var iscascader = this.dicKeys.some((x) => { return ( x.type == 'cascader' && x.fileds && x.fileds.indexOf(key) != -1 ); }); if (iscascader && editFormFields[key].length) { editFormFields[key] = editFormFields[key][editFormFields[key].length - 1]; } else { editFormFields[key] = editFormFields[key].join(','); } } } let formData = { mainData: editFormFields, detailData: null, delKeys: null }; //èŽ·å–æ˜Žç»†æ•°æ®(å‰å°æ•°æ®æ˜Žç»†æœªåšæ ¡éªŒï¼Œå¾…å®Œ.åŽå°å·²ç»æ ¡éªŒ) if (this.hasDetail) { formData.detailData = this.$refs.detail.rowData; let _fields = this.detail.columns .filter((c) => { return ( c.type == 'selectList' || (c.edit && c.edit.type == 'selectList') ); }) .map((c) => { return c.field; }); //2022.06.20å¢žåŠ ä¿å˜æ—¶å¯¹æ˜Žç»†è¡¨ä¸‹æ‹‰æ¡†å¤šé€‰çš„åˆ¤æ– if (_fields.length) { formData.detailData = JSON.parse(JSON.stringify(formData.detailData)); formData.detailData.forEach((row) => { for (let index = 0; index < _fields.length; index++) { const _field = _fields[index]; if (Array.isArray(row[_field])) { row[_field] = row[_field].join(','); } } }); } } if (this.detailOptions.delKeys.length > 0) { formData.delKeys = this.detailOptions.delKeys; } //ä¿å˜å‰æ‹¦æˆª let _currentIsAdd = this.currentAction == this.const.ADD; if (_currentIsAdd) { //2020.12.06å¢žåŠ æ–°å»ºå‰å¼‚æ¥å¤„ç†æ–¹æ³• //2021.08.16ä¿®å¤å¼‚æ¥è¯æ³•写错的问题 if (!this.addBefore(formData) || !(await this.addBeforeAsync(formData))) return; } else { //2020.12.06å¢žåŠ ä¿®æ”¹å‰å¼‚æ¥å¤„ç†æ–¹æ³• if ( !this.updateBefore(formData) || !(await this.updateBeforeAsync(formData)) ) return; } let url = this.getUrl(this.currentAction); this.http.post(url, formData, true).then((x) => { //ä¿å˜åŽ if (_currentIsAdd) { if (!this.addAfter(x)) return; //è¿žç»æ·»åŠ if (this.continueAdd && x.status) { this.$success(x.message); //新建 this.currentAction = this.const.ADD; this.currentRow = {}; this.resetAdd(); this.refresh(); return; } } else { if (!this.updateAfter(x)) return; } if (!x.status) return this.$error(x.message); this.$success(x.message || 'æ“作æˆåŠŸ'); //如果ä¿å˜æˆåŠŸåŽéœ€è¦å…³é—编辑框,直接返回ä¸å¤„ç†åŽé¢ if (this.boxOptions.saveClose) { this.boxModel = false; //2020.12.27如果是编辑ä¿å˜åŽä¸é‡ç½®åˆ†é¡µé¡µæ•°ï¼Œåˆ·æ–°é¡µé¢æ—¶è¿˜æ˜¯æ˜¾ç¤ºå½“å‰é¡µçš„æ•°æ® this.$refs.table.load(null, _currentIsAdd); //this.refresh(); return; } let resultRow; if (typeof x.data == 'string' && x.data != '') { resultRow = JSON.parse(x.data); } else { resultRow = x.data; } if (this.currentAction == this.const.ADD) { // this.currentRow=x.data; this.editFormFields[this.table.key] = ''; this.currentAction = this.const.EDIT; this.currentRow = resultRow.data; } this.resetEditForm(resultRow.data); // console.log(resultRow); if (this.hasDetail) { this.detailOptions.delKeys = []; if (resultRow.list) { this.$refs.detail.rowData.push(...resultRow.list); } } this.$refs.table.load(null, _currentIsAdd); // this.refresh(); }); }, del(rows) { if (rows) { if (!(rows instanceof Array)) { rows = [rows]; } } else { rows = this.$refs.table.getSelected(); } //åˆ é™¤æ•°æ® if (!rows || rows.length == 0) return this.$error('请选择è¦åˆ 除的行!'); let delKeys = rows.map((x) => { return x[this.table.key]; }); if (!delKeys || delKeys.length == 0) return this.$error('没有获å–è¦åˆ 除的行数æ®!'); //åˆ é™¤å‰ if (!this.delBefore(delKeys, rows)) { return; } let tigger = false; this.$confirm('确认è¦åˆ 除选择的数æ®å—?', 'è¦å‘Š', { confirmButtonText: '确定', cancelButtonText: 'å–æ¶ˆ', type: 'warning', center: true }).then(() => { if (tigger) return; tigger = true; let url = this.getUrl(this.const.DEL); this.http.post(url, delKeys, 'æ£åœ¨åˆ 除数æ®....').then((x) => { if (!x.status) return this.$error(x.message); this.$success(x.message); //åˆ é™¤åŽ if (!this.delAfter(x)) { return; } this.refresh(); }); }); }, async modelOpenBeforeAsync(row) { return true; }, async initBox() { //2022.01.08å¢žåŠ æ–°å»ºæ—¶éšè—明细表导出功能 this.detailOptions.buttons.forEach((x) => { if (x.value == 'export') { x.hidden = this.currentAction == 'Add'; } }); //åˆå§‹åŒ–新建ã€ç¼–辑的弹出框 if (!(await this.modelOpenBeforeAsync(this.currentRow))) return false; this.modelOpenBefore(this.currentRow); if (!this.boxInit) { this.boxInit = true; this.boxModel = true; // this.detailUrl = this.url; } return true; }, setEditForm(row) { // if (this.remoteColumns.length == 0 || !rows || rows.length == 0) return; let remoteColumns = this.$refs.table.remoteColumns; remoteColumns.forEach((column) => { this.editFormOptions.forEach((option) => { option.forEach((x) => { if (x.field == column.field) { x.data.data = Object.assign([], x.data, column.bind.data); } }); }); }); this.editFormFields; //é‡ç½®ç¼–è¾‘è¡¨å•æ•°æ® this.editFormFields[this.table.key] = row[this.table.key]; this.resetEditForm(row); this.currentAction = this.const.EDIT; this.boxModel = true; }, async linkData(row, column) { this.boxOptions.title = this.table.cnName + '(编辑)'; //点击tableå•å…ƒæ ¼å¿«æ·é“¾æŽ¥æ˜¾ç¤ºç¼–è¾‘æ•°æ® this.currentAction = this.const.EDIT; this.currentRow = row; if (!(await this.initBox())) return; this.resetDetailTable(row); this.setEditForm(row); this.setContinueAdd(false); //设置远程查询表å•的默认key/value this.getRemoteFormDefaultKeyValue(); //点击编辑按钮弹出框åŽï¼Œå¯ä»¥åœ¨æ¤å¤„写逻辑,如,从åŽå°èŽ·å–æ•°æ® this.modelOpenProcess(row); }, setContinueAdd(isAdd) { if (!this.continueAdd) return; var _button = this.boxButtons.find((x) => { return x.value == 'save'; }); if (_button) { _button.name = isAdd ? this.continueAddName : 'ä¿ å˜'; } }, resetAdd() { if (this.hasDetail) { this.$refs.detail && // this.$refs.detail.rowData && this.$refs.detail.reset(); } let obj = {}; //如果有switchæ ‡ç¾ï¼Œé»˜è®¤éƒ½è®¾ç½®ä¸ºå¦ this.editFormOptions.forEach((x) => { x.forEach((item) => { if (item.type == 'switch') { obj[item.field] = 0; } }); }); this.resetEditForm(obj); }, async add() { this.boxOptions.title = this.table.cnName + '(新建)'; //新建 this.currentAction = this.const.ADD; this.currentRow = {}; if (!(await this.initBox())) return; this.resetAdd(); this.setContinueAdd(true); // this.resetEditForm(); this.boxModel = true; //点击新建按钮弹出框åŽï¼Œå¯ä»¥åœ¨æ¤å¤„写逻辑,如,从åŽå°èŽ·å–æ•°æ® this.modelOpenProcess(); // this.modelOpenAfter(); }, async edit(rows) { this.boxOptions.title = '编辑'; //编辑 this.currentAction = this.const.EDIT; if (rows) { if (!(rows instanceof Array)) { rows = [rows]; } } else { rows = this.$refs.table.getSelected(); } if (rows.length == 0) { return this.$error('请选择è¦ç¼–辑的行!'); } if (rows.length != 1) { return this.$error('åªèƒ½é€‰æ‹©ä¸€è¡Œæ•°æ®è¿›è¡Œç¼–辑!'); } //记录当å‰ç¼–辑的行 this.currentRow = rows[0]; //åˆå§‹åŒ–弹出框 if (!(await this.initBox())) return; this.setContinueAdd(false); //é‡ç½®è¡¨å• this.resetDetailTable(); //设置当å‰çš„æ•°æ®åˆ°è¡¨å•上 this.setEditForm(rows[0]); //设置远程查询表å•的默认key/value this.getRemoteFormDefaultKeyValue(); //点击编辑按钮弹出框åŽï¼Œå¯ä»¥åœ¨æ¤å¤„写逻辑,如,从åŽå°èŽ·å–æ•°æ® this.modelOpenProcess(rows[0]); // this.modelOpenAfter(rows[0]); }, getRemoteFormDefaultKeyValue() { //设置表å•è¿œç¨‹æ•°æ®æºçš„默认key.value if (this.currentAction != this.const.EDIT || this.remoteKeys.length == 0) return; this.editFormOptions.forEach((x, xIndex) => { x.forEach((item, yIndex) => { if (item.remote) { let column = this.columns.find((x) => { return x.bind && x.bind.key == item.dataKey; }); if (!column) return; let key = this.currentRow[item.field]; let obj = column.bind.data.find((x) => { return x.key == key; }); // obj ? obj.value : keyå¦‚æžœæ²¡æœ‰æŸ¥åˆ°æ•°æ®æºï¼Œç›´æŽ¥ä½¿ç”¨åŽŸæ•°æ® item.data = [{ key: key, value: obj ? obj.value : key }]; this.editFormOptions[xIndex].splice(yIndex, 1, item); // this.$set(item, 'data', [{ key: key + '', value: obj.value }]) // item.data = [{ key: key + '', value: obj.value }]; } }); }); }, modelOpenProcess(row) { this.$nextTick(() => { this.modelOpenAfter(row); }); return; // if (!this.$refs.form) { // let timeOut = setTimeout(x => { // this.modelOpenAfter(row); // }, 500) // return; // } // this.modelOpenAfter(row); }, import() { //导入(ä¸Šä¼ excel),弹出导入组件UploadExcel.vue this.upload.excel = true; this.$refs.upload_excel && this.$refs.upload_excel.reset(); }, download(url, fileName) { //下载导出的文件 let xmlResquest = new XMLHttpRequest(); xmlResquest.open('GET', url, true); xmlResquest.setRequestHeader('Content-type', 'application/json'); xmlResquest.setRequestHeader( 'Authorization', this.$store.getters.getToken() ); let elink = this.$refs.export; xmlResquest.responseType = 'blob'; xmlResquest.onload = function (oEvent) { if (xmlResquest.status != 200) { this.$error('下载文件出错了..'); return; } let content = xmlResquest.response; // let elink = this.$refs.export;//document.createElement("a"); elink.download = fileName; //+".xlsx"; // elink.style.display = "none"; let blob = new Blob([content]); elink.href = URL.createObjectURL(blob); // document.body.appendChild(elink); elink.click(); // document.body.removeChild(elink); }; xmlResquest.send(); }, getFileName(isDetail) { //2021.01.08å¢žåŠ å¯¼å‡ºexcel时自定义文件å if (isDetail) { return this.detail.cnName + '.xlsx'; } return this.table.cnName + '.xlsx'; }, export(isDetail) { //导出 let url, query, param; if (isDetail) { //明细表导出时如果是新建状æ€ï¼Œç¦æ¢å¯¼å‡º if (this.currentAction == 'Add') { return; } url = `api/${this.detail.table}/${this.const.EXPORT}`; param = { wheres: [ { name: this.table.key, value: this.editFormFields[this.table.key] } ] }; } else { //主表导出 url = this.getUrl(this.const.EXPORT); query = this.getSearchParameters(); param = { order: this.pagination.order, wheres: query.wheres || [] }; } //2020.06.25å¢žåŠ å¯¼å‡ºå‰å¤„ç† if (!isDetail && !this.exportBefore(param)) { return; } if (param.wheres && typeof param.wheres == 'object') { param.wheres = JSON.stringify(param.wheres); } let $http = this.http; //2022.09.26å¢žåŠ è‡ªå®šä¹‰å¯¼å‡ºæ–‡ä»¶å let fileName = this.downloadFileName || this.getFileName(isDetail); //2021.01.08优化导出功能 $http .post(url, param, 'æ£åœ¨å¯¼å‡ºæ•°æ®....', { responseType: 'blob' }) .then((content) => { const blob = new Blob([content]); if ('download' in document.createElement('a')) { // éžIE下载 const elink = document.createElement('a'); elink.download = fileName; elink.style.display = 'none'; elink.href = URL.createObjectURL(blob); document.body.appendChild(elink); elink.click(); URL.revokeObjectURL(elink.href); document.body.removeChild(elink); } else { // IE10+下载 navigator.msSaveBlob(blob, fileName); } }); //.then(result => { // if (!result.status) { // return this.$error(result.message); // } // let path = this.getUrl(this.const.DOWNLOAD); // path = path[0] == "/" ? path.substring(1) : path; // this.download( // $http.ipAddress + path + "?path=" + result.data, // this.table.cnName + ".xlsx" // filePath // ); /// window.open($http.ipAddress + path + "?fileName=" + filePath, "_self"); // }); }, getSelectRows() { //获å–选ä¸çš„行 return this.$refs.table.getSelected(); }, getDetailSelectRows() { //æˆ–èŽ·å–æ˜Žç»†é€‰ä¸çš„行 if (!this.$refs.detail) { return []; } return this.$refs.detail.getSelected(); }, audit() { //å®¡æ ¸å¼¹å‡ºæ¡† let rows = this.$refs.table.getSelected(); if (rows.length == 0) return this.$error('请选择è¦å®¡æ ¸çš„行!'); let auditStatus = Object.keys(rows[0]).find(x => { return x.toLowerCase() === 'auditstatus' }); if (!auditStatus) { return this.$message.error(`è¡¨å¿…é¡»åŒ…æ‹¬å®¡æ ¸å—æ®µã€AuditStatus】,并且是int类型`) } // let checkStatus = rows.every((x) => { // return this.$global.audit.status.some(c => { return c === x[auditStatus] || !x[auditStatus] }) // }); // if (!checkStatus) return this.$error('åªèƒ½é€‰æ‹©å¾…å®¡æ‰¹æˆ–å®¡æ ¸ä¸çš„æ•°æ®!'); this.$refs.audit.open(rows); }, saveAudit(params, rows, callback) { //ä¿å˜å®¡æ ¸ let keys = rows.map(x => { return x[this.table.key] }); if (!this.auditBefore(keys, rows)) { return; } let url = `${this.getUrl(this.const.AUDIT)}?auditReason=${params.reason}&auditStatus=${params.value}` this.http.post(url, keys, 'å®¡æ ¸ä¸....').then((x) => { if (!this.auditAfter(x, keys)) { return; } if (!x.status) return this.$error(x.message); callback && callback(x); this.$success(x.message); this.refresh(); }); }, viewModelCancel() { //查看表结构 this.viewModel = false; }, initFormOptions(formOptions, keys, formFields, isEdit) { //åˆå§‹åŒ–查询ã€ç¼–è¾‘å¯¹è±¡çš„ä¸‹æ‹‰æ¡†æ•°æ®æºã€å›¾ç‰‡ä¸Šä¼ é“¾æŽ¥åœ°å€ //let defaultOption = { key: "", value: "请选择" }; //æœ‰ä¸Šä¼ çš„å—æ®µ //2020.05.03新增 //ç¼–è¾‘æ•°æ®æºçš„类型 formOptions.forEach((item) => { item.forEach((d) => { if (d.type == 'number') { //2022.08.22优化表å•类型为number时的默认值 if (formFields[d.field] === '') { formFields[d.field] = undefined; } this.numberFields.push(d.field); } if ( d.type == 'img' || d.type == 'excel' || d.type == 'file' || d.columnType == 'img' ) { d.url = this.http.ipAddress + 'api' + this.table.url + 'Upload'; this.uploadfiled.push(d.field); } if (!d.dataKey) return true; //2022.02.20强制开å¯è”级å¯ä»¥é€‰æ‹©æŸä¸ªèŠ‚ç‚¹ if (d.type == 'cascader' && !d.hasOwnProperty('changeOnSelect')) { //强制开å¯è”级å¯ä»¥é€‰æ‹©æŸä¸ªèŠ‚ç‚¹ d.changeOnSelect = true; } //å¼€å¯è¿œç¨‹æœç´¢ if (d.remote) { this.remoteKeys.push(d.dataKey); d.data = []; //{ dicNo: d.dataKey, data: [] }; return true; } //2020.05.03å¢žåŠ ç¼–è¾‘è¡¨å•对checkboxçš„æ”¯æŒ if (d.type == 'checkbox' && !(formFields[d.field] instanceof Array)) { formFields[d.field] = []; } if (keys.indexOf(d.dataKey) == -1) { //2020.05.03å¢žåŠ è®°å½•ç¼–è¾‘å—æ®µçš„æ•°æ®æºç±»åž‹ keys.push(d.dataKey); //2020.05.03ä¿®å¤æŸ¥è¯¢è¡¨å•与编辑表å•typeç±»åž‹å˜æˆå¼ºä¸€è‡´æ€§çš„问题 //this.dicKeys.push({ dicNo: d.dataKey, data: [], type: d.type }); // 2020.11.01å¢žåŠ iview组件Cascaderæ•°æ®æºå˜å‚¨ let _dic = { dicNo: d.dataKey, data: [], fileds: [d.field], orginData: [] }; if (d.type == 'cascader') { _dic.type = 'cascader'; } if (isEdit) { _dic['e_type'] = d.type; } this.dicKeys.push(_dic); } else if (d.type == 'cascader') { this.dicKeys.forEach((x) => { if (x.dicNo == d.dataKey) { x.type = 'cascader'; x.fileds.push(d.field); } }); } if (d.type != 'cascader') { //2020.01.30移除内部表å•formOptionsæ•°æ®æºé…ç½®æ ¼å¼data.dataï¼Œæ‰€æœ‰å‚æ•°æ”¹ä¸ºä¸Žç»„ä»¶apiæ ¼å¼ç›¸åŒ Object.assign( d, this.dicKeys.filter((f) => { return f.dicNo == d.dataKey; })[0], { type: d.type } ); } }); }); }, //åˆå§‹tableä¸Žæ˜Žç»†è¡¨çš„æ•°æ®æºæŒ‡å‘dicKeys对象,å†åŽ»åŽå°åŠ è½½æ•°æ®æº initColumns(scoure, dicKeys, keys) { if (!scoure || !(scoure instanceof Array)) return; scoure.forEach((item) => { if (!item.bind || (item.bind.data && item.bind.data.length > 0)) return true; let key = item.bind.key || item.bind.dicNo; if (this.remoteKeys.indexOf(key) != -1) { item.bind.remote = true; return true; } if (this.hasKeyField.indexOf(item.field) == -1) { this.hasKeyField.push(item.field); } var dic = dicKeys.filter((x) => { return x.dicNo == key; }); if (!dic || dic.length == 0) { dicKeys.push({ dicNo: key, data: [] }); dic = [dicKeys[dicKeys.length - 1]]; keys.push(key); } //2020.11.01å¢žåŠ çº§è”å¤„ç† if (dic[0].type == 'cascader' || dic[0].type == 'treeSelect') { item.bind = { data: dic[0].orginData, type: 'select', key: key }; } else { item.bind = dic[0]; } //2020.05.03优化tableæ•°æ®æºcheckbox与select类型从编辑列ä¸é€‰å– item.bind.type = item.bind.e_type || 'string'; }); }, bindOptions(dic) { //ç»‘å®šä¸‹æ‹‰æ¡†çš„æ•°æ®æº //绑定åŽå°çš„å—å…¸æ•°æ® dic.forEach((d) => { if (d.data.length >= (this.select2Count || 500)) { if ( !this.dicKeys.some((x) => { return ( x.dicNo == d.dicNo && (x.type == 'cascader' || x.type == 'treeSelect') ); }) ) { d.data.forEach((item) => { item.label = item.value; item.value = item.key; }); } } this.dicKeys.forEach((x) => { if (x.dicNo != d.dicNo) return true; //2020.10.26å¢žåŠ çº§è”æ•°æ®æºç»‘å®šå¤„ç† if (x.type == 'cascader' || x.type == 'treeSelect') { // x.data=d.data; //生æˆtree结构 let _data = JSON.parse(JSON.stringify(d.data)); //2022.04.04å¢žåŠ çº§è”å—å…¸æ•°æ®æºåˆ·æ–°åŽtable没有å˜åŒ–的问题 this.columns.forEach((column) => { if (column.bind && column.bind.key == d.dicNo) { column.bind.data = d.data; } }); let arr = this.base.convertTree(_data, (node, data, isRoot) => { if (!node.inited) { node.inited = true; node.label = node.value; node.value = node.key; } }); x.data.push(...arr); x.orginData.push(...d.data); //2021.10.17ä¿®å¤æŸ¥è¯¢çº§è”ä¸èƒ½ç»‘å®šæ•°æ®æºçš„问题 this.searchFormOptions.forEach((searhcOption) => { searhcOption.forEach((_option) => { if (_option.type == 'cascader' && _option.dataKey == x.dicNo) { _option.data = arr; _option.orginData = d.data; } }); }); //2021.10.17ä¿®å¤çº§è”ä¸èƒ½äºŒçº§åˆ·æ–°çš„问题 this.editFormOptions.forEach((editOption) => { editOption.forEach((_option) => { if ( (_option.type == 'cascader' || _option.type == 'treeSelect') && _option.dataKey == x.dicNo ) { _option.data = arr; _option.orginData = d.data; } }); }); } else if (d.data.length > 0 && !d.data[0].hasOwnProperty('key')) { let source = d.data, newSource = new Array(source.length); for (let index = 0; index < source.length; index++) { newSource[index] = { //默认从å—典数æ®è¯»å‡ºæ¥çš„key都是string类型,但如果数æ®ä»Žsql䏿Ÿ¥è¯¢çš„å¯èƒ½ä¸ºéžstring,妿˜¯async-validator需è¦é‡ç½®è®¾ç½®æ ¼å¼ key: source['key'] + '', //source[index][x.config.valueField] + "", value: source['value'] //source[index][x.config.textField] }; } x.data.push(...newSource); } else { //2020.06.06,如果是selectListæ•°æ®æºä½¿ç”¨çš„自定义sql并且key是数å—ï¼Œå¼ºåˆ¶è½¬æ¢æˆå—符串 if ( x.e_type == 'selectList' && d.data.length > 0 && typeof d.data[0].key == 'number' ) { d.data.forEach((c) => { c.key = c.key + ''; }); } x.data.push(...d.data); } if ( this.singleSearch && this.singleSearch.dataKey && this.singleSearch.dataKey == x.dicNo ) { this.singleSearch.data.splice(0, 1, ...x.data); } }); }); }, getUrl(action, ingorPrefix) { //是å¦å¿½ç•¥å‰ç¼€/ èŽ·å–æ“作的url return (!ingorPrefix ? '/' : '') + 'api' + this.table.url + action; }, initDicKeys() { //åˆå§‹åŒ–å—å…¸æ•°æ® let keys = []; //2022.04.17ä¼˜åŒ–é‡æ–°åŠ è½½æ•°æ®æº this.dicKeys.forEach((item) => { item.data.splice(0); item.orginData && item.orginData.splice(0); }); //this.dicKeys.splice(0); //åˆå§‹åŒ–ç¼–è¾‘æ•°æ®æº,é»˜è®¤ä¸ºä¸€ä¸ªç©ºæ•°ç»„ï¼Œå¦‚æžœè¦æ±‚必填设置type=number/decimal的最å°å€¼ this.initFormOptions(this.editFormOptions, keys, this.editFormFields, true); //åˆå§‹åŒ–æŸ¥è¯¢æ•°æ®æº,默认为一个空数组 this.initFormOptions( this.searchFormOptions, keys, this.searchFormFields, false ); //查询日期设置为å¯é€‰å¼€å§‹ä¸Žç»“果日期 this.searchFormOptions.forEach((item) => { item.forEach((x) => { if (x.type == 'date' || x.type == 'datetime') x.range = true; }); }); //åˆå§‹åŒ–datatableè¡¨æ•°æ®æº,默认为一个空数组,dicKeysä¸ºç•Œé¢æ‰€æœ‰çš„æ•°æ®å—å…¸ç¼–å· this.initColumns(this.columns, this.dicKeys, keys); //2021.05.23é»˜è®¤å¼€å¯æŸ¥è¯¢é¡µé¢æ‰€æœ‰å—段排åº,如果ä¸éœ€è¦æŽ’åºï¼Œåœ¨onInitedé历columns设置sort=false //2021.09.25移除强制排åºåŠŸèƒ½ // this.columns.forEach(x => { // x.sort = x.render ? false : true; // }) if (this.detailOptions && this.detailOptions.columns) { this.initColumns(this.detailOptions.columns, this.dicKeys, keys); } //åˆå§‹åŒ–å¿«é€ŸæŸ¥è¯¢å—æ®µ,默认使用代ç 生æˆå™¨é…ç½®çš„ç¬¬ä¸€ä¸ªæŸ¥è¯¢å—æ®µ if (this.searchFormOptions.length > 0) { this.singleSearch = { dataKey: this.searchFormOptions[0][0].dataKey, dicNo: this.searchFormOptions[0][0].dicNo, field: this.searchFormOptions[0][0].field, title: this.searchFormOptions[0][0].title, type: this.searchFormOptions[0][0].type, data: [] }; // this.singleSearch = this.searchFormOptions[0][0]; } if (keys.length == 0) return; let $this = this; this.http.post('/api/Sys_Dictionary/GetVueDictionary', keys).then((dic) => { $this.bindOptions(dic); //2022.04.04å¢žåŠ å—å…¸åŠ è½½å®Œæˆæ–¹æ³• $this.dicInited && $this.dicInited(dic); }); }, setFiexdColumn(columns, containerWidth) { //计算整个tableçš„å®½åº¦ï¼Œæ ¹æ®å®½åº¦å†³å®šæ˜¯å¦å¯ç”¨ç¬¬ä¸€è¡Œæ˜¾ç¤ºçš„列为固定列 //2021.09.21移除强制固定第一列 // let columnsWidth = 0; // columns.forEach(x => { // if (!x.hidden && x.width) { // columnsWidth += x.width; // } // }); // //å¯ç”¨ç¬¬ä¸€åˆ—为固定列 // if (columnsWidth > containerWidth) { // let firstColumn = columns.find(x => !x.hidden); // if (firstColumn) { // firstColumn.fixed = true; // } // } }, initBoxHeightWidth() { //åˆå§‹åŒ–弹出框的高度与宽度 let clientHeight = document.documentElement.clientHeight; //弹出框高度至少250px clientHeight = clientHeight < 250 ? 250 : clientHeight; let clientWidth = document.documentElement.clientWidth; if ( this.editFormOptions.some((x) => { return x.some((item) => { return item.type == 'editor'; }); }) ) { this.editor.uploadImgUrl = this.getUrl('upload'); this.boxOptions.height = clientHeight * 0.8; this.boxOptions.width = clientWidth * 0.8; } else { if (this.boxOptions.height) { //如果高度与宽度超过了获å–到的å¯è§é«˜å®½åº¦ï¼Œåˆ™è®¾ä¸ºé»˜è®¤çš„90%高宽 if (this.boxOptions.height > clientHeight * 0.8) { this.boxOptions.height = clientHeight * 0.8; } } if (this.boxOptions.width) { //如果高度与宽度超过了获å–到的å¯è§é«˜å®½åº¦ï¼Œåˆ™è®¾ä¸ºé»˜è®¤çš„90%高宽 if (this.boxOptions.width > clientWidth * 0.8) { this.boxOptions.width = clientWidth * 0.8; } } } //计算整个tableçš„å®½åº¦ï¼Œæ ¹æ®å®½åº¦å†³å®šæ˜¯å¦å¯ç”¨ç¬¬ä¸€è¡Œæ˜¾ç¤ºçš„列为固定列 let maxTableWidth = clientWidth - 270; this.setFiexdColumn(this.columns, maxTableWidth); this.height = this.tableHeight || clientHeight - 206; this.url = this.getUrl(this.const.PAGE); //计算弹出框的高与宽度 //如果有明细表,高度与宽带设置为0.9/0.82 if (this.detail.columns && this.detail.columns.length > 0) { this.hasDetail = true; clientWidth = clientWidth * 0.8; clientHeight = clientHeight * 0.85; if (!this.detailOptions.height) { this.detailOptions.height = clientHeight - this.editFormOptions.length * 36 - 234; this.detailOptions.height = this.detailOptions.height < 240 ? 240 : this.detailOptions.height; } this.detailOptions.columns = this.detail.columns; this.detailOptions.pagination.sortName = this.detail.sortName; this.detailOptions.cnName = this.detail.cnName; this.detailOptions.key = this.detail.key; this.detailOptions.url = this.getUrl('getDetailPage'); //计算弹出框整个tableçš„å®½åº¦ï¼Œæ ¹æ®å®½åº¦å†³å®šæ˜¯å¦å¯ç”¨ç¬¬ä¸€è¡Œæ˜¾ç¤ºçš„列为固定列 this.setFiexdColumn(this.detail.columns, clientWidth); } else { let maxColumns = 1; //æœ€å¤§åˆ—æ•°ï¼Œæ ¹æ®åˆ—计算弹框的宽度 this.editFormOptions.forEach((x) => { if (x.length > maxColumns) maxColumns = x.length; }); let maxHeightRate = 0.7, maxWidthRate = 0.5; maxWidthRate = maxColumns / 10 + 0.3; maxHeightRate = (this.editFormOptions.length || 1) * 0.1 + 0.03; maxHeightRate = maxHeightRate > 0.9 ? 0.9 : maxHeightRate; clientWidth = clientWidth * maxWidthRate; clientHeight = clientHeight * maxHeightRate; // this.boxOptions.width = clientWidth * maxWidthRate; // this.boxOptions.height = clientHeight * maxHeightRate; } if (!this.boxOptions.height) { this.boxOptions.height = clientHeight + 10; } if (!this.boxOptions.width) { this.boxOptions.width = clientWidth + 30; } }, rowOnChange(row) { this.rowChange(row); }, rowChange(row) { //选ä¸è¡Œcheckbox行事件 }, rowOnClick({ row, column, event }) { this.rowClick({ row, column, event }); }, rowClick({ row, column, event }) { // 点击行事件(2020.11.07) }, rowOnDbClick({ row, column, event }) { this.rowDbClick({ row, column, event }); }, rowDbClick({ row, column, event }) { // åŒå‡»å‡»è¡Œäº‹ä»¶(2021.05.23) }, $error(message) { this.$message.error(message); // this.$message({ // type: 'error', // content: message, // duration: 5 // }); }, $success(message) { this.$message.success(message); }, setFiexdSearchForm(visiable) { //2020.09.011å¢žåŠ å›ºå®šæŸ¥è¯¢è¡¨å•功能,visiable=true默认将查询表å•展开 this.fiexdSearchForm = true; let refreshBtn = this.buttons.find((x) => x.name == '刷 æ–°'); if (visiable) { this.searchBoxShow = true; } if (refreshBtn) { refreshBtn.name = 'é‡ ç½®'; refreshBtn.onClick = function () { this.resetSearch(); }; } }, tableBeginEdit(row, column, index) { //2021.03.19是å¦å¼€å¯æŸ¥è¯¢ç•Œé¢è¡¨æ ¼åŒå‡»ç¼–è¾‘ç»“æŸæ–¹æ³•,返回falseä¸ä¼šç»“æŸç¼–辑 return this.beginEdit(row, column, index); }, beginEdit(row, column, index) { //2021.03.19是å¦å¼€å¯æŸ¥è¯¢ç•Œé¢è¡¨æ ¼åŒå‡»ç¼–è¾‘ç»“æŸæ–¹æ³•,返回falseä¸ä¼šç»“æŸç¼–辑 return true; }, tableEndEditBefore(row, column, index) { return this.endEditBefore(row, column, index); }, endEditBefore(row, column, index) { //2021.03.19是å¦å¼€å¯æŸ¥è¯¢ç•Œé¢è¡¨æ ¼åŒå‡»ç¼–è¾‘ç»“æŸæ–¹æ³•,返回falseä¸ä¼šç»“æŸç¼–辑 return true; }, filterPermission(tableName, permission) { //2021.03.19åˆ¤æ–æ˜¯å¦æœ‰æŸä¸ªè¡¨çš„æŒ‰é’®æƒé™ //:["Search","Add","Delete","Update","Import","Export","Upload","Audit"] const _result = (this.$store.state.permission || []).find((x) => { return x.url == '/' + tableName; }); return _result && _result.permission.some((x) => x == permission); }, destroyed() { //2021.04.11å¢žåŠ vue页é¢é”€æ¯æ–¹æ³•,路由必须设置keepLive:false,设置方法è§ï¼šå‰ç«¯å¼€å‘文档-》[ç¦ç”¨é¡µé¢ç¼“å˜keepAlive] }, loadTreeTableChildren(tree, treeNode, resolve) { this.loadTreeChildren.call(this, tree, treeNode, resolve); }, loadTreeChildren(tree, treeNode, resolve) { //æ ‘å½¢ç»“æž„åŠ è½½å节点(2021.05.02),在onInitä¸è®¾ç½®äº†rowKey䏻键嗿®µåŽæ‰ä¼šç”Ÿæ•ˆ return resolve([]); }, importDetailAfter(data) { //2022.01.08å¢žåŠ æ˜Žç»†è¡¨å¯¼å…¥åŽå¤„ç† }, importExcelAfter(data) { //2022.01.08å¢žåŠ æ˜Žç»†è¡¨å¯¼å…¥åŽæ–¹æ³•åˆ¤æ– if (!data.status) { return; // this.$message.error(data.message); } //明细表导入 if (this.boxModel) { if (data.data) { data.data = JSON.parse(data.data); } else { data.data = []; } data.data.forEach((x) => { x[this.detail.key] = undefined; x[this.table.key] = undefined; }); this.importDetailAfter(data); //å¢žåŠ æ˜Žç»†è¡¨å¯¼å…¥åŽå¤„ç† this.$refs.detail.rowData.unshift(...data.data); this.upload.excel = false; return; } this.importAfter(data); }, onGridModelClose(iconClick) { if (this.isBoxAudit) { this.initFormOptionType(false); } this.isBoxAudit = false; this.onModelClose(iconClick); }, initAuditColumn() { }, getWorkFlowSteps(row) { let table = this.table.url.replaceAll('/', ''); let url = `api/Sys_WorkFlow/getSteps?tableName=${table}&id=${row[this.table.key] }`; this.http.get(url, {}, true).then((result) => { this.workFlowSteps.splice(0); //有å¯èƒ½æ²¡æœ‰é…置审批æµç¨‹ if (!result.list || !result.list.length) { result.list = []; this.auditParam.showAction = true; this.auditParam.height = 240; this.auditParam.showViewButton = row.AuditStatus == 0; } else { this.auditParam.showAction = result.list.some((c) => { return c.isCurrentUser; }); this.auditParam.height = 511; this.auditParam.showViewButton = true; } this.auditParam.reason = ''; this.auditParam.status = -1; this.auditParam.value = -1; if (result.his) { result.his.forEach((item) => { item.auditStatus = this.getAuditStatus(item.auditStatus); }); } this.auditParam.auditHis = result.his; this.workFlowSteps.push(...result.list); this.isBoxAudit = true; this.initFormOptionType(true); this.edit(row); this.boxOptions.title = 'å®¡æ ¸'; }); }, initFormOptionType(isReadonly) { this.editFormOptions.forEach((options) => { options.forEach((option) => { if (isReadonly) { if (!option.readonly) { this.formFieldsType.push(option.field); option.readonly = true; } } else { if (this.formFieldsType.indexOf(option.field) != -1) { option.readonly = false; } } }); }); }, getAuditStatus(status) { let data = this.auditParam.data.find((x) => { return x.value == status; }); if (!data) { return '-'; // return `å®¡æ ¸å€¼ä¸æ£ç¡®:${status}` } return data.text; }, initFlowQuery() { if (this.$route.query.viewflow) { this.$refs.table && this.search(); } }, fullscreen(full){ //å¼¹å‡ºæ¡†å…¨å±æ–¹æ³• } }; import customColumns from './ViewGridCustomColumn.js'; //åˆå¹¶æ‰©å±•方法 methods = Object.assign(methods, detailMethods, serviceFilter, customColumns); export default methods;