diff --git a/src/resources/api/framework/form/form.js b/src/resources/api/framework/form/form.js index fe532b5f336fdc681162dce290065a9d1fd2d27c..912a7682a62a46a6694113491f63d684ff1081c5 100644 --- a/src/resources/api/framework/form/form.js +++ b/src/resources/api/framework/form/form.js @@ -2,10 +2,10 @@ import axios from '../../http'; const form = { getCustomItemById(id) { - return axios.post('/api/rest/form/customitem/get', {id: id}); + return axios.post('/api/rest/form/customitem/get', { id: id }); }, getCustomItemByName(name) { - return axios.post('/api/rest/form/customitem/get', {name: name}); + return axios.post('/api/rest/form/customitem/get', { name: name }); }, searchCustomItem(params) { return axios.post('/api/rest/form/customitem/search', params); @@ -67,20 +67,27 @@ const form = { }, //删除表单自定义组件 deleteCustomItem(id) { - return axios.post('/api/rest/form/customitem/delete', {id: id}); + return axios.post('/api/rest/form/customitem/delete', { id: id }); }, //删除表单场景 deleteScene(params) { return axios.post('/api/rest/form/version/scene/delete', params); }, - getReferenceCount(params) { //查询引用数量 + getReferenceCount(params) { + //查询引用数量 return axios.post('/api/rest/dependency/count', params); }, - saveFormDefaultscene(params) { //保存默认场景 + saveFormDefaultscene(params) { + //保存默认场景 return axios.post('/api/rest/form/version/defaultscene/save', params); }, - saveFormSceneReadonly(params) { //场景设置只读 + saveFormSceneReadonly(params) { + //场景设置只读 return axios.post('/api/rest/form/version/scene/readonly', params); + }, + searchMatrixColumnData(params) { + // 表格输入组件批量矩阵属性查询下拉接口 + return axios.post('/api/rest/matrix/column/data/search/forbatch', params); } }; export default form; diff --git a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue index 72a141963ef6ea721f69463c5a66ce2f2a6a78ff..b70d2d0c7535c0d02773a2be1f10247dac8bdb55 100644 --- a/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue +++ b/src/resources/plugins/TsSheet/form/component/formtableinputer/index.vue @@ -48,6 +48,7 @@ { workbook?.eachSheet((sheet, id) => { - sheet?.eachRow((row, rowIndex) => { + sheet?.eachRow(async(row, rowIndex) => { if (rowIndex != 1) { let rowValue = {}; let rowValuesList = this.$utils.deepClone(row.values); rowValuesList.splice(0, 1); // 删除excel第一列的序号 - this.tableData.theadList.forEach((item, tIndex) => { - if (item.key != 'selection' && item.key != 'number') { - this.$set(rowValue, [item.key], this.byComponentTypeSetValue(item.key, rowValuesList[tIndex - 2])); + for (let tIndex = 0; tIndex < this.tableData.theadList.length; tIndex++) { + if (this.tableData.theadList[tIndex] && this.tableData.theadList[tIndex].key != 'selection' && this.tableData.theadList[tIndex].key != 'number') { + let value = await this.byComponentTypeSetValue(this.tableData.theadList[tIndex].key, rowValuesList[tIndex - 2]); + this.loading = false; + this.$set(rowValue, [this.tableData.theadList[tIndex].key], value); } - }); + } let item = {...(this.tableData.tbodyList[rowIndex - 2] || {}), ...rowValue}; if (!this.$utils.isEmpty(this.tableData.tbodyList[rowIndex - 2])) { // 不为空时,修改数组对象里面的值 @@ -552,29 +556,41 @@ export default { } }); }); - this.$Message.success(this.$t('message.importsuccess')); }); }, - byComponentTypeSetValue(uuid, value) { + async byComponentTypeSetValue(uuid, value) { // 根据组件的类型,设置回显值 let resultValue; let selectedItem = this.extraList.find((extraItem) => extraItem.uuid == uuid); + console.log('selectedItem', selectedItem); let {config = {}, handler = ''} = selectedItem || {}; if (!this.$utils.isEmpty(value)) { - let {dataSource = '', isMultiple = false} = config || {}; + let {dataSource = '', isMultiple = false, matrixUuid = '', mapping = {}} = config || {}; if (dataSource === 'matrix' && (isMultiple || handler == 'formradio' || handler == 'formcheckbox')) { // 矩阵 resultValue = []; - let valueList = []; - if (typeof value == 'string') { - valueList = value.split(','); - valueList.forEach((valueItem) => { - if (valueItem) { - resultValue.push({text: valueItem, value: valueItem}); + if (matrixUuid && !this.$utils.isEmpty(mapping) && mapping.text && mapping.value) { + this.loading = true; + let params = { + searchParamList: [ + { + matrixUuid: matrixUuid, + textField: mapping.text, + valueField: mapping.value, + defaultValue: value instanceof Array ? value : typeof value == 'string' ? value.split(',') : [value] // 逗号处理多个选项时传递的值 + } + ] + }; + await this.$api.framework.form.searchMatrixColumnData(params).then((res) => { + if (res && res.Status == 'OK') { + let tbodyList = res.Return && res.Return.tbodyList || []; + tbodyList.forEach((item) => { + if (item && item.dataList) { + resultValue.push(...item.dataList); + } + }); } }); - } else { - resultValue.push({text: valueItem, value: valueItem}); } } else if (dataSource == 'static' && (isMultiple || (handler == 'formcheckbox'))) { resultValue = [];