kechengBind.vue 6.6 KB

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