|
@@ -2,83 +2,41 @@
|
|
|
<div class="app-container">
|
|
|
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
|
|
|
<el-form-item label="名称" prop="name">
|
|
|
- <el-input
|
|
|
- v-model="queryParams.name"
|
|
|
- placeholder="名称"
|
|
|
- clearable
|
|
|
- @keyup.enter.native="handleQuery"
|
|
|
- />
|
|
|
+ <el-input v-model="queryParams.name" placeholder="名称" clearable @keyup.enter.native="handleQuery" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="SNS编号" title="SNS编号" prop="snsId">
|
|
|
- <el-input
|
|
|
- v-model="queryParams.snsId"
|
|
|
- placeholder="请输入SNS编号"
|
|
|
- clearable
|
|
|
- @keyup.enter.native="handleQuery"
|
|
|
- />
|
|
|
+ <el-input v-model="queryParams.snsId" placeholder="请输入SNS编号" clearable @keyup.enter.native="handleQuery" />
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- plain
|
|
|
- icon="el-icon-plus"
|
|
|
- size="mini"
|
|
|
- @click="handleAdd"
|
|
|
- v-hasPermi="['manage:product:add']"
|
|
|
- >新增</el-button>
|
|
|
+ <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
|
|
|
+ v-hasPermi="['manage:product:add']">新增</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button
|
|
|
- type="info"
|
|
|
- plain
|
|
|
- icon="el-icon-sort"
|
|
|
- size="mini"
|
|
|
- @click="toggleExpandAll"
|
|
|
- >展开/折叠</el-button>
|
|
|
+ <el-button type="info" plain icon="el-icon-sort" size="mini" @click="toggleExpandAll">展开/折叠</el-button>
|
|
|
</el-col>
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
</el-row>
|
|
|
|
|
|
- <el-table
|
|
|
- v-if="refreshTable"
|
|
|
- v-loading="loading"
|
|
|
- :data="productList"
|
|
|
- row-key="id"
|
|
|
- :default-expand-all="isExpandAll"
|
|
|
- :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
|
|
|
- >
|
|
|
+ <el-table v-if="refreshTable" v-loading="loading" :data="productList" row-key="id" :default-expand-all="isExpandAll"
|
|
|
+ :tree-props="{children: 'children', hasChildren: 'hasChildren'}">
|
|
|
<el-table-column label="名称" align="center" prop="name" />
|
|
|
<el-table-column label="SNS编号" align="center" prop="snsId" />
|
|
|
+ <el-table-column label="归属" align="center" prop="parentName" />
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button
|
|
|
- size="mini"
|
|
|
- type="text"
|
|
|
- icon="el-icon-edit"
|
|
|
- @click="handleUpdate(scope.row)"
|
|
|
- v-hasPermi="['manage:product:edit']"
|
|
|
- >修改</el-button>
|
|
|
- <el-button
|
|
|
- size="mini"
|
|
|
- type="text"
|
|
|
- icon="el-icon-plus"
|
|
|
- @click="handleAdd(scope.row)"
|
|
|
- v-hasPermi="['manage:product:add']"
|
|
|
- >新增</el-button>
|
|
|
- <el-button
|
|
|
- size="mini"
|
|
|
- type="text"
|
|
|
- icon="el-icon-delete"
|
|
|
- @click="handleDelete(scope.row)"
|
|
|
- v-hasPermi="['manage:product:remove']"
|
|
|
- >删除</el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
|
|
|
+ v-hasPermi="['manage:product:edit']">修改</el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-plus" @click="handleAdd(scope.row)"
|
|
|
+ v-hasPermi="['manage:product:add']">新增</el-button>
|
|
|
+ <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
|
|
+ v-hasPermi="['manage:product:remove']">删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
@@ -86,7 +44,14 @@
|
|
|
<!-- 添加或修改产品树信息对话框 -->
|
|
|
<el-dialog :title="title" :visible.sync="open" :close-on-click-modal="false" width="500px" append-to-body>
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
- <el-form-item label="归属" prop="parentId">
|
|
|
+ <el-form-item label="归属" prop="parentId" v-if="isAdd">
|
|
|
+ <el-select v-model="form.parentId" placeholder="请选择机号信息" style="width:100%">
|
|
|
+ <el-option v-for="item in aircraftOptions" :key="item.id" :label="item.number"
|
|
|
+ :value="item.id">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="归属" prop="parentId" v-else>
|
|
|
<treeselect v-model="form.parentId" :options="productOptions" :normalizer="normalizer" placeholder="请选择父ID" />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="名称" prop="name">
|
|
@@ -105,14 +70,21 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { listProduct, getProduct, delProduct, addProduct, updateProduct } from "@/api/manage/product";
|
|
|
-import Treeselect from "@riophae/vue-treeselect";
|
|
|
-import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
|
+import {
|
|
|
+ listProduct,
|
|
|
+ getProduct,
|
|
|
+ delProduct,
|
|
|
+ addProduct,
|
|
|
+ updateProduct,
|
|
|
+ aircraftListSelect,
|
|
|
+} from '@/api/manage/product'
|
|
|
+import Treeselect from '@riophae/vue-treeselect'
|
|
|
+import '@riophae/vue-treeselect/dist/vue-treeselect.css'
|
|
|
|
|
|
export default {
|
|
|
- name: "Product",
|
|
|
+ name: 'Product',
|
|
|
components: {
|
|
|
- Treeselect
|
|
|
+ Treeselect,
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
@@ -125,11 +97,15 @@ export default {
|
|
|
// 产品树信息树选项
|
|
|
productOptions: [],
|
|
|
// 弹出层标题
|
|
|
- title: "",
|
|
|
+ title: '',
|
|
|
// 是否显示弹出层
|
|
|
open: false,
|
|
|
+ // 是否新增
|
|
|
+ isAdd: true,
|
|
|
// 是否展开,默认全部展开
|
|
|
isExpandAll: true,
|
|
|
+ // 单机列表
|
|
|
+ aircraftOptions: undefined,
|
|
|
// 重新渲染表格状态
|
|
|
refreshTable: true,
|
|
|
// 查询参数
|
|
@@ -143,134 +119,142 @@ export default {
|
|
|
// 表单校验
|
|
|
rules: {
|
|
|
parentId: [
|
|
|
- { required: true, message: "归属不能为空", trigger: "blur" }
|
|
|
+ { required: true, message: '归属不能为空', trigger: 'blur' },
|
|
|
],
|
|
|
- }
|
|
|
- };
|
|
|
+ },
|
|
|
+ }
|
|
|
},
|
|
|
created() {
|
|
|
- this.getList();
|
|
|
+ this.getList()
|
|
|
},
|
|
|
methods: {
|
|
|
/** 查询产品树信息列表 */
|
|
|
getList() {
|
|
|
- this.loading = true;
|
|
|
+ this.loading = true
|
|
|
listProduct(this.queryParams).then(response => {
|
|
|
- this.productList = this.handleTree(response.data, "id", "parentId");
|
|
|
- this.loading = false;
|
|
|
- });
|
|
|
+ this.productList = this.handleTree(response.data, 'id', 'parentId')
|
|
|
+ this.loading = false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /** 查询单机信息列表 */
|
|
|
+ getAircraftList() {
|
|
|
+ aircraftListSelect(this.queryParams).then(response => {
|
|
|
+ this.aircraftOptions = response.data
|
|
|
+ })
|
|
|
},
|
|
|
/** 转换产品树信息数据结构 */
|
|
|
normalizer(node) {
|
|
|
if (node.children && !node.children.length) {
|
|
|
- delete node.children;
|
|
|
+ delete node.children
|
|
|
}
|
|
|
return {
|
|
|
id: node.id,
|
|
|
label: node.name,
|
|
|
- children: node.children
|
|
|
- };
|
|
|
+ children: node.children,
|
|
|
+ }
|
|
|
},
|
|
|
- /** 查询产品树信息下拉树结构 */
|
|
|
+ /** 查询产品树信息下拉树结构 */
|
|
|
getTreeselect() {
|
|
|
listProduct().then(response => {
|
|
|
- this.productOptions = [];
|
|
|
- const data = { id: 0, name: '顶级节点', children: [] };
|
|
|
- data.children = this.handleTree(response.data, "id", "parentId");
|
|
|
- this.productOptions.push(data);
|
|
|
- });
|
|
|
+ this.productOptions = []
|
|
|
+ const data = { id: 0, name: '顶级节点', children: [] }
|
|
|
+ data.children = this.handleTree(response.data, 'id', 'parentId')
|
|
|
+ this.productOptions.push(data)
|
|
|
+ })
|
|
|
},
|
|
|
// 取消按钮
|
|
|
cancel() {
|
|
|
- this.open = false;
|
|
|
- this.reset();
|
|
|
+ this.open = false
|
|
|
+ this.reset()
|
|
|
},
|
|
|
// 表单重置
|
|
|
reset() {
|
|
|
this.form = {
|
|
|
id: null,
|
|
|
parentId: null,
|
|
|
+ parentName: null,
|
|
|
name: null,
|
|
|
- snsId: null,
|
|
|
- isDelete: null,
|
|
|
- createBy: null,
|
|
|
- createTime: null,
|
|
|
- updateBy: null,
|
|
|
- updateTime: null
|
|
|
- };
|
|
|
- this.resetForm("form");
|
|
|
+ snsId: null
|
|
|
+ }
|
|
|
+ this.resetForm('form')
|
|
|
},
|
|
|
/** 搜索按钮操作 */
|
|
|
handleQuery() {
|
|
|
- this.getList();
|
|
|
+ this.getList()
|
|
|
},
|
|
|
/** 重置按钮操作 */
|
|
|
resetQuery() {
|
|
|
- this.resetForm("queryForm");
|
|
|
- this.handleQuery();
|
|
|
+ this.resetForm('queryForm')
|
|
|
+ this.handleQuery()
|
|
|
},
|
|
|
/** 新增按钮操作 */
|
|
|
handleAdd(row) {
|
|
|
- this.reset();
|
|
|
- this.getTreeselect();
|
|
|
+ this.isAdd = true
|
|
|
+ this.reset()
|
|
|
+ this.getAircraftList()
|
|
|
if (row != null && row.id) {
|
|
|
- this.form.parentId = row.id;
|
|
|
+ this.form.parentId = row.id
|
|
|
} else {
|
|
|
- this.form.parentId = 0;
|
|
|
+ this.form.parentId = this.aircraftOptions[0].id
|
|
|
}
|
|
|
- this.open = true;
|
|
|
- this.title = "添加产品树信息";
|
|
|
+ this.open = true
|
|
|
+ this.title = '添加产品树信息'
|
|
|
},
|
|
|
/** 展开/折叠操作 */
|
|
|
toggleExpandAll() {
|
|
|
- this.refreshTable = false;
|
|
|
- this.isExpandAll = !this.isExpandAll;
|
|
|
+ this.refreshTable = false
|
|
|
+ this.isExpandAll = !this.isExpandAll
|
|
|
this.$nextTick(() => {
|
|
|
- this.refreshTable = true;
|
|
|
- });
|
|
|
+ this.refreshTable = true
|
|
|
+ })
|
|
|
},
|
|
|
/** 修改按钮操作 */
|
|
|
handleUpdate(row) {
|
|
|
- this.reset();
|
|
|
- this.getTreeselect();
|
|
|
+ this.reset()
|
|
|
+ this.isAdd = false
|
|
|
+ this.getTreeselect()
|
|
|
if (row != null) {
|
|
|
- this.form.parentId = row.id;
|
|
|
+ this.form.parentId = row.id
|
|
|
}
|
|
|
getProduct(row.id).then(response => {
|
|
|
- this.form = response.data;
|
|
|
- this.open = true;
|
|
|
- this.title = "修改产品树信息";
|
|
|
- });
|
|
|
+ this.form = response.data
|
|
|
+ this.open = true
|
|
|
+ this.title = '修改产品树信息'
|
|
|
+ })
|
|
|
},
|
|
|
/** 提交按钮 */
|
|
|
submitForm() {
|
|
|
- this.$refs["form"].validate(valid => {
|
|
|
+ this.$refs['form'].validate(valid => {
|
|
|
if (valid) {
|
|
|
if (this.form.id != null) {
|
|
|
updateProduct(this.form).then(response => {
|
|
|
- this.$modal.msgSuccess("修改成功");
|
|
|
- this.open = false;
|
|
|
- this.getList();
|
|
|
- });
|
|
|
+ this.$modal.msgSuccess('修改成功')
|
|
|
+ this.open = false
|
|
|
+ this.getList()
|
|
|
+ })
|
|
|
} else {
|
|
|
addProduct(this.form).then(response => {
|
|
|
- this.$modal.msgSuccess("新增成功");
|
|
|
- this.open = false;
|
|
|
- this.getList();
|
|
|
- });
|
|
|
+ this.$modal.msgSuccess('新增成功')
|
|
|
+ this.open = false
|
|
|
+ this.getList()
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
- });
|
|
|
+ })
|
|
|
},
|
|
|
/** 删除按钮操作 */
|
|
|
handleDelete(row) {
|
|
|
- this.$modal.confirm('是否确认删除产品树信息编号为"' + row.id + '"的数据项?').then(function() {
|
|
|
- return delProduct(row.id);
|
|
|
- }).then(() => {
|
|
|
- this.getList();
|
|
|
- this.$modal.msgSuccess("删除成功");
|
|
|
- }).catch(() => {});
|
|
|
- }
|
|
|
- }
|
|
|
-};
|
|
|
+ this.$modal
|
|
|
+ .confirm('是否确认删除产品树信息编号为"' + row.id + '"的数据项?')
|
|
|
+ .then(function () {
|
|
|
+ return delProduct(row.id)
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.getList()
|
|
|
+ this.$modal.msgSuccess('删除成功')
|
|
|
+ })
|
|
|
+ .catch(() => {})
|
|
|
+ },
|
|
|
+ },
|
|
|
+}
|
|
|
</script>
|