You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

list.vue 9.2 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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, "MeetingTitle") }}
  26. </view>
  27. <view class="customlist-item-field">
  28. <text class="customlist-item-field-title">纪要标题:</text>
  29. {{ displayListItem(item, "Title") }}
  30. </view>
  31. <view class="customlist-item-field">
  32. <text class="customlist-item-field-title">内容:</text>
  33. {{ displayListItem(item, "Content") }}
  34. </view>
  35. <view class="customlist-item-field">
  36. <text class="customlist-item-field-title">附件上传:</text>
  37. {{ displayListItem(item, "Files") }}
  38. </view>
  39. <l-customlist-action
  40. showEdit
  41. @edit="action('edit', item.ID)"
  42. showDelete
  43. @delete="action('delete', item.ID)"
  44. @view="action('view', item.ID)"
  45. />
  46. </view>
  47. </l-customlist>
  48. </l-scroll-list>
  49. </view>
  50. <!-- 关闭侧边抽屉按钮 -->
  51. <view
  52. @click="sideOpen = false"
  53. :class="sideOpen ? 'show' : ''"
  54. class="sideclose"
  55. >
  56. <l-icon type="pullright" color="blue" />
  57. </view>
  58. <!-- 侧边栏,用于设置查询条件 -->
  59. <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  60. <view v-if="ready" class="padding">
  61. <l-input
  62. v-model="queryData.MeetID"
  63. @change="searchChange"
  64. title="会议名称"
  65. placeholder="按会议名称查询"
  66. />
  67. <l-input
  68. v-model="queryData.Title"
  69. @change="searchChange"
  70. title="纪要标题"
  71. placeholder="按纪要标题查询"
  72. />
  73. <!-- 重置查询条件按钮 -->
  74. <view class="padding-tb">
  75. <l-button @click="reset" line="orange" class="block" block
  76. >重置查询条件</l-button
  77. >
  78. </view>
  79. </view>
  80. </scroll-view>
  81. <l-customlist-add v-if="!sideOpen" @click="action('add')" />
  82. </view>
  83. </template>
  84. <script>
  85. /*
  86. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  87. * Copyright (c) 2013-2021 上海力软信息技术有限公司
  88. * 创建人:超级管理员
  89. * 日 期:2021-03-08 10:36
  90. * 描 述:会议纪要
  91. */
  92. /**
  93. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  94. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  95. * { "path": "pages/PersonnelManagement/MeetingMinutes/list", "style": { "navigationBarTitleText": "表单列表页" } }
  96. *
  97. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  98. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  99. */
  100. import moment from "moment";
  101. import get from "lodash/get";
  102. import set from "lodash/set";
  103. import pickBy from "lodash/pickBy";
  104. import mapValues from "lodash/mapValues";
  105. export default {
  106. data() {
  107. return {
  108. // 数据项的数据类型、结构
  109. scheme: {
  110. MeetingTitle: { type: "text" },
  111. Title: { type: "text" },
  112. Content: { type: "texteditor" },
  113. Files: { type: "upload" },
  114. },
  115. // 查询条件
  116. searchData: {},
  117. defaultQueryData: {},
  118. queryData: {
  119. MeetID: "",
  120. Title: "",
  121. },
  122. // 数据源
  123. dataSource: {},
  124. // 页面相关参数
  125. meetId: "",
  126. ready: false,
  127. tips: "加载中...",
  128. loadState: "向下翻以加载更多",
  129. sideOpen: false,
  130. // 列表与分页信息
  131. page: 1,
  132. total: 2,
  133. list: [],
  134. };
  135. },
  136. async onLoad(meetId) {
  137. await this.init(meetId);
  138. },
  139. onUnload() {
  140. this.OFF("PersonnelManagementMeetingMinutes-list-change");
  141. },
  142. methods: {
  143. // 页面初始化
  144. async init(meetId) {
  145. console.log(meetId);
  146. this.meetId = meetId.meetId;
  147. this.ON(
  148. "PersonnelManagementMeetingMinutes-list-change",
  149. this.refreshList
  150. );
  151. // 拉取加载列表和数据源
  152. await Promise.all([() => {}]);
  153. await this.fetchList();
  154. // 初始化查询条件
  155. this.defaultQueryData = this.COPY(this.queryData);
  156. this.ready = true;
  157. },
  158. // 拉取列表
  159. async fetchList() {
  160. if (this.page > this.total) {
  161. return;
  162. }
  163. this.searchData.MeetID=this.meetId;
  164. const result = await this.HTTP_GET(
  165. "learun/adms/PersonnelManagement/MeetingMinutes/pagelist",
  166. {
  167. // 这里 sidx 表示排序字段,sord 表示排序方式(DESC=降序,ASC=升序)
  168. // 代码生成器生成时默认按照主键排序,您可以修改成按创建时间的字段降序
  169. pagination: { rows: 10, page: this.page, sidx: "ID", sord: "DESC" },
  170. queryJson: JSON.stringify(this.searchData),
  171. },
  172. "加载数据时出错"
  173. );
  174. if (!result) {
  175. return;
  176. }
  177. this.total = result.total;
  178. this.page = result.page + 1;
  179. this.list = this.list.concat(result.rows);
  180. this.tips = `已加载 ${Math.min(result.page, result.total)} / ${
  181. result.total
  182. } 页,共 ${result.records} 项`;
  183. this.loadState =
  184. result.page >= result.total ? "已加载所有项目" : "向下翻以加载更多";
  185. },
  186. // 刷新清空列表
  187. async refreshList() {
  188. this.page = 1;
  189. this.total = 2;
  190. this.list = [];
  191. await this.fetchList();
  192. },
  193. // 列表下拉
  194. pullDown() {
  195. this.refreshList().then(() => {
  196. this.$refs.list.stopPullDown();
  197. });
  198. },
  199. // 设置搜索条件
  200. async searchChange() {
  201. const result = {};
  202. // 将其他查询项添加到查询 JSON 中
  203. const queryObj = pickBy(this.queryData, (t) =>
  204. Array.isArray(t) ? t.length > 0 : t
  205. );
  206. Object.assign(
  207. result,
  208. mapValues(queryObj, (t) => (Array.isArray(t) ? t.join(",") : t))
  209. );
  210. this.searchData = result;
  211. await this.refreshList();
  212. },
  213. // 点击「清空查询条件」按钮
  214. reset() {
  215. this.queryData = this.COPY(this.defaultQueryData);
  216. this.searchChange();
  217. },
  218. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  219. async action(type, id = "") {
  220. switch (type) {
  221. case "view":
  222. this.NAV_TO(`./single?type=view&id=${id}`);
  223. return;
  224. case "add":
  225. this.NAV_TO("./single?type=create&meetId="+this.meetId);
  226. return;
  227. case "edit":
  228. this.NAV_TO(`./single?type=edit&id=${id}`);
  229. return;
  230. case "delete":
  231. if (!(await this.CONFIRM("删除项目", "确定要删除该项吗?", true))) {
  232. return;
  233. }
  234. this.HTTP_POST(
  235. "learun/adms/PersonnelManagement/MeetingMinutes/delete",
  236. id,
  237. "删除失败"
  238. ).then((success) => {
  239. if (!success) {
  240. return;
  241. }
  242. this.TOAST("删除成功", "success");
  243. this.refreshList();
  244. });
  245. return;
  246. default:
  247. return;
  248. }
  249. },
  250. // 显示列表中的标题项
  251. displayListItem(item, field) {
  252. const fieldItem = this.scheme[field];
  253. const value = item[field];
  254. switch (fieldItem.type) {
  255. case "currentInfo":
  256. case "organize":
  257. return fieldItem.dataType === "time"
  258. ? value
  259. : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, "");
  260. case "radio":
  261. case "select":
  262. const selectItem = this.dataSource[field].find(
  263. (t) => t.value === String(value)
  264. );
  265. return get(selectItem, "text", "");
  266. case "checkbox":
  267. if (!value || value.split(",").length <= 0) {
  268. return "";
  269. }
  270. const checkboxItems = value.split(",");
  271. return this.dataSource[field]
  272. .filter((t) => checkboxItems.includes(t.value))
  273. .map((t) => t.text)
  274. .join(",");
  275. case "datetime":
  276. if (!value) {
  277. return "";
  278. }
  279. return moment(value).format(
  280. Number(fieldItem.dateformat) === 0
  281. ? "YYYY年 M月 D日"
  282. : "YYYY-MM-DD HH:mm"
  283. );
  284. default:
  285. return value === null || value === undefined ? "" : value;
  286. }
  287. },
  288. },
  289. };
  290. </script>
  291. <style lang="less" scoped>
  292. @import "~@/common/css/sidepage.less";
  293. @import "~@/common/css/customlist.less";
  294. </style>