kechengBind.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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="kc-bind-btn phone-green-btn" type="default" 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 class="bind-btn-row">
  51. <button type="default" size="mini" class="kc-bind-btn phone-green-btn"
  52. @click.stop="toDelete(item)">重置</button>
  53. <button type="default" size="mini" class="kc-bind-btn phone-white-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. toReset(data){
  123. },
  124. searchBtn() {
  125. this.$refs.searchRef.handleShow()
  126. },
  127. handleSearchFromBtn(textD) {
  128. this.name = textD;
  129. this.getList()
  130. },
  131. handleResetLeixing() {
  132. this.selectClassify = null;
  133. this.leixing = '全部类型';
  134. this.getList()
  135. },
  136. handleSelectLeixing(item) {
  137. this.leixing = item.lable;
  138. this.selectClassify = item;
  139. this.getList()
  140. },
  141. clickAlltype() {
  142. this.$refs.kclxRef.showPopup({
  143. data: this.leixingList
  144. })
  145. },
  146. getKechengClassify() {
  147. getAdminClassify().then(res => {
  148. res.data.children.forEach(item => {
  149. item.checked = false;
  150. })
  151. this.leixingList = res.data.children || [];
  152. })
  153. },
  154. toAdd(data) {
  155. debounce(()=>{
  156. let req = {
  157. kcIds: [data.kcId],
  158. id: this.id
  159. }
  160. jiazhengKcAdd(req).then(res => {
  161. if (res.code == 0) {
  162. this.getList()
  163. uni.showToast({
  164. title: '添加成功',
  165. icon: 'success'
  166. });
  167. } else {
  168. uni.showToast({
  169. title: '添加失败',
  170. icon: 'success'
  171. });
  172. return false
  173. }
  174. })
  175. },500)
  176. },
  177. deleteQuerenBtn() {
  178. let req = {
  179. kcId: this.kcId,
  180. id: this.id
  181. }
  182. jiazhengKcDelete(req).then(res => {
  183. if (res.code == 0) {
  184. this.getYxList()
  185. uni.showToast({
  186. title: '删除成功',
  187. icon: 'success'
  188. });
  189. } else {
  190. uni.showToast({
  191. title: '删除失败',
  192. icon: 'success'
  193. });
  194. return false
  195. }
  196. })
  197. },
  198. toDelete(data) {
  199. this.kcId = data.kcId
  200. this.$refs.commonDialogRef.handleShow();
  201. },
  202. changeTab(data) {
  203. this.current = data
  204. if (this.current == 0) {
  205. this.getList()
  206. } else {
  207. this.getYxList()
  208. }
  209. console.log('data', data);
  210. },
  211. goUpPage() {
  212. uni.redirectTo({
  213. url: "/pages/admin/Jiazheng/index"
  214. })
  215. },
  216. getList() {
  217. let req = {
  218. id: this.id,
  219. "kcClassifyId": this.selectClassify && this.selectClassify.id || 0,
  220. name:this.name
  221. }
  222. kcSelectList(req).then(res => {
  223. if (res.code == 0) {
  224. this.list = res.data
  225. } else {
  226. return false
  227. }
  228. })
  229. },
  230. getYxList() {
  231. let req = {
  232. id: this.id,
  233. }
  234. jiazhengKcList(req).then(res => {
  235. if (res.code == 0) {
  236. this.listYx = res.data
  237. } else {
  238. return false
  239. }
  240. })
  241. }
  242. }
  243. }
  244. </script>