diff --git a/src/resources/api/framework/form/form.js b/src/resources/api/framework/form/form.js index b8aecd1cc86e87db977d54b1f132581b3b6ac84b..fe532b5f336fdc681162dce290065a9d1fd2d27c 100644 --- a/src/resources/api/framework/form/form.js +++ b/src/resources/api/framework/form/form.js @@ -76,8 +76,11 @@ const form = { getReferenceCount(params) { //查询引用数量 return axios.post('/api/rest/dependency/count', params); }, - getFormDefaultscene(params) { //保持默认场景 + saveFormDefaultscene(params) { //保存默认场景 return axios.post('/api/rest/form/version/defaultscene/save', params); + }, + saveFormSceneReadonly(params) { //场景设置只读 + return axios.post('/api/rest/form/version/scene/readonly', params); } }; export default form; diff --git a/src/resources/assets/languages/term/en.json b/src/resources/assets/languages/term/en.json index 7cfeb6f6a4daa63f9d42919cad55a1fdfcaf6d0a..fde435ee9f5b55e4fcadc27aaa4e160f353985d5 100644 --- a/src/resources/assets/languages/term/en.json +++ b/src/resources/assets/languages/term/en.json @@ -1152,7 +1152,9 @@ "versionlog": "Version Log", "exporttable": "Export Table", "importtable": "Import Table", - "excelinputtemplate": "Table Input Template" + "excelinputtemplate": "Table Input Template", + "globalreadonly": "Global read-only", + "globalreadonlytip": "The global read-only priority is higher than the internal read and write settings of the component. After turning on the global read-only switch, all components in the scene are in a read-only state" }, "knowledge": { "document": "Document", diff --git a/src/resources/assets/languages/term/zh.json b/src/resources/assets/languages/term/zh.json index 94782d627fabb7bf7a94fe925dc8586f72bc99fb..cf2339881125ac4908171d0b1dacece2dc737774 100644 --- a/src/resources/assets/languages/term/zh.json +++ b/src/resources/assets/languages/term/zh.json @@ -1151,7 +1151,9 @@ "versionlog": "版本日志", "exporttable": "导出表格", "importtable": "导入表格", - "excelinputtemplate": "表格输入模板" + "excelinputtemplate": "表格输入模板", + "globalreadonly": "全局只读", + "globalreadonlytip": "全局只读优先级高于组件内部的读写设置,打开全局只读开关后,场景内所有组件均为只读状态" }, "knowledge": { "document": "文档", diff --git a/src/resources/plugins/TsSheet/TsSheet.vue b/src/resources/plugins/TsSheet/TsSheet.vue index 5096fd62450ee56ebab559f53c806705cc83fe98..aa5f1564a645b7b80c05ab9d55948b947bba610c 100644 --- a/src/resources/plugins/TsSheet/TsSheet.vue +++ b/src/resources/plugins/TsSheet/TsSheet.vue @@ -665,12 +665,15 @@ export default { //校验表单内所有组件的数据,返回异常数据 async validData(validConifg) { const errorMap = {}; - for (let i = 0; i < this.componentCells.length; i++) { - const component = this.componentCells[i].component; - if (component && component.uuid) { - const es = this.$refs['formitem_' + component.uuid] && this.$refs['formitem_' + component.uuid][0] ? await this.$refs['formitem_' + component.uuid][0].validData(validConifg) : null; - if (es && es.length > 0) { - errorMap[component.uuid] = es; + //表单只读或者禁用,所有组件跳过校验 + if (!this.disabled && !this.readonly) { + for (let i = 0; i < this.componentCells.length; i++) { + const component = this.componentCells[i].component; + if (component && component.uuid) { + const es = this.$refs['formitem_' + component.uuid] && this.$refs['formitem_' + component.uuid][0] ? await this.$refs['formitem_' + component.uuid][0].validData(validConifg) : null; + if (es && es.length > 0) { + errorMap[component.uuid] = es; + } } } } @@ -1556,11 +1559,16 @@ export default { let hiddenComponentList = []; if (this.config.tableList && this.config.tableList.length > 0) { this.config.tableList.forEach(item => { - if (item.component && item.component.hasValue && !hiddenComponentList.includes(item.component.uuid)) { - if (!this.$refs['formitem_' + item.component.uuid]) { - hiddenComponentList.push(item.component.uuid); - } else if (this.config.hiddenRowList.includes(item.row) || (item.component.config && item.component.config.isHide)) { + if (item.component && item.component.hasValue) { + if (this.disabled || this.readonly) { + //表单只读或者禁用,所有组件uuid传到后台跳过接口校验 hiddenComponentList.push(item.component.uuid); + } else if (!hiddenComponentList.includes(item.component.uuid)) { + if (!this.$refs['formitem_' + item.component.uuid]) { + hiddenComponentList.push(item.component.uuid); + } else if (this.config.hiddenRowList.includes(item.row) || (item.component.config && item.component.config.isHide)) { + hiddenComponentList.push(item.component.uuid); + } } } }); diff --git a/src/resources/plugins/TsSheet/form-edit.vue b/src/resources/plugins/TsSheet/form-edit.vue index 593df3cf3a719d197c5dff01d2b2663bb73a81a3..727796c7e48061b64680af1777e574726551cd3b 100644 --- a/src/resources/plugins/TsSheet/form-edit.vue +++ b/src/resources/plugins/TsSheet/form-edit.vue @@ -5,18 +5,19 @@ {{ $getFromPage($t('router.framework.formmanage')) }} - @@ -297,6 +322,7 @@ @close="closeScene" @deleteScene="deleteScene" @updateDefaultSceneUuid="updateDefaultSceneUuid" + @updateSceneReadOnly="updateSceneReadOnly" > @@ -319,7 +345,8 @@ export default { FormReferenceDialog: resolve => require(['./form-reference-dialog.vue'], resolve), UploadDialog: resolve => require(['@/resources/components/UploadDialog/UploadDialog.vue'], resolve), FormWidthDialog: resolve => require(['./form-width-dialog.vue'], resolve), - FormSceneDialog: resolve => require(['./form-scene-dialog.vue'], resolve) + FormSceneDialog: resolve => require(['./form-scene-dialog.vue'], resolve), + TsFormSwitch: resolve => require(['@/resources/plugins/TsForm/TsFormSwitch'], resolve) }, extends: subformconfig, mixins: [download], @@ -376,7 +403,8 @@ export default { isShowEditFormWidth: false, //表单宽度设置 formGroup: ['basic', 'layout', 'autoexec', 'cmdb', 'custom'], isFormSceneDialog: false, - sceneUuid: null + sceneUuid: null, + readOnly: false //设置全局只读 }; }, beforeCreate() {}, @@ -541,6 +569,7 @@ export default { !formConfig.name && (formConfig.name = this.$t('page.mainscene')); this.$set(formConfig, 'sceneList', this.initFormConfig.sceneList || []); this.$set(formConfig, 'defaultSceneUuid', this.initFormConfig.defaultSceneUuid || formConfig.uuid); + this.$set(formConfig, 'readOnly', this.readOnly); if (type === 'saveother') { this.$set(formConfig, 'uuid', this.$utils.setUuid()); formConfig.sceneList.forEach(item => { @@ -679,6 +708,7 @@ export default { this.versionList = res.Return.versionList || []; let formConfig = res.Return.formConfig || {}; this.sceneUuid = formConfig.uuid; + this.readOnly = formConfig.readOnly || false; this.$set(this.formData, 'name', res.Return.name); if (this.versionList.length > 0) { this.versionList.forEach(item => { @@ -995,7 +1025,32 @@ export default { }); }, updateDefaultSceneUuid(uuid) { - this.$set(this.initData, 'defaultsceneUuid', uuid); + this.$set(this.initFormConfig, 'defaultSceneUuid', uuid); + }, + updateSceneReadOnly(readOnly, sceneUuid) { + if (sceneUuid === this.initFormConfig.uuid) { + this.$set(this.initFormConfig, 'readOnly', readOnly); + this.readOnly = readOnly; + } else { + this.initFormConfig.sceneList.forEach(item => { + if (item.uuid === sceneUuid) { + this.$set(item, 'readOnly', readOnly); + } + }); + } + }, + changeReadOnly(val) { + this.defaultSceneUuid = this.selectSceneUuid; + this.$api.framework.form.saveFormSceneReadonly({ + versionUuid: this.currentVersion.uuid, + sceneUuid: this.sceneUuid, + readOnly: val + }).then(res => { + if (res.Status == 'OK') { + this.$Message.success(this.$t('message.savesuccess')); + this.$set(this.initFormConfig, 'readOnly', readOnly); + } + }); } }, filter: {}, diff --git a/src/resources/plugins/TsSheet/form-preview.vue b/src/resources/plugins/TsSheet/form-preview.vue index d5b22e5cd9af5954a932db684d00b3a86f4ca01c..6a0e0abdf7ebb06c27554e81c35c9031135c2258 100644 --- a/src/resources/plugins/TsSheet/form-preview.vue +++ b/src/resources/plugins/TsSheet/form-preview.vue @@ -9,6 +9,7 @@ mode="read" :value="data" :data="inputFormData" + :readonly="data.readOnly || false" @emit="emitFn" > diff --git a/src/resources/plugins/TsSheet/form-scene-dialog.vue b/src/resources/plugins/TsSheet/form-scene-dialog.vue index 646472ba742ebddc6cd2923efd8057b773bf1949..dc0afd038ddca86ab09203ffa64452a16b58b5e4 100644 --- a/src/resources/plugins/TsSheet/form-scene-dialog.vue +++ b/src/resources/plugins/TsSheet/form-scene-dialog.vue @@ -31,6 +31,14 @@ :referenceCount="row.referenceCount" > + @@ -120,6 +146,8 @@ :formConfig="initFormConfig" @close="closeScene" @deleteScene="deleteScene" + @updateDefaultSceneUuid="updateDefaultSceneUuid" + @updateSceneReadOnly="updateSceneReadOnly" > require(['./form-item-config.vue'], resolve), FormPreview: resolve => require(['./form-preview.vue'], resolve), FormSceneDialog: resolve => require(['./form-scene-dialog.vue'], resolve), - ReactionDialog: resolve => require(['./form-row-reaction-dialog.vue'], resolve) + ReactionDialog: resolve => require(['./form-row-reaction-dialog.vue'], resolve), + TsFormSwitch: resolve => require(['@/resources/plugins/TsForm/TsFormSwitch'], resolve) }, props: {}, data() { @@ -168,7 +197,8 @@ export default { isFormSceneDialog: false, disabled: false, sceneList: [], - deleteSceneUuid: '' + deleteSceneUuid: '', + readOnly: false }; }, beforeCreate() {}, @@ -316,6 +346,7 @@ export default { return !sceneConfig.tableList.find(t => t.component && t.component.uuid === f.uuid); }); this.formData.formConfig = this.$utils.deepClone(sceneConfig); + this.readOnly = sceneConfig.readOnly || false; } } this.$addWatchData(this.getCompareData(sceneConfig)); @@ -478,6 +509,7 @@ export default { let formConfig = this.$refs.sheet.getFormConfig(); this.$set(formConfig, 'name', this.sceneName); this.$set(formConfig, 'uuid', this.sceneUuid); + this.$set(formConfig, 'readOnly', this.readOnly); if (formConfig.tableList) { formConfig.tableList.forEach(item => { if (item.component && item.component.inherit) { @@ -544,6 +576,40 @@ export default { currentVersionUuid: this.currentVersionUuid } }); + }, + updateDefaultSceneUuid(uuid) { + this.$set(this.initFormConfig, 'defaultSceneUuid', uuid); + }, + updateSceneReadOnly(readOnly, sceneUuid) { + if (sceneUuid === this.initFormConfig.uuid) { + this.$set(this.initFormConfig, 'readOnly', readOnly); + } else { + this.initFormConfig.sceneList.forEach(item => { + if (item.uuid === sceneUuid) { + this.$set(item, 'readOnly', readOnly); + } + }); + } + if (sceneUuid === this.sceneUuid) { + this.readOnly = readOnly; + } + }, + changeReadOnly(val) { + this.defaultSceneUuid = this.selectSceneUuid; + this.$api.framework.form.saveFormSceneReadonly({ + versionUuid: this.currentVersionUuid, + sceneUuid: this.sceneUuid, + readOnly: val + }).then(res => { + if (res.Status == 'OK') { + this.$Message.success(this.$t('message.savesuccess')); + this.initFormConfig.sceneList.forEach(item => { + if (item.uuid === sceneUuid) { + this.$set(item, 'readOnly', readOnly); + } + }); + } + }); } }, filter: {}, diff --git a/src/views/pages/process/task/processdetail/workorder/CenterDetail.vue b/src/views/pages/process/task/processdetail/workorder/CenterDetail.vue index 6444cdfffb2806f77405d5d48aca22154673f6f0..4036adfcbb5bc23f0982df5fd2d0bd3eaf13a9e4 100644 --- a/src/views/pages/process/task/processdetail/workorder/CenterDetail.vue +++ b/src/views/pages/process/task/processdetail/workorder/CenterDetail.vue @@ -59,7 +59,7 @@ mode="read" :value="formConfig" :data="processTaskConfig.formAttributeDataMap" - :readonly="!actionConfig.save || !formEdit" + :readonly="!actionConfig.save || !formEdit || formConfig.readOnly" class="pl-sm pr-sm" @emit="formSheetEmitData" @updateHiddenComponentList="updateHiddenComponentList" diff --git a/src/views/pages/process/task/processdispatch/workorder/form-setting.vue b/src/views/pages/process/task/processdispatch/workorder/form-setting.vue index 128369ae11192bda43109d4c7d680efde3ecb9ac..c58555d223bc03de2aed8aa0d83bab3c991fbe50 100644 --- a/src/views/pages/process/task/processdispatch/workorder/form-setting.vue +++ b/src/views/pages/process/task/processdispatch/workorder/form-setting.vue @@ -12,6 +12,7 @@ v-else-if="formConfig && formConfig._type == 'new'" ref="formSheet" mode="read" + :readonly="formConfig.readOnly || false" :value="formConfig" :data="formAttributeDataMap" @emit="formSheetEmitData"