kechengBind.vue 5.4 KB

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