Browse Source

update 设备类型

pull/18/head
lb 1 year ago
parent
commit
fc94d0cccc
2 changed files with 46 additions and 57 deletions
  1. +28
    -1
      src/views/base/components/dialogForm.vue
  2. +18
    -56
      src/views/base/equipmentType/index.vue

+ 28
- 1
src/views/base/components/dialogForm.vue View File

@@ -1,7 +1,7 @@
<!-- <!--
filename: dialogForm.vue filename: dialogForm.vue
author: liubin author: liubin
date: 2023-08-02 10:32:36
date: 2023-08-15 10:32:36
description: 弹窗的表单组件 description: 弹窗的表单组件
--> -->


@@ -45,6 +45,18 @@
type="datetime" type="datetime"
:placeholder="`请选择${col.label}`" :placeholder="`请选择${col.label}`"
v-bind="col.bind"></el-date-picker> v-bind="col.bind"></el-date-picker>
<el-upload
class="upload-in-dialog"
v-if="col.upload"
:file-list="uploadedFileList"
:action="col.url"
:on-success="handleUploadSuccess"
v-bind="col.bind">
<el-button size="small" type="primary">点击上传</el-button>
<div class="el-upload__tip" slot="tip" v-if="col.uploadTips">
{{ col.uploadTips || '只能上传jpg/png文件,大小不超过2MB' }}
</div>
</el-upload>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@@ -90,6 +102,7 @@ export default {
return { return {
formLoading: true, formLoading: true,
optionListOf: {}, optionListOf: {},
uploadedFileList: [],
}; };
}, },
computed: { computed: {
@@ -196,6 +209,20 @@ export default {
} }
if (!promiseList.length) this.formLoading = false; if (!promiseList.length) this.formLoading = false;
}, },
// 上传成功的特殊处理
// 上传前的验证规则可通过 bind 属性传入
handleUploadSuccess(response, file, fileList) {
// 保存原始文件名
if ('fileNames' in this.form) this.form.fileNames.push(file.name);
// 保存完整地址
if ('fileUrls' in this.form) this.form.fileUrls.push(response.data);
// console.log('[dialogForm:handleUploadSuccess]', response, file, fileList, this.form);
this.$modal.msgSuccess('上传成功');
},

getFileName(fileUrl) {
return fileUrl.split('/').pop();
}
}, },
}; };
</script> </script>


+ 18
- 56
src/views/base/equipmentType/index.vue View File

@@ -54,6 +54,8 @@ import {
exportEquipmentTypeExcel, exportEquipmentTypeExcel,
} from '@/api/base/equipmentType'; } from '@/api/base/equipmentType';


import { getAccessToken } from '@/utils/auth';

export default { export default {
name: 'EquipmentType', name: 'EquipmentType',
components: {}, components: {},
@@ -86,40 +88,7 @@ export default {
{ prop: 'name', label: '设备类型名称', align: 'center' }, { prop: 'name', label: '设备类型名称', align: 'center' },
{ prop: 'code', label: '检测类型编码', align: 'center' }, { prop: 'code', label: '检测类型编码', align: 'center' },
{ prop: 'remark', label: '备注', align: 'center' }, { prop: 'remark', label: '备注', align: 'center' },
// {
// label: '操作',
// alignt: 'center',
// subcomponent: {
// render: function (h) {
// return h('div', null, [
// h(
// 'el-button',
// {
// props: {
// icon: 'el-icon-edit',
// size: 'mini',
// type: 'text',
// },
// },
// ' 修改'
// ),
// h(
// 'el-button',
// {
// props: {
// icon: 'el-icon-edit',
// size: 'mini',
// type: 'text',
// },
// },
// ' 修改'
// ),
// ]);
// },
// },
// },
], ],
//
searchBarFormConfig: [ searchBarFormConfig: [
{ {
type: 'input', type: 'input',
@@ -133,11 +102,6 @@ export default {
name: 'search', name: 'search',
color: 'primary', color: 'primary',
}, },
// {
// type: 'button',
// btnName: '重置',
// name: 'reset',
// },
{ {
type: 'separate', type: 'separate',
}, },
@@ -159,22 +123,6 @@ export default {
// color: 'warning', // color: 'warning',
// }, // },
], ],
// 表单配置
// formRows: [
// [
// {
// input: true,
// label: '检测类型名称',
// prop: 'name',
// rules: [{ required: true, message: '不能为空', trigger: 'blur' }],
// // bind: {
// // disabled: true, // some condition, like detail mode...
// // }
// },
// ],
// [{ input: true, label: '检测类型编码', prop: 'code' }],
// [{ input: true, label: '备注', prop: 'remark' }],
// ],
rows: [ rows: [
[ [
{ {
@@ -198,13 +146,17 @@ export default {
select: true, select: true,
label: '父类', label: '父类',
prop: 'parentId', prop: 'parentId',
// other...
url: '/base/equipment-type/page?pageNo=1&pageSize=100',
}, },
{ {
upload: true, upload: true,
label: '上传资料', label: '上传资料',
prop: 'uploadFiles', prop: 'uploadFiles',
// other...
url: process.env.VUE_APP_BASE_API + '/admin-api/infra/file/upload', // 请求地址
bind: {
headers: { Authorization: 'Bearer ' + getAccessToken() },
'show-file-list': false,
},
}, },
], ],
[{ input: true, label: '备注', prop: 'remark' }], [{ input: true, label: '备注', prop: 'remark' }],
@@ -221,6 +173,14 @@ export default {
form: {}, form: {},
}; };
}, },
watch: {
// form: {
// handler: function (val, oldVal) {
// console.log('[watch:form]', val, oldVal);
// },
// deep: true,
// },
},
created() { created() {
this.getList(); this.getList();
}, },
@@ -248,6 +208,8 @@ export default {
name: undefined, name: undefined,
parentId: undefined, parentId: undefined,
remark: undefined, remark: undefined,
fileNames: [],
fileUrls: [],
}; };
this.resetForm('form'); this.resetForm('form');
}, },


Loading…
Cancel
Save