kechengBind.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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 class="select-text">{{leixing}}</text>
  16. <icon class="select-jt-default" />
  17. </view>
  18. <view>课程剩余数量:{{kechengNumber||0}}</view>
  19. </view>
  20. <view class="kc-bind-scroll-view scroll-top-border" v-if="current ==0">
  21. <uni-list class="admin-list-box">
  22. <uni-list-item v-for="item in list" class="admin-list-item-box">
  23. <template v-slot:body>
  24. <view @click="lookUserInfo(item)" class="kecheng-list-card">
  25. <img :src="item.pic">
  26. <view class="item-card-row">
  27. <view class="ks-item-top">
  28. <view class="kc-name">{{item.name}}</view>
  29. </view>
  30. <view class="ks-totalTm kc-fenlei">
  31. <icon class="phone-fenlei-icon" />分类:{{item.kcClassifyName}}
  32. </view>
  33. <button class="kc-bind-btn phone-green-btn" type="default" size="mini"
  34. @click.stop="toAdd(item)">绑定</button>
  35. </view>
  36. </view>
  37. </template>
  38. </uni-list-item>
  39. </uni-list>
  40. </view>
  41. <view class="kc-notbind-scroll-view scroll-top-border" v-if="current ==1">
  42. <uni-list class="admin-list-box">
  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 {toast} from "@/utils/common";
  88. import searchVue from "./common/search2.vue";
  89. import {
  90. debounce
  91. } from "@/utils/common";
  92. export default {
  93. data() {
  94. return {
  95. leixing: '全部类型',
  96. leixingList: [],
  97. selectClassify: null,
  98. kcClassifyId: 0,
  99. id: '',
  100. kechengNumber: '',
  101. addFlag: false,
  102. name: '',
  103. current: 0,
  104. list: [],
  105. listYx: [],
  106. deleteTitle: '删除',
  107. kcId: '',
  108. deleteConcent: '你确定要执行这个操作吗',
  109. tabs: [{
  110. id: 1,
  111. name: '未绑定课程',
  112. },
  113. {
  114. id: 2,
  115. name: '已绑定课程',
  116. },
  117. ],
  118. }
  119. },
  120. components: {
  121. commonDialog,
  122. kechengLeixingVue,
  123. searchVue
  124. },
  125. onLoad(options) {
  126. this.id = options.id
  127. this.getList()
  128. this.getKechengClassify()
  129. this.chaxunNumber()
  130. },
  131. methods: {
  132. chaxunNumber() {
  133. chaxunNumberKecheng({
  134. id: this.id
  135. }).then(res => {
  136. if (res.code == 0) {
  137. this.kechengNumber = res.data
  138. this.addFlag = this.kechengNumber > 0;
  139. } else {
  140. uni.showToast({
  141. title: '失败'
  142. });
  143. return false
  144. }
  145. })
  146. },
  147. toReset(data) {
  148. let req = {
  149. kcId: data.kcId,
  150. id: this.id
  151. }
  152. kechengReset(req).then(res => {
  153. if (res.code == 0) {
  154. this.getList()
  155. uni.showToast({
  156. title: '成功',
  157. icon: 'success'
  158. });
  159. } else {
  160. uni.showToast({
  161. title: '失败'
  162. });
  163. return false
  164. }
  165. })
  166. },
  167. searchBtn() {
  168. this.$refs.searchRef.handleShow()
  169. },
  170. handleSearchFromBtn(textD) {
  171. this.name = textD;
  172. this.getList()
  173. },
  174. handleResetLeixing() {
  175. this.selectClassify = null;
  176. this.leixing = '全部类型';
  177. this.getList()
  178. },
  179. handleSelectLeixing(item) {
  180. this.leixing = item.lable;
  181. this.selectClassify = item;
  182. this.getList()
  183. },
  184. clickAlltype() {
  185. this.$refs.kclxRef.showPopup({
  186. data: this.leixingList
  187. })
  188. },
  189. getKechengClassify() {
  190. getAdminClassify().then(res => {
  191. res.data.children.forEach(item => {
  192. item.checked = false;
  193. })
  194. this.leixingList = res.data.children || [];
  195. })
  196. },
  197. toAdd(data) {
  198. if (!this.addFlag) {
  199. toast('课程剩余数量不足')
  200. return false
  201. }
  202. debounce(
  203. this.jzAdd(data), 500)
  204. },
  205. jzAdd(data) {
  206. let req = {
  207. kcIds: [data.kcId],
  208. id: this.id
  209. }
  210. jiazhengKcAdd(req).then(res => {
  211. if (res.code == 0) {
  212. this.getList()
  213. this.chaxunNumber()
  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>