indexPage.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <template>
  2. <gui-page :custom-header="true" :is-header-sized="false" :header-class="['gui-theme-background-color']">
  3. <template #gHeader>
  4. <view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
  5. <!-- 使用组件实现返回按钮及返回首页按钮 -->
  6. <text
  7. style="font-size:44rpx;"
  8. class="gui-header-leader-btns gui-color-white font-icons"
  9. @tap="goHome"
  10. >&#xe6c5;</text>
  11. <!-- 导航文本此处也可以是其他自定义内容 -->
  12. <text
  13. class="gui-h4 gui-blod gui-flex1 gui-text-center gui-color-white gui-ellipsis gui-primary-text"
  14. >点胶管理</text>
  15. <!-- 此处加一个右侧展位元素与左侧同宽,实现标题居中 -->
  16. <!-- 实际宽度请根据自己情况设置 -->
  17. <view style="width:40px;" />
  18. </view>
  19. </template>
  20. <template #gBody>
  21. <uni-notice-bar
  22. v-if="machineObject.code"
  23. style="margin-top: 85px;padding: 4px 10px;"
  24. show-icon
  25. scrollable
  26. :text="'当前运行设备: '+ machineObject.name +' 机器编码: ' + machineObject.code"
  27. />
  28. <view class="glue-manage">
  29. <view class="bind-button">
  30. <view v-if="!machineObject.code" class="scan-button" @click="handleBindMachine">
  31. <text class="font-icons">&#xe6a8;</text>
  32. 绑定机器
  33. </view>
  34. </view>
  35. <view v-if="machineObject.code" class="description">
  36. <text class="line-text">设备模具</text>
  37. <view class="tag-operation">
  38. <view class="tag-skyblue" @click="handleMouldLoad"><text class="font-icons">&#xe6b7;</text>模具上料
  39. </view>
  40. <view class="tag-skyblue" @click="handleBindMachine"><text
  41. class="font-icons"
  42. >&#xe6a8;</text>更换设备</view>
  43. </view>
  44. </view>
  45. <view class="machine-mould-panel">
  46. <view v-if="machineObject.code">
  47. <view v-for="(item, key) in machineMouldList" :key="key">
  48. <uni-swipe-action>
  49. <!-- 基础用法 -->
  50. <uni-swipe-action-item
  51. :right-options="options"
  52. :left-options="options"
  53. @click="onClick(item)"
  54. >
  55. <view class="machine-details">
  56. <view>
  57. <text
  58. class="font-icons-online"
  59. :style="computedStateLight(item)"
  60. >{{ item.status == "0"?"&#xe6bc;":item.status=="1"?"&#xe6cc;":"&#xe6d0;" }}</text>
  61. <view class="text-content">
  62. <view class="content-title">{{ item.code }}</view>
  63. <view class="content">{{ item.name }}</view>
  64. </view>
  65. </view>
  66. <view class="effective-time">
  67. <view>
  68. 过期还剩
  69. <text :style="computedStateLight(item)">{{ item.effectiveTime }}</text>
  70. </view>
  71. </view>
  72. </view>
  73. </uni-swipe-action-item>
  74. </uni-swipe-action>
  75. </view>
  76. </view>
  77. </view>
  78. <view v-if="machineObject.code" class="bind-button" style="margin: 10px 0;">
  79. <view class="scan-button" @click="handleScanSNCode">
  80. <text class="font-icons">&#xe6a8;</text>
  81. 扫描SN码
  82. </view>
  83. </view>
  84. <view class="machine-panel">
  85. <view v-for="(item, key) in SNCodeList" :key="key" class="card-list-flexbox">
  86. <view class="card-list-item">
  87. <text class="text-1 gui-color-gray">{{ item.materialCode }}</text>
  88. </view>
  89. <view class="card-list-item">
  90. <text class="text-1 gui-color-gray">物料名称</text>
  91. <text class="text-2 gui-color-gray">{{ item.materialName }}</text>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. </template>
  97. </gui-page>
  98. </template>
  99. <script>
  100. import {
  101. computed,
  102. defineComponent,
  103. onMounted,
  104. ref
  105. } from 'vue'
  106. export default defineComponent({
  107. setup() {
  108. // 绑定的机器信息
  109. const machineObject = ref({
  110. code: '',
  111. name: ''
  112. })
  113. const options = ref([{
  114. text: '卸料',
  115. style: {
  116. backgroundColor: '#dd524d'
  117. }
  118. }])
  119. // 设备模具
  120. const machineMouldList = ref([{
  121. code: 'PCL983992100',
  122. name: '胶水',
  123. effectiveTime: 45,
  124. status: '0'
  125. },
  126. {
  127. code: 'PCL983992101',
  128. name: '模切刀具',
  129. effectiveTime: 100,
  130. status: '2'
  131. }
  132. ])
  133. const SNCodeList = ref([])
  134. const computedStateLight = computed(() => {
  135. return item => {
  136. switch (item.status) {
  137. case '0':
  138. return 'color: #85ce61;'
  139. case '1':
  140. return 'color: rgb(255 172 70);'
  141. case '2':
  142. return 'color: #ee0a25;'
  143. }
  144. }
  145. })
  146. onMounted(() => {
  147. const machineData = uni.getStorageSync('machineData')
  148. if (Object.keys(machineData).length !== 0) {
  149. Object.assign(machineObject.value, machineData)
  150. }
  151. })
  152. const goHome = function() {
  153. uni.$goHome()
  154. }
  155. // 卸料
  156. const onClick = function(opt) {
  157. const fdIndex = machineMouldList.value.findIndex(item => item.code === opt.code)
  158. machineMouldList.value.splice(fdIndex, 1)
  159. }
  160. // 模具上料
  161. const handleMouldLoad = function() {
  162. machineMouldList.value.push({
  163. code: 'PCL983992102',
  164. name: '钻头',
  165. effectiveTime: 32,
  166. status: Math.round(Math.random() * 2).toString()
  167. }, {
  168. code: 'PCL983992103',
  169. name: '托盘',
  170. effectiveTime: 75,
  171. status: Math.round(Math.random() * 2).toString()
  172. })
  173. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  174. mpaasScanModule.mpaasScan({
  175. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  176. 'scanType': ['qrCode', 'barCode'],
  177. // 是否隐藏相册,默认false不隐藏
  178. 'hideAlbum': false
  179. },
  180. (ret) => {
  181. if (ret.resp_code === 1000) {
  182. machineMouldList.value.push({
  183. code: 'PCL983992102',
  184. name: '钻头',
  185. effectiveTime: 32,
  186. status: Math.round(Math.random() * 2).toString()
  187. }, {
  188. code: 'PCL983992103',
  189. name: '托盘',
  190. effectiveTime: 75,
  191. status: Math.round(Math.random() * 2).toString()
  192. })
  193. }
  194. })
  195. }
  196. // 绑定设备/更换设备
  197. const handleBindMachine = function() {
  198. machineObject.value.code = 'C911029' + Math.round(Math.random() * 10000)
  199. machineObject.value.name = '点胶机' + Math.round(Math.random() * 10000)
  200. uni.setStorageSync('machineData', JSON.parse(JSON.stringify(machineObject.value)))
  201. // const mpaasScanModule = uni.requireNativePlugin("Mpaas-Scan-Module")
  202. // mpaasScanModule.mpaasScan({
  203. // // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  204. // 'scanType': ['qrCode', 'barCode'],
  205. // // 是否隐藏相册,默认false不隐藏
  206. // 'hideAlbum': false
  207. // },
  208. // (ret) => {
  209. // if (ret.resp_code === 1000) {
  210. // machineObject.value.code = "C91102933331";
  211. // machineObject.value.name = "点胶机09111";
  212. // }
  213. // })
  214. }
  215. // 扫描SN码
  216. const handleScanSNCode = function() {
  217. SNCodeList.value.push({
  218. materialCode: 'PCL9839921' + Math.round(Math.random() * 100),
  219. materialName: '胶水' + Math.round(Math.random() * 999)
  220. })
  221. const mpaasScanModule = uni.requireNativePlugin('Mpaas-Scan-Module')
  222. mpaasScanModule.mpaasScan({
  223. // 扫码识别类型,参数可多选,qrCode、barCode,不设置,默认识别所有
  224. 'scanType': ['qrCode', 'barCode'],
  225. // 是否隐藏相册,默认false不隐藏
  226. 'hideAlbum': false
  227. },
  228. (ret) => {
  229. if (ret.resp_code === 1000) {
  230. SNCodeList.value.push({
  231. materialCode: 'PCL9839921' + Math.round(Math.random() * 100),
  232. materialName: '胶水' + Math.round(Math.random() * 999)
  233. })
  234. // uni.$reqGet("splitOrMergeScanMaterial", {
  235. // qrCode: ret.resp_result
  236. // })
  237. // .then(({
  238. // data
  239. // }) => {
  240. // })
  241. }
  242. })
  243. }
  244. return {
  245. goHome,
  246. options,
  247. onClick,
  248. SNCodeList,
  249. machineObject,
  250. machineMouldList,
  251. handleBindMachine,
  252. computedStateLight,
  253. handleMouldLoad,
  254. handleScanSNCode
  255. }
  256. }
  257. })
  258. </script>
  259. <style lang="scss" scoped>
  260. .gui-header-leader-btns {
  261. color: black;
  262. font-size: 24px !important;
  263. margin-left: 24rpx;
  264. }
  265. .gui-sbody {
  266. background-color: rgba(234, 239, 242, 1);
  267. }
  268. .glue-manage {
  269. width: 100vw;
  270. height: 100vh;
  271. top: 120px;
  272. position: fixed;
  273. .description {
  274. height: 40px;
  275. line-height: 40px;
  276. display: flex;
  277. justify-content: space-between;
  278. align-items: center;
  279. font-weight: bold;
  280. background-color: white;
  281. .tag-operation {
  282. height: 40px;
  283. display: flex;
  284. align-items: center;
  285. }
  286. .line-text {
  287. display: flex;
  288. align-items: center;
  289. }
  290. .line-text::before {
  291. content: "";
  292. display: inline-block;
  293. width: 4px;
  294. height: 20px;
  295. border-radius: 4px;
  296. margin: 0 4px;
  297. background-color: skyblue;
  298. }
  299. }
  300. .bind-button {
  301. display: flex;
  302. justify-content: center;
  303. .scan-button {
  304. width: 40vw;
  305. min-width: 50px;
  306. height: 35px;
  307. display: flex;
  308. justify-content: center;
  309. align-items: center;
  310. color: white;
  311. background-color: rgba(0, 160, 233, 1);
  312. border-radius: 6px;
  313. box-shadow: 2px 2px 3px 1px rgba(0, 156, 223, 1.0);
  314. }
  315. }
  316. .machine-panel,
  317. .machine-mould-panel {
  318. width: 100%;
  319. display: flex;
  320. flex-direction: column;
  321. overflow-y: scroll;
  322. .machine-details {
  323. width: calc(100vw - 20px);
  324. height: 25px;
  325. padding: 10px;
  326. margin-top: 2px;
  327. display: flex;
  328. justify-content: space-between;
  329. align-items: center;
  330. background-color: white;
  331. >uni-view:nth-of-type(1) {
  332. flex: 3;
  333. display: flex;
  334. font-size: 12px;
  335. .font-icons,
  336. .font-icons-online {
  337. font-size: 26px;
  338. margin-right: 8px;
  339. }
  340. .text-content {
  341. .content-title {
  342. font-weight: bold;
  343. }
  344. }
  345. }
  346. .effective-time {
  347. flex: 2;
  348. font-size: 12px;
  349. text-align: right;
  350. }
  351. }
  352. .machine-details:nth-of-type(1) {
  353. margin-top: 0;
  354. }
  355. }
  356. .machine-mould-panel {
  357. height: 90px;
  358. min-height: 90px;
  359. }
  360. .machine-panel {
  361. height: calc((100vh - 45px) * 0.6);
  362. }
  363. }
  364. /* 针对适配的设备重新写一套样式 */
  365. /* height >= 520px */
  366. @media screen and (min-height: 520px) {
  367. .glue-manage {
  368. .machine-panel {
  369. height: calc((100vh - 45px) * 0.65);
  370. }
  371. }
  372. }
  373. /* height <= 520px */
  374. @media screen and (max-height: 530px) {
  375. .glue-manage {
  376. .machine-panel {
  377. height: 200px;
  378. }
  379. }
  380. }
  381. .card-list-flexbox {
  382. display: flex;
  383. flex-direction: row;
  384. align-items: center;
  385. flex-wrap: wrap;
  386. margin: 0 2px 3px 2px;
  387. .card-list-item,
  388. .card-list-item-operation {
  389. width: 750rpx;
  390. height: 35px;
  391. margin-bottom: 3rpx;
  392. display: flex;
  393. flex-direction: row;
  394. align-items: center;
  395. justify-content: space-between;
  396. background-color: #fff;
  397. uni-text {
  398. font-size: 14px;
  399. height: 50rpx;
  400. text-align: left;
  401. padding: 0 4px;
  402. display: flex;
  403. flex-direction: row;
  404. align-items: center;
  405. }
  406. .text-1 {
  407. flex: 1;
  408. height: 35px;
  409. justify-content: flex-start;
  410. }
  411. .text-2 {
  412. flex: 3;
  413. height: 35px;
  414. justify-content: flex-end;
  415. margin-right: 4px;
  416. padding: 2px 6px;
  417. }
  418. }
  419. .card-list-item:nth-of-type(1) {
  420. .text-1 {
  421. font-weight: bold;
  422. color: black !important;
  423. }
  424. .text-1::before {
  425. content: "";
  426. width: 4px;
  427. height: 20px;
  428. border-radius: 4px;
  429. margin-right: 4px;
  430. background-color: skyblue;
  431. }
  432. }
  433. }
  434. .tag-skyblue {
  435. padding: 0 4px;
  436. margin: 0 4px;
  437. border-radius: 5px;
  438. }
  439. .tag-skyblue {
  440. border: 1px solid skyblue;
  441. color: skyblue;
  442. height: 24px;
  443. line-height: 24px;
  444. font-size: 12px;
  445. }
  446. </style>