|
|
@@ -248,9 +248,9 @@
|
|
|
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
- <el-form-item label="投入使用时间" prop="useTime">
|
|
|
+ <el-form-item label="投产时间" prop="useTime">
|
|
|
<el-date-picker style="width: 100%" clearable v-model="form.useTime" type="date"
|
|
|
- value-format="yyyy-MM-dd" placeholder="请选择投入使用时间">
|
|
|
+ value-format="yyyy-MM-dd" placeholder="请选择投产时间">
|
|
|
</el-date-picker>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -310,6 +310,7 @@
|
|
|
:on-progress="handleFileUploadProgress"
|
|
|
:on-success="handleFileSuccess"
|
|
|
:auto-upload="false"
|
|
|
+ :before-upload="beforeUpload"
|
|
|
drag
|
|
|
>
|
|
|
<i class="el-icon-upload"></i>
|
|
|
@@ -333,12 +334,13 @@ import {getDeviceType} from "@/api/system/dict/data";
|
|
|
import {
|
|
|
addDevice,
|
|
|
delDevice,
|
|
|
- getDevice,
|
|
|
+ getDevice, getDictList,
|
|
|
getDictTree, getDictTreeByParentId,
|
|
|
getHostByOrgId,
|
|
|
listDevice,
|
|
|
updateDevice,
|
|
|
} from "@/api/system/device";
|
|
|
+import request from "@/utils/request";
|
|
|
|
|
|
export default {
|
|
|
/** 引入基础minxins*/
|
|
|
@@ -388,6 +390,7 @@ export default {
|
|
|
//主机集合
|
|
|
hostList: [],
|
|
|
dictionaryTreeList: [],
|
|
|
+ dictionaryList: [],
|
|
|
assetChildrenDictList: [],
|
|
|
brandChildrenDictList: [],
|
|
|
deviceType: 0,
|
|
|
@@ -466,6 +469,7 @@ export default {
|
|
|
},
|
|
|
mounted() {
|
|
|
this.initDictionaryTreeList();
|
|
|
+ this.initDictionaryList();
|
|
|
},
|
|
|
|
|
|
|
|
|
@@ -503,6 +507,55 @@ export default {
|
|
|
);
|
|
|
this.getList();
|
|
|
},
|
|
|
+ beforeUpload(file) {
|
|
|
+ // 返回 false 可以阻止文件上传
|
|
|
+ // 创建 FormData 对象
|
|
|
+
|
|
|
+ let config = {
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'multipart/form-data'
|
|
|
+ },
|
|
|
+ responseType: 'blob'
|
|
|
+ }
|
|
|
+ const formData = new FormData();
|
|
|
+ // 添加文件到 FormData
|
|
|
+ formData.append("file", file);
|
|
|
+ request.post(this.upload.url, formData, config)
|
|
|
+ .then((response) => {
|
|
|
+ // 在接收到后端响应时执行的逻辑
|
|
|
+ // console.log(response,"response");
|
|
|
+ this.upload.open = false;
|
|
|
+ this.upload.isUploading = false;
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
+ if (response&&response.size >0) {
|
|
|
+ this.$alert(
|
|
|
+ "导入失败,请根据返回的Excel检查文件内容"
|
|
|
+ );
|
|
|
+ const blob = new Blob([response],
|
|
|
+ {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'}) //你需要的类型 转化为blob对象
|
|
|
+ const url = window.URL.createObjectURL(blob) //将对象转化为链接
|
|
|
+ let a = document.createElement('a')
|
|
|
+ // 下载链接
|
|
|
+ a.href = url
|
|
|
+ a.download = '设备导入结果.xlsx'
|
|
|
+ document.body.appendChild(a)
|
|
|
+ // 点击a标签,进行下载
|
|
|
+ a.click()
|
|
|
+ // 移除元素
|
|
|
+ document.body.removeChild(a)
|
|
|
+ } else {
|
|
|
+ this.$alert(
|
|
|
+ "导入成功!"
|
|
|
+ );
|
|
|
+ }
|
|
|
+ this.getList();
|
|
|
+ })
|
|
|
+ .catch((error) => {
|
|
|
+ // 在请求失败时执行的逻辑
|
|
|
+ // console.log(error,"error");
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ },
|
|
|
getDefaultOrg(org) {
|
|
|
this.orgName = org.name;
|
|
|
},
|
|
|
@@ -654,21 +707,17 @@ export default {
|
|
|
this.changeSelect(this.dept);
|
|
|
this.devices = null;
|
|
|
},
|
|
|
- changeSelectDevice(val) {
|
|
|
- if (val) {
|
|
|
- getDeviceType(val).then((response) => {
|
|
|
- this.devices = response.data;
|
|
|
- this.form.deviceType = null;
|
|
|
- this.queryParams.deviceType = null;
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
//获取字典数据
|
|
|
initDictionaryTreeList() {
|
|
|
getDictTree().then((response) => {
|
|
|
this.dictionaryTreeList = response.data;
|
|
|
});
|
|
|
},
|
|
|
+ initDictionaryList() {
|
|
|
+ getDictList().then((response) => {
|
|
|
+ this.dictionaryList = response.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
//从基础数据中获取资产分类
|
|
|
getAssetDict(type, parentId) {
|
|
|
let arr = []
|
|
|
@@ -677,12 +726,21 @@ export default {
|
|
|
});
|
|
|
return arr;
|
|
|
},
|
|
|
+ //从基础数据中获取资产分类
|
|
|
+ getAssetDictDetailInfo(id) {
|
|
|
+ let arr = []
|
|
|
+ this.dictionaryList.filter(item => item.id == id).map(item => {
|
|
|
+ arr.push(item);
|
|
|
+ });
|
|
|
+ return arr;
|
|
|
+ },
|
|
|
assetSelectChange(val) {
|
|
|
//改成数据库查询, children里面
|
|
|
if (!val) return;
|
|
|
this.form.deviceType = null;
|
|
|
getDictTreeByParentId(val).then((response) => {
|
|
|
this.assetChildrenDictList = response.data;
|
|
|
+ console.log('获取设备分类数据', this.assetChildrenDictList);
|
|
|
});
|
|
|
},
|
|
|
brandSelectChange(val) {
|
|
|
@@ -691,6 +749,7 @@ export default {
|
|
|
this.form.deviceModel = null;
|
|
|
getDictTreeByParentId(val).then((response) => {
|
|
|
this.brandChildrenDictList = response.data;
|
|
|
+ console.log('获取设备型号数据', this.assetChildrenDictList);
|
|
|
});
|
|
|
},
|
|
|
clearAsset() {
|
|
|
@@ -702,11 +761,15 @@ export default {
|
|
|
const id = row.id || this.ids;
|
|
|
getDevice(id).then((response) => {
|
|
|
this.form = response.data;
|
|
|
- // this.form.inBook=response.data.inBook.toString();
|
|
|
- this.devices = response.devices;
|
|
|
- this.hostList = response.hostList;
|
|
|
this.open = true;
|
|
|
this.title = "编辑设备信息";
|
|
|
+ console.log(this.form.assetType,this.form.deviceBrand)
|
|
|
+ getDictTreeByParentId(this.form.assetType).then((response) => {
|
|
|
+ this.assetChildrenDictList = response.data;
|
|
|
+ });
|
|
|
+ getDictTreeByParentId(this.form.deviceBrand).then((response) => {
|
|
|
+ this.brandChildrenDictList = response.data;
|
|
|
+ });
|
|
|
});
|
|
|
},
|
|
|
/** 提交按钮 */
|