tabs.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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, { 失压警告: "switch", 失压报警: "switch", 超流量警告: "switch", 超流量报警: "switch" })
  90. console.log(" this.bjszList", this.bjszList)
  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. let date = { 年: null, 月: null, 日: null, 时: null, 分: null, 秒: null }
  103. for (const key in date) {
  104. let lastvalue = newVal.params[key].lastvalue
  105. date[key] = lastvalue > 10 ? lastvalue : "0" + lastvalue
  106. };
  107. this.plclastvalue = `${date.年}-${date.月}-${date.日} ${date.时}:${date.分}:${date.秒}`;
  108. this.plc.params.lastvalue = this.plclastvalue;
  109. } catch (error) {
  110. console.error("PLC时钟", error)
  111. }
  112. }
  113. }
  114. },
  115. methods: {
  116. changeTab(e) {
  117. this.showPage = e.name;
  118. },
  119. onClick(item) {
  120. console.log(item)
  121. this.$refs.MyInput.openInput(item)
  122. },
  123. onCancel(e) {
  124. this.datetimeShow = false;
  125. },
  126. async onConfirm(e) {
  127. let date = formatTime(new Date(e.value)).split(" "),
  128. plc = this.plc;
  129. date = date[0].split("-").concat(date[1].split(":"))
  130. let res = await this.$Http.setControlItem(plc.w_functionid, {
  131. "年": date[0],
  132. "月": date[1],
  133. "日": date[2],
  134. "时": date[3],
  135. "分": date[4],
  136. "秒": date[5],
  137. "同步时间": 0
  138. });
  139. this.datetimeShow = false;
  140. }
  141. },
  142. }
  143. </script>
  144. <style lang="scss" scoped>
  145. .tabs {
  146. position: relative;
  147. box-sizing: border-box;
  148. .box {
  149. background: #fff;
  150. border: 4px;
  151. border-radius: 4px;
  152. box-sizing: border-box;
  153. }
  154. /deep/ .controlItem {
  155. width: 160px !important;
  156. }
  157. /deep/ .uni-scroll-view,
  158. /deep/.u-tabs__wrapper__nav__item {
  159. height: 35px !important;
  160. }
  161. /deep/ .u-tabs__wrapper__nav__item__text {
  162. font-size: 12px !important;
  163. }
  164. .content {
  165. // padding: 0 10px 10px;
  166. padding-bottom: 10px;
  167. box-sizing: border-box;
  168. width: 100%;
  169. .gdsz {
  170. padding-top: 10px;
  171. .llcj {
  172. display: flex;
  173. align-items: center;
  174. font-size: 3.2vw;
  175. .unit {
  176. font-size: 3.2vw;
  177. }
  178. }
  179. }
  180. .yblc {
  181. display: flex;
  182. flex-wrap: wrap;
  183. justify-content: space-between;
  184. }
  185. .plcsz {
  186. font-size: 14px;
  187. display: flex;
  188. align-items: center;
  189. justify-content: space-between;
  190. box-sizing: border-box;
  191. padding: 10px 10px 0;
  192. line-height: 25px;
  193. color: #fff;
  194. .value {
  195. display: flex;
  196. color: #fff;
  197. .plcsz-but {
  198. background-color: #004A92;
  199. font-size: 12px;
  200. padding: 0 6px !important;
  201. margin-right: 6px;
  202. border-radius: 4px;
  203. box-sizing: border-box;
  204. margin-left: 20px;
  205. color: #fff;
  206. font-size: 10px;
  207. height: 22px;
  208. line-height: 22px;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. </style>