|
|
@@ -0,0 +1,308 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <basic-container class="page-crad">
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="4">
|
|
|
+ <avue-tree ref="tree" :option="treeOption" :data="treeData" @node-click="nodeClick" style="height:73vh;"> </avue-tree>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="20">
|
|
|
+ <avue-crud
|
|
|
+ :option="option"
|
|
|
+ :table-loading="loading"
|
|
|
+ :data="data"
|
|
|
+ :page.sync="page"
|
|
|
+ :permission="permissionList"
|
|
|
+ :before-open="beforeOpen"
|
|
|
+ v-model="form"
|
|
|
+ ref="crud"
|
|
|
+ @row-update="rowUpdate"
|
|
|
+ @row-save="rowSave"
|
|
|
+ @row-del="rowDel"
|
|
|
+ @search-change="searchChange"
|
|
|
+ @search-reset="searchReset"
|
|
|
+ @selection-change="selectionChange"
|
|
|
+ @current-change="currentChange"
|
|
|
+ @size-change="sizeChange"
|
|
|
+ @refresh-change="refreshChange"
|
|
|
+ @on-load="onLoad"
|
|
|
+ @resetColumn="resetColumn('crud', 'option', 'optionList', 479)"
|
|
|
+ @saveColumn="saveColumn('crud', 'option', 'optionList', 479)"
|
|
|
+ >
|
|
|
+ <template slot-scope="{ type, size, row, $index }" slot="menuLeft">
|
|
|
+ <el-button icon="el-icon-plus" type="primary" :size="size" @click="addRow">新增</el-button>
|
|
|
+ </template>
|
|
|
+ </avue-crud>
|
|
|
+ <template slot-scope="{ type, size, row, index, disabled }" slot="menu">
|
|
|
+ <el-button type="text" size="small" icon="el-icon-delete" @click="rowDel(row)">删 除 </el-button>
|
|
|
+ </template>
|
|
|
+ <template slot-scope="{ row, index }" slot="code">
|
|
|
+ <span style="color: #409EFF;cursor: pointer" @click.stop="editOpen(row)">{{ row.code }} </span>
|
|
|
+ </template>
|
|
|
+ <template slot="status" slot-scope="{ row, size }">
|
|
|
+ <span v-if="row.status === 1">提交</span>
|
|
|
+ <span v-if="row.status === 0">保存</span>
|
|
|
+ </template>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ </basic-container>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { getList, getDetails, submit, remove } from "@/api/tirePartsMall/basicData/reservoirArea/index.js";
|
|
|
+import { customerListAll } from "@/api/tirePartsMall/basicData/warehouse";
|
|
|
+export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ treeOption: {
|
|
|
+ addBtn: false,
|
|
|
+ menu: false,
|
|
|
+ size: "small",
|
|
|
+ props: {
|
|
|
+ labelText: "标题",
|
|
|
+ label: "cname",
|
|
|
+ value: "id"
|
|
|
+ }
|
|
|
+ },
|
|
|
+ treeData: [],
|
|
|
+ form: {
|
|
|
+ status: 1
|
|
|
+ },
|
|
|
+ query: {},
|
|
|
+ loading: true,
|
|
|
+ page: {
|
|
|
+ pageSize: 10,
|
|
|
+ currentPage: 1,
|
|
|
+ total: 0
|
|
|
+ },
|
|
|
+ selectionList: [],
|
|
|
+ option: {
|
|
|
+ height: "auto",
|
|
|
+ calcHeight: 30,
|
|
|
+ tip: false,
|
|
|
+ searchShow: true,
|
|
|
+ searchMenuSpan: 12,
|
|
|
+ border: true,
|
|
|
+ index: true,
|
|
|
+ viewBtn: true,
|
|
|
+ selection: true,
|
|
|
+ dialogClickModal: false,
|
|
|
+ addBtn: false,
|
|
|
+ align: "center",
|
|
|
+ column: [
|
|
|
+ {
|
|
|
+ label: "库区编码",
|
|
|
+ prop: "code",
|
|
|
+ search: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "库区名称",
|
|
|
+ prop: "cname",
|
|
|
+ search: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "备注",
|
|
|
+ prop: "remarks"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ optionList: {
|
|
|
+ height: "auto",
|
|
|
+ calcHeight: 30,
|
|
|
+ tip: false,
|
|
|
+ searchShow: true,
|
|
|
+ searchMenuSpan: 12,
|
|
|
+ border: true,
|
|
|
+ index: true,
|
|
|
+ viewBtn: true,
|
|
|
+ selection: true,
|
|
|
+ dialogClickModal: false,
|
|
|
+ addBtn: false,
|
|
|
+ align: "center",
|
|
|
+ column: [
|
|
|
+ {
|
|
|
+ label: "库区编码",
|
|
|
+ prop: "code",
|
|
|
+ search: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "库区名称",
|
|
|
+ prop: "cname",
|
|
|
+ search: true
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "备注",
|
|
|
+ prop: "remarks"
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ data: []
|
|
|
+ };
|
|
|
+ },
|
|
|
+ async created() {
|
|
|
+ this.option = await this.getColumnData(this.getColumnName(479), this.optionList);
|
|
|
+ this.getStorageTree();
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ ids() {
|
|
|
+ let ids = [];
|
|
|
+ this.selectionList.forEach(ele => {
|
|
|
+ ids.push(ele.id);
|
|
|
+ });
|
|
|
+ return ids.join(",");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ getStorageTree() {
|
|
|
+ customerListAll().then(res => {
|
|
|
+ this.treeData = res.data.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ addRow() {
|
|
|
+ if (!this.query.storageId) {
|
|
|
+ this.$message({
|
|
|
+ type: "error",
|
|
|
+ message: "请先选择左侧仓库!"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.form.storageId = this.query.storageId;
|
|
|
+ this.form.storageName = this.query.storageName;
|
|
|
+ this.$refs.crud.rowAdd();
|
|
|
+ },
|
|
|
+
|
|
|
+ rowSave(row, done, loading) {
|
|
|
+ submit(row).then(
|
|
|
+ () => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ error => {
|
|
|
+ loading();
|
|
|
+ window.console.log(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ rowUpdate(row, index, done, loading) {
|
|
|
+ submit(row).then(
|
|
|
+ () => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ error => {
|
|
|
+ loading();
|
|
|
+ console.log(error);
|
|
|
+ }
|
|
|
+ );
|
|
|
+ },
|
|
|
+ nodeClick(data) {
|
|
|
+ console.info("data---", data);
|
|
|
+ this.query.storageId = data.id;
|
|
|
+ this.query.storageName = data.cname;
|
|
|
+ this.page.currentPage = 1;
|
|
|
+ this.onLoad(this.page);
|
|
|
+ },
|
|
|
+ rowDel(row) {
|
|
|
+ this.$confirm("确定将选择数据删除?", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ return remove(row.id);
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.onLoad(this.page);
|
|
|
+ this.$message({
|
|
|
+ type: "success",
|
|
|
+ message: "操作成功!"
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ beforeOpen(done, type) {
|
|
|
+ if (["edit", "view"].includes(type)) {
|
|
|
+ getDetails({ id: this.form.id }).then(res => {
|
|
|
+ this.form = res.data.data;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ searchReset() {
|
|
|
+ this.$refs.tree.setCurrentKey(null);
|
|
|
+ this.query = {};
|
|
|
+ this.onLoad(this.page);
|
|
|
+ },
|
|
|
+ searchChange(params, done) {
|
|
|
+ this.query = params;
|
|
|
+ this.page.currentPage = 1;
|
|
|
+ this.onLoad(this.page, params);
|
|
|
+ done();
|
|
|
+ },
|
|
|
+ selectionChange(list) {
|
|
|
+ this.selectionList = list;
|
|
|
+ },
|
|
|
+ selectionClear() {
|
|
|
+ this.selectionList = [];
|
|
|
+ this.$refs.crud.toggleSelection();
|
|
|
+ },
|
|
|
+ currentChange(currentPage) {
|
|
|
+ this.page.currentPage = currentPage;
|
|
|
+ },
|
|
|
+ sizeChange(pageSize) {
|
|
|
+ this.page.pageSize = pageSize;
|
|
|
+ },
|
|
|
+ refreshChange() {
|
|
|
+ this.onLoad(this.page, this.query);
|
|
|
+ },
|
|
|
+ onLoad(page, params = {}) {
|
|
|
+ this.loading = true;
|
|
|
+ getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
|
|
|
+ const data = res.data.data;
|
|
|
+ this.page.total = data.total;
|
|
|
+ this.data = data.records;
|
|
|
+ this.loading = false;
|
|
|
+ this.selectionClear();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ //自定义列保存
|
|
|
+ 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.$nextTick(() => {
|
|
|
+ this.$refs.crud.doLayout();
|
|
|
+ });
|
|
|
+ this.$refs[ref].$refs.dialogColumn.columnBox = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //自定义列重置
|
|
|
+ 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.$nextTick(() => {
|
|
|
+ this.$refs.crud.doLayout();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style></style>
|