123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- <template>
- <div>
- <div style="display:flex">
- <el-select
- v-model="value"
- placeholder="请选择"
- :disabled="disabled"
- @input="$emit('balabala', value)"
- filterable
- clearable
- >
- <el-option
- v-for="item in portList"
- :key="item.id"
- :label="item.name"
- :value="item.name"
- >
- </el-option>
- </el-select>
- <el-button
- icon="el-icon-search"
- @click="portinfoVisible = true"
- :disabled="disabled"
- size="mini"
- ></el-button>
- </div>
- <el-dialog
- title="港口信息"
- top="5vh"
- :visible.sync="portinfoVisible"
- width="80%"
- append-to-body
- @closed="closed"
- v-dialog-drag
- >
- <span>
- <el-row>
- <el-col :span="4">
- <el-scrollbar>
- <basic-container>
- <avue-tree
- :option="treeOption"
- :data="treeData"
- @node-click="nodeClick"
- />
- </basic-container>
- </el-scrollbar>
- </el-col>
- <el-col :span="20">
- <avue-crud
- ref="crud"
- :data="data"
- :option="tableOption"
- :page.sync="page"
- :table-loading="loading"
- v-model="form"
- :search.sync="search"
- :before-open="beforeOpen"
- @size-change="sizeChange"
- @current-change="currentChange"
- @search-change="searchChange"
- @refresh-change="refreshChange"
- @row-save="rowSave"
- @row-del="rowDel"
- @row-update="rowUpdate"
- @on-load="getList"
- @saveColumn="saveColumn"
- @tree-load="treeLoad"
- @selection-change="selectionChange"
- >
- </avue-crud>
- </el-col>
- </el-row>
- </span>
- <span slot="footer" class="dialog-footer">
- <el-button @click="portinfoVisible = false">取 消</el-button>
- <el-button
- type="primary"
- @click="importPort"
- :disabled="selectionList.length != 1"
- >确 定</el-button
- >
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import option from "./configuration/mainList.json";
- import reportDialog from "@/components/report-dialog/main";
- import {
- getList,
- add,
- update,
- remove,
- getPortTypeTree,
- getTypeTree,
- getAllList
- } from "@/api/basicData/portinformation";
- export default {
- data() {
- return {
- switchDialog: false, //报表
- loading: true,
- data: [],
- tableOption: option,
- form: {},
- search: {},
- treeDeptId: "",
- treeDeptName: "",
- page: {
- currentPage: 1,
- total: 0,
- pageSize: 10
- },
- treeOption: {
- nodeKey: "id",
- lazy: true,
- treeLoad: function(node, resolve) {
- const parentId = node.level === 0 ? 0 : node.data.id;
- getPortTypeTree(parentId).then(res => {
- resolve(
- res.data.map(item => {
- return {
- ...item,
- leaf: !item.hasChildren
- };
- })
- );
- });
- },
- addBtn: false,
- menu: false,
- size: "small",
- props: {
- labelText: "标题",
- label: "name",
- value: "id",
- children: "children"
- }
- },
- portinfoVisible: false,
- selectionList: [],
- portList: []
- };
- },
- props: {
- value: String,
- disabled: Boolean
- },
- model: {
- prop: "value",
- event: "balabala"
- },
- created() {
- getAllList().then(res => {
- this.portList = res.data.data;
- });
- },
- components: {
- reportDialog
- },
- mounted() {
- //查询服务类别字典项
- getTypeTree().then(res => {
- this.findObject(this.tableOption.column, "typeId").dicData =
- res.data.data;
- });
- },
- methods: {
- closed() {
- this.$refs.crud.toggleSelection();
- },
- importPort() {
- this.$emit("balabala", this.selectionList[0].name);
- this.portinfoVisible = false;
- },
- //打印
- openReport() {
- this.switchDialog = !this.switchDialog;
- },
- //关闭打印
- onClose(val) {
- this.switchDialog = val;
- },
- getList(page, params = {}) {
- this.loading = true;
- getList(page.currentPage, page.pageSize, params, this.treeDeptId).then(
- res => {
- this.data = res.data.data.records;
- this.page.total = res.data.data.total;
- this.loading = false;
- if (this.page.total) {
- this.tableOption.height = window.innerHeight - 350;
- }
- }
- );
- },
- //点击新增打开的窗口 取消时触发
- // beforeClose(){
- // },
- selectionChange(list) {
- this.selectionList = list;
- },
- //点击新增或修改时
- beforeOpen(done, type) {
- if (["add"].includes(type)) {
- this.tableOption.column.forEach(e => {
- if (e.prop == "typeId") {
- this.$set(this.tableOption.column, 3, {
- ...e,
- value: this.treeDeptId
- });
- }
- });
- }
- done();
- },
- searchChange(params, done) {
- this.getList(this.page, params);
- done();
- },
- sizeChange(val) {
- this.page.pageSize = val;
- this.getList();
- },
- currentChange(val) {
- this.page.currentPage = val;
- this.getList(this.page);
- },
- refreshChange() {
- this.getList(this.page, this.search);
- },
- rowSave(row, done, loading) {
- add(row).then(
- () => {
- this.page.currentPage = 1;
- this.getList(this.page);
- this.$message.success("保存成功");
- done();
- },
- error => {
- window.console.log(error);
- loading();
- }
- );
- },
- rowUpdate(row, index, done, loading) {
- row.createTime = "";
- update(row).then(
- () => {
- this.getList(this.page);
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- // 数据回调进行刷新
- done(row);
- },
- error => {
- window.console.log(error);
- loading();
- }
- );
- },
- rowDel(row, index, done) {
- this.$confirm("确定将选择数据删除?", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- })
- .then(() => {
- return remove(row.id);
- })
- .then(() => {
- this.$message({
- type: "success",
- message: "操作成功!"
- });
- this.getList(this.page);
- done(row);
- });
- },
- cellDblclick(row, column, cell, event) {
- this.$refs.crud.rowEdit(row);
- },
- saveColumn(row, column) {
- console.log(row, column);
- },
- //展开主页左边类型
- nodeClick(data) {
- this.treeDeptName = data.cname;
- this.treeDeptId = data.id;
- this.page.currentPage = 1;
- this.getList(this.page);
- },
- //列表内展开树节点
- treeLoad(tree, treeNode, resolve) {
- const parentId = tree.id;
- getList({ parentId: parentId }).then(res => {
- resolve(res.data.data.records);
- });
- }
- }
- };
- </script>
- <style scoped lang="scss"></style>
|