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.
 
 
 
 
 
 

337 lines
9.1 KiB

  1. <template>
  2. <view class="page">
  3. <!-- 主列表页 -->
  4. <view :class="sideOpen ? 'show' : ''" class="mainpage" style="padding-top: 80rpx">
  5. <!-- 顶部条目/分页信息栏 -->
  6. <l-customlist-banner @buttonClick="sideOpen = true">
  7. <text class="records">{{ records }}</text>
  8. 数据
  9. </l-customlist-banner>
  10. <!-- 滚动列表,跨端支持上拉/下拉 -->
  11. <l-scroll-list v-if="ready" @pullDown="pullDown" @toBottom="fetchList()" ref="list">
  12. <l-customlist :tips="loadState" showTips>
  13. <view class=""></view>
  14. <!-- 单条记录 -->
  15. <view class="pageBox customlist-item" showDelete="true" v-for="(item, ind) in list" :key="item.MakeDate" @click="action('view', item.ID)">
  16. <view class="">
  17. <text>填表人员:</text>
  18. {{ displayListItem(item, 'Creater') }}
  19. </view>
  20. <view class="">
  21. <text>填报时间:</text>
  22. <!-- {{ item.CreateTime }} -->
  23. {{ displayListItem(item, 'CreateTime') }}
  24. </view>
  25. <view class="listBtn" @click.stop="action('delete', item.ID)">删除</view>
  26. </view>
  27. </l-customlist>
  28. </l-scroll-list>
  29. </view>
  30. <!-- 关闭侧边抽屉按钮 -->
  31. <view @click="sideOpen = false" :class="sideOpen ? 'show' : ''" class="sideclose"><l-icon type="pullright" color="blue" /></view>
  32. <!-- 侧边栏,用于设置查询条件 -->
  33. <scroll-view :class="sideOpen ? 'show' : ''" class="sidepage" scroll-y>
  34. <view v-if="ready" class="padding">
  35. <l-input v-model="queryData.Creater" title="填表人员" placeholder="请填写填表人员" right />
  36. <l-select v-model="queryData.Type" :range="dataSource.Type" title="类别" placeholder="按类别查询" />
  37. <l-input v-model="queryData.UnitName" title="单位名称" placeholder="请填写单位名称" right />
  38. <l-input v-model="queryData.StudentSource" title="系专业班级" placeholder="请填写系专业班级" right />
  39. <!-- 重置查询条件按钮 -->
  40. <view class="padding-tb"><l-button @click="reset" line="orange" class="block" block>重置查询条件</l-button></view>
  41. <view class="padding-tb"><l-button @click="searchChange" line="orange" class="block" block>查询</l-button></view>
  42. </view>
  43. </scroll-view>
  44. <l-customlist-add v-if="!sideOpen" @click="action('add')" />
  45. </view>
  46. </template>
  47. <script>
  48. /*
  49. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  50. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  51. * 创建人:超级管理员
  52. * 日 期:2020-10-12 17:22
  53. * 描 述:班级自诊打卡
  54. */
  55. /**
  56. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  57. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  58. * { "path": "pages/EducationalAdministration/Thermography/list", "style": { "navigationBarTitleText": "表单列表页" } }
  59. *
  60. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  61. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  62. */
  63. import moment from 'moment';
  64. import get from 'lodash/get';
  65. import set from 'lodash/set';
  66. import pickBy from 'lodash/pickBy';
  67. import mapValues from 'lodash/mapValues';
  68. export default {
  69. data() {
  70. return {
  71. user: null,
  72. // 数据项的数据类型、结构
  73. scheme: {
  74. Creater: {
  75. type: 'select',
  76. dataSource: '1',
  77. dataSourceId: 'BaseUser,f_realname,f_userid'
  78. },
  79. CreateTime: {
  80. type: 'text'
  81. }
  82. },
  83. // 查询条件
  84. searchData: {
  85. MeasurerID: this.GET_GLOBAL('loginUser').account
  86. },
  87. defaultQueryData: {},
  88. queryData: {
  89. Creater: '',
  90. Type: '',
  91. UnitName: '',
  92. StudentSource: ''
  93. },
  94. // 数据源
  95. dataSource: {
  96. Creater: '',
  97. Type: Object.values(this.GET_GLOBAL('dataDictionary').EUserType).map(t => ({ value: t.value, text: t.text }))
  98. },
  99. // 时间查询参数
  100. dateRange: null,
  101. // 页面相关参数
  102. ready: false,
  103. tips: '加载中...',
  104. loadState: '向下翻以加载更多',
  105. sideOpen: false,
  106. // 列表与分页信息
  107. page: 1,
  108. total: 2,
  109. rows: 10,
  110. list: [],
  111. // records: '加载中...',
  112. records: 0,
  113. multipleData: null
  114. };
  115. },
  116. async onLoad() {
  117. await this.init();
  118. },
  119. onUnload() {
  120. this.OFF('EpidemicSituationCopy');
  121. },
  122. methods: {
  123. // 页面初始化
  124. async init() {
  125. this.ON('EpidemicSituationCopy', this.refreshList);
  126. this.user = this.GET_GLOBAL('loginUser');
  127. // this.queryData.Creater = this.user.userId
  128. // 拉取加载列表和数据源
  129. await Promise.all([
  130. this.FETCH_DATASOURCE('BaseUser').then(data => {
  131. // console.log(data)
  132. this.dataSource.Creater = data.data.map(t => ({
  133. text: t.f_realname,
  134. value: t.f_userid
  135. }));
  136. }),
  137. () => {}
  138. ]);
  139. // console.log(this.page)
  140. // console.log(this.dataSource.Type);
  141. this.fetchList();
  142. // 初始化查询条件
  143. this.defaultQueryData = this.COPY(this.queryData);
  144. this.ready = true;
  145. },
  146. // 拉取列表
  147. async fetchList() {
  148. // console.log(this.page)
  149. // console.log(this.total)
  150. this.sideOpen = false;
  151. if (this.page > this.total) {
  152. return;
  153. }
  154. let _this = this;
  155. let _postParam = {
  156. pagination: {
  157. rows: _this.rows,
  158. page: _this.page,
  159. sidx: 'ID',
  160. sord: 'DESC'
  161. },
  162. queryJson: '{}'
  163. };
  164. if(_this.queryData.Creater.length != 0){
  165. _postParam.queryJson = JSON.stringify(_this.queryData);
  166. }else{
  167. _postParam.queryJson = JSON.stringify({ Creater: _this.user.userId });
  168. }
  169. // console.log(_this.user)
  170. _this.LOADING('加载数据中…');
  171. // _this.HIDE_LOADING();
  172. _this.HTTP_GET('learun/PersonnelManagement/EpidemicSituationCopy/pagelist', _postParam, '加载数据时出错').then(res => {
  173. _this.HIDE_LOADING();
  174. // console.log(res);
  175. _this.list = _this.list.concat(res.rows);
  176. _this.total = res.total;
  177. _this.records = res.records;
  178. _this.page = res.page + 1;
  179. _this.loadState = res.page >= res.total ? '已加载所有项目' : '向下翻以加载更多';
  180. // console.log(_this.list);
  181. });
  182. },
  183. // 刷新清空列表
  184. async refreshList() {
  185. this.page = 1;
  186. this.total = 2;
  187. this.list = [];
  188. await this.fetchList();
  189. },
  190. // 列表下拉
  191. pullDown() {
  192. this.refreshList().then(() => {
  193. this.$refs.list.stopPullDown();
  194. });
  195. },
  196. // 设置搜索条件
  197. async searchChange() {
  198. const result = {};
  199. // 时间查询相关参数
  200. if (this.dateRange) {
  201. result.StartTime = this.dateRange.start;
  202. result.EndTime = this.dateRange.end;
  203. }
  204. // 将其他查询项添加到查询 JSON 中
  205. // this.multipleData = data || {};
  206. console.log(this.queryData)
  207. this.searchData = result;
  208. await this.refreshList();
  209. },
  210. // 点击「清空查询条件」按钮
  211. reset() {
  212. // this.$refs.datefilter.changeDateRange('all');
  213. this.queryData = this.COPY(this.defaultQueryData);
  214. this.searchChange();
  215. },
  216. // 点击「编辑」、「查看」、「添加」、「删除」按钮
  217. async action(type, id = '') {
  218. switch (type) {
  219. case 'view':
  220. this.NAV_TO('./from', {type: 'view', keyValue: id}, true);
  221. return;
  222. case 'add':
  223. this.NAV_TO('./from', {type: 'add'}, true);
  224. return;
  225. case 'delete':
  226. if (!(await this.CONFIRM('删除项目', '确定要删除该数据吗?', true))) {
  227. return;
  228. }
  229. this.LOADING('删除数据中…');
  230. // _this.HIDE_LOADING();
  231. this.HTTP_POST('learun/PersonnelManagement/EpidemicSituationCopy/delete', id, '删除失败').then(success => {
  232. if (!success) {
  233. return;
  234. }
  235. this.HIDE_LOADING();
  236. this.TOAST('删除成功', 'success');
  237. this.refreshList();
  238. });
  239. return;
  240. default:
  241. return;
  242. }
  243. },
  244. // 显示列表中的标题项
  245. displayListItem(item, field) {
  246. const fieldItem = this.scheme[field];
  247. const value = item[field];
  248. switch (fieldItem.type) {
  249. case 'currentInfo':
  250. case 'organize':
  251. return fieldItem.dataType === 'time' ? value : get(this.GET_GLOBAL(fieldItem.dataType), `${value}.name`, '');
  252. case 'radio':
  253. case 'select':
  254. const selectItem = this.dataSource[field].find(t => t.value === String(value));
  255. return get(selectItem, 'text', '');
  256. case 'checkbox':
  257. if (!value || value.split(',').length <= 0) {
  258. return '';
  259. }
  260. const checkboxItems = value.split(',');
  261. return this.dataSource[field]
  262. .filter(t => checkboxItems.includes(t.value))
  263. .map(t => t.text)
  264. .join(',');
  265. case 'datetime':
  266. if (!value) {
  267. return '';
  268. }
  269. return moment(value).format(Number(fieldItem.dateformat) === 0 ? 'YYYY年 M月 D日' : 'YYYY-MM-DD HH:mm');
  270. default:
  271. return value === null || value === undefined ? '' : value;
  272. }
  273. }
  274. }
  275. };
  276. </script>
  277. <style lang="less" scoped>
  278. @import '~@/common/css/sidepage.less';
  279. @import '~@/common/css/customlist.less';
  280. @import '~@/common/css/common.less';
  281. .records {
  282. display: inline-block;
  283. width: 16px;
  284. height: 16px;
  285. background-color: @pubColor;
  286. border-radius: 50%;
  287. color: #fff;
  288. font-size: 12px;
  289. line-height: 16px;
  290. text-align: center;
  291. margin: 0 5px;
  292. }
  293. .listBtn{
  294. background-color: @pubColor;
  295. border-radius: 3px;
  296. display: inline-block;
  297. padding: 3px 10px;
  298. color: #fff;
  299. margin-top: 5px;
  300. }
  301. </style>