检测设备更新

This commit is contained in:
许允枞 2025-02-06 18:03:27 +08:00
parent 23ce4633a9
commit cdd6ca0354

View File

@ -90,6 +90,24 @@
<text>{{ time1 || '' }}</text>
</view>
</view>
<view class="tinput">
<view class="text1">
<text class="hong1">*</text>
设备附件
</view>
<view class="you">
<u-upload
:fileList="fileList3"
@afterRead="afterRead"
@delete="deletePic"
name="3"
multiple
:maxCount="10"
:previewFullImage="true"
></u-upload>
</view>
</view>
<u-datetime-picker
:show="show"
v-model="box.validTime"
@ -144,6 +162,9 @@ export default {
typeShow: false,
columns: [],
typeName: null,
//
fileList3: [],
baseImageUrl: config.baseImageUrl,
}
},
onLoad(option) {
@ -158,14 +179,14 @@ export default {
if (this.type == 'edit') this.getDetail();
},
methods: {
confirmsType(e){
confirmsType(e) {
console.log(e)
this.box.type = e.value[0].value
this.typeName = e.value[0].label
this.typeShow = false
},
async getInsType(){
if (!this.columns || this.columns.length === 0){
async getInsType() {
if (!this.columns || this.columns.length === 0) {
this.columns = [await getDictDataByType("ins_equ_type")]
}
console.log(this.columns)
@ -177,14 +198,23 @@ export default {
})
if (res.code == 200) {
this.box = res.data
if (this.box.fileList) {
this.fileList3 = this.box.fileList
// URL
this.fileList3 = this.fileList3.map(file => {
//
file.url = this.baseImageUrl + '/' + file.url;
return file;
});
}
// this.maneizhi = this.box.type
this.time = this.box.validTime
this.time1 = this.box.nextCheckTime
}
if (this.box.type){
if (this.box.type) {
const data = this.columns[0]
const index = data.findIndex(item => item.value === this.box.type)
if (index !== -1){
if (index !== -1) {
this.typeName = data[index].label
}
}
@ -228,9 +258,14 @@ export default {
// icon:'none'
// })
this.box.fileList = this.fileList3.map(file => {
//
if (file.url && file.url.startsWith(this.baseImageUrl)) {
file.url = file.url.replace(this.baseImageUrl, '');
}
return file;
});
if (this.type == 'add') {
let res = await request({
url: '/system/equInfo/add',
method: 'post',
@ -274,6 +309,48 @@ export default {
})
},
//
deletePic(event) {
this[`fileList${event.name}`].splice(event.index, 1);
},
//
async afterRead(event) {
// multiple true , file
let lists = [].concat(event.file);
let fileListLen = this[`fileList${event.name}`].length;
lists.map((item) => {
this[`fileList${event.name}`].push({
...item,
status: "uploading",
message: "上传中",
});
});
for (let i = 0; i < lists.length; i++) {
const result = await this.uploadFilePromise(lists[i].url);
let item = this[`fileList${event.name}`][fileListLen];
this[`fileList${event.name}`].splice(
fileListLen,
1,
Object.assign(item, {
status: "success",
message: "",
url: result,
})
);
fileListLen++;
}
console.log('现在文件集合', this[`fileList${event.name}`])
},
uploadFilePromise(url) {
return new Promise((resolve, reject) => {
upload({
url: '/common/upload',
filePath: url,
}).then((res) => {
resolve(res.data.url);
})
});
},
}