index.vue 8.5 KB

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