index.vue 9.3 KB

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