index.vue 70 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024
  1. <template>
  2. <div class="cqcy-content" style="margin: 0;height: calc(100% - 70px);">
  3. <breadcrumb-view :breadcrumbList="breadcrumbList" :show-index="false"></breadcrumb-view>
  4. <div v-if="btnType === ''" class="cy-nav-sx">
  5. <el-select v-model="searchValue"
  6. style="width: 180px;"
  7. placeholder="请选择报表类型"
  8. @change="changeReportTypeEvent">
  9. <el-option v-for="item in reportOptions"
  10. style="margin-left: 5px; width: 180px;"
  11. :key="item.value"
  12. :label="item.label"
  13. :value="item.value">
  14. </el-option>
  15. </el-select>
  16. <el-input placeholder="请输入报表名称"
  17. v-model="searchTxt"
  18. style="margin-left: 5px; width: 180px;"
  19. prefix-icon="el-icon-search">
  20. </el-input>
  21. <el-button style="margin-left: 5px;" @click="searchReportEvent">查询</el-button>
  22. </div>
  23. <!-- <el-button v-if="btnType === ''" type="primary" class="cy-nav-btn" icon="el-icon-circle-plus-outline"-->
  24. <!-- size="mini" @click="addReportEvent">新增</el-button>-->
  25. <!-- <el-button v-if="btnType === ''" type="success" class="cy-nav-btn" icon="el-icon-refresh"-->
  26. <!-- size="mini" @click="refreshReportEvent">刷新</el-button>-->
  27. <el-divider></el-divider>
  28. <div class="cy-main">
  29. <div class="cy-main-left" v-if="!showMainView">
  30. <div class="cy-list">
  31. <el-table v-if="reportDataList.length > 0"
  32. :data="reportDataList"
  33. border
  34. :stripe="true"
  35. :header-cell-style="{background: '#E8E8E8'}"
  36. @sort-change="sortChange"
  37. style="width: 100%;">
  38. <el-table-column
  39. align="center"
  40. sortable="custom"
  41. label="报表名称"
  42. prop="reportTableName">
  43. <template slot-scope="scope">
  44. <span style="color: #409EFF; cursor: pointer;"
  45. @click="handleReportNodeClick(scope.row, scope.row.userId != uid ? 'deny' : '')"
  46. :title="scope.row.reportTableName">{{ scope.row.reportTableName }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. align="center"
  51. label="报表状态"
  52. prop="isAutoReport"
  53. width="350">
  54. <template slot-scope="scope">
  55. <el-tag v-if="scope.row.userId != uid" type="success" style="margin-right: 5px;">被分享</el-tag>
  56. <el-tag v-if="uid == scope.row.userId && scope.row.userGroupList && scope.row.userGroupList.length > 0"
  57. type="warning" style="margin-right: 5px;">已分享</el-tag>
  58. <el-tag v-if="scope.row.isAutoReport == 0" style="margin-right: 5px;">手动报表</el-tag>
  59. <el-tag v-if="scope.row.isAutoReport == 1" style="margin-right: 5px;">自动报表</el-tag>
  60. <el-tag v-if="scope.row.isAutoReport == 3" style="margin-right: 5px;">事件驱动报表</el-tag>
  61. <!-- <el-tag v-if="scope.row.isAutoReport == 0" type="info" style="margin-right: 5px;">默认</el-tag>-->
  62. </template>
  63. </el-table-column>
  64. <!-- <el-table-column-->
  65. <!-- align="center"-->
  66. <!-- label="自动报表"-->
  67. <!-- prop="isAutoReport"-->
  68. <!-- width="150">-->
  69. <!-- <template slot-scope="scope">-->
  70. <!-- <el-switch v-if="scope.row.isAutoReport == '2'" :value="true" active-color="#13ce66"-->
  71. <!-- disabled></el-switch>-->
  72. <!-- <el-switch v-else :value="scope.row.isAutoReport == '1'" active-color="#13ce66"-->
  73. <!-- @change="switchChangeEvent($event, scope.row)" :disabled="uid != scope.row.userId"></el-switch>-->
  74. <!-- </template>-->
  75. <!-- </el-table-column>-->
  76. <el-table-column
  77. align="center"
  78. label="当前版本"
  79. sortable="custom"
  80. prop="version"
  81. width="120">
  82. </el-table-column>
  83. <el-table-column
  84. align="center"
  85. label="创建时间"
  86. sortable
  87. prop="createTime"
  88. width="200">
  89. </el-table-column>
  90. <!-- <el-table-column label="操作" align="center" width="300">-->
  91. <!-- <template slot-scope="scope">-->
  92. <!-- <el-button type="text"-->
  93. <!-- v-if="uid == scope.row.userId"-->
  94. <!-- size="small"-->
  95. <!-- icon="el-icon-edit"-->
  96. <!-- @click="editReportItem(scope.row)">修改名称</el-button>-->
  97. <!-- <el-button type="text"-->
  98. <!-- v-if="uid == scope.row.userId"-->
  99. <!-- size="small"-->
  100. <!-- icon="el-icon-user"-->
  101. <!-- @click="setUserGroupEvent(scope.row)">授权</el-button>-->
  102. <!-- <el-button type="text"-->
  103. <!-- v-if="uid == scope.row.userId"-->
  104. <!-- size="small"-->
  105. <!-- icon="el-icon-delete"-->
  106. <!-- style="color: red;"-->
  107. <!-- @click="removeReportItem(scope.row)">删除</el-button>-->
  108. <!-- </template>-->
  109. <!-- </el-table-column>-->
  110. </el-table>
  111. <el-empty v-else description="暂无数据"></el-empty>
  112. </div>
  113. <el-pagination
  114. background
  115. @size-change="handleSizeChange"
  116. @current-change="handleCurrentChange"
  117. :current-page="reportPage"
  118. :page-size="reportLimit"
  119. layout="sizes, prev, pager, next, total"
  120. :total="reportTotal">
  121. </el-pagination>
  122. </div>
  123. <div class="cy-main-right" :style="showMainView ? '' : 'display: none;'">
  124. <el-row v-if="btnType == 'add'" style="margin: 10px 20px;">
  125. <el-button type="primary" size="mini" icon="el-icon-document" @click="saveReportInfo">保存报表</el-button>
  126. <el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport">取消</el-button>
  127. </el-row>
  128. <el-row v-if="btnType == 'show'" style="margin: 10px 20px;">
  129. <!-- <el-button type="success" size="mini" icon="el-icon-document-checked" @click="updateReport">保存</el-button>-->
  130. <el-button type="primary" size="mini" icon="el-icon-download" @click="downloadReport">下载</el-button>
  131. <el-button type="warning" size="mini" icon="el-icon-printer" @click="printExcel">打印</el-button>
  132. <el-button type="info" size="mini" icon="el-icon-document" @click="historyReport">运行记录</el-button>
  133. <el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport">关闭</el-button>
  134. </el-row>
  135. <el-row v-if="btnType == 'showShared'" style="margin: 10px 20px;">
  136. <el-button type="primary" size="mini" icon="el-icon-download" @click="downloadReport">下载</el-button>
  137. <el-button type="warning" size="mini" icon="el-icon-printer" @click="printExcel">打印</el-button>
  138. <el-button type="info" size="mini" icon="el-icon-document" @click="historyReport">运行记录</el-button>
  139. <el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport">关闭</el-button>
  140. </el-row>
  141. <el-row v-if="btnType == 'showChild'" style="margin: 10px 20px;">
  142. <el-button type="primary" size="mini" icon="el-icon-download" @click="downloadReport">下载</el-button>
  143. <el-button type="warning" size="mini" icon="el-icon-printer" @click="printExcel">打印</el-button>
  144. <el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport2">关闭</el-button>
  145. </el-row>
  146. <div id="luckysheet"
  147. style="margin:0px;padding:0px;position:relative;height:calc(100% - 50px);width:100%;left: 20px;top: 0px;bottom:0px;">
  148. </div>
  149. </div>
  150. </div>
  151. <!-- 新增报表 -->
  152. <el-dialog
  153. title="新增报表"
  154. width="50%"
  155. top="10vh"
  156. center
  157. v-dialog-drag
  158. v-if="dialogReportTemplateVisible"
  159. :before-close="dialogClose"
  160. :visible.sync="dialogReportTemplateVisible"
  161. :close-on-click-modal="false"
  162. :append-to-body="true">
  163. <el-form ref="reportForm" :model="reportForm" :rules="reportRules" label-width="80px">
  164. <el-form-item label="报表模板" prop="reportTemplate">
  165. <el-select v-model="reportForm.reportTemplate" filterable placeholder="请选择报表模板" style="width: 100%;">
  166. <el-option
  167. v-for="item in reportTemplateList"
  168. :key="item.id"
  169. :label="item.templateName"
  170. :value="item.id">
  171. </el-option>
  172. </el-select>
  173. </el-form-item>
  174. <el-form-item label="取值方式" prop="reportValueFormat">
  175. <el-radio v-model="reportForm.reportValueFormat" label="0">时段数据</el-radio>
  176. </el-form-item>
  177. <el-form-item label="数据时间" prop="reportDate">
  178. <el-date-picker
  179. v-model="reportForm.reportDate" :editable="false" :clearable="false"
  180. style="width: 100%;"
  181. type="datetimerange"
  182. :picker-options="{
  183. format: 'yyyy-MM-dd HH:mm:ss'
  184. }"
  185. value-format="yyyy-MM-dd HH:mm:ss"
  186. range-separator="至"
  187. start-placeholder="开始日期"
  188. end-placeholder="结束日期">
  189. </el-date-picker>
  190. </el-form-item>
  191. <el-form-item style="text-align: center;">
  192. <el-button type="primary" @click="chooseReportEvent" style="margin-top: 20px;">确定</el-button>
  193. <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
  194. </el-form-item>
  195. </el-form>
  196. </el-dialog>
  197. <!-- 用户组选择 -->
  198. <el-dialog
  199. title="选择用户组"
  200. width="840px"
  201. top="10vh"
  202. center
  203. v-dialog-drag
  204. v-if="dialogUserGroupVisible"
  205. :before-close="dialogClose"
  206. :visible.sync="dialogUserGroupVisible"
  207. :close-on-click-modal="false"
  208. :append-to-body="true">
  209. <!-- <el-form label-width="80px">-->
  210. <!-- <el-form-item label="用户组">-->
  211. <!-- <el-select v-model="userGroupInfo" filterable clearable multiple placeholder="请选择用户组" style="width: 100%;">-->
  212. <!-- <el-option-->
  213. <!-- v-for="item in userGroupList"-->
  214. <!-- :key="item.id"-->
  215. <!-- :label="item.userGroupName"-->
  216. <!-- :value="item.id">-->
  217. <!-- </el-option>-->
  218. <!-- </el-select>-->
  219. <!-- </el-form-item>-->
  220. <!-- </el-form>-->
  221. <div class="ug-div">
  222. <el-transfer
  223. v-model="userGroupInfo"
  224. :titles="['用户组列表', '已选择用户组']"
  225. :data="userGroupList"
  226. :props="{
  227. key: 'id',
  228. label: 'userGroupName'
  229. }">
  230. </el-transfer>
  231. </div>
  232. <span slot='footer'>
  233. <el-button type="primary" @click="chooseUserGroupEvent" style="margin-top: 20px;">确定</el-button>
  234. <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
  235. </span>
  236. </el-dialog>
  237. <!-- 自动报表CRON定时表达式 -->
  238. <el-dialog
  239. title="配置定时任务"
  240. width="50%"
  241. top="10vh"
  242. center
  243. v-dialog-drag
  244. v-if="dialogAutoReportVisible"
  245. :before-close="dialogClose"
  246. :visible.sync="dialogAutoReportVisible"
  247. :close-on-click-modal="false"
  248. :append-to-body="true">
  249. <el-form label-width="80px">
  250. <el-radio-group v-model="radioByCron">
  251. <el-form-item label="秒">
  252. <el-radio :label="1">
  253. <span style="margin-right: 10px;">每</span>
  254. <el-input-number size="mini" v-model="radioByCronValS" :min="1" :max="59"></el-input-number>
  255. <span style="margin-left: 10px;">秒执行一次</span>
  256. </el-radio>
  257. </el-form-item>
  258. <el-form-item label="分钟">
  259. <el-radio :label="2">
  260. <span style="margin-right: 10px;">每</span>
  261. <el-input-number size="mini" v-model="radioByCronValM" :min="1" :max="59"></el-input-number>
  262. <span style="margin-left: 10px;">分钟执行一次</span>
  263. </el-radio>
  264. </el-form-item>
  265. <el-form-item label="小时">
  266. <el-radio :label="3">
  267. <span style="margin-right: 10px;">每</span>
  268. <el-input-number size="mini" v-model="radioByCronValH" :min="1" :max="2"></el-input-number>
  269. <span style="margin-left: 10px;">小时执行一次</span>
  270. </el-radio>
  271. </el-form-item>
  272. <el-form-item label="指定时间">
  273. <el-radio :label="4">
  274. <span style="margin-right: 10px;">在每天的</span>
  275. <el-time-picker v-model="radioByCronValD"
  276. size="mini"
  277. placeholder="请选择时间"
  278. :clearable="false"
  279. :editable="false"
  280. value-format="HH:mm:ss"
  281. :picker-options="{
  282. format: 'HH:mm:ss'
  283. }">
  284. </el-time-picker>
  285. <span style="margin-left: 10px;">执行一次</span>
  286. </el-radio>
  287. </el-form-item>
  288. <el-form-item label="">
  289. <el-radio :label="5">
  290. <span style="margin-right: 10px;">在每月</span>
  291. <el-input-number size="mini" v-model="radioByCronValMo" :min="1" :max="31"></el-input-number>
  292. <span style="margin-right: 10px; margin-left: 10px;">号的</span>
  293. <el-time-picker v-model="radioByCronValMoD"
  294. size="mini"
  295. placeholder="请选择时间"
  296. :clearable="false"
  297. :editable="false"
  298. value-format="HH:mm:ss"
  299. :picker-options="{
  300. format: 'HH:mm:ss'
  301. }">
  302. </el-time-picker>
  303. <span style="margin-left: 10px;">执行一次</span>
  304. </el-radio>
  305. </el-form-item>
  306. </el-radio-group>
  307. <!-- <el-form-item label="表达式">-->
  308. <!-- <el-input type="text" placeholder="请输入定时任务表达式" v-model="cronVal" maxlength="50"></el-input>-->
  309. <!-- </el-form-item>-->
  310. <!-- <div>-->
  311. <!-- <label>常用定时任务表达式例子</label>-->
  312. <!-- <ul>-->
  313. <!-- <li v-for="(item, i) in cronList" style="margin-bottom: 5px;">-->
  314. <!-- <span class="cron-txt" @click="cronNodeEvent(item)">{{ item.value }}</span>-->
  315. <!-- <span class="cron-txt-desc">{{ item.label }}</span>-->
  316. <!-- </li>-->
  317. <!-- </ul>-->
  318. <!-- </div>-->
  319. </el-form>
  320. <span slot='footer'>
  321. <el-button type="primary" @click="chooseCronEvent">确定</el-button>
  322. <el-button @click="dialogClose">取消</el-button>
  323. </span>
  324. </el-dialog>
  325. <!-- 报表下载类型选择 -->
  326. <el-dialog
  327. title="选择下载类型"
  328. width="500px"
  329. center
  330. v-dialog-drag
  331. v-if="dialogDownloadReportTypeVisible"
  332. :before-close="dialogClose"
  333. :visible.sync="dialogDownloadReportTypeVisible"
  334. :close-on-click-modal="false"
  335. :append-to-body="true">
  336. <div style="text-align: center;">
  337. <el-radio v-model="downloadType" label="1">Excel</el-radio>
  338. <!-- <el-radio v-model="downloadType" label="2" disabled>PDF</el-radio>-->
  339. </div>
  340. <div style="text-align: center; margin-top: 40px;">
  341. <el-button type="primary" @click="downloadReportEvent">确定</el-button>
  342. </div>
  343. </el-dialog>
  344. <!-- 历史报表查看 -->
  345. <el-dialog
  346. title="运行报表记录"
  347. width="80%"
  348. top="10vh"
  349. center
  350. v-dialog-drag
  351. v-if="dialogHistoryReportVisible"
  352. :before-close="dialogClose"
  353. :visible.sync="dialogHistoryReportVisible"
  354. :close-on-click-modal="false"
  355. :append-to-body="true">
  356. <div style="height: 60vh;">
  357. <el-table
  358. :data="reportHistoryData" border :stripe="true"
  359. :header-cell-style="{background: '#E8E8E8'}"
  360. @sort-change="sortChange1"
  361. style="width: 100%; height: calc(100% - 50px); overflow: auto;">
  362. <el-table-column
  363. align="center"
  364. sortable="custom"
  365. label="报表名称"
  366. prop="reportTableName">
  367. <template slot-scope="scope">
  368. <span style="color: #409EFF; cursor: pointer;"
  369. @click="handleReportNodeClick(scope.row, 'history')"
  370. :title="scope.row.reportTableName">{{ scope.row.reportTableName }}</span>
  371. </template>
  372. </el-table-column>
  373. <!-- <el-table-column-->
  374. <!-- align="center"-->
  375. <!-- label="报表状态"-->
  376. <!-- prop="isAutoReport"-->
  377. <!-- width="180">-->
  378. <!-- <template slot-scope="scope">-->
  379. <!-- <el-tag v-if="scope.row.userId != uid" type="success" style="margin-right: 5px;">被分享</el-tag>-->
  380. <!-- <el-tag v-if="uid == scope.row.userId && scope.row.userGroupList && scope.row.userGroupList.length > 0"-->
  381. <!-- type="warning" style="margin-right: 5px;">已分享</el-tag>-->
  382. <!-- </template>-->
  383. <!-- </el-table-column>-->
  384. <el-table-column
  385. align="center"
  386. label="当前版本"
  387. sortable="custom"
  388. prop="version"
  389. width="120">
  390. </el-table-column>
  391. <el-table-column
  392. align="center"
  393. label="运行时间"
  394. sortable
  395. prop="createTime"
  396. width="200">
  397. </el-table-column>
  398. <!-- <el-table-column label="操作" align="center" width="300">-->
  399. <!-- <template slot-scope="scope">-->
  400. <!-- <el-button type="text"-->
  401. <!-- v-if="uid == scope.row.userId"-->
  402. <!-- size="small"-->
  403. <!-- icon="el-icon-delete"-->
  404. <!-- style="color: red;"-->
  405. <!-- @click="removeReportItem(scope.row, 'record')">删除</el-button>-->
  406. <!-- </template>-->
  407. <!-- </el-table-column>-->
  408. </el-table>
  409. <el-pagination
  410. style="margin-top: 20px;"
  411. background
  412. layout="sizes, prev, pager, next, total"
  413. :current-page="reportHistoryPage"
  414. :page-size="reportHistoryLimit"
  415. @size-change="sizeHistoryChangeEvent"
  416. @current-change="currentHistoryChangeEvent"
  417. :total="reportHistoryTotal">
  418. </el-pagination>
  419. </div>
  420. </el-dialog>
  421. <div id="print-area" style="display: none;position: absolute;z-index: 0;top: 0;width: 100%;height: 100vh;overflow: hidden;">
  422. <div id="print-html" ref="printPayFeeNew"></div>
  423. </div>
  424. </div>
  425. </template>
  426. <script>
  427. import BreadcrumbView from '@/components/BreadcrumbView'
  428. import {customCompare, getNowFormatDate, showAlertWin, showLoading} from '@/utils/cqcy'
  429. import {
  430. delReportTableById,
  431. getAllDataModel, getAllOkReportTable,
  432. getAllTableTemplate, getAutoChReportTable, getChartData,
  433. getDataModelById, getReportTableById, getTableData,
  434. getTableTemplateById, saveReport, tableAssignUserById, tableExchangeTypeById, updateReportTable, updateTableNameById
  435. } from '@/api/datasource'
  436. import Print from 'print-js'
  437. import {getUsername} from '@/utils/auth'
  438. import {exportExcel} from '@/utils/export'
  439. import {getAllUserGroup} from "@/api/user";
  440. import {mapGetters} from "vuex";
  441. import {insertLuckysheetEChart} from "@/utils/luckysheettool";
  442. export default {
  443. name: "index",
  444. components: {
  445. BreadcrumbView
  446. },
  447. computed: {
  448. ...mapGetters([
  449. 'name',
  450. 'uid'
  451. ])
  452. },
  453. data() {
  454. return {
  455. breadcrumbList: ['我的报表'],
  456. groupProps: {
  457. isLeaf: 'leaf'
  458. },
  459. showMainView: false,
  460. chooseMyReport: null,
  461. dialogReportTemplateVisible: false,
  462. dialogDownloadReportTypeVisible: false,
  463. dialogAutoReportVisible: false,
  464. dialogUserGroupVisible: false,
  465. dialogHistoryReportVisible: false,
  466. downloadType: '1',
  467. btnType: '',
  468. hasUserGroup: false,
  469. userGroupInfo: null,
  470. userGroupList: [],
  471. radioByCron: null,
  472. radioByCronValS: '',
  473. radioByCronValM: '',
  474. radioByCronValH: '',
  475. radioByCronValD: null,
  476. radioByCronValMo: '',
  477. radioByCronValMoD: null,
  478. cronVal: '',
  479. cronList: [],
  480. reportId: null,
  481. reportTemplateList: [],
  482. dataModelList: [],
  483. chooseReportTemplate: null,
  484. chooseReportTemplateId: null,
  485. delFlag: 0,
  486. reportForm: {
  487. reportTemplate: null,
  488. reportValueFormat: '0',
  489. reportDate: [getNowFormatDate('yyyy-MM-dd') + ' 09:00:00',
  490. getNowFormatDate('yyyy-MM-dd') + ' 18:00:00']
  491. },
  492. searchValue: null,
  493. searchTxt: '',
  494. reportOptions: [{
  495. label: '所有报表',
  496. value: -1
  497. }, {
  498. label: '手动报表',
  499. value: 0
  500. }, {
  501. label: '自动报表',
  502. value: 1
  503. }, {
  504. label: '事件驱动报表',
  505. value: 3
  506. }],
  507. reportHistoryData: [],
  508. reportHistoryTotal: 0,
  509. reportHistoryPage: 1,
  510. reportHistoryLimit: 10,
  511. reportTotal: 0,
  512. reportPage: 1,
  513. reportLimit: 10,
  514. reportDataList: [],
  515. reportRules: {
  516. reportTemplate: [
  517. {required: true, message: '请选择报表模板', trigger: 'change'}
  518. ],
  519. reportValueFormat: [
  520. {required: true, message: '请选择取值方式', trigger: 'change'}
  521. ],
  522. reportDate: [
  523. {required: true, message: '请选择数据时间'}
  524. ]
  525. },
  526. luckysheetOption: {
  527. container: 'luckysheet', // 设定 DOM 容器的 id
  528. title: '报表模板', // 设定表格名称
  529. lang: 'zh', // 设定表格语言
  530. showinfobar: false, // 是否显示顶部信息栏
  531. showtoolbar: false, // 是否显示工具栏
  532. showtoolbarConfig: {
  533. paintFormat: true, //格式刷
  534. moreFormats: true, // 单元格格式
  535. font: true, // 字体
  536. fontSize: true, // 字号大小
  537. bold: true, // 粗体 (Ctrl+B)
  538. italic: true, // 斜体 (Ctrl+I)
  539. strikethrough: true, // 删除线 (Alt+Shift+5)
  540. underline: true, // 下划线 (Alt+Shift+6)
  541. textColor: true, // 文本颜色
  542. fillColor: true, // 单元格颜色
  543. border: true, // 边框
  544. mergeCell: true, // 合并单元格
  545. horizontalAlignMode: true, // 水平对齐方式
  546. verticalAlignMode: true, // 垂直对齐方式
  547. function: true, // 公式
  548. // image: true
  549. // chart: true
  550. },
  551. showsheetbar: false, // 是否显示底部 sheet 页按钮
  552. sheetFormulaBar: false, // 是否显示公式
  553. row: 100, // 是否显示底部 sheet 页按钮
  554. data: [{
  555. "name": "统计报表", //工作表名称
  556. }],
  557. cellRightClickConfig: { // 自定义配置单元格右击菜单
  558. copy: true, // 复制
  559. copyAs: false, // 复制为
  560. paste: true, // 粘贴
  561. insertRow: true, // 插入行
  562. insertColumn: true, // 插入列
  563. deleteRow: true, // 删除选中行
  564. deleteColumn: true, // 删除选中列
  565. deleteCell: false, // 删除单元格
  566. hideRow: false, // 隐藏选中行和显示选中行
  567. hideColumn: false, // 隐藏选中列和显示选中列
  568. rowHeight: true, // 行高
  569. columnWidth: true, // 列宽
  570. clear: false, // 清除内容
  571. matrix: false, // 矩阵操作选区
  572. sort: false, // 排序选区
  573. filter: false, // 筛选选区
  574. chart: true, // 图表生成
  575. image: false, // 插入图片
  576. link: false, // 插入链接
  577. data: false, // 数据验证
  578. cellFormat: false // 设置单元格格式
  579. },
  580. plugins: ['chart']
  581. }
  582. }
  583. },
  584. watch: {},
  585. beforeDestroy() {
  586. this.chooseMyReport = null
  587. },
  588. created() {
  589. luckysheet.destroy()
  590. this.loadReport()
  591. this.initCronList()
  592. },
  593. methods: {
  594. sortChange({ prop, order }) {
  595. this.reportDataList.sort(customCompare(prop, order))
  596. },
  597. sortChange1({ prop, order }) {
  598. this.reportHistoryData.sort(customCompare(prop, order))
  599. },
  600. handleSizeChange(val) {
  601. this.reportPage = 1
  602. this.reportLimit = val
  603. this.loadReport()
  604. },
  605. handleCurrentChange(val) {
  606. this.reportPage = val
  607. this.loadReport()
  608. },
  609. sizeHistoryChangeEvent(val) {
  610. this.reportHistoryPage = 1
  611. this.reportHistoryLimit = val
  612. this.historyReport()
  613. },
  614. currentHistoryChangeEvent(val) {
  615. this.reportHistoryPage = val
  616. this.historyReport()
  617. },
  618. changeReportTypeEvent(val) {
  619. this.reportPage = 1
  620. this.searchValue = val
  621. this.loadReport()
  622. },
  623. searchReportEvent() {
  624. this.reportPage = 1
  625. this.loadReport()
  626. },
  627. validCron(value) {
  628. const cronParse = require('cron-parser')
  629. try {
  630. const interval = cronParse.parseExpression(value)
  631. console.log('cronDate:', interval.next().toDate())
  632. return true
  633. } catch (e) {
  634. }
  635. return false
  636. },
  637. analysisCron() {
  638. if (!this.cronVal) return
  639. let s = this.cronVal.split(' ')
  640. if (s[0].indexOf('/') > -1) {
  641. this.radioByCron = 1
  642. this.radioByCronValS = s[0].split('/')[1]
  643. } else if (s[1].indexOf('/') > -1) {
  644. this.radioByCron = 2
  645. this.radioByCronValM = s[1].split('/')[1]
  646. } else if (s[2].indexOf('/') > -1) {
  647. this.radioByCron = 3
  648. this.radioByCronValH = s[2].split('/')[1]
  649. } else if (s[3] === '*') {
  650. this.radioByCron = 4
  651. this.radioByCronValD = s[2] + ':' + s[1] + ':' + s[0]
  652. } else {
  653. this.radioByCron = 5
  654. this.radioByCronValMo = s[3]
  655. this.radioByCronValMoD = s[2] + ':' + s[1] + ':' + s[0]
  656. }
  657. },
  658. getCron() {
  659. let result = null
  660. switch (this.radioByCron) {
  661. // 按每秒执行:0/2 * * * * ?
  662. case 1:
  663. if (Number.isInteger(this.radioByCronValS)) {
  664. result = '0/#{cron} * * * * ?'
  665. result = result.replace('#{cron}', this.radioByCronValS)
  666. }
  667. break
  668. // 按每分钟执行:0 0/2 * * * ?
  669. case 2:
  670. if (Number.isInteger(this.radioByCronValM)) {
  671. result = '0 0/#{cron} * * * ?'
  672. result = result.replace('#{cron}', this.radioByCronValM)
  673. }
  674. break
  675. // 按每小时执行:0 0 0/2 * * ?
  676. case 3:
  677. if (Number.isInteger(this.radioByCronValH)) {
  678. result = '0 0 0/#{cron} * * ?'
  679. result = result.replace('#{cron}', this.radioByCronValH)
  680. }
  681. break
  682. // 每天定时执行:0 15 10 * * ?
  683. case 4:
  684. if (this.radioByCronValD) {
  685. let times = this.radioByCronValD.split(':')
  686. result = '#{cron1} #{cron2} #{cron3} * * ?'
  687. result = result.replace('#{cron1}', times[2])
  688. result = result.replace('#{cron2}', times[1])
  689. result = result.replace('#{cron3}', times[0])
  690. result = result.replace(/00/g, '0')
  691. }
  692. break
  693. // 每月定时执行:0 0 2 1 * ?
  694. case 5:
  695. if (Number.isInteger(this.radioByCronValMo) && this.radioByCronValMoD) {
  696. let times = this.radioByCronValMoD.split(':')
  697. result = '#{cron1} #{cron2} #{cron3} #{cron4} * ?'
  698. result = result.replace('#{cron1}', times[2])
  699. result = result.replace('#{cron2}', times[1])
  700. result = result.replace('#{cron3}', times[0])
  701. result = result.replace('#{cron4}', this.radioByCronValMo)
  702. result = result.replace(/00/g, '0')
  703. }
  704. break
  705. default:
  706. break
  707. }
  708. return result
  709. },
  710. chooseCronEvent() {
  711. this.cronVal = this.getCron()
  712. if (!this.cronVal) {
  713. this.$message({
  714. message: '请指定定时任务类型或运行时间!',
  715. type: 'warning'
  716. })
  717. return
  718. }
  719. if (!this.validCron(this.cronVal)) {
  720. this.$message({
  721. message: '定时任务表达式格式不正确,请检查!',
  722. type: 'warning'
  723. })
  724. return
  725. }
  726. const loading = showLoading(this, '请稍候···')
  727. let params = {
  728. 'id': this.reportId,
  729. 'isAutoReport': '1',
  730. 'cron': this.cronVal
  731. }
  732. tableExchangeTypeById(params).then(res => {
  733. loading.close()
  734. this.dialogClose()
  735. this.loadReport()
  736. }).catch((e) => {
  737. loading.close()
  738. showAlertWin(this, e)
  739. })
  740. },
  741. resetRadioVal() {
  742. this.radioByCron = null
  743. this.radioByCronValS = ''
  744. this.radioByCronValM = ''
  745. this.radioByCronValH = ''
  746. this.radioByCronValD = null
  747. this.radioByCronValMo = ''
  748. this.radioByCronValMoD = null
  749. this.cronVal = ''
  750. },
  751. switchChangeEvent(val, data) {
  752. if (val) {
  753. this.resetRadioVal()
  754. this.dialogAutoReportVisible = true
  755. this.reportId = data.id
  756. getReportTableById(data.id).then(res => {
  757. this.cronVal = res.data.cron
  758. this.analysisCron()
  759. }).catch((e) => {
  760. showAlertWin(this, e)
  761. })
  762. return
  763. }
  764. const loading = showLoading(this, '请稍候···')
  765. let params = {
  766. 'id': data.id,
  767. 'isAutoReport': '0'
  768. }
  769. tableExchangeTypeById(params).then(res => {
  770. loading.close()
  771. this.loadReport()
  772. }).catch((e) => {
  773. loading.close()
  774. showAlertWin(this, e)
  775. })
  776. },
  777. /** 新增报表 */
  778. addReportEvent() {
  779. this.getAllReportTemplate()
  780. this.dialogReportTemplateVisible = true
  781. },
  782. /** 刷新报表 */
  783. refreshReportEvent() {
  784. this.reportPage = 1
  785. this.loadReport()
  786. },
  787. /** 模版报表选择 */
  788. chooseReportEvent() {
  789. this.$refs['reportForm'].validate((valid) => {
  790. if (valid) {
  791. const loading = showLoading(this, '数据加载中,请稍候···')
  792. getTableTemplateById(this.reportForm.reportTemplate).then(res => {
  793. if (!res.data) {
  794. loading.close()
  795. this.$message({
  796. message: '选择的报表模板不存在!',
  797. type: 'warning'
  798. })
  799. return
  800. }
  801. this.showMainView = true
  802. let luckyData = JSON.parse(res.data.templateData)
  803. this.chooseReportTemplateId = res.data.id
  804. this.chooseReportTemplate = luckyData
  805. this.drawLuckyExcel(luckyData, () => {
  806. loading.close()
  807. this.btnType = 'add'
  808. this.$refs.reportForm.resetFields()
  809. this.dialogReportTemplateVisible = false
  810. this.breadcrumbList = ['新增报表']
  811. })
  812. }).catch((e) => {
  813. loading.close()
  814. showAlertWin(this, e)
  815. })
  816. }
  817. })
  818. },
  819. /** 根据 ID 查询数据模型 */
  820. getDataModelById(loading, reportData) {
  821. if (!loading) {
  822. loading = showLoading(this, '数据加载中,请稍候···')
  823. }
  824. getDataModelById(this.reportForm.operationRule).then(res => {
  825. loading.close()
  826. if (!res.data) {
  827. this.$message({
  828. message: '选择的四则运算表达式不存在!',
  829. type: 'warning'
  830. })
  831. return
  832. }
  833. let luckyData = JSON.parse(reportData.templateData)
  834. this.drawLuckyExcel(luckyData)
  835. this.btnType = 'add'
  836. this.dialogReportTemplateVisible = false
  837. }).catch((e) => {
  838. loading.close()
  839. showAlertWin(this, e)
  840. })
  841. },
  842. /** 绘制 Excel 表 */
  843. drawLuckyExcel(luckyData, callback) {
  844. let _this = this
  845. luckysheet.destroy()
  846. let option = luckyData.option
  847. option.data = luckyData.data
  848. let charts = luckyData.charts
  849. let tables = luckyData.tables
  850. option.hook = {
  851. workbookCreateAfter() {
  852. for (let i in charts) {
  853. _this.insertEChartInfo(charts[i])
  854. }
  855. for (let i in tables) {
  856. _this.insertTableInfo(tables[i])
  857. }
  858. _this.drawBaseInfo()
  859. if (callback) {
  860. callback()
  861. }
  862. }
  863. }
  864. luckysheet.create(option)
  865. },
  866. /** 获取图表数据 */
  867. getChartData(data, callback) {
  868. getChartData(data).then(res => {
  869. if (!res.data) {
  870. if (callback) callback([])
  871. return
  872. }
  873. if (callback) callback(res.data)
  874. }).catch((e) => {
  875. if (callback) callback([])
  876. showAlertWin(this, e)
  877. })
  878. },
  879. /** 获取表格数据 */
  880. getTableData(data, callback) {
  881. getTableData(data).then(res => {
  882. if (!res.data) {
  883. if (callback) callback([])
  884. return
  885. }
  886. if (callback) callback(res.data)
  887. }).catch((e) => {
  888. if (callback) callback([])
  889. showAlertWin(this, e)
  890. })
  891. },
  892. /** 向 Excel 插入表格 */
  893. insertTableInfo(tableData) {
  894. let params = []
  895. let itemList = tableData.item
  896. for (let i in itemList) {
  897. let temp = itemList[i]
  898. params.push({
  899. 'itemGroupId': temp.itemGroupId,
  900. 'itemName': temp.itemName
  901. })
  902. }
  903. let p = {
  904. 'reportValueFormat': this.reportForm.reportValueFormat,
  905. 'tableDataDtoChList': params,
  906. 'showType': tableData.showType
  907. }
  908. if (this.reportForm.reportDate && this.reportForm.reportDate.length > 0) {
  909. p.startBelongTime = this.reportForm.reportDate[0]
  910. p.endBelongTime = this.reportForm.reportDate[1]
  911. } else {
  912. p.startBelongTime = getNowFormatDate('yyyy-MM-dd') + ' 08:00:00'
  913. p.endBelongTime = getNowFormatDate('yyyy-MM-dd') + ' 18:00:00'
  914. }
  915. this.getTableData(p, (res) => {
  916. // console.log('option==>', luckysheet.getAllSheets()[0])
  917. // console.log('table1==>', res)
  918. // const optionData = packtable(res, luckysheet.getAllSheets()[0])
  919. // console.log('table2==>', optionData)
  920. setTimeout(() => {
  921. this.drawTableData(res, p.showType, luckysheet.getAllSheets()[0])
  922. }, 500)
  923. })
  924. },
  925. drawBaseInfo() {
  926. let currDate = getNowFormatDate('yyyy-MM-dd')
  927. let currDateTime = getNowFormatDate('yyyy-MM-dd HH:mm:ss')
  928. let option = luckysheet.getAllSheets()[0]
  929. option.celldata.map(item => {
  930. if (item.v.v) {
  931. item.v.v = String(item.v.v).trim();
  932. if (item.v.v.match(/\${([^}]+)}/g)) { // 替换${xxx}内部数据
  933. if (item.v.v.indexOf('${currDate}') > -1) {
  934. let val = item.v.v
  935. val = val.replace('${currDate}', currDate)
  936. luckysheet.setCellValue(item.r, item.c, val)
  937. }
  938. if (item.v.v.indexOf('${currDateTime}') > -1) {
  939. let val = item.v.v
  940. val = val.replace('${currDateTime}', currDateTime)
  941. luckysheet.setCellValue(item.r, item.c, val)
  942. }
  943. if (item.v.v.indexOf('${userName}') > -1) {
  944. let val = item.v.v
  945. val = val.replace('${userName}', getUsername())
  946. luckysheet.setCellValue(item.r, item.c, val)
  947. }
  948. if (item.v.v.indexOf('${winUserName}') > -1) {
  949. let val = item.v.v
  950. val = val.replace('${winUserName}', process.env.VUE_APP_WINNAME)
  951. luckysheet.setCellValue(item.r, item.c, val)
  952. }
  953. }
  954. }
  955. })
  956. },
  957. drawTableData(sources, type, option) {
  958. option.celldata.map(item => {
  959. if (item.v.v) {
  960. item.v.v = String(item.v.v).trim();
  961. if (item.v.v.match(/\${([^}]+)}/g)) { // 替换${xxx}内部数据
  962. sources.forEach(source => {
  963. let itemName = source.itemName
  964. itemName = itemName.substring(itemName.lastIndexOf('.') + 1)
  965. let name = '${' + source.itemGroupId + '.' + itemName + '.' + type.dataId + '}'
  966. if (item.v.v === name) {
  967. let dataList = source.dataList
  968. // for (let i = 0; i < dataList.length; i++) {
  969. for (let i = 0; i < type.valLine; i++) {
  970. let p_r = parseInt(item.r)
  971. let p_c = parseInt(item.c)
  972. if (type.valType == '2') p_r += i
  973. else p_c += i
  974. luckysheet.setCellValue(p_r, p_c, (dataList[i] != null && dataList[i] != undefined) ? dataList[i] : '')
  975. }
  976. }
  977. })
  978. }
  979. }
  980. })
  981. },
  982. /** 向 Excel 插入图表 */
  983. insertEChartInfo(chart) {
  984. let _self = this
  985. console.log(chart)
  986. let info = chart.info
  987. let itemList = chart.item
  988. let itemArr = []
  989. for (let i in itemList) {
  990. let temp = itemList[i]
  991. itemArr.push({
  992. 'itemGroupId': temp.itemGroupId,
  993. 'id': temp.id,
  994. 'itemName': temp.itemName
  995. })
  996. }
  997. let params = {
  998. 'type': info.option.series[0].type,
  999. 'chartTimeType': this.reportForm.reportValueFormat,
  1000. 'tableDataDtoChList': itemArr
  1001. }
  1002. if (this.reportForm.reportDate && this.reportForm.reportDate.length > 0) {
  1003. params.startBelongTime = this.reportForm.reportDate[0]
  1004. params.endBelongTime = this.reportForm.reportDate[1]
  1005. } else {
  1006. params.startBelongTime = getNowFormatDate('yyyy-MM-dd') + ' 08:00:00'
  1007. params.endBelongTime = getNowFormatDate('yyyy-MM-dd') + ' 18:00:00'
  1008. }
  1009. this.getChartData(params, (res) => {
  1010. let result = (res instanceof Array) ? res : []
  1011. // 系列
  1012. let series = info.option.series
  1013. for (let i in series) {
  1014. let temp = series[i]
  1015. temp.data = []
  1016. for (let j in result) {
  1017. if (params.type == 'pie') {
  1018. temp.name = result[j].name
  1019. temp.data.push({
  1020. 'name': result[j].describe ? result[j].describe : result[j].name,
  1021. 'value': result[j].value
  1022. })
  1023. } else {
  1024. temp.data = result[i].dataList ? result[i].dataList : []
  1025. }
  1026. }
  1027. }
  1028. if (params.type != 'pie') {
  1029. // x 轴
  1030. let xAxis = info.option.xAxis
  1031. let legend = info.option.legend
  1032. xAxis.data = []
  1033. legend.data = []
  1034. for (let i in result) {
  1035. let name = result[i].describe ? result[i].describe : result[i].itemName
  1036. xAxis.data.push(name)
  1037. legend.data.push(name)
  1038. }
  1039. }
  1040. console.log(params.type, info)
  1041. setTimeout(() => {
  1042. const sheet = luckysheet.getLuckysheetfile()[0]
  1043. let optionData = sheet.data
  1044. try {
  1045. let flag = true
  1046. insertLuckysheetEChart({
  1047. selector: '#luckysheet',
  1048. info,
  1049. sheet,
  1050. optionData,
  1051. echarts,
  1052. luckysheet,
  1053. $,
  1054. _self,
  1055. flag
  1056. })
  1057. } catch (e) {
  1058. console.log(999, e == 'echarts is not defined')
  1059. console.error(e)
  1060. }
  1061. }, 200)
  1062. })
  1063. },
  1064. /** 查询所有报表信息 */
  1065. getAllReportTemplate() {
  1066. const loading = showLoading(this, '数据加载中,请稍候···')
  1067. let params = {
  1068. 'page': 1,
  1069. 'limit': 1000
  1070. }
  1071. getAllTableTemplate(params).then(res => {
  1072. loading.close()
  1073. if (!res.data) {
  1074. return
  1075. }
  1076. this.reportTemplateList = res.data.tableTemplateList
  1077. }).catch((e) => {
  1078. loading.close()
  1079. showAlertWin(this, e)
  1080. })
  1081. },
  1082. /** 查询所有数据模型 */
  1083. getAllDataModel() {
  1084. let params = {
  1085. 'page': 1,
  1086. 'limit': 1000
  1087. }
  1088. getAllDataModel(params).then(res => {
  1089. if (!res.data) {
  1090. return
  1091. }
  1092. this.dataModelList = res.data.dataModelList
  1093. }).catch((e) => {
  1094. showAlertWin(this, e)
  1095. })
  1096. },
  1097. /** 查询我的报表列表 */
  1098. loadReport() {
  1099. const loading = showLoading(this, '加载中,请稍候···')
  1100. let params = {
  1101. 'page': this.reportPage,
  1102. 'limit': this.reportLimit
  1103. }
  1104. if (this.searchValue != '-1') {
  1105. params.isAutoReport = this.searchValue
  1106. }
  1107. if (this.searchTxt && this.searchTxt.trim()) {
  1108. params.reportTableName = this.searchTxt
  1109. }
  1110. // getAllReportTable(params).then(res => {
  1111. getAllOkReportTable(params).then(res => {
  1112. loading.close()
  1113. if (!res || !res.data) {
  1114. return
  1115. }
  1116. this.reportTotal = res.data.count
  1117. this.reportDataList = res.data.reportTableList
  1118. }).catch((e) => {
  1119. loading.close()
  1120. showAlertWin(this, e)
  1121. })
  1122. },
  1123. /** 设置用户组信息 */
  1124. setUserGroupEvent(data) {
  1125. if (data.userId != this.uid) {
  1126. this.$message({
  1127. message: '您没有权限进行设置!',
  1128. type: 'warning'
  1129. })
  1130. return
  1131. }
  1132. this.reportId = data.id
  1133. this.dialogUserGroupVisible = true
  1134. getAllUserGroup().then(res => {
  1135. this.$nextTick(() => {
  1136. this.userGroupList = res.data
  1137. // this.userGroupInfo = data.userGroupList
  1138. this.userGroupInfo = []
  1139. for (let i = 0; i < data.userGroupList.length; i++) {
  1140. this.userGroupInfo.push(data.userGroupList[i].id)
  1141. }
  1142. if (data.userGroupList && data.userGroupList.length > 0) {
  1143. this.hasUserGroup = true
  1144. }
  1145. })
  1146. }).catch((e) => {
  1147. showAlertWin(this, e)
  1148. })
  1149. },
  1150. chooseUserGroupEvent() {
  1151. // if (!this.userGroupInfo) {
  1152. // this.$message({
  1153. // message: '请选择用户组!',
  1154. // type: 'warning'
  1155. // })
  1156. // return
  1157. // }
  1158. let params = {
  1159. 'id': this.reportId,
  1160. 'userGroupList': []
  1161. }
  1162. for (let i = 0; i < this.userGroupInfo.length; i ++) {
  1163. params.userGroupList.push({
  1164. 'id': this.userGroupInfo[i]
  1165. })
  1166. }
  1167. tableAssignUserById(params).then(res => {
  1168. if (this.hasUserGroup || this.userGroupInfo) {
  1169. this.$message({
  1170. message: '保存成功!',
  1171. type: 'success'
  1172. })
  1173. this.hasUserGroup = false
  1174. }
  1175. this.dialogClose()
  1176. this.loadReport()
  1177. }).catch((e) => {
  1178. showAlertWin(this, e)
  1179. })
  1180. },
  1181. /** 处理自动报表数据信息 */
  1182. drawAutoReportData(datas) {
  1183. if (!datas || datas.length == 0) {
  1184. return
  1185. }
  1186. datas.forEach((data) => {
  1187. if (!data || !data.item) {
  1188. return
  1189. }
  1190. let showInfo = data.showType
  1191. let fieldList = data.field
  1192. data.item.forEach((item, i) => {
  1193. if (!item || !item.dataList) {
  1194. return
  1195. }
  1196. let itemName = item.itemName
  1197. itemName = itemName.substring(itemName.lastIndexOf('.') + 1)
  1198. let tempName = '${' + item.itemGroupId + '.' + itemName + '.' + showInfo.dataId + '}'
  1199. let p_r, p_c
  1200. if (fieldList[i] && tempName == fieldList[i].name) {
  1201. p_r = parseInt(fieldList[i].r)
  1202. p_c = parseInt(fieldList[i].c)
  1203. } else {
  1204. for (let n = 0; n < fieldList.length; n ++) {
  1205. if (fieldList[n].name == tempName) {
  1206. p_r = parseInt(fieldList[n].r)
  1207. p_c = parseInt(fieldList[n].c)
  1208. break
  1209. }
  1210. }
  1211. }
  1212. // 数据信息
  1213. let dataList = item.dataList
  1214. for (let j = 0; j < showInfo.valLine; j++) {
  1215. let c = p_c
  1216. let r = p_r
  1217. if (showInfo.valType == '2') r += j
  1218. else c += j
  1219. luckysheet.setCellValue(r, c, (dataList[j] != null && dataList[j] != undefined) ? (dataList[j] + '') : '')
  1220. }
  1221. })
  1222. })
  1223. },
  1224. /** 报表点击事件 */
  1225. handleReportNodeClick(data, type) {
  1226. if (data.id == -1 || this.delFlag == 1) {
  1227. return
  1228. }
  1229. const loading = showLoading(this, '加载中,请稍候···')
  1230. getReportTableById(data.id).then(res => {
  1231. loading.close()
  1232. if (!res.data) {
  1233. this.$message({
  1234. message: '选择的报表不存在!',
  1235. type: 'warning'
  1236. })
  1237. return
  1238. }
  1239. this.showMainView = true
  1240. this.breadcrumbList = [res.data.reportTableName]
  1241. let reportTableData = res.data.reportTableData
  1242. let luckyData = JSON.parse(reportTableData)
  1243. console.log(luckyData)
  1244. // 只读
  1245. if (type === 'history') {
  1246. this.dialogHistoryReportVisible = false
  1247. this.btnType = 'showChild'
  1248. } else if (type === 'deny') {
  1249. this.chooseMyReport = res.data
  1250. this.dialogHistoryReportVisible = false
  1251. this.btnType = 'showShared'
  1252. } else {
  1253. this.chooseMyReport = res.data
  1254. this.btnType = 'show'
  1255. }
  1256. this.setLuckysheetStatus(luckyData, true, type)
  1257. }).catch((e) => {
  1258. loading.close()
  1259. showAlertWin(this, e)
  1260. })
  1261. },
  1262. /** 设置工作表状态 */
  1263. setLuckysheetStatus(luckyData, isReadOnly, type) {
  1264. let _this = this
  1265. luckysheet.destroy()
  1266. let option = luckyData.option
  1267. if (!option) option = JSON.parse(JSON.stringify(this.luckysheetOption))
  1268. option.data = luckyData.data
  1269. if (isReadOnly) {
  1270. // 设置工作表保护
  1271. option.data[0].config.authority = {
  1272. sheet: 1, // 如果为 1 或 true,则该工作表受到保护;如果为 0 或 false,则该工作表不受保护。
  1273. hintText: '该工作表受到保护,无法操作', // 弹窗提示的文字
  1274. }
  1275. // 关闭右键菜单
  1276. option.cellRightClickConfig.chart = false
  1277. option.cellRightClickConfig.columnWidth = false
  1278. option.cellRightClickConfig.rowHeight = false
  1279. option.cellRightClickConfig.deleteColumn = false
  1280. option.cellRightClickConfig.deleteRow = false
  1281. option.cellRightClickConfig.insertColumn = false
  1282. option.cellRightClickConfig.insertRow = false
  1283. // 关闭工具栏
  1284. option.showtoolbar = false
  1285. option.enableAddRow = false
  1286. option.showtoolbarConfig = {
  1287. bold: false,
  1288. border: false,
  1289. fillColor: false,
  1290. font: false,
  1291. fontSize: false,
  1292. function: false,
  1293. horizontalAlignMode: false,
  1294. italic: false,
  1295. mergeCell: false,
  1296. moreFormats: false,
  1297. paintFormat: false,
  1298. strikethrough: false,
  1299. textColor: false,
  1300. underline: false,
  1301. verticalAlignMode: false
  1302. }
  1303. }
  1304. // 钩子函数
  1305. option.hook = {
  1306. workbookCreateAfter() {
  1307. let charts = luckyData.charts
  1308. let tables = luckyData.tables
  1309. let eventTables = luckyData.eventTables
  1310. option.data.forEach((data, i) => {
  1311. if (data.chart && data.chart.length > 0) {
  1312. data.chart.forEach((chart, j) => {
  1313. console.log(chart.chart_id)
  1314. let dom = document.getElementById(chart.chart_id + '_c')
  1315. if (dom) dom.style.display = 'none'
  1316. })
  1317. }
  1318. })
  1319. if (type == '' || type == 'deny') {
  1320. for (let i in charts) {
  1321. _this.insertEChartInfo(charts[i])
  1322. }
  1323. for (let i in tables) {
  1324. _this.insertTableInfo(tables[i])
  1325. }
  1326. _this.drawBaseInfo()
  1327. }
  1328. _this.drawAutoReportData(tables)
  1329. // 事件驱动报表信息
  1330. _this.drawEventReportData(eventTables)
  1331. luckysheet.setRangeShow('BH1')
  1332. }
  1333. }
  1334. luckysheet.create(option)
  1335. },
  1336. /** 绘制事件驱动报表信息 */
  1337. drawEventReportData(eventTables) {
  1338. if (!eventTables || eventTables.length == 0) {
  1339. return
  1340. }
  1341. let x = 0, y = 0
  1342. eventTables.forEach((data, i) => {
  1343. x += 1
  1344. y = 0
  1345. let { dataList, dataTimeList, itemName } = data
  1346. itemName = (itemName != null && itemName != undefined) ? itemName : ''
  1347. luckysheet.setCellValue(x, y, itemName)
  1348. dataList.forEach((val, j) => {
  1349. y = j + 1
  1350. let _date = luckysheet.getCellValue(0, y)
  1351. if (!_date) {
  1352. let text = (dataTimeList[j] != null && dataTimeList[j] != undefined) ? dataTimeList[j] : ''
  1353. if (text.length > 19) text = text.substring(0, 19)
  1354. luckysheet.setCellValue(0, y, text)
  1355. }
  1356. val = (val != null && val != undefined) ? val : ''
  1357. luckysheet.setCellValue(x, y, val)
  1358. })
  1359. })
  1360. },
  1361. /** 修改报表信息 */
  1362. editReportItem(data) {
  1363. this.$prompt('请输入报表名称', '修改报表名称', {
  1364. confirmButtonText: '确定',
  1365. cancelButtonText: '取消',
  1366. inputValue: data.reportTableName,
  1367. customClass: 'close_confirm',
  1368. closeOnClickModal: false,
  1369. inputValidator: (val) => {
  1370. if (!val || !val.trim()) {
  1371. return '报表名称不能为空'
  1372. }
  1373. if (val.length > 20) {
  1374. return '报表名称必须在20字以内'
  1375. }
  1376. }
  1377. }).then(({value}) => {
  1378. const loading = showLoading(this, '修改中,请稍候···')
  1379. let params = {
  1380. 'id': data.id,
  1381. 'reportTableName': value
  1382. }
  1383. updateTableNameById(params).then(res => {
  1384. loading.close()
  1385. let msg = res.data ? '修改成功!' : '修改失败!'
  1386. let msgType = res.data ? 'success' : 'warning'
  1387. this.$message({
  1388. message: msg,
  1389. type: msgType
  1390. })
  1391. this.reportPage = 1
  1392. this.loadReport()
  1393. }).catch((e) => {
  1394. loading.close()
  1395. showAlertWin(this, e)
  1396. })
  1397. }).catch((e) => {
  1398. console.log(e)
  1399. })
  1400. },
  1401. /** 报表移除 */
  1402. removeReportItem(data, type) {
  1403. this.$confirm('您确定要删除该报表吗?', '温馨提示', {
  1404. confirmButtonText: '确定',
  1405. cancelButtonText: '取消',
  1406. customClass: 'close_confirm',
  1407. closeOnClickModal: false
  1408. }).then(() => {
  1409. const loading = showLoading(this, '删除中,请稍候···')
  1410. delReportTableById(data.id).then(res => {
  1411. loading.close()
  1412. let msg = res.data ? '删除成功!' : '删除失败!'
  1413. let msgType = res.data ? 'success' : 'warning'
  1414. this.$message({
  1415. message: msg,
  1416. type: msgType
  1417. })
  1418. if (type == 'record') {
  1419. this.reportHistoryPage = 1
  1420. this.historyReport()
  1421. return
  1422. }
  1423. this.reportPage = 1
  1424. this.loadReport()
  1425. this.cancelSaveReport()
  1426. }).catch((e) => {
  1427. loading.close()
  1428. showAlertWin(this, e)
  1429. })
  1430. }).catch(() => {
  1431. })
  1432. },
  1433. /** 获取单元格大小 */
  1434. getCellSize(celldata, r, c, luckysheet) {
  1435. const { cs, rs } = celldata.data[r][c].mc
  1436. const rowhidden = celldata.config.rowhidden && Object.keys(celldata.config.rowhidden) || ''
  1437. const rowArr = []
  1438. for (let i = 0; i < rs; i++) {
  1439. let rowIndex = r + i
  1440. if (rowhidden.indexOf(String(rowIndex)) < 0) {
  1441. rowArr.push(rowIndex)
  1442. }
  1443. }
  1444. const colArr = []
  1445. for (let j = 0; j < cs; j++) {
  1446. colArr.push(c + j)
  1447. }
  1448. const totalHeight = Object.values(
  1449. luckysheet.getRowHeight(rowArr)
  1450. ).reduce((a, b) => a + b)
  1451. const totalWidth = Object.values(
  1452. luckysheet.getColumnWidth(colArr)
  1453. ).reduce((a, b) => a + b)
  1454. return {
  1455. w: totalWidth,
  1456. h: totalHeight
  1457. }
  1458. },
  1459. /** 获取图片位置 */
  1460. getImagePosition(num, arr) {
  1461. let index = 0
  1462. let minIndex
  1463. let maxIndex
  1464. for (let i = 0; i < arr.length; i++) {
  1465. if (num < arr[i]) {
  1466. index = i
  1467. break
  1468. }
  1469. }
  1470. if (index == 0) {
  1471. minIndex = 0
  1472. maxIndex = 1
  1473. } else if (index == arr.length - 1) {
  1474. minIndex = arr.length - 2
  1475. maxIndex = arr.length - 1
  1476. } else {
  1477. minIndex = index - 1
  1478. maxIndex = index
  1479. }
  1480. let min = arr[minIndex]
  1481. let max = arr[maxIndex]
  1482. let radio = Math.abs((num - min) / (max - min)) + index
  1483. return radio
  1484. },
  1485. /** 图表转换为图片 */
  1486. convertChart(luckyData) {
  1487. const optionData = luckysheet.getLuckysheetfile()[0]
  1488. let {
  1489. visibledatacolumn, // 所有行的位置
  1490. visibledatarow // 所有列的位置
  1491. } = optionData
  1492. // 动态图表
  1493. if (luckyData.charts && luckyData.charts.length > 0) {
  1494. luckyData.charts.forEach((chart, i) => {
  1495. let myChart = echarts.init(
  1496. document.getElementsByClassName(chart.info.className)[0]
  1497. )
  1498. let baseData = myChart.getConnectedDataURL({
  1499. type: 'png',
  1500. pixelRatio: 2,
  1501. backgroundColor: '#ffffff'
  1502. })
  1503. // luckysheet.cancelRangeMerge(chart.info.pos)
  1504. luckysheet.insertImage(baseData, {
  1505. rowIndex: chart.info.pos[0],
  1506. colIndex: chart.info.pos[1],
  1507. cellSize: this.getCellSize(optionData, chart.info.pos[0], chart.info.pos[1], luckysheet),
  1508. success: function () {
  1509. console.log("插入成功")
  1510. }
  1511. })
  1512. })
  1513. }
  1514. // 静态图表
  1515. if (luckyData.data && luckyData.data.length > 0) {
  1516. luckyData.data.forEach((data, i) => {
  1517. if (data.chart && data.chart.length > 0) {
  1518. data.chart.forEach((chart, j) => {
  1519. let myChart = echarts.init(
  1520. document.getElementById(chart.chart_id)
  1521. )
  1522. myChart.setOption(chart.chartOptions);
  1523. let baseData = myChart.getConnectedDataURL({
  1524. type: 'png',
  1525. pixelRatio: 2,
  1526. backgroundColor: '#ffffff'
  1527. })
  1528. let col_st = this.getImagePosition(chart.left, visibledatacolumn)
  1529. let row_st = this.getImagePosition(chart.top, visibledatarow)
  1530. luckysheet.insertImage(baseData, {
  1531. rowIndex: parseInt(row_st),
  1532. colIndex: parseInt(col_st),
  1533. cellSize: {
  1534. w: chart.width,
  1535. h: chart.height,
  1536. },
  1537. success: function () {
  1538. console.log("插入成功")
  1539. }
  1540. })
  1541. })
  1542. }
  1543. })
  1544. }
  1545. },
  1546. /** 处理日期显示数字问题 */
  1547. withDateData(excelData) {
  1548. if (!excelData) {
  1549. return
  1550. }
  1551. excelData.map((item) => {
  1552. if (item) {
  1553. item.map((ll) => {
  1554. if (ll && ll.ct && ll.ct.t && ll.ct.t === 'd') {
  1555. ll.m = ll.m,
  1556. ll.v = ll.m,
  1557. ll.ct = {
  1558. fa: "@",
  1559. t: "s",
  1560. }
  1561. }
  1562. })
  1563. }
  1564. })
  1565. },
  1566. /** 保存报表信息 */
  1567. saveReportInfo() {
  1568. this.$prompt('请输入报表名称', '保存', {
  1569. confirmButtonText: '确定',
  1570. cancelButtonText: '取消',
  1571. customClass: 'close_confirm',
  1572. closeOnClickModal: false,
  1573. inputValidator: (val) => {
  1574. if (!val) {
  1575. return '报表名称不能为空'
  1576. }
  1577. if (val.length > 20) {
  1578. return '报表名称必须在20字以内'
  1579. }
  1580. }
  1581. }).then(({value}) => {
  1582. if (!this.chooseReportTemplate) {
  1583. this.$message({
  1584. message: '请重新选择报表模板',
  1585. type: 'warning'
  1586. })
  1587. return
  1588. }
  1589. const loading = showLoading(this, '保存中,请稍候···')
  1590. let excelData = this.chooseReportTemplate.data[0].data
  1591. this.withDateData(excelData)
  1592. // this.convertChart(this.chooseReportTemplate)
  1593. let data = {
  1594. 'tableTemplateId': this.chooseReportTemplateId,
  1595. 'reportTableName': value,
  1596. 'reportValueFormat': this.reportForm.reportValueFormat,
  1597. 'reportTableData': JSON.stringify(this.chooseReportTemplate)
  1598. }
  1599. saveReport(data).then(res => {
  1600. loading.close()
  1601. let msg = res.data ? '保存成功!' : '保存失败!'
  1602. let msgType = res.data ? 'success' : 'error'
  1603. this.$message({
  1604. message: msg,
  1605. type: msgType
  1606. })
  1607. this.showMainView = false
  1608. this.loadReport()
  1609. this.cancelSaveReport()
  1610. }).catch((e) => {
  1611. loading.close()
  1612. showAlertWin(this, e)
  1613. })
  1614. }).catch((e) => {
  1615. console.log(e)
  1616. })
  1617. },
  1618. /** 更新报表信息 */
  1619. updateReport() {
  1620. console.log(this.chooseMyReport)
  1621. if (!this.chooseMyReport || !this.chooseMyReport.id) {
  1622. this.$message({
  1623. message: '保存失败,请刷新后重试!',
  1624. type: 'warning'
  1625. })
  1626. return
  1627. }
  1628. this.$prompt('请输入报表名称', '保存', {
  1629. confirmButtonText: '确定',
  1630. cancelButtonText: '取消',
  1631. customClass: 'close_confirm',
  1632. closeOnClickModal: false,
  1633. inputValue: this.chooseMyReport.reportTableName,
  1634. inputValidator: (val) => {
  1635. if (!val) {
  1636. return '报表名称不能为空'
  1637. }
  1638. if (val.length > 20) {
  1639. return '报表名称必须在20字以内'
  1640. }
  1641. }
  1642. }).then(({value}) => {
  1643. const loading = showLoading(this, '保存中,请稍候···')
  1644. let _data = JSON.parse(this.getLuckysheetConfig())
  1645. let _data2 = JSON.parse(this.chooseMyReport.reportTableData)
  1646. let excelData = _data[0].data
  1647. this.withDateData(excelData)
  1648. _data2.data = _data
  1649. // this.convertChart(_data2)
  1650. let data = this.chooseMyReport
  1651. data.reportTableName = value
  1652. data.reportTableData = JSON.stringify(_data2)
  1653. updateReportTable(data).then(res => {
  1654. loading.close()
  1655. let msg = res.data ? '保存成功!' : '保存失败!'
  1656. let msgType = res.data ? 'success' : 'error'
  1657. this.$message({
  1658. message: msg,
  1659. type: msgType
  1660. })
  1661. this.showMainView = false
  1662. this.loadReport()
  1663. this.cancelSaveReport()
  1664. }).catch((e) => {
  1665. loading.close()
  1666. showAlertWin(this, e)
  1667. })
  1668. }).catch((e) => {
  1669. console.log(e)
  1670. })
  1671. },
  1672. /** 保存数据格式转换 */
  1673. getLuckysheetConfig() {
  1674. let ls = luckysheet.getLuckysheetfile()
  1675. ls.forEach((item, index) => {
  1676. if(item.chart) {
  1677. item.chart.forEach((chart, i) => {
  1678. ls[index].chart[i] = {
  1679. ...ls[index].chart[i],
  1680. chartOptions: {...chartmix.default.getChartJson(chart.chart_id)}
  1681. }
  1682. let div = document.getElementById(chart.chart_id + '_c');
  1683. if(div.style) {
  1684. ls[index].chart[i].left = parseInt(div.style.left)
  1685. ls[index].chart[i].top = parseInt(div.style.top)
  1686. ls[index].chart[i].width = parseInt(div.style.width)
  1687. ls[index].chart[i].height = parseInt(div.style.height)
  1688. }
  1689. })
  1690. }
  1691. })
  1692. return JSON.stringify(ls)
  1693. },
  1694. /** 报表下载 */
  1695. downloadReport() {
  1696. this.dialogDownloadReportTypeVisible = true
  1697. },
  1698. /** 报表下载事件 */
  1699. downloadReportEvent() {
  1700. if (!this.chooseMyReport) {
  1701. this.$message({
  1702. message: '请选择报表',
  1703. type: 'warning'
  1704. })
  1705. return
  1706. }
  1707. let reportName = this.chooseMyReport.reportTableName ? this.chooseMyReport.reportTableName : '统计报表'
  1708. if (this.downloadType == '1') {
  1709. // exportExcel(luckysheet, reportName, ExcelJS).then((res) => {
  1710. // console.log("result==>", res)
  1711. // // this.$message({
  1712. // // message: res,
  1713. // // type: 'success'
  1714. // // })
  1715. // this.dialogDownloadReportTypeVisible = false
  1716. // }).catch((err) => {
  1717. // })
  1718. exportExcel(luckysheet.getAllSheets(), reportName)
  1719. setTimeout(() => {
  1720. this.dialogDownloadReportTypeVisible = false
  1721. }, 500)
  1722. }
  1723. },
  1724. /** 报表记录 */
  1725. historyReport() {
  1726. const loading = showLoading(this, '加载中,请稍候···')
  1727. let params = {
  1728. 'page': this.reportHistoryPage,
  1729. 'limit': this.reportHistoryLimit,
  1730. 'autoTableId': this.chooseMyReport.id
  1731. }
  1732. getAutoChReportTable(params).then(res => {
  1733. loading.close()
  1734. this.dialogHistoryReportVisible = true
  1735. if (!res.data) return
  1736. this.reportHistoryData = res.data.reportTableList
  1737. this.reportHistoryTotal = res.data.count
  1738. }).catch((e) => {
  1739. loading.close()
  1740. showAlertWin(this, e)
  1741. })
  1742. },
  1743. getPrintSheetArea() {
  1744. const sheetData = luckysheet.getSheetData();
  1745. let objRowColumn = {
  1746. row: [0, 0], //行
  1747. column: [0, 0], //列
  1748. };
  1749. // * item是行、index是行索引、it是一行里的一格、itemIndex是这一格在这一行里的列索引
  1750. sheetData.forEach((item, index) => {
  1751. //行数
  1752. item.forEach((it, itemIndex) => {
  1753. if (it !== null && it.v) {
  1754. console.log(index, it)
  1755. if (objRowColumn.row[1] < index) {
  1756. objRowColumn.row[1] = index; //row第二位
  1757. }
  1758. if (objRowColumn.column[1] < itemIndex) {
  1759. objRowColumn.column[1] = itemIndex; //column第二位
  1760. }
  1761. }
  1762. });
  1763. });
  1764. return objRowColumn;
  1765. },
  1766. /** 打印操作 */
  1767. printExcel() {
  1768. const loading = showLoading(this, '请稍候···')
  1769. document.querySelector('#print-area').style = "display:block";
  1770. window.luckysheet.hideGridLines();
  1771. // 获取当前选中区域
  1772. let currentSelected = luckysheet.getRange()
  1773. // 如果当前选中区只是一个单元格,则认为选取无效。
  1774. if (currentSelected[0] != null
  1775. && (currentSelected[0].row[1] - currentSelected[0].row[0] >= 1
  1776. || currentSelected[0].column[1] - currentSelected[0].column[0] >= 1)) {
  1777. // 生成base64图片
  1778. let imgSrc = luckysheet.getScreenshot();
  1779. window.luckysheet.showGridLines();
  1780. // * Lodop中的ADD_PRINT_IMAGE,也可以直接输出base64码图片,不用加img标签(如果加了img标签,会被当做超文本对待,受浏览器引擎解析的影响)
  1781. let $img = `<img src=${imgSrc} style="max-width: 90%;" />`
  1782. this.$nextTick(() => {
  1783. document.querySelector('#print-html').innerHTML = $img;
  1784. setTimeout(() => {
  1785. Print({
  1786. printable: 'print-html',
  1787. type: 'html',
  1788. documentTitle: '文档标题',
  1789. header: '',
  1790. headerStyle: 'font-weight:400;text-align:center;',
  1791. style: '@page {margin: 0 10mm};', // 不打印页眉和页脚
  1792. honorColor: true, // 是否打印彩色文本
  1793. targetStyles: ['*'] // 允许打印所有样式属性
  1794. }) // Print.js插件
  1795. document.querySelector("#print-area").style.display = "none";
  1796. loading.close()
  1797. }, 1000)
  1798. })
  1799. } else {
  1800. // 获取打印区域的行列
  1801. let RowColumn = this.getPrintSheetArea();
  1802. // 因需要打印左边的边框,需重新设置第一列
  1803. RowColumn.column[0] = 0;
  1804. // 进行选区操作
  1805. luckysheet.setRangeShow(RowColumn);
  1806. let imgSrc = luckysheet.getScreenshot(); // 生成base64图片
  1807. window.luckysheet.showGridLines();
  1808. // * Lodop中的ADD_PRINT_IMAGE,也可以直接输出base64码图片,不用加img标签(如果加了img标签,会被当做超文本对待,受浏览器引擎解析的影响)
  1809. let $img = `<img src=${imgSrc} style="max-width: 90%;" />`
  1810. this.$nextTick(() => {
  1811. document.querySelector('#print-html').innerHTML = $img;
  1812. setTimeout(() => {
  1813. Print({
  1814. printable: 'print-html',
  1815. type: 'html',
  1816. documentTitle: '文档标题',
  1817. header: '',
  1818. headerStyle: 'font-weight:400;text-align:center;',
  1819. style: '@page {margin: 0 10mm};', // 不打印页眉和页脚
  1820. honorColor: true, // 是否打印彩色文本
  1821. targetStyles: ['*'] // 允许打印所有样式属性
  1822. }) // Print.js插件
  1823. document.querySelector("#print-area").style.display = "none";
  1824. loading.close()
  1825. }, 1000)
  1826. })
  1827. }
  1828. },
  1829. /** 自定义选中区域 */
  1830. getExcelRowColumn() {
  1831. const sheetData = luckysheet.getSheetData();
  1832. let objRowColumn = {
  1833. row: [null, null], //行
  1834. column: [null, null], //列
  1835. };
  1836. sheetData.forEach((item, index) => {
  1837. //行数
  1838. item.forEach((it, itemIndex) => {
  1839. console.log(it)
  1840. if (it !== null) {
  1841. if (objRowColumn.row[0] == null) objRowColumn.row[0] = index; // row第一位
  1842. objRowColumn.row[1] = index; //row第二位
  1843. if (objRowColumn.column[0] == null)
  1844. objRowColumn.column[0] = itemIndex; //column第一位
  1845. objRowColumn.column[1] = itemIndex; //column第二位
  1846. }
  1847. });
  1848. });
  1849. return objRowColumn;
  1850. },
  1851. cronNodeEvent(obj) {
  1852. this.cronVal = obj.value
  1853. },
  1854. initCronList() {
  1855. this.cronList = []
  1856. this.cronList.push({ value: '0/2 * * * * ?', label: '表示每2秒钟执行一次任务' })
  1857. this.cronList.push({ value: '0 0/2 * * * ?', label: '表示每2分钟执行一次任务' })
  1858. this.cronList.push({ value: '0 0 0/2 * * ?', label: '表示每2小时执行一次任务' })
  1859. this.cronList.push({ value: '0 15 10 * * ?', label: '表示在每天上午10点15分执行一次任务' })
  1860. this.cronList.push({ value: '0 0 10,14,16 * * ?', label: '表示在每天的上午10点、下午2点、下午4点分别执行一次任务' })
  1861. this.cronList.push({ value: '0 0/30 9-17 * * ?', label: '表示在每天的上午9点到下午5点的范围内每30分钟执行一次任务' })
  1862. this.cronList.push({ value: '0 0 12 ? * WED', label: '表示在每周星期三中午12点执行一次任务' })
  1863. this.cronList.push({ value: '0 0 2 1 * ?', label: '表示在每月的1日的凌晨2点执行一次任务' })
  1864. },
  1865. /** 取消保存报表 */
  1866. cancelSaveReport2() {
  1867. this.handleReportNodeClick(this.chooseMyReport, this.chooseMyReport.userId !== this.uid ? 'deny' : '')
  1868. },
  1869. /** 取消保存报表 */
  1870. cancelSaveReport() {
  1871. luckysheet.destroy()
  1872. this.breadcrumbList = ['我的报表']
  1873. this.showMainView = false
  1874. this.btnType = ''
  1875. this.chooseMyReport = null
  1876. if (this.$refs['reportForm']) this.$refs['reportForm'].resetFields()
  1877. },
  1878. /** 弹出层关闭事件 */
  1879. dialogClose(done) {
  1880. this.cronVal = ''
  1881. this.reportId = null
  1882. // this.userGroupInfo = null
  1883. if (typeof (done) === 'function') {
  1884. done()
  1885. } else {
  1886. this.dialogReportTemplateVisible = false
  1887. this.dialogDownloadReportTypeVisible = false
  1888. this.dialogAutoReportVisible = false
  1889. this.dialogUserGroupVisible = false
  1890. }
  1891. }
  1892. }
  1893. }
  1894. </script>
  1895. <style rel="stylesheet/scss" lang="scss">
  1896. .breadcrumb-content {
  1897. padding-bottom: 0;
  1898. }
  1899. .cy-nav-sx {
  1900. float: left !important;
  1901. margin-top: -23px !important;
  1902. margin-left: 120px !important;
  1903. display: flex;
  1904. }
  1905. .cy-nav-btn {
  1906. float: right !important;
  1907. margin-right: 20px !important;
  1908. margin-top: -20px !important;
  1909. }
  1910. .cy-main {
  1911. margin: 10px 20px;
  1912. width: calc(100% - 40px);
  1913. height: calc(100% - 100px);
  1914. .cy-btn {
  1915. margin-bottom: 10px;
  1916. }
  1917. .cy-btn .el-link {
  1918. margin-right: 15px;
  1919. }
  1920. .cy-main-left {
  1921. width: 100%;
  1922. height: 100%;
  1923. overflow: auto;
  1924. //float: left;
  1925. padding: 5px 10px;
  1926. //border-right: 1px solid #d4d4d4;
  1927. .cy-list {
  1928. overflow: auto;
  1929. height: 100%;
  1930. height: calc(100% - 40px);
  1931. ul {
  1932. display: flex;
  1933. flex-wrap: wrap;
  1934. padding: 0;
  1935. margin-top: 0;
  1936. li {
  1937. list-style-type: none;
  1938. background: #41aed7;
  1939. width: 23%;
  1940. margin: 10px 1%;
  1941. border-radius: 8px;
  1942. height: 110px;
  1943. padding: 15px;
  1944. color: #ffffff;
  1945. .cy-item-name {
  1946. font-size: 14px;
  1947. text-overflow: ellipsis;
  1948. white-space: nowrap;
  1949. overflow: hidden;
  1950. margin-bottom: 15px;
  1951. cursor: pointer;
  1952. }
  1953. .cy-item-val {
  1954. font-size: 12px;
  1955. }
  1956. .cy-list-item {
  1957. font-size: 12px;
  1958. color: #f6f6f6;
  1959. width: 100%;
  1960. //display: flex;
  1961. margin-top: 40px;
  1962. }
  1963. }
  1964. }
  1965. }
  1966. }
  1967. .cy-main-right {
  1968. width: 100%;
  1969. height: 100%;
  1970. float: left;
  1971. overflow: hidden;
  1972. }
  1973. }
  1974. .cy-group-tree1 {
  1975. font-size: 14px;
  1976. .custom-tree-node1 {
  1977. height: 28px;
  1978. line-height: 28px;
  1979. }
  1980. }
  1981. .cron-txt {
  1982. color: blue;
  1983. margin-right: 20px;
  1984. cursor: pointer;
  1985. font-weight: bold;
  1986. font-size: 16px;
  1987. }
  1988. .cron-txt-desc {
  1989. }
  1990. .ug-div {
  1991. .el-transfer-panel {
  1992. width: 300px;
  1993. }
  1994. }
  1995. </style>