tabs.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  1. <template>
  2. <view class="tabs">
  3. <view class="box">
  4. <u-tabs
  5. :list="tabList"
  6. @click="changeTab"
  7. lineColor="#052E5D"
  8. :activeStyle="{ color: '#052E5D', fontWeight: 'bold' }"
  9. :inactiveStyle="{
  10. color: '#BBBBBB',
  11. }"
  12. lineWidth="36"
  13. />
  14. </view>
  15. <view class="content">
  16. <view class="yblc" v-show="showPage == '报警设置'">
  17. <control-item
  18. v-show="showPage == '报警设置'"
  19. v-for="item in bjszList"
  20. :key="item.w_functionid"
  21. :item="item"
  22. @click.native="onClick(item)"
  23. />
  24. </view>
  25. <view class="gdsz" v-show="showPage == 'PID设置'">
  26. <view class="plcsz" style="margin-bottom: 4px">
  27. <view class="label">PID调节</view>
  28. <view class="value">
  29. {{ PICTJ || "--" }}
  30. </view>
  31. </view>
  32. <view class="yblc">
  33. <control-item
  34. v-show="showPage == 'PID设置'"
  35. v-for="item in gdszList"
  36. :key="item.w_functionid"
  37. :item="item"
  38. @click.native="onClick(item)"
  39. />
  40. </view>
  41. </view>
  42. <view class="yblc" v-show="showPage == '仪表量程'">
  43. <control-item
  44. v-show="showPage == '仪表量程'"
  45. v-for="item in yclbList"
  46. :key="item.w_functionid"
  47. :item="item"
  48. @click.native="onClick(item)"
  49. />
  50. </view>
  51. <block v-if="showPage == 'PLC时钟'">
  52. <view class="plcsz">
  53. <view class="label"> 年月日时分秒 </view>
  54. <view class="value" v-if="plc.funcname">
  55. {{ plc.params.lastvalue || "--" }}
  56. <view
  57. class="plcsz-but"
  58. hover-class="navigator-hover"
  59. @click="datetimeShow = true"
  60. >{{ plc.isfeedback ? "待更新" : "更新" }}</view
  61. >
  62. <u-datetime-picker
  63. :show="datetimeShow"
  64. title="PLC时钟"
  65. v-model="plclastvalue"
  66. @cancel="onCancel"
  67. @confirm="onConfirm"
  68. mode="datetime"
  69. />
  70. </view>
  71. </view>
  72. <view class="plcsz">
  73. <view class="label"> 同步时间 </view>
  74. <view class="value" v-if="TBSJ.funcname">
  75. {{ TBSJ.params.options[0].label || "--" }}
  76. <view
  77. class="plcsz-but"
  78. hover-class="navigator-hover"
  79. @click="changeTBSJ"
  80. >{{ TBSJ.isfeedback ? "待更新" : "更新" }}</view
  81. >
  82. </view>
  83. </view>
  84. </block>
  85. </view>
  86. <My_input ref="MyInput" />
  87. </view>
  88. </template>
  89. <script>
  90. import mpattern from "./mpattern";
  91. import { formatTime } from "../../../../utils/getTime";
  92. export default {
  93. name: "tabs",
  94. components: { mpattern },
  95. props: {
  96. control: Object,
  97. },
  98. data() {
  99. return {
  100. tabList: [],
  101. showPage: "报警设置",
  102. bjszList: [],
  103. yclbList: [],
  104. gdszList: [],
  105. PICTJ: "",
  106. llcj: {},
  107. plc: {},
  108. TBSJ: {},
  109. datetimeShow: false,
  110. plclastvalue: "",
  111. };
  112. },
  113. watch: {
  114. control: function (newVal) {
  115. if (newVal) {
  116. this.tabList = [
  117. {
  118. name: "报警设置",
  119. },
  120. {
  121. name: "仪表量程",
  122. },
  123. {
  124. name: "PLC时钟",
  125. },
  126. {
  127. name: "PID设置",
  128. },
  129. ];
  130. try {
  131. this.bjszList = this.__proto__.getControlItem(
  132. ["失压警告", "失压警告设定", "失压报警", "失压报警设定"],
  133. newVal
  134. );
  135. let s018 = newVal.params.S018;
  136. this.PICTJ = s018.options.find(
  137. (v) => v.value == s018.lastvalue
  138. ).label;
  139. } catch (error) {
  140. console.error("报警设置", error);
  141. }
  142. try {
  143. let nameList = ["压力量程高值", "压力量程低值"];
  144. this.yclbList = this.__proto__.getControlItem(nameList, newVal);
  145. } catch (error) {
  146. console.error("仪表量程", error);
  147. }
  148. try {
  149. this.plc = this.__proto__.getControlItem(["PLC时钟"], newVal, {
  150. Ctrl: "datatime",
  151. })[0];
  152. let date = {
  153. C006: null,
  154. C007: null,
  155. C008: null,
  156. C009: null,
  157. C010: null,
  158. C011: null,
  159. };
  160. for (const key in date) {
  161. let lastvalue = newVal.params[key].lastvalue;
  162. date[key] = lastvalue > 10 ? lastvalue : "0" + (lastvalue - 0);
  163. }
  164. this.plclastvalue = `${date.C006}-${date.C007}-${date.C008} ${date.C009}:${date.C010}:${date.C011}`;
  165. this.plc.params.lastvalue = this.plclastvalue;
  166. this.TBSJ = this.__proto__.getControlItem(["同步时间"], newVal)[0];
  167. console.log("TBSJ", this.TBSJ);
  168. } catch (error) {
  169. console.error("PLC时钟", error);
  170. }
  171. try {
  172. let nameList = ["P设定", "I设定", "D设定"];
  173. this.gdszList = this.__proto__.getControlItem(nameList, newVal);
  174. } catch (error) {
  175. console.error("PID设置", error);
  176. }
  177. }
  178. },
  179. },
  180. methods: {
  181. changeTBSJ() {
  182. let that = this;
  183. uni.showModal({
  184. title: "提示",
  185. content: "确定更新数据吗?",
  186. success: function ({ confirm }) {
  187. if (confirm)
  188. that.$refs.MyInput.submit(
  189. that.TBSJ.w_functionid,
  190. that.TBSJ.paramName
  191. );
  192. },
  193. });
  194. },
  195. changeTab(e) {
  196. this.showPage = e.name;
  197. },
  198. onClick(item) {
  199. console.log("修改", item);
  200. this.$refs.MyInput.openInput(item);
  201. },
  202. onCancel(e) {
  203. this.datetimeShow = false;
  204. },
  205. async onConfirm(e) {
  206. let date = formatTime(new Date(e.value)).split(" "),
  207. plc = this.plc;
  208. date = date[0].split("-").concat(date[1].split(":"));
  209. let res = await this.$Http.setControlItem(plc.w_functionid, {
  210. C006: date[0],
  211. C007: date[1],
  212. C008: date[2],
  213. C009: date[3],
  214. C010: date[4],
  215. C011: date[5],
  216. });
  217. this.datetimeShow = false;
  218. },
  219. },
  220. };
  221. </script>
  222. <style lang="scss" scoped>
  223. .tabs {
  224. position: relative;
  225. box-sizing: border-box;
  226. .box {
  227. background: #fff;
  228. border: 4px;
  229. border-radius: 4px;
  230. box-sizing: border-box;
  231. }
  232. /deep/ .controlItem {
  233. width: 160px !important;
  234. }
  235. /deep/ .uni-scroll-view,
  236. /deep/.u-tabs__wrapper__nav__item {
  237. height: 35px !important;
  238. }
  239. /deep/ .u-tabs__wrapper__nav__item__text {
  240. font-size: 12px !important;
  241. }
  242. .content {
  243. // padding: 0 10px 10px;
  244. padding-bottom: 10px;
  245. box-sizing: border-box;
  246. width: 100%;
  247. .gdsz {
  248. .llcj {
  249. display: flex;
  250. align-items: center;
  251. font-size: 3.2vw;
  252. .unit {
  253. font-size: 3.2vw;
  254. }
  255. }
  256. }
  257. .yblc {
  258. display: flex;
  259. flex-wrap: wrap;
  260. justify-content: space-between;
  261. }
  262. .plcsz {
  263. font-size: 14px;
  264. display: flex;
  265. align-items: center;
  266. justify-content: space-between;
  267. box-sizing: border-box;
  268. padding: 10px 10px 0;
  269. line-height: 25px;
  270. color: #fff;
  271. .value {
  272. display: flex;
  273. color: #fff;
  274. .plcsz-but {
  275. background-color: #004a92;
  276. font-size: 12px;
  277. padding: 0 6px !important;
  278. margin-right: 6px;
  279. border-radius: 4px;
  280. box-sizing: border-box;
  281. margin-left: 20px;
  282. color: #fff;
  283. font-size: 10px;
  284. height: 22px;
  285. line-height: 22px;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. </style>