fix bugs
This commit is contained in:
@@ -46,35 +46,36 @@
|
||||
}}文件大小不超过2MB
|
||||
</div>
|
||||
</el-upload>
|
||||
<!-- <div
|
||||
class="file-list__item"
|
||||
v-for="n in 9"
|
||||
:key="n"
|
||||
:style="{
|
||||
display: n > 4 && !expand ? 'none' : 'block',
|
||||
}"
|
||||
:data-name="n"
|
||||
:class="{ 'default-icon': !isPicMode }">
|
||||
<i class="el-icon-delete"></i>
|
||||
</div> -->
|
||||
<div
|
||||
class="file-list__item"
|
||||
v-for="(file, index) in files"
|
||||
:key="file.fileName"
|
||||
:style="{
|
||||
background: isPicMode
|
||||
? `url(${file.fileUrl}) no-repeat`
|
||||
: `url(${defaultBg}) no-repeat`,
|
||||
backgroundSize: isPicMode ? '100% 100%' : '64px',
|
||||
backgroundPosition: isPicMode ? '0% 0%' : 'center',
|
||||
}"
|
||||
:data-name="file.fileName">
|
||||
<el-button
|
||||
v-if="!disabled"
|
||||
type="text"
|
||||
class="el-icon-delete"
|
||||
style="padding: 0"
|
||||
@click="(e) => handleDelete(file)" />
|
||||
style="width: 100%">
|
||||
<div
|
||||
class="file-list__item"
|
||||
v-if="!isPicMode"
|
||||
:style="{
|
||||
background: isPicMode
|
||||
? `url(${file.fileUrl}) no-repeat`
|
||||
: `url(${defaultBg}) no-repeat`,
|
||||
backgroundSize: isPicMode ? '100% 100%' : '64px',
|
||||
backgroundPosition: isPicMode ? '0% 0%' : 'center',
|
||||
}"
|
||||
@click="handleDownload(file)"
|
||||
:data-name="file.fileName">
|
||||
<el-button
|
||||
v-if="!disabled"
|
||||
type="text"
|
||||
class="el-icon-delete"
|
||||
style="padding: 0"
|
||||
@click="(e) => handleDelete(file)" />
|
||||
</div>
|
||||
|
||||
<el-image
|
||||
v-else
|
||||
class="file-list__item"
|
||||
style="width: 100%"
|
||||
:src="file.fileUrl"
|
||||
:preview-src-list="files.map((item) => item.fileUrl)"></el-image>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@@ -189,6 +190,32 @@ export default {
|
||||
}, 500);
|
||||
},
|
||||
|
||||
async handleDownload(file) {
|
||||
if (this.isPicMode) {
|
||||
// this.$emit('preview', file);
|
||||
const link = document.createElement('a');
|
||||
link.href = file.fileUrl;
|
||||
link.target = '_blank';
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
} else {
|
||||
// this.$emit('download', file);
|
||||
const data = await this.$axios({
|
||||
url: file.fileUrl,
|
||||
method: 'get',
|
||||
responseType: 'blob',
|
||||
});
|
||||
const link = document.createElement('a');
|
||||
link.href = window.URL.createObjectURL(new Blob([data]));
|
||||
link.download = file.fileName;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
window.URL.revokeObjectURL(link.href);
|
||||
}
|
||||
},
|
||||
|
||||
emitFilelist() {
|
||||
this.$emit('update', this.files);
|
||||
},
|
||||
|
||||
@@ -42,16 +42,26 @@
|
||||
v-model="form" />
|
||||
</div>
|
||||
|
||||
<div v-if="section.key == 'attrs'" style="margin-top: 12px">
|
||||
<div
|
||||
v-if="section.key == 'attrs'"
|
||||
style="margin-top: 12px; position: relative">
|
||||
<div
|
||||
v-if="!mode.includes('detail')"
|
||||
style="position: absolute; top: -40px; right: 0">
|
||||
<el-button @click="handleAddAttr" type="text">
|
||||
<i class="el-icon-plus"></i>
|
||||
添加属性
|
||||
</el-button>
|
||||
</div>
|
||||
<base-table
|
||||
v-loading="attrListLoading"
|
||||
:table-props="section.props"
|
||||
:page="attrQuery?.params.pageNo || 1"
|
||||
:limit="attrQuery?.params.pageSize || 10"
|
||||
:table-data="list"
|
||||
:add-button-show="mode.includes('detail') ? null : '添加属性'"
|
||||
@emitButtonClick="handleAddAttr"
|
||||
@emitFun="handleEmitFun">
|
||||
<!-- :add-button-show="mode.includes('detail') ? null : '添加属性'"
|
||||
@emitButtonClick="handleAddAttr" -->
|
||||
<method-btn
|
||||
v-if="section.tableBtn"
|
||||
slot="handleBtn"
|
||||
@@ -76,7 +86,7 @@
|
||||
<el-button v-if="mode == 'detail'" type="primary" @click="toggleEdit">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button v-else type="primary" @click="handleConfirm">确定</el-button>
|
||||
<el-button v-else type="primary" @click="handleConfirm">保存</el-button>
|
||||
<!-- sections的第二项必须是 属性列表 -->
|
||||
<!-- <el-button
|
||||
v-if="sections[1].allowAdd"
|
||||
@@ -162,7 +172,9 @@ export default {
|
||||
input: true,
|
||||
label: '属性名称',
|
||||
prop: 'name',
|
||||
rules: [{ required: true, message: '属性名称不能为空', trigger: 'blur' }],
|
||||
rules: [
|
||||
{ required: true, message: '属性名称不能为空', trigger: 'blur' },
|
||||
],
|
||||
},
|
||||
],
|
||||
[
|
||||
|
||||
@@ -1,29 +1,62 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<!-- 搜索工作栏 -->
|
||||
<SearchBar :formConfigs="searchBarFormConfig" ref="search-bar" @headBtnClick="handleSearchBarBtnClick" />
|
||||
<SearchBar
|
||||
:formConfigs="searchBarFormConfig"
|
||||
ref="search-bar"
|
||||
@headBtnClick="handleSearchBarBtnClick" />
|
||||
|
||||
<!-- 列表 -->
|
||||
<base-table :table-props="tableProps" :page="queryParams.pageNo" :limit="queryParams.pageSize" :table-data="list"
|
||||
<base-table
|
||||
:table-props="tableProps"
|
||||
:page="queryParams.pageNo"
|
||||
:limit="queryParams.pageSize"
|
||||
:table-data="list"
|
||||
@emitFun="handleEmitFun">
|
||||
<method-btn v-if="tableBtn.length" slot="handleBtn" :width="120" label="操作" :method-list="tableBtn"
|
||||
<method-btn
|
||||
v-if="tableBtn.length"
|
||||
slot="handleBtn"
|
||||
:width="120"
|
||||
label="操作"
|
||||
:method-list="tableBtn"
|
||||
@clickBtn="handleTableBtnClick" />
|
||||
</base-table>
|
||||
|
||||
<!-- 分页组件 -->
|
||||
<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageNo"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList" />
|
||||
|
||||
<!-- 对话框(添加) -->
|
||||
<base-dialog :dialogTitle="title" :dialogVisible="open" @close="cancel" @cancel="cancel" width="60%"
|
||||
<base-dialog
|
||||
:dialogTitle="title"
|
||||
:dialogVisible="open"
|
||||
@close="cancel"
|
||||
@cancel="cancel"
|
||||
width="60%"
|
||||
@confirm="submitForm">
|
||||
<DialogForm v-if="open" key="index-dialog-form" ref="form" label-position="top" size="small" v-model="form"
|
||||
<DialogForm
|
||||
v-if="open"
|
||||
key="index-dialog-form"
|
||||
ref="form"
|
||||
label-position="top"
|
||||
size="small"
|
||||
v-model="form"
|
||||
:has-files="['files', 'files2']"
|
||||
:rows="computedRows" />
|
||||
</base-dialog>
|
||||
|
||||
<!-- 设备 详情 - 编辑 -->
|
||||
<EquipmentDrawer v-if="editVisible" ref="drawer" :mode="editMode" @update-mode="editMode = $event"
|
||||
:data-id="form.id" :sections="[
|
||||
<EquipmentDrawer
|
||||
v-if="editVisible"
|
||||
ref="drawer"
|
||||
:mode="editMode"
|
||||
@update-mode="editMode = $event"
|
||||
:data-id="form.id"
|
||||
:sections="[
|
||||
{
|
||||
name: '基本信息',
|
||||
key: 'base',
|
||||
@@ -50,20 +83,23 @@
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi('base:core-equipment-attr:update')
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '修改',
|
||||
}
|
||||
type: 'edit',
|
||||
btnName: '修改',
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi('base:core-equipment-attr:delete')
|
||||
? {
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
allowAdd: true,
|
||||
},
|
||||
]" @refreshDataList="getList" @cancel="cancelEdit" @destroy="cancelEdit" />
|
||||
]"
|
||||
@refreshDataList="getList"
|
||||
@cancel="cancelEdit"
|
||||
@destroy="cancelEdit" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -96,21 +132,21 @@ export default {
|
||||
tableBtn: [
|
||||
this.$auth.hasPermi(`base:core-equipment:update`)
|
||||
? {
|
||||
type: 'detail',
|
||||
btnName: '详情',
|
||||
}
|
||||
type: 'detail',
|
||||
btnName: '详情',
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi('base:core-equipment:update')
|
||||
? {
|
||||
type: 'edit',
|
||||
btnName: '修改',
|
||||
}
|
||||
type: 'edit',
|
||||
btnName: '修改',
|
||||
}
|
||||
: undefined,
|
||||
this.$auth.hasPermi('base:core-equipment:delete')
|
||||
? {
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
type: 'delete',
|
||||
btnName: '删除',
|
||||
}
|
||||
: undefined,
|
||||
].filter((v) => v),
|
||||
tableProps: [
|
||||
@@ -176,14 +212,18 @@ export default {
|
||||
type: 'separate',
|
||||
},
|
||||
{
|
||||
type: this.$auth.hasPermi('base:core-equipment:export') ? 'button' : '',
|
||||
type: this.$auth.hasPermi('base:core-equipment:export')
|
||||
? 'button'
|
||||
: '',
|
||||
btnName: '导出',
|
||||
name: 'export',
|
||||
plain: true,
|
||||
color: 'primary',
|
||||
},
|
||||
{
|
||||
type: this.$auth.hasPermi('base:core-equipment:create') ? 'button' : '',
|
||||
type: this.$auth.hasPermi('base:core-equipment:create')
|
||||
? 'button'
|
||||
: '',
|
||||
btnName: '新增',
|
||||
name: 'add',
|
||||
plain: true,
|
||||
@@ -196,7 +236,9 @@ export default {
|
||||
input: true,
|
||||
label: '设备名称',
|
||||
prop: 'name',
|
||||
rules: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
|
||||
rules: [
|
||||
{ required: true, message: '设备名称不能为空', trigger: 'blur' },
|
||||
],
|
||||
// bind: {
|
||||
// disabled: this.editMode == 'detail', // some condition, like detail mode...
|
||||
// }
|
||||
@@ -225,7 +267,9 @@ export default {
|
||||
label: '设备类型',
|
||||
prop: 'equipmentTypeId',
|
||||
url: '/base/core-equipment-type/page?pageNo=1&pageSize=100',
|
||||
rules: [{ required: true, message: '设备类型不能为空', trigger: 'blur' }],
|
||||
rules: [
|
||||
{ required: true, message: '设备类型不能为空', trigger: 'blur' },
|
||||
],
|
||||
bind: {
|
||||
filterable: true,
|
||||
},
|
||||
@@ -235,7 +279,11 @@ export default {
|
||||
label: '预计生产时间(min/天)',
|
||||
prop: 'workTime',
|
||||
rules: [
|
||||
{ required: true, message: '预计生产时间不能为空', trigger: 'blur' },
|
||||
{
|
||||
required: true,
|
||||
message: '预计生产时间不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
message: '请输入正确的数字值',
|
||||
@@ -291,7 +339,11 @@ export default {
|
||||
label: '单件产品加工时间(s)',
|
||||
prop: 'processingTime',
|
||||
rules: [
|
||||
{ required: true, message: '单件产品加工时间不能为空', trigger: 'blur' },
|
||||
{
|
||||
required: true,
|
||||
message: '单件产品加工时间不能为空',
|
||||
trigger: 'blur',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
message: '请输入正确的数字值',
|
||||
@@ -322,13 +374,19 @@ export default {
|
||||
[
|
||||
{
|
||||
upload: true,
|
||||
label: '上传资料',
|
||||
label: '设备资料',
|
||||
prop: 'files',
|
||||
},
|
||||
],
|
||||
[
|
||||
{ input: true, label: '备注', prop: 'remark' }
|
||||
{
|
||||
upload: true,
|
||||
label: '设备图片',
|
||||
prop: 'files2',
|
||||
fileType: 1,
|
||||
},
|
||||
],
|
||||
[{ input: true, label: '备注', prop: 'remark' }],
|
||||
// [
|
||||
// {
|
||||
// assetUpload: true,
|
||||
@@ -429,7 +487,7 @@ export default {
|
||||
// 表单参数
|
||||
form: {
|
||||
id: null,
|
||||
files: []
|
||||
files: [],
|
||||
},
|
||||
showUploadComponents: false, // 是否显示上传组件
|
||||
};
|
||||
@@ -441,36 +499,36 @@ export default {
|
||||
computedRows() {
|
||||
return this.showUploadComponents
|
||||
? [
|
||||
...this.rows,
|
||||
[
|
||||
{
|
||||
assetUpload: true,
|
||||
key: 'eq-assets', // 用于区分不同的上传组件
|
||||
label: '上传资料',
|
||||
fieldName: 'assets',
|
||||
subcomponent: AssetsUpload,
|
||||
prop: 'uploadedAssets',
|
||||
default: [],
|
||||
bind: {
|
||||
'is-pic-mode': false,
|
||||
...this.rows,
|
||||
[
|
||||
{
|
||||
assetUpload: true,
|
||||
key: 'eq-assets', // 用于区分不同的上传组件
|
||||
label: '上传资料',
|
||||
fieldName: 'assets',
|
||||
subcomponent: AssetsUpload,
|
||||
prop: 'uploadedAssets',
|
||||
default: [],
|
||||
bind: {
|
||||
'is-pic-mode': false,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
assetUpload: true,
|
||||
key: 'eq-pics', // 用于区分不同的上传组件
|
||||
label: '上传图片',
|
||||
fieldName: 'images',
|
||||
subcomponent: AssetsUpload,
|
||||
// prop: '',
|
||||
// default: [],
|
||||
bind: {
|
||||
'is-pic-mode': true,
|
||||
],
|
||||
[
|
||||
{
|
||||
assetUpload: true,
|
||||
key: 'eq-pics', // 用于区分不同的上传组件
|
||||
label: '上传图片',
|
||||
fieldName: 'images',
|
||||
subcomponent: AssetsUpload,
|
||||
// prop: '',
|
||||
// default: [],
|
||||
bind: {
|
||||
'is-pic-mode': true,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
]
|
||||
],
|
||||
]
|
||||
: this.rows;
|
||||
},
|
||||
},
|
||||
@@ -512,7 +570,8 @@ export default {
|
||||
spec: undefined,
|
||||
description: undefined,
|
||||
remark: undefined,
|
||||
files: []
|
||||
files: [],
|
||||
files2: [],
|
||||
};
|
||||
this.resetForm('form');
|
||||
},
|
||||
@@ -540,9 +599,12 @@ export default {
|
||||
if (!valid) {
|
||||
return;
|
||||
}
|
||||
const payload = Object.assign({}, this.form);
|
||||
payload.files = [...payload.files, ...payload.files2];
|
||||
delete payload.files2;
|
||||
// 修改的提交
|
||||
if (this.form.id != null) {
|
||||
updateEquipment(this.form).then((response) => {
|
||||
updateEquipment(payload).then((response) => {
|
||||
this.$modal.msgSuccess('修改成功');
|
||||
this.open = false;
|
||||
this.getList();
|
||||
@@ -550,7 +612,7 @@ export default {
|
||||
return;
|
||||
}
|
||||
// 添加的提交
|
||||
createEquipment(this.form).then((response) => {
|
||||
createEquipment(payload).then((response) => {
|
||||
this.$modal.msgSuccess('新增成功');
|
||||
this.open = false;
|
||||
this.getList();
|
||||
@@ -569,7 +631,7 @@ export default {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess('删除成功');
|
||||
})
|
||||
.catch(() => { });
|
||||
.catch(() => {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
@@ -587,7 +649,7 @@ export default {
|
||||
this.$download.excel(response, '设备.xls');
|
||||
this.exportLoading = false;
|
||||
})
|
||||
.catch(() => { });
|
||||
.catch(() => {});
|
||||
},
|
||||
// 查看详情
|
||||
viewDetail(id) {
|
||||
|
||||
Reference in New Issue
Block a user