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