更新
This commit is contained in:
parent
7523444595
commit
0a62aaf1aa
@ -65,6 +65,16 @@ export function addInspectionFile(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 新增inspectionFile
|
||||||
|
export function addBatchInspectionFile(data) {
|
||||||
|
return request({
|
||||||
|
url: '/inspectionFile/inspectionFile/addBatch',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 修改inspectionFile
|
// 修改inspectionFile
|
||||||
export function updateInspectionFile(data) {
|
export function updateInspectionFile(data) {
|
||||||
return request({
|
return request({
|
||||||
|
@ -37,6 +37,15 @@
|
|||||||
|
|
||||||
>新增
|
>新增
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAddBatch"
|
||||||
|
|
||||||
|
>批量新增
|
||||||
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
|
||||||
<el-col :span="1.5">
|
<el-col :span="1.5">
|
||||||
@ -116,12 +125,6 @@
|
|||||||
<!-- 添加或修改inspectionFile对话框 -->
|
<!-- 添加或修改inspectionFile对话框 -->
|
||||||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
||||||
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
|
||||||
<!-- <el-form-item label="店铺主键" prop="partnerId">-->
|
|
||||||
<!-- <el-input v-model="form.partnerId" placeholder="请输入店铺主键" />-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
<!-- <el-form-item label="父节点" prop="fatherId">-->
|
|
||||||
<!-- <el-input v-model="form.fatherId" placeholder="请输入父节点" />-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
<el-form-item label="文件名称" prop="fileName">
|
<el-form-item label="文件名称" prop="fileName">
|
||||||
<el-input v-model="form.fileName" placeholder="请输入文件名称"/>
|
<el-input v-model="form.fileName" placeholder="请输入文件名称"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@ -152,6 +155,38 @@
|
|||||||
<el-button @click="cancel">取 消</el-button>
|
<el-button @click="cancel">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<!-- 批量添加-->
|
||||||
|
<el-dialog title="批量新增" :visible.sync="openBatch" width="600px" append-to-body>
|
||||||
|
<el-form ref="formBatch" :model="form" :rules="rules" label-width="120px">
|
||||||
|
<el-form-item label="文件路径" prop="fileList">
|
||||||
|
<el-upload
|
||||||
|
class="upload-demo"
|
||||||
|
:action="uploadFileUrl"
|
||||||
|
multiple
|
||||||
|
:on-error="handleUploadError"
|
||||||
|
:on-exceed="handleExceed"
|
||||||
|
:on-success="handleUploadSuccess"
|
||||||
|
:before-upload="handleBeforeUpload"
|
||||||
|
:headers="headers"
|
||||||
|
:file-list="fileList">
|
||||||
|
<el-button size="small" type="primary">点击上传</el-button>
|
||||||
|
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
|
||||||
|
</el-upload>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="提醒时间" prop="warnTime">
|
||||||
|
<el-date-picker clearable
|
||||||
|
v-model="form.warnTime"
|
||||||
|
type="date"
|
||||||
|
value-format="yyyy-MM-dd"
|
||||||
|
placeholder="请选择提醒时间">
|
||||||
|
</el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitBatchForm">确 定</el-button>
|
||||||
|
<el-button @click="cancelBatch">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -161,19 +196,29 @@ import {
|
|||||||
getInspectionFile,
|
getInspectionFile,
|
||||||
delInspectionFile,
|
delInspectionFile,
|
||||||
addInspectionFile,
|
addInspectionFile,
|
||||||
updateInspectionFile, listStaff, assignAuthority, getUserIdsByFileId, listByPermission, getFileRecord
|
updateInspectionFile,
|
||||||
|
listStaff,
|
||||||
|
assignAuthority,
|
||||||
|
getUserIdsByFileId,
|
||||||
|
listByPermission,
|
||||||
|
getFileRecord,
|
||||||
|
addBatchInspectionFile
|
||||||
} from "../api/file";
|
} from "../api/file";
|
||||||
import inspFileUpload from '@/components/FileUpload/index.vue'
|
import inspFileUpload from '@/components/FileUpload/index.vue'
|
||||||
|
import {getAccessToken} from "@/utils/auth";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "InspectionFile",
|
name: "InspectionFile",
|
||||||
components: {inspFileUpload},
|
components: {inspFileUpload},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
uploadFileUrl: process.env.VUE_APP_BASE_API + "/admin-api/infra/file/uploadDetail",
|
||||||
// 遮罩层
|
// 遮罩层
|
||||||
loading: true,
|
loading: true,
|
||||||
// 选中数组
|
// 选中数组
|
||||||
ids: [],
|
ids: [],
|
||||||
|
fileList:[],
|
||||||
|
headers: { Authorization: "Bearer " + getAccessToken() }, // 设置上传的请求头部
|
||||||
// 非单个禁用
|
// 非单个禁用
|
||||||
single: true,
|
single: true,
|
||||||
// 非多个禁用
|
// 非多个禁用
|
||||||
@ -189,10 +234,13 @@ export default {
|
|||||||
drawer: false,
|
drawer: false,
|
||||||
// 是否显示弹出层
|
// 是否显示弹出层
|
||||||
open: false,
|
open: false,
|
||||||
|
openBatch: false,
|
||||||
// 是否显示弹出层(分配权限)
|
// 是否显示弹出层(分配权限)
|
||||||
isShow: false,
|
isShow: false,
|
||||||
// 提醒时间时间范围
|
// 提醒时间时间范围
|
||||||
daterangeWarnTime: [],
|
daterangeWarnTime: [],
|
||||||
|
number: 0,
|
||||||
|
uploadList:[],
|
||||||
// 查询参数
|
// 查询参数
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
@ -205,7 +253,25 @@ export default {
|
|||||||
// 表单参数
|
// 表单参数
|
||||||
form: {},
|
form: {},
|
||||||
// 表单校验
|
// 表单校验
|
||||||
rules: {},
|
rules: {
|
||||||
|
fileList: [
|
||||||
|
{
|
||||||
|
required: false,
|
||||||
|
message: "文件路径不能为空",
|
||||||
|
trigger: "blur"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validator: (rule, value, callback) => {
|
||||||
|
if (!value || value.length === 0) {
|
||||||
|
callback(new Error("请至少上传一个文件"));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
trigger: "change"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
// 员工列表
|
// 员工列表
|
||||||
staffList: [],
|
staffList: [],
|
||||||
selectStaffList: [],
|
selectStaffList: [],
|
||||||
@ -343,6 +409,11 @@ export default {
|
|||||||
this.open = false;
|
this.open = false;
|
||||||
this.reset();
|
this.reset();
|
||||||
},
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancelBatch() {
|
||||||
|
this.openBatch = false;
|
||||||
|
this.resetBatch();
|
||||||
|
},
|
||||||
// 表单重置
|
// 表单重置
|
||||||
reset() {
|
reset() {
|
||||||
this.form = {
|
this.form = {
|
||||||
@ -360,6 +431,24 @@ export default {
|
|||||||
};
|
};
|
||||||
this.resetForm("form");
|
this.resetForm("form");
|
||||||
},
|
},
|
||||||
|
// 表单重置
|
||||||
|
resetBatch() {
|
||||||
|
this.form = {
|
||||||
|
id: null,
|
||||||
|
partnerId: null,
|
||||||
|
type: null,
|
||||||
|
fatherId: null,
|
||||||
|
fileName: null,
|
||||||
|
filePath: null,
|
||||||
|
warnTime: null,
|
||||||
|
createTime: null,
|
||||||
|
createBy: null,
|
||||||
|
updateTime: null,
|
||||||
|
updateBy: null
|
||||||
|
};
|
||||||
|
this.fileList = []
|
||||||
|
this.resetForm("formBatch");
|
||||||
|
},
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery() {
|
handleQuery() {
|
||||||
this.queryParams.pageNum = 1;
|
this.queryParams.pageNum = 1;
|
||||||
@ -383,6 +472,12 @@ export default {
|
|||||||
this.open = true;
|
this.open = true;
|
||||||
this.title = "新增";
|
this.title = "新增";
|
||||||
},
|
},
|
||||||
|
/** 批量新增按钮操作 */
|
||||||
|
handleAddBatch() {
|
||||||
|
this.resetBatch();
|
||||||
|
this.openBatch = true;
|
||||||
|
this.title = "新增";
|
||||||
|
},
|
||||||
handleE(item) {
|
handleE(item) {
|
||||||
this.reset(item);
|
this.reset(item);
|
||||||
this.form = item;
|
this.form = item;
|
||||||
@ -424,6 +519,26 @@ export default {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitBatchForm() {
|
||||||
|
console.log(this.form,'内容')
|
||||||
|
console.log(this.fileList,'文件')
|
||||||
|
this.$refs["formBatch"].validate(valid => {
|
||||||
|
this.fileList.forEach(item => {
|
||||||
|
item.fatherId = this.fatherId
|
||||||
|
item.type = '2'
|
||||||
|
item.fileName = this.getFileNameWithoutExtension(item.name)
|
||||||
|
item.filePath = item.url
|
||||||
|
item.warnTime = this.form.warnTime
|
||||||
|
})
|
||||||
|
addBatchInspectionFile(this.fileList).then(res => {
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.openBatch = false
|
||||||
|
this.resetBatch()
|
||||||
|
this.getList();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
},
|
||||||
/** 分配文件权限给对应用户 */
|
/** 分配文件权限给对应用户 */
|
||||||
saveStaff() {
|
saveStaff() {
|
||||||
console.log(this.selectStaffList, "66666666666666")
|
console.log(this.selectStaffList, "66666666666666")
|
||||||
@ -452,6 +567,10 @@ export default {
|
|||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getFileNameWithoutExtension(filename) {
|
||||||
|
if (!filename.includes('.')) return filename; // 没有后缀直接返回
|
||||||
|
return filename.substring(0, filename.lastIndexOf('.'));
|
||||||
|
},
|
||||||
/** 删除按钮操作 */
|
/** 删除按钮操作 */
|
||||||
handleDelete(row) {
|
handleDelete(row) {
|
||||||
const ids = row.id || this.ids;
|
const ids = row.id || this.ids;
|
||||||
@ -468,7 +587,70 @@ export default {
|
|||||||
this.download('inspectionFile/inspectionFile/export', {
|
this.download('inspectionFile/inspectionFile/export', {
|
||||||
...this.queryParams
|
...this.queryParams
|
||||||
}, `inspectionFile_${new Date().getTime()}.xlsx`)
|
}, `inspectionFile_${new Date().getTime()}.xlsx`)
|
||||||
}
|
},
|
||||||
|
// 上传前校检格式和大小
|
||||||
|
handleBeforeUpload(file) {
|
||||||
|
// 校检文件类型
|
||||||
|
if (this.fileType) {
|
||||||
|
let fileExtension = "";
|
||||||
|
if (file.name.lastIndexOf(".") > -1) {
|
||||||
|
fileExtension = file.name.slice(file.name.lastIndexOf(".") + 1);
|
||||||
|
}
|
||||||
|
const isTypeOk = this.fileType.some((type) => {
|
||||||
|
if (file.type.indexOf(type) > -1) return true;
|
||||||
|
if (fileExtension && fileExtension.indexOf(type) > -1) return true;
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
if (!isTypeOk) {
|
||||||
|
this.$modal.msgError(`文件格式不正确, 请上传${this.fileType.join("/")}格式文件!`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 校检文件大小
|
||||||
|
if (this.fileSize) {
|
||||||
|
const isLt = file.size / 1024 / 1024 < this.fileSize;
|
||||||
|
if (!isLt) {
|
||||||
|
this.$modal.msgError(`上传文件大小不能超过 ${this.fileSize} MB!`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.$modal.loading("正在上传文件,请稍候...");
|
||||||
|
this.number++;
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
// 文件个数超出
|
||||||
|
handleExceed() {
|
||||||
|
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} 个!`);
|
||||||
|
},
|
||||||
|
// 上传失败
|
||||||
|
handleUploadError(err) {
|
||||||
|
this.$modal.msgError("上传图片失败,请重试");
|
||||||
|
this.$modal.closeLoading()
|
||||||
|
},
|
||||||
|
// 上传成功回调
|
||||||
|
handleUploadSuccess(res, file) {
|
||||||
|
if (res.code === 0) {
|
||||||
|
// edit by 芋道源码
|
||||||
|
this.uploadList.push({ name: res.data.name, url: res.data.url });
|
||||||
|
this.uploadedSuccessfully();
|
||||||
|
} else {
|
||||||
|
this.number--;
|
||||||
|
this.$modal.closeLoading();
|
||||||
|
this.$modal.msgError(res.msg);
|
||||||
|
this.$refs.fileUpload.handleRemove(file);
|
||||||
|
this.uploadedSuccessfully();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 上传结束处理
|
||||||
|
uploadedSuccessfully() {
|
||||||
|
if (this.number > 0 && this.uploadList.length === this.number) {
|
||||||
|
this.fileList = this.fileList.concat(this.uploadList);
|
||||||
|
this.uploadList = [];
|
||||||
|
this.number = 0;
|
||||||
|
// this.$emit("input", this.listToString(this.fileList));
|
||||||
|
this.$modal.closeLoading();
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user