| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437 |
- <template>
- <div>
- <basic-container v-if="isShow">
- <avue-crud :option="option" :table-loading="loading" :data="data" :page.sync="page" :search.sync="query"
- v-model="form" id="out-table" :header-cell-class-name="headerClassName" ref="crud" @row-del="rowDel"
- @search-change="searchChange" @search-reset="searchReset" @selection-change="selectionChange"
- @current-change="currentChange" @size-change="sizeChange" @refresh-change="refreshChange"
- @resetColumn="resetColumn('crud', 'option', 'optionBack', 514)"
- @saveColumn="saveColumn('crud', 'option', 'optionBack', 514)" @on-load="onLoad">
- <template slot="menuLeft">
- <el-button type="primary" size="small" icon="el-icon-upload" @click="allClick('excel导入')">excel导入
- </el-button>
- <el-button type="success" size="small" icon="el-icon-upload" @click="allClick('edi导入')">edi导入
- </el-button>
- <!-- <el-button type="warning" size="small" disabled @click="outExport">导 出
- </el-button> -->
- </template>
- <template slot="menu" slot-scope="{ row, index }">
- <el-button size="small" type="text" @click="rowEdit(row)">{{ row.$cellEdit ? '保存' : '编辑' }}</el-button>
- </template>
- <template slot="fileType" slot-scope="{ row }">
- <span style="color: #1e9fff;cursor: pointer;" @click="inDetail(row)">{{ row.fileType }}</span>
- </template>
- </avue-crud>
- </basic-container>
- <detailsPage v-if="!isShow" :detailData="detailData" @goBack="goBack"></detailsPage>
- <el-dialog title="导入数据" append-to-body :visible.sync="excelBox" width="555px" :close-on-click-modal="false"
- v-dialog-drag>
- <avue-form v-if="excelBox" :option="excelOption" v-model="excelForm" :table-loading="excelLoading"
- :upload-before="uploadBefore" :upload-after="onSuccess">
- <template slot="excelTemplate">
- <el-button type="primary" @click="handleGet">
- 点击下载<i class="el-icon-download el-icon--right"></i>
- </el-button>
- </template>
- </avue-form>
- <p style="text-align: center;color: #DC0505">
- 温馨提示 第一次导入时请先下载模板
- </p>
- </el-dialog>
- <import-module ref="importModule" @refreshData="refreshData" />
- </div>
- </template>
- <script>
- import { getList, submit, emptyContainerEntryFtp } from "@/api/boxManagement/record/index.js";
- import detailsPage from "./detailsPage";
- import importModule from "./components/importModule.vue";
- import { getToken } from "@/util/auth";
- import _ from "lodash";
- export default {
- data() {
- return {
- excelBox: false,
- excelForm: {},
- excelLoading: false,
- excelOption: {
- submitBtn: false,
- emptyBtn: false,
- column: [
- {
- label: "模板下载",
- prop: "excelTemplate",
- formslot: true,
- span: 24
- },
- {
- label: "模板上传",
- prop: "excelFile",
- type: "upload",
- drag: true,
- loadText: "模板上传中,请稍等",
- span: 24,
- propsHttp: {
- res: "data"
- },
- tip: "请上传 .xls,.xlsx 标准格式文件",
- action: "/api/blade-los/boxdynamicsrecord/importExcel?type=CC"
- }
- ]
- },
- isShow: true,
- form: {},
- query: {
- approachExit: "CC",
- },
- loading: false,
- page: {
- pageSize: 10,
- currentPage: 1,
- total: 0
- },
- selectionList: [],
- option: {},
- optionBack: {
- height: 'auto',
- calcHeight: 30,
- menuWidth: 60,
- tip: false,
- searchShow: true,
- searchMenuSpan: 12,
- border: true,
- index: true,
- addBtn: false,
- viewBtn: false,
- editBtn: false,
- delBtn: false,
- selection: true,
- searchIcon: true,
- align: 'center',
- searchIndex: 3,
- column: [
- {
- label: '文件类型',
- prop: 'fileType',
- overHidden: true,
- },
- {
- label: '导入时间',
- prop: 'importDate',
- overHidden: true,
- },
- {
- label: '港口',
- prop: 'portCname',
- overHidden: true,
- search: true,
- type: "select",
- filterable: true,
- remote: true,
- dicUrl: "/api/blade-los/bports/list?status=0&size=5¤t=1&cnName={{key}}",
- props: {
- label: "cnName",
- value: "cnName",
- desc: 'code',
- res: "data.records"
- },
- },
- {
- label: '场站',
- prop: 'stationCname',
- overHidden: true,
- search: true,
- type: "select",
- filterable: true,
- remote: true,
- dicUrl: "/api/blade-los/bcorps/list?status=0&size=5¤t=1&cnName={{key}}",
- props: {
- label: "cnName",
- value: "cnName",
- desc: 'code',
- res: "data.records"
- },
- },
- {
- label: '放箱号',
- prop: 'containerNumber',
- search: true,
- hide: true,
- overHidden: true,
- },
- {
- label: '提单号',
- prop: 'mblno',
- search: true,
- hide: true,
- overHidden: true,
- },
- {
- label: '箱号',
- prop: 'boxCode',
- search: true,
- hide: true,
- overHidden: true,
- },
- {
- label: '状态',
- prop: 'boxDynamics',
- search: true,
- overHidden: true,
- },
- {
- label: '备注',
- prop: 'remarks',
- cell: true,
- overHidden: true,
- }
- ]
- },
- data: [],
- };
- },
- components: {
- detailsPage,
- importModule
- },
- async created() {
- this.option = await this.getColumnData(this.getColumnName(514), this.optionBack);
- },
- activated() {
- setTimeout(() => {
- }, 100);
- },
- methods: {
- refreshData() {
- this.refreshChange()
- },
- allClick(name) {
- if (name == 'excel导入') {
- this.excelBox = true;
- }
- if (name == 'edi导入') {
- this.$DialogForm.show({
- title: '出场导入',
- width: '30%',
- menuPosition: 'right',
- option: {
- submitText: '确定',
- emptyText: '取消',
- column: [
- {
- label: "场站",
- span: 24,
- prop: "corpId",
- type: 'select',
- filterable: true,
- remote: true,
- dicUrl: "/api/blade-los/bcorps/selectList?status=0&corpTypeName=场站&size=5¤t=1&shortName={{key}}",
- props: {
- label: "shortName",
- value: "id",
- desc: 'code',
- res: "data.records"
- },
- rules: [{
- required: true,
- message: "选择场站",
- trigger: "blur",
- }],
- },
- ]
- },
- beforeClose: (done) => {
- done()
- },
- callback: (res) => {
- res.done()
- console.log(res)
- let obj = {
- corpId: res.data.corpId,
- type: 'OUT'
- }
- emptyContainerEntryFtp(obj).then(res => {
- this.$message.success("操作成功!");
- this.$refs.importModule.openDialog(6, res.data.data)
- })
- res.close()
- }
- })
- }
- },
- uploadBefore(file, done, loading) {
- done();
- loading = true;
- },
- // 上传成功
- onSuccess(res, done, loading, column) {
- if (res == '操作成功') {
- this.$message.success("上传成功!");
- }
- this.excelBox = false;
- // this.$message.success("导入成功!");
- loading = false;
- this.onLoad(this.page, this.query);
- done();
- },
- // 下载模板
- handleGet() {
- window.open(
- `/api/blade-los/boxdynamicsrecord/exportTemplate?${this.website.tokenHeader
- }=${getToken()}`
- );
- },
- inDetail(row) {
- this.detailData = {
- id: row.id
- };
- this.isShow = false
- },
- rowEdit(row) {
- if (row.$cellEdit == true) {
- submit(row).then(res => {
- this.$message.success("保存成功!");
- this.$set(row, "$cellEdit", false);
- this.onLoad(this.page, this.query);
- })
- } else {
- this.$set(row, "$cellEdit", true);
- }
- },
- searchReset() {
- this.query = this.$options.data().query;
- this.onLoad(this.page);
- },
- // 搜索按钮点击
- searchChange(params, done) {
- this.page.currentPage = 1;
- this.onLoad(this.page, this.query);
- done();
- },
- selectionChange(list) {
- this.selectionList = list;
- },
- currentChange(currentPage) {
- this.page.currentPage = currentPage;
- },
- sizeChange(pageSize) {
- this.page.pageSize = pageSize;
- },
- refreshChange() {
- this.onLoad(this.page, this.query);
- },
- onLoad(page, params = {}) {
- let obj = {}
- obj = {
- ...Object.assign(params, this.query),
- }
- this.loading = true;
- getList(page.currentPage, page.pageSize, obj).then(res => {
- this.data = res.data.data.records;
- this.page.total = res.data.data.total;
- this.$nextTick(() => {
- this.$refs.crud.doLayout();
- this.$refs.crud.dicInit();
- });
- }).finally(() => {
- this.loading = false;
- })
- },
- // 详情的返回列表
- goBack() {
- // 初始化数据
- this.detailData = {}
- this.isShow = true;
- this.onLoad(this.page, this.query);
- },
- outExport() {
- let config = { params: { ...this.query } }
- if (config.params) {
- for (const propName of Object.keys(config.params)) {
- const value = config.params[propName];
- if (value !== null && typeof (value) !== "undefined") {
- if (value instanceof Array) {
- for (const key of Object.keys(value)) {
- let params = propName + '[' + key + ']';
- config.params[params] = value[key]
- }
- delete config.params[propName]
- }
- }
- }
- }
- const routeData = this.$router.resolve({
- path: '/api/blade-los/routecost/exportRouteCost', //跳转目标窗口的地址
- query: {
- ...config.params, //括号内是要传递给新窗口的参数
- identification: this.url
- }
- })
- window.open(routeData.href.slice(1, routeData.href.length) + '&' + `${this.website.tokenHeader}=${getToken()}`);
- },
- //自定义列保存
- async saveColumn(ref, option, optionBack, code) {
- /**
- * 已定义全局方法,直接使用,saveColumnData保存列数据方法,参数传值(表格名称,当前表格的option数据)
- * 已定义全局方法,直接使用,getColumnName方法用来获取枚举值,参数根据自己定义的code值获取中文名
- * 一定要执行异步操作,要等接口成功返回,才能执行下一行代码
- */
- const inSave = await this.saveColumnData(this.getColumnName(code), this[option]);
- if (inSave) {
- this.$message.success("保存成功");
- //关闭窗口
- this.$refs[ref].$refs.dialogColumn.columnBox = false;
- this.selectionList = []
- this.searchReset()
- }
- },
- //自定义列重置
- async resetColumn(ref, option, optionBack, code) {
- this[option] = this[optionBack];
- const inSave = await this.delColumnData(this.getColumnName(code), this[optionBack]);
- if (inSave) {
- this.$message.success("重置成功");
- this.$refs[ref].$refs.dialogColumn.columnBox = false;
- this.selectionList = []
- this.searchReset()
- }
- },
- // 更改表格颜色
- headerClassName(tab) {
- //颜色间隔
- let back = ""
- if (tab.columnIndex >= 0 && tab.column.level === 1) {
- if (tab.columnIndex % 2 === 0) {
- back = "back-one"
- } else if (tab.columnIndex % 2 === 1) {
- back = "back-two"
- }
- }
- return back;
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- ::v-deep #out-table .back-one {
- background: #ecf5ff !important;
- text-align: center;
- }
- ::v-deep #out-table .back-two {
- background: #ecf5ff !important;
- text-align: center;
- }
- .pointerClick {
- cursor: pointer;
- color: #1e9fff;
- }
- ::v-deep .el-col-md-8 {
- width: 24.33333%;
- }
- </style>
|