reports.vue 44 KB

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