flowerShow.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  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. var arr = nameNum.split("-");
  245. var name = arr[0];
  246. var num = arr[1];
  247. var list = [];
  248. var productList = this.products;
  249. var products = [];
  250. //修改所有蓝色的花型
  251. if (name == 'blue') {
  252. products = ['精灵蝶梦', '夏日倾城', '百花齐放', '星空幻想', '坠入星空', '花飞蝶舞', '花样年华', '五彩缤纷', '幽兰爱恋', '冰美人', '海洋之心',
  253. '彩色精灵'
  254. ];
  255. }
  256. if (name == 'yellow') {
  257. products = ['精灵蝶梦', '夏日倾城', '百花齐放', '蜂缠蝶恋', '星空幻想', '坠入星空', '花飞蝶舞',
  258. '花样年华', '心花怒放', '五彩缤纷', '美梦成真', '夏日爱恋', '国色天香', '彩色精灵',
  259. ];
  260. }
  261. if (name == 'red') {
  262. products = ['精灵蝶梦', '夏日倾城', '百花齐放','星空幻想', '蜂缠蝶恋', '豆蔻年华', '花飞蝶舞', '花样年华', '心花怒放',
  263. '玫瑰精灵', '童心未泯', '五彩缤纷', '烈焰红唇', '美梦成真', '一见钟情', '赤子之心', '彩色精灵'
  264. ];
  265. }
  266. if (name == 'white') {
  267. products = ['蜂缠蝶恋', '雪花飞舞', '春暖花开', '天雪恋舞', '心花怒放','水中芙蓉', '幽兰爱恋', '心之守护', '水晶之恋', '小棉袄'];
  268. }
  269. for (var j = 0; j < products.length; j++) {
  270. for (var i = 0; i < productList.length; i++) {
  271. var product = productList[i];
  272. if (products[j] == product.productName) {
  273. product.showType = num;
  274. // list.push(product);
  275. }
  276. }
  277. }
  278. this.products = productList;
  279. },
  280. updateProducts() {
  281. uni.showModal({
  282. title: "提示",
  283. content: "是否修改?",
  284. success: (res) => {
  285. if (res.confirm) {
  286. // var that = this;
  287. var token = uni.getStorageSync("token");
  288. var products = this.products;
  289. if (products == null) {
  290. return;
  291. }
  292. // encodeURIComponent(JSON.stringify(products))
  293. var list = JSON.stringify(products);
  294. uni.request({
  295. url: this.serverurl + '/TProduct/updateProductsShow',
  296. data: {
  297. "productList": list
  298. },
  299. header: {
  300. 'token': token
  301. },
  302. method: "POST",
  303. success: (res) => {
  304. var code = res.data.code;
  305. if (code == true) {
  306. uni.showToast({
  307. title: "发送成功",
  308. duration: 2000
  309. });
  310. } else {
  311. uni.showToast({
  312. title: res.data.message,
  313. duration: 2000
  314. });
  315. }
  316. },
  317. });
  318. } else if (res.cancel) {}
  319. }
  320. })
  321. },
  322. selectSugar(no) {
  323. var token = uni.getStorageSync("token");
  324. uni.request({
  325. url: this.serverurl + '/TSugarDo/selectSugarStatus',
  326. data: {
  327. "no": no
  328. },
  329. header: {
  330. 'token': token
  331. },
  332. method: "GET",
  333. success: (res) => {
  334. var code = res.data.code;
  335. if (code == true) {
  336. uni.showModal({
  337. title: "提示",
  338. content: res.data.message,
  339. success: (res) => {
  340. }
  341. })
  342. // var sugar = res.data.data;
  343. } else {
  344. uni.showModal({
  345. title: "提示",
  346. content: res.data.message,
  347. confirmText: "重新查询",
  348. success: (res) => {
  349. if (res.confirm) {
  350. this.selectSugar(no);
  351. } else if (res.cancel) {}
  352. }
  353. })
  354. }
  355. },
  356. });
  357. }
  358. }
  359. }
  360. </script>
  361. <style>
  362. .search {
  363. width: 100%;
  364. padding-top: 10upx;
  365. display: flex;
  366. flex-direction: row;
  367. justify-content: flex-start;
  368. }
  369. .search-title {
  370. width: 28%;
  371. text-align: center;
  372. font-size: 26upx;
  373. font-family: "PingFang-SC-Bold";
  374. }
  375. .search-input {
  376. width: 45%;
  377. text-align: center;
  378. font-size: 26upx;
  379. font-family: "PingFang-SC-Bold";
  380. box-shadow: 0upx 0upx 20upx #D3D3D3;
  381. border-radius: 5upx;
  382. }
  383. .search-button {
  384. width: 20%;
  385. padding-left: 7upx;
  386. text-align: center;
  387. }
  388. .tr {
  389. padding-top: 15upx;
  390. display: flex;
  391. flex-direction: row;
  392. justify-content: flex-start;
  393. font-size: 48upx;
  394. font-family: "PingFang-SC-Bold";
  395. /* position: fixed; */
  396. bottom: 100upx;
  397. width: 100%;
  398. }
  399. .product {
  400. font-family: "PingFang-SC-Bold";
  401. font-size: 38upx;
  402. padding-top: 15upx;
  403. display: flex;
  404. flex-direction: row;
  405. justify-content: flex-start;
  406. }
  407. .productName {
  408. width: 70%;
  409. padding-left: 40upx;
  410. padding-right: 10upx;
  411. }
  412. .button {
  413. margin: auto;
  414. width: 60%;
  415. height: 100upx;
  416. }
  417. .p2 {
  418. font-size: 30upx;
  419. /* #ifndef H5 */
  420. padding-top: 3upx;
  421. /* #endif */
  422. position: absolute;
  423. /* 水平居中 */
  424. left: 50%;
  425. -webkit-transform: translateX(-50%);
  426. transform: translateX(-50%);
  427. }
  428. .p1 {
  429. font-size: 48upx;
  430. }
  431. .p {
  432. align: right;
  433. color: #007AFF;
  434. padding-top: 30upx;
  435. }
  436. .line {
  437. background: #ECECEC;
  438. height: 20upx;
  439. }
  440. </style>