dosugar.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view>
  3. <view class="search">
  4. <view class="search-title">
  5. {{$t('dosugar.equipmentClientID')}}
  6. </view>
  7. <view class="search-input">
  8. <input type="text" :placeholder="$t('dosugar.placeholder')" v-model="searchClientId" />
  9. </view>
  10. <view class="search-button">
  11. <button type="primary" size="mini" class="" @click="search()">
  12. <p class="">{{$t('dosugar.search')}}</P>
  13. </button>
  14. </view>
  15. </view>
  16. <view class="td-right">
  17. <view class="uni-list">
  18. <view class="uni-list-cell">
  19. <view class="uni-list-cell-left">
  20. {{$t('dosugar.chooseEquipment')}}
  21. </view>
  22. <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
  23. <picker @change="changeEquipment" :value="index" :range="equipmentNameList">
  24. <view class="uni-input">{{equipmentNameList[index]}}</view>
  25. </picker>
  26. </view>
  27. </view>
  28. <view class="uni-list-cell">
  29. <view class="uni-list-cell-left">
  30. {{$t('dosugar.chooseProduct')}}
  31. </view>
  32. <view class="uni-list-cell-db" style="overflow: hidden;text-overflow: ellipsis;">
  33. <picker @change="changeProduct" :value="index2" :range="productList">
  34. <view class="uni-input">{{productList[index2]}}</view>
  35. </picker>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. <view class="p">
  41. <p style="text-align:right" @click=sugarList()>{{$t('dosugar.list')}}>>></p>
  42. </view>
  43. <view class="tr">
  44. <button type="primary" formType="submit" @click="dosugar()" class="button">
  45. <p class="p1">提交</p>
  46. </button>
  47. </view>
  48. </view>
  49. </template>
  50. <script>
  51. import {
  52. mapState,
  53. mapActions,
  54. mapMutations
  55. } from 'vuex'
  56. export default {
  57. data() {
  58. return {
  59. globalUser: {},
  60. index: null,
  61. index2: null,
  62. equipmentName: null,
  63. equipmentNameList: [],
  64. products: [],
  65. productList: [],
  66. productName: null,
  67. equipmentId: null,
  68. searchClientId:null
  69. }
  70. },
  71. onShow() {
  72. this.globalUser = uni.getStorageSync("globalUser");
  73. // uni.setNavigationBarTitle({
  74. // title: this.$t('equipmentStatusList.title')
  75. // });
  76. // uni.setTabBarItem({
  77. // index: 3,
  78. // text: this.$t('tabs.tab4')
  79. // });
  80. var token = uni.getStorageSync("token");
  81. uni.setNavigationBarTitle({
  82. title: this.$t('remoteList.dosugur')
  83. });
  84. if (token.length > 1) {
  85. this.getEquipmentListData();
  86. } else {
  87. uni.reLaunch({
  88. url: '../Login/Login',
  89. });
  90. }
  91. },
  92. methods: {
  93. ...mapActions('chart', ['getEquipmentListByUser']),
  94. getEquipmentListData() {
  95. this.getEquipmentListByUser(this.globalUser)
  96. .then(data => {
  97. this.merchantList = data;
  98. var listName = data[0].equipmentList;
  99. var equipmentNameList = [];
  100. for (var i = 0; i < listName.length; i++) {
  101. equipmentNameList.push("名称:" + listName[i].name + " 编号:" + listName[i].clientId.substring(
  102. listName[i].clientId.length - 6, listName[i].clientId.length));
  103. }
  104. this.equipmentNameList = equipmentNameList;
  105. var listId = data[0].id;
  106. if (listId != null && listId != '1') {
  107. uni.setStorageSync("listName", listName);
  108. }
  109. uni.stopPullDownRefresh();
  110. }, _ => void uni.stopPullDownRefresh());
  111. },
  112. search(){
  113. var clientId = this.searchClientId;
  114. var list = uni.getStorageSync("listName");
  115. var n = 0;
  116. for (var i = 0; i < list.length; i++) {
  117. var code = list[i].clientId.substring(list[i].clientId.length - 6, list[i].clientId.length);
  118. if(code==clientId){
  119. n++;
  120. this.index = i;
  121. var id = list[i].id;
  122. this.getProName(id);
  123. this.equipmentId = id;
  124. this.productName = null;
  125. this.index2 = null;
  126. break;
  127. }
  128. }
  129. if(n==0){
  130. uni.showModal({
  131. title: "提示",
  132. content: "找不到该机器",
  133. success: (res) => {
  134. }
  135. })
  136. }
  137. },
  138. sugarList() {
  139. uni.navigateTo({
  140. url: 'sugarList',
  141. });
  142. },
  143. //改变机器
  144. changeEquipment: function(e) {
  145. this.index = e.target.value;
  146. // console.log("index="+this.index)
  147. var list = uni.getStorageSync("listName");
  148. this.getProName(list[e.target.value].id);
  149. this.equipmentId = list[e.target.value].id;
  150. this.productName = null;
  151. this.index2 = null;
  152. this.searchClientId = null;
  153. },
  154. changeProduct: function(e) {
  155. this.index2 = e.target.value;
  156. // console.log("index="+this.index2)
  157. var list = this.products;
  158. this.productName = list[this.index2].productName;
  159. },
  160. //获取商品列表
  161. getProName(equipmentId) {
  162. // console.log("equipmentId="+equipmentId)
  163. var token = uni.getStorageSync("token");
  164. uni.request({
  165. url: this.serverurl + '/TProduct/selectProducts',
  166. data: {
  167. "equimentId": equipmentId
  168. },
  169. header: {
  170. 'token': token
  171. },
  172. method: "GET",
  173. success: (res) => {
  174. var listName = res.data.data;
  175. this.products = listName;
  176. var productList = [];
  177. for (var i = 0; i < listName.length; i++) {
  178. productList.push(listName[i].productName);
  179. }
  180. this.productList = productList;
  181. },
  182. });
  183. },
  184. dosugar() {
  185. uni.showModal({
  186. title: "提示",
  187. content: "是否远程做糖?",
  188. success: (res) => {
  189. if (res.confirm) {
  190. var that = this;
  191. var token = uni.getStorageSync("token");
  192. var productName = this.productName;
  193. if (productName == null) {
  194. return;
  195. }
  196. var adminId = uni.getStorageSync("globalUser").id;
  197. var equipmentId = this.equipmentId;
  198. if (equipmentId == null) {
  199. return;
  200. }
  201. uni.request({
  202. url: this.serverurl + '/TSugarDo/doSugar',
  203. data: {
  204. "equipmentId": equipmentId,
  205. "adminId": adminId,
  206. "productName": productName
  207. },
  208. header: {
  209. 'token': token
  210. },
  211. method: "GET",
  212. success: (res) => {
  213. var code = res.data.code;
  214. if (code == true) {
  215. uni.showToast({
  216. title: "发送成功",
  217. duration: 2000
  218. });
  219. var sugar = res.data.data;
  220. console.log(sugar.no);
  221. var no = sugar.no;
  222. setTimeout(function() {
  223. that.selectSugar(no);
  224. }, 7000);
  225. // this.selectSugar(sugar.no)
  226. } else {
  227. uni.showToast({
  228. title: res.data.message,
  229. duration: 2000
  230. });
  231. }
  232. },
  233. });
  234. } else if (res.cancel) {}
  235. }
  236. })
  237. },
  238. selectSugar(no) {
  239. var token = uni.getStorageSync("token");
  240. uni.request({
  241. url: this.serverurl + '/TSugarDo/selectSugarStatus',
  242. data: {
  243. "no": no
  244. },
  245. header: {
  246. 'token': token
  247. },
  248. method: "GET",
  249. success: (res) => {
  250. var code = res.data.code;
  251. if (code == true) {
  252. uni.showModal({
  253. title: "提示",
  254. content: res.data.message,
  255. success: (res) => {
  256. }
  257. })
  258. // var sugar = res.data.data;
  259. } else {
  260. uni.showModal({
  261. title: "提示",
  262. content: res.data.message,
  263. confirmText: "重新查询",
  264. success: (res) => {
  265. if (res.confirm) {
  266. this.selectSugar(no);
  267. } else if (res.cancel) {}
  268. }
  269. })
  270. }
  271. },
  272. });
  273. }
  274. }
  275. }
  276. </script>
  277. <style>
  278. .search{
  279. width: 100%;
  280. padding-top: 10upx;
  281. display: flex;
  282. flex-direction: row;
  283. justify-content: flex-start;
  284. }
  285. .search-title{
  286. width: 28%;
  287. text-align: center;
  288. font-size: 26upx;
  289. font-family: "PingFang-SC-Bold";
  290. }
  291. .search-input{
  292. width: 48%;
  293. height: 25px;
  294. text-align: center;
  295. font-size: 26upx;
  296. /* font-family: "PingFang-SC-Bold"; */
  297. box-shadow: 0upx 0upx 20upx #D3D3D3;
  298. border-radius: 5upx;
  299. }
  300. .search-button{
  301. width: 20%;
  302. padding-left: 10px;
  303. padding-bottom: 5px;
  304. text-align: center;
  305. height: 60upx;
  306. text-align: left;
  307. }
  308. .tr {
  309. padding-top: 15upx;
  310. display: flex;
  311. flex-direction: row;
  312. justify-content: flex-start;
  313. font-size: 48upx;
  314. font-family: "PingFang-SC-Bold";
  315. position: fixed;
  316. bottom: 100upx;
  317. width: 100%;
  318. }
  319. .button {
  320. margin: auto;
  321. width: 60%;
  322. height: 100upx;
  323. }
  324. .p2 {
  325. font-size: 30upx;
  326. /* #ifndef H5 */
  327. padding-top: 3upx;
  328. /* #endif */
  329. position: absolute;
  330. /* 水平居中 */
  331. left: 50%;
  332. -webkit-transform: translateX(-50%);
  333. transform: translateX(-50%);
  334. }
  335. .p1 {
  336. font-size: 48upx;
  337. }
  338. .p {
  339. align: right;
  340. color: #007AFF;
  341. padding-top: 30upx;
  342. }
  343. </style>