【新增】 xlsx相关页面
This commit is contained in:
@@ -126,7 +126,7 @@
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item>
|
||||
<el-button @click="addWordInfo">添加</el-button>
|
||||
<el-button @click="addXlsxForm">添加</el-button>
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
@@ -278,25 +278,26 @@
|
||||
</div>
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<FileForm ref="FileRef" @success="handleUploadSuccess" />
|
||||
<el-dialog v-model="dialogFormVisibleWordInfo" title="考点设置" width="70%">
|
||||
|
||||
<el-dialog v-model="dialogFormVisibleXlsxInfo" title="考点设置" width="70%">
|
||||
<input type="file" id="xlsxFile" accept=".xlsx" />
|
||||
<button @click="getXlsxDataInfo">文件解析</button>
|
||||
<div style="height: 400px; overflow: hidden; display: flex; gap: 16px">
|
||||
<div style="flex: 0.8; overflow: auto; border: 1px solid #eee; padding: 8px">
|
||||
<div style="flex: 0.5; overflow: auto; border: 1px solid #eee; padding: 8px">
|
||||
<h3>考点</h3>
|
||||
<el-table :data="listPoint" style="width: 100%">
|
||||
<el-table-column prop="contentIn" label="值" width="500px">
|
||||
<template #default="{ row }">
|
||||
<span @click="addPoints(row)" style="cursor: pointer; color: black">
|
||||
{{ row.contentIn }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-tree
|
||||
style="max-width: 600px"
|
||||
:data="xlsxPointsList"
|
||||
:props="defaultProps"
|
||||
:expand-on-click-node="false"
|
||||
@node-click="handleNodelClick"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style="flex: 1.2; overflow: auto; border: 1px solid #eee; padding: 8px">
|
||||
<div style="flex: 1.5; overflow: auto; border: 1px solid #eee; padding: 8px">
|
||||
<h3>考点详情</h3>
|
||||
<el-table :data="list" style="width: 100%">
|
||||
<el-table-column prop="contentIn" label="值" width="400px" />
|
||||
<el-table-column prop="contentIn" label="值" width="500px" />
|
||||
|
||||
<el-table-column prop="scoreRate" label="权值" width="100">
|
||||
<template #default="{ row }">
|
||||
@@ -317,45 +318,44 @@
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <el-skeleton :rows="5" animated v-if="XlsxPointsList.length < 0 && isLoading" />
|
||||
-->
|
||||
</el-dialog>
|
||||
<!-- <el-dialog v-model="dialogFormVisibleWordInfos" :title="titles" width="300px">
|
||||
<el-dialog v-model="dialogFormVisibleXlsxInfos" :title="titles" width="300px">
|
||||
<el-tree
|
||||
style="max-width: 600px"
|
||||
:data="wordPointsInfoList"
|
||||
:data="xlsxPointsInfoList"
|
||||
:props="defaultProps"
|
||||
:expand-on-click-node="false"
|
||||
show-checkbox
|
||||
@check-change="handleCheckChange"
|
||||
/>
|
||||
<template #footer>
|
||||
<el-button type="primary" @click="submitWordPoints">确 定</el-button>
|
||||
<el-button @click="dialogFormVisibleWordInfos = false">取 消</el-button>
|
||||
<el-button type="primary" @click="submitXlsxPoints">确 定</el-button>
|
||||
<el-button @click="dialogFormVisibleXlsxInfos = false">取 消</el-button>
|
||||
</template>
|
||||
</el-dialog> -->
|
||||
</el-dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions, getStrDictOptions } from '@/utils/dict'
|
||||
import { FormRules } from 'element-plus'
|
||||
import * as QuestionApi from '@/api/paper/question'
|
||||
import * as XlsxApi from '@/api/wps/xlsx'
|
||||
import FileForm from './components/FileForm.vue'
|
||||
import WordInfo from './components/WordInfo.vue'
|
||||
import WordInfos from './components/WordInfos.vue'
|
||||
import * as SpecialtyApi from '@/api/points'
|
||||
import * as XlsxApi from '@/api/wps/xlsx'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { defaultProps, handleTree } from '@/utils/tree'
|
||||
import { FormRules } from 'element-plus'
|
||||
import { cloneDeep } from 'lodash-es'
|
||||
import FileForm from './components/FileForm.vue'
|
||||
|
||||
defineOptions({ name: 'WpsWordFrom' })
|
||||
const wordPointsList = ref<Tree[]>([]) // 树形结构
|
||||
const wordPointsInfoList = ref<Tree[]>([]) // 树形结构
|
||||
defineOptions({ name: 'WpsXlsxFrom' })
|
||||
const xlsxPointsList = ref<Tree[]>([]) // 树形结构
|
||||
const xlsxPointsInfoList = ref<Tree[]>([]) // 树形结构
|
||||
|
||||
const list = ref([]) // 列表的数
|
||||
const listPoint = ref([]) // 列表的数
|
||||
const { t } = useI18n() // 国际化
|
||||
const message = useMessage() // 消息弹窗
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const isLoading = ref(false)
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||
@@ -403,22 +403,8 @@ const formData = ref({
|
||||
}
|
||||
]
|
||||
})
|
||||
const wordPointsFun = ref({
|
||||
chineseName: '',
|
||||
function: ''
|
||||
})
|
||||
const wordPoints = ref({
|
||||
name: '',
|
||||
englishName: '',
|
||||
filePath: '',
|
||||
type: '',
|
||||
belongTo: '',
|
||||
isboo: '',
|
||||
function: '',
|
||||
unit: '',
|
||||
isExam: ''
|
||||
})
|
||||
let wordPointsInfosList: (typeof wordPoints)[] = []
|
||||
|
||||
let xlsxPointsInfosList: (typeof xlsxPoints)[] = []
|
||||
const removePoint = (index: number) => {
|
||||
list.value.splice(index, 1)
|
||||
}
|
||||
@@ -448,103 +434,63 @@ const documentList = ref([
|
||||
fileName: ''
|
||||
}
|
||||
])
|
||||
const dialogFormVisibleWordInfo = ref(false)
|
||||
const dialogFormVisibleWordInfos = ref(false)
|
||||
const nodeFunction = ref('')
|
||||
const dialogFormVisibleXlsxInfo = ref(false)
|
||||
const dialogFormVisibleXlsxInfos = ref(false)
|
||||
const titles = ref('')
|
||||
const englishName = ref('')
|
||||
const filePath = ref('')
|
||||
const upFilePath = ref('')
|
||||
|
||||
const functionList = ref<string[]>([])
|
||||
const xlsxPoints = reactive({
|
||||
contentIn: '',
|
||||
content: '',
|
||||
image: '',
|
||||
scoreRate: '',
|
||||
sort: 0
|
||||
})
|
||||
const wordData = reactive({
|
||||
chineseName: '',
|
||||
englishName: '',
|
||||
filePath: '',
|
||||
function: [] as string[]
|
||||
})
|
||||
const addPoints = (row: any) => {
|
||||
xlsxPoints.contentIn = row.contentIn
|
||||
xlsxPoints.content = row.content
|
||||
xlsxPoints.image = row.image
|
||||
xlsxPoints.scoreRate = row.scoreRate
|
||||
xlsxPoints.sort = list.value.length + 1
|
||||
list.value.push(cloneDeep(xlsxPoints))
|
||||
}
|
||||
const handleCheckChange = (data: Tree, checked: boolean, indeterminate: boolean) => {
|
||||
// if (checked || indeterminate) {
|
||||
// wordPoints.value.belongTo = data.belongTo
|
||||
// wordPoints.value.parameter = data.isboo
|
||||
// wordPoints.value.type = data.type
|
||||
// wordPointsFun.value = {
|
||||
// chineseName: '',
|
||||
// function: ''
|
||||
// }
|
||||
// wordPointsFun.value.chineseName = data.toChinese
|
||||
// wordPointsFun.value.function = data.nodeFunction
|
||||
// wordPoints.value.function.push(cloneDeep(wordPointsFun.value))
|
||||
// console.log(wordPoints)
|
||||
// }
|
||||
if (data.titleType == '2') {
|
||||
wordPoints.value.name = chineseName.value + data.toChinese
|
||||
wordPoints.value.filePath = filePath.value
|
||||
wordPoints.value.function = englishNames.value + data.nodeFunction
|
||||
wordPoints.value.englishName = englishNames.value
|
||||
wordPoints.value.belongTo = data.belongTo
|
||||
wordPoints.value.isboo = data.isboo
|
||||
wordPoints.value.type = data.type
|
||||
wordPoints.value.unit = data.unit
|
||||
wordPoints.value.isExam = '0'
|
||||
wordPointsInfosList.push(cloneDeep(wordPoints.value))
|
||||
console.log(data)
|
||||
const xlsxPoints = {
|
||||
firstName: '',
|
||||
index: '',
|
||||
function: '',
|
||||
examName: '',
|
||||
examCode: ''
|
||||
}
|
||||
if (data.functions != null && data.functions != "") {
|
||||
xlsxPoints.firstName = chineseName.value
|
||||
xlsxPoints.index = textIndex.value
|
||||
xlsxPoints.function = data.functions
|
||||
xlsxPoints.examName = data.chineseName
|
||||
xlsxPoints.examCode = '111'
|
||||
xlsxPoints.method = data.parameter
|
||||
xlsxPointsInfosList.push(cloneDeep(xlsxPoints))
|
||||
}
|
||||
}
|
||||
const file = ref()
|
||||
// 获取xlsx文件,并使用文件流进行解析
|
||||
const getXlsxDataInfo = async () => {
|
||||
const fileInput = document.getElementById('xlsxFile') as HTMLInputElement
|
||||
if (fileInput != null) {
|
||||
file.value = fileInput.files[0]
|
||||
const res = await XlsxApi.getXlsxDataInfo({ file: file.value })
|
||||
xlsxPointsList.value = []
|
||||
xlsxPointsList.value.push(...handleTree(res.data))
|
||||
}
|
||||
console.log(data, checked, indeterminate)
|
||||
}
|
||||
|
||||
const addWordInfo = async () => {
|
||||
var filePath = ''
|
||||
for (var i = 0; i < documentList.value.length; i++) {
|
||||
if (documentList.value[i].fileType == '2') {
|
||||
filePath = documentList.value[i].url
|
||||
}
|
||||
}
|
||||
// http://115.120.213.238:9000/exam/9f7d8f5d7c68cc2bfd03a23c19045efe7ba13a4bebeb833abece146908bcd0c6.docx documentList.value[1].url
|
||||
if (filePath == '' || filePath == null) {
|
||||
return
|
||||
}
|
||||
|
||||
isLoading.value = true
|
||||
// if (wordPointsList.value.length <= 0) {
|
||||
const res = await XlsxApi.getXlsxInfo(filePath)
|
||||
listPoint.value = res
|
||||
// isLoading.value = false
|
||||
// wordPointsList.value = []
|
||||
// wordPointsList.value.push(...handleTree(res))
|
||||
// }
|
||||
dialogFormVisibleWordInfo.value = true
|
||||
// 打开考点窗口
|
||||
const addXlsxForm = async () => {
|
||||
dialogFormVisibleXlsxInfo.value = true
|
||||
}
|
||||
|
||||
const queryParams = reactive({
|
||||
nodeFunction: undefined
|
||||
})
|
||||
const chineseName = ref('')
|
||||
const nodeFunctions = ref('')
|
||||
const englishNames = ref('')
|
||||
const textIndex = ref()
|
||||
|
||||
// 打开
|
||||
const handleNodelClick = async (row: any) => {
|
||||
// queryParams.nodeFunction = row.selectName
|
||||
// chineseName.value = '【' + row.name + '】'
|
||||
// filePath.value = row.filePath
|
||||
// nodeFunctions.value = row.selectName
|
||||
// englishNames.value = row.englishName
|
||||
// const res = await Xlsx.getWordInfos(queryParams)
|
||||
// wordPointsInfoList.value = []
|
||||
// wordPointsInfoList.value.push(...handleTree(res))
|
||||
// dialogFormVisibleWordInfos.value = true
|
||||
console.log(row)
|
||||
// 获取名称
|
||||
chineseName.value = '【' + row.name + '】'
|
||||
textIndex.value = row.index
|
||||
const res = await XlsxApi.getXlsxByNameList(row.type)
|
||||
xlsxPointsInfoList.value = []
|
||||
xlsxPointsInfoList.value.push(...handleTree(res))
|
||||
dialogFormVisibleXlsxInfos.value = true
|
||||
}
|
||||
const handleDelete = (row) => {
|
||||
console.log(row)
|
||||
@@ -555,39 +501,29 @@ const handleDelete = (row) => {
|
||||
}
|
||||
}
|
||||
|
||||
// const submitWordPoints = async () => {
|
||||
// const res = await WordApi.getWordListInfos(wordPointsInfosList)
|
||||
// wordPoints.value = {
|
||||
// name: '',
|
||||
// englishName: '',
|
||||
// filePath: '',
|
||||
// type: '',
|
||||
// belongTo: '',
|
||||
// isboo: '',
|
||||
// function: '',
|
||||
// unit: '',
|
||||
// isExam: ''
|
||||
// }
|
||||
// let index = 0
|
||||
// wordPointsInfosList = []
|
||||
// for (let i = 0; i < res.length; i++) {
|
||||
// var indexFlag = false
|
||||
// for (let x = 0; x < list.value.length; x++) {
|
||||
// if (res[i].content == list.value[x].content) {
|
||||
// // 如果存在相同的数据话 不进入
|
||||
// indexFlag = true
|
||||
// }
|
||||
// }
|
||||
// if (!indexFlag) {
|
||||
// index += 1;
|
||||
// res[i].sort = index;
|
||||
// list.value.push(res[i])
|
||||
// }
|
||||
// }
|
||||
// dialogFormVisibleWordInfo.value = false
|
||||
// dialogFormVisibleWordInfos.value = false
|
||||
// wordPointsList.value = []
|
||||
// }
|
||||
const submitXlsxPoints = async () => {
|
||||
console.log(xlsxPointsInfosList)
|
||||
const res = await XlsxApi.getXlsxMaster({
|
||||
data: JSON.stringify(xlsxPointsInfosList),
|
||||
file: file.value
|
||||
})
|
||||
xlsxPointsInfosList = []
|
||||
console.log(res)
|
||||
for (let i = 0; i < res.data.length; i++) {
|
||||
var indexFlag = false
|
||||
for (let x = 0; x < list.value.length; x++) {
|
||||
if (res.data[i].content == list.value[x].content) {
|
||||
// 如果存在相同的数据话 不进入
|
||||
indexFlag = true
|
||||
}
|
||||
}
|
||||
if (!indexFlag) {
|
||||
res.data[i].sort = list.value.length + 1
|
||||
list.value.push(res.data[i])
|
||||
}
|
||||
}
|
||||
dialogFormVisibleXlsxInfos.value = false
|
||||
}
|
||||
const formRules = reactive<FormRules>({
|
||||
status: [{ required: true, message: '启用状态必填', trigger: 'blur' }]
|
||||
})
|
||||
@@ -599,16 +535,10 @@ const rightActiveName = ref('annex')
|
||||
const rightHandleClick = (tab, e) => {
|
||||
rightActiveName.value = tab.paneName.value
|
||||
}
|
||||
// 关键字
|
||||
const multipleKeywordSelection = ref([] as any)
|
||||
const handleKeywordSelectionChange = (val: any) => {
|
||||
multipleKeywordSelection.value = val
|
||||
}
|
||||
const selections = ref([])
|
||||
const handleSelectionChange = (rows) => {
|
||||
selections.value = rows
|
||||
}
|
||||
const keyWord = ref([null])
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const FileRef = ref()
|
||||
@@ -652,17 +582,8 @@ const deleteUrl = (index: number) => {
|
||||
formData.value.fileUploads[index].fileName = ''
|
||||
}
|
||||
// 媒体文件
|
||||
const mediumList = ref([] as any)
|
||||
const multipleMediumSelection = ref([] as any)
|
||||
const handleMediumSelectionChange = (val: any) => {
|
||||
multipleMediumSelection.value = val
|
||||
}
|
||||
const fileList = []
|
||||
|
||||
const multipleDocumentSelection = ref([] as any)
|
||||
const handleDocumentSelectionChange = (val: any) => {
|
||||
multipleDocumentSelection.value = val
|
||||
}
|
||||
const handleUploadSuccess = ({ url, fileType }) => {
|
||||
const index = documentList.value.findIndex((item) => item.fileType === fileType)
|
||||
if (index !== -1) {
|
||||
@@ -699,16 +620,6 @@ const open = async (queryParams: any, type: string, id?: number) => {
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
// 转换函数:将大写字母 A-Z 映射为 0-25
|
||||
const mappedNumber = computed(() => {
|
||||
const char = radio.value.toUpperCase()
|
||||
const code = char.charCodeAt(0)
|
||||
if (code >= 65 && code <= 90) {
|
||||
return code - 65
|
||||
} else {
|
||||
return '请输入 A-Z 的字母'
|
||||
}
|
||||
})
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
@@ -329,7 +329,7 @@
|
||||
<WpsPptxForm ref="pformRef" @success="getList" />
|
||||
<SettingForm ref="setformRef" @success="getList"/>
|
||||
<EmailForm ref="emailformRef" @success="getList" />
|
||||
<WpsExcelForm ref="xlsxformRef" @success="getList" />
|
||||
<WpsXlsxForm ref="xlsxformRef" @success="getList" />
|
||||
<PsForm ref="psformRef" @success="getList" />
|
||||
|
||||
</template>
|
||||
@@ -351,7 +351,7 @@ import UserImportForm from './UserImportForm.vue'
|
||||
import WpsWordForm from './WpsWordForm.vue'
|
||||
import WpsPptxForm from './WpsPptxForm.vue'
|
||||
import SettingForm from './SettingForm.vue'
|
||||
import WpsExcelForm from './WpsExcelForm.vue'
|
||||
import WpsXlsxForm from './WpsXlsxForm.vue'
|
||||
import PsForm from './PsForm.vue'
|
||||
import EmailForm from './EmailForm.vue'
|
||||
import UserAssignRoleForm from './UserAssignRoleForm.vue'
|
||||
|
Reference in New Issue
Block a user