index.vue 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. <!-- 船名 -->
  2. <template>
  3. <basic-container>
  4. <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :permission="permissionList"
  5. id="out-table" :header-cell-class-name="headerClassName" :before-open="beforeOpen" :search.sync="search"
  6. v-model="form" ref="crud" @row-update="rowUpdate" @row-save="rowSave" @row-del="rowDel"
  7. @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
  8. @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
  9. @resetColumn="resetColumnTwo('crud', 'option', 'optionBack', 293)"
  10. @saveColumn="saveColumnTwo('crud', 'option', 'optionBack', 293)" @on-load="onLoad">
  11. <!-- <template slot-scope="scope" slot="status">
  12. <el-checkbox v-model="scope.row.status" :true-label="0" :false-label="1" @change="putStatus(scope.row)">启用</el-checkbox>
  13. </template> -->
  14. <template slot-scope="scope" slot="extendedDataArr">
  15. <span style="color: #1e9fff" @click="extendedDataview(scope.row)">
  16. {{ scope.row.extendedDataArr.length }}
  17. </span>
  18. </template>
  19. <template slot-scope="{type,disabled,row}" slot="extendedDataArrForm">
  20. <el-button type="primary" size="small" @click="dialogVisible = true">EDI CODE
  21. </el-button>
  22. </template>
  23. <template slot="code" slot-scope="scope">
  24. <avue-text-ellipsis :text="scope.row.code" :height="30" use-tooltip placement="top">
  25. <small slot="more">...</small>
  26. </avue-text-ellipsis>
  27. </template>
  28. <template slot="cnName" slot-scope="scope">
  29. <avue-text-ellipsis :text="scope.row.cnName" :height="30" use-tooltip placement="top">
  30. <small slot="more">...</small>
  31. </avue-text-ellipsis>
  32. </template>
  33. <template slot="enName" slot-scope="scope">
  34. <avue-text-ellipsis :text="scope.row.enName" :height="30" use-tooltip placement="top">
  35. <small slot="more">...</small>
  36. </avue-text-ellipsis>
  37. </template>
  38. <template slot="cntyCode" slot-scope="scope">
  39. <avue-text-ellipsis :text="scope.row.enName" :height="30" use-tooltip placement="top">
  40. <small slot="more">...</small>
  41. </avue-text-ellipsis>
  42. </template>
  43. <template slot="cntyName" slot-scope="scope">
  44. <avue-text-ellipsis :text="scope.row.enName" :height="30" use-tooltip placement="top">
  45. <small slot="more">...</small>
  46. </avue-text-ellipsis>
  47. </template>
  48. <template slot="remarks" slot-scope="scope">
  49. <avue-text-ellipsis :text="scope.row.remarks" :height="30" use-tooltip placement="top">
  50. <small slot="more">...</small>
  51. </avue-text-ellipsis>
  52. </template>
  53. <template slot="menuLeft">
  54. <el-button type="primary" size="small" icon="el-icon-plus" @click="addbtnfun()">新建船名
  55. </el-button>
  56. <el-button type="danger" size="small" icon="el-icon-delete" plain @click="handleDelete">删 除
  57. </el-button>
  58. <el-button type="warning" size="small" icon="el-icon-printer" @click="excelBox = true">导入
  59. </el-button>
  60. <el-button type="success" size="small" @click="handleExport" icon="el-icon-printer">导出</el-button>
  61. </template>
  62. <template slot-scope="scope" slot="menu">
  63. <el-button type="text" icon="el-icon-view" size="small" @click.stop="rowViewfun(scope.row, scope.index)">查看
  64. </el-button>
  65. <el-button type="text" icon="el-icon-edit" size="small" @click.stop="rowEditfun(scope.row, scope.index)">编辑
  66. </el-button>
  67. <el-button type="text" icon="el-icon-edit" size="small" @click.stop="rowDel(scope.row, scope.index)">删除
  68. </el-button>
  69. </template>
  70. </avue-crud>
  71. <el-dialog title="EDI CODE" :visible.sync="dialogVisible" width="50%" append-to-body :destroy-on-close="true"
  72. :modal-append-to-body="false" :before-close="handleClose">
  73. <div>
  74. <el-button type="primary" size="small" :disabled="extendedDisabled" @click="extendedDataAdd">新增
  75. </el-button>
  76. <el-table stripe :data="form.extendedDataArr" id="out-table" :header-cell-class-name="headerClassName"
  77. style="width: 100%">
  78. <el-table-column prop="name" label="名称">
  79. <template slot-scope="{row}">
  80. <el-input v-if="row.edit" size="mini" v-model="row.name" placeholder="请输入名称"></el-input>
  81. <span v-else>{{ row.name }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column prop="value" label="键值">
  85. <template slot-scope="{row}">
  86. <el-input v-if="row.edit" size="mini" v-model="row.value" placeholder="请输入键值"></el-input>
  87. <span v-else>{{ row.value }}</span>
  88. </template>
  89. </el-table-column>
  90. <el-table-column label="操作">
  91. <template slot-scope="scope">
  92. <el-button type="text" size="mini" :disabled="extendedDisabled"
  93. @click="extendedDataEdit(scope.$index, scope.row)">{{ scope.row.edit ? '保存' : '编辑' }}</el-button>
  94. <el-button size="mini" type="text" :disabled="extendedDisabled"
  95. @click="extendedDataDelete(scope.$index, scope.row)">删除</el-button>
  96. </template>
  97. </el-table-column>
  98. </el-table>
  99. </div>
  100. <span slot="footer" class="dialog-footer">
  101. <el-button @click="dialogVisible = false; extendedDisabled = false">取 消</el-button>
  102. <el-button type="primary" @click="dialogVisible = false; extendedDisabled = false">确 定</el-button>
  103. </span>
  104. </el-dialog>
  105. <el-dialog title="导入往来单位" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"
  106. v-dialog-drag>
  107. <avue-form :option="excelOption" v-model="excelForm" :table-loading="excelLoading" :upload-before="uploadBefore"
  108. :upload-after="onSuccess">
  109. <template slot="excelTemplate">
  110. <el-button type="primary" @click="handleGet">
  111. 点击下载<i class="el-icon-download el-icon--right"></i>
  112. </el-button>
  113. </template>
  114. </avue-form>
  115. <p style="text-align: center;color: #DC0505">
  116. 温馨提示 第一次导入时请先下载模板
  117. </p>
  118. </el-dialog>
  119. </basic-container>
  120. </template>
  121. <script>
  122. import { getBvesselsList, getBvesselsDetail, addBvessels, updateBvessels, removeBvessels } from "@/api/iosBasicData/bvessels";
  123. import { mapGetters } from "vuex";
  124. import { getToken } from "@/util/auth";
  125. export default {
  126. data() {
  127. return {
  128. // 扩展数据弹窗
  129. dialogVisible: false,
  130. form: {
  131. extendedDataArr: []
  132. },
  133. // form: {},
  134. query: {},
  135. loading: true,
  136. excelBox: false,
  137. search: {},
  138. excelForm: {},
  139. excelLoading: false,
  140. excelOption: {
  141. submitBtn: false,
  142. emptyBtn: false,
  143. column: [
  144. {
  145. label: "模板下载",
  146. prop: "excelTemplate",
  147. formslot: true,
  148. span: 24
  149. },
  150. {
  151. label: "模板上传",
  152. prop: "excelFile",
  153. type: "upload",
  154. drag: true,
  155. loadText: "模板上传中,请稍等",
  156. span: 24,
  157. propsHttp: {
  158. res: "data"
  159. },
  160. tip: "请上传 .xls,.xlsx 标准格式文件",
  161. action: "/api/blade-los/bvessels/importBVessels"
  162. }
  163. ]
  164. },
  165. page: {
  166. pageSize: 10,
  167. currentPage: 1,
  168. total: 0
  169. },
  170. selectionList: [],
  171. option: {},
  172. optionBack: {
  173. addBtnText: '新建船名',
  174. addTitle: '新建船名',
  175. editBtnText: '编辑船名',
  176. editTitle: '编辑船名',
  177. viewBtnText: '查看船名',
  178. viewTitle: '查看船名',
  179. labelWidth: 120,
  180. height: 'auto',
  181. stripe: true,
  182. searchIcon: true,
  183. searchIndex: 3,
  184. calcHeight: 30,
  185. tip: false,
  186. searchShow: true,
  187. searchMenuSpan: 6,
  188. border: true,
  189. index: true,
  190. viewBtn: true,
  191. selection: true,
  192. dialogClickModal: false,
  193. column: [
  194. // {
  195. // label: "主键",
  196. // prop: "id",
  197. // rules: [{
  198. // required: true,
  199. // message: "请输入主键",
  200. // trigger: "blur"
  201. // }]
  202. // },
  203. // {
  204. // label: "创建人 Id",
  205. // prop: "createUser",
  206. // rules: [{
  207. // required: true,
  208. // message: "请输入创建人 Id",
  209. // trigger: "blur"
  210. // }]
  211. // },
  212. // {
  213. // label: "创建人",
  214. // prop: "createUserName",
  215. // rules: [{
  216. // required: true,
  217. // message: "请输入创建人",
  218. // trigger: "blur"
  219. // }]
  220. // },
  221. // {
  222. // label: "创建部门 Id",
  223. // prop: "createDept",
  224. // rules: [{
  225. // required: true,
  226. // message: "请输入创建部门 Id",
  227. // trigger: "blur"
  228. // }]
  229. // },
  230. // {
  231. // label: "创建部门",
  232. // prop: "createDeptName",
  233. // rules: [{
  234. // required: true,
  235. // message: "请输入创建部门",
  236. // trigger: "blur"
  237. // }]
  238. // },
  239. // {
  240. // label: "创建时间",
  241. // prop: "createTime",
  242. // rules: [{
  243. // required: true,
  244. // message: "请输入创建时间",
  245. // trigger: "blur"
  246. // }]
  247. // },
  248. // {
  249. // label: "修改人 Id",
  250. // prop: "updateUser",
  251. // rules: [{
  252. // required: true,
  253. // message: "请输入修改人 Id",
  254. // trigger: "blur"
  255. // }]
  256. // },
  257. // {
  258. // label: "修改人",
  259. // prop: "updateUserName",
  260. // rules: [{
  261. // required: true,
  262. // message: "请输入修改人",
  263. // trigger: "blur"
  264. // }]
  265. // },
  266. // {
  267. // label: "修改时间",
  268. // prop: "updateTime",
  269. // rules: [{
  270. // required: true,
  271. // message: "请输入修改时间",
  272. // trigger: "blur"
  273. // }]
  274. // },
  275. {
  276. label: "编码",
  277. prop: "code",
  278. width: "180",
  279. search: true,
  280. slot: true,
  281. rules: [{
  282. required: true,
  283. message: "请输入编码",
  284. trigger: "blur"
  285. }]
  286. },
  287. {
  288. label: "中文船名",
  289. prop: "cnName",
  290. width: "180",
  291. search: true,
  292. slot: true,
  293. rules: [{
  294. required: true,
  295. message: "请输入中文船名",
  296. trigger: "blur"
  297. }]
  298. },
  299. {
  300. label: "英文船名",
  301. prop: "enName",
  302. width: "180",
  303. search: true,
  304. slot: true,
  305. rules: [{
  306. required: true,
  307. message: "请输入英文船名",
  308. trigger: "blur"
  309. }]
  310. },
  311. {
  312. label: "船舶注册国家编码",
  313. prop: "cntyCode",
  314. search: true,
  315. slot: true,
  316. width: "120"
  317. },
  318. {
  319. label: "船舶注册国家名称",
  320. prop: "cntyName",
  321. search: true,
  322. slot: true,
  323. width: "120"
  324. },
  325. {
  326. label: "船舶呼号",
  327. prop: "afrno",
  328. search: true,
  329. },
  330. {
  331. label: "IMONO",
  332. prop: "imono",
  333. },
  334. {
  335. label: "MMSI",
  336. prop: "mmsi",
  337. },
  338. {
  339. label: "船公司 Id",
  340. prop: "carrierId",
  341. search: true,
  342. hide: true,
  343. // rules: [{
  344. // required: true,
  345. // message: "请输入船公司 Id",
  346. // trigger: "blur"
  347. // }]
  348. },
  349. {
  350. label: "船公司名称",
  351. prop: "carrierName",
  352. width: "100",
  353. display: false,
  354. },
  355. {
  356. label: "港务局编码",
  357. prop: "portOfficeCode",
  358. search: true,
  359. width: "100",
  360. // rules: [{
  361. // required: true,
  362. // message: "请输入港务局编码",
  363. // trigger: "blur"
  364. // }]
  365. },
  366. {
  367. label: "港务局中文船名",
  368. prop: "portOfficeCnName",
  369. search: true,
  370. width: "120",
  371. // rules: [{
  372. // required: true,
  373. // message: "请输入港务局中文船名",
  374. // trigger: "blur"
  375. // }]
  376. },
  377. {
  378. label: "港务局英文船名",
  379. prop: "portOfficeEnName",
  380. search: true,
  381. width: "120",
  382. // rules: [{
  383. // required: true,
  384. // message: "请输入港务局英文船名",
  385. // trigger: "blur"
  386. // }]
  387. },
  388. {
  389. label: "港务局船公司编码",
  390. prop: "portOfficeCarrierCode",
  391. search: true,
  392. width: "120",
  393. // rules: [{
  394. // required: true,
  395. // message: "请输入港务局船公司编码",
  396. // trigger: "blur"
  397. // }]
  398. },
  399. {
  400. label: "EDI CODE",
  401. prop: "extendedDataArr",
  402. type: 'tree',
  403. formslot: true,
  404. dicData: [],
  405. // rules: [{
  406. // required: true,
  407. // message: "请输入EDI CODE",
  408. // trigger: "blur"
  409. // }]
  410. },
  411. // {
  412. // label: "JSON 对象数组,用于不查询的扩展数据, 例如:[{name: "key1", value: "value1"}]",
  413. // prop: "extendedData",
  414. // rules: [{
  415. // required: true,
  416. // message: "请输入JSON 对象数组,用于不查询的扩展数据, 例如:[{name: "key1", value: "value1"}]",
  417. // trigger: "blur"
  418. // }]
  419. // },
  420. {
  421. label: "版本",
  422. prop: "version",
  423. display: false,
  424. },
  425. {
  426. label: "状态",
  427. prop: "status",
  428. type: "select",
  429. dicData: [{
  430. label: '启用',
  431. value: 0
  432. }, {
  433. label: '停用',
  434. value: 1
  435. }],
  436. value: 0
  437. },
  438. // {
  439. // label: "是否已删除(0 否 1是)",
  440. // prop: "isDeleted",
  441. // rules: [{
  442. // required: true,
  443. // message: "请输入是否已删除(0 否 1是)",
  444. // trigger: "blur"
  445. // }]
  446. // },
  447. {
  448. label: "备注",
  449. prop: "remarks",
  450. type: 'textarea',
  451. width: 180,
  452. slot: true,
  453. minRows: 3,
  454. span: 24,
  455. },
  456. ]
  457. },
  458. data: []
  459. };
  460. },
  461. computed: {
  462. ...mapGetters(["permission"]),
  463. permissionList() {
  464. return {
  465. addBtn: this.vaildData(this.permission.bvessels_add, false),
  466. viewBtn: this.vaildData(this.permission.bvessels_view, false),
  467. delBtn: this.vaildData(this.permission.bvessels_delete, false),
  468. editBtn: this.vaildData(this.permission.bvessels_edit, false)
  469. };
  470. },
  471. ids() {
  472. let ids = [];
  473. this.selectionList.forEach(ele => {
  474. ids.push(ele.id);
  475. });
  476. return ids.join(",");
  477. }
  478. },
  479. async created() {
  480. this.option = await this.getColumnData(this.getColumnName(293), this.optionBack);
  481. },
  482. methods: {
  483. // 导出
  484. handleExport() {
  485. var condition = ''
  486. for (const key in this.search) {
  487. var value = this.search[key]
  488. if (value) {
  489. condition += `&${key}=${this.search[key]}`
  490. }
  491. }
  492. this.$confirm('是否导出船名?', '提示', {
  493. confirmButtonText: '确定',
  494. cancelButtonText: '取消',
  495. type: 'warning'
  496. }).then(() => {
  497. window.open(
  498. `/api/blade-los/bvessels/exportBVessels?${this.website.tokenHeader
  499. }=${getToken()}${condition}`
  500. );
  501. }).catch(() => {
  502. this.$message({
  503. type: 'info',
  504. message: '已取消' //
  505. });
  506. })
  507. },
  508. uploadBefore(file, done, loading) {
  509. done();
  510. loading = true;
  511. },
  512. // 上传成功
  513. onSuccess(res, done, loading, column) {
  514. this.excelBox = false;
  515. this.$message.success("导入成功!");
  516. loading = false;
  517. this.onLoad(this.page);
  518. done();
  519. },
  520. // 下载模板
  521. handleGet() {
  522. window.open(
  523. `/api/blade-los/bvessels/exportBVessels/template?${this.website.tokenHeader
  524. }=${getToken()}`
  525. );
  526. },
  527. // 扩展数据详情的---------------------------------------
  528. // 扩展数据添加
  529. extendedDataAdd() {
  530. this.form.extendedDataArr.map(item => {
  531. item.edit = false
  532. })
  533. this.form.extendedDataArr.push({
  534. edit: true
  535. })
  536. },
  537. // 扩展数据编辑
  538. extendedDataEdit(index, row) {
  539. // row.edit = !row.edit
  540. this.$set(row, 'edit', !row.edit)
  541. },
  542. // 扩展数据删除
  543. extendedDataDelete(index, row) {
  544. this.form.extendedDataArr.splice(index, 1)
  545. },
  546. // 扩展数据表格点击查询详情
  547. extendedDataview(row) {
  548. this.form = row
  549. this.extendedDisabled = true
  550. this.dialogVisible = true
  551. },
  552. // 扩展数据弹窗关闭
  553. handleClose(done) {
  554. this.$confirm('确认关闭?')
  555. .then(_ => {
  556. done();
  557. })
  558. .catch(_ => { });
  559. },
  560. // 表格操作------------------------------------------------------------
  561. // 新增
  562. addbtnfun() {
  563. this.form.status = 0
  564. this.$refs.crud.rowAdd()
  565. },
  566. // 查看
  567. rowViewfun(row, index) {
  568. this.extendedDisabled = true
  569. this.$refs.crud.rowView(row, index)
  570. },
  571. // 编辑
  572. rowEditfun(row, index) {
  573. getBvesselsDetail(row.id).then(res => {
  574. this.form = res.data.data;
  575. this.form.extendedDataArr.map(item => {
  576. item.edit = false
  577. })
  578. this.$refs.crud.rowEdit(row, index)
  579. });
  580. },
  581. rowSave(row, done, loading) {
  582. if (row.extendedDataArr) {
  583. row.extendedDataArr.map(item => {
  584. delete item.edit
  585. })
  586. }
  587. row.extendedData = JSON.stringify(row.extendedDataArr)
  588. delete row.extendedDataArr
  589. addBvessels(row).then(() => {
  590. this.onLoad(this.page);
  591. this.$message({
  592. type: "success",
  593. message: "操作成功!"
  594. });
  595. done();
  596. }, error => {
  597. loading();
  598. window.console.log(error);
  599. });
  600. },
  601. rowUpdate(row, index, done, loading) {
  602. // if (row.status === 1) {
  603. if (row.extendedDataArr) {
  604. row.extendedDataArr.map(item => {
  605. delete item.edit
  606. })
  607. }
  608. row.extendedData = JSON.stringify(row.extendedDataArr)
  609. delete row.extendedDataArr
  610. updateBvessels(row).then(() => {
  611. this.onLoad(this.page);
  612. this.$message({
  613. type: "success",
  614. message: "操作成功!"
  615. });
  616. done();
  617. }, error => {
  618. loading();
  619. console.log(error);
  620. });
  621. // } else {
  622. // this.$message({
  623. // message: '非禁用状态无法修改',
  624. // type: 'warning'
  625. // });
  626. // }
  627. },
  628. // putStatus(row) {
  629. // console.log(row.status);
  630. // if (row.status == 0) {
  631. // row.status = 1
  632. // } else if (row.status == 1) {
  633. // row.status = 0
  634. // }
  635. // updateBvessels(row).then(() => {
  636. // this.onLoad(this.page);
  637. // this.$message({
  638. // type: "success",
  639. // message: "操作成功!"
  640. // });
  641. // }, error => {
  642. // loading();
  643. // console.log(error);
  644. // });
  645. // // this.$forceUpdate
  646. // },
  647. rowDel(row) {
  648. if (row.status === 1) {
  649. this.$confirm("确定将选择数据删除?", {
  650. confirmButtonText: "确定",
  651. cancelButtonText: "取消",
  652. type: "warning"
  653. })
  654. .then(() => {
  655. return removeBvessels(row.id);
  656. })
  657. .then(() => {
  658. this.onLoad(this.page);
  659. this.$message({
  660. type: "success",
  661. message: "操作成功!"
  662. });
  663. });
  664. } else {
  665. this.$message({
  666. message: '非禁用状态无法删除',
  667. type: 'warning'
  668. });
  669. }
  670. },
  671. handleDelete() {
  672. if (this.selectionList.length === 0) {
  673. this.$message.warning("请选择至少一条数据");
  674. return;
  675. }
  676. for (const selection of this.selectionList) {
  677. if (selection.status == 0) {
  678. this.$message.warning("选中的数据中有启用数据,启用数据不可删除!");
  679. return;
  680. }
  681. }
  682. this.$confirm("确定将选择数据删除?", {
  683. confirmButtonText: "确定",
  684. cancelButtonText: "取消",
  685. type: "warning"
  686. })
  687. .then(() => {
  688. return removeBvessels(this.ids);
  689. })
  690. .then(() => {
  691. this.onLoad(this.page);
  692. this.$message({
  693. type: "success",
  694. message: "操作成功!"
  695. });
  696. this.$refs.crud.toggleSelection();
  697. });
  698. },
  699. beforeOpen(done, type) {
  700. if (["edit", "view"].includes(type)) {
  701. getBvesselsDetail(this.form.id).then(res => {
  702. this.form = res.data.data;
  703. });
  704. }
  705. done();
  706. },
  707. searchReset() {
  708. this.query = {};
  709. this.onLoad(this.page);
  710. },
  711. searchChange(params, done) {
  712. this.query = params;
  713. this.page.currentPage = 1;
  714. this.onLoad(this.page, params);
  715. done();
  716. },
  717. selectionChange(list) {
  718. this.selectionList = list;
  719. },
  720. selectionClear() {
  721. this.selectionList = [];
  722. this.$refs.crud.toggleSelection();
  723. },
  724. currentChange(currentPage) {
  725. this.page.currentPage = currentPage;
  726. },
  727. sizeChange(pageSize) {
  728. this.page.pageSize = pageSize;
  729. },
  730. refreshChange() {
  731. this.onLoad(this.page, this.query);
  732. },
  733. onLoad(page, params = {}) {
  734. this.loading = true;
  735. getBvesselsList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
  736. const data = res.data.data;
  737. this.page.total = data.total;
  738. this.data = data.records;
  739. this.loading = false;
  740. this.selectionClear();
  741. });
  742. },
  743. //自定义列保存
  744. async saveColumnTwo(ref, option, optionBack, code) {
  745. /**
  746. * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
  747. * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
  748. * 一定要执行异步操作,要等接口成功返回,才能执行下一行编码
  749. */
  750. const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
  751. if (inSave) {
  752. this.$message.success("保存成功");
  753. //关闭窗口
  754. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  755. }
  756. },
  757. //自定义列重置
  758. async resetColumnTwo(ref, option, optionBack, code) {
  759. this[option] = this[optionBack];
  760. const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
  761. if (inSave) {
  762. this.$message.success("重置成功");
  763. this.$refs[ref].$refs.dialogColumn.columnBox = false;
  764. }
  765. },
  766. // 更改表格颜色
  767. headerClassName(tab) {
  768. //颜色间隔
  769. let back = ""
  770. if (tab.columnIndex >= 0 && tab.column.level === 1) {
  771. if (tab.columnIndex % 2 === 0) {
  772. back = "back-one"
  773. } else if (tab.columnIndex % 2 === 1) {
  774. back = "back-two"
  775. }
  776. }
  777. return back;
  778. },
  779. }
  780. };
  781. </script>
  782. <style lang="scss" scoped>
  783. ::v-deep#out-table .back-one {
  784. background: #ecf5ff !important;
  785. }
  786. ::v-deep#out-table .back-two {
  787. background: #ecf5ff !important;
  788. }
  789. /deep/ .el-col-md-8 {
  790. width: 24.33333%;
  791. }
  792. </style>