kechengBind.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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. <view @click.stop="clickAlltype" class="select-item-box">
  11. <text>{{leixing}}</text>
  12. <icon class="select-jt-default" />
  13. </view>
  14. <uni-list-item v-for="item in list" class="jz-list-item-box">
  15. <template v-slot:body>
  16. <view class="card-head-row">
  17. <button type="default" class="phone-green-btn bz-tel-btn" @click.stop="toAdd(item)">添加</button>
  18. </view>
  19. <view @click="lookUserInfo(item)" class="card-body-row">
  20. <view class="card-img-box">
  21. <img :src="item.pic" v-if="item.pic">
  22. <icon class="phone-default-userImg" v-else></icon>
  23. </view>
  24. <view class="body-content-row">
  25. <view class="content-text-row">
  26. <view> {{item.name}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. </template>
  31. </uni-list-item>
  32. </uni-list>
  33. <uni-list v-if="current ==1" class="jz-scroll-view">
  34. <uni-list-item v-for="item in listYx" class="jz-list-item-box">
  35. <template v-slot:body>
  36. <view class="card-head-row">
  37. <button type="default" class="phone-green-btn bz-tel-btn"
  38. @click.stop="toDelete(item)">删除</button>
  39. </view>
  40. <view @click="lookUserInfo(item)" class="card-body-row">
  41. <view class="card-img-box">
  42. <img :src="item.pic" v-if="item.pic">
  43. <icon class="phone-default-userImg" v-else></icon>
  44. </view>
  45. <view class="body-content-row">
  46. <view class="content-text-row">
  47. <view> {{item.name}}</view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. </uni-list-item>
  53. </uni-list>
  54. <common-dialog ref="commonDialogRef" :title="deleteTitle" :content="deleteConcent"
  55. @confirm-btn="deleteQuerenBtn"></common-dialog>
  56. <kechengLeixingVue ref="kclxRef" @select="handleSelectLeixing" @reset="handleResetLeixing"></kechengLeixingVue>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. ref
  62. } from "vue";
  63. import {
  64. kcSelectList,
  65. jiazhengKcList,
  66. jiazhengKcAdd,
  67. jiazhengKcDelete,
  68. getAdminClassify
  69. } from "@/api/jiazheng.js";
  70. import commonDialog from '@/components/dialog/commonDialog.vue';
  71. import kechengLeixingVue from "./common/kechengLeixing.vue";
  72. export default {
  73. data() {
  74. return {
  75. leixing: '全部类型',
  76. leixingList: [],
  77. selectClassify:null,
  78. kcClassifyId: 0,
  79. id: '',
  80. current: 0,
  81. list: [],
  82. listYx: [],
  83. deleteTitle :'删除',
  84. kcId :'',
  85. deleteConcent :'你确定要执行这个操作吗',
  86. tabs: [{
  87. id: 1,
  88. name: '未绑定课程',
  89. },
  90. {
  91. id: 2,
  92. name: '已绑定课程',
  93. },
  94. ],
  95. }
  96. },
  97. components: {
  98. commonDialog,
  99. kechengLeixingVue
  100. },
  101. onLoad(options) {
  102. this.id = options.id
  103. this.getList()
  104. this.getKechengClassify()
  105. },
  106. methods: {
  107. handleResetLeixing() {
  108. this.selectClassify = null;
  109. this.leixing = '全部类型';
  110. this.getList()
  111. },
  112. handleSelectLeixing(item) {
  113. this.leixing = item.lable;
  114. this.selectClassify = item;
  115. this.getList()
  116. },
  117. clickAlltype(){
  118. this.$refs.kclxRef.showPopup({
  119. data: this.leixingList
  120. })
  121. },
  122. getKechengClassify(){
  123. getAdminClassify().then(res => {
  124. res.data.children.forEach(item => {
  125. item.checked = false;
  126. })
  127. this.leixingList = res.data.children || [];
  128. })
  129. },
  130. toAdd(data) {
  131. let req = {
  132. kcIds: [data.kcId],
  133. id: this.id
  134. }
  135. jiazhengKcAdd(req).then(res => {
  136. if (res.code == 0) {
  137. this.getList()
  138. uni.showToast({
  139. title: '添加成功',
  140. icon: 'success'
  141. });
  142. } else {
  143. uni.showToast({
  144. title: '添加失败',
  145. icon: 'success'
  146. });
  147. return false
  148. }
  149. })
  150. },
  151. deleteQuerenBtn(){
  152. let req = {
  153. kcId: this.kcId,
  154. id: this.id
  155. }
  156. jiazhengKcDelete(req).then(res => {
  157. if (res.code == 0) {
  158. this.getYxList()
  159. uni.showToast({
  160. title: '删除成功',
  161. icon: 'success'
  162. });
  163. } else {
  164. uni.showToast({
  165. title: '删除失败',
  166. icon: 'success'
  167. });
  168. return false
  169. }
  170. })
  171. },
  172. toDelete(data) {
  173. this.kcId = data.kcId
  174. this.$refs.commonDialogRef.handleShow();
  175. },
  176. changeTab(data) {
  177. this.current = data
  178. if (this.current == 0) {
  179. this.getList()
  180. } else {
  181. this.getYxList()
  182. }
  183. console.log('data', data);
  184. },
  185. goUpPage() {
  186. uni.redirectTo({
  187. url: "/pages/admin/Jiazheng/index"
  188. })
  189. },
  190. getList() {
  191. let req = {
  192. id: this.id,
  193. "kcClassifyId": this.selectClassify && this.selectClassify.id || 0,
  194. }
  195. kcSelectList(req).then(res => {
  196. if (res.code == 0) {
  197. this.list = res.data
  198. } else {
  199. return false
  200. }
  201. })
  202. },
  203. getYxList() {
  204. let req = {
  205. id: this.id,
  206. }
  207. jiazhengKcList(req).then(res => {
  208. if (res.code == 0) {
  209. this.listYx = res.data
  210. } else {
  211. return false
  212. }
  213. })
  214. }
  215. }
  216. }
  217. </script>