index.vue 9.4 KB

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