index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. console.log(curSelectedTenant.value)
  155. }
  156. })
  157. }
  158. function handleTenantChange() {
  159. store.tenantId = curSelectedTenant.value;
  160. getDeptsByTenantId(store.tenantId);
  161. }
  162. function handleDeptChange() {
  163. store.curDeptDetails = curSelectedDept.value;
  164. }
  165. </script>
  166. <style lang="scss">
  167. .page-container {
  168. height: calc(100% - 208rpx);
  169. overflow: auto;
  170. }
  171. .logo-container {
  172. justify-content: center;
  173. .logo {
  174. width: 120rpx;
  175. height: 120rpx;
  176. }
  177. }
  178. .title {
  179. align-items: center;
  180. .label {
  181. font-size: 40rpx;
  182. font-weight: bold;
  183. }
  184. }
  185. .user-info-container {
  186. margin: 16rpx 0 20rpx 20rpx;
  187. align-items: center;
  188. .icon {
  189. width: 120rpx;
  190. height: 120rpx;
  191. justify-content: center;
  192. align-items: center;
  193. border-radius: 60rpx;
  194. border: 1px solid #e1e1e1;
  195. .label {
  196. font-size: 64rpx;
  197. }
  198. }
  199. .user-info {
  200. box-sizing: border-box;
  201. padding-top: 8rpx;
  202. margin-left: 24rpx;
  203. justify-content: center;
  204. // font-size: 20rpx;
  205. .nickname {
  206. margin-bottom: 16rpx;
  207. .label {
  208. font-weight: bold;
  209. font-size: 32rpx;
  210. }
  211. }
  212. .process {
  213. .label {
  214. font-size: 32rpx;
  215. }
  216. }
  217. }
  218. .data-select {
  219. flex: 3;
  220. width: 100%;
  221. height: 50rpx;
  222. border-radius: 18rpx;
  223. background-color: #FFF;
  224. .data-select-options {
  225. width: 200rpx;
  226. }
  227. }
  228. }
  229. .business-btn {
  230. margin: 0 20rpx 20rpx 20rpx;
  231. background-color: #fff;
  232. height: 200rpx;
  233. width: 94%;
  234. align-items: center;
  235. justify-content: center;
  236. border: 1rpx solid #e1e1e1;
  237. border-radius: 8rpx;
  238. .label {
  239. font-size: 40rpx;
  240. }
  241. }
  242. .bottom-btn-container {
  243. position: fixed;
  244. right: 20rpx;
  245. bottom: 0;
  246. left: 20rpx;
  247. .start-batch-btn {
  248. // background-color: grey;
  249. background-color: #1684fc;
  250. margin-bottom: 24rpx;
  251. border-radius: 8rpx;
  252. justify-content: center;
  253. align-items: center;
  254. height: 80rpx;
  255. .label {
  256. font-size: 32rpx;
  257. color: #ffffff;
  258. }
  259. }
  260. }
  261. </style>