onlineExcelCopy.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. <template>
  2. <div class="excel-data-container" v-loading="saveLoading"
  3. :element-loading-text="$t('Edb.save_ing')" element-loading-spinner="el-icon-loading"
  4. element-loading-background="rgba(0, 0, 0, 0.8)">
  5. <div class="online-excel">
  6. <div id="luckysheet"></div>
  7. </div>
  8. <div class="data-options-box">
  9. <div class="data-options-buttons">
  10. <el-button type="primary" style="width: 80px;font-size: 16px;" @click="saveExcel"><!-- 保存 -->{{$t('Dialog.confirm_save_btn')}}</el-button>
  11. <el-button plain style="width: 80px;font-size: 16px;" @click="cancel"><!-- 取消 -->{{$t('Dialog.cancel_btn')}}</el-button>
  12. </div>
  13. <div class="data-options" >
  14. <el-form :model="dataForm" label-position="top" ref="dataOptions">
  15. <el-form-item :label="$t('ManualEntryPage.label_one_level_classify')" prop="firstClassify" :rules="[{required:true,message:'品种不能为空',trigger:'change'}]">
  16. <el-select v-model="dataForm.firstClassify" placeholder="请选择品种" style="width: 100%;" @change="changeFirstClassify">
  17. <el-option :label="item.ClassifyName" :value="item.ClassifyId" v-for="item in classifyArray" :key="item.ClassifyId"></el-option>
  18. </el-select>
  19. </el-form-item>
  20. <el-form-item :label="$t('ManualEntryPage.label_edb_classify')" prop="secondClassify" :rules="[{required:true,message:'子品种不能为空',trigger:'change'}]">
  21. <el-select v-model="dataForm.secondClassify" placeholder="请选择子品种" style="width: 100%;" @change="changeSecondClassify">
  22. <el-option :label="item.ClassifyName" :value="item.ClassifyId" v-for="item in secondClassifyArray" :key="item.ClassifyId"></el-option>
  23. </el-select>
  24. </el-form-item>
  25. <el-form-item :label="$t('Edb.Detail.e_fre')" prop="frequency" :rules="[{required:true,message:'频度不能为空',trigger:'change'}]">
  26. <el-select v-model="dataForm.frequency" placeholder="请选择频度" style="width: 100%;" @change="changeFrequency">
  27. <el-option :label="item.label" :value="item.value" v-for="item in frequencyList" :key="item.value"></el-option>
  28. </el-select>
  29. </el-form-item>
  30. </el-form>
  31. <el-tooltip :open-delay="400">
  32. <div slot="content" v-html="$t('ManualEntryPage.use_msg')">
  33. </div>
  34. <div class="instruction-hint" >
  35. <span><!-- 使用说明 -->{{$t('ManualEntryPage.use_intro')}}</span>
  36. <i class="el-icon-question" style="color: #999;"></i>
  37. </div>
  38. </el-tooltip>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import { dataInterence } from "@/api/api.js";
  45. import EventBus from '@/api/bus.js';
  46. import {frequencySelectList} from '@/utils/defaultOptions';
  47. export default {
  48. name:'onlineExcelCopy',
  49. data() {
  50. // 受保护的数据 维护一个二维数组 用于还原不能被修改或者以错误方式修改的数据
  51. this.protectedData=[]
  52. // 初始化数据
  53. this.options={
  54. container:'luckysheet',
  55. lang: this.$i18nt.locale,
  56. gridKey:'handmade-excel',
  57. showinfobar:false,
  58. row:300,
  59. column:60,
  60. data:[
  61. {
  62. "name":"test",
  63. "celldata":[
  64. {
  65. "r":0,
  66. "c":0,
  67. "v":{
  68. ct: {fa: "@", t: "s"},
  69. m:"一级分类",
  70. v:"一级分类",
  71. bg:'#b4a7d6'
  72. },
  73. },
  74. {
  75. "r":1,
  76. "c":0,
  77. "v":{
  78. ct: {fa: "@", t: "s"},
  79. m:"指标分类",
  80. v:"指标分类",
  81. bg:'#b4a7d6'
  82. },
  83. },
  84. {
  85. "r":2,
  86. "c":0,
  87. "v":{
  88. ct: {fa: "@", t: "s"},
  89. m:"频度",
  90. v:"频度",
  91. bg:'#b4a7d6'
  92. },
  93. },
  94. {
  95. "r":3,
  96. "c":0,
  97. "v":{
  98. ct: {fa: "@", t: "s"},
  99. m:"指标名称",
  100. v:"指标名称",
  101. bg:'#b4a7d6'
  102. },
  103. },
  104. {
  105. "r":4,
  106. "c":0,
  107. "v":{
  108. ct: {fa: "@", t: "s"},
  109. m:"单位",
  110. v:"单位",
  111. bg:'#b4a7d6'
  112. },
  113. },
  114. ],
  115. "config":{
  116. "borderInfo":[{
  117. "rangeType": "range",
  118. "borderType": "border-all",
  119. "style": "1",
  120. "color": "#fff",
  121. "range": [{
  122. "row": [0,4],
  123. "column": [0,0]
  124. }]
  125. }],
  126. },
  127. "frozen":{
  128. type: 'rangeBoth',
  129. range: {row_focus: 4, column_focus: 0}
  130. },
  131. "dataVerification":{}
  132. }
  133. ],
  134. hook:{},
  135. showsheetbar:false
  136. }
  137. return {
  138. dataForm:{
  139. firstClassify:'',
  140. secondClassify:'',
  141. frequency:'',
  142. tradeCode:''
  143. },
  144. copyDataForm:{},
  145. firstClassName:'',
  146. secondClassName:'',
  147. //frequencyList: ['日度','周度','旬度','月度','季度','半年度','年度'],
  148. classifyArray:[],
  149. unitList:[],
  150. secondClassifyArray:[],
  151. // 保存时候的加载框
  152. saveLoading:false,
  153. isEdit:"false",
  154. refreshed:false,
  155. haveSaveProtected:false,
  156. hintMsg:`
  157. 1、新增指标:在预设好的指标列下输入指标名称、单位、数值并保存;</br>
  158. 2、新增日期:在第一列选择日期或插入日期行(需复制已有日期格式)输入数值并保存;</br>
  159. 3、清除指标:清空该指标下所有数据并保存,该操作不会删除指标,仅清除指标数据,请勿直接删除指标列;</br>
  160. 4、删除日期:清空该日期对应所有数据并保存,请勿直接删除日期行;</br>
  161. 5、指标名称编辑、单位编辑、频度编辑、指标删除等操作请在“手工指标列表”中完成;</br>
  162. `
  163. }
  164. },
  165. computed:{
  166. frequencyList(){
  167. return frequencySelectList()
  168. }
  169. },
  170. created() {
  171. // this.dataForm.firstClassify = parseInt(this.$route.query.parentClassifyId) || ''
  172. // this.dataForm.secondClassify = parseInt(this.$route.query.ClassifyId) || ''
  173. // this.dataForm.frequency = this.$route.query.Frequency || ''
  174. // this.dataForm.tradeCode = this.$route.query.TradeCode || ''
  175. // this.dataForm.tradeName = this.$route.query.TradeName || ''
  176. // this.copyDataForm = JSON.parse(JSON.stringify(this.dataForm))
  177. // // 字符串
  178. // this.isEdit = this.$route.query.isEdit.toString()
  179. this.initExcelOptions()
  180. // 监听折叠导航栏事件
  181. EventBus.$off('collapseHandle')
  182. EventBus.$on('collapseHandle',(params)=>{
  183. luckysheet.destroy()
  184. luckysheet.create(this.options)
  185. })
  186. },
  187. beforeRouteLeave(to, from, next) {
  188. luckysheet.destroy()
  189. next();
  190. },
  191. // 监听浏览器返回事件
  192. mounted() {
  193. window.addEventListener('popstate',this.setCache)
  194. },
  195. unmounted() {
  196. window.removeEventListener('popstate',this.setCache)
  197. },
  198. methods: {
  199. async initExcelOptions(){
  200. // 获取单位接口
  201. await this.getTargetUnitList()
  202. // 获取分类
  203. await this.getClassify()
  204. let dataList = []
  205. // 编辑才请求数据
  206. if(this.dataForm.secondClassify && this.isEdit == "true"){
  207. let res = await dataInterence.getTargetList({
  208. Frequency: this.dataForm.frequency,
  209. ClassifyId: this.dataForm.secondClassify,
  210. TradeCode:this.dataForm.tradeCode,
  211. EdbShowType: this.dataForm.tradeCode?0:1,
  212. })
  213. if(res.Ret == 200){
  214. dataList = res.Data.List || []
  215. }
  216. }
  217. // hook设置
  218. // 处理复制粘贴造成的漏洞 - 记录数据
  219. this.options.hook.cellAllRenderBefore=(data,sheet)=>{
  220. if(this.haveSaveProtected) return
  221. if(!this.protectedData.length>0){
  222. for (let i = 0; i < 5; i++) {
  223. if([0,1,2].includes(i)){
  224. for (let j = 0; j < 2; j++) {
  225. const element = data[i][j];
  226. if(!Array.isArray(this.protectedData[i])) this.protectedData[i]=[]
  227. this.protectedData[i][j] = element
  228. }
  229. }else{
  230. for (let k = 0; k <= dataList.length; k++) {
  231. const element = data[i][k];
  232. if(!Array.isArray(this.protectedData[i])) this.protectedData[i]=[]
  233. this.protectedData[i][k] = element
  234. }
  235. }
  236. }
  237. }
  238. this.haveSaveProtected=true
  239. }
  240. this.options.hook.cellUpdateBefore=(r,c)=>{
  241. let edbNameEle = luckysheet.getSheetData()[3][c]
  242. // 禁止更新的单元格 已经有的指标名称和单位不允许更新
  243. if(([0,1,2].includes(r) && c==0)
  244. || ([3,4].includes(r) && edbNameEle && this.protectedData[3].some(data => data.v == edbNameEle.v))){
  245. return false
  246. }
  247. }
  248. this.options.hook.cellMousedownBefore=(e,position)=>{
  249. let edbNameEle = luckysheet.getSheetData()[3][position.c]
  250. // 禁止鼠标选中的单元格
  251. if([0,1,2].includes(position.r)
  252. || ([3,4].includes(position.r) && edbNameEle && this.protectedData[3].some(data => data.v == edbNameEle.v))){
  253. return false
  254. }
  255. }
  256. // 处理复制粘贴造成的漏洞 - 还原数据 PS:这个钩子函数只有在单元格在可是区域内才会执行
  257. this.options.hook.cellRenderBefore=(cell,position,sheet,ctx)=>{
  258. // 清除两边空格
  259. if(cell && cell.m && typeof(cell.m)=='string'){
  260. cell.m = cell.m.trim()
  261. }
  262. if(cell && cell.v && typeof(cell.v)=='string'){
  263. cell.v = cell.v.trim()
  264. }
  265. /**
  266. * 从excel整个单元格复制,到这里进入编辑模式的粘贴,出来个cell.ct.s,不知道啥东西,官网也没写
  267. * 看似有内容,实则保存没内容,因为cell.m和cell.v 都是空。直接清掉了
  268. */
  269. if(cell && cell.ct && cell.ct.s){
  270. cell.ct.s=''
  271. }
  272. // 是否更改了受保护的数据
  273. let haveUpdatedProtectedData=false
  274. if([3,4].includes(position.r)){
  275. if(!cell) return
  276. let index = this.protectedData[3].findIndex((pd,ind) => pd && ind==position.c)
  277. if(index ==-1) return
  278. Object.keys(this.protectedData[position.r][index]).forEach(key => {
  279. if(!_.isEqual(cell[key], this.protectedData[position.r][index][key])){
  280. haveUpdatedProtectedData=true
  281. cell[key] = this.protectedData[position.r][index][key]
  282. }
  283. });
  284. }else if([0,1,2].includes(position.r)){
  285. let cindex = position.c>1?1:position.c
  286. if(!cell){
  287. if(cindex<1){
  288. return
  289. }
  290. sheet.data[position.r][position.c] = this.protectedData[position.r][1]
  291. }else{
  292. Object.keys(this.protectedData[position.r][cindex]).forEach(key => {
  293. if(!_.isEqual(cell[key], this.protectedData[position.r][cindex][key])){
  294. haveUpdatedProtectedData=true
  295. cell[key] = this.protectedData[position.r][cindex][key]
  296. }
  297. });
  298. if(position.c>0){
  299. if(position.r==0){
  300. if(cell.m !==this.firstClassName || cell.v !== this.firstClassName){
  301. haveUpdatedProtectedData=true
  302. cell.m = cell.v = this.firstClassName
  303. }
  304. }else if(position.r==1){
  305. if(cell.m !==this.secondClassName || cell.v !== this.secondClassName){
  306. haveUpdatedProtectedData=true
  307. cell.m = cell.v = this.secondClassName
  308. }
  309. }else{
  310. if(cell.m !==this.dataForm.frequency || cell.v !== this.dataForm.frequency){
  311. haveUpdatedProtectedData=true
  312. cell.m = cell.v = this.dataForm.frequency
  313. }
  314. }
  315. }
  316. }
  317. }
  318. if(haveUpdatedProtectedData){
  319. // 还原数据后的手动刷新
  320. this.refreshManual()
  321. }
  322. }
  323. this.options.hook.updated=(operation)=>{
  324. // 维护 protectedData数据
  325. if(operation.type == 'delRC'){
  326. // 删除列
  327. if(operation.ctrlValue.rc == 'c'){
  328. // console.log('删除列',`第${operation.ctrlValue.index+1}列开始`,`删除了${operation.ctrlValue.len}列`);
  329. if(!operation.data){
  330. // 没有data为撤销 恢复他
  331. for (let i = operation.ctrlValue.index; i < operation.ctrlValue.index+operation.ctrlValue.len; i++) {
  332. // 在celldata初始数据里面找,有找到说明不是新加的
  333. let isFind = luckysheet.getSheet().celldata.some(cd => {
  334. return cd.r==3 && cd.c < operation.ctrlValue.index+operation.ctrlValue.len+1 &&
  335. cd.v && cd.v.v == operation.curdata[3][i].v
  336. })
  337. this.protectedData[3].splice(i,0,isFind?operation.curdata[3][i]:false)
  338. this.protectedData[4].splice(i,0,isFind?operation.curdata[4][i]:false)
  339. }
  340. }else{
  341. for (let i = operation.ctrlValue.index; i < operation.ctrlValue.index+operation.ctrlValue.len; i++) {
  342. if(operation.ctrlValue.index > this.protectedData[3].length){
  343. break;
  344. }
  345. this.protectedData[3].splice(operation.ctrlValue.index,1)
  346. this.protectedData[4].splice(operation.ctrlValue.index,1)
  347. }
  348. }
  349. }
  350. }else if(operation.type == 'addRC' && operation.ctrlValue.rc == 'c'){
  351. // 增加列
  352. let addIndex = operation.ctrlValue.index
  353. if(operation.ctrlValue.direction=='lefttop'){
  354. // 向左加
  355. addIndex--
  356. }
  357. // 比原本的protectedData数组长度大,就不会对protectedData造成形象 就return
  358. if(!(addIndex < this.protectedData[3].length)) return
  359. // console.log('增加列',`第${addIndex+1}列开始向右`,`增加了${operation.ctrlValue.len}列,${operation.data?"正向操作":"撤销"}`);
  360. if(!operation.data){
  361. // 没有data为撤销 删除它
  362. for (let i = addIndex; i < addIndex+operation.ctrlValue.len; i++) {
  363. this.protectedData[3].splice(addIndex+1,1)
  364. this.protectedData[4].splice(addIndex+1,1)
  365. }
  366. }else{
  367. for (let i = addIndex; i < addIndex+operation.ctrlValue.len; i++) {
  368. // 新加的列,只占个位置,保持索引相对,不需要保护,置为false
  369. this.protectedData[3].splice(i+1,0,false)
  370. this.protectedData[4].splice(i+1,0,false)
  371. }
  372. }
  373. }
  374. }
  375. // 拿出所有数组
  376. let arr = dataList.map((item => item.DataList)).flat()
  377. // 拿出所有数组的日期并展平排序
  378. let dateArr = [...new Set(arr.map((item) => item.Dt))].sort().reverse()
  379. // 组合成需要的数据格式
  380. let excelData=dateArr.map(date =>{
  381. let objList = [date]
  382. dataList.forEach(element => {
  383. let obj = element.DataList.find((time) => time.Dt === date)
  384. objList.push(obj?obj.Close : '')
  385. });
  386. return objList
  387. })
  388. /**
  389. * 当数据的长度大于默认的300时,行数需要设置成数据的长度+15
  390. */
  391. this.options.row = dateArr.length>(this.options.row-15) ? (dateArr.length+15):this.options.row
  392. /**
  393. * 设置列数
  394. * 当数据的长度大于默认的60时,列数需要设置成数据的长度+10
  395. */
  396. this.options.column = dataList.length>(this.options.column-10) ? (dataList.length+10):this.options.column
  397. let row = this.options.row
  398. let col = this.options.column
  399. // 初始化数据
  400. dataList.map((item,index) =>{
  401. this.options.data[0].celldata.push(
  402. {
  403. "r":3,
  404. "c":1+index,
  405. "v":{
  406. ct: {fa: "@", t: "s"},
  407. m:item.SecName,
  408. v:item.SecName,
  409. bg:'#cccccc'
  410. }
  411. },
  412. {
  413. "r":4,
  414. "c":1+index,
  415. "v":{
  416. ct: {fa: "@", t: "s"},
  417. m:item.Unit,
  418. v:item.Unit,
  419. bg:'#cccccc'
  420. }
  421. })
  422. })
  423. for (let i = 0; i < col; i++) {
  424. this.options.data[0].celldata.push(
  425. {
  426. "r":0,
  427. "c":1+i,
  428. "v":{
  429. ct: {fa: "@", t: "s"},
  430. m:this.firstClassName || '',
  431. v:this.firstClassName || '',
  432. bg:'#cccccc'
  433. }
  434. },
  435. {
  436. "r":1,
  437. "c":1+i,
  438. "v":{
  439. ct: {fa: "@", t: "s"},
  440. m:this.secondClassName || '',
  441. v:this.secondClassName || '',
  442. bg:'#cccccc'
  443. }
  444. },
  445. {
  446. "r":2,
  447. "c":1+i,
  448. "v":{
  449. ct: {fa: "@", t: "s"},
  450. m:this.dataForm.frequency || '',
  451. v:this.dataForm.frequency || '',
  452. bg:'#cccccc'
  453. }
  454. })
  455. }
  456. for (let i = 0; i < row-5; i++) {
  457. for (let j = 0; j < (col+1); j++) {
  458. this.options.data[0].celldata.push(
  459. {
  460. "r":5+i,
  461. "c":0+j,
  462. "v":{
  463. ct: j==0?{fa: "yyyy-MM-dd", t: "d"}:{fa: "0.0000", t: "n"},
  464. m:excelData[i]?excelData[i][j]:'',
  465. v:excelData[i]?excelData[i][j]:'',
  466. }
  467. })
  468. }
  469. }
  470. // // 设置日期单元格颜色
  471. this.options.data[0].celldata.forEach(element => {
  472. if(element.c==0 && (![0,1,2,3,4].includes(element.r))){
  473. element.v.bg = '#ff9900'
  474. }
  475. });
  476. // 设置边框颜色
  477. this.options.data[0].config.borderInfo.push({
  478. "rangeType": "range",
  479. "borderType": "border-all",
  480. "style": "1",
  481. "color": "#fff",
  482. "range": [{
  483. "row": [0,2],
  484. "column": [1,col]
  485. }]
  486. },{
  487. "rangeType": "range",
  488. "borderType": "border-all",
  489. "style": "1",
  490. "color": "#fff",
  491. "range": [{
  492. "row": [5,row],
  493. "column": [0,0]
  494. }]
  495. },{
  496. "rangeType": "range",
  497. "borderType": "border-all",
  498. "style": "1",
  499. "color": "#fff",
  500. "range": [{
  501. "row": [3,4],
  502. "column": [1,dataList.length]
  503. }]
  504. })
  505. // 设置数据验证
  506. for (let i = 0; i < col; i++) {
  507. this.options.data[0].dataVerification[`4_${1+i}`]={
  508. "type": "dropdown",
  509. "type2": null,
  510. "value1": this.unitList.join(','),
  511. "value2": "",
  512. "prohibitInput": false,
  513. }
  514. }
  515. this.$nextTick(()=>{
  516. luckysheet.create(this.options)
  517. })
  518. },
  519. refreshManual: _.debounce(function() {
  520. if(!this.refreshed) {
  521. luckysheet.refresh()
  522. this.refreshed=true
  523. setTimeout(()=>{
  524. this.refreshed=false
  525. },1500)
  526. }
  527. },1000),
  528. // 获取分类
  529. async getClassify() {
  530. let res=await dataInterence.getClassify()
  531. if(res.Ret===200){
  532. this.classifyArray = res.Data.List || []
  533. this.dataForm.firstClassify = this.classifyArray[0].ClassifyId;
  534. this.firstClassName = this.classifyArray[0].ClassifyName
  535. this.secondClassifyArray = this.classifyArray[0] ? this.classifyArray[0].Child : []
  536. if(this.secondClassifyArray.length>0){
  537. this.dataForm.secondClassify = this.secondClassifyArray[0].ClassifyId;
  538. this.secondClassName = this.secondClassifyArray[0].ClassifyName
  539. }
  540. }
  541. },
  542. // 获取指标单位
  543. async getTargetUnitList(){
  544. let res=await dataInterence.getTargetUnitList()
  545. if(res.Ret===200){
  546. this.unitList = res.Data || []
  547. }
  548. },
  549. // 切换选择一级分类
  550. changeFirstClassify(id){
  551. let col = this.options.column
  552. let item = this.classifyArray.find(item => item.ClassifyId == id)
  553. this.firstClassName = item.ClassifyName
  554. // 指标分类数组
  555. this.secondClassifyArray = item.Child || []
  556. if(this.secondClassifyArray.length >0){
  557. // 默认选择第一个指标分类
  558. this.dataForm.secondClassify = this.secondClassifyArray[0].ClassifyId
  559. this.secondClassName = this.secondClassifyArray[0].ClassifyName
  560. }
  561. luckysheet.refresh()
  562. },
  563. // 切换选择二级分类
  564. changeSecondClassify(id){
  565. let col = this.options.column
  566. let item = this.secondClassifyArray.find(item => item.ClassifyId == id)
  567. this.secondClassName=item.ClassifyName
  568. luckysheet.refresh()
  569. },
  570. // 切换选择频度
  571. changeFrequency(value){
  572. luckysheet.refresh()
  573. },
  574. saveExcel(){
  575. this.$refs.dataOptions.validate((valid)=>{
  576. if(valid){
  577. this.saveLoading=true
  578. let data = luckysheet.getAllSheets()
  579. for (let i = 0; i < data[0].data.length; i++) {
  580. // 清除日期列的两边的空格,防止保存时日期变成0000-00-00
  581. const element = data[0].data[i][0];
  582. if(element && element.v && typeof(element.v)=='string'){
  583. element.v = element.v.trim()
  584. }
  585. if(element && element.m && typeof(element.m)=='string'){
  586. element.m = element.m.trim()
  587. }
  588. }
  589. dataInterence.saveOnlineExcel({...data[0],ClassifyId:this.dataForm.secondClassify}).then(res=>{
  590. if(res.Ret == 200) {
  591. this.setCache('submit')
  592. this.$router.push({path:'/dataList'})
  593. }
  594. }).finally(()=>{
  595. this.saveLoading=false
  596. })
  597. }
  598. })
  599. },
  600. cancel(){
  601. this.setCache()
  602. this.$router.back()
  603. },
  604. // 设置sessionStorage缓存
  605. setCache(type = 'cancel'){
  606. // 提交
  607. let params={}
  608. if(type == 'submit'){
  609. params = this.dataForm
  610. }else{
  611. params = this.copyDataForm
  612. }
  613. let query={
  614. tradeCode:params.tradeCode,
  615. secondClassify:params.secondClassify,
  616. frequency:params.frequency,
  617. firstClassify:params.firstClassify,
  618. tradeName:params.tradeName
  619. }
  620. sessionStorage.setItem('onlineExcelBack',JSON.stringify(query))
  621. }
  622. },
  623. }
  624. </script>
  625. <style lang="scss" scoped>
  626. .excel-data-container{
  627. display: flex;
  628. height: calc(100vh - 120px);
  629. .online-excel{
  630. flex-grow: 1;
  631. height: 100%;
  632. padding: 10px;
  633. border: 1px solid #ECECEC;
  634. box-sizing: border-box;
  635. #luckysheet{
  636. height: 100%;
  637. width: 100%;
  638. margin: 0;
  639. padding: 0;
  640. }
  641. }
  642. .data-options-box{
  643. min-width: 270px;
  644. height: 100%;
  645. margin-left: 20px;
  646. width: 270px;
  647. box-sizing: border-box;
  648. .data-options-buttons{
  649. border: 1px solid #ECECEC;
  650. box-sizing: border-box;
  651. padding: 20px 15px;
  652. }
  653. .data-options{
  654. padding: 25px 15px;
  655. box-sizing: border-box;
  656. .instruction-hint{
  657. display: inline-flex;
  658. align-items: center;
  659. cursor: pointer;
  660. span{
  661. font-size: 16px;
  662. margin-right: 4px;
  663. }
  664. }
  665. }
  666. }
  667. }
  668. .hint-message{
  669. font-size: 14px;
  670. line-height: 22px;
  671. }
  672. </style>
  673. <style lang="scss">
  674. // .online-excel{
  675. // }
  676. .data-options{
  677. .el-form--label-top .el-form-item__label{
  678. line-height: 16px;
  679. color: #333333;
  680. font-size: 16px;
  681. }
  682. }
  683. .luckysheet .toolbar {
  684. background: none;
  685. margin: 0;
  686. padding: 0;
  687. }
  688. </style>