index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <template>
  2. <view class="app-container">
  3. <uni-nav-bar ref="refTitle" dark :fixed="true" shadow background-color="#007AFF" status-bar :title="title"
  4. :right-icon="rightIcon" @clickRight="toggleDisplayMode" />
  5. <view class="menu-container" v-if="displayMode">
  6. <uni-section v-for="(item,index) in girdListSetGroupOf" :title="item.name" type="square" padding="0 0 0 5px">
  7. <view class="example-body" style="display: flex;">
  8. <view class="tag-view">
  9. <uni-tag :inverted="true" :type="item.type" style="height:45px;line-height: 45px;min-width:64px;font-size: 16px;font-weight: bold;margin: 0 5px 5px 0;"
  10. v-for="(item2, index) in item.girdList"
  11. :index="index" :key="index"
  12. :text="item2.text"
  13. @click="navClick(item2.navUrl)"
  14. />
  15. </view>
  16. </view>
  17. </uni-section>
  18. </view>
  19. <view class="menu-container" v-if="!displayMode">
  20. <uni-section title="WMS" type="circle"></uni-section>
  21. <view class="grid-body">
  22. <uni-grid :column="3" :highlight="true" :showBorder="false">
  23. <uni-grid-item v-for="(item, index) in girdListSetOf" :index="index" :key="index">
  24. <view class="grid-item-box" @click="navClick(item.navUrl)">
  25. <text class="t-icon" :class="item.icon"></text>
  26. <text class="text">{{ item.text }}</text>
  27. </view>
  28. </uni-grid-item>
  29. </uni-grid>
  30. </view>
  31. <uni-section title="MES" type="circle"></uni-section>
  32. <view class="grid-body">
  33. <uni-grid :column="3" :highlight="true" :showBorder="false">
  34. <uni-grid-item v-for="(item, index) in girdMesList" :index="index" :key="index">
  35. <view class="grid-item-box" @click="navClick(item.navUrl)">
  36. <text class="t-icon" :class="item.icon"></text>
  37. <text class="text">{{ item.text }}</text>
  38. </view>
  39. </uni-grid-item>
  40. </uni-grid>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. //types : ["default", "primary", "success", "warning", "error"]
  50. girdList: [
  51. {
  52. icon: 'iconrukutui',
  53. text: '入库(退)',
  54. navUrl: '/pages/menu/backStockIn/index',
  55. },
  56. {
  57. icon: 'iconchukutui',
  58. text: '出库(退)',
  59. navUrl: '/pages/menu/backStockOut/index',
  60. },
  61. {
  62. icon: 'iconcs-kc-1',
  63. text: '查库存',
  64. navUrl: '/pages/menu/report/current',
  65. },
  66. {
  67. icon: 'iconpandian',
  68. text: '盘点单',
  69. navUrl: '/pages/menu/stockCheck/index',
  70. },
  71. ],
  72. girdMesList:[
  73. {
  74. icon: 'icongantt-full',
  75. text: '生产报工',
  76. navUrl: '/pages/mes/progx/index',
  77. },
  78. ],
  79. inGirdList:[],
  80. outGirdList:[],
  81. moveGirdList:[],
  82. title:"菜单",
  83. isNavigating: false, // 用来检查是否正在导航
  84. displayMode: uni.getStorageSync('menuDisplayMode'),
  85. }
  86. },
  87. created() {
  88. let stockInBillType = [];
  89. let stockOutBillType = [];
  90. let stockMoveBillType = [];
  91. try{
  92. stockInBillType = JSON.parse(uni.getStorageSync('stockInBillType')).map(item => ({
  93. icon:'iconruku',
  94. text: item.billTypeName,
  95. navUrl: '/pages/menu/stockIn/index?ywlx=' + item.billTypeCode
  96. }));
  97. stockOutBillType = JSON.parse(uni.getStorageSync('stockOutBillType')).map(item => ({
  98. icon:'iconchuku',
  99. text: item.billTypeName,
  100. navUrl: '/pages/menu/stockOut/index?ywlx=' + item.billTypeCode
  101. }));
  102. stockMoveBillType = JSON.parse(uni.getStorageSync('stockMoveBillType')).map(item => ({
  103. icon:'icont-icon-svg-08',
  104. text: item.billTypeName,
  105. navUrl: '/pages/menu/stockMove/index?ywlx=' + item.billTypeCode
  106. }));
  107. }catch(e){
  108. stockInBillType = [{ icon:'iconruku', text: '入库单', navUrl:'/pages/menu/stockIn/index' }];
  109. stockOutBillType = [{ icon:'iconchuku', text: '出库单', navUrl:'/pages/menu/stockOut/index' }];
  110. stockMoveBillType = [{ icon:'icont-icon-svg-08', text: '移位单', navUrl:'/pages/menu/stockMove/index' }];
  111. }
  112. this.inGirdList = stockInBillType;
  113. this.outGirdList = stockOutBillType;
  114. this.moveGirdList = stockMoveBillType;
  115. //this.girdList = [ ...stockInBillType, ...stockOutBillType, ...this.otherGirdList ]
  116. //console.log(this.girdList);
  117. },
  118. methods: {
  119. navClick(path) {
  120. if (this.isNavigating) {
  121. // 如果正在导航,则不执行任何操作
  122. return;
  123. }
  124. this.isNavigating = true; // 设置正在导航状态
  125. uni.navigateTo({
  126. url: path,
  127. success: () => {
  128. // 导航成功,可以在这里做一些操作,比如发送全局事件等
  129. this.isNavigating = false; // 重置导航状态
  130. },
  131. fail: () => {
  132. // 导航失败,同样重置导航状态
  133. this.isNavigating = false;
  134. }
  135. });
  136. },
  137. toggleDisplayMode(){//切换用九宫格还是分组标签
  138. this.displayMode = !this.displayMode
  139. uni.setStorageSync('menuDisplayMode', this.displayMode)
  140. },
  141. },
  142. onLoad: function (options) {
  143. this.$nextTick(() => {
  144. this.title = "菜单("+ uni.getStorageSync('name') +")";
  145. });
  146. },
  147. computed: {
  148. girdListSetOf(){ //数据合集
  149. return [...this.inGirdList, ...this.outGirdList, ...this.moveGirdList, ...this.girdList]
  150. },
  151. girdListSetGroupOf() { //数据分组合集
  152. return [
  153. {"name" : "WMS","girdList" : this.girdList, "type" : "primary"},
  154. {"name" : "入库","girdList" : this.inGirdList, "type" : "success"},
  155. {"name" : "出库","girdList" : this.outGirdList, "type" : "warning"},
  156. {"name" : "移位","girdList" : this.moveGirdList, "type" : "error"},
  157. ]
  158. },
  159. rightIcon(){
  160. return this.displayMode ? 'list' : 'more-filled'
  161. },
  162. },
  163. }
  164. </script>
  165. <style>
  166. /* #ifndef APP-NVUE */
  167. page {
  168. display: flex;
  169. flex-direction: column;
  170. box-sizing: border-box;
  171. background-color: #fff;
  172. min-height: 100%;
  173. height: auto;
  174. }
  175. view {
  176. font-size: 16px;
  177. line-height: inherit;
  178. }
  179. /* #endif */
  180. .grid-item-box {
  181. flex: 1;
  182. /* #ifndef APP-NVUE */
  183. display: flex;
  184. /* #endif */
  185. flex-direction: column;
  186. align-items: center;
  187. justify-content: center;
  188. padding: 15px 0;
  189. }
  190. .image {
  191. width: 25px;
  192. height: 25px;
  193. }
  194. .text {
  195. font-size: 16px;
  196. margin-top: 10px;
  197. }
  198. .t-icon {
  199. display: inline-block;
  200. width: 2rem;
  201. height: 2rem;
  202. background-repeat: no-repeat;
  203. background-position: center;
  204. background-size: 100%;
  205. }
  206. .example-body {
  207. display: flex; /* 使用 Flexbox */
  208. flex-wrap: wrap; /* 允许子元素换行 */
  209. align-items: center; /* 垂直居中对齐 */
  210. }
  211. .tag-view {
  212. display: flex; /* 使用 Flexbox */
  213. flex-wrap: wrap; /* 允许子元素换行 */
  214. align-items: center; /* 垂直居中对齐 */
  215. /* 子元素之间的间距 */
  216. }
  217. </style>