Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

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