tabs.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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. let model = null;
  47. import mpattern from "./mpattern";
  48. import { formatTime } from "../../../../utils/getTime";
  49. export default {
  50. name: "tabs",
  51. components: { mpattern },
  52. props: {
  53. control: Object
  54. },
  55. data() {
  56. return {
  57. tabList: [],
  58. showPage: '关断设置',
  59. bjszList: [],
  60. yclbList: [],
  61. gdszList: [],
  62. llcj: {},
  63. plc: {},
  64. datetimeShow: false,
  65. plclastvalue: ""
  66. }
  67. },
  68. watch: {
  69. control: function (newVal) {
  70. if (newVal) {
  71. this.tabList = [{
  72. name: '关断设置',
  73. }, {
  74. name: '报警设置',
  75. }, {
  76. name: '仪表量程'
  77. }, {
  78. name: 'PLC时钟'
  79. }]
  80. try {
  81. this.$refs.关断设置.ctrlModel = this.__proto__.getControlItem(['关断设置'], newVal)[0];
  82. this.$refs.关断复位.ctrlModel = this.__proto__.getControlItem(['关断复位'], newVal, { 关断复位: "switch" })[0];
  83. this.llcj = newVal.params.流量采集;
  84. let nameList = ['关断流量设置', '关断延时设置']
  85. this.gdszList = this.__proto__.getControlItem(nameList, newVal)
  86. } catch (error) {
  87. console.error("关断设置", error)
  88. }
  89. try {
  90. this.bjszList = this.__proto__.getControlItem(["失压警告", "失压警告设定", "失压报警", "失压报警设定", "超流量警告", "超流量警告设定", "超流量报警", "超流量报警设定"], newVal)
  91. } catch (error) {
  92. console.error("报警设置", error)
  93. }
  94. try {
  95. let nameList = ['压力量程高值', '压力量程低值', '流量量程高值', '流量量程低值',]
  96. this.yclbList = this.__proto__.getControlItem(nameList, newVal)
  97. } catch (error) {
  98. console.error("仪表量程", error)
  99. }
  100. try {
  101. this.plc = this.__proto__.getControlItem(['PLC时钟'], newVal, { Ctrl: "datatime" })[0];
  102. this.plclastvalue = this.plc.params.lastvalue;
  103. } catch (error) {
  104. console.error("PLC时钟", error)
  105. }
  106. }
  107. }
  108. },
  109. methods: {
  110. changeTab(e) {
  111. this.showPage = e.name;
  112. },
  113. onClick(item) {
  114. if (!model) model = this.$refs.MyInput;
  115. model.openInput(item)
  116. },
  117. onCancel(e) {
  118. this.datetimeShow = false;
  119. },
  120. async onConfirm(e) {
  121. let date = formatTime(new Date(e.value)),
  122. plc = this.plc;
  123. let res = await this.$Http.setControlItem(plc.w_functionid, {
  124. [`${plc.paramName}`]: date
  125. });
  126. this.datetimeShow = false;
  127. }
  128. },
  129. }
  130. </script>
  131. <style lang="scss" scoped>
  132. .tabs {
  133. position: relative;
  134. box-sizing: border-box;
  135. .box {
  136. background: #fff;
  137. border: 4px;
  138. border-radius: 4px;
  139. box-sizing: border-box;
  140. }
  141. /deep/ .controlItem {
  142. width: 160px !important;
  143. }
  144. /deep/ .uni-scroll-view,
  145. /deep/.u-tabs__wrapper__nav__item {
  146. height: 35px !important;
  147. }
  148. /deep/ .u-tabs__wrapper__nav__item__text {
  149. font-size: 12px !important;
  150. }
  151. .content {
  152. // padding: 0 10px 10px;
  153. padding-bottom: 10px;
  154. box-sizing: border-box;
  155. width: 100%;
  156. .gdsz {
  157. padding-top: 10px;
  158. .llcj {
  159. display: flex;
  160. align-items: center;
  161. font-size: 3.2vw;
  162. .unit {
  163. font-size: 3.2vw;
  164. }
  165. }
  166. }
  167. .yblc {
  168. display: flex;
  169. flex-wrap: wrap;
  170. justify-content: space-between;
  171. }
  172. .plcsz {
  173. font-size: 14px;
  174. display: flex;
  175. align-items: center;
  176. justify-content: space-between;
  177. box-sizing: border-box;
  178. padding: 10px 10px 0;
  179. line-height: 25px;
  180. color: #fff;
  181. .value {
  182. display: flex;
  183. color: #fff;
  184. .plcsz-but {
  185. background-color: #004A92;
  186. font-size: 12px;
  187. padding: 0 6px !important;
  188. margin-right: 6px;
  189. border-radius: 4px;
  190. box-sizing: border-box;
  191. margin-left: 20px;
  192. color: #fff;
  193. font-size: 10px;
  194. height: 22px;
  195. line-height: 22px;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. </style>