您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 
 

290 行
7.7 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 主列表页 -->
  4. <view
  5. :class="sideOpen ? 'show' : ''"
  6. class="mainpage"
  7. style="padding-top: 80rpx"
  8. >
  9. <!-- 顶部条目/分页信息栏 -->
  10. <l-customlist-banner @buttonClick="sideOpen = true">{{
  11. tips
  12. }}</l-customlist-banner>
  13. <!-- 滚动列表,跨端支持上拉/下拉 -->
  14. <l-scroll-list
  15. v-if="ready"
  16. @pullDown="pullDown"
  17. @toBottom="fetchList()"
  18. ref="list"
  19. >
  20. <l-customlist :tips="loadState" showTips>
  21. <!-- 单条记录 -->
  22. <view class="customlist-item" v-for="item of list" :key="item.Id">
  23. <view class="customlist-item-field">
  24. <text class="customlist-item-field-title">绑定账号:</text>
  25. {{ displayListItem(item, "BindUserAccount") }}
  26. </view>
  27. <view class="customlist-item-field">
  28. <text class="customlist-item-field-title">绑定时间:</text>
  29. {{ displayListItem(item, "CreateTime") }}
  30. </view>
  31. <l-customlist-action
  32. showButton
  33. buttonText='登录'
  34. icontype='roundright'
  35. @join="action('tologin', item)"
  36. hideView
  37. />
  38. </view>
  39. </l-customlist>
  40. </l-scroll-list>
  41. </view>
  42. <!-- 关闭侧边抽屉按钮 -->
  43. <view
  44. @click="sideOpen = false"
  45. :class="sideOpen ? 'show' : ''"
  46. class="sideclose"
  47. >
  48. <l-icon type="pullright" color="blue" />
  49. </view>
  50. <!-- 侧边栏,用于设置查询条件 -->
  51. <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  52. <view v-if="ready" class="padding">
  53. <l-input
  54. v-model="queryData.BindUserAccount"
  55. @change="searchChange"
  56. title="绑定账号"
  57. placeholder="按绑定账号查询"
  58. />
  59. <!-- 重置查询条件按钮 -->
  60. <view class="padding-tb">
  61. <l-button @click="reset" line="orange" class="block" block
  62. >重置查询条件</l-button
  63. >
  64. </view>
  65. </view>
  66. </scroll-view>
  67. </view>
  68. </template>
  69. <script>
  70. /*
  71. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  72. * Copyright (c) 2013-2021 上海力软信息技术有限公司
  73. * 创建人:超级管理员
  74. * 日 期:2021-03-08 10:36
  75. * 描 述:切换账号
  76. */
  77. /**
  78. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  79. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  80. * { "path": "pages/my/bindaccount", "style": { "navigationBarTitleText": "表单列表页" } }
  81. *
  82. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  83. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  84. */
  85. import moment from "moment";
  86. import get from "lodash/get";
  87. import set from "lodash/set";
  88. import pickBy from "lodash/pickBy";
  89. import mapValues from "lodash/mapValues";
  90. export default {
  91. data() {
  92. return {
  93. // 数据项的数据类型、结构
  94. scheme: {
  95. BindUserAccount: { type: "text" },
  96. CreateTime: { type: "datetime" },
  97. },
  98. // 查询条件
  99. searchData: {},
  100. defaultQueryData: {},
  101. queryData: {
  102. BindUserAccount: "",
  103. },
  104. // 数据源
  105. dataSource: {},
  106. // 页面相关参数
  107. ready: false,
  108. tips: "加载中...",
  109. loadState: "向下翻以加载更多",
  110. sideOpen: false,
  111. // 列表与分页信息
  112. page: 1,
  113. total: 2,
  114. list: [],
  115. };
  116. },
  117. async onLoad() {
  118. await this.init();
  119. },
  120. onUnload() {
  121. this.OFF("EducationalAdministrationLoginUserBind-list-change");
  122. },
  123. methods: {
  124. // 页面初始化
  125. async init() {
  126. this.ON(
  127. "EducationalAdministrationLoginUserBind-list-change",
  128. this.refreshList
  129. );
  130. // 拉取加载列表和数据源
  131. await Promise.all([() => {}]);
  132. await this.fetchList();
  133. // 初始化查询条件
  134. this.defaultQueryData = this.COPY(this.queryData);
  135. this.ready = true;
  136. },
  137. // 拉取列表
  138. async fetchList() {
  139. if (this.page > this.total) {
  140. return;
  141. }
  142. this.searchData.CreateUserId=this.GET_GLOBAL('loginUser').userId
  143. const result = await this.HTTP_GET(
  144. "learun/EducationalAdministration/LoginUserBind/pagelist",
  145. {
  146. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  147. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  148. pagination: { rows: 10, page: this.page, sidx: "CreateTime desc", sord: "DESC" },
  149. queryJson: JSON.stringify(this.searchData),
  150. },
  151. "加载数据时出错"
  152. );
  153. if (!result) {
  154. return;
  155. }
  156. this.total = result.total;
  157. this.page = result.page + 1;
  158. this.list = this.list.concat(result.rows);
  159. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${
  160. result.total
  161. } 页,共 ${result.records} 项`;
  162. this.loadState =
  163. result.page >= result.total ? "已加载所有项目" : "向下翻以加载更多";
  164. },
  165. // 刷新清空列表
  166. async refreshList() {
  167. this.page = 1;
  168. this.total = 2;
  169. this.list = [];
  170. await this.fetchList();
  171. },
  172. // 列表下拉
  173. pullDown() {
  174. this.refreshList().then(() => {
  175. this.$refs.list.stopPullDown();
  176. });
  177. },
  178. // 设置搜索条件
  179. async searchChange() {
  180. const result = {};
  181. // 将其他查询项添加到查询 JSON 中
  182. const queryObj = pickBy(this.queryData, (t) =>
  183. Array.isArray(t) ? t.length > 0 : t
  184. );
  185. Object.assign(
  186. result,
  187. mapValues(queryObj, (t) => (Array.isArray(t) ? t.join(",") : t))
  188. );
  189. this.searchData = result;
  190. await this.refreshList();
  191. },
  192. // 点击「清空查询条件」按钮
  193. reset() {
  194. this.queryData = this.COPY(this.defaultQueryData);
  195. this.searchChange();
  196. },
  197. // 点击「登录」、按钮
  198. async action(type, item) {
  199. switch (type) {
  200. case "tologin":
  201. this.NAV_TO(`/pages/login?isBindAccountLogin=1&bindUserName=${item.BindUserAccount}&bindUserPassword=${item.BindUserPassword}`);
  202. return;
  203. default:
  204. return;
  205. }
  206. },
  207. // 显示列表中的标题项
  208. displayListItem(item, field) {
  209. const fieldItem = this.scheme[field];
  210. const value = item[field];
  211. switch (fieldItem.type) {
  212. case "currentInfo":
  213. case "organize":
  214. return fieldItem.dataType === "time"
  215. ? value
  216. : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, "");
  217. case "radio":
  218. case "select":
  219. const selectItem = this.dataSource[field].find(
  220. (t) => t.value === String(value)
  221. );
  222. return get(selectItem, "text", "");
  223. case "checkbox":
  224. if (!value || value.split(",").length <= 0) {
  225. return "";
  226. }
  227. const checkboxItems = value.split(",");
  228. return this.dataSource[field]
  229. .filter((t) => checkboxItems.includes(t.value))
  230. .map((t) => t.text)
  231. .join(",");
  232. case "datetime":
  233. if (!value) {
  234. return "";
  235. }
  236. return moment(value).format(
  237. Number(fieldItem.dateformat) === 0
  238. ? "YYYY年 M月 D日"
  239. : "YYYY-MM-DD HH:mm"
  240. );
  241. default:
  242. return value === null || value === undefined ? "" : value;
  243. }
  244. },
  245. },
  246. };
  247. </script>
  248. <style lang="less" scoped>
  249. @import "~@/common/css/sidepage.less";
  250. @import "~@/common/css/customlist.less";
  251. </style>