division.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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="changeItem.showValue.end" data-name="begin"
  42. @change="timeChange">
  43. <view class="row">
  44. <view class="label">
  45. 开始时间:
  46. </view>
  47. <view class="value">{{ changeItem.showValue.begin || ' --' }}
  48. </view>
  49. </view>
  50. </picker>
  51. <picker class="row" mode="time" :start="changeItem.showValue.begin" :value="changeItem.showValue.end"
  52. data-name="end" @change="timeChange">
  53. <view class="row">
  54. <view class="label">
  55. 结束时间:
  56. </view>
  57. <view class="value">{{ 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. let model = null;
  79. export default {
  80. name: "division",
  81. data() {
  82. return {
  83. list: [],
  84. changeItem: {}
  85. }
  86. },
  87. methods: {
  88. loadData(newVal) {
  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. for (let i = 1; i <= count; i++) {
  96. let obj = newVal.function[`时段${i}`],
  97. keyList = [
  98. `时段${i}分钟开始`,//0
  99. `时段${i}分钟结束`,//1
  100. `时段${i}小时开始`,//2
  101. `时段${i}小时结束`,//3
  102. `时段${i}流量设定`,//4
  103. `时间段${i}置位`,//5
  104. ],
  105. item = {
  106. keyList,
  107. index: i,
  108. inputType: "slot",
  109. paramValue: {
  110. begin: newVal.paramcmdvalues[keyList[2]] ? newVal.paramcmdvalues[keyList[2]] + ":" + newVal.paramcmdvalues[keyList[0]] : "",
  111. end: newVal.paramcmdvalues[keyList[3]] ? newVal.paramcmdvalues[keyList[3]] + ":" + newVal.paramcmdvalues[keyList[1]] : "",
  112. value: newVal.paramcmdvalues[keyList[4]]
  113. },
  114. showValue: {
  115. begin: newVal.paramvalues[keyList[2]] ? newVal.paramvalues[keyList[2]] + ":" + newVal.paramvalues[keyList[0]] : "",
  116. end: newVal.paramvalues[keyList[3]] ? newVal.paramvalues[keyList[3]] + ":" + newVal.paramvalues[keyList[1]] : "",
  117. value: newVal.paramvalues[keyList[4]]
  118. },
  119. params: {}
  120. };
  121. keyList.forEach(key => {
  122. item.params[key] = newVal.params[key];
  123. });
  124. item.isfeedback = (newVal.isfeedback && (obj.paramValue.begin || obj.paramValue.end || obj.paramValue.value)) ? true : false;
  125. list.push(Object.assign(obj, item))
  126. }
  127. this.list = list;
  128. },
  129. onClick(item) {
  130. if (!model) model = this.$refs.MyInput;
  131. model.openInput(item, true)
  132. if (this.changeItem.funcname != item.funcname) this.changeItem = JSON.parse(JSON.stringify(item));
  133. let toBeUpdated = [];
  134. if (item.paramValue.begin) toBeUpdated.push(`开始时间:${item.paramValue.begin}`);
  135. if (item.paramValue.end) toBeUpdated.push(`结束时间:${item.paramValue.begin}`);
  136. if (item.paramValue.value) toBeUpdated.push(`流量设定:${item.paramValue.value}`);
  137. if (toBeUpdated.length) {
  138. model.toBeUpdated = '待更新记录:' + toBeUpdated.join(",")
  139. }
  140. },
  141. timeChange(e) {
  142. const name = e.currentTarget.dataset.name;
  143. this.changeItem.showValue[name] = e.detail.value;
  144. },
  145. customMethod() {
  146. const {
  147. showValue,
  148. w_functionid,
  149. params,
  150. index,
  151. funcname
  152. } = this.changeItem,
  153. MyInput = this.$refs.MyInput;
  154. if (!showValue.begin) return MyInput.submitBreak("还未填写开始时间")
  155. if (!showValue.end) return MyInput.submitBreak("还未填写结束时间")
  156. if ((showValue.value + '').length == 0) return MyInput.submitBreak("还未设定流量")
  157. showValue.value = (showValue.value - 0).toFixed(params[funcname + '流量设定'].num_scale)
  158. MyInput.submit(w_functionid, {
  159. "时段1分钟开始": showValue.begin.split(":")[1],
  160. "时段1小时开始": showValue.begin.split(":")[0],
  161. "时段1分钟结束": showValue.end.split(":")[1],
  162. "时段1小时结束": showValue.end.split(":")[0],
  163. "时段1流量设定": showValue.value,
  164. [`时间段${index}置位`]: params[`时间段${index}置位`].lastvalue
  165. })
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss" scoped>
  171. .item {
  172. position: relative;
  173. padding: 4px 6px 6px;
  174. box-sizing: border-box;
  175. background: #fff;
  176. border-radius: 4px;
  177. margin-bottom: 5px;
  178. .title {
  179. margin-bottom: 6px;
  180. font-weight: bold;
  181. }
  182. .row {
  183. display: flex;
  184. .box {
  185. width: 33.33%;
  186. .content {
  187. display: flex;
  188. margin-top: 6px;
  189. align-items: flex-end;
  190. .value {
  191. width: 0;
  192. flex: 1;
  193. color: #333;
  194. font-size: 16px;
  195. flex-shrink: 0;
  196. font-weight: bold;
  197. }
  198. .unit {
  199. font-size: 10px;
  200. color: #666;
  201. flex-shrink: 0;
  202. max-width: 50px;
  203. }
  204. }
  205. }
  206. }
  207. .dot {
  208. position: absolute;
  209. right: 2px;
  210. top: 2px;
  211. width: 10px;
  212. height: 10px;
  213. background: #D9001B;
  214. border-radius: 50%;
  215. }
  216. }
  217. .change-item {
  218. .row {
  219. display: flex;
  220. align-items: center;
  221. line-height: 35px;
  222. width: 100%;
  223. .label {
  224. width: 80px;
  225. flex-shrink: 0;
  226. }
  227. }
  228. }
  229. </style>