yudao-dev/src/views/core/base/equipment/index.vue

450 lines
9.9 KiB
Vue
Raw Normal View History

2023-08-10 16:52:47 +08:00
<template>
2023-08-16 14:29:29 +08:00
<div class="app-container">
<!-- 搜索工作栏 -->
<SearchBar
:formConfigs="searchBarFormConfig"
ref="search-bar"
@headBtnClick="handleSearchBarBtnClick" />
2023-08-10 16:52:47 +08:00
2023-08-16 14:29:29 +08:00
<!-- 列表 -->
<base-table
:table-props="tableProps"
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-data="list"
@emitFun="handleEmitFun">
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
label="操作"
:method-list="tableBtn"
@clickBtn="handleTableBtnClick" />
</base-table>
2023-08-10 16:52:47 +08:00
2023-08-16 14:29:29 +08:00
<!-- 分页组件 -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
@pagination="getList" />
2023-08-10 16:52:47 +08:00
2023-08-16 14:29:29 +08:00
<!-- 对话框(添加 / 修改) -->
<base-dialog
:dialogTitle="title"
:dialogVisible="open"
@close="cancel"
@cancel="cancel"
@confirm="submitForm">
<DialogForm v-if="open" ref="form" :dataForm="form" :rows="rows" />
</base-dialog>
</div>
2023-08-10 16:52:47 +08:00
</template>
<script>
2023-08-16 14:29:29 +08:00
import moment from 'moment';
import basicPageMixin from '@/mixins/lb/basicPageMixin';
2023-08-16 14:29:29 +08:00
import { getAccessToken } from '@/utils/auth';
2023-08-18 16:56:53 +08:00
import EquipmentPics from './components/EquipmentPics';
2023-08-22 11:14:38 +08:00
import EquipmentAssets from './components/EquipmentAssets';
2023-08-16 14:29:29 +08:00
import {
createEquipment,
updateEquipment,
deleteEquipment,
getEquipment,
getEquipmentPage,
exportEquipmentExcel,
} from '@/api/base/equipment';
2023-08-10 16:52:47 +08:00
import Editor from '@/components/Editor';
export default {
2023-08-16 14:29:29 +08:00
name: 'Equipment',
components: {
Editor,
},
mixins: [basicPageMixin],
data() {
return {
searchBarKeys: ['name', 'code'],
tableBtn: [
this.$auth.hasPermi('base:equipment:update')
? {
type: 'edit',
btnName: '修改',
}
: undefined,
this.$auth.hasPermi('base:equipment:delete')
? {
type: 'delete',
btnName: '删除',
}
: undefined,
].filter((v) => v),
tableProps: [
{
prop: 'createTime',
label: '添加时间',
fixed: true,
width: 180,
filter: (val) => moment(val).format('yyyy-MM-DD HH:mm:ss'),
},
{ prop: 'name', label: '设备名称', align: 'center' },
{ prop: 'code', label: '检测编码', align: 'center' },
{ prop: 'equipmentType', label: '设备类型', align: 'center' },
{ prop: 'equipmentGroup', label: '设备分组', align: 'center' },
{ prop: 'enName', label: '英文名称', align: 'center' },
{ prop: 'abbr', label: '缩写', align: 'center' },
{
action: 'show-detail',
label: '详情',
align: 'center',
subcomponent: {
props: ['injectData'],
render: function (h) {
const _this = this;
return h(
'el-button',
{
props: { type: 'text', size: 'mini' },
on: {
click: function () {
console.log('inejctdata', _this.injectData);
_this.$emit('emitData', {
action: _this.injectData.action,
value: _this.injectData.id,
});
},
},
},
'查看详情'
);
},
},
},
],
searchBarFormConfig: [
{
type: 'input',
label: '名称',
placeholder: '请输入设备名称',
param: 'name',
},
{
type: 'input',
label: '编码',
placeholder: '请输入设备编码',
param: 'codes',
},
{
type: 'button',
btnName: '查询',
name: 'search',
color: 'primary',
},
{
type: 'separate',
},
{
type: this.$auth.hasPermi('base:equipment:create') ? 'button' : '',
btnName: '新增',
name: 'add',
plain: true,
color: 'success',
},
{
type: this.$auth.hasPermi('base:equipment:export') ? 'button' : '',
btnName: '导出',
name: 'export',
color: 'warning',
},
],
rows: [
[
{
input: true,
label: '设备名称',
prop: 'name',
rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
// bind: {
// disabled: true, // some condition, like detail mode...
// }
},
{
input: true,
label: '设备编码',
prop: 'code',
url: '/base/equipment/getCode',
},
],
[
{
input: true,
label: '英文名称',
prop: 'enName',
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
// bind: {
// disabled: true, // some condition, like detail mode...
// }
},
{
input: true,
label: '缩写',
prop: 'abbr',
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
// bind: {
// disabled: true, // some condition, like detail mode...
// }
},
],
[
{
select: true,
label: '设备类型',
prop: 'equipmentTypeId',
url: '/base/equipment-type/page?pageNo=1&pageSize=100',
},
2023-08-18 16:56:53 +08:00
// {
// select: true,
// label: '设备分组',
// prop: 'groupId',
// url: '/base/equipment-group/page?pageNo=1&pageSize=100',
// },
{ input: true, label: '备注', prop: 'remark' },
2023-08-16 14:29:29 +08:00
],
[
{
select: true,
label: '生产日期',
prop: 'productionTime',
},
{
select: true,
label: '进厂日期',
prop: 'enterTime',
},
],
[
{
select: true,
2023-08-18 16:56:53 +08:00
prop: 'tvalue',
2023-08-16 14:29:29 +08:00
label: '设备TT值',
rules: [
{ required: true, message: '不能为空', trigger: 'blur' },
{
type: 'number',
message: '请输入正确的数字值',
trigger: 'blur',
transform: (val) => Number(val),
},
],
},
{
select: true,
2023-08-18 16:56:53 +08:00
label: '产品加工时间',
2023-08-16 14:29:29 +08:00
prop: 'processingTime',
rules: [
{
type: 'number',
message: '请输入正确的数字值',
trigger: 'blur',
transform: (val) => Number(val),
},
],
},
],
[
{
select: true,
label: '制造商',
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
prop: 'manufacturer',
},
{
select: true,
label: '设备规格',
prop: 'spec',
},
],
[
{
textarea: true,
label: '功能描述',
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
prop: 'description',
},
],
[
{
upload: true,
label: '上传资料',
prop: 'uploadFiles',
url: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/upload', // 请求地址
bind: {
headers: { Authorization: 'Bearer ' + getAccessToken() },
'show-file-list': false,
},
},
],
[
{
diy: true,
2023-08-18 16:56:53 +08:00
key: 'eq-assets',
2023-08-16 14:29:29 +08:00
label: '设备资料',
prop: 'fileNames',
2023-08-22 11:14:38 +08:00
subcomponent: EquipmentAssets,
2023-08-16 14:29:29 +08:00
},
],
2023-08-17 09:37:39 +08:00
[
{
diy: true,
2023-08-18 16:56:53 +08:00
key: 'eq-pics',
2023-08-17 09:37:39 +08:00
label: '设备图片',
prop: 'fileUrls',
2023-08-18 16:56:53 +08:00
subcomponent: EquipmentPics,
2023-08-21 14:05:15 +08:00
pictures: async () => {
// some async request
return []
},
2023-08-18 16:56:53 +08:00
style: 'overflow-x: auto;'
2023-08-17 09:37:39 +08:00
},
],
2023-08-16 14:29:29 +08:00
],
// 是否显示弹出层
open: false,
// 查询参数
queryParams: {
pageNo: 1,
pageSize: 10,
2023-08-18 16:56:53 +08:00
code: '',
name: '',
2023-08-16 14:29:29 +08:00
},
// 表单参数
form: {},
};
},
created() {
this.getList();
},
methods: {
/** 查询列表 */
getList() {
this.loading = true;
// 执行查询
getEquipmentPage(this.queryParams).then((response) => {
this.list = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
/** 取消按钮 */
cancel() {
this.open = false;
this.reset();
},
/** 表单重置 */
reset() {
this.form = {
id: undefined,
code: undefined,
name: undefined,
enName: undefined,
abbr: undefined,
enterTime: undefined,
productionTime: undefined,
equipmentTypeId: undefined,
groupId: undefined,
tvalue: undefined,
processingTime: undefined,
manufacturer: undefined,
spec: undefined,
description: undefined,
remark: undefined,
};
this.resetForm('form');
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm('queryForm');
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = '添加设备';
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id;
getEquipment(id).then((response) => {
this.form = response.data;
this.open = true;
this.title = '修改设备';
});
},
/** 提交按钮 */
submitForm() {
this.$refs['form'].validate((valid) => {
if (!valid) {
return;
}
// 修改的提交
if (this.form.id != null) {
updateEquipment(this.form).then((response) => {
this.$modal.msgSuccess('修改成功');
this.open = false;
this.getList();
});
return;
}
// 添加的提交
createEquipment(this.form).then((response) => {
this.$modal.msgSuccess('新增成功');
this.open = false;
this.getList();
});
});
},
/** 删除按钮操作 */
handleDelete(row) {
const id = row.id;
this.$modal
.confirm('是否确认删除设备编号为"' + id + '"的数据项?')
.then(function () {
return deleteEquipment(id);
})
.then(() => {
this.getList();
this.$modal.msgSuccess('删除成功');
})
.catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
// 处理查询参数
let params = { ...this.queryParams };
params.pageNo = undefined;
params.pageSize = undefined;
this.$modal
.confirm('是否确认导出所有设备数据项?')
.then(() => {
this.exportLoading = true;
return exportEquipmentExcel(params);
})
.then((response) => {
this.$download.excel(response, '设备.xls');
this.exportLoading = false;
})
.catch(() => {});
},
},
2023-08-10 16:52:47 +08:00
};
</script>