index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <view class="page-container uni-column">
  3. <view class="logo-container uni-row">
  4. <image class="logo" src="../../static/images/logo.png" />
  5. </view>
  6. <view class="title"><text class="label">德迈仕数字生产线管理平台</text></view>
  7. <view class="user-info-container uni-row">
  8. <view class="icon"><text class="label">{{ userInfo.nickName.charAt(0) }}</text></view>
  9. <view class="user-info uni-column">
  10. <view class="nickname uni-row"><text class="label">用户名: {{ userInfo.userName }}</text></view>
  11. <view class="nickname uni-row"><text class="label">ID:{{ userInfo.userId }}</text></view>
  12. <!-- <view class="process uni-row"><text class="label">当前工段:</text><text class="label">{{ deptName }}</text> -->
  13. <!-- </view> -->
  14. </view>
  15. </view>
  16. <view class="user-info uni-column" style="margin: 0 20rpx 20rpx 20rpx;width: 94%;">
  17. <uni-section title="当前厂别" type="square">
  18. <uni-data-select v-model="curSelectedTenant" :localdata="tenantList" :clear="false"
  19. @change="handleTenantChange"></uni-data-select>
  20. </uni-section>
  21. <uni-section title="当前工段" type="square">
  22. <uni-data-select v-model="curSelectedDept" :localdata="userDeptsByTenantId" :clear="false"
  23. @change="handleDeptChange"></uni-data-select>
  24. </uni-section>
  25. </view>
  26. <view class="business-btn uni-row" @click="handleRecerptSfprod"><text class="label">半成品接收</text></view>
  27. <view class="business-btn uni-row" @click="handleToProductionPlan"><text class="label">报工</text></view>
  28. <view class="business-btn uni-row" @click="handleToHandlingList"><text class="label">周转</text></view>
  29. <view class="bottom-btn-container">
  30. <view class="start-batch-btn uni-row" @click="handleToEquiPmentList"><text class="label">绑定设备</text></view>
  31. <view class="start-batch-btn uni-row" @click="handleSwitchOrQuit"><text class="label">切换 / 退出账号</text>
  32. </view>
  33. </view>
  34. </view>
  35. <dialog-confirm ref="confirm" @submit="logout"></dialog-confirm>
  36. </template>
  37. <script setup>
  38. import {
  39. ref
  40. } from 'vue'
  41. import {
  42. onLoad,
  43. onReady
  44. } from '@dcloudio/uni-app'
  45. import {
  46. getSubPlanDetailsList
  47. } from '../../api/business/subPlanDetails'
  48. import {
  49. getTenantList,
  50. } from '@/api/login/index.js'
  51. import {
  52. getUserDeptList
  53. } from '@/api/dept/dept.js'
  54. import {
  55. store
  56. } from '@/store/index.js'
  57. const userName = ref('') // 用户名
  58. const curSelectedDept = ref(null) // 用户当前选择的工段
  59. const curSelectedTenant = ref(null) // 用户当前选择的厂别
  60. const userInfo = ref({}) // 用户信息
  61. const tenantList = ref([]) // 厂别列表
  62. const userDeptList = ref([]) // 用户所在所有工段列表
  63. const userDeptsByTenantId = ref([])
  64. const confirm = ref(null) // 确认组件
  65. onLoad(() => {
  66. userInfo.value = store.userInfo || {
  67. nickName: ""
  68. };getUserDepts
  69. store.tenantId = userInfo.value.tenantId;
  70. init();
  71. })
  72. function init() {
  73. getTenant();
  74. getUserDepts(store.userInfo.userId,store.tenantId);
  75. getDeptsByTenantId(store.tenantId);
  76. }
  77. function handleRecerptSfprod() {
  78. uni.navigateTo({
  79. url: '/pages/recerptSfprod/index'
  80. })
  81. }
  82. function handleToProductionPlan() {
  83. uni.navigateTo({
  84. url: '/pages/productionPlan/index'
  85. })
  86. }
  87. function handleToHandlingList() {
  88. uni.navigateTo({
  89. url: '/pages/handlingList/index'
  90. })
  91. }
  92. function logout() {
  93. uni.reLaunch({
  94. url: '/pages/index/index'
  95. })
  96. }
  97. function handleSwitchOrQuit() {
  98. let msg = "确认退出登录吗?"
  99. confirm.value.open(msg);
  100. }
  101. function handleToEquiPmentList() {
  102. uni.navigateTo({
  103. url: "/pages/equipmentList/index"
  104. })
  105. }
  106. function getUserDepts(userId,tenantId) {
  107. getUserDeptList(userId).then((res) => {
  108. if (res.code == 200) {
  109. userDeptList.value = res.data;
  110. for (let i = 0; i < res.data.length; i++) {
  111. if(res.data[i].tenantId == tenantId){
  112. userDeptsByTenantId.value[i] = {
  113. text: res.data[i].deptName,
  114. value: res.data[i]
  115. }
  116. }
  117. }
  118. console.log()
  119. // 选择工段来个默认值
  120. if(res.data.length > 0){
  121. curSelectedDept.value = res.data[0];
  122. }
  123. store.curDeptDetails = curSelectedDept.value;
  124. }
  125. })
  126. }
  127. function getDeptsByTenantId(tenantId){
  128. userDeptsByTenantId.value = [];
  129. let newArr = userDeptList.value.filter((item,index,arrs) => item.tenantId == tenantId);
  130. curSelectedDept.value = newArr.length > 0 ? newArr[0].deptId : null;
  131. for (var i = 0; i < newArr.length; i++) {
  132. userDeptsByTenantId.value[i] = {
  133. text: newArr[i].deptName,
  134. value: newArr[i]
  135. }
  136. }
  137. if(userDeptsByTenantId.value.length == 0){
  138. store.curDeptDetails = 0;
  139. }else{
  140. store.curDeptDetails = userDeptsByTenantId.value[0].value;
  141. }
  142. console.log(userDeptsByTenantId.value);
  143. }
  144. function getTenant() {
  145. getTenantList().then((res) => {
  146. if (res.code == 200) {
  147. for (var i = 0; i < res.rows.length; i++) {
  148. tenantList.value[i] = {
  149. text: res.rows[i].orgName,
  150. value: res.rows[i].id
  151. }
  152. }
  153. curSelectedTenant.value = store.userInfo.tenantId;
  154. }
  155. })
  156. }
  157. function handleTenantChange() {
  158. store.tenantId = curSelectedTenant.value;
  159. getDeptsByTenantId(store.tenantId);
  160. }
  161. function handleDeptChange() {
  162. store.curDeptDetails = curSelectedDept.value;
  163. }
  164. </script>
  165. <style lang="scss">
  166. .page-container {
  167. height: calc(100% - 208rpx);
  168. overflow: auto;
  169. }
  170. .logo-container {
  171. justify-content: center;
  172. .logo {
  173. width: 120rpx;
  174. height: 120rpx;
  175. }
  176. }
  177. .title {
  178. align-items: center;
  179. .label {
  180. font-size: 40rpx;
  181. font-weight: bold;
  182. }
  183. }
  184. .user-info-container {
  185. margin: 16rpx 0 20rpx 20rpx;
  186. align-items: center;
  187. .icon {
  188. width: 120rpx;
  189. height: 120rpx;
  190. justify-content: center;
  191. align-items: center;
  192. border-radius: 60rpx;
  193. border: 1px solid #e1e1e1;
  194. .label {
  195. font-size: 64rpx;
  196. }
  197. }
  198. .user-info {
  199. box-sizing: border-box;
  200. padding-top: 8rpx;
  201. margin-left: 24rpx;
  202. justify-content: center;
  203. // font-size: 20rpx;
  204. .nickname {
  205. margin-bottom: 16rpx;
  206. .label {
  207. font-weight: bold;
  208. font-size: 32rpx;
  209. }
  210. }
  211. .process {
  212. .label {
  213. font-size: 32rpx;
  214. }
  215. }
  216. }
  217. .data-select {
  218. flex: 3;
  219. width: 100%;
  220. height: 50rpx;
  221. border-radius: 18rpx;
  222. background-color: #FFF;
  223. .data-select-options {
  224. width: 200rpx;
  225. }
  226. }
  227. }
  228. .business-btn {
  229. margin: 0 20rpx 20rpx 20rpx;
  230. background-color: #fff;
  231. height: 200rpx;
  232. width: 94%;
  233. align-items: center;
  234. justify-content: center;
  235. border: 1rpx solid #e1e1e1;
  236. border-radius: 8rpx;
  237. .label {
  238. font-size: 40rpx;
  239. }
  240. }
  241. .bottom-btn-container {
  242. position: fixed;
  243. right: 20rpx;
  244. bottom: 0;
  245. left: 20rpx;
  246. .start-batch-btn {
  247. // background-color: grey;
  248. background-color: #1684fc;
  249. margin-bottom: 24rpx;
  250. border-radius: 8rpx;
  251. justify-content: center;
  252. align-items: center;
  253. height: 80rpx;
  254. .label {
  255. font-size: 32rpx;
  256. color: #ffffff;
  257. }
  258. }
  259. }
  260. </style>