ServiceStudent.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div style="min-height: 100vh">
  3. <van-sticky>
  4. <m-header :backUrl="backUrl" :isFixed="false">
  5. <template slot="right">
  6. <div
  7. @click="
  8. () => {
  9. $router.push('/goodsOrder');
  10. }
  11. "
  12. >
  13. 商品订单
  14. </div>
  15. </template>
  16. </m-header>
  17. <search @onSearch="onSearch" placeholder="请输入姓名或手机号" />
  18. </van-sticky>
  19. <van-list
  20. v-model="loading"
  21. v-if="dataShow"
  22. :finished="finished"
  23. :immediate-check="false"
  24. finished-text="- 没有更多内容 -"
  25. @load="getStudent"
  26. >
  27. <van-radio-group v-model="radioSelect">
  28. <van-cell-group>
  29. <van-cell
  30. v-for="(item, index) in dataList"
  31. :key="index"
  32. @click="onSelect(item)"
  33. title-class="title-class"
  34. class="input-cell"
  35. :center="true"
  36. is-link
  37. >
  38. <template slot="icon">
  39. <img
  40. class="logo"
  41. v-if="item.headUrl"
  42. :src="item.headUrl"
  43. alt=""
  44. />
  45. <img
  46. class="logo"
  47. v-else
  48. src="@/assets/images/icon_students.png"
  49. alt=""
  50. />
  51. </template>
  52. <template slot="title">
  53. <div class="label">
  54. {{ item.name }}
  55. <span class="phone_section">
  56. {{ item.phone ? desensitPhone(item.phone) : null }}
  57. <a
  58. @click.stop="() => {}"
  59. v-if="type != 'sale'"
  60. style="height: 0.17rem"
  61. :href="'tel:' + item.phone"
  62. ><i class="icon_phone"></i
  63. ></a>
  64. </span>
  65. </div>
  66. </template>
  67. <!-- <template slot="default">
  68. <van-radio :name="item.userId">
  69. <template #icon="props">
  70. <img
  71. class="img-icon"
  72. :src="props.checked ? activeButtonIcon : inactiveButtonIcon"
  73. />
  74. </template>
  75. </van-radio>
  76. </template> -->
  77. </van-cell>
  78. </van-cell-group>
  79. </van-radio-group>
  80. </van-list>
  81. <m-empty class="empty" v-else />
  82. <!-- <div class="button-group">
  83. <van-button type="primary" @click="onSubmit" round size="large">确认选择</van-button>
  84. </div> -->
  85. </div>
  86. </template>
  87. <script>
  88. import MHeader from "@/components/header";
  89. import search from "@/components/Search";
  90. import MEmpty from "@/components/MEmpty";
  91. import { getStudentsByTeacherOrgan } from "./api";
  92. export default {
  93. name: "teacherList",
  94. components: {
  95. MHeader,
  96. search,
  97. MEmpty,
  98. },
  99. data() {
  100. let query = this.$route.query;
  101. // 如果有 保存记录,测删除
  102. localStorage.removeItem("repaireForm");
  103. return {
  104. type: query.type,
  105. radioSelect: null,
  106. radioSelectOrganId: null,
  107. loading: false,
  108. finished: false,
  109. params: {
  110. search: null,
  111. page: 1,
  112. rows: 20,
  113. },
  114. dataShow: true, // 是否有数据
  115. dataList: [],
  116. backUrl: {
  117. status: true,
  118. path: "/home",
  119. },
  120. };
  121. },
  122. async mounted() {
  123. await this.getStudent();
  124. },
  125. methods: {
  126. onSelect(item) {
  127. // 商品销售
  128. this.$router.push({
  129. path: "/goodsSale",
  130. query: {
  131. studentId: item.userId,
  132. studentName: item.name,
  133. organId: item.organId,
  134. },
  135. });
  136. // this.radioSelect = item.userId;
  137. // this.radioSelectOrganId = item.organId;
  138. },
  139. onSubmit() {
  140. if (!this.radioSelect) {
  141. this.$toast("请选择学生");
  142. return;
  143. }
  144. localStorage.setItem("studentId", this.radioSelect);
  145. let studentName = null;
  146. this.dataList.forEach((item) => {
  147. if (item.userId == this.radioSelect) {
  148. studentName = item.name;
  149. }
  150. });
  151. // 商品销售
  152. this.$router.push({
  153. path: "/goodsSale",
  154. query: {
  155. studentId: this.radioSelect,
  156. studentName: studentName,
  157. organId: this.radioSelectOrganId,
  158. },
  159. });
  160. },
  161. // 搜索
  162. onSearch(val) {
  163. this.params.search = val;
  164. this.params.page = 1;
  165. this.dataList = [];
  166. this.dataShow = true;
  167. this.loading = true;
  168. this.finished = false;
  169. this.getStudent();
  170. },
  171. async getStudent() {
  172. let params = this.params;
  173. params.search = params.search ? params.search : null;
  174. let studentList = null;
  175. try {
  176. studentList = await getStudentsByTeacherOrgan(params);
  177. // }
  178. let result = studentList.data;
  179. this.loading = false;
  180. if (studentList.code == 200) {
  181. // 重点这句,判断是不是重复请求了
  182. if (this.dataList.length > 0 && result.pageNo == 1) {
  183. return;
  184. }
  185. params.page = result.pageNo;
  186. this.dataList = this.dataList.concat(result.rows);
  187. if (params.page >= result.totalPage) {
  188. this.finished = true;
  189. }
  190. this.params.page++;
  191. } else {
  192. this.finished = true;
  193. }
  194. // 判断是否有数据
  195. if (this.dataList.length <= 0) {
  196. this.dataShow = false;
  197. }
  198. } catch {
  199. //
  200. }
  201. },
  202. desensitPhone(phone) {
  203. // 手机号脱敏
  204. let first = phone.substr(0, 3);
  205. let last = phone.substr(-4);
  206. return first + "****" + last;
  207. },
  208. },
  209. };
  210. </script>
  211. <style lang="less" scoped>
  212. @import url("../../assets/commonLess/variable.less");
  213. /deep/.van-cell__title {
  214. font-size: 0.14rem;
  215. color: @mFontColor;
  216. flex: 1 auto;
  217. }
  218. .logo {
  219. width: 0.42rem;
  220. height: 0.42rem;
  221. margin-right: 0.12rem;
  222. border-radius: 100%;
  223. }
  224. .input-cell {
  225. padding: 0.12rem 0.16rem 0.2rem;
  226. .van-radio {
  227. justify-content: flex-end;
  228. }
  229. }
  230. /deep/.van-cell__value {
  231. height: 0.24rem;
  232. }
  233. /deep/.van-radio__icon .van-icon {
  234. border-color: @sFontColor;
  235. }
  236. /deep/.van-radio__icon--checked {
  237. .van-icon {
  238. border-color: @orangeColor;
  239. background: @orangeColor;
  240. }
  241. }
  242. .van-tag {
  243. margin-left: 0.08rem;
  244. }
  245. .button-group {
  246. margin: 0.3rem 0.26rem 0.2rem;
  247. .van-button--primary {
  248. background: @mColor;
  249. border: 1px solid @mColor;
  250. font-size: 0.18rem;
  251. }
  252. }
  253. .phone_section {
  254. display: flex;
  255. align-items: center;
  256. font-size: 0.14rem;
  257. color: #999;
  258. }
  259. .icon_phone {
  260. margin-left: 0.1rem;
  261. width: 0.14rem;
  262. height: 0.17rem;
  263. display: inline-block;
  264. background: url("../../assets/images/icon_phone.png") no-repeat center center;
  265. background-size: contain;
  266. }
  267. .title-class {
  268. display: flex;
  269. align-items: center;
  270. .label {
  271. display: flex;
  272. flex-direction: column;
  273. font-size: 0.16rem;
  274. color: #1a1a1a;
  275. }
  276. }
  277. </style>