reports.vue 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266
  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.8)"
  7. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 312.8)" @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" :disabled="disabled" @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="authorizedUsersIdForm">
  21. <dic-select v-model="form.authorizedUsersId" placeholder="授权用户" key="id" keyValue="id" label="realName"
  22. url="/blade-user/userListAll" :filterable="true" :multiple="true" dataName="realName" dataType="string"
  23. @selectChange="dicChange('authorizedUsersId', $event, form)"></dic-select>
  24. </template>
  25. <template slot="authorizedRoleIdForm">
  26. <dic-select v-model="form.authorizedRoleId" placeholder="授权角色" key="id" keyValue="id" label="roleName"
  27. url="/blade-system/role/list" :filterable="true" :multiple="true" dataName="roleName" dataType="string"
  28. @selectChange="dicChange('authorizedRoleId', $event, form)"></dic-select>
  29. </template>
  30. <template slot="authorizedTeamIdForm">
  31. <dic-select v-model="form.authorizedTeamId" placeholder="授权团队" key="id" keyValue="id" label="postName"
  32. url="/blade-system/post/listAll" :filterable="true" :multiple="true" dataName="postName" dataType="string"
  33. @selectChange="dicChange('authorizedTeamId', $event, form)"></dic-select>
  34. </template>
  35. <template slot="excludeUsersIdForm">
  36. <dic-select v-model="form.excludeUsersId" placeholder="排除用户" key="id" keyValue="id" label="realName"
  37. url="/blade-user/userListAll" :filterable="true" :multiple="true" dataName="realName" dataType="string"
  38. @selectChange="dicChange('excludeUsersId', $event, form)"></dic-select>
  39. </template>
  40. <template slot-scope="scope" slot="menu">
  41. <el-link type="primary" style="font-size: 12px" icon="el-icon-view" :underline="false"
  42. @click="addedData(1, scope)">查看详情&nbsp;&nbsp;</el-link>
  43. <el-link type="primary" style="font-size: 12px" icon="el-icon-edit" :underline="false"
  44. @click="addedData(2, scope)">编 辑&nbsp;&nbsp;</el-link>
  45. <el-link type="primary" style="font-size: 12px" icon="el-icon-delete" :underline="false"
  46. @click="rowDel(scope.row)">删 除</el-link>
  47. <el-link type="primary" :disabled="scope.row.status == 1"
  48. @click="handleReportPreview(scope.row.url, scope.row)">预览报表</el-link>
  49. </template>
  50. </avue-crud>
  51. <reportContainer ref="reportContainer"></reportContainer>
  52. <mail-component ref="mailComponentRef" />
  53. </basic-container>
  54. </template>
  55. <script>
  56. import { getList, reportsDetail, add, update, reportsRemove2, reportsGetReportData } from "@/api/iosBasicData/reports";
  57. import { getUserApprovalList } from "@/api/approval/processConfig";
  58. import { mapGetters } from "vuex";
  59. import { billsDetail } from '@/api/iosBasicData/bills'
  60. import { bbusinesstypeList } from "@/api/iosBasicData/bbusinesstype";
  61. import reportContainer from "@/views/iosBasicData/report-container/report-container.vue"
  62. import { isProcurement } from "@/api/basicData/configuration";
  63. import dicSelect from "@/components/dicSelect/main";
  64. import mailComponent from "@/components/iosbasic-data/mail-component.vue";
  65. export default {
  66. components: {
  67. reportContainer,
  68. dicSelect,
  69. mailComponent
  70. },
  71. props: {
  72. assemblyForm: {
  73. type: Object,
  74. default: {}
  75. },
  76. id: {
  77. type: String
  78. },
  79. disabled: {
  80. type: Boolean,
  81. default: false,
  82. },
  83. businessValue: {
  84. type: String,
  85. default: ''
  86. },
  87. groupCode: {
  88. type: String,
  89. default: ''
  90. }
  91. },
  92. data() {
  93. return {
  94. textareaNumber: 5,
  95. userList: [],
  96. isPrintTheBoxNumber: false,
  97. bbDisabled: false,
  98. form: {
  99. authorizedUsers: null,
  100. },
  101. formReport: {},
  102. query: {},
  103. loading: true,
  104. page: {
  105. pageSize: 10,
  106. currentPage: 1,
  107. total: 0
  108. },
  109. selectionList: [],
  110. option: {},
  111. optionBack: {
  112. height: 'auto',
  113. calcHeight: 30,
  114. tip: false,
  115. searchShow: true,
  116. searchMenuSpan: 6,
  117. border: true,
  118. index: true,
  119. viewBtn: true,
  120. selection: true,
  121. dialogClickModal: false,
  122. column: [
  123. {
  124. label: "业务类型",
  125. prop: "businessType",
  126. disabled: true,
  127. type: 'select',
  128. dicData: [],
  129. props: {
  130. label: "cnName",
  131. value: "code"
  132. },
  133. // rules: [{
  134. // required: true,
  135. // message: "请输入业务类型",
  136. // trigger: "blur"
  137. // }]
  138. },
  139. {
  140. label: "类别",
  141. prop: "classifyCode",
  142. rules: [{
  143. required: true,
  144. message: "请输入类别",
  145. trigger: "blur"
  146. }]
  147. },
  148. {
  149. label: "组别",
  150. prop: "groupCode",
  151. rules: [{
  152. required: true,
  153. message: "请输入组别",
  154. trigger: "blur"
  155. }]
  156. },
  157. {
  158. label: "报表编码",
  159. prop: "code",
  160. search: true,
  161. rules: [{
  162. required: true,
  163. message: "请输入报表编码",
  164. trigger: "blur"
  165. }]
  166. },
  167. {
  168. label: "中文名称",
  169. prop: "cnName",
  170. search: true,
  171. rules: [{
  172. required: true,
  173. message: "请输入中文名称",
  174. trigger: "blur"
  175. }]
  176. },
  177. {
  178. label: "英文名称",
  179. prop: "enName"
  180. },
  181. {
  182. label: "报表格式",
  183. prop: "content",
  184. rules: [{
  185. required: true,
  186. message: "请输入报表格式",
  187. trigger: "blur"
  188. }]
  189. },
  190. {
  191. label: "授权用户",
  192. prop: "authorizedUsersId",
  193. hide: true,
  194. showColumn: false,
  195. formslot: true,
  196. overHidden: true,
  197. },
  198. {
  199. label: "授权用户",
  200. prop: "authorizedUsers",
  201. display: false,
  202. overHidden: true,
  203. },
  204. {
  205. label: "授权角色",
  206. prop: "authorizedRoleId",
  207. hide: true,
  208. showColumn: false,
  209. formslot: true,
  210. overHidden: true,
  211. },
  212. {
  213. label: "授权角色",
  214. prop: "authorizedRole",
  215. display: false,
  216. overHidden: true,
  217. },
  218. {
  219. label: "授权团队",
  220. prop: "authorizedTeamId",
  221. hide: true,
  222. showColumn: false,
  223. formslot: true,
  224. overHidden: true,
  225. },
  226. {
  227. label: "授权团队",
  228. prop: "authorizedTeam",
  229. display: false,
  230. overHidden: true,
  231. },
  232. {
  233. label: "排除用户",
  234. prop: "excludeUsersId",
  235. hide: true,
  236. showColumn: false,
  237. formslot: true,
  238. overHidden: true,
  239. },
  240. {
  241. label: "排除用户",
  242. prop: "excludeUsers",
  243. display: false,
  244. overHidden: true,
  245. },
  246. {
  247. label: "状态",
  248. prop: "status",
  249. type: 'select',
  250. dicData: [{
  251. label: '正常',
  252. value: 0
  253. }, {
  254. label: '停用',
  255. value: 1
  256. }],
  257. rules: [{
  258. required: true,
  259. message: "请输入状态",
  260. trigger: "blur"
  261. }]
  262. },
  263. {
  264. label: "设计报表",
  265. prop: "url",
  266. hide: true,
  267. formslot: true,
  268. rules: [{
  269. required: true,
  270. message: "请输入备注",
  271. trigger: "blur"
  272. }]
  273. },
  274. {
  275. label: "备注",
  276. prop: "remarks"
  277. },
  278. ]
  279. },
  280. data: []
  281. };
  282. },
  283. async created() {
  284. this.option = await this.getColumnData(this.getColumnName(312.8), this.optionBack);
  285. isProcurement({ "param": "textarea.number" }).then(res => {
  286. if (res.data.data) {
  287. this.textareaNumber = res.data.data
  288. }
  289. })
  290. // getUserApprovalList().then(res => {
  291. // this.findObject(this.option.column, "authorizedUsersId").dicData = res.data.data
  292. // })
  293. // 获取业务类型
  294. bbusinesstypeList(1, 20).then(res => {
  295. this.findObject(this.option.column, "businessType").dicData = res.data.data.records
  296. })
  297. },
  298. computed: {
  299. ...mapGetters(["permission"]),
  300. permissionList() {
  301. return {
  302. addBtn: this.vaildData(this.permission.reports_add, false),
  303. viewBtn: this.vaildData(this.permission.reports_view, false),
  304. delBtn: this.vaildData(this.permission.reports_delete, false),
  305. editBtn: this.vaildData(this.permission.reports_edit, false)
  306. };
  307. },
  308. ids() {
  309. let ids = [];
  310. this.selectionList.forEach(ele => {
  311. ids.push(ele.id);
  312. });
  313. return ids.join(",");
  314. }
  315. },
  316. methods: {
  317. dicChange(name, row) {
  318. if (name == 'authorizedUsersId') {
  319. if (row) {
  320. this.form.authorizedUsers = row
  321. } else {
  322. this.form.authorizedUsersId = null
  323. this.form.authorizedUsers = null
  324. }
  325. }
  326. if (name == 'authorizedRoleId') {
  327. if (row) {
  328. this.form.authorizedRole = row
  329. } else {
  330. this.form.authorizedRoleId = null
  331. this.form.authorizedRole = null
  332. }
  333. }
  334. if (name == 'authorizedTeamId') {
  335. if (row) {
  336. this.form.authorizedTeam = row
  337. } else {
  338. this.form.authorizedTeamId = null
  339. this.form.authorizedTeam = null
  340. }
  341. }
  342. if (name == 'excludeUsersId') {
  343. if (row) {
  344. this.form.excludeUsers = row
  345. } else {
  346. this.form.excludeUsersId = null
  347. this.form.excludeUsers = null
  348. }
  349. }
  350. },
  351. // 设计报表
  352. async reportDesignButton(url) {
  353. Stimulsoft.Base.StiLicense.key = '6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHn0s4gy0Fr5YoUZ9V00Y0igCSFQzwEqYBh/N77k4f0fWXTHW5rqeBNLkaurJDenJ9o97TyqHs9HfvINK18Uwzsc/bG01Rq+x3H3Rf+g7AY92gvWmp7VA2Uxa30Q97f61siWz2dE5kdBVcCnSFzC6awE74JzDcJMj8OuxplqB1CYcpoPcOjKy1PiATlC3UsBaLEXsok1xxtRMQ283r282tkh8XQitsxtTczAJBxijuJNfziYhci2jResWXK51ygOOEbVAxmpflujkJ8oEVHkOA/CjX6bGx05pNZ6oSIu9H8deF94MyqIwcdeirCe60GbIQByQtLimfxbIZnO35X3fs/94av0ODfELqrQEpLrpU6FNeHttvlMc5UVrT4K+8lPbqR8Hq0PFWmFrbVIYSi7tAVFMMe2D1C59NWyLu3AkrD3No7YhLVh7LV0Tttr/8FrcZ8xirBPcMZCIGrRIesrHxOsZH2V8t/t0GXCnLLAWX+TNvdNXkB8cF2y9ZXf1enI064yE5dwMs2fQ0yOUG/xornE'
  354. // Stimulsoft.Base.StiLicense.Key = '6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHkcgIvwL0jnpsDqRpWg5FI5kt2G7A0tYIcUygBh1sPs7plofUOqPB1a4HBIXJB621mau2oiAIj+ysU7gKUXfjn/D5BocmduNB+ZMiDGPxFrAp3PoD0nYNkkWh8r7gBZ1v/JZSXGE3bQDrCQCNSy6mgby+iFAMV8/PuZ1z77U+Xz3fkpbm6MYQXYp3cQooLGLUti7k1TFWrnawT0iEEDJ2iRcU9wLqn2g9UiWesEZtKwI/UmEI2T7nv5NbgV+CHguu6QU4WWzFpIgW+3LUnKCT/vCDY+ymzgycw9A9+HFSzARiPzgOaAuQYrFDpzhXV+ZeX31AxWlnzjDWqpfluygSNPtGul5gyNt2CEoJD1Yom0VN9fvRonYsMsimkFFx2AwyVpPcs+JfVBtpPbTcZscnzUdmiIvxv8Gcin6sNSibM6in/uUKFt3bVgW/XeMYa7MLGF53kvBSwi78poUDigA2n12SmghLR0AHxyEDIgZGOTbNI33GWu7ZsPBeUdGu55R8w='
  355. Stimulsoft.Base.Localization.StiLocalization.addLocalizationFile('/reports/stimulsoft/Localization/zh-CHS.xml', true, 'zh-CHS')
  356. Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile('/reports/stimulsoft/Localization/zh-CHS.xml')
  357. var options = new Stimulsoft.Designer.StiDesignerOptions()
  358. options.appearance.fullScreenMode = true
  359. options.allowChangeWindowTitle = false
  360. options.toolbar.showSaveDialog = false
  361. options.toolbar.showFileMenuSave = false
  362. options.toolbar.showFileMenuAbout = false
  363. options.toolbar.showFileMenuClose = false
  364. options.toolbar.showFileMenuExit = false
  365. options.toolbar.showFileMenuInfo = false
  366. options.toolbar.showFileMenuHelp = false
  367. options.toolbar.showFileMenuNew = false
  368. options.appearance.showTooltips = false
  369. options.appearance.showDialogsHelp = false
  370. options.toolbar.showSetupToolboxButton = true
  371. options.appearance.htmlRenderMode = Stimulsoft.Report.Export.StiHtmlExportMode.Table
  372. let designer = new Stimulsoft.Designer.StiDesigner(
  373. options,
  374. 'StiDesigner',
  375. false
  376. )
  377. designer.onSaveReport = (e) => {
  378. console.log('onSaveReport')
  379. // let jsObject = this.jsObject
  380. if (!e.report.isModified)
  381. return
  382. var jsonString = e.report.saveToJsonString()
  383. // console.log(jsonString)
  384. this.form.url = jsonString;
  385. console.log('保存url')
  386. console.log(jsonString)
  387. console.log('保存url结束')
  388. }
  389. let report = new window.Stimulsoft.Report.StiReport();
  390. report.styles.loadFile('static/Plugins/reports/css/Styles.sts')
  391. report.applyStyles()
  392. console.log("从 url 报表");
  393. console.log(url)
  394. console.log("结束");
  395. if (url) {
  396. report.load(url)
  397. }
  398. // 加载文件
  399. // if (this.id) {
  400. // billsDetail(this.id).then(res => {
  401. // var data = res.data.data
  402. // data.pageOne = 'Page : 1 of 1'
  403. // // 处理超长数据
  404. // if (data.hshipperDetails) {
  405. // var consignerIndex2 = data.hshipperDetails.indexOf( '\n' )
  406. // for (let i = 0; i < 4; i++) {
  407. // consignerIndex2 = data.hshipperDetails.indexOf( '\n', consignerIndex2 + 1 );
  408. // }
  409. // if (consignerIndex2 != -1) {
  410. // var hshipperDetails = data.hshipperDetails.substring(consignerIndex2 + 2, data.hshipperDetails.length)
  411. // data.hshipperDetails = data.hshipperDetails.substring(0, consignerIndex2) + ' *'
  412. // data.commodityDescr += '\n*' + hshipperDetails
  413. // }
  414. // }
  415. //
  416. // if (data.hconsigneeDetails) {
  417. // var consigneeIndex2 = data.hconsigneeDetails.indexOf( '\n' )
  418. // for (let i = 0; i < 3; i++) {
  419. // consigneeIndex2 = data.hconsigneeDetails.indexOf( '\n', consigneeIndex2 + 1 );
  420. // }
  421. // if (consigneeIndex2 != -1) {
  422. // var hconsigneeDetails = data.hconsigneeDetails.substring(consigneeIndex2 + 2, data.hconsigneeDetails.length)
  423. // data.hconsigneeDetails = data.hconsigneeDetails.substring(0, consigneeIndex2) + ' **'
  424. // data.commodityDescr += '\n**' + hconsigneeDetails
  425. // }
  426. // }
  427. //
  428. // if (data.hnotifyDetails) {
  429. // var notifierIndex2 = data.hnotifyDetails.indexOf( '\n' )
  430. // for (let i = 0; i < 3; i++) {
  431. // notifierIndex2 = data.hnotifyDetails.indexOf( '\n', notifierIndex2 + 1 );
  432. // }
  433. // if (notifierIndex2 != -1) {
  434. // var hnotifyDetails = data.hnotifyDetails.substring(notifierIndex2 + 2, data.hnotifyDetails.length)
  435. // data.hnotifyDetails = data.hnotifyDetails.substring(0, notifierIndex2) + ' ***'
  436. // data.commodityDescr += '\n***' + hnotifyDetails
  437. // }
  438. // }
  439. //
  440. // // 处理箱号
  441. // if (this.isPrintTheBoxNumber) {
  442. // data.commodityDescr += '\n.\n.\n'
  443. // }
  444. //
  445. // // PLACE & DATE OF ISSUE
  446. // data.placeAndDateOfIssue = ''
  447. // if (data.issueAt) {
  448. // data.placeAndDateOfIssue += data.issueAt
  449. // }
  450. // if (data.issueDate) {
  451. // let date = new Date(data.issueDate.replace(/-/g,'/'));
  452. // let yyyy = date.getFullYear();
  453. // let mmmm = date.toDateString().split(" ")[1]
  454. // let dd = date.getDate()
  455. // data.placeAndDateOfIssue += ', ' + dd + '-' + mmmm + '-' + yyyy
  456. // }
  457. //
  458. // // Total number of containers or packages received by the Carriers
  459. // if (data.preContainersList) {
  460. // let boxMap = new Map();
  461. // for (let boxQuantity of data.preContainersList) {
  462. // if (boxMap.get(boxQuantity.cntrTypeCode)) {
  463. // let v = boxMap.get(boxQuantity.cntrTypeCode)
  464. // boxMap.set(boxQuantity.cntrTypeCode, v + boxQuantity.quantity)
  465. // } else {
  466. // boxMap.set(boxQuantity.cntrTypeCode, boxQuantity.quantity)
  467. // }
  468. // }
  469. // let boxs = ''
  470. // boxMap.forEach(function (value, key, map) {
  471. // boxs += value + 'x' + key + ', '
  472. // })
  473. // boxs = boxs.substring(0, boxs.length - 2)
  474. //
  475. // data.boxQuantity = boxs + ' CONTAINER(S) ONLY'
  476. // }
  477. //
  478. // // Number of original B/Ls
  479. // if (data.numberOfObl) {
  480. // data.numberOfObl += ' (' + data.numberOfOblDigit + ')'
  481. // }
  482. //
  483. // if (data.commodityDescr) {
  484. // var descriptionIndex2 = data.commodityDescr.indexOf( '\n' )
  485. // for (let i = 0; i < 19; i++) {
  486. // descriptionIndex2 = data.commodityDescr.indexOf( '\n', descriptionIndex2 + 1 );
  487. // }
  488. // if (descriptionIndex2 != -1) {
  489. // data.pageOne = 'Page : 1 of 2'
  490. // data.pageTwo = 'Page : 2 of 2'
  491. // var extraLongText = data.commodityDescr.substring(descriptionIndex2 + 2, data.commodityDescr.length)
  492. // data.commodityDescr = data.commodityDescr.substring(0, descriptionIndex2)
  493. // data.extraLongTips = '** TO BE CONTINUED ON ATTACHED LIST **'
  494. // data.extraLongText = extraLongText
  495. // }
  496. // }
  497. // var dataSet = new Stimulsoft.System.Data.DataSet(
  498. // 'reportData'
  499. // )
  500. // dataSet.readJson(data)
  501. // report.regData('reportData', 'reportData', dataSet)
  502. // // 从模版和数据加载报表
  503. // // loadReport(report, '', {})
  504. //
  505. // designer.report = report
  506. // })
  507. // }
  508. // let data = [
  509. // {
  510. // id: 2,
  511. // billNo: 'JOB NO',
  512. // billDate: 'DATE',
  513. // operatorName: 'OP',
  514. // bookingNo: 'bookingNo',
  515. // mblno: 'ob/l no',
  516. // carrierCnName: 'CARRIER',
  517. // polCnName: 'POL',
  518. // vesselCnName: 'vsl/voy',
  519. // voyageNo: 'vsl/voy',
  520. // podCnName: 'POD',
  521. // cyCnName: 'DEPOT',
  522. // etd: 'etd/eta',
  523. // eta: 'etd/eta',
  524. // mpaymode: 'freight / freight',
  525. // volume: '箱型箱量',
  526. // hblno: 'hb/l no',
  527. // srcType: 'analysis1',
  528. // srcCnName: 'analysis2',
  529. // corpCnName: 'analysis3',
  530. // list: [
  531. // {
  532. // id:1,
  533. // pid:2,
  534. // feeCnNameData: 'fee list1',
  535. // usd: 'usd',
  536. // rmb: 'rmb',
  537. // tr: '税',
  538. // corpCnName: 'customer',
  539. // },
  540. // {
  541. // id:2,
  542. // pid:2,
  543. // feeCnNameData: 'fee list2',
  544. // usd: 'usd',
  545. // rmb: 'rmb',
  546. // tr: '税',
  547. // corpCnName: 'customer',
  548. // },
  549. // ]
  550. //
  551. // }, {
  552. // id:3,
  553. // billNo: 'JOB NO',
  554. // billDate: 'DATE',
  555. // operatorName: 'OP',
  556. // bookingNo: 'bookingNo',
  557. // mblno: 'ob/l no',
  558. // carrierCnName: 'CARRIER',
  559. // polCnName: 'POL',
  560. // vesselCnName: 'vsl/voy',
  561. // voyageNo: 'vsl/voy',
  562. // podCnName: 'POD',
  563. // cyCnName: 'DEPOT',
  564. // etd: 'etd/eta',
  565. // eta: 'etd/eta',
  566. // mpaymode: 'freight / freight',
  567. // volume: '箱型箱量',
  568. //
  569. // hblno: 'hb/l no',
  570. // srcType: 'analysis1',
  571. // srcCnName: 'analysis2',
  572. // corpCnName: 'analysis3',
  573. // list: [
  574. // {
  575. // id:3,
  576. // pid:3,
  577. // feeCnNameData: 'fee list',
  578. // usd: 'usd',
  579. // rmb: 'rmb',
  580. // tr: '税',
  581. // corpCnName: 'customer',
  582. // },
  583. // {
  584. // id:4,
  585. // pid:3,
  586. // feeCnNameData: 'fee list',
  587. // usd: 'usd',
  588. // rmb: 'rmb',
  589. // tr: '税',
  590. // corpCnName: 'customer',
  591. // },
  592. // ]
  593. //
  594. // }, {
  595. // id:4,
  596. // billNo: 'JOB NO',
  597. // billDate: 'DATE',
  598. // operatorName: 'OP',
  599. // bookingNo: 'bookingNo',
  600. // mblno: 'ob/l no',
  601. // carrierCnName: 'CARRIER',
  602. // polCnName: 'POL',
  603. // vesselCnName: 'vsl/voy',
  604. // voyageNo: 'vsl/voy',
  605. // podCnName: 'POD',
  606. // cyCnName: 'DEPOT',
  607. // etd: 'etd/eta',
  608. // eta: 'etd/eta',
  609. // mpaymode: 'freight / freight',
  610. // volume: '箱型箱量',
  611. //
  612. // hblno: 'hb/l no',
  613. // srcType: 'analysis1',
  614. // srcCnName: 'analysis2',
  615. // corpCnName: 'analysis3',
  616. // list: [
  617. // {
  618. // id:10,
  619. // pid:4,
  620. // feeCnNameData: 'fee list',
  621. // usd: 'usd',
  622. // rmb: 'rmb',
  623. // tr: '税',
  624. // corpCnName: 'customer',
  625. // },
  626. // {
  627. // id:11,
  628. // pid:4,
  629. // feeCnNameData: 'fee list',
  630. // usd: 'usd',
  631. // rmb: 'rmb',
  632. // tr: '税',
  633. // corpCnName: 'customer',
  634. // },
  635. // ]
  636. // },
  637. // ]
  638. // 获取报表数据
  639. const res = await reportsGetReportData({
  640. billId: this.id,
  641. reportCode: this.form.classifyCode,
  642. groupCode: this.form.groupCode,
  643. type: this.businessValue
  644. })
  645. console.log('获取的数据赋值', res.data.data.data)
  646. // 获取的数据赋值
  647. var data = res.data.data.data
  648. var dataSet = new Stimulsoft.System.Data.DataSet(
  649. 'reportData'
  650. )
  651. dataSet.readJson(data)
  652. report.regData('reportData', 'reportData', dataSet)
  653. // 从模版和数据加载报表
  654. // loadReport(report, '', {})
  655. designer.report = report
  656. this.designer = designer
  657. this.$refs.reportContainer.showContainer(
  658. () => {
  659. setTimeout(() => {
  660. designer.renderHtml('reportContainer')
  661. this.createDesignerButtons()
  662. }, 50)
  663. },
  664. () => { },
  665. )
  666. },
  667. testMail(e) {
  668. console.info('eeeeeeeeeeeeeeeeeeee----', e)
  669. this.$refs.mailComponentRef.dialogVisible = true
  670. this.$refs.mailComponentRef.formData.attachments = e.fileName
  671. this.$refs.mailComponentRef.formData.fileType = e.formatName
  672. this.$refs.mailComponentRef.formData.fileContent = e.data
  673. },
  674. // 预览报表
  675. handleReportPreview(url, row) {
  676. console.log(row, 698)
  677. Stimulsoft.Base.StiLicense.key = '6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHn0s4gy0Fr5YoUZ9V00Y0igCSFQzwEqYBh/N77k4f0fWXTHW5rqeBNLkaurJDenJ9o97TyqHs9HfvINK18Uwzsc/bG01Rq+x3H3Rf+g7AY92gvWmp7VA2Uxa30Q97f61siWz2dE5kdBVcCnSFzC6awE74JzDcJMj8OuxplqB1CYcpoPcOjKy1PiATlC3UsBaLEXsok1xxtRMQ283r282tkh8XQitsxtTczAJBxijuJNfziYhci2jResWXK51ygOOEbVAxmpflujkJ8oEVHkOA/CjX6bGx05pNZ6oSIu9H8deF94MyqIwcdeirCe60GbIQByQtLimfxbIZnO35X3fs/94av0ODfELqrQEpLrpU6FNeHttvlMc5UVrT4K+8lPbqR8Hq0PFWmFrbVIYSi7tAVFMMe2D1C59NWyLu3AkrD3No7YhLVh7LV0Tttr/8FrcZ8xirBPcMZCIGrRIesrHxOsZH2V8t/t0GXCnLLAWX+TNvdNXkB8cF2y9ZXf1enI064yE5dwMs2fQ0yOUG/xornE'
  678. // Stimulsoft.Base.StiLicense.Key = '6vJhGtLLLz2GNviWmUTrhSqnOItdDwjBylQzQcAOiHkcgIvwL0jnpsDqRpWg5FI5kt2G7A0tYIcUygBh1sPs7plofUOqPB1a4HBIXJB621mau2oiAIj+ysU7gKUXfjn/D5BocmduNB+ZMiDGPxFrAp3PoD0nYNkkWh8r7gBZ1v/JZSXGE3bQDrCQCNSy6mgby+iFAMV8/PuZ1z77U+Xz3fkpbm6MYQXYp3cQooLGLUti7k1TFWrnawT0iEEDJ2iRcU9wLqn2g9UiWesEZtKwI/UmEI2T7nv5NbgV+CHguu6QU4WWzFpIgW+3LUnKCT/vCDY+ymzgycw9A9+HFSzARiPzgOaAuQYrFDpzhXV+ZeX31AxWlnzjDWqpfluygSNPtGul5gyNt2CEoJD1Yom0VN9fvRonYsMsimkFFx2AwyVpPcs+JfVBtpPbTcZscnzUdmiIvxv8Gcin6sNSibM6in/uUKFt3bVgW/XeMYa7MLGF53kvBSwi78poUDigA2n12SmghLR0AHxyEDIgZGOTbNI33GWu7ZsPBeUdGu55R8w='
  679. Stimulsoft.Base.Localization.StiLocalization.addLocalizationFile('/reports/stimulsoft/Localization/zh-CHS.xml', true, 'zh-CHS')
  680. Stimulsoft.Base.Localization.StiLocalization.setLocalizationFile('/reports/stimulsoft/Localization/zh-CHS.xml')
  681. // 工具栏
  682. var options = new Stimulsoft.Viewer.StiViewerOptions()
  683. options.height = '100%'
  684. options.appearance.scrollbarsMode = true // 滚动条模式
  685. options.toolbar.showDesignButton = false // 显示设计按钮
  686. options.toolbar.showAboutButton = false // 显示关于按钮
  687. options.toolbar.showResourcesButton = false // 显示资源按钮
  688. options.toolbar.showFullScreenButton = false // 显示全屏按钮
  689. options.toolbar.showOpenButton = false // 显示打开按钮
  690. options.appearance.showTooltips = false // 显示工具提示
  691. options.appearance.showDialogsHelp = false // 显示对话框帮助
  692. options.exports.showExportToDocument = false // 显示导出到文档
  693. options.toolbar.showParametersButton = true // 显示参数按钮
  694. options.appearance.bookmarksPrint = true // 书签打印
  695. // options.toolbar.showPrintButton = false // 打印按钮是否显示 下面直接自定义控制打印弹窗是否开启
  696. options.toolbar.showSendEmailButton = true // 显示发送邮件按钮
  697. options.email.showEmailDialog = false
  698. options.email.showExportDialog = false
  699. // printDestination 参数:用于指定报表打印的目标位置,可以是打印机、PDF 文件或者直接打印到浏览器等。
  700. // Stimulsoft.Viewer.StiPrintDestination.Direct:表示直接打印到打印机,即将报表内容直接发送至打印机进行打印。
  701. // 通过设置不同的 printDestination 参数,你可以控制报表打印的行为,例如是直接打印到打印机,还是生成 PDF 文件,或者直接在浏览器中预览打印内容等。
  702. options.toolbar.printDestination = Stimulsoft.Viewer.StiPrintDestination.Direct
  703. // htmlRenderMode html渲染模式
  704. options.appearance.htmlRenderMode = Stimulsoft.Report.Export.StiHtmlExportMode.Table
  705. // 是创建一个 Stimulsoft 报表查看器的实例的代码
  706. let viewer = new Stimulsoft.Viewer.StiViewer(options, 'StiViewer', false)
  707. viewer.onEmailReport = this.testMail
  708. // 报表
  709. console.log("创建一个报表实例");
  710. let report = new window.Stimulsoft.Report.StiReport();
  711. // 加载文件
  712. console.log("从url加载报表");
  713. // report.loadFile("/reports/stimulsoft/demos/SimpleList.mrt");
  714. report.load(url)
  715. // 获取报告文件名更改文件名称
  716. report.reportAlias = this.assemblyForm.corpCnName.split(' - ')[0] + '-' + this.assemblyForm.mblno
  717. // report.reportName = '12313'
  718. // 获取报表数据
  719. // const res = await reportsGetReportData({
  720. // billId:this.id,
  721. // reportCode:this.form.code,
  722. // groupCode:this.form.groupCode,
  723. // })
  724. // // 获取的数据赋值
  725. // let data = res.data.data.data
  726. // 加载数据
  727. if (this.id) {
  728. // billsDetail(this.id).then(res => {
  729. reportsGetReportData({
  730. billId: this.id,
  731. reportCode: row.classifyCode,
  732. groupCode: row.groupCode,
  733. type: this.businessValue
  734. }).then(res => {
  735. // var data = res.data.data.data.map((item,index)=>{
  736. // item.index = index
  737. // item.feeCenterList.forEach(ite=>{
  738. // ite.ppid = index
  739. // })
  740. // return item
  741. // })
  742. var data = res.data.data.data
  743. console.log(data, 'hshipperDetails')
  744. // var aaa = data.hshipperDetails.split('\n')
  745. // console.log(aaa)
  746. data.pageOne = 'Page : 1 of 1'
  747. // 处理超长数据
  748. console.log(data.commodityDescr)
  749. if (data.hshipperDetails) {
  750. let arrDeteil = []
  751. arrDeteil = data.hshipperDetails.split('\n')
  752. if (arrDeteil.length > this.textareaNumber) {
  753. data.hshipperDetails = arrDeteil.slice(0, this.textareaNumber).join('\n') + '*'
  754. data.commodityDescr += "\n*" + arrDeteil.slice(this.textareaNumber, arrDeteil.length).join('\n')
  755. } else {
  756. data.hshipperDetails = data.hshipperDetails
  757. }
  758. }
  759. if (data.hconsigneeDetails) {
  760. let arrDeteil = []
  761. arrDeteil = data.hconsigneeDetails.split('\n')
  762. if (arrDeteil.length > this.textareaNumber) {
  763. data.hconsigneeDetails = arrDeteil.slice(0, this.textareaNumber).join('\n') + '**'
  764. data.commodityDescr += "\n**" + arrDeteil.slice(this.textareaNumber, arrDeteil.length).join('\n')
  765. } else {
  766. data.hconsigneeDetails = data.hconsigneeDetails
  767. }
  768. }
  769. if (data.hnotifyDetails) {
  770. let arrDeteil = []
  771. arrDeteil = data.hnotifyDetails.split('\n')
  772. if (arrDeteil.length > this.textareaNumber) {
  773. data.hnotifyDetails = arrDeteil.slice(0, this.textareaNumber).join('\n') + '***'
  774. data.commodityDescr += "\n***" + arrDeteil.slice(this.textareaNumber, arrDeteil.length).join('\n')
  775. } else {
  776. data.hnotifyDetails = data.hnotifyDetails
  777. }
  778. }
  779. console.log(data.commodityDescr)
  780. // 处理箱号
  781. if (this.isPrintTheBoxNumber) {
  782. data.commodityDescr += '\n.\n.\n'
  783. }
  784. // PLACE & DATE OF ISSUE
  785. data.placeAndDateOfIssue = ''
  786. if (data.issueAt) {
  787. data.placeAndDateOfIssue += data.issueAt
  788. }
  789. if (data.issueDate) {
  790. let date = new Date(data.issueDate.replace(/-/g, '/'));
  791. let yyyy = date.getFullYear();
  792. let mmmm = date.toDateString().split(" ")[1]
  793. let dd = date.getDate()
  794. data.placeAndDateOfIssue += ', ' + dd + '-' + mmmm + '-' + yyyy
  795. }
  796. // Total number of containers or packages received by the Carriers
  797. if (data.preContainersList) {
  798. let boxMap = new Map();
  799. for (let boxQuantity of data.preContainersList) {
  800. if (boxMap.get(boxQuantity.cntrTypeCode)) {
  801. let v = boxMap.get(boxQuantity.cntrTypeCode)
  802. boxMap.set(boxQuantity.cntrTypeCode, v + boxQuantity.quantity)
  803. } else {
  804. boxMap.set(boxQuantity.cntrTypeCode, boxQuantity.quantity)
  805. }
  806. }
  807. let boxs = ''
  808. boxMap.forEach(function (value, key, map) {
  809. boxs += value + 'x' + key + ', '
  810. })
  811. boxs = boxs.substring(0, boxs.length - 2)
  812. data.boxQuantity = boxs + ' CONTAINER(S) ONLY'
  813. }
  814. // Number of original B/Ls
  815. // if (data.numberOfObl) {
  816. // data.numberOfObl += ' (' + data.numberOfOblDigit + ')'
  817. // }
  818. if (data.commodityDescr) {
  819. var descriptionIndex2 = data.commodityDescr.indexOf('\n')
  820. for (let i = 0; i < 19; i++) {
  821. descriptionIndex2 = data.commodityDescr.indexOf('\n', descriptionIndex2 + 1);
  822. }
  823. if (descriptionIndex2 != -1) {
  824. data.pageOne = 'Page : 1 of 2'
  825. data.pageTwo = 'Page : 2 of 2'
  826. var extraLongText = data.commodityDescr.substring(descriptionIndex2 + 2, data.commodityDescr.length)
  827. // data.commodityDescr = data.commodityDescr.substring(0, descriptionIndex2)
  828. data.extraLongTips = '** TO BE CONTINUED ON ATTACHED LIST **'
  829. data.extraLongText = extraLongText
  830. }
  831. // let arrDeteil = []
  832. // arrDeteil = data.commodityDescr.split('\n')
  833. // if (arrDeteil.length > 18) {
  834. // data.commodityDescr = arrDeteil.slice(0, 18).join('\n')
  835. // }
  836. }
  837. // console.log(data.hshipperDetails, 'hshipperDetails2')
  838. // 创建一个 Stimulsoft 数据集(DataSet)的实例的代码
  839. var dataSet = new Stimulsoft.System.Data.DataSet(
  840. 'reportData'
  841. )
  842. dataSet.readJson(data) // 用于将 JSON 格式的数据加载到数据集中。data 是包含报表数据的 JSON 对象。
  843. // 这是一个方法调用,用于在报表中注册数据源。参数 'reportData' 是数据源的名称,
  844. // 第二个 'reportData' 是数据源的别名,dataSet 则是之前创建的数据集实例
  845. report.regData('reportData', 'reportData', dataSet)
  846. // 从模版和数据加载报表
  847. // loadReport(report, '', {})
  848. // 这是将报表对象指定给报表查看器的属性。viewer 是报表查看器的实例,而 report 是之前创建的报表对象。
  849. viewer.report = report;
  850. })
  851. }
  852. this.$refs.reportContainer.showContainer(
  853. () => {
  854. setTimeout(() => {
  855. viewer.renderHtml('reportContainer')
  856. this.createViewerButtons(viewer)
  857. }, 50)
  858. },
  859. () => {
  860. },
  861. )
  862. console.log("加载成功完成!");
  863. },
  864. loadReport(report, content, data) {
  865. var mimeString = content
  866. .split(',')[0]
  867. .split(':')[1]
  868. .split(';')[0]
  869. var byteString = atob(content.split(',')[1])
  870. var ab = new ArrayBuffer(byteString.length)
  871. var ia = new Uint8Array(ab)
  872. for (var i = 0; i < byteString.length; i++) {
  873. ia[i] = byteString.charCodeAt(i)
  874. }
  875. var blob = new Blob([ab])
  876. JSZip.loadAsync(blob).then(function (unziped) {
  877. unziped
  878. .file('reportfile.json')
  879. .async('string')
  880. .then(res => {
  881. report.load(res)
  882. if (!!data) {
  883. var dataSet = new Stimulsoft.System.Data.DataSet(
  884. 'reportData'
  885. )
  886. dataSet.readJson(data)
  887. report.regData('reportData', 'reportData', dataSet)
  888. }
  889. })
  890. })
  891. },
  892. createDesignerButtons(e) {
  893. console.log(e, 936)
  894. if (!!e) {
  895. try {
  896. this.designer.jsObject.options.menus.localizationMenu.addEventListener(
  897. 'click',
  898. this.createDesignerButtons
  899. )
  900. } catch (error) {
  901. }
  902. }
  903. let toolBarRow = this.designer.jsObject.options.toolBar.firstChild.tr[0]
  904. let customButton = this.designer.jsObject.StatusPanelButton(
  905. 'exitButton',
  906. '关闭',
  907. 'LoginControls.Window.CloseWhite.png',
  908. '关闭',
  909. null,
  910. 30,
  911. 60
  912. )
  913. customButton.image.style.width = customButton.image.style.height = '16px'
  914. let buttonCell = document.createElement('td')
  915. buttonCell.className = 'stiDesignerToolButtonCell'
  916. buttonCell.appendChild(customButton)
  917. toolBarRow.appendChild(buttonCell)
  918. let that = this
  919. customButton.action = function (e) {
  920. let jsObject = this.jsObject
  921. if (jsObject.options.reportIsModified) {
  922. var messageForm = jsObject.MessageFormForSave()
  923. messageForm.changeVisibleState(true)
  924. messageForm.action = function (state) {
  925. if (state) {
  926. jsObject.SendCommandSaveReport()
  927. setTimeout(() => {
  928. jsObject.SendCommandCloseReport()
  929. jsObject.designer.invokeExit()
  930. if (that.$refs.reportContainer)
  931. that.$refs.reportContainer.hideContainer()
  932. }, 250)
  933. } else {
  934. jsObject.SendCommandCloseReport()
  935. jsObject.designer.invokeExit()
  936. if (that.$refs.reportContainer)
  937. that.$refs.reportContainer.hideContainer()
  938. }
  939. }
  940. } else {
  941. jsObject.SendCommandCloseReport()
  942. jsObject.designer.invokeExit()
  943. if (that.$refs.reportContainer)
  944. that.$refs.reportContainer.hideContainer()
  945. }
  946. }
  947. },
  948. createViewerButtons(viewer) {
  949. viewer.jsObject.collections.images['myClose.png'] =
  950. 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABmJLR0QA/wD/AP+gvaeTAAAA0ElEQVQ4ja3TO05CQRQG4A8iOwAbtYWETndAaecK7NwCKmETtJZsSBNLobEz8ZFIJQ0UnOGSm3DnYviTybzO/895DQXGWGCVGQuMEqkRcwcfuMOLalziCaf4TIe9UG9nyMJmFRzNGoRK1BU4xxx9G7cfwostciGk+x8MqgySwDXe4tU53hVV+MNtTmAoX84JGv9NYgrHyR6DV8wUSW7hItZLm36ZVoVQxsFJLOMsPOrH/h7dQwR2cdxOTEn8DtUbPGc4V2H7Vb4Yqfedf/GYSGt8VUmxgyfuBAAAAABJRU5ErkJggg=='
  951. const closeBtn = viewer.jsObject.SmallButton(
  952. 'closeBtn',
  953. '关闭',
  954. 'myClose.png'
  955. )
  956. // 增加打印弹窗配置
  957. const printBtn = viewer.jsObject.SmallButton(
  958. 'printBtn',
  959. '打印报表',
  960. 'myClose.png'
  961. )
  962. // console.log(viewer.jsObject.print(),'1013')
  963. // 获取 关闭按钮的dom元素位置
  964. const toolbarTable = viewer.jsObject.controls.toolbar.firstChild.firstChild
  965. const buttonsTable = toolbarTable.rows[0].lastChild.lastChild
  966. const userButtonCell = buttonsTable.rows[0].insertCell(0)
  967. // 获取打印按钮的位置
  968. const buttonsTablePrint = toolbarTable.rows[0].childNodes[0].lastChild // 打印按钮
  969. const userButtonPrint = buttonsTablePrint.rows[0].childNodes[0] // 打印按钮dom位置
  970. userButtonPrint.addEventListener("click", (event) => {
  971. console.log("打印点击");
  972. // event.preventDefault()
  973. });
  974. userButtonPrint.addEventListener("mouseover", (event) => {
  975. console.log("移入打印按钮");
  976. console.log(event, 1035)
  977. });
  978. userButtonCell.className = 'stiJsViewerClearAllStyles'
  979. userButtonCell.appendChild(closeBtn) // 添加关闭节点
  980. // userButtonPrint.prepend(printBtn) // 在 printBtn 节点里最前面增加一个子级节点
  981. let that = this
  982. // 关闭按钮的监听点击
  983. closeBtn.action = function () {
  984. console.log(that.$refs.ReportContainer, '1022')
  985. if (that.$refs.reportContainer)
  986. that.$refs.reportContainer.hideContainer()
  987. }
  988. // // // 打印按钮监听
  989. // printBtn.action = (e)=>{
  990. // console.log('打印')
  991. // window.print()
  992. // }
  993. },
  994. addedData(type, scope) {
  995. this.form = {};
  996. if (type == 1) {
  997. this.bbDisabled = true;
  998. this.$refs.crud.rowView(scope.row, scope.$index);
  999. } else if (type == 2) {
  1000. this.bbDisabled = true;
  1001. var userIdList = [];
  1002. userIdList = scope.row.authorizedUsersId
  1003. let userObj = JSON.parse(localStorage.getItem("saber-userInfo")).content;
  1004. for (let id of userIdList) {
  1005. if (id == userObj.user_id) {
  1006. this.bbDisabled = false;
  1007. }
  1008. }
  1009. if (userObj.role_name.indexOf('admin') != -1 || userObj.role_name.indexOf('报表管理') != -1) {
  1010. this.bbDisabled = false;
  1011. }
  1012. this.$refs.crud.rowEdit(scope.row, scope.$index);
  1013. } else if (type == 3) {
  1014. this.bbDisabled = false;
  1015. this.$refs.crud.rowAdd();
  1016. }
  1017. },
  1018. // 添加
  1019. rowSave(row, done, loading) {
  1020. // row.authorizedUsersId = row.authorizedUsersId.join()
  1021. row.businessType = this.businessValue
  1022. add(row).then(() => {
  1023. this.onLoad(this.page);
  1024. this.$message({
  1025. type: "success",
  1026. message: "操作成功!"
  1027. });
  1028. done();
  1029. }, error => {
  1030. loading();
  1031. window.console.log(error);
  1032. });
  1033. },
  1034. rowUpdate(row, index, done, loading) {
  1035. // console.log(row.authorizedUsersId)
  1036. // row.authorizedUsersId = row.authorizedUsersId.join()
  1037. update(row).then(() => {
  1038. this.onLoad(this.page);
  1039. this.$message({
  1040. type: "success",
  1041. message: "操作成功!"
  1042. });
  1043. done();
  1044. }, error => {
  1045. loading();
  1046. console.log(error);
  1047. });
  1048. },
  1049. rowDel(row) {
  1050. this.$confirm("确定将选择数据删除?", {
  1051. confirmButtonText: "确定",
  1052. cancelButtonText: "取消",
  1053. type: "warning"
  1054. })
  1055. .then(() => {
  1056. return reportsRemove2(row.id);
  1057. })
  1058. .then(() => {
  1059. this.onLoad(this.page);
  1060. this.$message({
  1061. type: "success",
  1062. message: "操作成功!"
  1063. });
  1064. });
  1065. },
  1066. handleDelete() {
  1067. if (this.selectionList.length === 0) {
  1068. this.$message.warning("请选择至少一条数据");
  1069. return;
  1070. }
  1071. this.$confirm("确定将选择数据删除?", {
  1072. confirmButtonText: "确定",
  1073. cancelButtonText: "取消",
  1074. type: "warning"
  1075. })
  1076. .then(() => {
  1077. return reportsRemove2(this.ids);
  1078. })
  1079. .then(() => {
  1080. this.onLoad(this.page);
  1081. this.$message({
  1082. type: "success",
  1083. message: "操作成功!"
  1084. });
  1085. this.$refs.crud.toggleSelection();
  1086. });
  1087. },
  1088. beforeOpen(done, type) {
  1089. if (["edit", "view"].includes(type)) {
  1090. reportsDetail(this.form.id).then(res => {
  1091. this.form = res.data.data;
  1092. });
  1093. }
  1094. done();
  1095. },
  1096. searchReset() {
  1097. this.query = {};
  1098. this.onLoad(this.page);
  1099. },
  1100. searchChange(params, done) {
  1101. this.query = params;
  1102. this.page.currentPage = 1;
  1103. this.onLoad(this.page, params);
  1104. done();
  1105. },
  1106. selectionChange(list) {
  1107. this.selectionList = list;
  1108. },
  1109. selectionClear() {
  1110. this.selectionList = [];
  1111. this.$refs.crud.toggleSelection();
  1112. },
  1113. currentChange(currentPage) {
  1114. this.page.currentPage = currentPage;
  1115. },
  1116. sizeChange(pageSize) {
  1117. this.page.pageSize = pageSize;
  1118. },
  1119. refreshChange() {
  1120. this.onLoad(this.page, this.query);
  1121. },
  1122. onLoad(page, params = {}) {
  1123. this.loading = true;
  1124. params.businessType = this.businessValue
  1125. if (this.groupCode) {
  1126. params.groupCode = this.groupCode
  1127. }
  1128. getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  1129. const data = res.data.data;
  1130. this.page.total = data.total;
  1131. this.data = data.records;
  1132. this.loading = false;
  1133. this.selectionClear();
  1134. });
  1135. },
  1136. //自定义列保存
  1137. async saveColumnTwo(ref, option, optionBack, code) {
  1138. /**
  1139. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  1140. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  1141. * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
  1142. */
  1143. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  1144. if (inSave) {
  1145. this.$message.success("保存成功");
  1146. //关闭窗口
  1147. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  1148. }
  1149. },
  1150. //自定义列重置
  1151. async resetColumnTwo(ref, option, optionBack, code) {
  1152. this[option] = this[optionBack];
  1153. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  1154. if (inSave) {
  1155. this.$message.success("重置成功");
  1156. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  1157. }
  1158. },
  1159. // 更改表格颜色
  1160. headerClassName(tab) {
  1161. //颜色间隔
  1162. let back = ""
  1163. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  1164. if (tab.columnIndex % 2 === 0) {
  1165. back = "back-one"
  1166. } else if (tab.columnIndex % 2 === 1) {
  1167. back = "back-two"
  1168. }
  1169. }
  1170. return back;
  1171. },
  1172. }
  1173. };
  1174. </script>
  1175. <style lang="scss" scoped>
  1176. ::v-deep#out-table .back-one {
  1177. background: #ecf5ff !important;
  1178. }
  1179. ::v-deep#out-table .back-two {
  1180. background: #ecf5ff !important;
  1181. }
  1182. ::v-deep .el-input-group__append {
  1183. padding: 0 0px !important;
  1184. }
  1185. /deep/ .el-tree-node__content>.el-tree-node__expand-icon {
  1186. visibility: hidden;
  1187. }
  1188. /deep/ .el-col-md-8 {
  1189. width: 24.33333%;
  1190. }
  1191. </style>