|
@@ -1,3 +1,4 @@
|
|
|
+<!-- 设备管理 设备分类 -->
|
|
|
<template>
|
|
|
<div class="app-container">
|
|
|
<!-- 搜索表单 -->
|
|
@@ -6,43 +7,94 @@
|
|
|
<el-input v-model="form.name" placeholder="请输入设备名称" clearable />
|
|
|
</el-form-item>
|
|
|
<el-form-item label="设备型号:">
|
|
|
- <el-select v-model="form.clientTypeId" placeholder="请选择设备型号" filterable clearable>
|
|
|
- <el-option v-for="item in devOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
+ <el-select
|
|
|
+ v-model="form.clientTypeId"
|
|
|
+ placeholder="请选择设备型号"
|
|
|
+ filterable
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in devOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="设备分类:">
|
|
|
- <el-select v-model="form.categoryId" placeholder="请选择设备分类" clearable>
|
|
|
- <el-option v-for="item in categoryOptions" :key="item.value" :value="item.value" :label="item.label" />
|
|
|
+ <el-select
|
|
|
+ v-model="form.categoryId"
|
|
|
+ placeholder="请选择设备分类"
|
|
|
+ clearable
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in categoryOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :value="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="当前状态:">
|
|
|
<el-select v-model="form.status" placeholder="请选择当前状态" clearable>
|
|
|
- <el-option v-for="item in onOrOffOptions" :key="item.value" :value="item.value" :label="item.label" />
|
|
|
+ <el-option
|
|
|
+ v-for="item in onOrOffOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :value="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="是否热门:">
|
|
|
<el-select v-model="form.isHot" placeholder="请选择是否热门" clearable>
|
|
|
- <el-option v-for="item in yesOrNoOptions" :key="item.value" :value="item.value" :label="item.label" />
|
|
|
+ <el-option
|
|
|
+ v-for="item in yesOrNoOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :value="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
- <el-button type="primary" icon="el-icon-search" @click="getSearch">搜索</el-button>
|
|
|
+ <el-button type="primary" icon="el-icon-search" @click="getSearch"
|
|
|
+ >搜索</el-button
|
|
|
+ >
|
|
|
<el-button icon="el-icon-refresh" @click="getRefresh">重置</el-button>
|
|
|
- <el-button type="primary" icon="el-icon-plus" plain @click="getChange()" v-hasPermi="['device:list:add']">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-plus"
|
|
|
+ plain
|
|
|
+ @click="getChange()"
|
|
|
+ v-hasPermi="['device:list:add']"
|
|
|
+ >
|
|
|
新增
|
|
|
</el-button>
|
|
|
- <el-button type="primary" icon="el-icon-top" @click="getShelves(1)" :disabled="isDisabled()"
|
|
|
- v-hasPermi="['device:list:up']">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-top"
|
|
|
+ @click="getShelves(1)"
|
|
|
+ :disabled="isDisabled()"
|
|
|
+ v-hasPermi="['device:list:up']"
|
|
|
+ >
|
|
|
批量上架
|
|
|
</el-button>
|
|
|
- <el-button type="primary" icon="el-icon-bottom" @click="getShelves(2)" :disabled="isDisabled()"
|
|
|
- v-hasPermi="['device:list:down']">
|
|
|
+ <el-button
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-bottom"
|
|
|
+ @click="getShelves(2)"
|
|
|
+ :disabled="isDisabled()"
|
|
|
+ v-hasPermi="['device:list:down']"
|
|
|
+ >
|
|
|
批量下架
|
|
|
</el-button>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<!-- 表格 -->
|
|
|
- <el-table :data="tableData" v-loading="loading" @selection-change="handleSelectionChange">
|
|
|
+ <el-table
|
|
|
+ :data="tableData"
|
|
|
+ v-loading="loading"
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
+ >
|
|
|
<el-table-column type="selection" align="center" />
|
|
|
<el-table-column label="设备ID" prop="id" align="center" />
|
|
|
<el-table-column label="设备型号" prop="clientType" align="center" />
|
|
@@ -54,40 +106,87 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="设备分类" prop="categoryName" align="center" />
|
|
|
- <el-table-column label="设备类型" prop="deviceType" align="center" :formatter="deviceTypeFormatter" />
|
|
|
- <el-table-column label="是否热门" prop="isHot" align="center" :formatter="hotFormatter" />
|
|
|
+ <el-table-column
|
|
|
+ label="设备类型"
|
|
|
+ prop="deviceType"
|
|
|
+ align="center"
|
|
|
+ :formatter="deviceTypeFormatter"
|
|
|
+ />
|
|
|
+ <el-table-column
|
|
|
+ label="是否热门"
|
|
|
+ prop="isHot"
|
|
|
+ align="center"
|
|
|
+ :formatter="hotFormatter"
|
|
|
+ />
|
|
|
<el-table-column label="创建时间" prop="createTimeText" align="center" />
|
|
|
<el-table-column label="操作" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
- <el-button type="text" @click="getChange(scope.row.id, true)">查看</el-button>
|
|
|
- <el-button v-if="scope.row.status === 2" type="text" @click="getChange(scope.row.id)"
|
|
|
- v-hasPermi="['device:list:edit']">
|
|
|
+ <el-button type="text" @click="getChange(scope.row.id, true)"
|
|
|
+ >查看</el-button
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ v-if="scope.row.status === 2"
|
|
|
+ type="text"
|
|
|
+ @click="getChange(scope.row.id)"
|
|
|
+ v-hasPermi="['device:list:edit']"
|
|
|
+ >
|
|
|
编辑
|
|
|
</el-button>
|
|
|
- <el-button v-if="scope.row.status === 2" type="text" @click="getShelves(1, scope.row.id)"
|
|
|
- v-hasPermi="['device:list:up']">
|
|
|
+ <el-button
|
|
|
+ v-if="scope.row.status === 2"
|
|
|
+ type="text"
|
|
|
+ @click="getShelves(1, scope.row.id)"
|
|
|
+ v-hasPermi="['device:list:up']"
|
|
|
+ >
|
|
|
上架
|
|
|
</el-button>
|
|
|
- <el-button v-else type="text" @click="getShelves(2, scope.row.id)" v-hasPermi="['device:list:down']">
|
|
|
+ <el-button
|
|
|
+ v-else
|
|
|
+ type="text"
|
|
|
+ @click="getShelves(2, scope.row.id)"
|
|
|
+ v-hasPermi="['device:list:down']"
|
|
|
+ >
|
|
|
下架
|
|
|
</el-button>
|
|
|
- <el-button v-if="scope.row.status === 2" type="delete" @click="getDelete(scope.row.id)"
|
|
|
- v-hasPermi="['device:list:delete']">
|
|
|
+ <el-button
|
|
|
+ v-if="scope.row.status === 2"
|
|
|
+ type="delete"
|
|
|
+ @click="getDelete(scope.row.id)"
|
|
|
+ v-hasPermi="['device:list:delete']"
|
|
|
+ >
|
|
|
删除
|
|
|
</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
- <pagination v-show="total > 0" :total="total" :page.sync="form.pageNum" :limit.sync="form.pageSize"
|
|
|
- @pagination="getList" />
|
|
|
+ <pagination
|
|
|
+ v-show="total > 0"
|
|
|
+ :total="total"
|
|
|
+ :page.sync="form.pageNum"
|
|
|
+ :limit.sync="form.pageSize"
|
|
|
+ @pagination="getList"
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { list, remove, change } from '@/api/device/list'
|
|
|
-import { devMixin, onOrOffMixin, devTypeMixin, devCategoryMixin, yesOrNoMixin } from '@/mixin/index'
|
|
|
+import { change, list, remove } from "@/api/device/list";
|
|
|
+import {
|
|
|
+ devCategoryMixin,
|
|
|
+ devMixin,
|
|
|
+ devTypeMixin,
|
|
|
+ onOrOffMixin,
|
|
|
+ yesOrNoMixin,
|
|
|
+} from "@/mixin/index";
|
|
|
+import { dialogCallBack } from "@/utils/DialogUtil";
|
|
|
export default {
|
|
|
- mixins: [devMixin, onOrOffMixin, devTypeMixin, devCategoryMixin, yesOrNoMixin],
|
|
|
+ mixins: [
|
|
|
+ devMixin,
|
|
|
+ onOrOffMixin,
|
|
|
+ devTypeMixin,
|
|
|
+ devCategoryMixin,
|
|
|
+ yesOrNoMixin,
|
|
|
+ ],
|
|
|
data() {
|
|
|
return {
|
|
|
// 遮罩层
|
|
@@ -99,66 +198,66 @@ export default {
|
|
|
// 搜索表单
|
|
|
form: {
|
|
|
pageNum: 1,
|
|
|
- pageSize: 10
|
|
|
+ pageSize: 10,
|
|
|
},
|
|
|
// 批量上下架
|
|
|
changeForm: {
|
|
|
- ids: '',
|
|
|
- type: null
|
|
|
- }
|
|
|
- }
|
|
|
+ ids: "",
|
|
|
+ type: null,
|
|
|
+ },
|
|
|
+ };
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.getDevList()
|
|
|
- this.getCateGory(1)
|
|
|
- this.getList()
|
|
|
+ this.getDevList();
|
|
|
+ this.getCateGory(1);
|
|
|
+ this.getList();
|
|
|
},
|
|
|
methods: {
|
|
|
// 列表
|
|
|
getList() {
|
|
|
- this.loading = true
|
|
|
- list(this.form).then(res => {
|
|
|
- this.tableData = res.data.records
|
|
|
- this.total = res.data.total
|
|
|
- this.loading = false
|
|
|
- })
|
|
|
+ this.loading = true;
|
|
|
+ list(this.form).then((res) => {
|
|
|
+ this.tableData = res.data.records;
|
|
|
+ this.total = res.data.total;
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
// 搜索
|
|
|
getSearch() {
|
|
|
- this.form.pageNum = 1
|
|
|
- this.form.pageSize = 10
|
|
|
- this.getList()
|
|
|
+ this.form.pageNum = 1;
|
|
|
+ this.form.pageSize = 10;
|
|
|
+ this.getList();
|
|
|
},
|
|
|
|
|
|
// 重置
|
|
|
getRefresh() {
|
|
|
this.form = {
|
|
|
- name: '',
|
|
|
+ name: "",
|
|
|
pageNum: 1,
|
|
|
- pageSize: 10
|
|
|
- }
|
|
|
- this.getList()
|
|
|
+ pageSize: 10,
|
|
|
+ };
|
|
|
+ this.getList();
|
|
|
},
|
|
|
|
|
|
// 禁用上下架功能
|
|
|
isDisabled() {
|
|
|
- return this.changeForm.ids === '' ? true : false
|
|
|
+ return this.changeForm.ids === "" ? true : false;
|
|
|
},
|
|
|
|
|
|
// 上下架
|
|
|
getShelves(key, e) {
|
|
|
if (e) {
|
|
|
- this.changeForm.ids = e
|
|
|
+ this.changeForm.ids = e;
|
|
|
}
|
|
|
- let title = key === 1 ? '上架' : '下架'
|
|
|
- this.changeForm.type = key
|
|
|
- change(this.changeForm).then(res => {
|
|
|
+ let title = key === 1 ? "上架" : "下架";
|
|
|
+ this.changeForm.type = key;
|
|
|
+ change(this.changeForm).then((res) => {
|
|
|
if (res.code === 0) {
|
|
|
- this.$message.success(`${title}成功!`)
|
|
|
- this.getList()
|
|
|
+ this.$message.success(`${title}成功!`);
|
|
|
+ this.getList();
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
// 新增 / 编辑 / 查看
|
|
@@ -167,46 +266,52 @@ export default {
|
|
|
path: `/device/deviceList/detail`,
|
|
|
query: {
|
|
|
id: id,
|
|
|
- boolean: boolean
|
|
|
- }
|
|
|
- })
|
|
|
+ boolean: boolean,
|
|
|
+ },
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
// 多选
|
|
|
handleSelectionChange(e) {
|
|
|
if (e.length > 0) {
|
|
|
- let arr = []
|
|
|
- e.filter(i => {
|
|
|
- arr.push(i.id)
|
|
|
- this.changeForm.ids = arr.join(',')
|
|
|
- })
|
|
|
+ let arr = [];
|
|
|
+ e.filter((i) => {
|
|
|
+ arr.push(i.id);
|
|
|
+ this.changeForm.ids = arr.join(",");
|
|
|
+ });
|
|
|
} else {
|
|
|
- this.changeForm.ids = ''
|
|
|
+ this.changeForm.ids = "";
|
|
|
}
|
|
|
},
|
|
|
|
|
|
// 删除
|
|
|
getDelete(id) {
|
|
|
- this.$confirm('确定要删除?', {
|
|
|
- type: 'warning'
|
|
|
- }).then(() => {
|
|
|
- remove(id).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.getList()
|
|
|
- this.$message.success('删除成功!')
|
|
|
- }
|
|
|
- })
|
|
|
- }).catch(() => { })
|
|
|
+ var that = this;
|
|
|
+ dialogCallBack(that, function () {
|
|
|
+ that
|
|
|
+ .$confirm("确定要删除?", {
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ remove(id).then((res) => {
|
|
|
+ if (res.code === 0) {
|
|
|
+ that.getList();
|
|
|
+ that.$message.success("删除成功!");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {});
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
// 字典翻译
|
|
|
hotFormatter(row) {
|
|
|
- return this.selectDictLabel(this.yesOrNoOptions, row.isHot)
|
|
|
+ return this.selectDictLabel(this.yesOrNoOptions, row.isHot);
|
|
|
},
|
|
|
|
|
|
deviceTypeFormatter(row) {
|
|
|
- return this.selectDictLabel(this.devTypeOptions, row.deviceType)
|
|
|
- }
|
|
|
- }
|
|
|
-}
|
|
|
+ return this.selectDictLabel(this.devTypeOptions, row.deviceType);
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|