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.
 
 
 
 
 
 

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