kechengBind.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. <view style="display: flex;">
  51. <button type="primary" size="mini" class="item-view-btn"
  52. @click.stop="toDelete(item)">删除</button>
  53. <button type="primary" size="mini" class="item-view-btn"
  54. @click.stop="toDelete(item)">删除</button>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. </uni-list-item>
  60. </uni-list>
  61. </view>
  62. <common-dialog ref="commonDialogRef" :title="deleteTitle" :content="deleteConcent"
  63. @confirm-btn="deleteQuerenBtn"></common-dialog>
  64. <kechengLeixingVue ref="kclxRef" @select="handleSelectLeixing" @reset="handleResetLeixing"></kechengLeixingVue>
  65. <searchVue ref="searchRef" @search-btn="handleSearchFromBtn"></searchVue>
  66. </view>
  67. </template>
  68. <script>
  69. import {
  70. ref
  71. } from "vue";
  72. import {
  73. kcSelectList,
  74. jiazhengKcList,
  75. jiazhengKcAdd,
  76. jiazhengKcDelete,
  77. getAdminClassify
  78. } from "@/api/jiazheng.js";
  79. import commonDialog from '@/components/dialog/commonDialog.vue';
  80. import kechengLeixingVue from "./common/kechengLeixing.vue";
  81. import searchVue from "./common/search2.vue";
  82. import {
  83. debounce
  84. } from "@/utils/common";
  85. export default {
  86. data() {
  87. return {
  88. leixing: '全部类型',
  89. leixingList: [],
  90. selectClassify: null,
  91. kcClassifyId: 0,
  92. id: '',
  93. name: '',
  94. current: 0,
  95. list: [],
  96. listYx: [],
  97. deleteTitle: '删除',
  98. kcId: '',
  99. deleteConcent: '你确定要执行这个操作吗',
  100. tabs: [{
  101. id: 1,
  102. name: '未绑定课程',
  103. },
  104. {
  105. id: 2,
  106. name: '已绑定课程',
  107. },
  108. ],
  109. }
  110. },
  111. components: {
  112. commonDialog,
  113. kechengLeixingVue,
  114. searchVue
  115. },
  116. onLoad(options) {
  117. this.id = options.id
  118. this.getList()
  119. this.getKechengClassify()
  120. },
  121. methods: {
  122. searchBtn() {
  123. this.$refs.searchRef.handleShow()
  124. },
  125. handleSearchFromBtn(textD) {
  126. this.name = textD;
  127. this.getList()
  128. },
  129. handleResetLeixing() {
  130. this.selectClassify = null;
  131. this.leixing = '全部类型';
  132. this.getList()
  133. },
  134. handleSelectLeixing(item) {
  135. this.leixing = item.lable;
  136. this.selectClassify = item;
  137. this.getList()
  138. },
  139. clickAlltype() {
  140. this.$refs.kclxRef.showPopup({
  141. data: this.leixingList
  142. })
  143. },
  144. getKechengClassify() {
  145. getAdminClassify().then(res => {
  146. res.data.children.forEach(item => {
  147. item.checked = false;
  148. })
  149. this.leixingList = res.data.children || [];
  150. })
  151. },
  152. toAdd(data) {
  153. debounce(()=>{
  154. let req = {
  155. kcIds: [data.kcId],
  156. id: this.id
  157. }
  158. jiazhengKcAdd(req).then(res => {
  159. if (res.code == 0) {
  160. this.getList()
  161. uni.showToast({
  162. title: '添加成功',
  163. icon: 'success'
  164. });
  165. } else {
  166. uni.showToast({
  167. title: '添加失败',
  168. icon: 'success'
  169. });
  170. return false
  171. }
  172. })
  173. },500)
  174. },
  175. deleteQuerenBtn() {
  176. let req = {
  177. kcId: this.kcId,
  178. id: this.id
  179. }
  180. jiazhengKcDelete(req).then(res => {
  181. if (res.code == 0) {
  182. this.getYxList()
  183. uni.showToast({
  184. title: '删除成功',
  185. icon: 'success'
  186. });
  187. } else {
  188. uni.showToast({
  189. title: '删除失败',
  190. icon: 'success'
  191. });
  192. return false
  193. }
  194. })
  195. },
  196. toDelete(data) {
  197. this.kcId = data.kcId
  198. this.$refs.commonDialogRef.handleShow();
  199. },
  200. changeTab(data) {
  201. this.current = data
  202. if (this.current == 0) {
  203. this.getList()
  204. } else {
  205. this.getYxList()
  206. }
  207. console.log('data', data);
  208. },
  209. goUpPage() {
  210. uni.redirectTo({
  211. url: "/pages/admin/Jiazheng/index"
  212. })
  213. },
  214. getList() {
  215. let req = {
  216. id: this.id,
  217. "kcClassifyId": this.selectClassify && this.selectClassify.id || 0,
  218. name:this.name
  219. }
  220. kcSelectList(req).then(res => {
  221. if (res.code == 0) {
  222. this.list = res.data
  223. } else {
  224. return false
  225. }
  226. })
  227. },
  228. getYxList() {
  229. let req = {
  230. id: this.id,
  231. }
  232. jiazhengKcList(req).then(res => {
  233. if (res.code == 0) {
  234. this.listYx = res.data
  235. } else {
  236. return false
  237. }
  238. })
  239. }
  240. }
  241. }
  242. </script>