index.vue 9.9 KB

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