检测设备更新
This commit is contained in:
parent
23ce4633a9
commit
cdd6ca0354
@ -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);
|
||||
})
|
||||
});
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user