index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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="handeleToReportHistory"><text class="label">我的报工</text></view>
  28. <view class="business-btn uni-row" v-if="showOther" @click="handleToProductionPlan"><text class="label">报工</text></view>
  29. <!-- v-hasRoles="['porter']" 可通过v-Roles自定义指令进行显隐 -->
  30. <view class="business-btn uni-row" v-if="showTurn" @click="handleToHandlingList"><text class="label">周转</text></view>
  31. <view class="bottom-btn-container">
  32. <view class="start-batch-btn uni-row" @click="handleToEquiPmentList"><text class="label">绑定设备</text></view>
  33. <view class="start-batch-btn uni-row" @click="handleSwitchOrQuit"><text class="label">切换 / 退出账号</text>
  34. </view>
  35. </view>
  36. </view>
  37. <dialog-confirm ref="confirm" @submit="logout"></dialog-confirm>
  38. </template>
  39. <script setup>
  40. import {
  41. ref
  42. } from 'vue'
  43. import {
  44. onLoad,
  45. onReady
  46. } from '@dcloudio/uni-app'
  47. import {
  48. getSubPlanDetailsList
  49. } from '../../api/business/subPlanDetails'
  50. import {
  51. getTenantList,
  52. } from '@/api/login/index.js'
  53. import {
  54. getUserDeptList
  55. } from '@/api/dept/dept.js'
  56. import {
  57. store
  58. } from '@/store/index.js'
  59. const userName = ref('') // 用户名
  60. const curSelectedDept = ref(null) // 用户当前选择的工段
  61. const curSelectedTenant = ref(null) // 用户当前选择的厂别
  62. const userInfo = ref({}) // 用户信息
  63. const tenantList = ref([]) // 厂别列表
  64. const userDeptList = ref([]) // 用户所在所有工段列表
  65. const userDeptsByTenantId = ref([])
  66. const confirm = ref(null) // 确认组件
  67. const showTurn = ref(false)
  68. const showOther = ref(false)
  69. onLoad(() => {
  70. userInfo.value = store.userInfo || {
  71. nickName: ""
  72. };getUserDepts
  73. store.tenantId = userInfo.value.tenantId;
  74. if(store.userInfo.roles.some(item => item.roleId == 124) && store.userInfo.roles.length > 1){
  75. showTurn.value = true;
  76. showOther.value = true;
  77. }else if(store.userInfo.roles.some(item => item.roleId == 124) && store.userInfo.roles.length == 1){
  78. showTurn.value = true;
  79. showOther.value = false;
  80. }else{
  81. showTurn.value = false;
  82. showOther.value = true;
  83. }
  84. init();
  85. })
  86. function init() {
  87. getTenant();
  88. getUserDepts(store.userInfo.userId,store.tenantId);
  89. getDeptsByTenantId(store.tenantId);
  90. }
  91. function handleRecerptSfprod() {
  92. if(curSelectedDept.value){
  93. uni.navigateTo({
  94. url: '/pages/recerptSfprod/index'
  95. })
  96. }else{
  97. uni.showToast({
  98. icon: "none",
  99. title: "请选择工段"
  100. })
  101. }
  102. }
  103. function handeleToReportHistory(){
  104. uni.navigateTo({
  105. url: '/pages/reportHistory/index'
  106. })
  107. }
  108. function handleToProductionPlan() {
  109. if(curSelectedDept.value){
  110. uni.navigateTo({
  111. url: '/pages/productionPlan/index'
  112. })
  113. }else{
  114. uni.showToast({
  115. icon: "none",
  116. title: "请选择工段"
  117. })
  118. }
  119. }
  120. function handleToHandlingList() {
  121. console.log(store)
  122. uni.navigateTo({
  123. url: '/pages/handlingList/index'
  124. })
  125. }
  126. function logout() {
  127. uni.reLaunch({
  128. url: '/pages/index/index'
  129. })
  130. }
  131. function handleSwitchOrQuit() {
  132. let msg = "确认退出登录吗?"
  133. confirm.value.open(msg);
  134. }
  135. function handleToEquiPmentList() {
  136. uni.navigateTo({
  137. url: "/pages/equipmentList/index"
  138. })
  139. }
  140. function getUserDepts(userId,tenantId) {
  141. getUserDeptList(userId).then((res) => {
  142. if (res.code == 200) {
  143. userDeptList.value = res.data;
  144. for (let i = 0; i < res.data.length; i++) {
  145. if(res.data[i].tenantId == tenantId){
  146. userDeptsByTenantId.value[i] = {
  147. text: res.data[i].deptName,
  148. value: res.data[i]
  149. }
  150. }
  151. }
  152. console.log()
  153. // 选择工段来个默认值
  154. // if(res.data.length > 0){
  155. // curSelectedDept.value = res.data[0];
  156. // }
  157. // store.curDeptDetails = curSelectedDept.value;
  158. }
  159. })
  160. }
  161. function getDeptsByTenantId(tenantId){
  162. userDeptsByTenantId.value = [];
  163. let newArr = userDeptList.value.filter((item,index,arrs) => item.tenantId == tenantId);
  164. // curSelectedDept.value = newArr.length > 0 ? newArr[0].deptId : null;
  165. for (var i = 0; i < newArr.length; i++) {
  166. userDeptsByTenantId.value[i] = {
  167. text: newArr[i].deptName,
  168. value: newArr[i]
  169. }
  170. }
  171. // if(userDeptsByTenantId.value.length == 0){
  172. // store.curDeptDetails = 0;
  173. // }else{
  174. // store.curDeptDetails = userDeptsByTenantId.value[0].value;
  175. // }
  176. console.log(userDeptsByTenantId.value);
  177. }
  178. function getTenant() {
  179. getTenantList().then((res) => {
  180. if (res.code == 200) {
  181. for (var i = 0; i < res.rows.length; i++) {
  182. tenantList.value[i] = {
  183. text: res.rows[i].orgName,
  184. value: res.rows[i].id
  185. }
  186. }
  187. curSelectedTenant.value = store.userInfo.tenantId;
  188. console.log(curSelectedTenant.value)
  189. }
  190. })
  191. }
  192. function handleTenantChange() {
  193. store.tenantId = curSelectedTenant.value;
  194. curSelectedDept.value = null;
  195. getDeptsByTenantId(store.tenantId);
  196. }
  197. function handleDeptChange() {
  198. store.curDeptDetails = curSelectedDept.value;
  199. }
  200. </script>
  201. <style lang="scss">
  202. .page-container {
  203. height: calc(100% - 208rpx);
  204. overflow: auto;
  205. }
  206. .logo-container {
  207. justify-content: center;
  208. .logo {
  209. width: 120rpx;
  210. height: 120rpx;
  211. }
  212. }
  213. .title {
  214. align-items: center;
  215. .label {
  216. font-size: 40rpx;
  217. font-weight: bold;
  218. }
  219. }
  220. .user-info-container {
  221. margin: 16rpx 0 20rpx 20rpx;
  222. align-items: center;
  223. .icon {
  224. width: 120rpx;
  225. height: 120rpx;
  226. justify-content: center;
  227. align-items: center;
  228. border-radius: 60rpx;
  229. border: 1px solid #e1e1e1;
  230. .label {
  231. font-size: 64rpx;
  232. }
  233. }
  234. .user-info {
  235. box-sizing: border-box;
  236. padding-top: 8rpx;
  237. margin-left: 24rpx;
  238. justify-content: center;
  239. // font-size: 20rpx;
  240. .nickname {
  241. margin-bottom: 16rpx;
  242. .label {
  243. font-weight: bold;
  244. font-size: 32rpx;
  245. }
  246. }
  247. .process {
  248. .label {
  249. font-size: 32rpx;
  250. }
  251. }
  252. }
  253. .data-select {
  254. flex: 3;
  255. width: 100%;
  256. height: 50rpx;
  257. border-radius: 18rpx;
  258. background-color: #FFF;
  259. .data-select-options {
  260. width: 200rpx;
  261. }
  262. }
  263. }
  264. .business-btn {
  265. margin: 0 20rpx 20rpx 20rpx;
  266. background-color: #fff;
  267. height: 200rpx;
  268. width: 94%;
  269. align-items: center;
  270. justify-content: center;
  271. border: 1rpx solid #e1e1e1;
  272. border-radius: 8rpx;
  273. .label {
  274. font-size: 40rpx;
  275. }
  276. }
  277. .bottom-btn-container {
  278. position: fixed;
  279. right: 20rpx;
  280. bottom: 0;
  281. left: 20rpx;
  282. .start-batch-btn {
  283. // background-color: grey;
  284. background-color: #1684fc;
  285. margin-bottom: 24rpx;
  286. border-radius: 8rpx;
  287. justify-content: center;
  288. align-items: center;
  289. height: 80rpx;
  290. .label {
  291. font-size: 32rpx;
  292. color: #ffffff;
  293. }
  294. }
  295. }
  296. </style>