division.vue 9.2 KB

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