division.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  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>
  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>
  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 day-parting-row">{{ changeItem.showValue.begin || ' --' }}
  58. </view>
  59. </view>
  60. </picker>
  61. <picker mode="time" :start="changeItem.showValue.begin" :value="changeItem.showValue.end" data-name="end"
  62. @change="timeChange">
  63. <view class="row">
  64. <view class="label">
  65. 结束时间:
  66. </view>
  67. <view class="value day-parting-row">{{ 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. export default {
  89. name: "division",
  90. data() {
  91. return {
  92. list: [],
  93. changeItem: {},
  94. timeControl: {}
  95. }
  96. },
  97. methods: {
  98. loadData(newVal) {
  99. let reg = /^T\d{1,5}$/,
  100. count = 0,
  101. list = [];
  102. for (const key in newVal.function) {
  103. if (reg.test(key)) count++
  104. }
  105. for (let i = 1; i <= count; i++) {
  106. let obj = newVal.function[`T${i}`],
  107. keyList = [
  108. `T${i}H`,//开始小时
  109. `T${i}M`,//开始分钟
  110. `T${i}H1`,//结束小时
  111. `T${i}M1`,//结束分钟
  112. `T${i}_P`,//压力设置
  113. ],
  114. item = {
  115. keyList,
  116. index: i,
  117. inputType: "slot",
  118. paramValue: {
  119. begin: newVal.paramcmdvalues[`T${i}H`] + newVal.paramcmdvalues[`T${i}M`] ? newVal.paramcmdvalues[`T${i}H`] + ":" + newVal.paramcmdvalues[`T${i}M`] : "",
  120. end: newVal.paramcmdvalues[`T${i}H1`] + newVal.paramcmdvalues[`T${i}M1`] ? newVal.paramcmdvalues[`T${i}H1`] + ":" + newVal.paramcmdvalues[`T${i}M1`] : "",
  121. value: newVal.paramcmdvalues[`T${i}_P`]
  122. },
  123. showValue: {
  124. begin: newVal.paramvalues[`T${i}H`] + newVal.paramvalues[`T${i}M`] ? newVal.paramvalues[`T${i}H`] + ":" + newVal.paramvalues[`T${i}M`] : "",
  125. end: newVal.paramvalues[`T${i}H1`] + newVal.paramvalues[`T${i}M1`] ? newVal.paramvalues[`T${i}H1`] + ":" + newVal.paramvalues[`T${i}M1`] : "",
  126. value: newVal.paramvalues[`T${i}_P`]
  127. },
  128. params: {}
  129. };
  130. keyList.forEach(key => {
  131. item.params[key] = newVal.params[key];
  132. });
  133. item.isfeedback = (newVal.isfeedback && (obj.paramValue.begin || obj.paramValue.end || obj.paramValue.value)) ? true : false;
  134. list.push(Object.assign(obj, item))
  135. }
  136. this.list = list;
  137. this.timeControl = this.__proto__.getControlItem(["TimeCon"], newVal)[0]
  138. },
  139. onClick(item) {
  140. this.$refs.MyInput.openInput(item, true)
  141. if (this.changeItem.funcname != item.funcname) this.changeItem = JSON.parse(JSON.stringify(item));
  142. let toBeUpdated = [];
  143. if (item.paramValue.begin) toBeUpdated.push(`开始时间:${item.paramValue.begin}`);
  144. if (item.paramValue.end) toBeUpdated.push(`结束时间:${item.paramValue.begin}`);
  145. if (item.paramValue.value) toBeUpdated.push(`压力设置:${item.paramValue.value}`);
  146. if (toBeUpdated.length) {
  147. model.toBeUpdated = '待更新记录:' + toBeUpdated.join(",")
  148. }
  149. },
  150. timeChange(e) {
  151. const name = e.currentTarget.dataset.name;
  152. this.changeItem.showValue[name] = e.detail.value;
  153. },
  154. customMethod() {
  155. const {
  156. showValue,
  157. w_functionid,
  158. params,
  159. index
  160. } = this.changeItem,
  161. MyInput = this.$refs.MyInput;
  162. if (!showValue.begin) return MyInput.submitBreak("还未填写开始时间")
  163. if (!showValue.end) return MyInput.submitBreak("还未填写结束时间")
  164. if ((showValue.value + '').length == 0) return MyInput.submitBreak("还未设定压力")
  165. showValue.value = (showValue.value - 0).toFixed(params[`T${index}_P`].num_scale)
  166. MyInput.submit(w_functionid, {
  167. [`T${index}H`]: showValue.begin.split(":")[1],
  168. [`T${index}M`]: showValue.begin.split(":")[0],
  169. [`T${index}H1`]: showValue.end.split(":")[1],
  170. [`T${index}M1`]: showValue.end.split(":")[0],
  171. [`T${index}_P`]: showValue.value,
  172. })
  173. }
  174. }
  175. }
  176. </script>
  177. <style lang="scss" scoped>
  178. /* 边框 */
  179. .day-parting-row {
  180. display: flex;
  181. align-items: center;
  182. flex: 1;
  183. width: 0;
  184. border: 1px solid #dadbde;
  185. border-radius: 4px;
  186. padding: 6px 9px;
  187. height: 35px;
  188. font-size: 14px;
  189. box-sizing: border-box;
  190. }
  191. .item {
  192. position: relative;
  193. padding: 4px 6px 6px;
  194. box-sizing: border-box;
  195. background: #fff;
  196. border-radius: 4px;
  197. margin-bottom: 5px;
  198. .title {
  199. margin-bottom: 6px;
  200. font-weight: bold;
  201. }
  202. .row {
  203. display: flex;
  204. .box {
  205. width: 33.33%;
  206. .content {
  207. display: flex;
  208. margin-top: 6px;
  209. align-items: flex-end;
  210. .value {
  211. width: 0;
  212. flex: 1;
  213. color: #333;
  214. font-size: 16px;
  215. flex-shrink: 0;
  216. font-weight: bold;
  217. }
  218. .unit {
  219. font-size: 10px;
  220. color: #666;
  221. flex-shrink: 0;
  222. max-width: 50px;
  223. }
  224. }
  225. }
  226. }
  227. .dot {
  228. position: absolute;
  229. right: 2px;
  230. top: 2px;
  231. width: 10px;
  232. height: 10px;
  233. background: #D9001B;
  234. border-radius: 50%;
  235. }
  236. }
  237. .change-item {
  238. .row {
  239. display: flex;
  240. align-items: center;
  241. line-height: 35px;
  242. width: 100%;
  243. margin-top: 4px;
  244. .label {
  245. width: 80px;
  246. flex-shrink: 0;
  247. }
  248. }
  249. }
  250. </style>