reports.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795
  1. <template>
  2. <basic-container>
  3. <!--<el-checkbox v-model="isPrintTheBoxNumber">打印箱号</el-checkbox>-->
  4. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="query"
  5. :permission="permissionList" :before-open="beforeOpen" v-model="form" ref="crud" id="out-table"
  6. :header-cell-class-name="headerClassName" @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 312)"
  7. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 312)" @row-update="rowUpdate" @row-save="rowSave"
  8. @row-del="rowDel" @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  9. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange" @on-load="onLoad">
  10. <template slot-scope="{type,disabled}" slot="urlForm">
  11. <el-button size="small" :disabled="bbDisabled" @click="reportDesignButton(form.url)">设计报表</el-button>
  12. </template>
  13. <template slot="menuLeft">
  14. <el-button type="primary" size="small" icon="el-icon-plus" @click="addedData(3)">新 增
  15. </el-button>
  16. <el-button type="danger" size="small" icon="el-icon-delete" plain v-if="permission.reports_delete"
  17. @click="handleDelete">删 除
  18. </el-button>
  19. </template>
  20. <template slot-scope="{disabled,size}" slot="authorizedUsersForm">
  21. <div>
  22. <el-select v-model="form.authorizedUsersId" placeholder="请选择">
  23. <el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item.value">
  24. </el-option>
  25. </el-select>
  26. </div>
  27. </template>
  28. <template slot-scope="scope" slot="menu">
  29. <el-link type="primary" style="font-size: 12px" icon="el-icon-view" :underline="false"
  30. @click="addedData(1, scope)">查看详情&nbsp;&nbsp;</el-link>
  31. <el-link type="primary" style="font-size: 12px" icon="el-icon-edit" :underline="false" :disabled="disabled"
  32. @click="addedData(2, scope)">编 辑&nbsp;&nbsp;</el-link>
  33. <el-link type="primary" style="font-size: 12px" icon="el-icon-delete" :underline="false" :disabled="disabled"
  34. @click="rowDel(scope.row)">删 除</el-link>
  35. <el-link type="primary" :disabled="scope.row.status == 1"
  36. @click="handleReportPreview(scope.row.url, scope.row)">预览报表</el-link>
  37. </template>
  38. </avue-crud>
  39. <reportContainer ref="reportContainer"></reportContainer>
  40. </basic-container>
  41. </template>
  42. <script>
  43. import { getList, reportsDetail, add, update, reportsRemove, fingenlegGetReportData } from "@/api/iosBasicData/reports";
  44. import { getUserApprovalList } from "@/api/approval/processConfig";
  45. import { mapGetters } from "vuex";
  46. import { billsDetail } from '@/api/iosBasicData/bills'
  47. import { bbusinesstypeList } from "@/api/iosBasicData/bbusinesstype";
  48. import reportContainer from "@/views/iosBasicData/report-container/report-container.vue"
  49. export default {
  50. components: {
  51. reportContainer
  52. },
  53. props: {
  54. assemblyForm: {
  55. type: Object,
  56. default: {}
  57. },
  58. id: {
  59. type: String
  60. },
  61. disabled: {
  62. type: Boolean,
  63. default: false,
  64. },
  65. businessValue: {
  66. type: String,
  67. default: ''
  68. },
  69. month: {
  70. type: String
  71. },
  72. type: {
  73. type: Number
  74. },
  75. },
  76. data() {
  77. return {
  78. userList: [],
  79. isPrintTheBoxNumber: false,
  80. bbDisabled: false,
  81. form: {},
  82. formReport: {},
  83. query: {
  84. code: 'ZCFZ'
  85. },
  86. loading: true,
  87. page: {
  88. pageSize: 10,
  89. currentPage: 1,
  90. total: 0
  91. },
  92. selectionList: [],
  93. option: {},
  94. optionBack: {
  95. height: 'auto',
  96. calcHeight: 30,
  97. tip: false,
  98. searchShow: true,
  99. searchMenuSpan: 6,
  100. border: true,
  101. index: true,
  102. viewBtn: true,
  103. selection: true,
  104. dialogClickModal: false,
  105. column: [
  106. {
  107. label: "业务类型",
  108. prop: "businessType",
  109. disabled: true,
  110. type: 'select',
  111. dicData: [],
  112. props: {
  113. label: "cnName",
  114. value: "code"
  115. },
  116. // rules: [{
  117. // required: true,
  118. // message: "请输入业务类型",
  119. // trigger: "blur"
  120. // }]
  121. },
  122. {
  123. label: "类别",
  124. prop: "classifyCode",
  125. rules: [{
  126. required: true,
  127. message: "请输入类别",
  128. trigger: "blur"
  129. }]
  130. },
  131. {
  132. label: "组别",
  133. prop: "groupCode",
  134. rules: [{
  135. required: true,
  136. message: "请输入组别",
  137. trigger: "blur"
  138. }]
  139. },
  140. {
  141. label: "报表编码",
  142. prop: "code",
  143. search: true,
  144. rules: [{
  145. required: true,
  146. message: "请输入报表编码",
  147. trigger: "blur"
  148. }]
  149. },
  150. {
  151. label: "中文名称",
  152. prop: "cnName",
  153. search: true,
  154. rules: [{
  155. required: true,
  156. message: "请输入中文名称",
  157. trigger: "blur"
  158. }]
  159. },
  160. {
  161. label: "英文名称",
  162. prop: "enName"
  163. },
  164. {
  165. label: "报表格式",
  166. prop: "content",
  167. rules: [{
  168. required: true,
  169. message: "请输入报表格式",
  170. trigger: "blur"
  171. }]
  172. },
  173. {
  174. label: "授权用户",
  175. prop: "authorizedUsersId",
  176. // hide: true,
  177. formslot: true,
  178. type: 'tree',
  179. dicUrl: "/api/blade-user/userList",
  180. multiple: true,
  181. props: {
  182. label: "realName",
  183. value: "id"
  184. },
  185. dicData: [],
  186. rules: [{
  187. required: true,
  188. message: "请选择授权用户",
  189. trigger: "blur"
  190. }]
  191. },
  192. // {
  193. // label: "版本",
  194. // prop: "version",
  195. // rules: [{
  196. // required: true,
  197. // message: "请输入版本",
  198. // trigger: "blur"
  199. // }]
  200. // },
  201. {
  202. label: "状态",
  203. prop: "status",
  204. type: 'select',
  205. dicData: [{
  206. label: '正常',
  207. value: 0
  208. }, {
  209. label: '停用',
  210. value: 1
  211. }],
  212. rules: [{
  213. required: true,
  214. message: "请输入状态",
  215. trigger: "blur"
  216. }]
  217. },
  218. {
  219. label: "设计报表",
  220. prop: "url",
  221. hide: true,
  222. formslot: true,
  223. rules: [{
  224. required: true,
  225. message: "请输入备注",
  226. trigger: "blur"
  227. }]
  228. },
  229. {
  230. label: "备注",
  231. prop: "remarks"
  232. },
  233. ]
  234. },
  235. data: []
  236. };
  237. },
  238. async created() {
  239. this.option = await this.getColumnData(this.getColumnName(312), this.optionBack);
  240. getUserApprovalList().then(res => {
  241. this.findObject(this.option.column, "authorizedUsersId").dicData = res.data.data
  242. })
  243. // 获取业务类型
  244. bbusinesstypeList(1, 20).then(res => {
  245. this.findObject(this.option.column, "businessType").dicData = res.data.data.records
  246. })
  247. },
  248. computed: {
  249. ...mapGetters(["permission"]),
  250. permissionList() {
  251. return {
  252. addBtn: this.vaildData(this.permission.reports_add, false),
  253. viewBtn: this.vaildData(this.permission.reports_view, false),
  254. delBtn: this.vaildData(this.permission.reports_delete, false),
  255. editBtn: this.vaildData(this.permission.reports_edit, false)
  256. };
  257. },
  258. ids() {
  259. let ids = [];
  260. this.selectionList.forEach(ele => {
  261. ids.push(ele.id);
  262. });
  263. return ids.join(",");
  264. }
  265. },
  266. methods: {
  267. // 设计报表
  268. async reportDesignButton(url) {
  269. Stimulsoft.Base.StiLicense.key = '6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHn0s4gy0Fr5YoUZ9V00Y0igCSFQzwEqYBh/N77k4f0fWXTHW5rqeBNLkaurJDenJ9o97TyqHs9HfvINK18Uwzsc/bG01Rq+x3H3Rf+g7AY92gvWmp7VA2Uxa30Q97f61siWz2dE5kdBVcCnSFzC6awE74JzDcJMj8OuxplqB1CYcpoPcOjKy1PiATlC3UsBaLEXsok1xxtRMQ283r282tkh8XQitsxtTczAJBxijuJNfziYhci2jResWXK51ygOOEbVAxmpflujkJ8oEVHkOA/CjX6bGx05pNZ6oSIu9H8deF94MyqIwcdeirCe60GbIQByQtLimfxbIZnO35X3fs/94av0ODfELqrQEpLrpU6FNeHttvlMc5UVrT4K+8lPbqR8Hq0PFWmFrbVIYSi7tAVFMMe2D1C59NWyLu3AkrD3No7YhLVh7LV0Tttr/8FrcZ8xirBPcMZCIGrRIesrHxOsZH2V8t/t0GXCnLLAWX+TNvdNXkB8cF2y9ZXf1enI064yE5dwMs2fQ0yOUG/xornE'
  270. // Stimulsoft.Base.StiLicense.Key = '6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHkcgIvwL0jnpsDqRpWg5FI5kt2G7A0tYIcUygBh1sPs7plofUOqPB1a4HBIXJB621mau2oiAIj+ysU7gKUXfjn/D5BocmduNB+ZMiDGPxFrAp3PoD0nYNkkWh8r7gBZ1v/JZSXGE3bQDrCQCNSy6mgby+iFAMV8/PuZ1z77U+Xz3fkpbm6MYQXYp3cQooLGLUti7k1TFWrnawT0iEEDJ2iRcU9wLqn2g9UiWesEZtKwI/UmEI2T7nv5NbgV+CHguu6QU4WWzFpIgW+3LUnKCT/vCDY+ymzgycw9A9+HFSzARiPzgOaAuQYrFDpzhXV+ZeX31AxWlnzjDWqpfluygSNPtGul5gyNt2CEoJD1Yom0VN9fvRonYsMsimkFFx2AwyVpPcs+JfVBtpPbTcZscnzUdmiIvxv8Gcin6sNSibM6in/uUKFt3bVgW/XeMYa7MLGF53kvBSwi78poUDigA2n12SmghLR0AHxyEDIgZGOTbNI33GWu7ZsPBeUdGu55R8w='
  271. Stimulsoft.Base.Localization.StiLocalization.addLocalizationFile('/reports/stimulsoft/Localization/zh-CHS.xml', true, 'zh-CHS')
  272. Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile('/reports/stimulsoft/Localization/zh-CHS.xml')
  273. var options = new Stimulsoft.Designer.StiDesignerOptions()
  274. options.appearance.fullScreenMode = true
  275. options.allowChangeWindowTitle = false
  276. options.toolbar.showSaveDialog = false
  277. options.toolbar.showFileMenuSave = false
  278. options.toolbar.showFileMenuAbout = false
  279. options.toolbar.showFileMenuClose = false
  280. options.toolbar.showFileMenuExit = false
  281. options.toolbar.showFileMenuInfo = false
  282. options.toolbar.showFileMenuHelp = false
  283. options.toolbar.showFileMenuNew = false
  284. options.appearance.showTooltips = false
  285. options.appearance.showDialogsHelp = false
  286. options.toolbar.showSetupToolboxButton = true
  287. options.appearance.htmlRenderMode = Stimulsoft.Report.Export.StiHtmlExportMode.Table
  288. let designer = new Stimulsoft.Designer.StiDesigner(
  289. options,
  290. 'StiDesigner',
  291. false
  292. )
  293. designer.onSaveReport = (e) => {
  294. console.log('onSaveReport')
  295. // let jsObject = this.jsObject
  296. if (!e.report.isModified)
  297. return
  298. var jsonString = e.report.saveToJsonString()
  299. // console.log(jsonString)
  300. this.form.url = jsonString;
  301. console.log('保存url')
  302. console.log(jsonString)
  303. console.log('保存url结束')
  304. }
  305. let report = new window.Stimulsoft.Report.StiReport();
  306. report.styles.loadFile('static/Plugins/reports/css/Styles.sts')
  307. report.applyStyles()
  308. console.log("从 url 报表");
  309. console.log(url)
  310. console.log("结束");
  311. if (url) {
  312. report.load(url)
  313. }
  314. const res = await fingenlegGetReportData({
  315. date: this.month,
  316. type: this.type
  317. })
  318. // 获取的数据赋值
  319. var data = res.data.data
  320. var dataSet = new Stimulsoft.System.Data.DataSet(
  321. 'reportData'
  322. )
  323. dataSet.readJson(data)
  324. report.regData('reportData', 'reportData', dataSet)
  325. // 从模版和数据加载报表
  326. // loadReport(report, '', {})
  327. designer.report = report
  328. this.designer = designer
  329. this.$refs.reportContainer.showContainer(
  330. () => {
  331. setTimeout(() => {
  332. designer.renderHtml('reportContainer')
  333. this.createDesignerButtons()
  334. }, 50)
  335. },
  336. () => { },
  337. )
  338. },
  339. // 预览报表
  340. handleReportPreview(url, row) {
  341. console.log(row, 698)
  342. Stimulsoft.Base.StiLicense.key = '6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHn0s4gy0Fr5YoUZ9V00Y0igCSFQzwEqYBh/N77k4f0fWXTHW5rqeBNLkaurJDenJ9o97TyqHs9HfvINK18Uwzsc/bG01Rq+x3H3Rf+g7AY92gvWmp7VA2Uxa30Q97f61siWz2dE5kdBVcCnSFzC6awE74JzDcJMj8OuxplqB1CYcpoPcOjKy1PiATlC3UsBaLEXsok1xxtRMQ283r282tkh8XQitsxtTczAJBxijuJNfziYhci2jResWXK51ygOOEbVAxmpflujkJ8oEVHkOA/CjX6bGx05pNZ6oSIu9H8deF94MyqIwcdeirCe60GbIQByQtLimfxbIZnO35X3fs/94av0ODfELqrQEpLrpU6FNeHttvlMc5UVrT4K+8lPbqR8Hq0PFWmFrbVIYSi7tAVFMMe2D1C59NWyLu3AkrD3No7YhLVh7LV0Tttr/8FrcZ8xirBPcMZCIGrRIesrHxOsZH2V8t/t0GXCnLLAWX+TNvdNXkB8cF2y9ZXf1enI064yE5dwMs2fQ0yOUG/xornE'
  343. // Stimulsoft.Base.StiLicense.Key = '6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHkcgIvwL0jnpsDqRpWg5FI5kt2G7A0tYIcUygBh1sPs7plofUOqPB1a4HBIXJB621mau2oiAIj+ysU7gKUXfjn/D5BocmduNB+ZMiDGPxFrAp3PoD0nYNkkWh8r7gBZ1v/JZSXGE3bQDrCQCNSy6mgby+iFAMV8/PuZ1z77U+Xz3fkpbm6MYQXYp3cQooLGLUti7k1TFWrnawT0iEEDJ2iRcU9wLqn2g9UiWesEZtKwI/UmEI2T7nv5NbgV+CHguu6QU4WWzFpIgW+3LUnKCT/vCDY+ymzgycw9A9+HFSzARiPzgOaAuQYrFDpzhXV+ZeX31AxWlnzjDWqpfluygSNPtGul5gyNt2CEoJD1Yom0VN9fvRonYsMsimkFFx2AwyVpPcs+JfVBtpPbTcZscnzUdmiIvxv8Gcin6sNSibM6in/uUKFt3bVgW/XeMYa7MLGF53kvBSwi78poUDigA2n12SmghLR0AHxyEDIgZGOTbNI33GWu7ZsPBeUdGu55R8w='
  344. Stimulsoft.Base.Localization.StiLocalization.addLocalizationFile('/reports/stimulsoft/Localization/zh-CHS.xml', true, 'zh-CHS')
  345. Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile('/reports/stimulsoft/Localization/zh-CHS.xml')
  346. // 工具栏
  347. var options = new Stimulsoft.Viewer.StiViewerOptions()
  348. options.height = '100%'
  349. options.appearance.scrollbarsMode = true // 滚动条模式
  350. options.toolbar.showDesignButton = false // 显示设计按钮
  351. options.toolbar.showAboutButton = false // 显示关于按钮
  352. options.toolbar.showResourcesButton = false // 显示资源按钮
  353. options.toolbar.showFullScreenButton = false // 显示全屏按钮
  354. options.toolbar.showOpenButton = false // 显示打开按钮
  355. options.appearance.showTooltips = false // 显示工具提示
  356. options.appearance.showDialogsHelp = false // 显示对话框帮助
  357. options.exports.showExportToDocument = false // 显示导出到文档
  358. options.toolbar.showParametersButton = true // 显示参数按钮
  359. options.appearance.bookmarksPrint = true // 书签打印
  360. // options.toolbar.showPrintButton = false // 打印按钮是否显示 下面直接自定义控制打印弹窗是否开启
  361. // printDestination 参数:用于指定报表打印的目标位置,可以是打印机、PDF 文件或者直接打印到浏览器等。
  362. // Stimulsoft.Viewer.StiPrintDestination.Direct:表示直接打印到打印机,即将报表内容直接发送至打印机进行打印。
  363. // 通过设置不同的 printDestination 参数,你可以控制报表打印的行为,例如是直接打印到打印机,还是生成 PDF 文件,或者直接在浏览器中预览打印内容等。
  364. options.toolbar.printDestination = Stimulsoft.Viewer.StiPrintDestination.Direct
  365. // htmlRenderMode html渲染模式
  366. options.appearance.htmlRenderMode = Stimulsoft.Report.Export.StiHtmlExportMode.Table
  367. // 是创建一个 Stimulsoft 报表查看器的实例的代码
  368. let viewer = new Stimulsoft.Viewer.StiViewer(options, 'StiViewer', false)
  369. // 报表
  370. console.log("创建一个报表实例");
  371. let report = new window.Stimulsoft.Report.StiReport();
  372. // 加载文件
  373. console.log("从url加载报表");
  374. // report.loadFile("/reports/stimulsoft/demos/SimpleList.mrt");
  375. report.load(url)
  376. // 加载数据
  377. fingenlegGetReportData({
  378. date: this.month,
  379. type: this.type
  380. }).then(res => {
  381. var data = res.data.data
  382. // 创建一个 Stimulsoft 数据集(DataSet)的实例的代码
  383. var dataSet = new Stimulsoft.System.Data.DataSet(
  384. 'reportData'
  385. )
  386. dataSet.readJson(data) // 用于将 JSON 格式的数据加载到数据集中。data 是包含报表数据的 JSON 对象。
  387. // 这是一个方法调用,用于在报表中注册数据源。参数 'reportData' 是数据源的名称,
  388. // 第二个 'reportData' 是数据源的别名,dataSet 则是之前创建的数据集实例
  389. report.regData('reportData', 'reportData', dataSet)
  390. // 从模版和数据加载报表
  391. // loadReport(report, '', {})
  392. // 这是将报表对象指定给报表查看器的属性。viewer 是报表查看器的实例,而 report 是之前创建的报表对象。
  393. viewer.report = report;
  394. })
  395. this.$refs.reportContainer.showContainer(
  396. () => {
  397. setTimeout(() => {
  398. viewer.renderHtml('reportContainer')
  399. this.createViewerButtons(viewer)
  400. }, 50)
  401. },
  402. () => {
  403. },
  404. )
  405. console.log("加载成功完成!");
  406. },
  407. loadReport(report, content, data) {
  408. var mimeString = content
  409. .split(',')[0]
  410. .split(':')[1]
  411. .split(';')[0]
  412. var byteString = atob(content.split(',')[1])
  413. var ab = new ArrayBuffer(byteString.length)
  414. var ia = new Uint8Array(ab)
  415. for (var i = 0; i < byteString.length; i++) {
  416. ia[i] = byteString.charCodeAt(i)
  417. }
  418. var blob = new Blob([ab])
  419. JSZip.loadAsync(blob).then(function (unziped) {
  420. unziped
  421. .file('reportfile.json')
  422. .async('string')
  423. .then(res => {
  424. report.load(res)
  425. if (!!data) {
  426. var dataSet = new Stimulsoft.System.Data.DataSet(
  427. 'reportData'
  428. )
  429. dataSet.readJson(data)
  430. report.regData('reportData', 'reportData', dataSet)
  431. }
  432. })
  433. })
  434. },
  435. createDesignerButtons(e) {
  436. console.log(e, 936)
  437. if (!!e) {
  438. try {
  439. this.designer.jsObject.options.menus.localizationMenu.addEventListener(
  440. 'click',
  441. this.createDesignerButtons
  442. )
  443. } catch (error) {
  444. }
  445. }
  446. let toolBarRow = this.designer.jsObject.options.toolBar.firstChild.tr[0]
  447. let customButton = this.designer.jsObject.StatusPanelButton(
  448. 'exitButton',
  449. '关闭',
  450. 'LoginControls.Window.CloseWhite.png',
  451. '关闭',
  452. null,
  453. 30,
  454. 60
  455. )
  456. customButton.image.style.width = customButton.image.style.height = '16px'
  457. let buttonCell = document.createElement('td')
  458. buttonCell.className = 'stiDesignerToolButtonCell'
  459. buttonCell.appendChild(customButton)
  460. toolBarRow.appendChild(buttonCell)
  461. let that = this
  462. customButton.action = function (e) {
  463. let jsObject = this.jsObject
  464. if (jsObject.options.reportIsModified) {
  465. var messageForm = jsObject.MessageFormForSave()
  466. messageForm.changeVisibleState(true)
  467. messageForm.action = function (state) {
  468. if (state) {
  469. jsObject.SendCommandSaveReport()
  470. setTimeout(() => {
  471. jsObject.SendCommandCloseReport()
  472. jsObject.designer.invokeExit()
  473. if (that.$refs.reportContainer)
  474. that.$refs.reportContainer.hideContainer()
  475. }, 250)
  476. } else {
  477. jsObject.SendCommandCloseReport()
  478. jsObject.designer.invokeExit()
  479. if (that.$refs.reportContainer)
  480. that.$refs.reportContainer.hideContainer()
  481. }
  482. }
  483. } else {
  484. jsObject.SendCommandCloseReport()
  485. jsObject.designer.invokeExit()
  486. if (that.$refs.reportContainer)
  487. that.$refs.reportContainer.hideContainer()
  488. }
  489. }
  490. },
  491. createViewerButtons(viewer) {
  492. viewer.jsObject.collections.images['myClose.png'] =
  493. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAA0ElEQVQ4ja3TO05CQRQG4A8iOwAbtYWETndAaecK7NwCKmETtJZsSBNLobEz8ZFIJQ0UnOGSm3DnYviTybzO/895DQXGWGCVGQuMEqkRcwcfuMOLalziCaf4TIe9UG9nyMJmFRzNGoRK1BU4xxx9G7cfwostciGk+x8MqgySwDXe4tU53hVV+MNtTmAoX84JGv9NYgrHyR6DV8wUSW7hItZLm36ZVoVQxsFJLOMsPOrH/h7dQwR2cdxOTEn8DtUbPGc4V2H7Vb4Yqfedf/GYSGt8VUmxgyfuBAAAAABJRU5ErkJggg=='
  494. const closeBtn = viewer.jsObject.SmallButton(
  495. 'closeBtn',
  496. '关闭',
  497. 'myClose.png'
  498. )
  499. // 增加打印弹窗配置
  500. const printBtn = viewer.jsObject.SmallButton(
  501. 'printBtn',
  502. '打印报表',
  503. 'myClose.png'
  504. )
  505. // console.log(viewer.jsObject.print(),'1013')
  506. // 获取 关闭按钮的dom元素位置
  507. const toolbarTable = viewer.jsObject.controls.toolbar.firstChild.firstChild
  508. const buttonsTable = toolbarTable.rows[0].lastChild.lastChild
  509. const userButtonCell = buttonsTable.rows[0].insertCell(0)
  510. // 获取打印按钮的位置
  511. const buttonsTablePrint = toolbarTable.rows[0].childNodes[0].lastChild // 打印按钮
  512. const userButtonPrint = buttonsTablePrint.rows[0].childNodes[0] // 打印按钮dom位置
  513. userButtonPrint.addEventListener("click", (event) => {
  514. console.log("打印点击");
  515. // event.preventDefault()
  516. });
  517. userButtonPrint.addEventListener("mouseover", (event) => {
  518. console.log("移入打印按钮");
  519. console.log(event, 1035)
  520. });
  521. userButtonCell.className = 'stiJsViewerClearAllStyles'
  522. userButtonCell.appendChild(closeBtn) // 添加关闭节点
  523. // userButtonPrint.prepend(printBtn) // 在 printBtn 节点里最前面增加一个子级节点
  524. let that = this
  525. // 关闭按钮的监听点击
  526. closeBtn.action = function () {
  527. console.log(that.$refs.ReportContainer, '1022')
  528. if (that.$refs.reportContainer)
  529. that.$refs.reportContainer.hideContainer()
  530. }
  531. // // // 打印按钮监听
  532. // printBtn.action = (e)=>{
  533. // console.log('打印')
  534. // window.print()
  535. // }
  536. },
  537. addedData(type, scope) {
  538. this.form = {};
  539. if (type == 1) {
  540. this.bbDisabled = true;
  541. this.$refs.crud.rowView(scope.row, scope.$index);
  542. } else if (type == 2) {
  543. this.bbDisabled = true;
  544. var userIdList = [];
  545. userIdList = scope.row.authorizedUsersId
  546. let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
  547. for (let id of userIdList) {
  548. if (id == userObj.user_id) {
  549. this.bbDisabled = false;
  550. }
  551. }
  552. if (userObj.role_name.indexOf('admin') != -1 || userObj.role_name.indexOf('报表管理') != -1) {
  553. this.bbDisabled = false;
  554. }
  555. this.$refs.crud.rowEdit(scope.row, scope.$index);
  556. } else if (type == 3) {
  557. this.bbDisabled = false;
  558. this.$refs.crud.rowAdd();
  559. }
  560. },
  561. // 添加
  562. rowSave(row, done, loading) {
  563. row.authorizedUsersId = row.authorizedUsersId.join()
  564. row.businessType = this.businessValue
  565. add(row).then(() => {
  566. this.onLoad(this.page);
  567. this.$message({
  568. type: "success",
  569. message: "操作成功!"
  570. });
  571. done();
  572. }, error => {
  573. loading();
  574. window.console.log(error);
  575. });
  576. },
  577. rowUpdate(row, index, done, loading) {
  578. // console.log(row.authorizedUsersId)
  579. // row.authorizedUsersId = row.authorizedUsersId.join()
  580. update(row).then(() => {
  581. this.query.code = 'ZCFZ'
  582. this.onLoad(this.page, this.query);
  583. this.$message({
  584. type: "success",
  585. message: "操作成功!"
  586. });
  587. done();
  588. }, error => {
  589. loading();
  590. console.log(error);
  591. });
  592. },
  593. rowDel(row) {
  594. this.$confirm("确定将选择数据删除?", {
  595. confirmButtonText: "确定",
  596. cancelButtonText: "取消",
  597. type: "warning"
  598. })
  599. .then(() => {
  600. return reportsRemove(row.id);
  601. })
  602. .then(() => {
  603. this.onLoad(this.page);
  604. this.$message({
  605. type: "success",
  606. message: "操作成功!"
  607. });
  608. });
  609. },
  610. handleDelete() {
  611. if (this.selectionList.length === 0) {
  612. this.$message.warning("请选择至少一条数据");
  613. return;
  614. }
  615. this.$confirm("确定将选择数据删除?", {
  616. confirmButtonText: "确定",
  617. cancelButtonText: "取消",
  618. type: "warning"
  619. })
  620. .then(() => {
  621. return reportsRemove(this.ids);
  622. })
  623. .then(() => {
  624. this.onLoad(this.page);
  625. this.$message({
  626. type: "success",
  627. message: "操作成功!"
  628. });
  629. this.$refs.crud.toggleSelection();
  630. });
  631. },
  632. beforeOpen(done, type) {
  633. if (["edit", "view"].includes(type)) {
  634. reportsDetail(this.form.id).then(res => {
  635. this.form = res.data.data;
  636. });
  637. }
  638. done();
  639. },
  640. searchReset() {
  641. this.query = {};
  642. this.onLoad(this.page);
  643. },
  644. searchChange(params, done) {
  645. this.query = params;
  646. this.page.currentPage = 1;
  647. this.onLoad(this.page, params);
  648. done();
  649. },
  650. selectionChange(list) {
  651. this.selectionList = list;
  652. },
  653. selectionClear() {
  654. this.selectionList = [];
  655. this.$refs.crud.toggleSelection();
  656. },
  657. currentChange(currentPage) {
  658. this.page.currentPage = currentPage;
  659. },
  660. sizeChange(pageSize) {
  661. this.page.pageSize = pageSize;
  662. },
  663. refreshChange() {
  664. this.onLoad(this.page, this.query);
  665. },
  666. onLoad(page, params = {}) {
  667. this.loading = true;
  668. params.businessType = this.businessValue
  669. params.code = 'ZCFZ'
  670. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  671. const data = res.data.data;
  672. this.page.total = data.total;
  673. this.data = data.records;
  674. this.loading = false;
  675. this.selectionClear();
  676. });
  677. },
  678. //自定义列保存
  679. async saveColumnTwo(ref, option, optionBack, code) {
  680. /**
  681. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  682. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  683. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  684. */
  685. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  686. if (inSave) {
  687. this.$message.success("保存成功");
  688. //关闭窗口
  689. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  690. }
  691. },
  692. //自定义列重置
  693. async resetColumnTwo(ref, option, optionBack, code) {
  694. this[option] = this[optionBack];
  695. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  696. if (inSave) {
  697. this.$message.success("重置成功");
  698. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  699. }
  700. },
  701. // 更改表格颜色
  702. headerClassName(tab) {
  703. //颜色间隔
  704. let back = ""
  705. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  706. if (tab.columnIndex % 2 === 0) {
  707. back = "back-one"
  708. } else if (tab.columnIndex % 2 === 1) {
  709. back = "back-two"
  710. }
  711. }
  712. return back;
  713. },
  714. }
  715. };
  716. </script>
  717. <style lang="scss" scoped>
  718. ::v-deep#out-table .back-one {
  719. background: #ecf5ff !important;
  720. }
  721. ::v-deep#out-table .back-two {
  722. background: #ecf5ff !important;
  723. }
  724. ::v-deep .el-input-group__append {
  725. padding: 0 0px !important;
  726. }
  727. /deep/ .el-tree-node__content>.el-tree-node__expand-icon {
  728. visibility: hidden;
  729. }
  730. /deep/ .el-col-md-8 {
  731. width: 24.33333%;
  732. }
  733. </style>