division.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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.funcname + '流量设定'].num_scale == 0 ? 'number' : 'digit'">
  67. <template slot="suffix">
  68. {{ changeItem.params[changeItem.funcname + "流量设定"].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. item.isfeedback = (newVal.isfeedback && (obj.paramValue.begin || obj.paramValue.end || obj.paramValue.value)) ? true : false;
  128. list.push(Object.assign(obj, item))
  129. }
  130. this.list = list;
  131. },
  132. onClick(item) {
  133. this.changeItem = JSON.parse(JSON.stringify(item));
  134. this.endTime = this.changeItem.showValue.end == '0:0' ? "" : this.changeItem.showValue.end;
  135. let toBeUpdated = [];
  136. if (item.paramValue.begin) toBeUpdated.push(`开始时间:${item.paramValue.begin}`);
  137. if (item.paramValue.end) toBeUpdated.push(`结束时间:${item.paramValue.begin}`);
  138. if (item.paramValue.value) toBeUpdated.push(`流量设定:${item.paramValue.value}`);
  139. if (toBeUpdated.length) {
  140. model.toBeUpdated = '待更新记录:' + toBeUpdated.join(",")
  141. }
  142. this.$refs.MyInput.openInput(item, true)
  143. },
  144. timeChange(e) {
  145. const name = e.currentTarget.dataset.name;
  146. this.changeItem.showValue[name] = e.detail.value;
  147. },
  148. customMethod() {
  149. const {
  150. showValue,
  151. w_functionid,
  152. params,
  153. index,
  154. } = this.changeItem,
  155. MyInput = this.$refs.MyInput;
  156. if (!showValue.begin) return MyInput.submitBreak("还未填写开始时间")
  157. if (!showValue.end) return MyInput.submitBreak("还未填写结束时间")
  158. if ((showValue.value + '').length == 0) return MyInput.submitBreak("还未设定流量")
  159. let Nzh = require("nzh");
  160. let nzhcn = require("nzh/cn"); //直接使用简体中文
  161. let funcname = '时段' + nzhcn.encodeS(index)
  162. showValue.value = (showValue.value - 0).toFixed(params[funcname + '流量设定'].num_scale)
  163. MyInput.submit(w_functionid, {
  164. [funcname + "分钟开始"]: showValue.begin.split(":")[1],
  165. [funcname + "小时开始"]: showValue.begin.split(":")[0],
  166. [funcname + "分钟结束"]: showValue.end.split(":")[1],
  167. [funcname + "小时结束"]: showValue.end.split(":")[0],
  168. [funcname + "流量设定"]: showValue.value,
  169. [`时间段${nzhcn.encodeS(index)}置位`]: params[`时间段${nzhcn.encodeS(index)}置位`].lastvalue
  170. })
  171. }
  172. }
  173. }
  174. </script>
  175. <style lang="scss" scoped>
  176. /* 边框 */
  177. .day-parting-row {
  178. display: flex;
  179. align-items: center;
  180. flex: 1;
  181. width: 0;
  182. border: 1px solid #dadbde;
  183. border-radius: 4px;
  184. padding: 6px 9px;
  185. height: 35px;
  186. font-size: 14px;
  187. box-sizing: border-box;
  188. }
  189. .item {
  190. position: relative;
  191. padding: 4px 6px 6px;
  192. box-sizing: border-box;
  193. background: #fff;
  194. border-radius: 4px;
  195. margin-bottom: 5px;
  196. .title {
  197. margin-bottom: 6px;
  198. font-weight: bold;
  199. }
  200. .row {
  201. display: flex;
  202. .box {
  203. width: 33.33%;
  204. .content {
  205. display: flex;
  206. margin-top: 6px;
  207. align-items: flex-end;
  208. .value {
  209. width: 0;
  210. flex: 1;
  211. color: #333;
  212. font-size: 16px;
  213. flex-shrink: 0;
  214. font-weight: bold;
  215. }
  216. .unit {
  217. font-size: 10px;
  218. color: #666;
  219. flex-shrink: 0;
  220. max-width: 50px;
  221. }
  222. }
  223. }
  224. }
  225. .dot {
  226. position: absolute;
  227. right: 2px;
  228. top: 2px;
  229. width: 10px;
  230. height: 10px;
  231. background: #D9001B;
  232. border-radius: 50%;
  233. }
  234. }
  235. .change-item {
  236. .row {
  237. display: flex;
  238. align-items: center;
  239. line-height: 35px;
  240. width: 100%;
  241. margin-top: 4px;
  242. .label {
  243. width: 80px;
  244. flex-shrink: 0;
  245. }
  246. }
  247. }
  248. </style>