Commit a66164ef authored by “yiyousong”'s avatar “yiyousong”

feat: 添加设备事项推荐

parent d0a65501
...@@ -138,8 +138,16 @@ export default { ...@@ -138,8 +138,16 @@ export default {
data.hotWords = data.hotWords.map((v) => v.hotwords); data.hotWords = data.hotWords.map((v) => v.hotwords);
this.homeInfo = data; this.homeInfo = data;
this.SET_homeInfo(data); this.SET_homeInfo(data);
this.SET_datumList(data.datumList); let datumList = this.removeDuplication(
this.SET_matterList(data.matterList); [...data.hotDatumList, ...data.datumList],
"id"
).slice(0, 7);
let matterList = this.removeDuplication(
[...data.hotMatterList, ...data.matterList],
"id"
).slice(0, 5);
this.SET_datumList(datumList);
this.SET_matterList(matterList);
} }
}, },
// 换肤 // 换肤
...@@ -172,6 +180,15 @@ export default { ...@@ -172,6 +180,15 @@ export default {
this.enabled = data.enabled; this.enabled = data.enabled;
} }
}, },
// 去重
removeDuplication(arr = [], field) {
const res = new Map();
return arr.filter((v) => {
return !res.has(v[field]) && res.set(v[field], 1);
});
},
// 轮询设备状态 // 轮询设备状态
getDevInfo() { getDevInfo() {
this.timer = setInterval(() => { this.timer = setInterval(() => {
......
...@@ -7,11 +7,13 @@ let PHP_URL = process.env.VUE_APP_API_PHP_URL; ...@@ -7,11 +7,13 @@ let PHP_URL = process.env.VUE_APP_API_PHP_URL;
export const getHomeInfo = (data) => { export const getHomeInfo = (data) => {
let baseUrl = local.getLocal("serverUrl"); let baseUrl = local.getLocal("serverUrl");
let siteId = local.getLocal("siteId"); let siteId = local.getLocal("siteId");
let deviceCode = local.getLocal("devicenum");
return request({ return request({
url: `${baseUrl}sampleform/home/info`, url: `${baseUrl}sampleform/home/info`,
method: "post", method: "post",
data: { data: {
siteId, siteId,
deviceCode,
...data, ...data,
}, },
}); });
......
...@@ -202,6 +202,7 @@ export default { ...@@ -202,6 +202,7 @@ export default {
matterId: this.matterId, matterId: this.matterId,
}); });
let { data } = res.data.data; let { data } = res.data.data;
if (!data.length) return;
data.forEach((v) => { data.forEach((v) => {
let image = new Image(); let image = new Image();
image.src = this.api + v.preViewPath; image.src = this.api + v.preViewPath;
......
...@@ -20,11 +20,38 @@ ...@@ -20,11 +20,38 @@
> >
<div class="flex aic jcb"> <div class="flex aic jcb">
<el-tooltip :content="v.matterName" placement="top"> <el-tooltip :content="v.matterName" placement="top">
<p class="matter-item-title"> <p class="matter-item-title flex1">
{{ v.matterName }} {{ v.matterName }}
</p> </p>
</el-tooltip> </el-tooltip>
<i class="el-icon-delete delete" @click="handleDel(v.id)"></i> <div>
<span
class="primary pointer"
v-if="!v.isRecommend"
@click="changeRecommend(v.id, 1)"
>
推荐
</span>
<span
class="green pointer"
v-else
@click="changeRecommend(v.id, 0)"
>
取消推荐
</span>
<el-tooltip
class="item"
effect="dark"
content="删除"
placement="top"
>
<i
class="el-icon-delete delete"
@click="handleDel(v.id)"
></i>
</el-tooltip>
</div>
</div> </div>
<div class="matter-item-count"> <div class="matter-item-count">
材料数量:{{ v.matterDatumList && v.matterDatumList.length }} 材料数量:{{ v.matterDatumList && v.matterDatumList.length }}
...@@ -319,6 +346,19 @@ export default { ...@@ -319,6 +346,19 @@ export default {
this.getDeviceMatterList(this.devInfo.id); this.getDeviceMatterList(this.devInfo.id);
} }
}, },
// 切换推荐
async changeRecommend(id, isRecommend) {
let obj = {
id,
isRecommend,
};
let res = await saveDeviceMatter(obj);
let { code, msg } = res.data;
if (code == 1) {
this.$message.success(msg);
this.getDeviceMatterList(this.devInfo.id);
}
},
// 删除设备事项 // 删除设备事项
handleDel(id) { handleDel(id) {
this.$confirm("此操作将删除该关联事项,是否继续?", "系统提示", { this.$confirm("此操作将删除该关联事项,是否继续?", "系统提示", {
...@@ -417,4 +457,4 @@ export default { ...@@ -417,4 +457,4 @@ export default {
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
} }
</style> </style>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment