flowerShow.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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" 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>
  29. </view>
  30. <view class="product" v-for="(item,index) in products" :key="index">
  31. <P class="productName">{{$t('flowers.flower')}}:{{item.productName}} </P>
  32. <radio-group :name="item.productName">
  33. <label>
  34. <radio @click="changeShow(item.productName+'-0')" value="0" :checked='item.showType==null || item.showType==0' /><text>{{$t('flowers.show')}}</text>
  35. </label>
  36. <label>
  37. <radio @click="changeShow(item.productName+'-1')" value="1" :checked='item.showType==1' /><text>{{$t('flowers.unshow')}}</text>
  38. </label>
  39. </radio-group>
  40. </view>
  41. <view class="tr">
  42. <button type="primary" formType="submit" @click="updateProducts()" class="button">
  43. <p class="p1">{{$t('flowers.submit')}}</p>
  44. </button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. mapState,
  51. mapActions,
  52. mapMutations
  53. } from 'vuex'
  54. export default {
  55. data() {
  56. return {
  57. globalUser: {},
  58. index: null,
  59. index2: null,
  60. equipmentName: null,
  61. equipmentNameList: [],
  62. products: [],
  63. productList: [],
  64. productName: null,
  65. equipmentId: null,
  66. searchClientId: null,
  67. showType: 0
  68. }
  69. },
  70. onShow() {
  71. this.globalUser = uni.getStorageSync("globalUser");
  72. // uni.setNavigationBarTitle({
  73. // title: this.$t('equipmentStatusList.title')
  74. // });
  75. // uni.setTabBarItem({
  76. // index: 3,
  77. // text: this.$t('tabs.tab4')
  78. // });
  79. var token = uni.getStorageSync("token");
  80. if (token.length > 1) {
  81. this.getEquipmentListData();
  82. } else {
  83. uni.reLaunch({
  84. url: '../Login/Login',
  85. });
  86. }
  87. },
  88. methods: {
  89. ...mapActions('chart', ['getEquipmentListByUser']),
  90. getEquipmentListData() {
  91. this.getEquipmentListByUser(this.globalUser)
  92. .then(data => {
  93. this.merchantList = data;
  94. var listName = data[0].equipmentList;
  95. var equipmentNameList = [];
  96. for (var i = 0; i < listName.length; i++) {
  97. equipmentNameList.push("名称:" + listName[i].name + " 编号:" + listName[i].clientId.substring(
  98. listName[i].clientId.length - 6, listName[i].clientId.length));
  99. }
  100. this.equipmentNameList = equipmentNameList;
  101. var listId = data[0].id;
  102. if (listId != null && listId != '1') {
  103. uni.setStorageSync("listName", listName);
  104. }
  105. uni.stopPullDownRefresh();
  106. }, _ => void uni.stopPullDownRefresh());
  107. },
  108. search() {
  109. var clientId = this.searchClientId;
  110. var list = uni.getStorageSync("listName");
  111. var n = 0;
  112. for (var i = 0; i < list.length; i++) {
  113. var code = list[i].clientId.substring(list[i].clientId.length - 6, list[i].clientId.length);
  114. if (code == clientId) {
  115. n++;
  116. this.index = i;
  117. var id = list[i].id;
  118. this.getProName(id);
  119. this.equipmentId = id;
  120. this.productName = null;
  121. this.index2 = null;
  122. break;
  123. }
  124. }
  125. if (n == 0) {
  126. uni.showModal({
  127. title: "提示",
  128. content: "找不到该机器",
  129. success: (res) => {
  130. }
  131. })
  132. }
  133. },
  134. sugarList() {
  135. uni.navigateTo({
  136. url: 'sugarList',
  137. });
  138. },
  139. //改变机器
  140. changeEquipment: function(e) {
  141. this.index = e.target.value;
  142. // console.log("index="+this.index)
  143. var list = uni.getStorageSync("listName");
  144. this.getProName(list[e.target.value].id);
  145. this.equipmentId = list[e.target.value].id;
  146. this.productName = null;
  147. this.index2 = null;
  148. this.searchClientId = null;
  149. },
  150. changeProduct: function(e) {
  151. this.index2 = e.target.value;
  152. // console.log("index="+this.index2)
  153. var list = this.products;
  154. this.productName = list[this.index2].productName;
  155. },
  156. //获取商品列表
  157. getProName(equipmentId) {
  158. // console.log("equipmentId="+equipmentId)
  159. var token = uni.getStorageSync("token");
  160. uni.request({
  161. url: this.serverurl + '/TProduct/selectProducts',
  162. data: {
  163. "equimentId": equipmentId
  164. },
  165. header: {
  166. 'token': token
  167. },
  168. method: "GET",
  169. success: (res) => {
  170. var listName = res.data.data;
  171. this.products = listName;
  172. var productList = [];
  173. for (var i = 0; i < listName.length; i++) {
  174. productList.push(listName[i].productName);
  175. }
  176. this.productList = productList;
  177. },
  178. });
  179. },
  180. changeShow(nameNum) {
  181. var arr = nameNum.split("-");
  182. var name = arr[0];
  183. var num = arr[1];
  184. var list = [];
  185. var productList = this.products;
  186. for (var i = 0; i < productList.length; i++) {
  187. var product = productList[i];
  188. if (name==product.productName) {
  189. product.showType = num;
  190. }
  191. list.push(product);
  192. }
  193. this.products = list;
  194. // console.log(name + '-' + num);
  195. },
  196. updateProducts() {
  197. uni.showModal({
  198. title: "提示",
  199. content: "是否修改?",
  200. success: (res) => {
  201. if (res.confirm) {
  202. // var that = this;
  203. var token = uni.getStorageSync("token");
  204. var products = this.products;
  205. if (products == null) {
  206. return;
  207. }
  208. // encodeURIComponent(JSON.stringify(products))
  209. var list = JSON.stringify(products);
  210. uni.request({
  211. url: this.serverurl + '/TProduct/updateProductsShow',
  212. data: {
  213. "productList": list
  214. },
  215. header: {
  216. 'token': token
  217. },
  218. method: "POST",
  219. success: (res) => {
  220. var code = res.data.code;
  221. if (code == true) {
  222. uni.showToast({
  223. title: "发送成功",
  224. duration: 2000
  225. });
  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: 45%;
  293. text-align: center;
  294. font-size: 26upx;
  295. font-family: "PingFang-SC-Bold";
  296. box-shadow: 0upx 0upx 20upx #D3D3D3;
  297. border-radius: 5upx;
  298. }
  299. .search-button {
  300. width: 20%;
  301. padding-left: 7upx;
  302. text-align: center;
  303. }
  304. .tr {
  305. padding-top: 15upx;
  306. display: flex;
  307. flex-direction: row;
  308. justify-content: flex-start;
  309. font-size: 48upx;
  310. font-family: "PingFang-SC-Bold";
  311. /* position: fixed; */
  312. bottom: 100upx;
  313. width: 100%;
  314. }
  315. .product {
  316. font-family: "PingFang-SC-Bold";
  317. font-size: 38upx;
  318. padding-top: 15upx;
  319. display: flex;
  320. flex-direction: row;
  321. justify-content: flex-start;
  322. }
  323. .productName {
  324. width: 70%;
  325. padding-left: 40upx;
  326. padding-right: 10upx;
  327. }
  328. .button {
  329. margin: auto;
  330. width: 60%;
  331. height: 100upx;
  332. }
  333. .p2 {
  334. font-size: 30upx;
  335. /* #ifndef H5 */
  336. padding-top: 3upx;
  337. /* #endif */
  338. position: absolute;
  339. /* 水平居中 */
  340. left: 50%;
  341. -webkit-transform: translateX(-50%);
  342. transform: translateX(-50%);
  343. }
  344. .p1 {
  345. font-size: 48upx;
  346. }
  347. .p {
  348. align: right;
  349. color: #007AFF;
  350. padding-top: 30upx;
  351. }
  352. </style>