flowerShow.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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>
  29. </view>
  30. <view class="product" v-if="productList.length>0">
  31. <P style='color:#0A98D5;' class="productName">{{$t('flowers.buleSugar')}}</P>
  32. <radio-group name="蓝">
  33. <label>
  34. <radio @click="changeShowList('blue-0')" value="0" /><text>{{$t('flowers.show')}}</text>
  35. </label>
  36. <label>
  37. <radio @click="changeShowList('blue-1')" value="1" /><text>{{$t('flowers.unshow')}}</text>
  38. </label>
  39. </radio-group>
  40. </view>
  41. <view class="product" v-if="productList.length>0">
  42. <P style='color:#F4AE1B;' class="productName">{{$t('flowers.yellowSugar')}}</P>
  43. <radio-group name="黄">
  44. <label>
  45. <radio @click="changeShowList('yellow-0')" value="0" /><text>{{$t('flowers.show')}}</text>
  46. </label>
  47. <label>
  48. <radio @click="changeShowList('yellow-1')" value="1" /><text>{{$t('flowers.unshow')}}</text>
  49. </label>
  50. </radio-group>
  51. </view>
  52. <view class="product" v-if="productList.length>0">
  53. <P style='color:#FF3333;' class="productName">{{$t('flowers.redSugar')}}</P>
  54. <radio-group name="红">
  55. <label>
  56. <radio @click="changeShowList('red-0')" value="0" /><text>{{$t('flowers.show')}}</text>
  57. </label>
  58. <label>
  59. <radio @click="changeShowList('red-1')" value="1" /><text>{{$t('flowers.unshow')}}</text>
  60. </label>
  61. </radio-group>
  62. </view>
  63. <view class="product" v-if="productList.length>0">
  64. <P class="productName">{{$t('flowers.whileSugar')}}</P>
  65. <radio-group name="白">
  66. <label>
  67. <radio @click="changeShowList('white-0')" value="0" /><text>{{$t('flowers.show')}}</text>
  68. </label>
  69. <label>
  70. <radio @click="changeShowList('white-1')" value="1" /><text>{{$t('flowers.unshow')}}</text>
  71. </label>
  72. </radio-group>
  73. </view>
  74. <view class="line"></view>
  75. <view class="product" v-for="(item,index) in products" :key="index">
  76. <P class="productName">{{$t('flowers.flower')}}:{{item.productName}} </P>
  77. <radio-group :name="item.productName">
  78. <label>
  79. <radio @click="changeShow(item.productName+'-0')" value="0"
  80. :checked='item.showType==null || item.showType==0' /><text>{{$t('flowers.show')}}</text>
  81. </label>
  82. <label>
  83. <radio @click="changeShow(item.productName+'-1')" value="1" :checked='item.showType==1' />
  84. <text>{{$t('flowers.unshow')}}</text>
  85. </label>
  86. </radio-group>
  87. </view>
  88. <view class="tr">
  89. <button type="primary" formType="submit" @click="updateProducts()" class="button">
  90. <p class="p1">{{$t('flowers.submit')}}</p>
  91. </button>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. import {
  97. mapState,
  98. mapActions,
  99. mapMutations
  100. } from 'vuex'
  101. export default {
  102. data() {
  103. return {
  104. globalUser: {},
  105. index: null,
  106. index2: null,
  107. equipmentName: null,
  108. equipmentNameList: [],
  109. products: [],
  110. productList: [],
  111. productName: null,
  112. equipmentId: null,
  113. searchClientId: null,
  114. showType: 0
  115. }
  116. },
  117. onShow() {
  118. this.globalUser = uni.getStorageSync("globalUser");
  119. // uni.setNavigationBarTitle({
  120. // title: this.$t('equipmentStatusList.title')
  121. // });
  122. // uni.setTabBarItem({
  123. // index: 3,
  124. // text: this.$t('tabs.tab4')
  125. // });
  126. var token = uni.getStorageSync("token");
  127. uni.setNavigationBarTitle({
  128. title: this.$t('remoteList.flowers')
  129. });
  130. if (token.length > 1) {
  131. this.getEquipmentListData();
  132. } else {
  133. uni.reLaunch({
  134. url: '../Login/Login',
  135. });
  136. }
  137. },
  138. methods: {
  139. ...mapActions('chart', ['getEquipmentListByUser']),
  140. getEquipmentListData() {
  141. this.getEquipmentListByUser(this.globalUser)
  142. .then(data => {
  143. this.merchantList = data;
  144. var listName = data[0].equipmentList;
  145. var equipmentNameList = [];
  146. for (var i = 0; i < listName.length; i++) {
  147. equipmentNameList.push("名称:" + listName[i].name + " 编号:" + listName[i].clientId.substring(
  148. listName[i].clientId.length - 6, listName[i].clientId.length));
  149. }
  150. this.equipmentNameList = equipmentNameList;
  151. var listId = data[0].id;
  152. if (listId != null && listId != '1') {
  153. uni.setStorageSync("listName", listName);
  154. }
  155. uni.stopPullDownRefresh();
  156. }, _ => void uni.stopPullDownRefresh());
  157. },
  158. search() {
  159. var clientId = this.searchClientId;
  160. var list = uni.getStorageSync("listName");
  161. var n = 0;
  162. for (var i = 0; i < list.length; i++) {
  163. var code = list[i].clientId.substring(list[i].clientId.length - 6, list[i].clientId.length);
  164. if (code == clientId) {
  165. n++;
  166. this.index = i;
  167. var id = list[i].id;
  168. this.getProName(id);
  169. this.equipmentId = id;
  170. this.productName = null;
  171. this.index2 = null;
  172. break;
  173. }
  174. }
  175. if (n == 0) {
  176. uni.showModal({
  177. title: "提示",
  178. content: "找不到该机器",
  179. success: (res) => {
  180. }
  181. })
  182. }
  183. },
  184. sugarList() {
  185. uni.navigateTo({
  186. url: 'sugarList',
  187. });
  188. },
  189. //改变机器
  190. changeEquipment: function(e) {
  191. this.index = e.target.value;
  192. // console.log("index="+this.index)
  193. var list = uni.getStorageSync("listName");
  194. this.getProName(list[e.target.value].id);
  195. this.equipmentId = list[e.target.value].id;
  196. this.productName = null;
  197. this.index2 = null;
  198. this.searchClientId = null;
  199. },
  200. changeProduct: function(e) {
  201. this.index2 = e.target.value;
  202. // console.log("index="+this.index2)
  203. var list = this.products;
  204. this.productName = list[this.index2].productName;
  205. },
  206. //获取商品列表
  207. getProName(equipmentId) {
  208. // console.log("equipmentId="+equipmentId)
  209. var token = uni.getStorageSync("token");
  210. uni.request({
  211. url: this.serverurl + '/TProduct/selectProducts',
  212. data: {
  213. "equimentId": equipmentId
  214. },
  215. header: {
  216. 'token': token
  217. },
  218. method: "GET",
  219. success: (res) => {
  220. var listName = res.data.data;
  221. this.products = listName;
  222. var productList = [];
  223. for (var i = 0; i < listName.length; i++) {
  224. productList.push(listName[i].productName);
  225. }
  226. this.productList = productList;
  227. },
  228. });
  229. },
  230. changeShow(nameNum) {
  231. var arr = nameNum.split("-");
  232. var name = arr[0];
  233. var num = arr[1];
  234. var list = [];
  235. var productList = this.products;
  236. for (var i = 0; i < productList.length; i++) {
  237. var product = productList[i];
  238. if (name == product.productName) {
  239. product.showType = num;
  240. }
  241. list.push(product);
  242. }
  243. this.products = list;
  244. },
  245. //按糖颜色去筛选花型的显示
  246. changeShowList(nameNum) {
  247. debugger
  248. var arr = nameNum.split("-");
  249. var name = arr[0];
  250. var num = arr[1];
  251. var list = [];
  252. var productList = this.products;
  253. var products = [];
  254. //修改所有蓝色的花型
  255. if (name == 'blue') {
  256. // products = ['精灵蝶梦', '夏日倾城', '百花齐放', '星空幻想', '坠入星空', '花飞蝶舞', '花样年华', '五彩缤纷', '幽兰爱恋', '冰美人', '海洋之心',
  257. // '彩色精灵'
  258. // ];
  259. products = ['A19', 'A20', 'A21', 'A24', 'A25', 'A28', 'A29', 'A03', 'A09', 'A12', 'A15',
  260. 'A17'
  261. ];
  262. }
  263. if (name == 'yellow') {
  264. // products = ['精灵蝶梦', '夏日倾城', '百花齐放', '蜂缠蝶恋', '星空幻想', '坠入星空', '花飞蝶舞',
  265. // '花样年华', '心花怒放', '五彩缤纷', '美梦成真', '夏日爱恋', '国色天香', '彩色精灵',
  266. // ];
  267. products = ['A19', 'A20', 'A21', 'A22', 'A24', 'A25', 'A28',
  268. 'A29', 'A30', 'A03', 'A07', 'A11', 'A13', 'A17',
  269. ];
  270. }
  271. if (name == 'red') {
  272. // products = ['精灵蝶梦', '夏日倾城', '百花齐放','星空幻想', '蜂缠蝶恋', '豆蔻年华', '花飞蝶舞', '花样年华', '心花怒放',
  273. // '玫瑰精灵', '童心未泯', '五彩缤纷', '烈焰红唇', '美梦成真', '一见钟情', '赤子之心', '彩色精灵'
  274. // ];
  275. products = ['A19', 'A20', 'A21','A24', 'A22', 'A23', 'A28', 'A29', 'A30',
  276. 'A01', 'A02', 'A03', 'A06', 'A07', 'A08', 'A14', 'A17'
  277. ];
  278. }
  279. if (name == 'white') {
  280. // products = ['蜂缠蝶恋', '雪花飞舞', '春暖花开', '天雪恋舞', '心花怒放','水中芙蓉', '幽兰爱恋', '心之守护', '水晶之恋', '小棉袄'];
  281. products = ['A22', 'A26', 'A27', 'A04', 'A30','A05', 'A09', 'A10', 'A16', 'A18'];
  282. }
  283. for (var j = 0; j < products.length; j++) {
  284. for (var i = 0; i < productList.length; i++) {
  285. var product = productList[i];
  286. if (products[j] == product.no) {
  287. product.showType = num;
  288. // list.push(product);
  289. }
  290. }
  291. }
  292. this.products = productList;
  293. },
  294. updateProducts() {
  295. uni.showModal({
  296. title: "提示",
  297. content: "是否修改?",
  298. success: (res) => {
  299. if (res.confirm) {
  300. // var that = this;
  301. var token = uni.getStorageSync("token");
  302. var products = this.products;
  303. if (products == null) {
  304. return;
  305. }
  306. // encodeURIComponent(JSON.stringify(products))
  307. var list = JSON.stringify(products);
  308. uni.request({
  309. url: this.serverurl + '/TProduct/updateProductsShow',
  310. data: {
  311. "productList": list
  312. },
  313. header: {
  314. 'token': token
  315. },
  316. method: "POST",
  317. success: (res) => {
  318. var code = res.data.code;
  319. if (code == true) {
  320. uni.showToast({
  321. title: "发送成功",
  322. duration: 2000
  323. });
  324. } else {
  325. uni.showToast({
  326. title: res.data.message,
  327. duration: 2000
  328. });
  329. }
  330. },
  331. });
  332. } else if (res.cancel) {}
  333. }
  334. })
  335. },
  336. selectSugar(no) {
  337. var token = uni.getStorageSync("token");
  338. uni.request({
  339. url: this.serverurl + '/TSugarDo/selectSugarStatus',
  340. data: {
  341. "no": no
  342. },
  343. header: {
  344. 'token': token
  345. },
  346. method: "GET",
  347. success: (res) => {
  348. var code = res.data.code;
  349. if (code == true) {
  350. uni.showModal({
  351. title: "提示",
  352. content: res.data.message,
  353. success: (res) => {
  354. }
  355. })
  356. // var sugar = res.data.data;
  357. } else {
  358. uni.showModal({
  359. title: "提示",
  360. content: res.data.message,
  361. confirmText: "重新查询",
  362. success: (res) => {
  363. if (res.confirm) {
  364. this.selectSugar(no);
  365. } else if (res.cancel) {}
  366. }
  367. })
  368. }
  369. },
  370. });
  371. }
  372. }
  373. }
  374. </script>
  375. <style>
  376. .search {
  377. width: 100%;
  378. padding-top: 10upx;
  379. display: flex;
  380. flex-direction: row;
  381. justify-content: flex-start;
  382. }
  383. .search-title {
  384. width: 28%;
  385. text-align: center;
  386. font-size: 26upx;
  387. font-family: "PingFang-SC-Bold";
  388. }
  389. .search-input{
  390. width: 48%;
  391. height: 25px;
  392. text-align: center;
  393. font-size: 26upx;
  394. /* font-family: "PingFang-SC-Bold"; */
  395. box-shadow: 0upx 0upx 20upx #D3D3D3;
  396. border-radius: 5upx;
  397. }
  398. .search-button{
  399. width: 20%;
  400. padding-left: 10px;
  401. padding-bottom: 5px;
  402. text-align: center;
  403. height: 60upx;
  404. text-align: left;
  405. }
  406. .tr {
  407. padding-top: 15upx;
  408. display: flex;
  409. flex-direction: row;
  410. justify-content: flex-start;
  411. font-size: 48upx;
  412. font-family: "PingFang-SC-Bold";
  413. /* position: fixed; */
  414. bottom: 100upx;
  415. width: 100%;
  416. }
  417. .product {
  418. font-family: "PingFang-SC-Bold";
  419. font-size: 38upx;
  420. padding-top: 15upx;
  421. display: flex;
  422. flex-direction: row;
  423. justify-content: flex-start;
  424. }
  425. .productName {
  426. width: 70%;
  427. padding-left: 40upx;
  428. padding-right: 10upx;
  429. }
  430. .button {
  431. margin: auto;
  432. width: 60%;
  433. height: 100upx;
  434. }
  435. .p2 {
  436. font-size: 30upx;
  437. /* #ifndef H5 */
  438. padding-top: 3upx;
  439. /* #endif */
  440. position: absolute;
  441. /* 水平居中 */
  442. left: 50%;
  443. -webkit-transform: translateX(-50%);
  444. transform: translateX(-50%);
  445. }
  446. .p1 {
  447. font-size: 48upx;
  448. }
  449. .p {
  450. align: right;
  451. color: #007AFF;
  452. padding-top: 30upx;
  453. }
  454. .line {
  455. background: #ECECEC;
  456. height: 20upx;
  457. }
  458. </style>