tabs.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view class="tabs">
  3. <view class="box">
  4. <u-tabs :list="tabList" @click="changeTab" lineColor="#052E5D"
  5. :activeStyle="{ color: '#052E5D', fontWeight: 'bold' }" :inactiveStyle="{
  6. color: '#BBBBBB',
  7. }" lineWidth="36" />
  8. </view>
  9. <view class="content">
  10. <view class="gdsz" v-show="showPage == '关断设置'">
  11. <mpattern ref="关断复位" /><!-- fColor="#000" -->
  12. <mpattern ref="关断设置" /><!-- fColor="#000" -->
  13. <!-- <view class="llcj" v-if="llcj.paramname">
  14. {{ llcj.paramname }}:{{ llcj.lastvalue || ' -- ' }}<text class="unit">{{ llcj.unit || '' }}</text>
  15. </view> -->
  16. <view class="yblc">
  17. <control-item v-show="showPage == '关断设置'" v-for="item in gdszList" :key="item.paramName" :item="item"
  18. @click.native="onClick(item)" />
  19. </view>
  20. </view>
  21. <view class="yblc" v-show="showPage == '报警设置'">
  22. <control-item v-show="showPage == '报警设置'" v-for="item in bjszList" :key="item.paramName" :item="item"
  23. @click.native="onClick(item)" />
  24. </view>
  25. <view class="yblc" v-show="showPage == '仪表量程'">
  26. <control-item v-show="showPage == '仪表量程'" v-for="item in yclbList" :key="item.paramName" :item="item"
  27. @click.native="onClick(item)" />
  28. </view>
  29. <view class="plcsz" v-if="showPage == 'PLC时钟'">
  30. <view class="label">
  31. 年月日时分秒
  32. </view>
  33. <view class="value" v-if="plc.funcname">
  34. {{ plc.params.lastvalue || '--' }}
  35. <view class="plcsz-but" hover-class="navigator-hover" @click="datetimeShow = true">{{
  36. plc.isfeedback ? '待更新' : '更新' }}</view>
  37. <u-datetime-picker :show="datetimeShow" title="PLC时钟" v-model="plclastvalue" @cancel="onCancel"
  38. @confirm="onConfirm" mode="datetime" />
  39. </view>
  40. </view>
  41. </view>
  42. <My_input ref="MyInput" />
  43. </view>
  44. </template>
  45. <script>
  46. import mpattern from "./mpattern";
  47. import { formatTime } from "../../../../utils/getTime";
  48. export default {
  49. name: "tabs",
  50. components: { mpattern },
  51. props: {
  52. control: Object
  53. },
  54. data() {
  55. return {
  56. tabList: [],
  57. showPage: '关断设置',
  58. bjszList: [],
  59. yclbList: [],
  60. gdszList: [],
  61. llcj: {},
  62. plc: {},
  63. datetimeShow: false,
  64. plclastvalue: ""
  65. }
  66. },
  67. watch: {
  68. control: function (newVal) {
  69. if (newVal) {
  70. this.tabList = [{
  71. name: '关断设置',
  72. }, {
  73. name: '报警设置',
  74. }, {
  75. name: '仪表量程'
  76. }, {
  77. name: 'PLC时钟'
  78. }]
  79. try {
  80. this.$refs.关断设置.ctrlModel = this.__proto__.getControlItem(['关断设置'], newVal, { 关断设置: "switch" })[0];
  81. this.$refs.关断复位.ctrlModel = this.__proto__.getControlItem(['关断复位'], newVal, { 关断复位: "switch" })[0];
  82. this.llcj = newVal.params.流量采集;
  83. let nameList = ['关断流量值设定', '关断延时设置']
  84. this.gdszList = this.__proto__.getControlItem(nameList, newVal)
  85. } catch (error) {
  86. console.error("关断设置", error)
  87. }
  88. try {
  89. this.bjszList = this.__proto__.getControlItem(["失压警告", "失压警告设定", "失压报警", "失压报警设定", "超流量警告", "超流量警告设定", "超流量报警", "超流量报警设定"], newVal)
  90. } catch (error) {
  91. console.error("报警设置", error)
  92. }
  93. try {
  94. let nameList = ['压力量程高值', '压力量程低值', '流量量程高值', '流量量程低值',]
  95. this.yclbList = this.__proto__.getControlItem(nameList, newVal)
  96. } catch (error) {
  97. console.error("仪表量程", error)
  98. }
  99. try {
  100. this.plc = this.__proto__.getControlItem(['PLC时钟'], newVal, { Ctrl: "datatime" })[0];
  101. this.plclastvalue = this.plc.params.lastvalue;
  102. } catch (error) {
  103. console.error("PLC时钟", error)
  104. }
  105. }
  106. }
  107. },
  108. methods: {
  109. changeTab(e) {
  110. this.showPage = e.name;
  111. },
  112. onClick(item) {
  113. this.$refs.MyInput.openInput(item)
  114. },
  115. onCancel(e) {
  116. this.datetimeShow = false;
  117. },
  118. async onConfirm(e) {
  119. let date = formatTime(new Date(e.value)),
  120. plc = this.plc;
  121. let res = await this.$Http.setControlItem(plc.w_functionid, {
  122. [`${plc.paramName}`]: date
  123. });
  124. this.datetimeShow = false;
  125. }
  126. },
  127. }
  128. </script>
  129. <style lang="scss" scoped>
  130. .tabs {
  131. position: relative;
  132. box-sizing: border-box;
  133. .box {
  134. background: #fff;
  135. border: 4px;
  136. border-radius: 4px;
  137. box-sizing: border-box;
  138. }
  139. /deep/ .controlItem {
  140. width: 160px !important;
  141. }
  142. /deep/ .uni-scroll-view,
  143. /deep/.u-tabs__wrapper__nav__item {
  144. height: 35px !important;
  145. }
  146. /deep/ .u-tabs__wrapper__nav__item__text {
  147. font-size: 12px !important;
  148. }
  149. .content {
  150. // padding: 0 10px 10px;
  151. padding-bottom: 10px;
  152. box-sizing: border-box;
  153. width: 100%;
  154. .gdsz {
  155. padding-top: 10px;
  156. .llcj {
  157. display: flex;
  158. align-items: center;
  159. font-size: 3.2vw;
  160. .unit {
  161. font-size: 3.2vw;
  162. }
  163. }
  164. }
  165. .yblc {
  166. display: flex;
  167. flex-wrap: wrap;
  168. justify-content: space-between;
  169. }
  170. .plcsz {
  171. font-size: 14px;
  172. display: flex;
  173. align-items: center;
  174. justify-content: space-between;
  175. box-sizing: border-box;
  176. padding: 10px 10px 0;
  177. line-height: 25px;
  178. color: #fff;
  179. .value {
  180. display: flex;
  181. color: #fff;
  182. .plcsz-but {
  183. background-color: #004A92;
  184. font-size: 12px;
  185. padding: 0 6px !important;
  186. margin-right: 6px;
  187. border-radius: 4px;
  188. box-sizing: border-box;
  189. margin-left: 20px;
  190. color: #fff;
  191. font-size: 10px;
  192. height: 22px;
  193. line-height: 22px;
  194. }
  195. }
  196. }
  197. }
  198. }
  199. </style>