Browse Source
Merge branch 'dev' of https://git.ouxuan.net/liujw/ox_zhiNengZhuShou into md0726
md0726
Merge branch 'dev' of https://git.ouxuan.net/liujw/ox_zhiNengZhuShou into md0726
md0726
刘嘉炜
4 months ago
7 changed files with 499 additions and 11 deletions
-
12src/pages.json
-
5src/subpackage/device/js/device_api.js
-
34src/subpackage/device/pages/index/index.vue
-
180src/subpackage/device/pages/lighting_time/list.vue
-
271src/subpackage/device/pages/lighting_time/setting.vue
-
8src/subpackage/device/pages/switch_manage/switch_manage.vue
-
BINsrc/subpackage/device/static/images/delete.png
@ -0,0 +1,180 @@ |
|||
<template> |
|||
<view class="lt-list"> |
|||
<view class="ll-title">{{ optionsQuery.hardware_name || '-' }}</view> |
|||
<view class="ll-list"> |
|||
<view class="ll-item" v-for="(e, i) in timingLs" :key="i"> |
|||
<view class="li-line"> |
|||
<view class="ll-txt">指令:{{ getInstructTxt(e.operate) }}</view> |
|||
<image class="ll-icon" @click="deleteItem(e)" mode="aspectFit" src="/subpackage/device/static/images/delete.png"></image> |
|||
</view> |
|||
<view class="li-line"> |
|||
<view class="ll-txt">时间:{{ e.h_m_s || '-'}}</view> |
|||
</view> |
|||
<view class="li-line"> |
|||
<view class="ll-txt">日期:{{ e.day_of_week || '-' }}</view> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="ll-fixed-space"></view> |
|||
<view class="ll-fixed"> |
|||
<view class="lf-btn" @click="addTask">添加定时任务</view> |
|||
</view> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import deviceServer from '../../js/device_server'; |
|||
import deviceApi from '../../js/device_api'; |
|||
import { showModal, showNone, showLoad, hideLoad, routeTo, jsonPar, jsonStr } from "@/utils/util"; |
|||
export default { |
|||
data(){ |
|||
return { |
|||
timingLs: [], |
|||
optionsQuery: {}, |
|||
} |
|||
}, |
|||
onLoad(options){ |
|||
options.hardware_name = jsonPar(options?.hardware_name); |
|||
this.optionsQuery = options; |
|||
}, |
|||
onShow(){ |
|||
let { optionsQuery } = this; |
|||
this.getTimingList({ |
|||
hardware_id: optionsQuery?.hardware_id || '' |
|||
}) |
|||
}, |
|||
methods: { |
|||
addTask(){ |
|||
let { hardware_id, hardware_name } = this.optionsQuery; |
|||
let _qryStr = `hardware_id=${hardware_id || ''}&hardware_name=${jsonStr(hardware_name || '')}` |
|||
routeTo(`/subpackage/device/pages/lighting_time/setting?${_qryStr}`, 'nT') |
|||
}, |
|||
deleteItem(e){ |
|||
showModal({ |
|||
title: '提示', |
|||
content: '是否删除该项?', |
|||
showCancel: true, |
|||
confirmText: '是', |
|||
cancelText: '否', |
|||
success: res =>{ |
|||
if(res?.confirm){ |
|||
this.cacScheduledTaskDelete(e?.id) |
|||
.then(res=>{ |
|||
if(res === 'SUCCESS')this.getTimingList({ hardware_id: e?.hardware_id }) |
|||
}) |
|||
} |
|||
} |
|||
}) |
|||
}, |
|||
cacScheduledTaskDelete(id){ |
|||
showLoad(); |
|||
return deviceServer.post({ |
|||
url: deviceApi.cacScheduledTaskDelete, |
|||
data: { id }, |
|||
isDefaultGet: false, |
|||
}) |
|||
.then(res => { |
|||
hideLoad(); |
|||
let _data = res?.data || {}; |
|||
if(_data.code === 0){ |
|||
showModal({ |
|||
title: '提示', |
|||
content: _data.message || '操作成功!' |
|||
}) |
|||
return "SUCCESS" |
|||
}else{ |
|||
return Promise.reject(_data); |
|||
} |
|||
|
|||
}) |
|||
.catch(err => { |
|||
hideLoad(); |
|||
showModal({ |
|||
title: '提示', |
|||
content: err.message || '操作失败!' |
|||
}) |
|||
console.warn('setting cacScheduledTaskSave err', err); |
|||
}) |
|||
}, |
|||
getInstructTxt(operate){ |
|||
let _obj = { |
|||
'open': '开启', |
|||
'close': '关闭' |
|||
} |
|||
return _obj?.[operate] || operate || '未知' |
|||
}, |
|||
getTimingList({ |
|||
hardware_id = '', |
|||
}){ |
|||
showLoad(); |
|||
return deviceServer.get({ |
|||
url: deviceApi.cacScheduledTaskGet, |
|||
data: { |
|||
hardware_id, |
|||
}, |
|||
failMsg: '获取定时列表失败' |
|||
}) |
|||
.then(res => { |
|||
hideLoad(); |
|||
let _ls = res || []; |
|||
this.timingLs = _ls; |
|||
}) |
|||
.catch(err => { |
|||
hideLoad(); |
|||
console.warn('lighting_time list getTimingList err --->', err); |
|||
// return Promise.reject(err); |
|||
}) |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss"> |
|||
.ll-title{ |
|||
padding: 46upx 40upx 60upx; |
|||
@include flcw(44upx, 60upx, #1a1a1a, 500); |
|||
@include tHide; |
|||
} |
|||
.ll-list{ |
|||
.ll-item{ |
|||
padding: 24upx 30upx; |
|||
background: #fff; |
|||
&+.ll-item{ |
|||
margin-top: 24upx; |
|||
} |
|||
.li-line{ |
|||
@include ctf(space-between); |
|||
align-items: baseline; |
|||
&+.li-line{ |
|||
margin-top: 16upx; |
|||
} |
|||
.ll-txt{ |
|||
@include flcw(28upx, 40upx, #1a1a1a); |
|||
} |
|||
.ll-icon { |
|||
flex-shrink: 0; |
|||
margin-left: 12upx; |
|||
width: 44upx; |
|||
height: 44upx; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
.ll-fixed-space{ |
|||
padding-bottom: 132upx; |
|||
@include isPd(132upx); |
|||
} |
|||
.ll-fixed{ |
|||
position: fixed; |
|||
bottom: 0; |
|||
padding: 10upx 24upx; |
|||
width: 100%; |
|||
@include isPd(10upx); |
|||
.lf-btn{ |
|||
text-align: center; |
|||
border-radius: 10upx; |
|||
background: $mColor; |
|||
@include flcw(32upx, 112upx, #fff, 500); |
|||
} |
|||
} |
|||
</style> |
@ -0,0 +1,271 @@ |
|||
<template> |
|||
<view class="lt-setting"> |
|||
<view class="ll-title">{{ optionsQuery.hardware_name || '-' }}</view> |
|||
|
|||
<view class="ls-container"> |
|||
<view class="lc-select"> |
|||
<view class="lc-name">指令</view> |
|||
<view class="ls-options"> |
|||
<view class="lp-item" @click="condition.instruct = 'open'"> |
|||
<view class="li-txt">开</view> |
|||
<image |
|||
class="li-icon" |
|||
mode="aspectFit" |
|||
:class="{active: condition.instruct === 'open'}" |
|||
:src="condition.instruct === 'open' ? '/subpackage/device/static/images/selected_987.png' : ''" |
|||
></image> |
|||
</view> |
|||
<view class="lp-item" @click="condition.instruct = 'close'"> |
|||
<view class="li-txt">关</view> |
|||
<image |
|||
class="li-icon" |
|||
mode="aspectFit" |
|||
:class="{active: condition.instruct === 'close'}" |
|||
:src="condition.instruct === 'close' ? '/subpackage/device/static/images/selected_987.png' : ''" |
|||
></image> |
|||
</view> |
|||
</view> |
|||
</view> |
|||
<view class="lc-picker"> |
|||
<view class="lc-name">时间点</view> |
|||
<picker mode="time" @change="condition.time = $event.detail.value"> |
|||
<view class="lp-box"> |
|||
<input disabled type="text" class="lb-ipt" v-model="condition.time"> |
|||
<image class="lb-icon" mode="aspectFit" src="/subpackage/device/static/images/arrow_b2.png"></image> |
|||
</view> |
|||
</picker> |
|||
</view> |
|||
<view class="lc-switch"> |
|||
<view class="lc-name">日期</view> |
|||
<view class="ls-right"> |
|||
<switch class="lr-switch" color="#009874" @change="switchChange"></switch> |
|||
<view class="lr-txt">全选</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="lc-week-ls"> |
|||
<view |
|||
class="lwl-item" |
|||
v-for="(e, i) in weeks" |
|||
:key="i" |
|||
:class="{active: condition.weekLs.includes(e)}" |
|||
@click="weekItemClick(e)" |
|||
>{{ e }}</view> |
|||
</view> |
|||
</view> |
|||
|
|||
<view class="ll-fixed-space"></view> |
|||
<view class="ll-fixed"> |
|||
<view class="lf-btn" @click="confirmBtn">添加定时任务</view> |
|||
</view> |
|||
</view> |
|||
</template> |
|||
|
|||
<script> |
|||
import deviceServer from '../../js/device_server'; |
|||
import deviceApi from '../../js/device_api'; |
|||
import { showModal, showNone, showLoad, hideLoad, routeTo, jsonPar } from "@/utils/util"; |
|||
export default { |
|||
data(){ |
|||
return { |
|||
weeks: [ '日', '一', '二', '三', '四', '五', '六' ].map(e=>`星期${e}`), |
|||
condition: { |
|||
instruct: 'open', // 指令 open: 开, close: 关 |
|||
time: '00:00', // 时间点 |
|||
weekLs: [], // 日期 |
|||
}, |
|||
optionsQuery: {} |
|||
} |
|||
}, |
|||
onLoad(options){ |
|||
options.hardware_name = jsonPar(options?.hardware_name); |
|||
this.optionsQuery = options || {} |
|||
}, |
|||
methods: { |
|||
switchChange(e){ |
|||
if(e.detail.value){ |
|||
this.condition.weekLs = [ ...this.weeks]; |
|||
}else{ |
|||
this.condition.weekLs = []; |
|||
} |
|||
}, |
|||
weekItemClick(e){ |
|||
let { weekLs } = this.condition; |
|||
if(weekLs.includes(e)){ |
|||
weekLs.splice(weekLs.indexOf(e), 1); |
|||
}else{ |
|||
weekLs.push(e); |
|||
} |
|||
}, |
|||
confirmBtn(){ |
|||
let { optionsQuery, condition } = this; |
|||
if(!condition?.weekLs?.length)return showNone('请选择日期!'); |
|||
if(!condition?.time)return showNone('请选时间点!'); |
|||
this.cacScheduledTaskSave({ |
|||
hardware_id: optionsQuery?.hardware_id || '', |
|||
day_of_week: condition?.weekLs?.join(','), |
|||
h_m_s: `${condition?.time}:00`, |
|||
operate: condition?.instruct, |
|||
|
|||
}) |
|||
}, |
|||
cacScheduledTaskSave({ |
|||
hardware_id = '', |
|||
day_of_week = '', |
|||
h_m_s = '', |
|||
operate = '' |
|||
}){ |
|||
showLoad(); |
|||
return deviceServer.post({ |
|||
url: deviceApi.cacScheduledTaskSave, |
|||
data: { hardware_id, day_of_week, h_m_s, operate }, |
|||
isDefaultGet: false, |
|||
}) |
|||
.then(res => { |
|||
hideLoad(); |
|||
let _data = res?.data || {}; |
|||
if(_data.code === 0){ |
|||
showModal({ |
|||
title: '提示', |
|||
content: _data.message || '操作成功!', |
|||
}) |
|||
}else{ |
|||
return Promise.reject(_data); |
|||
} |
|||
|
|||
}) |
|||
.catch(err => { |
|||
hideLoad(); |
|||
showModal({ |
|||
title: '提示', |
|||
content: err.message || '操作失败!' |
|||
}) |
|||
console.warn('setting cacScheduledTaskSave err', err); |
|||
}) |
|||
}, |
|||
} |
|||
} |
|||
</script> |
|||
|
|||
<style lang="scss"> |
|||
.ll-title{ |
|||
padding: 46upx 40upx 60upx; |
|||
@include flcw(44upx, 60upx, #1a1a1a, 500); |
|||
@include tHide; |
|||
} |
|||
.ls-container{ |
|||
margin: 0 auto; |
|||
padding: 50upx 30upx 100upx; |
|||
width: 678upx; |
|||
border-radius: 10upx; |
|||
background: #fff; |
|||
.lc-name{ |
|||
flex-shrink: 0; |
|||
@include flcw(32upx, 44upx, #1a1a1a); |
|||
} |
|||
.lc-select{ |
|||
@include ctf(space-between); |
|||
.ls-options{ |
|||
width: 480upx; |
|||
@include ctf; |
|||
.lp-item{ |
|||
width: 50%; |
|||
@include ctf; |
|||
.li-txt{ |
|||
@include flcw(32upx, 44upx, #1a1a1a); |
|||
} |
|||
.li-icon{ |
|||
margin-left: 22upx; |
|||
flex-shrink: 0; |
|||
width: 40upx; |
|||
height: 40upx; |
|||
border: 2upx solid #D8D8D8; |
|||
border-radius: 50%; |
|||
&.active{ |
|||
border-width: 0upx; |
|||
border-color: transparent; |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
.lc-picker{ |
|||
margin-top: 50upx; |
|||
@include ctf(space-between); |
|||
.lp-box{ |
|||
@include ctf(space-between); |
|||
width: 480upx; |
|||
height: 96upx; |
|||
border: 2upx solid #D8D8D8; |
|||
border-radius: 10upx; |
|||
padding: 0 20upx; |
|||
.lb-ipt{ |
|||
flex-grow: 1; |
|||
@include flcw(32upx, 44upx, #1a1a1a); |
|||
} |
|||
.lb-icon{ |
|||
flex-shrink: 0; |
|||
width: 28upx; |
|||
height: 28upx; |
|||
transform: rotateZ(90deg); |
|||
} |
|||
} |
|||
} |
|||
.lc-switch{ |
|||
margin-top: 50upx; |
|||
@include ctf(space-between); |
|||
.ls-right{ |
|||
width: 480upx; |
|||
@include ctf; |
|||
.lr-switch{ |
|||
transform: scale(.8); |
|||
} |
|||
.lr-txt{ |
|||
margin-left: 20upx; |
|||
@include flcw(32upx, 44upx, #1a1a1a); |
|||
} |
|||
} |
|||
} |
|||
.lc-week-ls{ |
|||
margin-top: 60upx; |
|||
display: flex; |
|||
flex-wrap: wrap; |
|||
.lwl-item{ |
|||
margin: 0 20upx; |
|||
width: 160upx; |
|||
height: 88upx; |
|||
border-radius: 6upx; |
|||
border: 2upx solid #979797; |
|||
text-align: center; |
|||
@include flcw(32upx, 84upx, #979797); |
|||
&:nth-child(n + 4){ |
|||
margin-top: 40upx; |
|||
} |
|||
&.active{ |
|||
color: $mColor; |
|||
border-color: $mColor; |
|||
background: rgba($color: $mColor, $alpha: .12); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
.ll-fixed-space{ |
|||
padding-bottom: 132upx; |
|||
@include isPd(132upx); |
|||
} |
|||
.ll-fixed{ |
|||
position: fixed; |
|||
bottom: 0; |
|||
padding: 10upx 24upx; |
|||
width: 100%; |
|||
@include isPd(10upx); |
|||
.lf-btn{ |
|||
text-align: center; |
|||
border-radius: 10upx; |
|||
background: $mColor; |
|||
@include flcw(32upx, 112upx, #fff, 500); |
|||
} |
|||
} |
|||
</style> |
After Width: 36 | Height: 36 | Size: 365 B |
Write
Preview
Loading…
Cancel
Save
Reference in new issue