设备列表&产品列表
This commit is contained in:
45
src/api/hardware/device.js
Normal file
45
src/api/hardware/device.js
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询设备列表
|
||||||
|
export function list(params) {
|
||||||
|
return request({
|
||||||
|
url: '/system/device/list',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 查询设备详细
|
||||||
|
export function Info(deviceId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/device/' + deviceId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增设备
|
||||||
|
export function add(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/device',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改设备
|
||||||
|
export function update(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/device',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除设备
|
||||||
|
export function del(ids) {
|
||||||
|
return request({
|
||||||
|
url: '/system/device/' + ids,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
44
src/api/hardware/product.js
Normal file
44
src/api/hardware/product.js
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询产品列表
|
||||||
|
export function list(params) {
|
||||||
|
return request({
|
||||||
|
url: '/system/product/list',
|
||||||
|
method: 'get',
|
||||||
|
params
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询产品详细
|
||||||
|
export function Info(productId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/product/' + productId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增产品
|
||||||
|
export function add(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/device',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改产品
|
||||||
|
export function update(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/product',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除产品
|
||||||
|
export function del(ids) {
|
||||||
|
return request({
|
||||||
|
url: '/system/product/' + ids,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
@ -110,8 +110,12 @@
|
|||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
padding-right: 0;
|
padding-right: 0;
|
||||||
width: inherit;
|
width: inherit;
|
||||||
|
&.text-danger {
|
||||||
|
color: #ed5565;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.el-tree-node__content > .el-checkbox {
|
.el-tree-node__content > .el-checkbox {
|
||||||
margin-right: 8px;
|
margin-right: 8px;
|
||||||
}
|
}
|
||||||
|
@ -268,7 +268,7 @@ import {
|
|||||||
addDevice,
|
addDevice,
|
||||||
updateDevice,
|
updateDevice,
|
||||||
delDevice,
|
delDevice,
|
||||||
} from "@/api/system/device";
|
} from "@/api/hardware/device";
|
||||||
export default {
|
export default {
|
||||||
name: "Device",
|
name: "Device",
|
||||||
data() {
|
data() {
|
||||||
@ -370,8 +370,10 @@ export default {
|
|||||||
/** 修改按钮操作 */
|
/** 修改按钮操作 */
|
||||||
handleUpdate(row) {
|
handleUpdate(row) {
|
||||||
this.reset();
|
this.reset();
|
||||||
this.deviceId=[]
|
// debugger
|
||||||
|
// this.deviceId=[]
|
||||||
const deviceId = row.deviceId || this.ids;
|
const deviceId = row.deviceId || this.ids;
|
||||||
|
debugger
|
||||||
getDevice(deviceId).then(response => {
|
getDevice(deviceId).then(response => {
|
||||||
this.form = response.data;
|
this.form = response.data;
|
||||||
this.open = true;
|
this.open = true;
|
||||||
|
302
src/views/hardware/deviceList/index.vue
Normal file
302
src/views/hardware/deviceList/index.vue
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
<template>
|
||||||
|
<section class="app-container">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="2">todo 地区</el-col>
|
||||||
|
<el-col :span="22">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="名称" prop="jobName">
|
||||||
|
<el-input v-model="queryParams.deviceName" placeholder="请输入名称" clearable size="small" style="width: 240px"
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="cyan" 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 size="mini" type="primary" icon="el-icon-plus" @click="handleAdd" v-hasPermi="['system:device:add']">增加</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
||||||
|
v-hasPermi="['monitor:job:remove']">批量删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<!-- <el-col :span="1.5">
|
||||||
|
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleClean" v-hasPermi="['monitor:job:remove']">清空
|
||||||
|
</el-button>
|
||||||
|
</el-col> -->
|
||||||
|
<!-- <el-col :span="1.5">
|
||||||
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['monitor:job:export']">导出
|
||||||
|
</el-button>
|
||||||
|
</el-col> -->
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="deviceId" align="center" label="设备ID">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="deviceName" align="center" label="设备名称">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="deviceCode" align="center" label="设备编码">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="deviceType" align="center" label="类型">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="deviceModel" align="center" label="装置模型">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="provinceCode" align="center" label="省份">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="city" align="center" label="市">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="areaCode" align="center" label="区">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="status" align="center" label="在线状态">
|
||||||
|
</el-table-column>
|
||||||
|
<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="['system:device:edit']">修改
|
||||||
|
</el-button>
|
||||||
|
<el-button class="text-danger" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['system:device:edit']">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList" />
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<!-- 添加或修改参数配置对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-form-item label="设备ID" prop="deviceId">
|
||||||
|
<el-input v-model="form.deviceId" placeholder="请输入设备ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备名称" prop="deviceName">
|
||||||
|
<el-input v-model="form.deviceName" placeholder="请输入设备名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备编码" prop="deviceCode">
|
||||||
|
<el-input v-model="form.deviceCode" placeholder="请输入设备编码" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="类型" prop="deviceType">
|
||||||
|
<el-input v-model="form.deviceType" placeholder="请输入设备类型" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="装置模型" prop="deviceModel">
|
||||||
|
<el-input v-model="form.deviceModel" placeholder="请输入装置模型" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="国家行政区 省" prop="provinceCode">
|
||||||
|
<el-input v-model="form.provinceCode" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="国家行政区 区" prop="areaCode">
|
||||||
|
<el-input v-model="form.areaCode" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
list,
|
||||||
|
get,
|
||||||
|
add,
|
||||||
|
update,
|
||||||
|
del,
|
||||||
|
} from "@/api/hardware/device";
|
||||||
|
export default {
|
||||||
|
name: "DeviceList",
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
labelPosition: "right",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
value: "选项1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "选项2",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 表单参数
|
||||||
|
form: { },
|
||||||
|
// 表格数据
|
||||||
|
tableData: null,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
deviceId: [
|
||||||
|
{ required: true, message: "设备ID不能为空", trigger: "blur" },
|
||||||
|
],
|
||||||
|
deviceName: [
|
||||||
|
{ required: true, message: "设备名称不能为空", trigger: "blur" },
|
||||||
|
],
|
||||||
|
deviceType: [
|
||||||
|
{ required: true, message: "设备编码不能为空", trigger: "blur" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery () {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery () {
|
||||||
|
this.dateRange = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 获取设备数据列表
|
||||||
|
getList () {
|
||||||
|
list(this.queryParams).then((response) => {
|
||||||
|
this.tableData = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
cancel () {
|
||||||
|
this.open = false;
|
||||||
|
// this.reset();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
reset () {
|
||||||
|
this.form = {
|
||||||
|
deviceId: "",
|
||||||
|
deviceType: "",
|
||||||
|
deviceName: "",
|
||||||
|
status: "0",
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange (selection) {
|
||||||
|
this.ids = selection.map((item) => item.id);
|
||||||
|
this.single = selection.length != 1;
|
||||||
|
this.multiple = !selection.length;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd () {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加设备";
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate (row) {
|
||||||
|
this.reset();
|
||||||
|
this.form = row;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改设备";
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm: function () {
|
||||||
|
this.$refs["form"].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
// debugger
|
||||||
|
if (this.form.id != undefined) {
|
||||||
|
update(this.form).then(res => {
|
||||||
|
if (200 == res.code) {
|
||||||
|
this.msgSuccess(this.title + "成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(res.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
add(this.form).then(res => {
|
||||||
|
if (200 == res.code) {
|
||||||
|
this.msgSuccess(this.title + "成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(res.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete (row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$confirm('是否确认删除?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(() => {
|
||||||
|
return del(ids);
|
||||||
|
}).catch(() => { }).then(res => {
|
||||||
|
if (200 == res.code) {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(res.msg);
|
||||||
|
}
|
||||||
|
}).catch(res => { })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 页码尺寸改变
|
||||||
|
handleSizeChange (val) {
|
||||||
|
this.queryForm.pagesize = val;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
// 页码改变
|
||||||
|
handleCurrentChange (val) {
|
||||||
|
this.queryForm.page = val;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
// handleSelectionChange(val) {
|
||||||
|
// this.multipleSelection = val;
|
||||||
|
// },
|
||||||
|
handleSizeChange (val) {
|
||||||
|
console.log(`每页 ${val} 条`);
|
||||||
|
},
|
||||||
|
handleCurrentChange (val) {
|
||||||
|
console.log(`当前页: ${val}`);
|
||||||
|
},
|
||||||
|
// 对话框的关闭
|
||||||
|
handleClose (done) {
|
||||||
|
this.$confirm("确认关闭?")
|
||||||
|
.then((_) => {
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch((_) => { });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<style></style>
|
291
src/views/hardware/productList/index.vue
Normal file
291
src/views/hardware/productList/index.vue
Normal file
@ -0,0 +1,291 @@
|
|||||||
|
<template>
|
||||||
|
<section class="app-container">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="2">todo 地区</el-col>
|
||||||
|
<el-col :span="22">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="名称" prop="productName">
|
||||||
|
<el-input v-model="queryParams.productName" placeholder="请输入名称" clearable size="small" style="width: 240px"
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="cyan" 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 size="mini" type="primary" icon="el-icon-plus" @click="handleAdd" v-hasPermi="['system:product:add']">增加</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button type="danger" icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
|
||||||
|
v-hasPermi="['monitor:product:remove']">批量删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<!-- <el-col :span="1.5">
|
||||||
|
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleClean" v-hasPermi="['monitor:job:remove']">清空
|
||||||
|
</el-button>
|
||||||
|
</el-col> -->
|
||||||
|
<!-- <el-col :span="1.5">
|
||||||
|
<el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport" v-hasPermi="['monitor:job:export']">导出
|
||||||
|
</el-button>
|
||||||
|
</el-col> -->
|
||||||
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table :data="tableData" style="width: 100%" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="55" align="center">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="productId" align="center" label="产品ID">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="productName" align="center" label="产品名称">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="productType" align="center" label="产品编码">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="productType" align="center" label="类型">
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column prop="status" align="center" label="状态">
|
||||||
|
</el-table-column>
|
||||||
|
<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="['system:product:edit']">修改
|
||||||
|
</el-button>
|
||||||
|
<el-button class="text-danger" size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['system:product:edit']">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList" />
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<!-- 添加或修改参数配置对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||||
|
<el-form-item label="产品ID" prop="productId">
|
||||||
|
<el-input v-model="form.productId" placeholder="请输入产品ID" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品名称" prop="productName">
|
||||||
|
<el-input v-model="form.productName" placeholder="请输入产品名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="类型" prop="productType">
|
||||||
|
<el-input v-model="form.productType" placeholder="请输入产品类型" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-input v-model="form.status" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注">
|
||||||
|
<el-input v-model="form.remark" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</section>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
list,
|
||||||
|
get,
|
||||||
|
add,
|
||||||
|
update,
|
||||||
|
del,
|
||||||
|
} from "@/api/hardware/product";
|
||||||
|
export default {
|
||||||
|
name: "ProductList",
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
labelPosition: "right",
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
value: "选项1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
value: "选项2",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
// 表单参数
|
||||||
|
form: { productId: '' },
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
value: "",
|
||||||
|
// 表格数据
|
||||||
|
tableData: null,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
productId: [
|
||||||
|
{ required: true, message: "产品ID不能为空", trigger: "blur" },
|
||||||
|
],
|
||||||
|
productName: [
|
||||||
|
{ required: true, message: "产品名称不能为空", trigger: "blur" },
|
||||||
|
],
|
||||||
|
productType: [
|
||||||
|
{ required: true, message: "产品编码不能为空", trigger: "blur" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery () {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery () {
|
||||||
|
this.dateRange = [];
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 获取产品数据列表
|
||||||
|
getList () {
|
||||||
|
list(this.queryParams).then((response) => {
|
||||||
|
this.tableData = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
// 取消按钮
|
||||||
|
cancel () {
|
||||||
|
this.open = false;
|
||||||
|
// this.reset();
|
||||||
|
},
|
||||||
|
|
||||||
|
// 表单重置
|
||||||
|
reset () {
|
||||||
|
this.form = {
|
||||||
|
productId: "",
|
||||||
|
productType: "",
|
||||||
|
productName: "",
|
||||||
|
status: "0",
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange (selection) {
|
||||||
|
this.ids = selection.map((item) => item.id);
|
||||||
|
this.single = selection.length != 1;
|
||||||
|
this.multiple = !selection.length;
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
handleAdd () {
|
||||||
|
this.reset();
|
||||||
|
this.open = true;
|
||||||
|
this.title = "添加产品";
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate (row) {
|
||||||
|
this.reset();
|
||||||
|
this.form = row;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改产品";
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm: function () {
|
||||||
|
this.$refs["form"].validate((valid) => {
|
||||||
|
if (valid) {
|
||||||
|
// debugger
|
||||||
|
if (this.form.id != undefined) {
|
||||||
|
updateproduct(this.form).then(res => {
|
||||||
|
if (200 == res.code) {
|
||||||
|
this.msgSuccess(this.title + "成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(res.msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addproduct(this.form).then(res => {
|
||||||
|
if (200 == res.code) {
|
||||||
|
this.msgSuccess(this.title + "成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(res.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete (row) {
|
||||||
|
const ids = row.id || this.ids;
|
||||||
|
this.$confirm('是否确认删除?', "警告", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
type: "warning"
|
||||||
|
}).then(() => {
|
||||||
|
return delproduct(ids);
|
||||||
|
}).catch(() => { }).then(res => {
|
||||||
|
if (200 == res.code) {
|
||||||
|
this.getList();
|
||||||
|
this.msgSuccess("删除成功");
|
||||||
|
} else {
|
||||||
|
this.msgSuccess(res.msg);
|
||||||
|
}
|
||||||
|
}).catch(res => { })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 页码尺寸改变
|
||||||
|
handleSizeChange (val) {
|
||||||
|
this.queryForm.pagesize = val;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
// 页码改变
|
||||||
|
handleCurrentChange (val) {
|
||||||
|
this.queryForm.page = val;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
// handleSelectionChange(val) {
|
||||||
|
// this.multipleSelection = val;
|
||||||
|
// },
|
||||||
|
handleSizeChange (val) {
|
||||||
|
console.log(`每页 ${val} 条`);
|
||||||
|
},
|
||||||
|
handleCurrentChange (val) {
|
||||||
|
console.log(`当前页: ${val}`);
|
||||||
|
},
|
||||||
|
// 对话框的关闭
|
||||||
|
handleClose (done) {
|
||||||
|
this.$confirm("确认关闭?")
|
||||||
|
.then((_) => {
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch((_) => { });
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<style></style>
|
@ -34,8 +34,8 @@ module.exports = {
|
|||||||
proxy: {
|
proxy: {
|
||||||
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
||||||
[process.env.VUE_APP_BASE_API]: {
|
[process.env.VUE_APP_BASE_API]: {
|
||||||
// target: `http://192.168.0.125:8080`,
|
target: `http://192.168.0.129:8080`,
|
||||||
target: `http://121.37.250.170:8080`,
|
// target: `http://121.37.250.170:8080`,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
['^' + process.env.VUE_APP_BASE_API]: ''
|
['^' + process.env.VUE_APP_BASE_API]: ''
|
||||||
|
Reference in New Issue
Block a user