kechengBind.vue 5.9 KB

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