kechengBind.vue 8.5 KB

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