kechengBind.vue 7.6 KB

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