kechengBind.vue 6.5 KB

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