kechengBind.vue 7.2 KB

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