index.vue 8.3 KB

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