dosugar.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. <template>
  2. <view>
  3. <view class="search">
  4. <view class="search-title">
  5. 输入机器编码
  6. </view>
  7. <view class="search-input">
  8. <input type="text" placeholder='输入设备编码后6位' v-model="searchClientId" />
  9. </view>
  10. <view class="search-button">
  11. <button type="primary" class="" @click="search()">
  12. <p class="">搜索</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. 点击选择机器
  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. 点击选择商品
  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()>今日做糖列表>>></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. if (token.length > 1) {
  82. this.getEquipmentListData();
  83. } else {
  84. uni.reLaunch({
  85. url: '../Login/Login',
  86. });
  87. }
  88. },
  89. methods: {
  90. ...mapActions('chart', ['getEquipmentListByUser']),
  91. getEquipmentListData() {
  92. this.getEquipmentListByUser(this.globalUser)
  93. .then(data => {
  94. this.merchantList = data;
  95. var listName = data[0].equipmentList;
  96. var equipmentNameList = [];
  97. for (var i = 0; i < listName.length; i++) {
  98. equipmentNameList.push("名称:" + listName[i].name + " 编号:" + listName[i].clientId.substring(
  99. listName[i].clientId.length - 6, listName[i].clientId.length));
  100. }
  101. this.equipmentNameList = equipmentNameList;
  102. var listId = data[0].id;
  103. if (listId != null && listId != '1') {
  104. uni.setStorageSync("listName", listName);
  105. }
  106. uni.stopPullDownRefresh();
  107. }, _ => void uni.stopPullDownRefresh());
  108. },
  109. search(){
  110. var clientId = this.searchClientId;
  111. var list = uni.getStorageSync("listName");
  112. var n = 0;
  113. for (var i = 0; i < list.length; i++) {
  114. var code = list[i].clientId.substring(list[i].clientId.length - 6, list[i].clientId.length);
  115. if(code==clientId){
  116. n++;
  117. this.index = i;
  118. var id = list[i].id;
  119. this.getProName(id);
  120. this.equipmentId = id;
  121. this.productName = null;
  122. this.index2 = null;
  123. break;
  124. }
  125. }
  126. if(n==0){
  127. uni.showModal({
  128. title: "提示",
  129. content: "找不到该机器",
  130. success: (res) => {
  131. }
  132. })
  133. }
  134. },
  135. sugarList() {
  136. uni.navigateTo({
  137. url: 'sugarList',
  138. });
  139. },
  140. //改变机器
  141. changeEquipment: function(e) {
  142. this.index = e.target.value;
  143. // console.log("index="+this.index)
  144. var list = uni.getStorageSync("listName");
  145. this.getProName(list[e.target.value].id);
  146. this.equipmentId = list[e.target.value].id;
  147. this.productName = null;
  148. this.index2 = null;
  149. this.searchClientId = null;
  150. },
  151. changeProduct: function(e) {
  152. this.index2 = e.target.value;
  153. // console.log("index="+this.index2)
  154. var list = this.products;
  155. this.productName = list[this.index2].productName;
  156. },
  157. //获取商品列表
  158. getProName(equipmentId) {
  159. // console.log("equipmentId="+equipmentId)
  160. var token = uni.getStorageSync("token");
  161. uni.request({
  162. url: this.serverurl + '/TProduct/selectProducts',
  163. data: {
  164. "equimentId": equipmentId
  165. },
  166. header: {
  167. 'token': token
  168. },
  169. method: "GET",
  170. success: (res) => {
  171. var listName = res.data.data;
  172. this.products = listName;
  173. var productList = [];
  174. for (var i = 0; i < listName.length; i++) {
  175. productList.push(listName[i].productName);
  176. }
  177. this.productList = productList;
  178. },
  179. });
  180. },
  181. dosugar() {
  182. uni.showModal({
  183. title: "提示",
  184. content: "是否远程做糖?",
  185. success: (res) => {
  186. if (res.confirm) {
  187. var that = this;
  188. var token = uni.getStorageSync("token");
  189. var productName = this.productName;
  190. if (productName == null) {
  191. return;
  192. }
  193. var adminId = uni.getStorageSync("globalUser").id;
  194. var equipmentId = this.equipmentId;
  195. if (equipmentId == null) {
  196. return;
  197. }
  198. uni.request({
  199. url: this.serverurl + '/TSugarDo/doSugar',
  200. data: {
  201. "equipmentId": equipmentId,
  202. "adminId": adminId,
  203. "productName": productName
  204. },
  205. header: {
  206. 'token': token
  207. },
  208. method: "GET",
  209. success: (res) => {
  210. var code = res.data.code;
  211. if (code == true) {
  212. uni.showToast({
  213. title: "发送成功",
  214. duration: 2000
  215. });
  216. var sugar = res.data.data;
  217. console.log(sugar.no);
  218. var no = sugar.no;
  219. setTimeout(function() {
  220. that.selectSugar(no);
  221. }, 7000);
  222. // this.selectSugar(sugar.no)
  223. } else {
  224. uni.showToast({
  225. title: res.data.message,
  226. duration: 2000
  227. });
  228. }
  229. },
  230. });
  231. } else if (res.cancel) {}
  232. }
  233. })
  234. },
  235. selectSugar(no) {
  236. var token = uni.getStorageSync("token");
  237. uni.request({
  238. url: this.serverurl + '/TSugarDo/selectSugarStatus',
  239. data: {
  240. "no": no
  241. },
  242. header: {
  243. 'token': token
  244. },
  245. method: "GET",
  246. success: (res) => {
  247. var code = res.data.code;
  248. if (code == true) {
  249. uni.showModal({
  250. title: "提示",
  251. content: res.data.message,
  252. success: (res) => {
  253. }
  254. })
  255. // var sugar = res.data.data;
  256. } else {
  257. uni.showModal({
  258. title: "提示",
  259. content: res.data.message,
  260. confirmText: "重新查询",
  261. success: (res) => {
  262. if (res.confirm) {
  263. this.selectSugar(no);
  264. } else if (res.cancel) {}
  265. }
  266. })
  267. }
  268. },
  269. });
  270. }
  271. }
  272. }
  273. </script>
  274. <style>
  275. .search{
  276. width: 100%;
  277. padding-top: 10upx;
  278. display: flex;
  279. flex-direction: row;
  280. justify-content: flex-start;
  281. }
  282. .search-title{
  283. width: 28%;
  284. text-align: center;
  285. font-size: 26upx;
  286. font-family: "PingFang-SC-Bold";
  287. }
  288. .search-input{
  289. width: 45%;
  290. text-align: center;
  291. font-size: 26upx;
  292. font-family: "PingFang-SC-Bold";
  293. box-shadow: 0upx 0upx 20upx #D3D3D3;
  294. border-radius: 5upx;
  295. }
  296. .search-button{
  297. width: 20%;
  298. padding-left: 7upx;
  299. text-align: center;
  300. }
  301. .tr {
  302. padding-top: 15upx;
  303. display: flex;
  304. flex-direction: row;
  305. justify-content: flex-start;
  306. font-size: 48upx;
  307. font-family: "PingFang-SC-Bold";
  308. position: fixed;
  309. bottom: 100upx;
  310. width: 100%;
  311. }
  312. .button {
  313. margin: auto;
  314. width: 60%;
  315. height: 100upx;
  316. }
  317. .p2 {
  318. font-size: 30upx;
  319. /* #ifndef H5 */
  320. padding-top: 3upx;
  321. /* #endif */
  322. position: absolute;
  323. /* 水平居中 */
  324. left: 50%;
  325. -webkit-transform: translateX(-50%);
  326. transform: translateX(-50%);
  327. }
  328. .p1 {
  329. font-size: 48upx;
  330. }
  331. .p {
  332. align: right;
  333. color: #007AFF;
  334. padding-top: 30upx;
  335. }
  336. </style>