index.vue 94 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615
  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">新增-->
  25. <!-- </el-button>-->
  26. <!-- <el-button v-if="btnType === ''" type="success" class="cy-nav-btn" icon="el-icon-refresh"-->
  27. <!-- size="mini" @click="refreshReportEvent">刷新</el-button>-->
  28. <el-divider></el-divider>
  29. <div class="cy-main">
  30. <div class="cy-main-left" v-if="!showMainView">
  31. <div class="cy-list">
  32. <el-table v-if="reportDataList.length > 0"
  33. :data="reportDataList"
  34. border
  35. :stripe="true"
  36. :header-cell-style="{background: '#E8E8E8'}"
  37. @sort-change="sortChange"
  38. style="width: 100%;">
  39. <el-table-column
  40. align="center"
  41. sortable="custom"
  42. label="报表名称"
  43. prop="reportTableName">
  44. <template slot-scope="scope">
  45. <span style="color: #409EFF; cursor: pointer;"
  46. @click="handleReportNodeClick(scope.row, scope.row.userId != uid ? 'deny' : '')"
  47. :title="scope.row.reportTableName">{{ scope.row.reportTableName }}</span>
  48. </template>
  49. </el-table-column>
  50. <el-table-column
  51. align="center"
  52. label="报表类型"
  53. prop="reportTableType"
  54. width="350">
  55. <template slot-scope="scope">
  56. <el-tag v-if="scope.row.userId != uid" type="success" style="margin-right: 5px;">被分享</el-tag>
  57. <el-tag v-if="uid == scope.row.userId && scope.row.userGroupList && scope.row.userGroupList.length > 0"
  58. type="warning" style="margin-right: 5px;">已分享
  59. </el-tag>
  60. <el-tag v-if="scope.row.reportTableType == 0" style="margin-right: 5px;">手动报表</el-tag>
  61. <el-tag v-if="scope.row.reportTableType == 1" style="margin-right: 5px;">自动报表</el-tag>
  62. <el-tag v-if="scope.row.reportTableType == 2" style="margin-right: 5px;">事件驱动报表</el-tag>
  63. </template>
  64. </el-table-column>
  65. <el-table-column
  66. align="center"
  67. label="创建时间"
  68. sortable
  69. prop="createTime"
  70. width="200">
  71. </el-table-column>
  72. <el-table-column label="操作" align="center" width="380">
  73. <template slot-scope="scope">
  74. <el-button type="text"
  75. v-if="uid == scope.row.userId"
  76. size="small"
  77. icon="el-icon-setting"
  78. @click="editReportItem(scope.row)">配置
  79. </el-button>
  80. <!-- <el-button type="text"-->
  81. <!-- v-if="uid == scope.row.userId"-->
  82. <!-- size="small"-->
  83. <!-- icon="el-icon-edit"-->
  84. <!-- @click="editReportItem(scope.row)">修改-->
  85. <!-- </el-button>-->
  86. <el-button type="text"
  87. v-if="uid == scope.row.userId && scope.row.reportTableType == 1 && scope.row.runState == 0"
  88. size="small"
  89. icon="el-icon-video-play"
  90. @click="setReportStatus(scope.row)">启动
  91. </el-button>
  92. <el-button type="text"
  93. v-if="uid == scope.row.userId && scope.row.reportTableType == 1 && scope.row.runState == 1"
  94. size="small"
  95. icon="el-icon-video-pause"
  96. @click="setReportStatus(scope.row)">停止
  97. </el-button>
  98. <el-button type="text"
  99. v-if="uid == scope.row.userId"
  100. size="small"
  101. icon="el-icon-printer"
  102. @click="setAutoPrint(scope.row)">打印
  103. </el-button>
  104. <el-button type="text"
  105. v-if="uid == scope.row.userId"
  106. size="small"
  107. icon="el-icon-user"
  108. @click="setUserGroupEvent(scope.row)">授权
  109. </el-button>
  110. <el-button type="text"
  111. v-if="uid == scope.row.userId"
  112. size="small"
  113. icon="el-icon-document"
  114. @click="getUserGroupEvent(scope.row)">授权详情
  115. </el-button>
  116. <el-button type="text"
  117. v-if="uid == scope.row.userId"
  118. size="small"
  119. icon="el-icon-delete"
  120. style="color: red;"
  121. @click="removeReportItem(scope.row)">删除
  122. </el-button>
  123. </template>
  124. </el-table-column>
  125. </el-table>
  126. <el-empty v-else description="暂无数据"></el-empty>
  127. </div>
  128. <el-pagination
  129. background
  130. @size-change="handleSizeChange"
  131. @current-change="handleCurrentChange"
  132. :current-page="reportPage"
  133. :page-size="reportLimit"
  134. layout="sizes, prev, pager, next, total"
  135. :total="reportTotal">
  136. </el-pagination>
  137. </div>
  138. <div class="cy-main-right" :style="showMainView ? '' : 'display: none;'">
  139. <el-row v-if="btnType == 'add'" style="margin: 10px 20px;">
  140. <el-button type="primary" size="mini" icon="el-icon-document" @click="saveReportInfo">保存报表</el-button>
  141. <el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport">取消</el-button>
  142. </el-row>
  143. <el-row v-if="btnType == 'show'" style="margin: 10px 20px;">
  144. <el-button type="success" size="mini" icon="el-icon-document-checked" @click="updateReport">保存</el-button>
  145. <el-button type="primary" size="mini" icon="el-icon-download" @click="downloadReport">下载</el-button>
  146. <el-button type="warning" size="mini" icon="el-icon-printer" @click="printExcel">打印</el-button>
  147. <el-button type="info" size="mini" icon="el-icon-document" @click="historyReport">运行记录</el-button>
  148. <el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport">关闭</el-button>
  149. </el-row>
  150. <el-row v-if="btnType == 'showShared'" style="margin: 10px 20px;">
  151. <el-button type="primary" size="mini" icon="el-icon-download" @click="downloadReport">下载</el-button>
  152. <el-button type="warning" size="mini" icon="el-icon-printer" @click="printExcel">打印</el-button>
  153. <el-button v-if="chooseMyReport && chooseMyReport.reportTableType != 0" type="info" size="mini"
  154. icon="el-icon-document" @click="historyReport">运行记录
  155. </el-button>
  156. <el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport">关闭</el-button>
  157. <div style="float: right;" v-if="this.showReportTableType == 1 || this.showReportTableType == 0">
  158. <label>频率:</label>
  159. <el-select style="width: 90px;" size="mini" placeholder="请选择频率"
  160. v-model="reportInterval" @change="reportIntervalChange">
  161. <el-option
  162. v-for="item in reportIntervalOptions"
  163. :key="item"
  164. :label="item + '秒'"
  165. :value="item">
  166. </el-option>
  167. </el-select>
  168. </div>
  169. </el-row>
  170. <el-row v-if="btnType == 'showChild'" style="margin: 10px 20px;">
  171. <el-button type="primary" size="mini" icon="el-icon-download" @click="downloadReport">下载</el-button>
  172. <el-button type="warning" size="mini" icon="el-icon-printer" @click="printExcel">打印</el-button>
  173. <el-button type="danger" size="mini" icon="el-icon-circle-close" @click="cancelSaveReport2">关闭</el-button>
  174. </el-row>
  175. <div id="luckysheet"
  176. style="margin:0px;padding:0px;position:relative;height:calc(100% - 50px);width:100%;left: 20px;top: 0px;bottom:0px;">
  177. </div>
  178. </div>
  179. </div>
  180. <!-- 新增报表 -->
  181. <el-dialog
  182. :title="reportDialogTitle"
  183. width="600px"
  184. top="10vh"
  185. center
  186. v-dialog-drag
  187. v-if="dialogReportTemplateVisible"
  188. :before-close="dialogClose"
  189. :visible.sync="dialogReportTemplateVisible"
  190. :close-on-click-modal="false"
  191. :append-to-body="true">
  192. <el-form ref="reportForm" :model="reportForm" :rules="reportRules" label-width="80px">
  193. <el-form-item label='报表名称' prop="reportTableName">
  194. <el-input placeholder="请输入报表名称" v-model="reportForm.reportTableName" maxlength="20"></el-input>
  195. </el-form-item>
  196. <el-form-item label="报表类型" prop="reportTableType" v-if="!reportForm.id">
  197. <el-radio-group v-model="reportForm.reportTableType" @input="changeReportType">
  198. <el-radio label="0">手动报表</el-radio>
  199. <el-radio label="1">自动报表</el-radio>
  200. <el-radio label="2">事件驱动报表</el-radio>
  201. </el-radio-group>
  202. </el-form-item>
  203. <el-form-item label="报表模板" prop="tableTemplateId" v-if="!reportForm.id">
  204. <el-select v-model="reportForm.tableTemplateId" filterable placeholder="请选择报表模板" style="width: 100%;">
  205. <el-option
  206. v-for="item in reportTemplateList"
  207. :key="item.id"
  208. :label="item.templateName"
  209. :value="item.id">
  210. </el-option>
  211. </el-select>
  212. </el-form-item>
  213. <el-form-item label="开始时间" prop="dateRange" v-if="reportForm.reportTableType == 1">
  214. <el-date-picker
  215. v-model="reportForm.startTime"
  216. style="width: 100%;"
  217. type="datetime"
  218. :clearable="false"
  219. placeholder="请选择开始时间"
  220. prefix-icon=""
  221. :picker-options="{
  222. format: 'yyyy-MM-dd HH:mm:ss'
  223. }"
  224. value-format="yyyy-MM-dd HH:mm:ss">
  225. </el-date-picker>
  226. </el-form-item>
  227. <el-form-item label="运行时间" prop="cronLabel" v-if="reportForm.reportTableType == 1">
  228. <el-input placeholder="请设置运行时间" v-model="reportForm.cronLabel" style="width: calc(100% - 105px);"
  229. readonly></el-input>
  230. <el-button size="mini" @click="settingAutoReportTime" style="float: right;width: 100px;line-height: 20px;">
  231. 设置运行时间
  232. </el-button>
  233. </el-form-item>
  234. </el-form>
  235. <span slot='footer'>
  236. <el-button type="primary" @click="chooseReportEvent" style="margin-top: 20px;">确定</el-button>
  237. <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
  238. </span>
  239. </el-dialog>
  240. <!-- 配置打印定时任务 -->
  241. <el-dialog
  242. :title="printDialogTitle"
  243. width="700px"
  244. top="10vh"
  245. center
  246. v-dialog-drag
  247. v-if="dialogAutoPrintVisible"
  248. :before-close="dialogClose"
  249. :visible.sync="dialogAutoPrintVisible"
  250. :close-on-click-modal="false"
  251. :append-to-body="true">
  252. <el-form ref="reportForm" :model="reportForm" :rules="reportRules" label-width="80px">
  253. <el-radio-group v-model="radioByCron">
  254. <el-form-item label="秒">
  255. <el-radio :label="1">
  256. <span style="margin-right: 10px;">每</span>
  257. <el-input-number size="mini" v-model="radioByCronValS" :min="1" :max="59"
  258. :precision="0"></el-input-number>
  259. <span style="margin-left: 10px;">秒执行一次</span>
  260. </el-radio>
  261. </el-form-item>
  262. <el-form-item label="分钟">
  263. <el-radio :label="2">
  264. <span style="margin-right: 10px;">每</span>
  265. <el-input-number size="mini" v-model="radioByCronValM" :min="1" :max="59"
  266. :precision="0"></el-input-number>
  267. <span style="margin-left: 10px;">分钟执行一次</span>
  268. </el-radio>
  269. </el-form-item>
  270. <el-form-item label="小时">
  271. <el-radio :label="3">
  272. <span style="margin-right: 10px;">每</span>
  273. <el-input-number size="mini" v-model="radioByCronValH" :min="1" :max="2" :precision="0"></el-input-number>
  274. <span style="margin-left: 10px;">小时执行一次</span>
  275. </el-radio>
  276. </el-form-item>
  277. <el-form-item label="指定时间">
  278. <el-radio :label="4">
  279. <span style="margin-right: 10px;">在每天的</span>
  280. <el-time-picker v-model="radioByCronValD"
  281. size="mini"
  282. placeholder="请选择时间"
  283. :clearable="false"
  284. :editable="false"
  285. value-format="HH:mm:ss"
  286. :picker-options="{
  287. format: 'HH:mm:ss'
  288. }">
  289. </el-time-picker>
  290. <span style="margin-left: 10px;">执行一次</span>
  291. </el-radio>
  292. </el-form-item>
  293. <el-form-item label="">
  294. <el-radio :label="5">
  295. <span style="margin-right: 10px;">在每月</span>
  296. <el-input-number size="mini" v-model="radioByCronValMo" :min="1" :max="31"
  297. :precision="0"></el-input-number>
  298. <span style="margin-right: 10px; margin-left: 10px;">号的</span>
  299. <el-time-picker v-model="radioByCronValMoD"
  300. size="mini"
  301. placeholder="请选择时间"
  302. :clearable="false"
  303. :editable="false"
  304. value-format="HH:mm:ss"
  305. :picker-options="{
  306. format: 'HH:mm:ss'
  307. }">
  308. </el-time-picker>
  309. <span style="margin-left: 10px;">执行一次</span>
  310. </el-radio>
  311. </el-form-item>
  312. </el-radio-group>
  313. </el-form>
  314. <span slot='footer'>
  315. <el-button type="primary" @click="chooseCronPrint" style="margin-top: 20px;">确定</el-button>
  316. <el-button type="warning" v-if="printForm.runState==1" @click="stopAutoPrint"
  317. style="margin-top: 20px;">停止</el-button>
  318. <el-button type="warning" disabled v-if="printForm.runState!=1" @click="stopAutoPrint"
  319. style="margin-top: 20px;">停止</el-button>
  320. <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
  321. </span>
  322. </el-dialog>
  323. <!-- 用户组选择 -->
  324. <el-dialog
  325. title="选择用户组"
  326. width="840px"
  327. top="10vh"
  328. center
  329. v-dialog-drag
  330. v-if="dialogUserGroupVisible"
  331. :before-close="dialogClose"
  332. :visible.sync="dialogUserGroupVisible"
  333. :close-on-click-modal="false"
  334. :append-to-body="true">
  335. <!-- <el-form label-width="80px">-->
  336. <!-- <el-form-item label="用户组">-->
  337. <!-- <el-select v-model="userGroupInfo" filterable clearable multiple placeholder="请选择用户组" style="width: 100%;">-->
  338. <!-- <el-option-->
  339. <!-- v-for="item in userGroupList"-->
  340. <!-- :key="item.id"-->
  341. <!-- :label="item.userGroupName"-->
  342. <!-- :value="item.id">-->
  343. <!-- </el-option>-->
  344. <!-- </el-select>-->
  345. <!-- </el-form-item>-->
  346. <!-- </el-form>-->
  347. <div class="ug-div">
  348. <el-transfer
  349. v-model="userGroupInfo"
  350. :titles="['用户组列表', '已选择用户组']"
  351. :data="userGroupList"
  352. :props="{
  353. key: 'id',
  354. label: 'userGroupName'
  355. }">
  356. </el-transfer>
  357. </div>
  358. <span slot='footer'>
  359. <el-button type="primary" @click="chooseUserGroupEvent" style="margin-top: 20px;">确定</el-button>
  360. <el-button @click="dialogClose" style="margin-top: 20px;">取消</el-button>
  361. </span>
  362. </el-dialog>
  363. <!-- 自动报表CRON定时表达式 -->
  364. <el-dialog
  365. title="配置定时任务"
  366. width="700px"
  367. top="10vh"
  368. center
  369. v-dialog-drag
  370. v-if="dialogAutoReportVisible"
  371. :before-close="dialogClose"
  372. :visible.sync="dialogAutoReportVisible"
  373. :close-on-click-modal="false"
  374. :append-to-body="true">
  375. <el-form label-width="80px">
  376. <el-radio-group v-model="radioByCron">
  377. <el-form-item label="秒">
  378. <el-radio :label="1">
  379. <span style="margin-right: 10px;">每</span>
  380. <el-input-number size="mini" v-model="radioByCronValS" :min="1" :max="59"
  381. :precision="0"></el-input-number>
  382. <span style="margin-left: 10px;">秒执行一次</span>
  383. </el-radio>
  384. </el-form-item>
  385. <el-form-item label="分钟">
  386. <el-radio :label="2">
  387. <span style="margin-right: 10px;">每</span>
  388. <el-input-number size="mini" v-model="radioByCronValM" :min="1" :max="59"
  389. :precision="0"></el-input-number>
  390. <span style="margin-left: 10px;">分钟执行一次</span>
  391. </el-radio>
  392. </el-form-item>
  393. <el-form-item label="小时">
  394. <el-radio :label="3">
  395. <span style="margin-right: 10px;">每</span>
  396. <el-input-number size="mini" v-model="radioByCronValH" :min="1" :max="2" :precision="0"></el-input-number>
  397. <span style="margin-left: 10px;">小时执行一次</span>
  398. </el-radio>
  399. </el-form-item>
  400. <el-form-item label="指定时间">
  401. <el-radio :label="4">
  402. <span style="margin-right: 10px;">在每天的</span>
  403. <el-time-picker v-model="radioByCronValD"
  404. size="mini"
  405. placeholder="请选择时间"
  406. :clearable="false"
  407. :editable="false"
  408. value-format="HH:mm:ss"
  409. :picker-options="{
  410. format: 'HH:mm:ss'
  411. }">
  412. </el-time-picker>
  413. <span style="margin-left: 10px;">执行一次</span>
  414. </el-radio>
  415. </el-form-item>
  416. <el-form-item label="">
  417. <el-radio :label="5">
  418. <span style="margin-right: 10px;">在每月</span>
  419. <el-input-number size="mini" v-model="radioByCronValMo" :min="1" :max="31"
  420. :precision="0"></el-input-number>
  421. <span style="margin-right: 10px; margin-left: 10px;">号的</span>
  422. <el-time-picker v-model="radioByCronValMoD"
  423. size="mini"
  424. placeholder="请选择时间"
  425. :clearable="false"
  426. :editable="false"
  427. value-format="HH:mm:ss"
  428. :picker-options="{
  429. format: 'HH:mm:ss'
  430. }">
  431. </el-time-picker>
  432. <span style="margin-left: 10px;">执行一次</span>
  433. </el-radio>
  434. </el-form-item>
  435. </el-radio-group>
  436. <!-- <el-form-item label="表达式">-->
  437. <!-- <el-input type="text" placeholder="请输入定时任务表达式" v-model="cronVal" maxlength="50"></el-input>-->
  438. <!-- </el-form-item>-->
  439. <!-- <div>-->
  440. <!-- <label>常用定时任务表达式例子</label>-->
  441. <!-- <ul>-->
  442. <!-- <li v-for="(item, i) in cronList" style="margin-bottom: 5px;">-->
  443. <!-- <span class="cron-txt" @click="cronNodeEvent(item)">{{ item.value }}</span>-->
  444. <!-- <span class="cron-txt-desc">{{ item.label }}</span>-->
  445. <!-- </li>-->
  446. <!-- </ul>-->
  447. <!-- </div>-->
  448. </el-form>
  449. <span slot='footer'>
  450. <el-button type="primary" @click="chooseCronEvent">确定</el-button>
  451. <!-- <el-button @click="dialogClose">取消</el-button>-->
  452. </span>
  453. </el-dialog>
  454. <!-- 报表类型 -->
  455. <el-dialog
  456. title="报表类型选择"
  457. width="50%"
  458. top="10vh"
  459. center
  460. v-dialog-drag
  461. v-if="dialogReportTypeVisible"
  462. :before-close="dialogClose"
  463. :visible.sync="dialogReportTypeVisible"
  464. :close-on-click-modal="false"
  465. :append-to-body="true">
  466. <div style="text-align: center;">
  467. <el-radio v-model="reportType" label="0">手动报表</el-radio>
  468. <el-radio v-model="reportType" label="1">自动报表</el-radio>
  469. <el-radio v-model="reportType" label="2">事件驱动报表</el-radio>
  470. </div>
  471. <span slot='footer'>
  472. <el-button type="primary" @click="chooseReportTypeEvent">确定</el-button>
  473. <el-button @click="dialogClose">取消</el-button>
  474. </span>
  475. </el-dialog>
  476. <!-- 报表下载类型选择 -->
  477. <el-dialog
  478. title="选择下载类型"
  479. width="500px"
  480. center
  481. v-dialog-drag
  482. v-if="dialogDownloadReportTypeVisible"
  483. :before-close="dialogClose"
  484. :visible.sync="dialogDownloadReportTypeVisible"
  485. :close-on-click-modal="false"
  486. :append-to-body="true">
  487. <div style="text-align: center;">
  488. <el-radio v-model="downloadType" label="1">Excel</el-radio>
  489. <!-- <el-radio v-model="downloadType" label="2" disabled>PDF</el-radio>-->
  490. </div>
  491. <div style="text-align: center; margin-top: 40px;">
  492. <el-button type="primary" @click="downloadReportEvent">确定</el-button>
  493. </div>
  494. </el-dialog>
  495. <!-- 历史报表查看 -->
  496. <el-dialog
  497. title="运行报表记录"
  498. width="80%"
  499. top="10vh"
  500. center
  501. v-dialog-drag-and-zoom
  502. v-if="dialogHistoryReportVisible"
  503. :before-close="dialogClose"
  504. :visible.sync="dialogHistoryReportVisible"
  505. :close-on-click-modal="false"
  506. :append-to-body="true">
  507. <div style="height: 60vh;">
  508. <div style="margin-bottom: 10px; float: right;">
  509. <el-input placeholder="请输入报表名称"
  510. v-model="searchHistoryTxt"
  511. style="margin-left: 5px; width: 300px;"
  512. prefix-icon="el-icon-search">
  513. </el-input>
  514. <el-button type="primary" style="margin-left: 5px;" @click="searchHistoryReportEvent">查询</el-button>
  515. </div>
  516. <el-table
  517. :data="reportHistoryData" border :stripe="true"
  518. :header-cell-style="{background: '#E8E8E8'}"
  519. @sort-change="sortChange1"
  520. style="width: 100%; height: calc(100% - 100px); overflow: auto;">
  521. <el-table-column
  522. align="center"
  523. sortable="custom"
  524. label="报表名称"
  525. prop="reportTableName">
  526. <template slot-scope="scope">
  527. <span style="color: #409EFF; cursor: pointer;"
  528. @click="handleReportNodeClick(scope.row, 'history')"
  529. :title="scope.row.reportTableName">{{ scope.row.reportTableName }}</span>
  530. </template>
  531. </el-table-column>
  532. <!-- <el-table-column-->
  533. <!-- align="center"-->
  534. <!-- label="报表状态"-->
  535. <!-- prop="isAutoReport"-->
  536. <!-- width="180">-->
  537. <!-- <template slot-scope="scope">-->
  538. <!-- <el-tag v-if="scope.row.userId != uid" type="success" style="margin-right: 5px;">被分享</el-tag>-->
  539. <!-- <el-tag v-if="uid == scope.row.userId && scope.row.userGroupList && scope.row.userGroupList.length > 0"-->
  540. <!-- type="warning" style="margin-right: 5px;">已分享</el-tag>-->
  541. <!-- </template>-->
  542. <!-- </el-table-column>-->
  543. <!-- <el-table-column-->
  544. <!-- align="center"-->
  545. <!-- label="当前版本"-->
  546. <!-- sortable="custom"-->
  547. <!-- prop="version"-->
  548. <!-- width="120">-->
  549. <!-- </el-table-column>-->
  550. <el-table-column
  551. align="center"
  552. label="运行时间"
  553. sortable
  554. prop="createTime"
  555. width="200">
  556. </el-table-column>
  557. <el-table-column label="操作" align="center" width="300">
  558. <template slot-scope="scope">
  559. <el-button type="text"
  560. v-if="uid == scope.row.userId"
  561. size="small"
  562. icon="el-icon-delete"
  563. style="color: red;"
  564. @click="removeReportItem(scope.row, 'record')">删除
  565. </el-button>
  566. </template>
  567. </el-table-column>
  568. </el-table>
  569. <el-pagination
  570. style="margin-top: 20px;"
  571. background
  572. layout="sizes, prev, pager, next, total"
  573. :current-page="reportHistoryPage"
  574. :page-size="reportHistoryLimit"
  575. @size-change="sizeHistoryChangeEvent"
  576. @current-change="currentHistoryChangeEvent"
  577. :total="reportHistoryTotal">
  578. </el-pagination>
  579. </div>
  580. </el-dialog>
  581. <!-- 用户组用户人员查看 -->
  582. <el-dialog
  583. title="授权详情"
  584. width="600px"
  585. top="10vh"
  586. center
  587. v-dialog-drag
  588. v-if="dialogGroupUserVisible"
  589. :before-close="dialogGroupUserClose"
  590. :visible.sync="dialogGroupUserVisible"
  591. :close-on-click-modal="false"
  592. :append-to-body="true">
  593. <div style="height: 60vh;">
  594. <el-table
  595. :data="groupUserData" border :stripe="true"
  596. :header-cell-style="{background: '#E8E8E8'}"
  597. style="width: 100%; height: calc(100% - 50px); overflow: auto;">
  598. <el-table-column
  599. align="center"
  600. label="用户组名称"
  601. prop="userGroupName">
  602. </el-table-column>
  603. <el-table-column
  604. align="center"
  605. label="姓名"
  606. prop="userName">
  607. </el-table-column>
  608. </el-table>
  609. </div>
  610. </el-dialog>
  611. <div id="print-area"
  612. style="display: none;position: absolute;z-index: 0;top: 0;width: 100%;height: 100vh;overflow: hidden;">
  613. <div id="print-html" ref="printPayFeeNew"></div>
  614. </div>
  615. </div>
  616. </template>
  617. <script>
  618. import BreadcrumbView from '@/components/BreadcrumbView'
  619. import {
  620. customCompare,
  621. getLuckysheetConfig,
  622. getNowFormatDate, showAlertMsgWin,
  623. showAlertWin, showConfirmWin,
  624. showLoading, showPromptWin
  625. } from '@/utils/cqcy'
  626. import {
  627. delReportTableById,
  628. getAllDataModel,
  629. getAllOkReportTable,
  630. getAllTableTemplate,
  631. getAutoChReportTable,
  632. getChartData,
  633. getDataModelById,
  634. getReportTableById,
  635. getTableData,
  636. getTableTemplateById,
  637. getUserByGroupId, runAutoTableById,
  638. saveReport, setAutoTableTime,
  639. tableAssignUserById,
  640. tableExchangeTypeById,
  641. updateReportTable,
  642. updateTableNameById,
  643. getPrintByReportId,
  644. addPrint,
  645. stopAutoPrintById
  646. } from '@/api/datasource'
  647. import Print from 'print-js'
  648. import {getUsername} from '@/utils/auth'
  649. import {exportExcel} from '@/utils/export'
  650. import {getAllUserGroup} from "@/api/user";
  651. import {mapGetters} from "vuex";
  652. import {insertLuckysheetEChart} from "@/utils/luckysheettool";
  653. import cqcyCode from "@/utils/cqcyCode";
  654. export default {
  655. name: "index",
  656. components: {
  657. BreadcrumbView
  658. },
  659. computed: {
  660. ...mapGetters([
  661. 'name',
  662. 'uid'
  663. ])
  664. },
  665. data() {
  666. return {
  667. breadcrumbList: ['运行配置'],
  668. groupProps: {
  669. isLeaf: 'leaf'
  670. },
  671. reportDialogTitle: '新增报表',
  672. showMainView: false,
  673. chooseMyReport: null,
  674. chooseCurrMyReport: null,
  675. dialogReportTemplateVisible: false,
  676. dialogDownloadReportTypeVisible: false,
  677. dialogAutoReportVisible: false,
  678. dialogReportTypeVisible: false,
  679. dialogUserGroupVisible: false,
  680. dialogHistoryReportVisible: false,
  681. dialogGroupUserVisible: false,
  682. dialogAutoPrintVisible: false,
  683. reportType: '0',
  684. downloadType: '1',
  685. btnType: '',
  686. hasUserGroup: false,
  687. userGroupInfo: null,
  688. userGroupList: [],
  689. radioByCron: null,
  690. radioByCronValS: '',
  691. radioByCronValM: '',
  692. radioByCronValH: '',
  693. radioByCronValD: null,
  694. radioByCronValMo: '',
  695. radioByCronValMoD: null,
  696. cronVal: '',
  697. cronList: [],
  698. reportId: null,
  699. reportTemplateList: [],
  700. dataModelList: [],
  701. chooseReportTemplate: null,
  702. chooseReportTemplateId: null,
  703. chooseIsAutoReport: null,
  704. delFlag: 0,
  705. dateByRange: null,
  706. reportForm: {
  707. id: null,
  708. reportTableName: '',
  709. reportTableType: null,
  710. tableTemplateId: null,
  711. reportTableData: '',
  712. cronLabel: '',
  713. startTime: '',
  714. cron: ''
  715. },
  716. printDialogTitle: '打印任务配置',
  717. printForm: {
  718. id: null,
  719. reportTableId: null,
  720. cronId: '',
  721. cron: '',
  722. runState: null
  723. },
  724. searchValue: null,
  725. searchTxt: '',
  726. searchHistoryTxt: '',
  727. reportOptions: [{
  728. label: '所有报表',
  729. value: -1
  730. }, {
  731. label: '手动报表',
  732. value: 0
  733. }, {
  734. label: '自动报表',
  735. value: 1
  736. }, {
  737. label: '事件驱动报表',
  738. value: 2
  739. }],
  740. groupUserData: [],
  741. reportHistoryData: [],
  742. reportHistoryTotal: 0,
  743. reportHistoryPage: 1,
  744. reportHistoryLimit: 10,
  745. reportTotal: 0,
  746. reportPage: 1,
  747. reportLimit: 10,
  748. reportDataList: [],
  749. reportIntervalOptions: [5, 10, 15, 20, 25, 30],
  750. reportInterval: 30, // 手动报表更新数据频率
  751. reportIntervalTag: null,
  752. showReportTableType: null,
  753. reportRules: {
  754. reportTableName: [
  755. {required: true, message: '请输入报表名称', trigger: 'blur'}
  756. ],
  757. reportTableType: [
  758. {required: true, message: '请选择报表类型', trigger: 'change'}
  759. ],
  760. tableTemplateId: [
  761. {required: true, message: '请选择报表模板', trigger: 'change'}
  762. ]
  763. },
  764. luckysheetOption: {
  765. container: 'luckysheet', // 设定 DOM 容器的 id
  766. title: '报表模板', // 设定表格名称
  767. lang: 'zh', // 设定表格语言
  768. showinfobar: false, // 是否显示顶部信息栏
  769. showtoolbar: false, // 是否显示工具栏
  770. showtoolbarConfig: {
  771. paintFormat: true, //格式刷
  772. moreFormats: true, // 单元格格式
  773. font: true, // 字体
  774. fontSize: true, // 字号大小
  775. bold: true, // 粗体 (Ctrl+B)
  776. italic: true, // 斜体 (Ctrl+I)
  777. strikethrough: true, // 删除线 (Alt+Shift+5)
  778. underline: true, // 下划线 (Alt+Shift+6)
  779. textColor: true, // 文本颜色
  780. fillColor: true, // 单元格颜色
  781. border: true, // 边框
  782. mergeCell: true, // 合并单元格
  783. horizontalAlignMode: true, // 水平对齐方式
  784. verticalAlignMode: true, // 垂直对齐方式
  785. function: true, // 公式
  786. // image: true
  787. // chart: true
  788. },
  789. showsheetbar: false, // 是否显示底部 sheet 页按钮
  790. sheetFormulaBar: false, // 是否显示公式
  791. row: 120, // 是否显示底部 sheet 页按钮
  792. data: [{
  793. "name": "统计报表", //工作表名称
  794. }],
  795. cellRightClickConfig: { // 自定义配置单元格右击菜单
  796. copy: true, // 复制
  797. copyAs: false, // 复制为
  798. paste: true, // 粘贴
  799. insertRow: true, // 插入行
  800. insertColumn: true, // 插入列
  801. deleteRow: true, // 删除选中行
  802. deleteColumn: true, // 删除选中列
  803. deleteCell: false, // 删除单元格
  804. hideRow: false, // 隐藏选中行和显示选中行
  805. hideColumn: false, // 隐藏选中列和显示选中列
  806. rowHeight: true, // 行高
  807. columnWidth: true, // 列宽
  808. clear: false, // 清除内容
  809. matrix: false, // 矩阵操作选区
  810. sort: false, // 排序选区
  811. filter: false, // 筛选选区
  812. chart: true, // 图表生成
  813. image: false, // 插入图片
  814. link: false, // 插入链接
  815. data: false, // 数据验证
  816. cellFormat: false // 设置单元格格式
  817. },
  818. plugins: ['chart']
  819. }
  820. }
  821. },
  822. watch: {},
  823. beforeDestroy() {
  824. this.chooseMyReport = null
  825. this.chooseCurrMyReport = null
  826. },
  827. mounted() {
  828. let _this = this
  829. document.onkeyup = function (event) {
  830. let e = event || window.event || arguments.callee.caller.arguments[0]
  831. if (!e) return
  832. const {key, keyCode} = e
  833. if (keyCode === 46 || keyCode === 8) {
  834. _this.forceRefreshLuckysheet()
  835. }
  836. }
  837. },
  838. created() {
  839. luckysheet.destroy()
  840. this.loadReport()
  841. this.initCronList()
  842. },
  843. destroyed() {
  844. if (this.reportIntervalTag) clearInterval(this.reportIntervalTag)
  845. luckysheet.destroy()
  846. },
  847. methods: {
  848. reportIntervalChange(val) {
  849. this.reportInterval = val
  850. this.pollingReportData()
  851. },
  852. /** 实现类似刷新效果 */
  853. forceRefreshLuckysheet() {
  854. if (luckysheet) {
  855. luckysheet.setCellValue(49, 0, luckysheet.getCellValue(49, 0))
  856. }
  857. },
  858. sortChange({prop, order}) {
  859. this.reportDataList.sort(customCompare(prop, order))
  860. },
  861. sortChange1({prop, order}) {
  862. this.reportHistoryData.sort(customCompare(prop, order))
  863. },
  864. handleSizeChange(val) {
  865. this.reportPage = 1
  866. this.reportLimit = val
  867. this.loadReport()
  868. },
  869. handleCurrentChange(val) {
  870. this.reportPage = val
  871. this.loadReport()
  872. },
  873. sizeHistoryChangeEvent(val) {
  874. this.reportHistoryPage = 1
  875. this.reportHistoryLimit = val
  876. this.historyReport()
  877. },
  878. currentHistoryChangeEvent(val) {
  879. this.reportHistoryPage = val
  880. this.historyReport()
  881. },
  882. searchHistoryReportEvent() {
  883. this.reportHistoryPage = 1
  884. this.historyReport()
  885. },
  886. changeReportTypeEvent(val) {
  887. this.reportPage = 1
  888. this.searchValue = val
  889. this.loadReport()
  890. },
  891. searchReportEvent() {
  892. this.reportPage = 1
  893. this.loadReport()
  894. },
  895. /** 验证CRON是否正确 */
  896. validCron(value) {
  897. const cronParse = require('cron-parser')
  898. try {
  899. const interval = cronParse.parseExpression(value)
  900. console.log('cronDate:', interval.next().toDate())
  901. return true
  902. } catch (e) {
  903. }
  904. return false
  905. },
  906. /** 解析数据运行表达式 */
  907. analysisCron(val) {
  908. if (!val) return
  909. let s = val.split(' ')
  910. if (s[0].indexOf('/') > -1) {
  911. this.radioByCron = 1
  912. this.radioByCronValS = parseInt(s[0].split('/')[1])
  913. } else if (s[1].indexOf('/') > -1) {
  914. this.radioByCron = 2
  915. this.radioByCronValM = parseInt(s[1].split('/')[1])
  916. } else if (s[2].indexOf('/') > -1) {
  917. this.radioByCron = 3
  918. this.radioByCronValH = parseInt(s[2].split('/')[1])
  919. } else if (s[3] === '*') {
  920. this.radioByCron = 4
  921. this.radioByCronValD = s[2] + ':' + s[1] + ':' + s[0]
  922. } else {
  923. this.radioByCron = 5
  924. this.radioByCronValMo = parseInt(s[3])
  925. this.radioByCronValMoD = s[2] + ':' + s[1] + ':' + s[0]
  926. }
  927. },
  928. /** 获取自动报表运行表达式 */
  929. getCron() {
  930. let result = null
  931. switch (this.radioByCron) {
  932. // 按每秒执行:0/2 * * * * ?
  933. case 1:
  934. if (Number.isInteger(this.radioByCronValS)) {
  935. result = '0/#{cron} * * * * ?'
  936. result = result.replace('#{cron}', this.radioByCronValS)
  937. }
  938. break
  939. // 按每分钟执行:0 0/2 * * * ?
  940. case 2:
  941. if (Number.isInteger(this.radioByCronValM)) {
  942. result = '0 0/#{cron} * * * ?'
  943. result = result.replace('#{cron}', this.radioByCronValM)
  944. }
  945. break
  946. // 按每小时执行:0 0 0/2 * * ?
  947. case 3:
  948. if (Number.isInteger(this.radioByCronValH)) {
  949. result = '0 0 0/#{cron} * * ?'
  950. result = result.replace('#{cron}', this.radioByCronValH)
  951. }
  952. break
  953. // 每天定时执行:0 15 10 * * ?
  954. case 4:
  955. if (this.radioByCronValD) {
  956. let times = this.radioByCronValD.split(':')
  957. result = '#{cron1} #{cron2} #{cron3} * * ?'
  958. result = result.replace('#{cron1}', times[2])
  959. result = result.replace('#{cron2}', times[1])
  960. result = result.replace('#{cron3}', times[0])
  961. result = result.replace(/00/g, '0')
  962. }
  963. break
  964. // 每月定时执行:0 0 2 1 * ?
  965. case 5:
  966. if (Number.isInteger(this.radioByCronValMo) && this.radioByCronValMoD) {
  967. let times = this.radioByCronValMoD.split(':')
  968. result = '#{cron1} #{cron2} #{cron3} #{cron4} * ?'
  969. result = result.replace('#{cron1}', times[2])
  970. result = result.replace('#{cron2}', times[1])
  971. result = result.replace('#{cron3}', times[0])
  972. result = result.replace('#{cron4}', this.radioByCronValMo)
  973. result = result.replace(/00/g, '0')
  974. }
  975. break
  976. default:
  977. break
  978. }
  979. return result
  980. },
  981. /** 获取自动报表运行表达式名称 */
  982. getCronLabel() {
  983. let result = null
  984. switch (this.radioByCron) {
  985. // 按每秒执行:0/2 * * * * ?
  986. case 1:
  987. if (Number.isInteger(this.radioByCronValS)) {
  988. result = '每#{cron}秒执行一次'
  989. result = result.replace('#{cron}', this.radioByCronValS)
  990. }
  991. break
  992. // 按每分钟执行:0 0/2 * * * ?
  993. case 2:
  994. if (Number.isInteger(this.radioByCronValM)) {
  995. result = '每#{cron}分钟执行一次'
  996. result = result.replace('#{cron}', this.radioByCronValM)
  997. }
  998. break
  999. // 按每小时执行:0 0 0/2 * * ?
  1000. case 3:
  1001. if (Number.isInteger(this.radioByCronValH)) {
  1002. result = '每#{cron}小时执行一次'
  1003. result = result.replace('#{cron}', this.radioByCronValH)
  1004. }
  1005. break
  1006. // 每天定时执行:0 15 10 * * ?
  1007. case 4:
  1008. if (this.radioByCronValD) {
  1009. let times = this.radioByCronValD.split(':')
  1010. result = '每天#{cron3}:#{cron2}:#{cron1}执行一次'
  1011. result = result.replace('#{cron1}',
  1012. (times[2].length < 2 && parseInt(times[2]) < 10) ? ('0' + times[2]) : times[2])
  1013. result = result.replace('#{cron2}',
  1014. (times[1].length < 2 && parseInt(times[1]) < 10) ? ('0' + times[1]) : times[1])
  1015. result = result.replace('#{cron3}',
  1016. (times[0].length < 2 && parseInt(times[0]) < 10) ? ('0' + times[0]) : times[0])
  1017. // result = result.replace(/00/g, '0')
  1018. }
  1019. break
  1020. // 每月定时执行:0 0 2 1 * ?
  1021. case 5:
  1022. if (Number.isInteger(this.radioByCronValMo) && this.radioByCronValMoD) {
  1023. let times = this.radioByCronValMoD.split(':')
  1024. result = '每月#{cron4}号的#{cron3}:#{cron2}:#{cron1}执行一次'
  1025. result = result.replace('#{cron1}',
  1026. (times[2].length < 2 && parseInt(times[2]) < 10) ? ('0' + times[2]) : times[2])
  1027. result = result.replace('#{cron2}',
  1028. (times[1].length < 2 && parseInt(times[1]) < 10) ? ('0' + times[1]) : times[1])
  1029. result = result.replace('#{cron3}',
  1030. (times[0].length < 2 && parseInt(times[0]) < 10) ? ('0' + times[0]) : times[0])
  1031. result = result.replace('#{cron4}', this.radioByCronValMo)
  1032. // result = result.replace(/00/g, '0')
  1033. }
  1034. break
  1035. default:
  1036. break
  1037. }
  1038. return result
  1039. },
  1040. /** 选择定时任务表达式 */
  1041. chooseCronEvent() {
  1042. if (!this.getCron()) {
  1043. showAlertMsgWin(this, null, '请指定定时任务类型或运行时间!')
  1044. return
  1045. }
  1046. this.reportForm.cron = this.getCron()
  1047. this.reportForm.cronLabel = this.getCronLabel()
  1048. if (!this.validCron(this.reportForm.cron)) {
  1049. showAlertMsgWin(this, null, '定时任务表达式格式不正确!')
  1050. return
  1051. }
  1052. this.dialogAutoReportVisible = false
  1053. },
  1054. resetRadioVal() {
  1055. this.radioByCron = null
  1056. this.radioByCronValS = ''
  1057. this.radioByCronValM = ''
  1058. this.radioByCronValH = ''
  1059. this.radioByCronValD = null
  1060. this.radioByCronValMo = ''
  1061. this.radioByCronValMoD = null
  1062. this.cronVal = ''
  1063. },
  1064. chooseReportTypeEvent() {
  1065. if (!this.reportType) {
  1066. showAlertMsgWin(this, null, '请选择报表类型!')
  1067. return
  1068. }
  1069. // 自动报表
  1070. if (this.reportType == '1') {
  1071. this.resetRadioVal()
  1072. getReportTableById(this.reportId).then(res => {
  1073. this.dialogAutoReportVisible = true
  1074. this.cronVal = res.data.cron
  1075. this.analysisCron(this.cronVal)
  1076. }).catch((e) => {
  1077. showAlertWin(this, null, e)
  1078. })
  1079. return
  1080. }
  1081. const loading = showLoading(this, '请稍候···')
  1082. let params = {
  1083. 'id': this.reportId,
  1084. 'isAutoReport': this.reportType
  1085. }
  1086. tableExchangeTypeById(params).then(res => {
  1087. loading.close()
  1088. this.dialogClose()
  1089. this.loadReport()
  1090. }).catch((e) => {
  1091. loading.close()
  1092. showAlertWin(this, null, e)
  1093. })
  1094. },
  1095. switchChangeEvent(val, data) {
  1096. this.reportId = data.id
  1097. if (val) {
  1098. this.resetRadioVal()
  1099. this.dialogAutoReportVisible = true
  1100. getReportTableById(data.id).then(res => {
  1101. this.cronVal = res.data.cron
  1102. this.analysisCron(this.cronVal)
  1103. }).catch((e) => {
  1104. showAlertWin(this, null, e)
  1105. })
  1106. return
  1107. }
  1108. this.dialogReportTypeVisible = true
  1109. },
  1110. /** 修改自动报表运行状态 */
  1111. setReportStatus(data) {
  1112. let status = data.runState == 0 ? '启动' : '停止'
  1113. let tips = '您确定要' + status + '该报表吗?'
  1114. showConfirmWin(this, null, tips, () => {
  1115. const loading = showLoading(this, status + '中,请稍候···')
  1116. let params = {
  1117. 'id': data.id,
  1118. 'runState': data.runState == 0 ? 1 : 0
  1119. }
  1120. runAutoTableById(params).then(res => {
  1121. loading.close()
  1122. let msg = res.data ? status + '成功!' : status + '失败!'
  1123. showAlertMsgWin(this, null, msg)
  1124. this.reportPage = 1
  1125. this.loadReport()
  1126. }).catch((e) => {
  1127. loading.close()
  1128. showAlertWin(this, null, e)
  1129. })
  1130. })
  1131. },
  1132. /** 初始化报表信息 */
  1133. resetReportFormVal() {
  1134. this.reportForm = {
  1135. id: null,
  1136. reportTableName: '',
  1137. reportTableType: null,
  1138. tableTemplateId: null,
  1139. reportTableData: '',
  1140. cronLabel: '',
  1141. startTime: '',
  1142. cron: ''
  1143. }
  1144. this.dateByRange = null
  1145. },
  1146. /** 报表类型更改事件 */
  1147. changeReportType() {
  1148. this.reportForm.tableTemplateId = null
  1149. this.getAllReportTemplate(this.reportForm.reportTableType)
  1150. },
  1151. /** 新增报表 */
  1152. addReportEvent() {
  1153. this.resetReportFormVal()
  1154. this.reportDialogTitle = '新增报表'
  1155. this.dialogReportTemplateVisible = true
  1156. },
  1157. /** 刷新报表 */
  1158. refreshReportEvent() {
  1159. this.reportPage = 1
  1160. this.loadReport()
  1161. },
  1162. /** 设置自动报表运行时间 */
  1163. settingAutoReportTime() {
  1164. if (this.reportForm.cron) {
  1165. this.analysisCron(this.reportForm.cron)
  1166. } else {
  1167. this.resetRadioVal()
  1168. }
  1169. this.dialogAutoReportVisible = true
  1170. },
  1171. /** 模版报表选择 */
  1172. chooseReportEvent() {
  1173. // 判断是否自动报表
  1174. // if (this.reportForm.reportTableType == 1 && this.dateByRange.length == 0) {
  1175. // showAlertMsgWin(this, null, '请选择时间范围!')
  1176. // return
  1177. // }
  1178. if (this.reportForm.reportTableType == 1 && !this.reportForm.startTime) {
  1179. showAlertMsgWin(this, null, '请选择开始时间!')
  1180. return
  1181. }
  1182. if (this.reportForm.reportTableType == 1 && !this.reportForm.cron) {
  1183. showAlertMsgWin(this, null, '请设置自动报表运行时间!')
  1184. return
  1185. }
  1186. this.$refs['reportForm'].validate((valid) => {
  1187. if (valid) {
  1188. const loading = showLoading(this, '数据加载中,请稍候···')
  1189. getTableTemplateById(this.reportForm.tableTemplateId).then(res => {
  1190. if (!res.data) {
  1191. loading.close()
  1192. showAlertMsgWin(this, null, '选择的报表模板不存在!')
  1193. return
  1194. }
  1195. let luckyData = JSON.parse(res.data.templateData)
  1196. if (this.reportForm.id) {
  1197. this.updateReportInfo(loading, luckyData)
  1198. } else {
  1199. this.saveReportInfo(loading, luckyData)
  1200. }
  1201. }).catch((e) => {
  1202. loading.close()
  1203. showAlertWin(this, null, e)
  1204. })
  1205. }
  1206. })
  1207. },
  1208. /** 根据 ID 查询数据模型 */
  1209. getDataModelById(loading, reportData) {
  1210. if (!loading) {
  1211. loading = showLoading(this, '数据加载中,请稍候···')
  1212. }
  1213. getDataModelById(this.reportForm.operationRule).then(res => {
  1214. loading.close()
  1215. if (!res.data) {
  1216. showAlertMsgWin(this, null, '选择的四则运算表达式不存在!')
  1217. return
  1218. }
  1219. let luckyData = JSON.parse(reportData.templateData)
  1220. this.drawLuckyExcel(luckyData)
  1221. this.btnType = 'add'
  1222. this.dialogReportTemplateVisible = false
  1223. }).catch((e) => {
  1224. loading.close()
  1225. showAlertWin(this, null, e)
  1226. })
  1227. },
  1228. /** 绘制 Excel 表 */
  1229. drawLuckyExcel(luckyData, callback) {
  1230. let _this = this
  1231. luckysheet.destroy()
  1232. let option = luckyData.option
  1233. option.data = luckyData.data
  1234. let charts = luckyData.charts
  1235. let tables = luckyData.tables
  1236. option.hook = {
  1237. workbookCreateAfter() {
  1238. console.log(luckyData)
  1239. for (let i in charts) {
  1240. _this.insertEChartInfo(charts[i])
  1241. }
  1242. for (let i in tables) {
  1243. _this.insertTableInfo(tables[i])
  1244. }
  1245. _this.drawBaseInfo()
  1246. if (callback) {
  1247. callback()
  1248. }
  1249. },
  1250. cellUpdated(r, c, newV, oldV) {
  1251. if (!(r === 49 && c === 0)) {
  1252. _this.forceRefreshLuckysheet()
  1253. }
  1254. }
  1255. }
  1256. luckysheet.create(option)
  1257. },
  1258. /** 获取图表数据 */
  1259. getChartData(data, callback) {
  1260. getChartData(data).then(res => {
  1261. if (!res.data) {
  1262. if (callback) callback([])
  1263. return
  1264. }
  1265. if (callback) callback(res.data)
  1266. }).catch((e) => {
  1267. if (callback) callback([])
  1268. showAlertWin(this, null, e)
  1269. })
  1270. },
  1271. /** 获取表格数据 */
  1272. getTableData(data, callback) {
  1273. getTableData(data).then(res => {
  1274. if (!res.data) {
  1275. if (callback) callback([])
  1276. return
  1277. }
  1278. if (callback) callback(res.data)
  1279. }).catch((e) => {
  1280. if (callback) callback([])
  1281. showAlertWin(this, null, e)
  1282. })
  1283. },
  1284. /** 向 Excel 插入表格 */
  1285. insertTableInfo(tableData) {
  1286. let params = []
  1287. let itemList = tableData.item
  1288. for (let i in itemList) {
  1289. let temp = itemList[i]
  1290. params.push({
  1291. 'itemGroupId': temp.itemGroupId,
  1292. 'itemName': temp.itemName
  1293. })
  1294. }
  1295. let p = {
  1296. 'reportValueFormat': this.reportForm.reportValueFormat,
  1297. 'valueCondition': this.reportForm.valueCondition,
  1298. 'tableDataDtoChList': params,
  1299. 'showType': tableData.showType
  1300. }
  1301. if (this.reportForm.reportDate && this.reportForm.reportDate.length > 0) {
  1302. p.startBelongTime = this.reportForm.reportDate[0]
  1303. p.endBelongTime = this.reportForm.reportDate[1]
  1304. } else {
  1305. p.startBelongTime = getNowFormatDate('yyyy-MM-dd') + ' 08:00:00'
  1306. p.endBelongTime = getNowFormatDate('yyyy-MM-dd') + ' 18:00:00'
  1307. }
  1308. this.getTableData(p, (res) => {
  1309. // console.log('option==>', luckysheet.getAllSheets()[0])
  1310. // console.log('table1==>', res)
  1311. // const optionData = packtable(res, luckysheet.getAllSheets()[0])
  1312. // console.log('table2==>', optionData)
  1313. setTimeout(() => {
  1314. // this.drawTableData(res, p.showType, luckysheet.getAllSheets()[0])
  1315. }, 500)
  1316. })
  1317. },
  1318. /** 初始化表格基础数据项值 */
  1319. initBaseInfoData(data) {
  1320. let currDate = getNowFormatDate('yyyy-MM-dd')
  1321. let currDateTime = getNowFormatDate('yyyy-MM-dd HH:mm:ss')
  1322. data.baseItem = {
  1323. 'currDate': currDate,
  1324. 'currDateTime': currDateTime,
  1325. 'userName': getUsername(),
  1326. 'winUserName': process.env.VUE_APP_WINNAME
  1327. }
  1328. return data
  1329. },
  1330. /** 绘制基础数据项布局信息 */
  1331. drawBaseInfo(baseData) {
  1332. if (!baseData) {
  1333. baseData = {
  1334. 'currDate': getNowFormatDate('yyyy-MM-dd'),
  1335. 'currDateTime': getNowFormatDate('yyyy-MM-dd HH:mm:ss'),
  1336. 'userName': getUsername(),
  1337. 'winUserName': process.env.VUE_APP_WINNAME
  1338. }
  1339. }
  1340. let option = luckysheet.getAllSheets()[0]
  1341. option.celldata.map(item => {
  1342. if (item.v.v) {
  1343. item.v.v = String(item.v.v).trim()
  1344. if (item.v.v.match(/\${([^}]+)}/g)) { // 替换${xxx}内部数据
  1345. if (item.v.v.indexOf('${currDate}') > -1) {
  1346. let val = item.v.v
  1347. val = val.replace('${currDate}', baseData.currDate)
  1348. luckysheet.setCellValue(item.r, item.c, val)
  1349. }
  1350. if (item.v.v.indexOf('${currDateTime}') > -1) {
  1351. let val = item.v.v
  1352. val = val.replace('${currDateTime}', baseData.currDateTime)
  1353. luckysheet.setCellValue(item.r, item.c, val)
  1354. }
  1355. if (item.v.v.indexOf('${userName}') > -1) {
  1356. let val = item.v.v
  1357. val = val.replace('${userName}', baseData.userName)
  1358. luckysheet.setCellValue(item.r, item.c, val)
  1359. }
  1360. if (item.v.v.indexOf('${winUserName}') > -1) {
  1361. let val = item.v.v
  1362. val = val.replace('${winUserName}', baseData.winUserName)
  1363. luckysheet.setCellValue(item.r, item.c, val)
  1364. }
  1365. }
  1366. }
  1367. })
  1368. },
  1369. /** 绘制表格数据 */
  1370. drawTableData(tableItemList, type) {
  1371. if (!tableItemList || tableItemList.length == 0) return
  1372. // 事件驱动报表
  1373. if (type == 2 || type == 4) {
  1374. tableItemList.forEach((tableItem, i) => {
  1375. if (i == 0) {
  1376. let valueTimeList = tableItem.valueTimeList ? tableItem.valueTimeList.split(',') : []
  1377. let xAxis = tableItem.xaxis
  1378. let yAxis = tableItem.yaxis - 1
  1379. if (valueTimeList.length == 0) {
  1380. luckysheet.setCellValue(xAxis, yAxis, '')
  1381. } else {
  1382. valueTimeList.forEach((v, j) => {
  1383. luckysheet.setCellValue(xAxis + j, yAxis, v)
  1384. })
  1385. }
  1386. }
  1387. let valueList = tableItem.valueList ? tableItem.valueList.split(',') : []
  1388. let xAxis = tableItem.xaxis
  1389. let yAxis = tableItem.yaxis
  1390. if (valueList.length == 0) {
  1391. luckysheet.setCellValue(xAxis, yAxis, '')
  1392. } else {
  1393. valueList.forEach((v, j) => {
  1394. luckysheet.setCellValue(xAxis + j, yAxis, v)
  1395. })
  1396. }
  1397. })
  1398. return
  1399. }
  1400. // 其余报表信息
  1401. tableItemList.forEach((tableItem, i) => {
  1402. let standby = tableItem.standby ? JSON.parse(tableItem.standby) : {}
  1403. let dataIndex = standby.index != null ? standby.index : -1
  1404. let valueList = tableItem.valueList ? tableItem.valueList.split(',') : []
  1405. let val = (dataIndex == -1 || (dataIndex + 1) > valueList.length)
  1406. ? cqcyCode['invalidData'] : valueList[dataIndex]
  1407. let xAxis = tableItem.xaxis
  1408. let yAxis = tableItem.yaxis
  1409. try {
  1410. luckysheet.setCellValue(xAxis, yAxis, val)
  1411. } catch (e) {
  1412. console.warn(e)
  1413. }
  1414. })
  1415. },
  1416. /** 向 Excel 插入图表 */
  1417. insertEChartInfo(chart) {
  1418. let _self = this
  1419. let info = JSON.parse(chart.standby)
  1420. let reportChartItemList = chart.reportChartItemList
  1421. let chartType = chart.chartType
  1422. // 系列
  1423. let series = info.option.series
  1424. for (let i in series) {
  1425. let temp = series[i]
  1426. temp.data = []
  1427. for (let j in reportChartItemList) {
  1428. let _name = reportChartItemList[j].describe ? reportChartItemList[j].describe : reportChartItemList[j].itemName
  1429. if (chartType == 'pie') {
  1430. temp.name = _name
  1431. temp.data.push({
  1432. 'name': _name,
  1433. 'value': reportChartItemList[j].valueList
  1434. })
  1435. } else {
  1436. let _t = []
  1437. let t = reportChartItemList[i].valueList ? reportChartItemList[i].valueList.split(',') : []
  1438. t.forEach((temp) => {
  1439. _t.push(parseFloat(temp))
  1440. })
  1441. temp.data = _t
  1442. }
  1443. }
  1444. }
  1445. if (chartType != 'pie') {
  1446. // x 轴
  1447. let xAxis = info.option.xAxis
  1448. let legend = info.option.legend
  1449. // xAxis.data = []
  1450. legend.data = []
  1451. let axisLabel = {};
  1452. axisLabel.rotate = 20;
  1453. xAxis.axisLabel = axisLabel
  1454. xAxis.data = (reportChartItemList && reportChartItemList.length > 0) ?
  1455. ((reportChartItemList[0].valueTimeList) ? reportChartItemList[0].valueTimeList.split(",") : []) : []
  1456. // xAxis.data = xAxis.data.slice(0, 7)
  1457. for (let i in reportChartItemList) {
  1458. let name = reportChartItemList[i].describe ? reportChartItemList[i].describe : reportChartItemList[i].itemName
  1459. // xAxis.data.push(name)
  1460. legend.data.push(name)
  1461. }
  1462. }
  1463. console.log(chartType, info)
  1464. setTimeout(() => {
  1465. const sheet = luckysheet.getLuckysheetfile()[0]
  1466. let optionData = sheet.data
  1467. let elements = document.getElementsByClassName(info.className);
  1468. for (let i = 0; i < elements.length; i++) {
  1469. elements[i].parentNode.removeChild(elements[i]);
  1470. }
  1471. try {
  1472. let flag = true
  1473. insertLuckysheetEChart({
  1474. selector: '#luckysheet',
  1475. info,
  1476. sheet,
  1477. optionData,
  1478. echarts,
  1479. luckysheet,
  1480. $,
  1481. _self,
  1482. flag
  1483. })
  1484. } catch (e) {
  1485. console.log(999, e == 'echarts is not defined')
  1486. console.error(e)
  1487. }
  1488. }, 200)
  1489. },
  1490. /** 查询所有报表模板信息 */
  1491. getAllReportTemplate(templateType) {
  1492. const loading = showLoading(this, '数据加载中,请稍候···')
  1493. let params = {
  1494. 'page': 1,
  1495. 'limit': 1000
  1496. }
  1497. if (templateType != null) {
  1498. params.templateType = templateType
  1499. }
  1500. getAllTableTemplate(params).then(res => {
  1501. loading.close()
  1502. if (!res.data) {
  1503. return
  1504. }
  1505. this.reportTemplateList = res.data.tableTemplateList
  1506. }).catch((e) => {
  1507. loading.close()
  1508. showAlertWin(this, null, e)
  1509. })
  1510. },
  1511. /** 查询所有数据模型 */
  1512. getAllDataModel() {
  1513. let params = {
  1514. 'page': 1,
  1515. 'limit': 1000
  1516. }
  1517. getAllDataModel(params).then(res => {
  1518. if (!res.data) {
  1519. return
  1520. }
  1521. this.dataModelList = res.data.dataModelList
  1522. }).catch((e) => {
  1523. showAlertWin(this, null, e)
  1524. })
  1525. },
  1526. /** 查询我的报表列表 */
  1527. loadReport() {
  1528. const loading = showLoading(this, '加载中,请稍候···')
  1529. let params = {
  1530. 'page': this.reportPage,
  1531. 'limit': this.reportLimit
  1532. }
  1533. if (this.searchValue != '-1') {
  1534. params.isAutoReport = this.searchValue
  1535. }
  1536. if (this.searchTxt && this.searchTxt.trim()) {
  1537. params.reportTableName = this.searchTxt
  1538. }
  1539. params.isDelete = 0
  1540. getAllOkReportTable(params).then(res => {
  1541. loading.close()
  1542. if (!res || !res.data) {
  1543. return
  1544. }
  1545. this.reportTotal = res.data.count
  1546. this.reportDataList = res.data.reportTableList
  1547. }).catch((e) => {
  1548. loading.close()
  1549. showAlertWin(this, null, e)
  1550. })
  1551. },
  1552. /** 设置自动打印 */
  1553. setAutoPrint(data) {
  1554. this.resetPrint();
  1555. const loading = showLoading(this, '设置中,请稍候···')
  1556. this.printForm.reportTableId = data.id;
  1557. getPrintByReportId(data.id).then(res => {
  1558. loading.close()
  1559. if (res.data) {
  1560. this.printForm.id = res.data.id;
  1561. this.printForm.cronId = res.data.cronId;
  1562. this.printForm.cron = res.data.cron;
  1563. this.printForm.runState = res.data.runState;
  1564. this.analysisCron(res.data.cron)
  1565. }
  1566. this.dialogAutoPrintVisible = true
  1567. }).catch((e) => {
  1568. loading.close()
  1569. })
  1570. },
  1571. resetPrint() {
  1572. this.printForm.id = null;
  1573. this.printForm.reportTableId = null;
  1574. this.printForm.cronId = '';
  1575. this.printForm.cron = '';
  1576. this.printForm.runState = null;
  1577. },
  1578. /** 选择定时打印 */
  1579. chooseCronPrint() {
  1580. if (!this.getCron()) {
  1581. showAlertMsgWin(this, null, '请指定定时任务类型或运行时间!')
  1582. return
  1583. }
  1584. this.printForm.cron = this.getCron();
  1585. if (!this.validCron(this.printForm.cron)) {
  1586. showAlertMsgWin(this, null, '定时任务表达式格式不正确!')
  1587. return
  1588. }
  1589. addPrint(this.printForm).then(res => {
  1590. let msg = res.data ? '配置成功!' : '配置失败!'
  1591. showAlertMsgWin(this, null, msg)
  1592. this.showMainView = false
  1593. this.dialogAutoPrintVisible = false;
  1594. }).catch(e => {
  1595. showAlertWin(this, null, e)
  1596. })
  1597. },
  1598. /** 停止打印 */
  1599. stopAutoPrint() {
  1600. console.log(this.printForm.reportTableId)
  1601. stopAutoPrintById(this.printForm.reportTableId).then(res => {
  1602. showAlertWin(this, null, res.data)
  1603. if (res.code == 200) {
  1604. this.dialogAutoPrintVisible = false;
  1605. }
  1606. }).catch(e => {
  1607. showAlertWin(this, null, e)
  1608. })
  1609. },
  1610. /** 设置用户组信息 */
  1611. setUserGroupEvent(data) {
  1612. if (data.userId != this.uid) {
  1613. showAlertMsgWin(this, null, '您没有权限进行设置!')
  1614. return
  1615. }
  1616. this.reportId = data.id
  1617. this.dialogUserGroupVisible = true
  1618. getAllUserGroup().then(res => {
  1619. this.$nextTick(() => {
  1620. this.userGroupList = res.data
  1621. // this.userGroupInfo = data.userGroupList
  1622. this.userGroupInfo = []
  1623. for (let i = 0; i < data.userGroupList.length; i++) {
  1624. this.userGroupInfo.push(data.userGroupList[i].id)
  1625. }
  1626. if (data.userGroupList && data.userGroupList.length > 0) {
  1627. this.hasUserGroup = true
  1628. }
  1629. })
  1630. }).catch((e) => {
  1631. showAlertWin(this, null, e)
  1632. })
  1633. },
  1634. getUserGroupEvent(data) {
  1635. this.groupUserData = []
  1636. if (!data.userGroupList || data.userGroupList.length == 0) {
  1637. showAlertMsgWin(this, null, '该报表还未进行授权操作!')
  1638. return
  1639. }
  1640. let _this = this
  1641. data.userGroupList.forEach((group) => {
  1642. getUserByGroupId(group.id).then(res => {
  1643. let users = res.data
  1644. users.forEach((u) => {
  1645. _this.groupUserData.push({
  1646. 'userGroupName': group.userGroupName,
  1647. 'userName': u.userName
  1648. })
  1649. })
  1650. }).catch((e) => {
  1651. showAlertWin(_this, null, e)
  1652. })
  1653. })
  1654. this.dialogGroupUserVisible = true
  1655. },
  1656. chooseUserGroupEvent() {
  1657. // if (!this.userGroupInfo) {
  1658. // this.$message({
  1659. // message: '请选择用户组!',
  1660. // type: 'warning'
  1661. // })
  1662. // return
  1663. // }
  1664. let params = {
  1665. 'id': this.reportId,
  1666. 'userGroupList': []
  1667. }
  1668. for (let i = 0; i < this.userGroupInfo.length; i++) {
  1669. params.userGroupList.push({
  1670. 'id': this.userGroupInfo[i]
  1671. })
  1672. }
  1673. tableAssignUserById(params).then(res => {
  1674. if (this.hasUserGroup || this.userGroupInfo) {
  1675. showAlertMsgWin(this, null, '保存成功!')
  1676. this.hasUserGroup = false
  1677. }
  1678. this.dialogClose()
  1679. this.loadReport()
  1680. }).catch((e) => {
  1681. showAlertWin(this, null, e)
  1682. })
  1683. },
  1684. /** 处理自动报表数据信息 */
  1685. drawAutoReportData(datas) {
  1686. if (!datas || datas.length == 0) {
  1687. return
  1688. }
  1689. datas.forEach((data) => {
  1690. if (!data || !data.item) {
  1691. return
  1692. }
  1693. let showInfo = data.showType
  1694. let fieldList = data.field
  1695. data.item.forEach((item, i) => {
  1696. if (!item || !item.dataList) {
  1697. return
  1698. }
  1699. let itemName = item.itemName
  1700. itemName = itemName.substring(itemName.lastIndexOf('.') + 1)
  1701. let tempName = '${' + item.itemGroupId + '.' + itemName + '.' + showInfo.dataId + '}'
  1702. let p_r, p_c
  1703. if (fieldList[i] && tempName == fieldList[i].name) {
  1704. p_r = parseInt(fieldList[i].r)
  1705. p_c = parseInt(fieldList[i].c)
  1706. } else {
  1707. for (let n = 0; n < fieldList.length; n++) {
  1708. if (fieldList[n].name == tempName) {
  1709. p_r = parseInt(fieldList[n].r)
  1710. p_c = parseInt(fieldList[n].c)
  1711. break
  1712. }
  1713. }
  1714. }
  1715. // 数据信息
  1716. let dataList = item.dataList
  1717. for (let j = 0; j < showInfo.valLine; j++) {
  1718. let c = p_c
  1719. let r = p_r
  1720. if (showInfo.valType == '2') r += j
  1721. else c += j
  1722. luckysheet.setCellValue(r, c, (dataList[j] != null && dataList[j] != undefined) ? (dataList[j] + '') : cqcyCode['invalidData'])
  1723. }
  1724. })
  1725. })
  1726. },
  1727. /** 报表点击事件 */
  1728. handleReportNodeClick(data, type) {
  1729. if (data.id == -1 || this.delFlag == 1) {
  1730. return
  1731. }
  1732. const loading = showLoading(this, '加载中,请稍候···')
  1733. getReportTableById(data.id).then(res => {
  1734. let _data = res.data
  1735. if (!_data) {
  1736. loading.close()
  1737. showAlertMsgWin(this, null, '选择的报表不存在!')
  1738. return
  1739. }
  1740. this.showMainView = true
  1741. this.breadcrumbList = [_data.reportTableName]
  1742. this.chooseCurrMyReport = _data
  1743. // 判断是否运行记录
  1744. if (type === 'history') {
  1745. this.dialogHistoryReportVisible = false
  1746. this.btnType = 'showChild'
  1747. } else {
  1748. this.chooseMyReport = res.data
  1749. this.btnType = 'showShared'
  1750. }
  1751. this.setLuckysheetStatus(_data, true, type, loading)
  1752. // 手动报表,循环查询数据
  1753. this.showReportTableType = _data.reportTableType
  1754. this.pollingReportData()
  1755. }).catch((e) => {
  1756. loading.close()
  1757. showAlertWin(this, null, e)
  1758. })
  1759. },
  1760. /** 轮询更新报表数据 */
  1761. pollingReportData() {
  1762. if (this.reportIntervalTag) clearInterval(this.reportIntervalTag)
  1763. if (this.showReportTableType == 0 || this.showReportTableType == 1) {
  1764. this.reportIntervalTag = setInterval(() => {
  1765. this.reloadReportNode()
  1766. }, this.reportInterval * 1000)
  1767. }
  1768. },
  1769. /** 报表reload事件 */
  1770. reloadReportNode() {
  1771. if (!this.chooseMyReport || !this.chooseMyReport.id) {
  1772. if (this.reportIntervalTag) clearInterval(this.reportIntervalTag)
  1773. return
  1774. }
  1775. const loading = showLoading(this, '加载中,请稍候···')
  1776. getReportTableById(this.chooseMyReport.id).then(res => {
  1777. let _data = res.data
  1778. if (!_data) {
  1779. loading.close()
  1780. // if (this.reportIntervalTag) clearInterval(this.reportIntervalTag)
  1781. return
  1782. }
  1783. this.chooseCurrMyReport = _data
  1784. this.chooseMyReport = res.data
  1785. // this.setLuckysheetStatus(_data, true, '', loading)
  1786. // 报表数据
  1787. let reportTableData = _data.reportTableData
  1788. let luckyData = JSON.parse(reportTableData)
  1789. // 基础数据项值
  1790. let baseItem = luckyData.baseItem
  1791. // 数据项
  1792. let reportTableItemList = _data.reportTableItemList
  1793. let reportChartList = _data.reportChartList
  1794. // 报表类型
  1795. let reportTableType = _data.reportTableType
  1796. for (let i in reportChartList) {
  1797. this.insertEChartInfo(reportChartList[i])
  1798. }
  1799. // 绘制基础数据项
  1800. this.drawBaseInfo(baseItem)
  1801. // 绘制数据值
  1802. this.drawTableData(reportTableItemList, reportTableType)
  1803. luckysheet.setRangeShow('BH1')
  1804. loading.close()
  1805. }).catch((e) => {
  1806. if (this.reportIntervalTag) clearInterval(this.reportIntervalTag)
  1807. loading.close()
  1808. showAlertWin(this, null, e)
  1809. })
  1810. },
  1811. /** 设置工作表状态 */
  1812. setLuckysheetStatus(dataInfo, isReadOnly, type, loading) {
  1813. let _this = this
  1814. // 报表数据
  1815. let reportTableData = dataInfo.reportTableData
  1816. let luckyData = JSON.parse(reportTableData)
  1817. // 基础数据项值
  1818. let baseItem = luckyData.baseItem
  1819. // 数据项
  1820. let reportTableItemList = dataInfo.reportTableItemList
  1821. let reportChartList = dataInfo.reportChartList
  1822. // 报表类型
  1823. let reportTableType = dataInfo.reportTableType
  1824. luckysheet.destroy()
  1825. let option = luckyData.option
  1826. if (!option) option = JSON.parse(JSON.stringify(this.luckysheetOption))
  1827. option.data = luckyData.data
  1828. if (isReadOnly) {
  1829. // 设置工作表保护
  1830. option.data[0].config.authority = {
  1831. sheet: 1, // 如果为 1 或 true,则该工作表受到保护;如果为 0 或 false,则该工作表不受保护。
  1832. hintText: '该工作表受到保护,无法操作', // 弹窗提示的文字
  1833. }
  1834. // 关闭右键菜单
  1835. option.cellRightClickConfig.chart = false
  1836. option.cellRightClickConfig.columnWidth = false
  1837. option.cellRightClickConfig.rowHeight = false
  1838. option.cellRightClickConfig.deleteColumn = false
  1839. option.cellRightClickConfig.deleteRow = false
  1840. option.cellRightClickConfig.insertColumn = false
  1841. option.cellRightClickConfig.insertRow = false
  1842. // 关闭工具栏
  1843. option.showtoolbar = false
  1844. option.enableAddRow = false
  1845. option.showtoolbarConfig = {
  1846. bold: false,
  1847. border: false,
  1848. fillColor: false,
  1849. font: false,
  1850. fontSize: false,
  1851. function: false,
  1852. horizontalAlignMode: false,
  1853. italic: false,
  1854. mergeCell: false,
  1855. moreFormats: false,
  1856. paintFormat: false,
  1857. strikethrough: false,
  1858. textColor: false,
  1859. underline: false,
  1860. verticalAlignMode: false
  1861. }
  1862. // 钩子函数
  1863. option.hook = {
  1864. workbookCreateAfter() {
  1865. for (let i in reportChartList) {
  1866. _this.insertEChartInfo(reportChartList[i])
  1867. }
  1868. // 绘制基础数据项
  1869. _this.drawBaseInfo(baseItem)
  1870. // 绘制数据值
  1871. _this.drawTableData(reportTableItemList, reportTableType)
  1872. luckysheet.setRangeShow('BH1')
  1873. if (loading) loading.close()
  1874. }
  1875. }
  1876. } else {
  1877. let charts = luckyData.charts
  1878. // 钩子函数
  1879. option.hook = {
  1880. workbookCreateAfter() {
  1881. for (let i in charts) {
  1882. _this.insertEChartInfo(charts[i])
  1883. }
  1884. // 绘制基础数据项
  1885. _this.drawBaseInfo(baseItem)
  1886. // 绘制数据值
  1887. _this.drawTableData(reportTableItemList, reportTableType)
  1888. luckysheet.setRangeShow('BH1')
  1889. if (loading) loading.close()
  1890. },
  1891. cellUpdated(r, c, newV, oldV) {
  1892. if (!(r === 49 && c === 0)) {
  1893. _this.forceRefreshLuckysheet()
  1894. }
  1895. }
  1896. }
  1897. }
  1898. luckysheet.create(option)
  1899. },
  1900. /** 绘制事件驱动报表信息 */
  1901. drawEventReportData(eventTables) {
  1902. if (!eventTables || eventTables.length == 0) {
  1903. return
  1904. }
  1905. let x = 0, y = 0
  1906. eventTables.forEach((data, i) => {
  1907. x += 1
  1908. y = 0
  1909. let {dataList, dataTimeList, itemName} = data
  1910. itemName = (itemName != null && itemName != undefined) ? itemName : cqcyCode['invalidData']
  1911. luckysheet.setCellValue(x, y, itemName)
  1912. dataList.forEach((val, j) => {
  1913. y = j + 1
  1914. let _date = luckysheet.getCellValue(0, y)
  1915. if (!_date) {
  1916. let text = (dataTimeList[j] != null && dataTimeList[j] != undefined) ? dataTimeList[j] : cqcyCode['invalidData']
  1917. if (text.length > 19) text = text.substring(0, 19)
  1918. luckysheet.setCellValue(0, y, text)
  1919. }
  1920. val = (val != null && val != undefined) ? val : cqcyCode['invalidData']
  1921. luckysheet.setCellValue(x, y, val)
  1922. })
  1923. })
  1924. },
  1925. /** 修改报表信息 */
  1926. editReportItem(data) {
  1927. let _data = JSON.parse(JSON.stringify(data))
  1928. this.$nextTick(() => {
  1929. this.resetRadioVal()
  1930. this.cronVal = _data.cron
  1931. this.analysisCron(this.cronVal)
  1932. this.reportForm = _data
  1933. // if (_data.startTime && _data.endTime) {
  1934. // this.dateByRange = [_data.startTime, _data.endTime]
  1935. // } else {
  1936. // this.dateByRange = ''
  1937. // }
  1938. this.reportForm.startTime = _data.startTime
  1939. this.reportForm.cronLabel = this.getCronLabel()
  1940. })
  1941. this.reportDialogTitle = '配置报表'
  1942. this.dialogReportTemplateVisible = true
  1943. // const loading = showLoading(this, '修改中,请稍候···')
  1944. // getReportTableById(data.id).then(res => {
  1945. // loading.close()
  1946. // this.cronVal = res.data.cron
  1947. // this.analysisCron(this.cronVal)
  1948. // this.reportForm = res.data
  1949. // this.reportForm.cronLabel = this.getCronLabel()
  1950. // this.reportDialogTitle = '配置报表'
  1951. // this.dialogReportTemplateVisible = true
  1952. // }).catch((e) => {
  1953. // loading.close()
  1954. // showAlertWin(this, null, e)
  1955. // })
  1956. },
  1957. /** 报表移除 */
  1958. removeReportItem(data, type) {
  1959. showConfirmWin(this, null, '您确定要删除该报表吗?', () => {
  1960. const loading = showLoading(this, '删除中,请稍候···')
  1961. delReportTableById(data.id).then(res => {
  1962. loading.close()
  1963. let msg = res.data ? '删除成功!' : '删除失败!'
  1964. showAlertMsgWin(this, null, msg)
  1965. if (type == 'record') {
  1966. this.reportHistoryPage = 1
  1967. this.historyReport()
  1968. return
  1969. }
  1970. this.reportPage = 1
  1971. this.loadReport()
  1972. this.cancelSaveReport()
  1973. }).catch((e) => {
  1974. loading.close()
  1975. showAlertWin(this, null, e)
  1976. })
  1977. })
  1978. },
  1979. /** 获取单元格大小 */
  1980. getCellSize(celldata, r, c, luckysheet) {
  1981. const {cs, rs} = celldata.data[r][c].mc
  1982. const rowhidden = celldata.config.rowhidden && Object.keys(celldata.config.rowhidden) || ''
  1983. const rowArr = []
  1984. for (let i = 0; i < rs; i++) {
  1985. let rowIndex = r + i
  1986. if (rowhidden.indexOf(String(rowIndex)) < 0) {
  1987. rowArr.push(rowIndex)
  1988. }
  1989. }
  1990. const colArr = []
  1991. for (let j = 0; j < cs; j++) {
  1992. colArr.push(c + j)
  1993. }
  1994. const totalHeight = Object.values(
  1995. luckysheet.getRowHeight(rowArr)
  1996. ).reduce((a, b) => a + b)
  1997. const totalWidth = Object.values(
  1998. luckysheet.getColumnWidth(colArr)
  1999. ).reduce((a, b) => a + b)
  2000. return {
  2001. w: totalWidth,
  2002. h: totalHeight
  2003. }
  2004. },
  2005. /** 获取图片位置 */
  2006. getImagePosition(num, arr) {
  2007. let index = 0
  2008. let minIndex
  2009. let maxIndex
  2010. for (let i = 0; i < arr.length; i++) {
  2011. if (num < arr[i]) {
  2012. index = i
  2013. break
  2014. }
  2015. }
  2016. if (index == 0) {
  2017. minIndex = 0
  2018. maxIndex = 1
  2019. } else if (index == arr.length - 1) {
  2020. minIndex = arr.length - 2
  2021. maxIndex = arr.length - 1
  2022. } else {
  2023. minIndex = index - 1
  2024. maxIndex = index
  2025. }
  2026. let min = arr[minIndex]
  2027. let max = arr[maxIndex]
  2028. let radio = Math.abs((num - min) / (max - min)) + index
  2029. return radio
  2030. },
  2031. /** 图表转换为图片 */
  2032. convertChart(luckyData) {
  2033. const optionData = luckysheet.getLuckysheetfile()[0]
  2034. let {
  2035. visibledatacolumn, // 所有行的位置
  2036. visibledatarow // 所有列的位置
  2037. } = optionData
  2038. // 动态图表
  2039. if (luckyData.charts && luckyData.charts.length > 0) {
  2040. luckyData.charts.forEach((chart, i) => {
  2041. let myChart = echarts.init(
  2042. document.getElementsByClassName(chart.info.className)[0]
  2043. )
  2044. let baseData = myChart.getConnectedDataURL({
  2045. type: 'png',
  2046. pixelRatio: 2,
  2047. backgroundColor: '#ffffff'
  2048. })
  2049. // luckysheet.cancelRangeMerge(chart.info.pos)
  2050. luckysheet.insertImage(baseData, {
  2051. rowIndex: chart.info.pos[0],
  2052. colIndex: chart.info.pos[1],
  2053. cellSize: this.getCellSize(optionData, chart.info.pos[0], chart.info.pos[1], luckysheet),
  2054. success: function () {
  2055. console.log("插入成功")
  2056. }
  2057. })
  2058. })
  2059. }
  2060. // 静态图表
  2061. if (luckyData.data && luckyData.data.length > 0) {
  2062. luckyData.data.forEach((data, i) => {
  2063. if (data.chart && data.chart.length > 0) {
  2064. data.chart.forEach((chart, j) => {
  2065. let myChart = echarts.init(
  2066. document.getElementById(chart.chart_id)
  2067. )
  2068. myChart.setOption(chart.chartOptions);
  2069. let baseData = myChart.getConnectedDataURL({
  2070. type: 'png',
  2071. pixelRatio: 2,
  2072. backgroundColor: '#ffffff'
  2073. })
  2074. let col_st = this.getImagePosition(chart.left, visibledatacolumn)
  2075. let row_st = this.getImagePosition(chart.top, visibledatarow)
  2076. luckysheet.insertImage(baseData, {
  2077. rowIndex: parseInt(row_st),
  2078. colIndex: parseInt(col_st),
  2079. cellSize: {
  2080. w: chart.width,
  2081. h: chart.height,
  2082. },
  2083. success: function () {
  2084. console.log("插入成功")
  2085. }
  2086. })
  2087. })
  2088. }
  2089. })
  2090. }
  2091. },
  2092. /** 处理日期显示数字问题 */
  2093. withDateData(excelData) {
  2094. if (!excelData) {
  2095. return
  2096. }
  2097. try {
  2098. excelData.map((item) => {
  2099. if (item) {
  2100. item.map((ll) => {
  2101. if (ll && ll.ct && ll.ct.t && ll.ct.t === 'd') {
  2102. ll.m = ll.m,
  2103. ll.v = ll.m,
  2104. ll.ct = {
  2105. fa: "@",
  2106. t: "s",
  2107. }
  2108. }
  2109. })
  2110. }
  2111. })
  2112. } catch (error) {
  2113. console.log(error)
  2114. }
  2115. },
  2116. /** 保存报表信息 */
  2117. saveReportInfo(loading, dataInfo) {
  2118. if (!loading) loading = showLoading(this, '保存中,请稍候···')
  2119. let _excelData = this.initBaseInfoData(dataInfo)
  2120. let params = JSON.parse(JSON.stringify(this.reportForm))
  2121. params.reportTableData = JSON.stringify(_excelData)
  2122. // if (this.dateByRange && this.dateByRange.length > 0) {
  2123. // params.startTime = this.dateByRange[0]
  2124. // params.endTime = this.dateByRange[1]
  2125. // }
  2126. saveReport(params).then(res => {
  2127. loading.close()
  2128. let msg = res.data ? '保存成功!' : '保存失败!'
  2129. showAlertMsgWin(this, null, msg)
  2130. this.showMainView = false
  2131. this.dialogReportTemplateVisible = false
  2132. this.loadReport()
  2133. this.cancelSaveReport()
  2134. }).catch((e) => {
  2135. loading.close()
  2136. showAlertWin(this, null, e)
  2137. })
  2138. },
  2139. /** 修改报表信息 */
  2140. updateReportInfo(loading, dataInfo) {
  2141. if (!loading) loading = showLoading(this, '修改中,请稍候···')
  2142. let params = JSON.parse(JSON.stringify(this.reportForm))
  2143. // if (this.dateByRange && this.dateByRange.length > 0) {
  2144. // params.startTime = this.dateByRange[0]
  2145. // params.endTime = this.dateByRange[1]
  2146. // }
  2147. setAutoTableTime(params).then(res => {
  2148. loading.close()
  2149. let msg = res.data ? '修改成功!' : '修改失败!'
  2150. showAlertMsgWin(this, null, msg)
  2151. this.showMainView = false
  2152. this.dialogReportTemplateVisible = false
  2153. this.loadReport()
  2154. this.cancelSaveReport()
  2155. }).catch((e) => {
  2156. loading.close()
  2157. showAlertWin(this, null, e)
  2158. })
  2159. },
  2160. /** 更新报表信息 */
  2161. updateReport() {
  2162. if (!this.chooseMyReport || !this.chooseMyReport.id) {
  2163. showAlertMsgWin(this, null, '保存失败,请刷新后重试!')
  2164. return
  2165. }
  2166. showPromptWin(this, '保存', '请输入报表名称', this.chooseMyReport.reportTableName, (val) => {
  2167. if (!val) {
  2168. return '报表名称不能为空'
  2169. }
  2170. if (val.length > 20) {
  2171. return '报表名称必须在20字以内'
  2172. }
  2173. }, (value) => {
  2174. const loading = showLoading(this, '保存中,请稍候···')
  2175. let _data2 = JSON.parse(this.chooseMyReport.reportTableData)
  2176. let excelTable = _data2.tables
  2177. excelTable.forEach(table => {
  2178. table.field.forEach(field => {
  2179. luckysheet.setCellValue(field.r, field.c, field.name)
  2180. })
  2181. })
  2182. let _data = JSON.parse(getLuckysheetConfig())
  2183. let excelData = _data[0].data
  2184. this.withDateData(excelData)
  2185. _data2.data = _data
  2186. // this.convertChart(_data2)
  2187. let data = this.chooseMyReport
  2188. data.reportTableName = value
  2189. data.reportTableData = JSON.stringify(_data2)
  2190. updateReportTable(data).then(res => {
  2191. loading.close()
  2192. let msg = res.data ? '保存成功!' : '保存失败!'
  2193. showAlertMsgWin(this, null, msg)
  2194. this.showMainView = false
  2195. this.loadReport()
  2196. this.cancelSaveReport()
  2197. }).catch((e) => {
  2198. loading.close()
  2199. showAlertWin(this, null, e)
  2200. })
  2201. })
  2202. },
  2203. /** 报表下载 */
  2204. downloadReport() {
  2205. this.dialogDownloadReportTypeVisible = true
  2206. },
  2207. /** 报表下载事件 */
  2208. downloadReportEvent() {
  2209. if (!this.chooseCurrMyReport) {
  2210. showAlertMsgWin(this, null, '请选择报表!')
  2211. return
  2212. }
  2213. let reportName = this.chooseCurrMyReport.reportTableName ? this.chooseCurrMyReport.reportTableName : '统计报表'
  2214. if (this.downloadType == '1') {
  2215. // exportExcel(luckysheet, reportName, ExcelJS).then((res) => {
  2216. // console.log("result==>", res)
  2217. // // this.$message({
  2218. // // message: res,
  2219. // // type: 'success'
  2220. // // })
  2221. // this.dialogDownloadReportTypeVisible = false
  2222. // }).catch((err) => {
  2223. // })
  2224. exportExcel(luckysheet.getAllSheets(), reportName)
  2225. setTimeout(() => {
  2226. this.dialogDownloadReportTypeVisible = false
  2227. }, 500)
  2228. }
  2229. },
  2230. /** 报表记录 */
  2231. historyReport() {
  2232. const loading = showLoading(this, '加载中,请稍候···')
  2233. let params = {
  2234. 'page': this.reportHistoryPage,
  2235. 'limit': this.reportHistoryLimit,
  2236. 'reportTableName': this.searchHistoryTxt,
  2237. 'autoTableId': this.chooseMyReport.id
  2238. }
  2239. getAutoChReportTable(params).then(res => {
  2240. loading.close()
  2241. this.dialogHistoryReportVisible = true
  2242. if (!res.data) return
  2243. this.reportHistoryData = res.data.reportTableList
  2244. this.reportHistoryTotal = res.data.count
  2245. }).catch((e) => {
  2246. loading.close()
  2247. showAlertWin(this, null, e)
  2248. })
  2249. },
  2250. getPrintSheetArea() {
  2251. const sheetData = luckysheet.getSheetData();
  2252. let objRowColumn = {
  2253. row: [0, 0], //行
  2254. column: [0, 0], //列
  2255. };
  2256. // * item是行、index是行索引、it是一行里的一格、itemIndex是这一格在这一行里的列索引
  2257. sheetData.forEach((item, index) => {
  2258. //行数
  2259. item.forEach((it, itemIndex) => {
  2260. if (it !== null && it.v) {
  2261. console.log(index, it)
  2262. if (objRowColumn.row[1] < index) {
  2263. objRowColumn.row[1] = index; //row第二位
  2264. }
  2265. if (objRowColumn.column[1] < itemIndex) {
  2266. objRowColumn.column[1] = itemIndex; //column第二位
  2267. }
  2268. }
  2269. });
  2270. });
  2271. return objRowColumn;
  2272. },
  2273. /** 打印操作 */
  2274. printExcel() {
  2275. const loading = showLoading(this, '请稍候···')
  2276. document.querySelector('#print-area').style = "display:block";
  2277. window.luckysheet.hideGridLines();
  2278. //获取当前选中区域
  2279. let currentSelected = luckysheet.getRange()
  2280. //如果当前选中区只是一个单元格,则认为选取无效。
  2281. if (currentSelected[0] != null && (currentSelected[0].row[1] - currentSelected[0].row[0] >= 1 || currentSelected[0].column[1] - currentSelected[0].column[0] >= 1)) {
  2282. // 将打印区域生成base64图片(*将生成的base64编码复制粘贴到浏览器地址框,是可以预览图片样式的),生成后执行的后续打印操作,取用匿名委托函数做为参数传入
  2283. luckysheet.getScreenshotNew((imgSrc) => {
  2284. window.luckysheet.showGridLines();
  2285. // * Lodop中的ADD_PRINT_IMAGE,也可以直接输出base64码图片,不用加img标签(如果加了img标签,会被当做超文本对待,受浏览器引擎解析的影响)
  2286. let $img = `<img src=${imgSrc} style="max-width: 90%;" />`
  2287. this.$nextTick(() => {
  2288. document.querySelector('#print-html').innerHTML = $img;
  2289. setTimeout(() => {
  2290. Print({
  2291. printable: 'print-html',
  2292. type: 'html',
  2293. documentTitle: '文档标题',
  2294. header: '',
  2295. headerStyle: 'font-weight:400;text-align:center;',
  2296. style: '@page {margin: 0 10mm};', // 不打印页眉和页脚
  2297. honorColor: true, // 是否打印彩色文本
  2298. targetStyles: ['*'] // 允许打印所有样式属性
  2299. }) // Print.js插件
  2300. if (document.querySelector('#print-area'))
  2301. document.querySelector('#print-area').style = "display:none";
  2302. loading.close()
  2303. }, 1000);
  2304. })
  2305. });
  2306. } else {
  2307. // 获取打印区域的行列
  2308. let RowColumn = this.getPrintSheetArea();
  2309. // 因需要打印左边的边框,需重新设置第一列
  2310. //RowColumn.column[0] = 0;
  2311. // 进行选区操作
  2312. luckysheet.setRangeShow(RowColumn);
  2313. // 将打印区域生成base64图片(*将生成的base64编码复制粘贴到浏览器地址框,是可以预览图片样式的),生成后执行的后续打印操作,取用匿名委托函数做为参数传入
  2314. luckysheet.getScreenshotNew((imgSrc) => {
  2315. window.luckysheet.showGridLines();
  2316. // * Lodop中的ADD_PRINT_IMAGE,也可以直接输出base64码图片,不用加img标签(如果加了img标签,会被当做超文本对待,受浏览器引擎解析的影响)
  2317. let $img = `<img src=${imgSrc} style="max-width: 90%;" />`
  2318. this.$nextTick(() => {
  2319. document.querySelector('#print-html').innerHTML = $img;
  2320. setTimeout(() => {
  2321. Print({
  2322. printable: 'print-html',
  2323. type: 'html',
  2324. documentTitle: '文档标题',
  2325. header: '',
  2326. headerStyle: 'font-weight:400;text-align:center;',
  2327. style: '@page {margin: 0 10mm};', // 不打印页眉和页脚
  2328. honorColor: true, // 是否打印彩色文本
  2329. targetStyles: ['*'] // 允许打印所有样式属性
  2330. }) // Print.js插件
  2331. if (document.querySelector('#print-area'))
  2332. document.querySelector('#print-area').style = "display:none";
  2333. loading.close()
  2334. }, 1000);
  2335. })
  2336. });
  2337. }
  2338. },
  2339. printSheet() {
  2340. const loading = showLoading(this, '请稍候···')
  2341. document.querySelector('#print-area').style = "display:block";
  2342. window.luckysheet.hideGridLines();
  2343. // 获取当前选中区域
  2344. let currentSelected = luckysheet.getRange()
  2345. // 如果当前选中区只是一个单元格,则认为选取无效。
  2346. if (currentSelected[0] != null
  2347. && (currentSelected[0].row[1] - currentSelected[0].row[0] >= 1
  2348. || currentSelected[0].column[1] - currentSelected[0].column[0] >= 1)) {
  2349. // 生成base64图片
  2350. let imgSrc = luckysheet.getScreenshot();
  2351. window.luckysheet.showGridLines();
  2352. // * Lodop中的ADD_PRINT_IMAGE,也可以直接输出base64码图片,不用加img标签(如果加了img标签,会被当做超文本对待,受浏览器引擎解析的影响)
  2353. let $img = `<img src=${imgSrc} style="max-width: 90%;" />`
  2354. this.$nextTick(() => {
  2355. document.querySelector('#print-html').innerHTML = $img;
  2356. setTimeout(() => {
  2357. Print({
  2358. printable: 'print-html',
  2359. type: 'html',
  2360. documentTitle: '文档标题',
  2361. header: '',
  2362. headerStyle: 'font-weight:400;text-align:center;',
  2363. style: '@page {margin: 0 10mm};', // 不打印页眉和页脚
  2364. honorColor: true, // 是否打印彩色文本
  2365. targetStyles: ['*'] // 允许打印所有样式属性
  2366. }) // Print.js插件
  2367. document.querySelector("#print-area").style.display = "none";
  2368. loading.close()
  2369. }, 1000)
  2370. })
  2371. } else {
  2372. // 获取打印区域的行列
  2373. let RowColumn = this.getPrintSheetArea();
  2374. // 因需要打印左边的边框,需重新设置第一列
  2375. RowColumn.column[0] = 0;
  2376. // 进行选区操作
  2377. luckysheet.setRangeShow(RowColumn);
  2378. let imgSrc = luckysheet.getScreenshot(); // 生成base64图片
  2379. window.luckysheet.showGridLines();
  2380. // * Lodop中的ADD_PRINT_IMAGE,也可以直接输出base64码图片,不用加img标签(如果加了img标签,会被当做超文本对待,受浏览器引擎解析的影响)
  2381. let $img = `<img src=${imgSrc} style="max-width: 90%;" />`
  2382. this.$nextTick(() => {
  2383. document.querySelector('#print-html').innerHTML = $img;
  2384. setTimeout(() => {
  2385. Print({
  2386. printable: 'print-html',
  2387. type: 'html',
  2388. documentTitle: '文档标题',
  2389. header: '',
  2390. headerStyle: 'font-weight:400;text-align:center;',
  2391. style: '@page {margin: 0 10mm};', // 不打印页眉和页脚
  2392. honorColor: true, // 是否打印彩色文本
  2393. targetStyles: ['*'] // 允许打印所有样式属性
  2394. }) // Print.js插件
  2395. document.querySelector("#print-area").style.display = "none";
  2396. loading.close()
  2397. }, 1000)
  2398. })
  2399. }
  2400. },
  2401. /** 自定义选中区域 */
  2402. getExcelRowColumn() {
  2403. const sheetData = luckysheet.getSheetData();
  2404. let objRowColumn = {
  2405. row: [null, null], //行
  2406. column: [null, null], //列
  2407. };
  2408. sheetData.forEach((item, index) => {
  2409. //行数
  2410. item.forEach((it, itemIndex) => {
  2411. console.log(it)
  2412. if (it !== null) {
  2413. if (objRowColumn.row[0] == null) objRowColumn.row[0] = index; // row第一位
  2414. objRowColumn.row[1] = index; //row第二位
  2415. if (objRowColumn.column[0] == null)
  2416. objRowColumn.column[0] = itemIndex; //column第一位
  2417. objRowColumn.column[1] = itemIndex; //column第二位
  2418. }
  2419. });
  2420. });
  2421. return objRowColumn;
  2422. },
  2423. cronNodeEvent(obj) {
  2424. this.cronVal = obj.value
  2425. },
  2426. initCronList() {
  2427. this.cronList = []
  2428. this.cronList.push({value: '0/2 * * * * ?', label: '表示每2秒钟执行一次任务'})
  2429. this.cronList.push({value: '0 0/2 * * * ?', label: '表示每2分钟执行一次任务'})
  2430. this.cronList.push({value: '0 0 0/2 * * ?', label: '表示每2小时执行一次任务'})
  2431. this.cronList.push({value: '0 15 10 * * ?', label: '表示在每天上午10点15分执行一次任务'})
  2432. this.cronList.push({value: '0 0 10,14,16 * * ?', label: '表示在每天的上午10点、下午2点、下午4点分别执行一次任务'})
  2433. this.cronList.push({
  2434. value: '0 0/30 9-17 * * ?',
  2435. label: '表示在每天的上午9点到下午5点的范围内每30分钟执行一次任务'
  2436. })
  2437. this.cronList.push({value: '0 0 12 ? * WED', label: '表示在每周星期三中午12点执行一次任务'})
  2438. this.cronList.push({value: '0 0 2 1 * ?', label: '表示在每月的1日的凌晨2点执行一次任务'})
  2439. },
  2440. /** 取消保存报表 */
  2441. cancelSaveReport2() {
  2442. this.handleReportNodeClick(this.chooseMyReport, this.chooseMyReport.userId !== this.uid ? 'deny' : '')
  2443. },
  2444. /** 取消保存报表 */
  2445. cancelSaveReport() {
  2446. if (this.reportIntervalTag) clearInterval(this.reportIntervalTag)
  2447. luckysheet.destroy()
  2448. this.breadcrumbList = ['运行配置']
  2449. this.showMainView = false
  2450. this.btnType = ''
  2451. this.chooseMyReport = null
  2452. if (this.$refs['reportForm']) this.$refs['reportForm'].resetFields()
  2453. },
  2454. /** 弹出层关闭事件 */
  2455. dialogClose(done) {
  2456. this.cronVal = ''
  2457. this.searchHistoryTxt = ''
  2458. this.reportId = null
  2459. // this.userGroupInfo = null
  2460. if (typeof (done) === 'function') {
  2461. done()
  2462. } else {
  2463. this.dialogReportTemplateVisible = false
  2464. this.dialogDownloadReportTypeVisible = false
  2465. this.dialogAutoReportVisible = false
  2466. this.dialogReportTypeVisible = false
  2467. this.dialogUserGroupVisible = false
  2468. this.dialogAutoPrintVisible = false
  2469. }
  2470. },
  2471. /** 弹出层关闭事件 */
  2472. dialogGroupUserClose(done) {
  2473. if (typeof (done) === 'function') {
  2474. done()
  2475. } else {
  2476. this.dialogGroupUserVisible = false
  2477. }
  2478. }
  2479. }
  2480. }
  2481. </script>
  2482. <style rel="stylesheet/scss" lang="scss">
  2483. .breadcrumb-content {
  2484. padding-bottom: 0;
  2485. }
  2486. .cy-nav-sx {
  2487. float: left !important;
  2488. margin-top: -23px !important;
  2489. margin-left: 120px !important;
  2490. display: flex;
  2491. }
  2492. .cy-nav-btn {
  2493. float: right !important;
  2494. margin-right: 20px !important;
  2495. margin-top: -20px !important;
  2496. }
  2497. .cy-main {
  2498. margin: 10px 20px;
  2499. width: calc(100% - 40px);
  2500. height: calc(100% - 100px);
  2501. .cy-btn {
  2502. margin-bottom: 10px;
  2503. }
  2504. .cy-btn .el-link {
  2505. margin-right: 15px;
  2506. }
  2507. .cy-main-left {
  2508. width: 100%;
  2509. height: 100%;
  2510. overflow: auto;
  2511. //float: left;
  2512. padding: 5px 10px;
  2513. //border-right: 1px solid #d4d4d4;
  2514. .cy-list {
  2515. overflow: auto;
  2516. height: 100%;
  2517. height: calc(100% - 40px);
  2518. ul {
  2519. display: flex;
  2520. flex-wrap: wrap;
  2521. padding: 0;
  2522. margin-top: 0;
  2523. li {
  2524. list-style-type: none;
  2525. background: #41aed7;
  2526. width: 23%;
  2527. margin: 10px 1%;
  2528. border-radius: 8px;
  2529. height: 110px;
  2530. padding: 15px;
  2531. color: #ffffff;
  2532. .cy-item-name {
  2533. font-size: 14px;
  2534. text-overflow: ellipsis;
  2535. white-space: nowrap;
  2536. overflow: hidden;
  2537. margin-bottom: 15px;
  2538. cursor: pointer;
  2539. }
  2540. .cy-item-val {
  2541. font-size: 12px;
  2542. }
  2543. .cy-list-item {
  2544. font-size: 12px;
  2545. color: #f6f6f6;
  2546. width: 100%;
  2547. //display: flex;
  2548. margin-top: 40px;
  2549. }
  2550. }
  2551. }
  2552. }
  2553. }
  2554. .cy-main-right {
  2555. width: 100%;
  2556. height: 100%;
  2557. float: left;
  2558. overflow: hidden;
  2559. }
  2560. }
  2561. .cy-group-tree1 {
  2562. font-size: 14px;
  2563. .custom-tree-node1 {
  2564. height: 28px;
  2565. line-height: 28px;
  2566. }
  2567. }
  2568. .cron-txt {
  2569. color: blue;
  2570. margin-right: 20px;
  2571. cursor: pointer;
  2572. font-weight: bold;
  2573. font-size: 16px;
  2574. }
  2575. .cron-txt-desc {
  2576. }
  2577. .ug-div {
  2578. .el-transfer-panel {
  2579. width: 300px;
  2580. }
  2581. }
  2582. </style>