flowerShow.vue 13 KB

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