reassignDialog.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <u-popup
  3. :show="show"
  4. mode="center"
  5. :round="10"
  6. closeable
  7. @close="cancel"
  8. bgColor="#fff"
  9. :customStyle="{ width: '85vw' }"
  10. >
  11. <view class="reassign_wrap">
  12. <view class="title">选择转派人员</view>
  13. <view class="search_row">
  14. <input class="search_ipt" v-model="kw" placeholder="搜索人员姓名" />
  15. </view>
  16. <scroll-view scroll-y class="user_list">
  17. <view
  18. v-for="item in filteredList"
  19. :key="item.id"
  20. class="user_item"
  21. :class="{ active: selectedId === item.id }"
  22. @click="selectedId = item.id"
  23. >
  24. <view class="name">{{ item.name }}</view>
  25. <view v-if="selectedId === item.id" class="check">✓</view>
  26. </view>
  27. <view v-if="!filteredList.length" class="empty">暂无人员</view>
  28. </scroll-view>
  29. <view class="btns">
  30. <button class="btn cancel" @click="cancel">取消</button>
  31. <button class="btn confirm" @click="confirm">确定</button>
  32. </view>
  33. </view>
  34. </u-popup>
  35. </template>
  36. <script>
  37. import { getteampage, transferTasks } from "@/api/pda/workReport.js";
  38. export default {
  39. data() {
  40. return {
  41. show: false,
  42. kw: "",
  43. selectedId: "",
  44. taskId: "",
  45. teamList: [],
  46. };
  47. },
  48. computed: {
  49. filteredList() {
  50. const k = (this.kw || "").trim();
  51. if (!k) return this.teamList;
  52. return this.teamList.filter((u) => (u.name || "").indexOf(k) > -1);
  53. },
  54. },
  55. methods: {
  56. async open(row) {
  57. this.taskId = row.id;
  58. this.selectedId = "";
  59. this.kw = "";
  60. this.teamList = [];
  61. this.show = true;
  62. try {
  63. const res = await getteampage({ name: row.assignTeamName });
  64. if (res && res.list && res.list[0]) {
  65. this.teamList = res.list[0].userVOList || [];
  66. }
  67. } catch (err) {
  68. uni.showToast({ title: err.message || "人员加载失败", icon: "none" });
  69. }
  70. },
  71. cancel() {
  72. this.show = false;
  73. },
  74. async confirm() {
  75. if (!this.selectedId) {
  76. return uni.showToast({ title: "请选择转派人员", icon: "none" });
  77. }
  78. const user = this.teamList.find((u) => u.id == this.selectedId);
  79. try {
  80. await transferTasks({
  81. assigneeId: user.id,
  82. assigneeName: user.name,
  83. id: this.taskId,
  84. });
  85. uni.showToast({ title: "转派成功", icon: "success" });
  86. this.$emit("success");
  87. this.cancel();
  88. } catch (err) {
  89. uni.showToast({ title: err.message || "转派失败", icon: "none" });
  90. }
  91. },
  92. },
  93. };
  94. </script>
  95. <style lang="scss" scoped>
  96. .reassign_wrap {
  97. padding: 30rpx;
  98. .title {
  99. font-size: 32rpx;
  100. font-weight: 600;
  101. text-align: center;
  102. margin-bottom: 20rpx;
  103. }
  104. .search_row {
  105. margin-bottom: 16rpx;
  106. .search_ipt {
  107. width: 100%;
  108. box-sizing: border-box;
  109. border: 1rpx solid #e0e0e0;
  110. border-radius: 6rpx;
  111. padding: 14rpx 16rpx;
  112. font-size: 26rpx;
  113. }
  114. }
  115. .user_list {
  116. max-height: 50vh;
  117. .user_item {
  118. display: flex;
  119. justify-content: space-between;
  120. align-items: center;
  121. padding: 20rpx 16rpx;
  122. border-bottom: 1rpx solid #f0f0f0;
  123. font-size: 28rpx;
  124. &.active {
  125. color: $theme-color;
  126. background: rgba(21, 122, 44, 0.06);
  127. }
  128. .check {
  129. color: $theme-color;
  130. font-weight: bold;
  131. }
  132. }
  133. .empty {
  134. text-align: center;
  135. color: #999;
  136. padding: 40rpx 0;
  137. font-size: 26rpx;
  138. }
  139. }
  140. .btns {
  141. display: flex;
  142. gap: 20rpx;
  143. margin-top: 30rpx;
  144. .btn {
  145. flex: 1;
  146. height: 80rpx;
  147. line-height: 80rpx;
  148. border-radius: 8rpx;
  149. font-size: 28rpx;
  150. }
  151. .cancel { background: #f5f5f5; color: #333; }
  152. .confirm { background: $theme-color; color: #fff; }
  153. }
  154. }
  155. </style>