index.vue 8.4 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="curSelectedTenantId" :localdata="tenantList" :clear="false" @change="handleTenantChange"></uni-data-select>
  19. </uni-section>
  20. <uni-section title="当前工段" type="square">
  21. <uni-data-select v-model="curSelectedDeptId" :localdata="userDeptsByTenantId" :clear="false" @change="handleDeptChange"></uni-data-select>
  22. </uni-section>
  23. </view>
  24. <!-- <view class="business-btn uni-row" v-if="showOther" @click="handleRecerptSfprod"><text class="label">半成品接收</text></view> -->
  25. <view class="business-btn uni-row" v-if="showOther" @click="handeleToReportHistory">
  26. <text class="label">我的报工</text>
  27. </view>
  28. <view v-if="showQuick" class="business-btn uni-row" @click="handleFastToProductionPlan">
  29. <text class="label">快速报工</text>
  30. </view>
  31. <view class="business-btn uni-row" v-if="showOther" @click="handleToProductionPlan">
  32. <text class="label">报工</text>
  33. </view>
  34. <!-- v-hasRoles="['porter']" 可通过v-Roles自定义指令进行显隐 -->
  35. <view class="business-btn uni-row" v-if="showTurn" @click="handleToHandlingList">
  36. <text class="label">周转</text>
  37. </view>
  38. <view class="bottom-btn-container">
  39. <!-- <view class="start-batch-btn uni-row" @click="handleToEquiPmentList"><text class="label">绑定设备</text></view> -->
  40. <view class="start-batch-btn uni-row" @click="handleSwitchOrQuit">
  41. <text class="label">切换 / 退出账号</text>
  42. </view>
  43. </view>
  44. </view>
  45. <dialog-confirm ref="confirm" @submit="logout"></dialog-confirm>
  46. </template>
  47. <script setup>
  48. import {
  49. ref
  50. } from 'vue'
  51. import {
  52. onLoad,
  53. onReady
  54. } from '@dcloudio/uni-app'
  55. import {
  56. getSubPlanDetailsList
  57. } from '../../api/business/subPlanDetails'
  58. import {
  59. getTenantList,
  60. } from '@/api/login/index.js'
  61. import {
  62. getUserDeptList
  63. } from '@/api/dept/dept.js'
  64. import {
  65. store
  66. } from '@/store/index.js'
  67. const userName = ref('') // 用户名
  68. const curSelectedDeptId = ref(null) // 用户当前选择的工段
  69. const curSelectedTenantId = ref(null) // 用户当前选择的厂别
  70. const userInfo = ref({}) // 用户信息
  71. const tenantList = ref([]) // 厂别列表
  72. const userDeptList = ref([]) // 用户所在所有工段列表
  73. const userDeptsByTenantId = ref([])
  74. const confirm = ref(null) // 确认组件
  75. const showTurn = ref(false)
  76. const showOther = ref(false)
  77. const showQuick = ref(false)
  78. onLoad(() => {
  79. userInfo.value = store.userInfo || {
  80. nickName: ""
  81. };
  82. store.tenantId = userInfo.value.tenantId;
  83. if (store.userInfo.roles.some(item => item.roleId == 124) && store.userInfo.roles.length > 1) {
  84. showTurn.value = true;
  85. showOther.value = true;
  86. } else if (store.userInfo.roles.some(item => item.roleId == 124) && store.userInfo.roles.length == 1) {
  87. showTurn.value = true;
  88. showOther.value = false;
  89. } else {
  90. showTurn.value = false;
  91. showOther.value = true;
  92. }
  93. init();
  94. })
  95. /******************************** 定义一些方法 ********************************/
  96. function init() {
  97. getTenant();
  98. getUserDepts(store.userInfo.userId, store.tenantId);
  99. //getUserDeptsByTenantId(store.tenantId);
  100. }
  101. // 获取租户列表
  102. function getTenant() {
  103. getTenantList().then((res) => {
  104. if (res.code == 200) {
  105. for (var i = 0; i < res.rows.length; i++) {
  106. tenantList.value[i] = {
  107. text: res.rows[i].orgName,
  108. value: res.rows[i].id
  109. }
  110. }
  111. curSelectedTenantId.value = store.userInfo.tenantId;
  112. }
  113. })
  114. }
  115. // 获取人员工段
  116. function getUserDepts(userId, tenantId) {
  117. userDeptsByTenantId.value = []
  118. getUserDeptList(userId).then((res) => {
  119. if (res.code == 200) {
  120. userDeptList.value = res.data;
  121. for (let i = 0; i < res.data.length; i++) {
  122. if (res.data[i].tenantId == tenantId) {
  123. userDeptsByTenantId.value[i] = {
  124. text: res.data[i].deptName,
  125. value: res.data[i].deptId
  126. }
  127. }
  128. }
  129. if (res.data.some(v => v.hasQuick === 1)) {
  130. showQuick.value = true
  131. } else {
  132. showQuick.value = false
  133. }
  134. }
  135. })
  136. }
  137. // 根据租户id获取到工段
  138. function getUserDeptsByTenantId(tenantId) {
  139. userDeptsByTenantId.value = [];
  140. let newArr = userDeptList.value.filter((item, index, arrs) => item.tenantId == tenantId);
  141. for (var i = 0; i < newArr.length; i++) {
  142. userDeptsByTenantId.value[i] = {
  143. text: newArr[i].deptName,
  144. value: newArr[i].deptId
  145. }
  146. }
  147. }
  148. /*
  149. // 半成品接收
  150. function handleRecerptSfprod() {
  151. if (curSelectedDeptId.value) {
  152. uni.navigateTo({
  153. url: '/pages/recerptSfprod/index'
  154. })
  155. } else {
  156. uni.showToast({
  157. icon: "none",
  158. title: "请选择工段"
  159. })
  160. }
  161. }
  162. */
  163. function handeleToReportHistory() {
  164. uni.navigateTo({
  165. url: '/pages/reportHistory/index'
  166. })
  167. }
  168. function handleFastToProductionPlan() {
  169. if (curSelectedDeptId.value) {
  170. uni.navigateTo({
  171. url: '/pages/fastProductionPlan/index'
  172. })
  173. } else {
  174. uni.showToast({
  175. icon: "none",
  176. title: "请选择工段"
  177. })
  178. }
  179. }
  180. function handleToProductionPlan() {
  181. if (curSelectedDeptId.value) {
  182. uni.navigateTo({
  183. url: '/pages/productionPlan/index'
  184. })
  185. } else {
  186. uni.showToast({
  187. icon: "none",
  188. title: "请选择工段"
  189. })
  190. }
  191. }
  192. function handleToHandlingList() {
  193. console.log(store)
  194. uni.navigateTo({
  195. url: '/pages/handlingList/index'
  196. })
  197. }
  198. function logout() {
  199. uni.reLaunch({
  200. url: '/pages/index/index'
  201. })
  202. }
  203. function handleSwitchOrQuit() {
  204. let msg = "确认退出登录吗?"
  205. confirm.value.open(msg);
  206. }
  207. /*
  208. // 绑定设备
  209. function handleToEquiPmentList() {
  210. uni.navigateTo({
  211. url: "/pages/equipmentList/index"
  212. })
  213. }
  214. */
  215. function handleTenantChange() {
  216. console.log(curSelectedTenantId)
  217. store.tenantId = curSelectedTenantId.value
  218. curSelectedDeptId.value = null
  219. getUserDeptsByTenantId(store.tenantId)
  220. }
  221. function handleDeptChange() {
  222. let curDept = userDeptList.value.find(item => item.deptId === curSelectedDeptId.value)
  223. store.curDeptDetails = curDept
  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>