division.vue 8.6 KB

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