index.vue 89 KB

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