|
@@ -13,6 +13,19 @@
|
|
|
</div>
|
|
|
<div class="btn-box">
|
|
|
<el-button small @click="addCard"><i class="el-icon-plus"></i>增加卡片</el-button>
|
|
|
+ <el-upload
|
|
|
+ ref="upload"
|
|
|
+ :action="url"
|
|
|
+ accept=".xlsx,.xls"
|
|
|
+ :limit="9999"
|
|
|
+ :on-exceed="handleExceed"
|
|
|
+ :on-success="handleSuccess"
|
|
|
+ :show-file-list="false"
|
|
|
+ class="btn"
|
|
|
+ style="margin: 0 8px"
|
|
|
+ >
|
|
|
+ <el-button>通过模版导入</el-button>
|
|
|
+ </el-upload>
|
|
|
<el-button type="primary" plain small @click="save">结束编辑并保存</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -76,6 +89,7 @@
|
|
|
import Header from '@/components/Header';
|
|
|
import { getLogin, LearnWebSI, getHZChineseInfo, getContentFile } from '@/api/api';
|
|
|
import writeTable from './writeTableNew.vue';
|
|
|
+import { getToken } from '@/utils/auth';
|
|
|
import html2canvas from 'html2canvas';
|
|
|
import { jsPDF } from 'jspdf';
|
|
|
import canvg from 'canvg';
|
|
@@ -130,7 +144,17 @@ export default {
|
|
|
};
|
|
|
},
|
|
|
//计算属性 类似于data概念
|
|
|
- computed: {},
|
|
|
+ computed: {
|
|
|
+ url() {
|
|
|
+ let userInfo = getToken()
|
|
|
+ ? JSON.parse(getToken())
|
|
|
+ : sessionStorage.getItem('GCLS_Token_Tc')
|
|
|
+ ? JSON.parse(sessionStorage.getItem('GCLS_Token_Tc'))
|
|
|
+ : null;
|
|
|
+ if (!userInfo) return `${process.env.VUE_APP_BASE_API}/GCLSFileServer/WebFileUpload`;
|
|
|
+ return `${process.env.VUE_APP_BASE_API}/GCLSFileServer/WebFileUpload?AccessToken=${userInfo.access_token}&SecurityLevel=Mid"`;
|
|
|
+ },
|
|
|
+ },
|
|
|
//监控data中数据变化
|
|
|
watch: {},
|
|
|
//方法集合
|
|
@@ -298,6 +322,90 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ async handleSuccess(res, file, fileList) {
|
|
|
+ if (res.status !== 1) {
|
|
|
+ this.$message.error(res.message);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let file_id = file.response.file_info_list[0].file_id;
|
|
|
+ this.loading = true;
|
|
|
+ // 通过 fileList 的 response 判断是否已全部完成上传
|
|
|
+ this.loading = true;
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
+ await LearnWebSI('tr_tool-wsc_manager-ParseWordSentenceCardImportFile', {
|
|
|
+ file_id: file_id,
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ this.loading = false;
|
|
|
+ this.$message.success('导入成功');
|
|
|
+ res.content_json_text.forEach((items) => {
|
|
|
+ if (
|
|
|
+ items.headerCon ||
|
|
|
+ items.label ||
|
|
|
+ items.left.con ||
|
|
|
+ items.right.cixing ||
|
|
|
+ items.right.collocation ||
|
|
|
+ items.right.definition ||
|
|
|
+ items.right.exampleSent ||
|
|
|
+ items.right.pinyin
|
|
|
+ ) {
|
|
|
+ items.borderColor = '#243C97';
|
|
|
+ items.fontAlign = 'left';
|
|
|
+ items.fontColor = '#243C97';
|
|
|
+ let con = items.left.con.trim();
|
|
|
+ if (con) {
|
|
|
+ let MethodName = 'hz_resource_manager-GetMultHZStrokesContent';
|
|
|
+ let data = {
|
|
|
+ hz_str: con,
|
|
|
+ };
|
|
|
+ getLogin(MethodName, data)
|
|
|
+ .then((res) => {
|
|
|
+ this.loading = false;
|
|
|
+ for (let key in res) {
|
|
|
+ if (key != 'status' && key != ',' && res[key]) {
|
|
|
+ res[key] = JSON.parse(res[key]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let hzDetailList = res;
|
|
|
+ let hz_list = [];
|
|
|
+ con.split('').forEach((items) => {
|
|
|
+ let res = JSON.parse(JSON.stringify(hzDetailList[items]));
|
|
|
+ let obj = {
|
|
|
+ con: items,
|
|
|
+ hzDetail: {
|
|
|
+ hz_json: res,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ hz_list.push(obj);
|
|
|
+ });
|
|
|
+ items.right.hz_info = hz_list;
|
|
|
+ let MethodName = 'tool-TextToVoiceFile';
|
|
|
+ if (con) {
|
|
|
+ let datas = {
|
|
|
+ text: con,
|
|
|
+ };
|
|
|
+ getLogin(MethodName, datas).then((res) => {
|
|
|
+ if (res.status === 1) {
|
|
|
+ items.right.audio_file = res.file_id;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.newEditTable.push(items);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch((res) => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ handleExceed(files) {
|
|
|
+ this.$message.warning(`当前限制选择 9999 个文件,本次选择了 ${files.length} 个文件`);
|
|
|
+ },
|
|
|
},
|
|
|
//生命周期 - 创建完成(可以访问当前this实例)
|
|
|
created() {},
|