index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <template>
  2. <div class="payment-settings">
  3. <s-header :name="$t('remote.C30')" :noback="false" />
  4. <!-- 设备名称标题 -->
  5. <div class="device-header">
  6. <div class="vertical-indicator"></div>
  7. <h3 class="device-name">
  8. {{ $t("device.equipmentName") }}:{{ deviceName }}
  9. </h3>
  10. </div>
  11. <!-- 果酱抽取卡片 -->
  12. <div class="settings-card">
  13. <div v-for="jam in jams" :key="jam.id" class="jam-item">
  14. <!-- 图片和名称行 -->
  15. <div class="jam-main-row">
  16. <van-image
  17. :src="showSugerPhoto(jam)"
  18. width="70"
  19. height="70"
  20. radius="8"
  21. fit="cover"
  22. class="jam-image"
  23. />
  24. <h3 class="jam-title">{{ jam.name }}</h3>
  25. </div>
  26. <!-- 操作按钮组 -->
  27. <div class="jam-actions">
  28. <van-button
  29. type="primary"
  30. size="small"
  31. class="action-btn"
  32. @click="handleExtract(jam.no, 1)"
  33. >
  34. {{ $t("jam.forward") }}
  35. </van-button>
  36. <van-button
  37. type="warning"
  38. size="small"
  39. class="action-btn"
  40. @click="handleExtract(jam.no, 2)"
  41. >
  42. {{ $t("jam.reverse") }}
  43. </van-button>
  44. <van-button
  45. type="danger"
  46. size="small"
  47. class="action-btn"
  48. @click="handleExtract(jam.no, 0)"
  49. >
  50. {{ $t("jam.stop") }}
  51. </van-button>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </template>
  57. <script>
  58. import sHeader from "@/components/SimpleHeader";
  59. import { selectProducts, smokeJam } from "@/service/device/index";
  60. import { useRoute } from "vue-router";
  61. import { ref } from "vue";
  62. import { useI18n } from "vue-i18n";
  63. import { onMounted } from "vue";
  64. import { showConfirmDialog, showFailToast, showSuccessToast } from "vant";
  65. export default {
  66. components: { sHeader },
  67. setup() {
  68. const { t } = useI18n();
  69. const route = useRoute();
  70. const deviceId = ref(route.query.deviceId);
  71. const deviceName = ref(route.query.name);
  72. const jams = ref([]);
  73. // 获取商品列表
  74. const getList = () => {
  75. selectProducts({
  76. equipmentId: deviceId.value,
  77. }).then((res) => {
  78. const { data } = res.data;
  79. if (data) {
  80. data.forEach((item) => {
  81. if (item.no.includes("J")) {
  82. jams.value.push(item);
  83. }
  84. });
  85. }
  86. });
  87. };
  88. // 商品图片路径处理
  89. const showSugerPhoto = (row) => {
  90. let imgId = row.no;
  91. if (imgId) {
  92. return require(`../../../assets/order/spunSugar/goods/${imgId}.png`);
  93. }
  94. return imgId;
  95. };
  96. // 果酱抽取
  97. const handleExtract = (no, status) => {
  98. showConfirmDialog({
  99. title: t("device.operationConfirmation"),
  100. message: t("device.pleaseConfirmAgainWhetherToOperate"),
  101. })
  102. .then(async () => {
  103. const { data } = await smokeJam({
  104. equipmentId: deviceId.value,
  105. productNo: no,
  106. status: status,
  107. });
  108. if (data.code === "00000") {
  109. showSuccessToast(t("device.Succeed"));
  110. } else {
  111. showFailToast(t("device.Failed"));
  112. }
  113. })
  114. .catch(() => {
  115. // on cancel
  116. showFailToast(t("device.Failed"));
  117. });
  118. };
  119. onMounted(async () => {
  120. getList();
  121. });
  122. return {
  123. deviceName,
  124. showSugerPhoto,
  125. handleExtract,
  126. jams,
  127. };
  128. },
  129. };
  130. </script>
  131. <style lang="less" scoped>
  132. @primary-color: #4dc294;
  133. @warning-color: #ff976a;
  134. @danger-color: #ee0a24;
  135. .payment-settings {
  136. --payment-bg: #ffffff;
  137. --border-color: #ebedf0;
  138. --active-color: #2c87c8;
  139. --text-primary: #323233;
  140. --text-secondary: #969799;
  141. background: #f7f8fa;
  142. min-height: 100vh;
  143. .device-header {
  144. display: flex;
  145. align-items: center;
  146. padding: 12px 15px;
  147. background: #fff;
  148. margin: 12px 16px;
  149. border-radius: 8px;
  150. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  151. .vertical-indicator {
  152. width: 4px;
  153. height: 15px;
  154. background: var(--active-color, #2c87c8);
  155. border-radius: 2px;
  156. margin-right: 10px;
  157. }
  158. .device-name {
  159. margin: 0;
  160. font-size: 15px;
  161. color: #404d74;
  162. font-weight: 550;
  163. // 长名称处理
  164. overflow: hidden;
  165. text-overflow: ellipsis;
  166. white-space: nowrap;
  167. max-width: 70vw;
  168. }
  169. }
  170. .settings-card {
  171. padding: 16px;
  172. margin: 12px 16px;
  173. background: #fff;
  174. border-radius: 12px;
  175. box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  176. }
  177. .jam-item {
  178. padding: 16px 0;
  179. border-bottom: 1px solid #f5f5f5;
  180. &:last-child {
  181. border-bottom: none;
  182. }
  183. }
  184. .jam-main-row {
  185. display: flex;
  186. align-items: center;
  187. gap: 16px;
  188. margin-bottom: 12px;
  189. }
  190. .jam-image {
  191. border: 1px solid #eee;
  192. flex-shrink: 0;
  193. }
  194. .jam-title {
  195. font-size: 16px;
  196. color: #333;
  197. word-break: break-word;
  198. line-height: 1.4;
  199. }
  200. .jam-actions {
  201. display: flex;
  202. justify-content: center;
  203. gap: 12px;
  204. flex-wrap: wrap;
  205. .action-btn {
  206. min-width: 80px;
  207. border-radius: 20px;
  208. font-size: 13px;
  209. padding: 8px 16px;
  210. &--primary {
  211. background: @primary-color;
  212. border-color: @primary-color;
  213. }
  214. &--warning {
  215. background: @warning-color;
  216. border-color: @warning-color;
  217. }
  218. &--danger {
  219. background: @danger-color;
  220. border-color: @danger-color;
  221. }
  222. }
  223. }
  224. @media (max-width: 480px) {
  225. .jam-main-row {
  226. gap: 12px;
  227. }
  228. .jam-image {
  229. width: 50px;
  230. height: 50px;
  231. }
  232. .jam-title {
  233. font-size: 14px;
  234. }
  235. .jam-actions {
  236. gap: 8px;
  237. .action-btn {
  238. min-width: 70px;
  239. font-size: 12px;
  240. padding: 6px 12px;
  241. }
  242. }
  243. }
  244. }
  245. </style>