index.vue 9.2 KB

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