index.vue 26 KB

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