index.vue 109 KB

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