云链智安app
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

index.vue 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view class="container">
  3. <view class="account_number">
  4. <view class="account_number_box">
  5. <view class="account_title">
  6. {{$t('strategy.name')}}:{{optionsinfo.type==1?$t('strategy.weekdays'):$t('strategy.weekends')}}
  7. </view>
  8. <view class="account_discharge">
  9. <view class="account_discharge1">
  10. {{$t('strategy.min')}}: 0%
  11. </view>
  12. <view class="account_discharge2">
  13. {{$t('strategy.max')}}: 100%
  14. </view>
  15. </view>
  16. <view class="account_text">
  17. {{$t('strategy.description')}}:{{optionsinfo.id}}-{{optionsinfo.type==1?$t('strategy.weekdays'):$t('strategy.weekends')}}
  18. </view>
  19. </view>
  20. </view>
  21. <view class="toptabbar">
  22. <view class="toptabbar_box">
  23. <zb-table
  24. :show-header="true"
  25. :columns="column"
  26. :stripe="true"
  27. :fit="false"
  28. border
  29. @cellClick="cellClick"
  30. :data="Arraytable"
  31. @dele="buttonDele"
  32. >
  33. </zb-table>
  34. <!-- <uni-icons type="trash" size="30"></uni-icons> -->
  35. </view>
  36. <view class="addtable">
  37. <!-- <uni-icons type="plus" size="30" @click="Upload"></uni-icons> -->
  38. </view>
  39. </view>
  40. <!-- 普通弹窗-->
  41. <time-picker-popup ref="TimePickerPopupRef" :value="value" @confirm="confirm"></time-picker-popup>
  42. </view>
  43. </template>
  44. <!-- -->
  45. <script>
  46. import TimePickerPopup from '@/components/jarvis-timePickerPopup/time-picker-popup.vue';
  47. import request from '@/utils/request';
  48. // import { useI18n } from 'vue-i18n'
  49. // const { t } = useI18n()
  50. export default {
  51. components: { TimePickerPopup },
  52. data() {
  53. return {
  54. value: {
  55. numberValue:'',
  56. defaultValue:true,
  57. data:['00', '00' , '00', '00']},
  58. column:[
  59. { name: 'StartTime', label: this.$t('strategy.start')},
  60. { name: 'EndTime', label:this.$t('strategy.end')},
  61. { name: 'direction', label: this.$t('strategy.direction')},
  62. { name: 'power', label: this.$t('strategy.power')},
  63. ],
  64. Arraytable:[
  65. {
  66. StartTime: '00:00',
  67. EndTime: '00:00',
  68. direction:this.$t('strategy.standing'),
  69. power: '0'
  70. },{
  71. StartTime: '00:00',
  72. EndTime: '00:00',
  73. direction:this.$t('strategy.standing'),
  74. power: '0'
  75. },{
  76. StartTime: '00:00',
  77. EndTime: '00:00',
  78. direction:this.$t('strategy.standing'),
  79. power: '0'
  80. },{
  81. StartTime: '00:00',
  82. EndTime: '00:00',
  83. direction:this.$t('strategy.standing'),
  84. power: '0'
  85. }
  86. ],
  87. optionsinfo:'',
  88. muserlistObj:{}
  89. }
  90. },
  91. onReady() {
  92. },
  93. onLoad(options) {
  94. console.log(options);
  95. this.optionsinfo = options
  96. if(options.type==1){
  97. this.strategydetails()
  98. }
  99. },
  100. onShow(){
  101. uni.setNavigationBarTitle({
  102. title:this.$t('strategy.editing'),
  103. });
  104. },
  105. methods: {
  106. // 策略详情
  107. async strategydetails () {
  108. try {
  109. const response = await request({
  110. url: `/mqtt/selectperiodoftime`,
  111. method: 'POST',
  112. header: {
  113. 'Content-Type': 'application/x-www-form-urlencoded'
  114. },
  115. data:{
  116. deviceId:this.optionsinfo.id
  117. }
  118. });
  119. console.log(response);
  120. // devicedata.value = response.data
  121. for (let index = 0; index < response.data.length; index++) {
  122. for (let i = 0; i < response.data[index].length; i++) {
  123. // 将 value 转换为整数
  124. response.data[index][i].value = Number(response.data[index][i].value) | 0;
  125. const key = response.data[index][i].k; // 使用 'k' 属性作为键
  126. const value = response.data[index][i].value + "";
  127. const value1 = String(value).padStart(2, "0");
  128. // 将键值对存入 muserlistObj
  129. this.muserlistObj[key] = value1;
  130. }
  131. }
  132. console.log(this.muserlistObj);
  133. let obj = [
  134. {
  135. StartTime:this.muserlistObj["Sys_Params_VPP_Charge_StartHour_1"]+':'+this.muserlistObj["Sys_Params_VPP_Charge_StartMin_1"],
  136. EndTime:this.muserlistObj["Sys_Params_VPP_Charge_StopHour_1"]+':'+this.muserlistObj["Sys_Params_VPP_Charge_StopMin_1"],
  137. direction: this.$t('strategy.charge'),
  138. power:this.muserlistObj["Sys_Params_VPP_ChargePower_1"]
  139. },
  140. {
  141. StartTime:this.muserlistObj["Sys_Params_VPP_Discharge_StartHour_1"]+':'+this.muserlistObj["Sys_Params_VPP_Discharge_StartMin_1"],
  142. EndTime:this.muserlistObj["Sys_Params_VPP_Discharge_StopHour_1"]+':'+this.muserlistObj["Sys_Params_VPP_Discharge_StopMin_1"],
  143. direction: this.$t('strategy.discharge'),
  144. power:this.muserlistObj["Sys_Params_VPP_DischargePower_1"]
  145. },{
  146. StartTime:this.muserlistObj["Sys_Params_VPP_Charge_StartHour_2"]+':'+this.muserlistObj["Sys_Params_VPP_Charge_StartMin_2"],
  147. EndTime:this.muserlistObj["Sys_Params_VPP_Charge_StopHour_2"]+':'+this.muserlistObj["Sys_Params_VPP_Charge_StopMin_2"],
  148. direction: this.$t('strategy.charge'),
  149. power:this.muserlistObj["Sys_Params_VPP_ChargePower_2"]
  150. },
  151. {
  152. StartTime:this.muserlistObj["Sys_Params_VPP_Discharge_StartHour_2"]+':'+this.muserlistObj["Sys_Params_VPP_Discharge_StartMin_2"],
  153. EndTime:this.muserlistObj["Sys_Params_VPP_Discharge_StopHour_2"]+':'+this.muserlistObj["Sys_Params_VPP_Discharge_StopMin_2"],
  154. direction: this.$t('strategy.discharge'),
  155. power:this.muserlistObj["Sys_Params_VPP_DischargePower_2"]
  156. }
  157. ]
  158. this.Arraytable = obj
  159. } catch (error) {
  160. console.error('登录失败:', error);
  161. }
  162. },
  163. // 确定弹窗
  164. async confirm (obj) {
  165. this.value = obj;
  166. console.log(deviceid.value);
  167. try {
  168. const response = await request({
  169. url: `/mqtt/periodoftime`,
  170. method: 'POST',
  171. header: {
  172. 'Content-Type': 'application/x-www-form-urlencoded'
  173. },
  174. });
  175. devicedata.value = response.data
  176. } catch (error) {
  177. console.error('登录失败:', error);
  178. }
  179. },
  180. open() {
  181. this.$refs.TimePickerPopupRef.open();
  182. },
  183. cellClick(row ,index,column){
  184. return
  185. console.log(row ,index,column);
  186. if(column.label=='操作'){
  187. return
  188. }
  189. let StartTime = row.StartTime.split(":");
  190. let EndTime = row.EndTime.split(":");
  191. const mergedArray = StartTime.concat(EndTime);
  192. this.value.numberValue = row.power
  193. this.value.defaultValue = row.direction == this.$t('strategy.charge')?true:false
  194. this.value.data = mergedArray
  195. this.$refs.TimePickerPopupRef.open();
  196. },
  197. buttonDele(e){
  198. this.deleteItemByIndex(e.key);
  199. },
  200. Upload(){
  201. let obj = {
  202. StartTime: '00:00',
  203. EndTime: '00:00',
  204. direction: this.$t('strategy.standing'),
  205. power: '0'
  206. }
  207. this.Arraytable.push(obj)
  208. },
  209. deleteItemByIndex(index) {
  210. // 使用 filter 创建一个新数组,排除指定索引的元素
  211. this.Arraytable = this.Arraytable.filter((item, i) => i !== index);
  212. console.log(this.Arraytable);
  213. }
  214. }
  215. }
  216. </script>
  217. <!-- -->
  218. <style scoped>
  219. .uni-page{
  220. width: 100%;
  221. height: 100%;
  222. }
  223. .container {
  224. height: 92vh;
  225. background: linear-gradient(to bottom, #007545 -40%, #f0f5f5 40%, #f0f5f5 100%);
  226. box-sizing: border-box;
  227. }
  228. .account_number{
  229. width: 100%;
  230. padding: 20rpx;
  231. display: flex;
  232. justify-content: center;
  233. box-sizing: border-box;
  234. }
  235. .account_number_box{
  236. width: 100%;
  237. height: 180rpx;
  238. padding: 20rpx;
  239. box-sizing: border-box;
  240. background-color: #f0f5f5;
  241. border-radius: 10rpx;
  242. }
  243. .account_title{
  244. font-size: 28rpx;
  245. font-weight: 600;
  246. }
  247. .toptabbar {
  248. width: 100%;
  249. padding: 10rpx 20rpx;
  250. box-sizing: border-box;
  251. }
  252. .toptabbar_box{
  253. display: flex;
  254. width: 100%;
  255. background-color: #f0f5f5;
  256. border-radius: 10rpx;
  257. padding: 20rpx;
  258. overflow: x;
  259. box-sizing: border-box;
  260. }
  261. .account_discharge2{
  262. margin-left: 40rpx;
  263. }
  264. .account_discharge{
  265. display: flex;
  266. font-size: 24rpx;
  267. margin-top: 30rpx;
  268. }
  269. .account_text{
  270. display: flex;
  271. font-size: 22rpx;
  272. margin-top: 10rpx;
  273. }
  274. .toptabbar_box1{
  275. width: 100%;
  276. height: 40rpx;
  277. display: flex;
  278. }
  279. .toptabbar_box2{
  280. flex: 1;
  281. display: flex;
  282. justify-content: center;
  283. }
  284. .toptabbar_box11{
  285. margin-top: 30rpx;
  286. width: 100%;
  287. height: 40rpx;
  288. display: flex;
  289. border-bottom: 1rpx solid #cccccc;
  290. padding-bottom:10rpx;
  291. }
  292. .toptabbar_direction{
  293. flex: 1;
  294. display: flex;
  295. justify-content: center;
  296. color: #007545;
  297. font-weight: 600;
  298. }
  299. .toptabbar_direction1{
  300. flex: 1;
  301. display: flex;
  302. justify-content: center;
  303. color: #E56E36;
  304. font-weight: 600;
  305. }
  306. .popup-height {
  307. @include height;
  308. width: 400px;
  309. }
  310. .text {
  311. font-size: 12px;
  312. color: #333;
  313. }
  314. .popup-success {
  315. color: #fff;
  316. background-color: #e1f3d8;
  317. }
  318. .popup-warn {
  319. color: #fff;
  320. background-color: #faecd8;
  321. }
  322. .popup-error {
  323. color: #fff;
  324. background-color: #fde2e2;
  325. }
  326. /* 弹出层内容样式 */
  327. .popup-content {
  328. height: 600rpx;
  329. padding: 30px;
  330. text-align: center;
  331. border-radius: 20rpx;
  332. box-sizing: border-box;
  333. }
  334. /* 文本样式 */
  335. .popuptext {
  336. display: flex;
  337. align-items: center;
  338. font-size: 26rpx;
  339. color: #333;
  340. margin-bottom: 60rpx;
  341. }
  342. .popuptext_left{
  343. margin-right: 20rpx;
  344. }
  345. /* 取消按钮样式 */
  346. .cancel-button {
  347. margin-top: 20rpx;
  348. font-size: 24rpx;
  349. color: #333;
  350. border: 0px solid rgba(0, 0, 0, 0) !important;
  351. background-color: #fff;
  352. }
  353. .uni-button:after{
  354. border: 0px solid rgba(0, 0, 0, 0) !important;
  355. }
  356. /* 确认按钮样式 */
  357. .confirm-button {
  358. width: 120rpx;
  359. height: 60rpx;
  360. margin-top: 10rpx;
  361. font-size: 24rpx;
  362. background-color: #007aff;
  363. color: #fff;
  364. }
  365. /* 根据设备类型调整高度 */
  366. .popup-height {
  367. height: 200px;
  368. }
  369. .popupbutton{
  370. display: flex;
  371. justify-content: center;
  372. }
  373. .l-switch{
  374. overflow: hidden;
  375. }
  376. .l-switch__rail-placeholder{
  377. height: 100%;
  378. }
  379. .addtable{
  380. width: 100%;
  381. height: 20rpx;
  382. text-align: center;
  383. }
  384. .static-direction {
  385. background-color: #f0f0f0; /* 静置的背景色 */
  386. color: #333; /* 静置的文字颜色 */
  387. }
  388. .forward-direction {
  389. background-color: #d4edda; /* 正向的背景色 */
  390. color: #155724; /* 正向的文字颜色 */
  391. }
  392. .reverse-direction {
  393. background-color: #f8d7da; /* 反向的背景色 */
  394. color: #721c24; /* 反向的文字颜色 */
  395. }
  396. </style>