设备相关修改
This commit is contained in:
parent
6e1c6b053b
commit
decbefe7d7
|
@ -10,7 +10,7 @@
|
|||
:on-exceed="handleExceed"
|
||||
:on-success="handleUploadSuccess"
|
||||
:show-file-list="false"
|
||||
:headers="headers"
|
||||
:data="uploadData"
|
||||
class="upload-file-uploader"
|
||||
ref="fileUpload"
|
||||
>
|
||||
|
@ -28,13 +28,9 @@
|
|||
<!-- 文件列表 -->
|
||||
<transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
|
||||
<li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
|
||||
<div class="file-link">
|
||||
<image-preview v-if="isImage(file.url)" :src="file.url" :width="32" :height="32" style="margin-right: 10px"/>
|
||||
<i class="el-icon-document" v-else/>
|
||||
<el-link :href="realUrl(file.url)" :underline="false" target="_blank">
|
||||
{{ getFileName(file.name) }}
|
||||
<el-link :href="`${file.url}`" :underline="false" target="_blank">
|
||||
<span class="el-icon-document"> {{ getFileName(file.name) }} </span>
|
||||
</el-link>
|
||||
</div>
|
||||
<div class="ele-upload-list__item-content-action">
|
||||
<el-link :underline="false" @click="handleDelete(index)" type="danger">删除</el-link>
|
||||
</div>
|
||||
|
@ -44,7 +40,8 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { getToken } from '@/utils/auth'
|
||||
import { getToken } from "@/utils/auth";
|
||||
import { getQiniuToken } from "@/api/tool/common";
|
||||
|
||||
export default {
|
||||
name: "FileUpload",
|
||||
|
@ -59,12 +56,13 @@ export default {
|
|||
// 大小限制(MB)
|
||||
fileSize: {
|
||||
type: Number,
|
||||
default: 10,
|
||||
default: 5,
|
||||
},
|
||||
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
||||
fileType: {
|
||||
type: Array,
|
||||
default: () => ["doc", "xls", "ppt", "txt", "pdf", "xlsx", "jpg", "jpeg", "png"],
|
||||
// default: () => ["doc", "docx", "xls", "ppt", "txt", "pdf","bin"],
|
||||
default: () => ["bin"],
|
||||
},
|
||||
// 是否显示提示
|
||||
isShowTip: {
|
||||
|
@ -77,13 +75,24 @@ export default {
|
|||
number: 0,
|
||||
uploadList: [],
|
||||
baseUrl: process.env.VUE_APP_BASE_API,
|
||||
uploadFileUrl: process.env.VUE_APP_BASE_API + "/common/upload", // 上传文件服务器地址
|
||||
headers: {
|
||||
Authorization: "Bearer " + getToken(),
|
||||
},
|
||||
uploadData: {token:''},
|
||||
domain:"",
|
||||
uploadFileUrl: "https://up-z2.qiniup.com", // 上传文件服务器地址
|
||||
// headers: {
|
||||
// Authorization: "Bearer " + getToken(),
|
||||
// },
|
||||
fileList: [],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
getQiniuToken().then((res)=> {
|
||||
console.log("七牛云获取token"+JSON.stringify(res));
|
||||
if (res.code === 200) {
|
||||
this.uploadData.token = res.token
|
||||
this.domain = res.domain;
|
||||
}
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
value: {
|
||||
handler(val) {
|
||||
|
@ -113,21 +122,8 @@ export default {
|
|||
showTip() {
|
||||
return this.isShowTip && (this.fileType || this.fileSize);
|
||||
},
|
||||
// 获取真实url
|
||||
realUrl() {
|
||||
return (url) => {
|
||||
if (url.startsWith('http')) {
|
||||
return url;
|
||||
}
|
||||
return this.baseUrl + url;
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 是否是图片
|
||||
isImage(url) {
|
||||
return url.endsWith('.png') || url.endsWith('.jpg') || url.endsWith('.jpeg');
|
||||
},
|
||||
// 上传前校检格式和大小
|
||||
handleBeforeUpload(file) {
|
||||
// 校检文件类型
|
||||
|
@ -159,20 +155,24 @@ export default {
|
|||
// 上传失败
|
||||
handleUploadError(err) {
|
||||
this.$modal.msgError("上传文件失败,请重试");
|
||||
this.$modal.closeLoading();
|
||||
this.$modal.closeLoading()
|
||||
},
|
||||
// 上传成功回调
|
||||
handleUploadSuccess(res, file) {
|
||||
if (res.code === 200) {
|
||||
this.uploadList.push({ name: res.fileName, url: res.fileName });
|
||||
console.log("七牛云获取res"+JSON.stringify(res));
|
||||
console.log("七牛云获取file"+JSON.stringify(file));
|
||||
this.uploadList.push({ name: res.hash, url: this.domain+"/"+res.hash });
|
||||
this.uploadedSuccessfully();
|
||||
} else {
|
||||
this.number--;
|
||||
this.$modal.closeLoading();
|
||||
this.$modal.msgError(res.msg);
|
||||
this.$refs.fileUpload.handleRemove(file);
|
||||
this.uploadedSuccessfully();
|
||||
}
|
||||
// if (res.code === 200) {
|
||||
// this.uploadList.push({ name: res.fileName, url: res.fileName });
|
||||
// this.uploadedSuccessfully();
|
||||
// } else {
|
||||
// this.number--;
|
||||
// this.$modal.closeLoading();
|
||||
// this.$modal.msgError(res.msg);
|
||||
// this.$refs.fileUpload.handleRemove(file);
|
||||
// this.uploadedSuccessfully();
|
||||
// }
|
||||
},
|
||||
// 删除文件
|
||||
handleDelete(index) {
|
||||
|
@ -181,7 +181,9 @@ export default {
|
|||
},
|
||||
// 上传结束处理
|
||||
uploadedSuccessfully() {
|
||||
if (this.number > 0 && this.uploadList.length === this.number) {
|
||||
console.log("this.number:"+this.number);
|
||||
console.log("this.uploadList.length:"+this.uploadList.length);
|
||||
if (this.number > 0) {
|
||||
this.fileList = this.fileList.concat(this.uploadList);
|
||||
this.uploadList = [];
|
||||
this.number = 0;
|
||||
|
@ -191,11 +193,10 @@ export default {
|
|||
},
|
||||
// 获取文件名称
|
||||
getFileName(name) {
|
||||
// 如果是url那么取最后的名字 如果不是直接返回
|
||||
if (name.lastIndexOf("/") > -1) {
|
||||
return name.slice(name.lastIndexOf("/") + 1);
|
||||
} else {
|
||||
return name;
|
||||
return "";
|
||||
}
|
||||
},
|
||||
// 对象转成指定字符串分隔
|
||||
|
@ -230,9 +231,4 @@ export default {
|
|||
.ele-upload-list__item-content-action .el-link {
|
||||
margin-right: 10px;
|
||||
}
|
||||
.file-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="id" align="center" prop="versionId" />
|
||||
<el-table-column label="型号" align="center" prop="model" />
|
||||
<el-table-column label="型号名称" align="center" prop="modelName" />
|
||||
<el-table-column label="版本号" align="center" prop="version" />
|
||||
<el-table-column label="大小(K)" align="center" prop="size" />
|
||||
<el-table-column label="升级要求" align="center" prop="upgradeRequire" />
|
||||
|
@ -135,8 +136,10 @@
|
|||
<el-input v-model="form.version" placeholder="请输入版本号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文件" prop="file">
|
||||
<file-upload v-model="form.file"
|
||||
file-size="" file-type=""
|
||||
<file-upload
|
||||
v-model="form.file"
|
||||
:file-type="bin"
|
||||
:is-show-tip="false"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="大小(K)" prop="size">
|
||||
|
@ -235,6 +238,7 @@ export default {
|
|||
this.form = {
|
||||
versionId: null,
|
||||
modelId: null,
|
||||
modelName: null,
|
||||
version: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
|
|
|
@ -55,4 +55,8 @@ public class AsDeviceVersion extends BaseEntity
|
|||
@Excel(name = "创建时间")
|
||||
private LocalDateTime createLocalDateTime;
|
||||
|
||||
/** 升级 */
|
||||
@Excel(name = "版本名称")
|
||||
private String modelName;
|
||||
|
||||
}
|
||||
|
|
|
@ -505,7 +505,7 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
|||
@Override
|
||||
public Boolean bandDevice(AsDevice asDevice) {
|
||||
Boolean execute = transactionTemplate.execute(e -> {
|
||||
asDevice.setDeviceName(defaultName);
|
||||
asDevice.setCreateTime(DateUtils.getNowDate());
|
||||
int i = bandSn(asDevice);
|
||||
ServiceUtil.assertion(i == 0, "录入失败!");
|
||||
|
||||
|
|
|
@ -90,9 +90,10 @@ public class AsDeviceVersionServiceImpl extends ServiceImpl<AsDeviceVersionMappe
|
|||
{
|
||||
asDeviceVersion.setUpdateTime(DateUtils.getNowDate());
|
||||
// 更新对应的设备固件版本为最新的版本
|
||||
asModelService.selectAsModelByModelId(asDeviceVersion.getModelId());
|
||||
AsDeviceVersion latestAsDeviceVersion = asDeviceVersionMapper.selectLatestAsDeviceVersion(asDeviceVersion.getModelId());
|
||||
asDeviceVersion.setVersionId(latestAsDeviceVersion.getVersionId());
|
||||
AsModel asModel = asModelService.selectAsModelByModelId(asDeviceVersion.getModelId());
|
||||
asModel.setVersionId(latestAsDeviceVersion.getVersionId());
|
||||
asModelService.updateAsModel(asModel);
|
||||
return asDeviceVersionMapper.updateAsDeviceVersion(asDeviceVersion);
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="isDefault != null">is_default = #{isDefault},</if>
|
||||
<if test="modeStr != null">mode_str = #{modeStr},</if>
|
||||
<if test="bluetoothId != null">bluetooth_id = #{bluetoothId},</if>
|
||||
<if test="bluetoothName != null">bluetooth_name = #{bluetoothName}</if>
|
||||
<if test="bluetoothName != null">bluetooth_name = #{bluetoothName},</if>
|
||||
<if test="pre != null">pre = #{pre}</if>
|
||||
</trim>
|
||||
where device_id = #{deviceId}
|
||||
|
@ -282,9 +282,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null">status = #{status},</if>
|
||||
<if test="isNetwork != null">is_network = #{isNetwork},</if>
|
||||
<if test="isDefault != null">is_default = #{isDefault},</if>
|
||||
<if test="modeStr != null">mode_str = #{modeStr}</if>
|
||||
<if test="bluetoothId != null">bluetooth_id = #{bluetoothId}</if>
|
||||
<if test="bluetoothName != null">bluetooth_name = #{bluetoothName}</if>
|
||||
<if test="modeStr != null">mode_str = #{modeStr},</if>
|
||||
<if test="bluetoothId != null">bluetooth_id = #{bluetoothId},</if>
|
||||
<if test="bluetoothName != null">bluetooth_name = #{bluetoothName},</if>
|
||||
<if test="pre != null">pre = #{pre}</if>
|
||||
</trim>
|
||||
where mac = #{mac}
|
||||
|
|
|
@ -31,7 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
v.size,
|
||||
v.file,
|
||||
v.upgrade_require,
|
||||
v.upgrade_describe
|
||||
v.upgrade_describe,
|
||||
m.model_name
|
||||
from as_device_version v
|
||||
left join as_model m on v.model_id = m.model_id
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user