division.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <template>
  2. <view class="control">
  3. <view class="control-title">
  4. 分时控制
  5. </view>
  6. <view class="item" hover-class="navigator-hover" v-for="item in list" :key="item.index" @click="onClick(item)">
  7. <view class="title">
  8. {{ item.funcname }}
  9. </view>
  10. <view class="row">
  11. <view class="box">
  12. <view class="">
  13. 开始时间
  14. </view>
  15. <view class="content">
  16. <view class="value">{{ item.showValue.begin || '--' }}</view>
  17. </view>
  18. </view>
  19. <view class="box">
  20. <view class="">
  21. 结束时间
  22. </view>
  23. <view class="content">
  24. <view class="value">{{ item.showValue.end || '--' }}</view>
  25. </view>
  26. </view>
  27. <view class="box">
  28. <view class="">
  29. 流量设定
  30. </view>
  31. <view class="content">
  32. <view class="value">{{ item.showValue.value || '--' }}</view>
  33. <view class="unit">{{ item.params[item.funcname + "流量设定"].unit || '' }}</view>
  34. </view>
  35. </view>
  36. </view>
  37. <view v-if="item.isfeedback" class="dot" />
  38. </view>
  39. <My_input ref="MyInput" @customMethod="customMethod">
  40. <view class="change-item" v-if="changeItem.funcname">
  41. <picker mode="time" :value="changeItem.showValue.begin" :end="endTime" data-name="begin"
  42. @change="timeChange">
  43. <view class="row">
  44. <view class="label">
  45. 开始时间:{{ endTime }}
  46. </view>
  47. <view class="value day-parting-row">{{ changeItem.showValue.begin || ' --' }}
  48. </view>
  49. </view>
  50. </picker>
  51. <picker mode="time" :start="changeItem.showValue.begin" :value="changeItem.showValue.end" data-name="end"
  52. @change="timeChange">
  53. <view class="row">
  54. <view class="label">
  55. 结束时间:
  56. </view>
  57. <view class="value day-parting-row">{{ changeItem.showValue.end || ' --' }}</view>
  58. </view>
  59. </picker>
  60. <view class="row">
  61. <view class="label">
  62. 流量设定:
  63. </view>
  64. <view class="value">
  65. <u-input :placeholder="changeItem.showValue.value || '流量设定'" v-model="changeItem.showValue.value"
  66. :type="changeItem.params[changeItem.funcname1 + '流量设定'].num_scale == 0 ? 'number' : 'digit'">
  67. <template slot="suffix">
  68. {{ changeItem.params[changeItem.funcname1 + '流量设定'].unit || '' }}
  69. </template>
  70. </u-input>
  71. </view>
  72. </view>
  73. </view>
  74. </My_input>
  75. </view>
  76. </template>
  77. <script>
  78. export default {
  79. name: "division",
  80. data() {
  81. return {
  82. list: [],
  83. changeItem: {},
  84. endTime: ""
  85. }
  86. },
  87. methods: {
  88. loadData(newVal, Chinese = false) {
  89. let reg = /^时段\d{1,5}$/,
  90. count = 0,
  91. list = [];
  92. for (const key in newVal.function) {
  93. if (reg.test(key)) count++
  94. }
  95. let Nzh = require("nzh");
  96. let nzhcn = require("nzh/cn"); //直接使用简体中文
  97. for (let i = 1; i <= count; i++) {
  98. let name = Chinese ? nzhcn.encodeS(i) : i;
  99. let obj = newVal.function[`时段${i}`],
  100. keyList = [
  101. `时段${name}分钟开始`,//0
  102. `时段${name}分钟结束`,//1
  103. `时段${name}小时开始`,//2
  104. `时段${name}小时结束`,//3
  105. `时段${name}流量设定`,//4
  106. `时间段${name}置位`,//5
  107. ],
  108. item = {
  109. keyList,
  110. index: i,
  111. inputType: "slot",
  112. paramValue: {
  113. begin: newVal.paramcmdvalues[keyList[2]] ? newVal.paramcmdvalues[keyList[2]] + ":" + newVal.paramcmdvalues[keyList[0]] : "",
  114. end: newVal.paramcmdvalues[keyList[3]] ? newVal.paramcmdvalues[keyList[3]] + ":" + newVal.paramcmdvalues[keyList[1]] : "",
  115. value: newVal.paramcmdvalues[keyList[4]]
  116. },
  117. showValue: {
  118. begin: newVal.paramvalues[keyList[2]] ? newVal.paramvalues[keyList[2]] + ":" + newVal.paramvalues[keyList[0]] : "",
  119. end: newVal.paramvalues[keyList[3]] ? newVal.paramvalues[keyList[3]] + ":" + newVal.paramvalues[keyList[1]] : "",
  120. value: newVal.paramvalues[keyList[4]]
  121. },
  122. params: {}
  123. };
  124. keyList.forEach(key => {
  125. item.params[key] = newVal.params[key];
  126. });
  127. obj.funcname1 = "时段" + nzhcn.encodeS(i);
  128. item.isfeedback = (newVal.isfeedback && (obj.paramValue.begin || obj.paramValue.end || obj.paramValue.value)) ? true : false;
  129. list.push(Object.assign(obj, item))
  130. }
  131. this.list = list;
  132. },
  133. onClick(item) {
  134. this.changeItem = JSON.parse(JSON.stringify(item));
  135. this.endTime = this.changeItem.showValue.end == '0:0' ? "" : this.changeItem.showValue.end;
  136. let toBeUpdated = [];
  137. if (item.paramValue.begin) toBeUpdated.push(`开始时间:${item.paramValue.begin}`);
  138. if (item.paramValue.end) toBeUpdated.push(`结束时间:${item.paramValue.begin}`);
  139. if (item.paramValue.value) toBeUpdated.push(`流量设定:${item.paramValue.value}`);
  140. if (toBeUpdated.length) {
  141. model.toBeUpdated = '待更新记录:' + toBeUpdated.join(",")
  142. }
  143. this.$refs.MyInput.openInput(item, true)
  144. console.log("时段设置", item)
  145. },
  146. timeChange(e) {
  147. const name = e.currentTarget.dataset.name;
  148. this.changeItem.showValue[name] = e.detail.value;
  149. },
  150. customMethod() {
  151. const {
  152. showValue,
  153. w_functionid,
  154. params,
  155. index,
  156. } = this.changeItem,
  157. MyInput = this.$refs.MyInput;
  158. if (!showValue.begin) return MyInput.submitBreak("还未填写开始时间")
  159. if (!showValue.end) return MyInput.submitBreak("还未填写结束时间")
  160. if ((showValue.value + '').length == 0) return MyInput.submitBreak("还未设定流量")
  161. let Nzh = require("nzh");
  162. let nzhcn = require("nzh/cn"); //直接使用简体中文
  163. let funcname = '时段' + nzhcn.encodeS(index)
  164. console.log('输入值:', showValue.value)
  165. showValue.value = (showValue.value - 0).toFixed(params[funcname + '流量设定'].num_scale)
  166. console.log('流量设定:', params[funcname + '流量设定'])
  167. console.log('发送值:', showValue.value)
  168. let obj = {
  169. [funcname + "分钟开始"]: showValue.begin.split(":")[1],
  170. [funcname + "小时开始"]: showValue.begin.split(":")[0],
  171. [funcname + "分钟结束"]: showValue.end.split(":")[1],
  172. [funcname + "小时结束"]: showValue.end.split(":")[0],
  173. [funcname + "流量设定"]: showValue.value,
  174. [`时间段${nzhcn.encodeS(index)}置位`]: params[`时间段${nzhcn.encodeS(index)}置位`].lastvalue
  175. }
  176. console.log("发送请求", obj)
  177. MyInput.submit(w_functionid, obj)
  178. }
  179. }
  180. }
  181. </script>
  182. <style lang="scss" scoped>
  183. /* 边框 */
  184. .day-parting-row {
  185. display: flex;
  186. align-items: center;
  187. flex: 1;
  188. width: 0;
  189. border: 1px solid #dadbde;
  190. border-radius: 4px;
  191. padding: 6px 9px;
  192. height: 35px;
  193. font-size: 14px;
  194. box-sizing: border-box;
  195. }
  196. .item {
  197. position: relative;
  198. padding: 4px 6px 6px;
  199. box-sizing: border-box;
  200. background: #fff;
  201. border-radius: 4px;
  202. margin-bottom: 5px;
  203. .title {
  204. margin-bottom: 6px;
  205. font-weight: bold;
  206. }
  207. .row {
  208. display: flex;
  209. .box {
  210. width: 33.33%;
  211. .content {
  212. display: flex;
  213. margin-top: 6px;
  214. align-items: flex-end;
  215. .value {
  216. width: 0;
  217. flex: 1;
  218. color: #333;
  219. font-size: 16px;
  220. flex-shrink: 0;
  221. font-weight: bold;
  222. }
  223. .unit {
  224. font-size: 10px;
  225. color: #666;
  226. flex-shrink: 0;
  227. max-width: 50px;
  228. }
  229. }
  230. }
  231. }
  232. .dot {
  233. position: absolute;
  234. right: 2px;
  235. top: 2px;
  236. width: 10px;
  237. height: 10px;
  238. background: #D9001B;
  239. border-radius: 50%;
  240. }
  241. }
  242. .change-item {
  243. .row {
  244. display: flex;
  245. align-items: center;
  246. line-height: 35px;
  247. width: 100%;
  248. margin-top: 4px;
  249. .label {
  250. width: 80px;
  251. flex-shrink: 0;
  252. }
  253. }
  254. }
  255. </style>