flowerShow.vue 12 KB

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