index.vue 8.7 KB

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