index.vue 9.1 KB

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