index.vue 68 KB

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