index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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" v-if="showOther" @click="handleRecerptSfprod"><text class="label">半成品接收</text></view>
  27. <view class="business-btn uni-row" v-if="showOther" @click="handleToProductionPlan"><text class="label">报工</text></view>
  28. <view class="business-btn uni-row" v-if="showTurn" @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. const showTurn = ref(false)
  66. const showOther = ref(false)
  67. onLoad(() => {
  68. userInfo.value = store.userInfo || {
  69. nickName: ""
  70. };getUserDepts
  71. store.tenantId = userInfo.value.tenantId;
  72. if(store.userInfo.roles.some(item => item.roleId == 124) && store.userInfo.roles.length > 1){
  73. showTurn.value = true;
  74. showOther.value = true;
  75. }else if(store.userInfo.roles.some(item => item.roleId == 124) && store.userInfo.roles.length == 1){
  76. showTurn.value = true;
  77. showOther.value = false;
  78. }else{
  79. showTurn.value = false;
  80. showOther.value = true;
  81. }
  82. init();
  83. })
  84. function init() {
  85. getTenant();
  86. getUserDepts(store.userInfo.userId,store.tenantId);
  87. getDeptsByTenantId(store.tenantId);
  88. }
  89. function handleRecerptSfprod() {
  90. if(curSelectedDept.value){
  91. uni.navigateTo({
  92. url: '/pages/recerptSfprod/index'
  93. })
  94. }else{
  95. uni.showToast({
  96. icon: "none",
  97. title: "请选择工段"
  98. })
  99. }
  100. }
  101. function handleToProductionPlan() {
  102. if(curSelectedDept.value){
  103. uni.navigateTo({
  104. url: '/pages/productionPlan/index'
  105. })
  106. }else{
  107. uni.showToast({
  108. icon: "none",
  109. title: "请选择工段"
  110. })
  111. }
  112. }
  113. function handleToHandlingList() {
  114. uni.navigateTo({
  115. url: '/pages/handlingList/index'
  116. })
  117. }
  118. function logout() {
  119. uni.reLaunch({
  120. url: '/pages/index/index'
  121. })
  122. }
  123. function handleSwitchOrQuit() {
  124. let msg = "确认退出登录吗?"
  125. confirm.value.open(msg);
  126. }
  127. function handleToEquiPmentList() {
  128. uni.navigateTo({
  129. url: "/pages/equipmentList/index"
  130. })
  131. }
  132. function getUserDepts(userId,tenantId) {
  133. getUserDeptList(userId).then((res) => {
  134. if (res.code == 200) {
  135. userDeptList.value = res.data;
  136. for (let i = 0; i < res.data.length; i++) {
  137. if(res.data[i].tenantId == tenantId){
  138. userDeptsByTenantId.value[i] = {
  139. text: res.data[i].deptName,
  140. value: res.data[i]
  141. }
  142. }
  143. }
  144. console.log()
  145. // 选择工段来个默认值
  146. // if(res.data.length > 0){
  147. // curSelectedDept.value = res.data[0];
  148. // }
  149. // store.curDeptDetails = curSelectedDept.value;
  150. }
  151. })
  152. }
  153. function getDeptsByTenantId(tenantId){
  154. userDeptsByTenantId.value = [];
  155. let newArr = userDeptList.value.filter((item,index,arrs) => item.tenantId == tenantId);
  156. // curSelectedDept.value = newArr.length > 0 ? newArr[0].deptId : null;
  157. for (var i = 0; i < newArr.length; i++) {
  158. userDeptsByTenantId.value[i] = {
  159. text: newArr[i].deptName,
  160. value: newArr[i]
  161. }
  162. }
  163. // if(userDeptsByTenantId.value.length == 0){
  164. // store.curDeptDetails = 0;
  165. // }else{
  166. // store.curDeptDetails = userDeptsByTenantId.value[0].value;
  167. // }
  168. console.log(userDeptsByTenantId.value);
  169. }
  170. function getTenant() {
  171. getTenantList().then((res) => {
  172. if (res.code == 200) {
  173. for (var i = 0; i < res.rows.length; i++) {
  174. tenantList.value[i] = {
  175. text: res.rows[i].orgName,
  176. value: res.rows[i].id
  177. }
  178. }
  179. curSelectedTenant.value = store.userInfo.tenantId;
  180. console.log(curSelectedTenant.value)
  181. }
  182. })
  183. }
  184. function handleTenantChange() {
  185. store.tenantId = curSelectedTenant.value;
  186. curSelectedDept.value = null;
  187. getDeptsByTenantId(store.tenantId);
  188. }
  189. function handleDeptChange() {
  190. store.curDeptDetails = curSelectedDept.value;
  191. }
  192. </script>
  193. <style lang="scss">
  194. .page-container {
  195. height: calc(100% - 208rpx);
  196. overflow: auto;
  197. }
  198. .logo-container {
  199. justify-content: center;
  200. .logo {
  201. width: 120rpx;
  202. height: 120rpx;
  203. }
  204. }
  205. .title {
  206. align-items: center;
  207. .label {
  208. font-size: 40rpx;
  209. font-weight: bold;
  210. }
  211. }
  212. .user-info-container {
  213. margin: 16rpx 0 20rpx 20rpx;
  214. align-items: center;
  215. .icon {
  216. width: 120rpx;
  217. height: 120rpx;
  218. justify-content: center;
  219. align-items: center;
  220. border-radius: 60rpx;
  221. border: 1px solid #e1e1e1;
  222. .label {
  223. font-size: 64rpx;
  224. }
  225. }
  226. .user-info {
  227. box-sizing: border-box;
  228. padding-top: 8rpx;
  229. margin-left: 24rpx;
  230. justify-content: center;
  231. // font-size: 20rpx;
  232. .nickname {
  233. margin-bottom: 16rpx;
  234. .label {
  235. font-weight: bold;
  236. font-size: 32rpx;
  237. }
  238. }
  239. .process {
  240. .label {
  241. font-size: 32rpx;
  242. }
  243. }
  244. }
  245. .data-select {
  246. flex: 3;
  247. width: 100%;
  248. height: 50rpx;
  249. border-radius: 18rpx;
  250. background-color: #FFF;
  251. .data-select-options {
  252. width: 200rpx;
  253. }
  254. }
  255. }
  256. .business-btn {
  257. margin: 0 20rpx 20rpx 20rpx;
  258. background-color: #fff;
  259. height: 200rpx;
  260. width: 94%;
  261. align-items: center;
  262. justify-content: center;
  263. border: 1rpx solid #e1e1e1;
  264. border-radius: 8rpx;
  265. .label {
  266. font-size: 40rpx;
  267. }
  268. }
  269. .bottom-btn-container {
  270. position: fixed;
  271. right: 20rpx;
  272. bottom: 0;
  273. left: 20rpx;
  274. .start-batch-btn {
  275. // background-color: grey;
  276. background-color: #1684fc;
  277. margin-bottom: 24rpx;
  278. border-radius: 8rpx;
  279. justify-content: center;
  280. align-items: center;
  281. height: 80rpx;
  282. .label {
  283. font-size: 32rpx;
  284. color: #ffffff;
  285. }
  286. }
  287. }
  288. </style>