index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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. console.log(res.data)
  174. if (res.data.some(v => v.hasQuick === 1)) {
  175. showQuick.value = true
  176. } else {
  177. showQuick.value = false
  178. }
  179. // 选择工段来个默认值
  180. // if(res.data.length > 0){
  181. // curSelectedDept.value = res.data[0];
  182. // }
  183. // store.curDeptDetails = curSelectedDept.value;
  184. }
  185. })
  186. }
  187. function getDeptsByTenantId(tenantId) {
  188. userDeptsByTenantId.value = [];
  189. let newArr = userDeptList.value.filter((item, index, arrs) => item.tenantId == tenantId);
  190. // curSelectedDept.value = newArr.length > 0 ? newArr[0].deptId : null;
  191. for (var i = 0; i < newArr.length; i++) {
  192. userDeptsByTenantId.value[i] = {
  193. text: newArr[i].deptName,
  194. value: newArr[i]
  195. }
  196. }
  197. // if(userDeptsByTenantId.value.length == 0){
  198. // store.curDeptDetails = 0;
  199. // }else{
  200. // store.curDeptDetails = userDeptsByTenantId.value[0].value;
  201. // }
  202. console.log(userDeptsByTenantId.value);
  203. }
  204. function getTenant() {
  205. getTenantList().then((res) => {
  206. if (res.code == 200) {
  207. for (var i = 0; i < res.rows.length; i++) {
  208. tenantList.value[i] = {
  209. text: res.rows[i].orgName,
  210. value: res.rows[i].id
  211. }
  212. }
  213. curSelectedTenant.value = store.userInfo.tenantId;
  214. console.log(curSelectedTenant.value)
  215. }
  216. })
  217. }
  218. function handleTenantChange() {
  219. store.tenantId = curSelectedTenant.value;
  220. curSelectedDept.value = null;
  221. getDeptsByTenantId(store.tenantId);
  222. }
  223. function handleDeptChange() {
  224. store.curDeptDetails = curSelectedDept.value;
  225. // console.log(store.curDeptDetails)
  226. }
  227. </script>
  228. <style lang="scss">
  229. .page-container {
  230. height: calc(100% - 208rpx);
  231. overflow: auto;
  232. }
  233. .logo-container {
  234. justify-content: center;
  235. .logo {
  236. width: 120rpx;
  237. height: 120rpx;
  238. }
  239. }
  240. .title {
  241. align-items: center;
  242. .label {
  243. font-size: 40rpx;
  244. font-weight: bold;
  245. }
  246. }
  247. .user-info-container {
  248. margin: 16rpx 0 20rpx 20rpx;
  249. align-items: center;
  250. .icon {
  251. width: 120rpx;
  252. height: 120rpx;
  253. justify-content: center;
  254. align-items: center;
  255. border-radius: 60rpx;
  256. border: 1px solid #e1e1e1;
  257. .label {
  258. font-size: 64rpx;
  259. }
  260. }
  261. .user-info {
  262. box-sizing: border-box;
  263. padding-top: 8rpx;
  264. margin-left: 24rpx;
  265. justify-content: center;
  266. // font-size: 20rpx;
  267. .nickname {
  268. margin-bottom: 16rpx;
  269. .label {
  270. font-weight: bold;
  271. font-size: 32rpx;
  272. }
  273. }
  274. .process {
  275. .label {
  276. font-size: 32rpx;
  277. }
  278. }
  279. }
  280. .data-select {
  281. flex: 3;
  282. width: 100%;
  283. height: 50rpx;
  284. border-radius: 18rpx;
  285. background-color: #FFF;
  286. .data-select-options {
  287. width: 200rpx;
  288. }
  289. }
  290. }
  291. .business-btn {
  292. margin: 0 20rpx 20rpx 20rpx;
  293. background-color: #fff;
  294. min-height: 100rpx;
  295. width: 94%;
  296. align-items: center;
  297. justify-content: center;
  298. border: 1rpx solid #e1e1e1;
  299. border-radius: 8rpx;
  300. .label {
  301. font-size: 35rpx;
  302. }
  303. }
  304. .bottom-btn-container {
  305. position: fixed;
  306. right: 20rpx;
  307. bottom: 0;
  308. left: 20rpx;
  309. .start-batch-btn {
  310. // background-color: grey;
  311. background-color: #1684fc;
  312. margin-bottom: 24rpx;
  313. border-radius: 8rpx;
  314. justify-content: center;
  315. align-items: center;
  316. height: 80rpx;
  317. .label {
  318. font-size: 32rpx;
  319. color: #ffffff;
  320. }
  321. }
  322. }
  323. </style>