kechengBind.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <view class="admin-jiazheng-list">
  3. <view class="icon-title-navBar-box">
  4. <view @click="goUpPage" class="nav-bar-icon"></view>
  5. <text class="nav-bar-title">家政人员</text>
  6. </view>
  7. <v-tabs v-model="current" :tabs="tabs" :scroll="false" @change="changeTab" field="name"
  8. class="admin-tab-box"></v-tabs>
  9. <uni-list v-if="current ==0" class="jz-scroll-view">
  10. <uni-list-item v-for="item in list" class="jz-list-item-box">
  11. <template v-slot:body>
  12. <view class="card-head-row">
  13. <button type="default" class="phone-green-btn bz-tel-btn" @click.stop="toAdd(item)">添加</button>
  14. </view>
  15. <view @click="lookUserInfo(item)" class="card-body-row">
  16. <view class="card-img-box">
  17. <img :src="item.pic" v-if="item.pic">
  18. <icon class="phone-default-userImg" v-else></icon>
  19. </view>
  20. <view class="body-content-row">
  21. <view class="content-text-row">
  22. <view> {{item.name}}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. </uni-list-item>
  28. </uni-list>
  29. <uni-list v-if="current ==1" class="jz-scroll-view">
  30. <uni-list-item v-for="item in listYx" class="jz-list-item-box">
  31. <template v-slot:body>
  32. <view class="card-head-row">
  33. <button type="default" class="phone-green-btn bz-tel-btn"
  34. @click.stop="toDelete(item)">删除</button>
  35. </view>
  36. <view @click="lookUserInfo(item)" class="card-body-row">
  37. <view class="card-img-box">
  38. <img :src="item.pic" v-if="item.pic">
  39. <icon class="phone-default-userImg" v-else></icon>
  40. </view>
  41. <view class="body-content-row">
  42. <view class="content-text-row">
  43. <view> {{item.name}}</view>
  44. </view>
  45. </view>
  46. </view>
  47. </template>
  48. </uni-list-item>
  49. </uni-list>
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. ref
  55. } from "vue";
  56. import {
  57. kcSelectList,
  58. jiazhengKcList,
  59. jiazhengKcAdd,
  60. jiazhengKcDelete
  61. } from "@/api/jiazheng.js";
  62. import commonDialog from '@/components/dialog/commonDialog.vue';
  63. export default {
  64. data() {
  65. return {
  66. kcClassifyId: 0,
  67. id: '',
  68. current: 0,
  69. list: [],
  70. listYx: [],
  71. tabs: [{
  72. id: 1,
  73. name: '未绑定课程',
  74. },
  75. {
  76. id: 2,
  77. name: '已绑定课程',
  78. },
  79. ],
  80. }
  81. },
  82. components: {
  83. commonDialog,
  84. },
  85. onLoad(options) {
  86. this.id = options.id
  87. this.getList()
  88. },
  89. methods: {
  90. toAdd(data) {
  91. let req = {
  92. kcIds: [data.kcId],
  93. id: this.id
  94. }
  95. jiazhengKcAdd(req).then(res => {
  96. if (res.code == 0) {
  97. this.getList()
  98. uni.showToast({
  99. title: '添加成功',
  100. icon: 'success'
  101. });
  102. } else {
  103. return false
  104. }
  105. })
  106. },
  107. toDelete(data) {
  108. let req = {
  109. kcId: data.kcId,
  110. id: this.id
  111. }
  112. jiazhengKcDelete(req).then(res => {
  113. if (res.code == 0) {
  114. this.getYxList()
  115. uni.showToast({
  116. title: '删除成功',
  117. icon: 'success'
  118. });
  119. } else {
  120. return false
  121. }
  122. })
  123. },
  124. changeTab(data) {
  125. this.current = data
  126. if (this.current == 0) {
  127. this.getList()
  128. } else {
  129. this.getYxList()
  130. }
  131. console.log('data', data);
  132. },
  133. goUpPage() {
  134. uni.redirectTo({
  135. url: "/pages/admin/Jiazheng/index"
  136. })
  137. },
  138. getList() {
  139. let req = {
  140. id: this.id,
  141. "kcClassifyId": this.kcClassifyId,
  142. }
  143. kcSelectList(req).then(res => {
  144. if (res.code == 0) {
  145. this.list = res.data
  146. } else {
  147. return false
  148. }
  149. })
  150. },
  151. getYxList() {
  152. let req = {
  153. id: this.id,
  154. }
  155. jiazhengKcList(req).then(res => {
  156. if (res.code == 0) {
  157. this.listYx = res.data
  158. } else {
  159. return false
  160. }
  161. })
  162. }
  163. }
  164. }
  165. </script>