index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="报告ID" prop="reportId">
  5. <el-input
  6. v-model="queryParams.reportId"
  7. placeholder="请输入报告ID"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item label="指标ID" prop="indicatorId">
  13. <el-input
  14. v-model="queryParams.indicatorId"
  15. placeholder="请输入指标ID"
  16. clearable
  17. @keyup.enter.native="handleQuery"
  18. />
  19. </el-form-item>
  20. <el-form-item>
  21. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  22. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  23. </el-form-item>
  24. </el-form>
  25. <el-row :gutter="10" class="mb8">
  26. <el-col :span="1.5">
  27. <el-button
  28. type="primary"
  29. plain
  30. icon="el-icon-plus"
  31. size="mini"
  32. @click="handleAdd"
  33. v-hasPermi="['medical:result:add']"
  34. >新增</el-button>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-button
  38. type="success"
  39. plain
  40. icon="el-icon-plus"
  41. size="mini"
  42. @click="handleBatchAdd"
  43. v-hasPermi="['medical:result:add']"
  44. >批量新增</el-button>
  45. </el-col>
  46. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  47. </el-row>
  48. <el-table v-loading="loading" :data="resultList" @selection-change="handleSelectionChange">
  49. <el-table-column type="selection" width="55" align="center" />
  50. <el-table-column label="结果ID" align="center" prop="resultId" />
  51. <el-table-column label="报告ID" align="center" prop="reportId" />
  52. <el-table-column label="指标ID" align="center" prop="indicatorId" />
  53. <el-table-column label="指标名称" align="center" prop="indicatorName" />
  54. <el-table-column label="检查结果" align="center" prop="resultValue" />
  55. <el-table-column label="参考范围" align="center" prop="referenceRange" />
  56. <el-table-column label="单位" align="center" prop="unit" />
  57. <el-table-column label="异常标识" align="center" prop="abnormalFlag">
  58. <template slot-scope="scope">
  59. <dict-tag :options="abnormalFlagOptions" :value="scope.row.abnormalFlag"/>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  63. <template slot-scope="scope">
  64. <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  68. <template slot-scope="scope">
  69. <el-button
  70. size="mini"
  71. type="text"
  72. icon="el-icon-view"
  73. @click="handleDetail(scope.row)"
  74. v-hasPermi="['medical:result:query']"
  75. >详情</el-button>
  76. <el-button
  77. size="mini"
  78. type="text"
  79. icon="el-icon-edit"
  80. @click="handleUpdate(scope.row)"
  81. v-hasPermi="['medical:result:edit']"
  82. >修改</el-button>
  83. <el-button
  84. size="mini"
  85. type="text"
  86. icon="el-icon-delete"
  87. @click="handleDelete(scope.row)"
  88. v-hasPermi="['medical:result:remove']"
  89. >删除</el-button>
  90. </template>
  91. </el-table-column>
  92. </el-table>
  93. <pagination
  94. v-show="total>0"
  95. :total="total"
  96. :page.sync="queryParams.pageNum"
  97. :limit.sync="queryParams.pageSize"
  98. @pagination="getList"
  99. />
  100. <!-- 添加或修改报告指标检查结果对话框 -->
  101. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  102. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  103. <el-form-item label="报告ID" prop="reportId">
  104. <el-input v-model="form.reportId" placeholder="请输入报告ID" />
  105. </el-form-item>
  106. <el-form-item label="指标ID" prop="indicatorId">
  107. <el-input v-model="form.indicatorId" placeholder="请输入指标ID" />
  108. </el-form-item>
  109. <el-form-item label="指标名称" prop="indicatorName">
  110. <el-input v-model="form.indicatorName" placeholder="请输入指标名称" />
  111. </el-form-item>
  112. <el-form-item label="检查结果" prop="resultValue">
  113. <el-input v-model="form.resultValue" placeholder="请输入检查结果" />
  114. </el-form-item>
  115. <el-form-item label="参考范围" prop="referenceRange">
  116. <el-input v-model="form.referenceRange" placeholder="请输入参考范围" />
  117. </el-form-item>
  118. <el-form-item label="单位" prop="unit">
  119. <el-input v-model="form.unit" placeholder="请输入单位" />
  120. </el-form-item>
  121. <el-form-item label="异常标识" prop="abnormalFlag">
  122. <el-select v-model="form.abnormalFlag" placeholder="请选择异常标识">
  123. <el-option
  124. v-for="dict in abnormalFlagOptions"
  125. :key="dict.value"
  126. :label="dict.label"
  127. :value="dict.value"
  128. ></el-option>
  129. </el-select>
  130. </el-form-item>
  131. <el-form-item label="备注" prop="remark">
  132. <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
  133. </el-form-item>
  134. </el-form>
  135. <div slot="footer" class="dialog-footer">
  136. <el-button type="primary" @click="submitForm">确 定</el-button>
  137. <el-button @click="cancel">取 消</el-button>
  138. </div>
  139. </el-dialog>
  140. <!-- 批量新增对话框 -->
  141. <el-dialog title="批量新增检查结果" :visible.sync="batchOpen" width="800px" append-to-body>
  142. <el-form ref="batchForm" :model="batchForm" label-width="80px">
  143. <el-form-item label="报告ID" prop="reportId">
  144. <el-input v-model="batchForm.reportId" placeholder="请输入报告ID" />
  145. </el-form-item>
  146. <el-button type="primary" size="mini" @click="addBatchRow">添加行</el-button>
  147. <el-table :data="batchForm.results" style="margin-top: 10px;">
  148. <el-table-column label="指标ID" width="100">
  149. <template slot-scope="scope">
  150. <el-input v-model="scope.row.indicatorId" size="mini" />
  151. </template>
  152. </el-table-column>
  153. <el-table-column label="指标名称" width="120">
  154. <template slot-scope="scope">
  155. <el-input v-model="scope.row.indicatorName" size="mini" />
  156. </template>
  157. </el-table-column>
  158. <el-table-column label="检查结果" width="100">
  159. <template slot-scope="scope">
  160. <el-input v-model="scope.row.resultValue" size="mini" />
  161. </template>
  162. </el-table-column>
  163. <el-table-column label="参考范围" width="120">
  164. <template slot-scope="scope">
  165. <el-input v-model="scope.row.referenceRange" size="mini" />
  166. </template>
  167. </el-table-column>
  168. <el-table-column label="单位" width="80">
  169. <template slot-scope="scope">
  170. <el-input v-model="scope.row.unit" size="mini" />
  171. </template>
  172. </el-table-column>
  173. <el-table-column label="异常标识" width="100">
  174. <template slot-scope="scope">
  175. <el-select v-model="scope.row.abnormalFlag" size="mini">
  176. <el-option
  177. v-for="dict in abnormalFlagOptions"
  178. :key="dict.value"
  179. :label="dict.label"
  180. :value="dict.value"
  181. ></el-option>
  182. </el-select>
  183. </template>
  184. </el-table-column>
  185. <el-table-column label="操作" width="80">
  186. <template slot-scope="scope">
  187. <el-button type="text" size="mini" @click="removeBatchRow(scope.$index)">删除</el-button>
  188. </template>
  189. </el-table-column>
  190. </el-table>
  191. </el-form>
  192. <div slot="footer" class="dialog-footer">
  193. <el-button type="primary" @click="submitBatchForm">确 定</el-button>
  194. <el-button @click="cancelBatch">取 消</el-button>
  195. </div>
  196. </el-dialog>
  197. <!-- 详情对话框 -->
  198. <el-dialog title="检查结果详情" :visible.sync="detailOpen" width="500px" append-to-body>
  199. <el-descriptions :column="2" border>
  200. <el-descriptions-item label="结果ID">{{ detailData.resultId }}</el-descriptions-item>
  201. <el-descriptions-item label="报告ID">{{ detailData.reportId }}</el-descriptions-item>
  202. <el-descriptions-item label="指标ID">{{ detailData.indicatorId }}</el-descriptions-item>
  203. <el-descriptions-item label="指标名称">{{ detailData.indicatorName }}</el-descriptions-item>
  204. <el-descriptions-item label="检查结果">{{ detailData.resultValue }}</el-descriptions-item>
  205. <el-descriptions-item label="参考范围">{{ detailData.referenceRange }}</el-descriptions-item>
  206. <el-descriptions-item label="单位">{{ detailData.unit }}</el-descriptions-item>
  207. <el-descriptions-item label="异常标识">
  208. <dict-tag :options="abnormalFlagOptions" :value="detailData.abnormalFlag"/>
  209. </el-descriptions-item>
  210. <el-descriptions-item label="创建时间" :span="2">
  211. {{ parseTime(detailData.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}
  212. </el-descriptions-item>
  213. <el-descriptions-item label="备注" :span="2">{{ detailData.remark }}</el-descriptions-item>
  214. </el-descriptions>
  215. <div slot="footer" class="dialog-footer">
  216. <el-button @click="detailOpen = false">关 闭</el-button>
  217. </div>
  218. </el-dialog>
  219. </div>
  220. </template>
  221. <script>
  222. import { listResult, getResult, delResult, addResult, updateResult, batchAddResult, listByReportId, listByIndicatorId } from "@/api/medical/reportIndicator";
  223. export default {
  224. name: "Result",
  225. data() {
  226. return {
  227. // 遮罩层
  228. loading: true,
  229. // 选中数组
  230. ids: [],
  231. // 非单个禁用
  232. single: true,
  233. // 非多个禁用
  234. multiple: true,
  235. // 显示搜索条件
  236. showSearch: true,
  237. // 总条数
  238. total: 0,
  239. // 报告指标检查结果表格数据
  240. resultList: [],
  241. // 弹出层标题
  242. title: "",
  243. // 是否显示弹出层
  244. open: false,
  245. // 是否显示批量新增弹出层
  246. batchOpen: false,
  247. // 是否显示详情弹出层
  248. detailOpen: false,
  249. // 详情数据
  250. detailData: {},
  251. // 异常标识字典
  252. abnormalFlagOptions: [],
  253. // 查询参数
  254. queryParams: {
  255. pageNum: 1,
  256. pageSize: 10,
  257. reportId: null,
  258. indicatorId: null,
  259. },
  260. // 表单参数
  261. form: {},
  262. // 批量表单参数
  263. batchForm: {
  264. reportId: null,
  265. results: [] },
  266. // 表单校验规则
  267. rules: {
  268. reportId: [{ required: true, message: '请输入报告ID', trigger: 'blur' }],
  269. indicatorId: [{ required: true, message: '请输入指标ID', trigger: 'blur' }],
  270. indicatorName: [{ required: true, message: '请输入指标名称', trigger: 'blur' }],
  271. resultValue: [{ required: true, message: '请输入检查结果', trigger: 'blur' }],
  272. referenceRange: [{ required: true, message: '请输入参考范围', trigger: 'blur' }],
  273. unit: [{ required: true, message: '请输入单位', trigger: 'blur' }],
  274. abnormalFlag: [{ required: true, message: '请选择异常标识', trigger: 'change' }],
  275. }
  276. };
  277. },
  278. created() {
  279. this.getList();
  280. this.loadDictData();
  281. },
  282. methods: {
  283. // 加载异常标识字典数据
  284. loadDictData() {
  285. // 这里模拟加载字典数据,实际可以根据项目字典接口替换
  286. this.abnormalFlagOptions = [
  287. { label: '正常', value: '0' },
  288. { label: '异常', value: '1' }
  289. ];
  290. },
  291. // 查询列表
  292. getList() {
  293. this.loading = true;
  294. listResult(this.queryParams).then((res) => {
  295. if (res && res.data) {
  296. this.resultList = res.data.list;
  297. this.total = res.data.total;
  298. }
  299. this.loading = false;
  300. }).catch(() => {
  301. this.loading = false;
  302. });
  303. },
  304. // 重置搜索条件
  305. resetQuery() {
  306. this.queryParams = {
  307. pageNum: 1,
  308. pageSize: 10,
  309. reportId: null,
  310. indicatorId: null,
  311. };
  312. this.getList();
  313. },
  314. // 处理查询按钮点击
  315. handleQuery() {
  316. this.queryParams.pageNum = 1;
  317. this.getList();
  318. },
  319. // 选择项变化
  320. handleSelectionChange(selection) {
  321. this.ids = selection.map(item => item.resultId);
  322. this.single = this.ids.length !== 1;
  323. this.multiple = this.ids.length === 0;
  324. },
  325. // 打开新增弹窗
  326. handleAdd() {
  327. this.title = "新增检查结果";
  328. this.form = {};
  329. this.open = true;
  330. this.$nextTick(() => {
  331. if (this.$refs.form) {
  332. this.$refs.form.resetFields();
  333. }
  334. });
  335. },
  336. // 打开批量新增弹窗
  337. handleBatchAdd() {
  338. this.batchForm = {
  339. reportId: null,
  340. results: []
  341. };
  342. this.batchOpen = true;
  343. },
  344. // 添加批量新增表格行
  345. addBatchRow() {
  346. this.batchForm.results.push({
  347. indicatorId: '',
  348. indicatorName: '',
  349. resultValue: '',
  350. referenceRange: '',
  351. unit: '',
  352. abnormalFlag: '0'
  353. });
  354. },
  355. // 删除批量新增表格行
  356. removeBatchRow(index) {
  357. this.batchForm.results.splice(index, 1);
  358. },
  359. // 取消批量新增
  360. cancelBatch() {
  361. this.batchOpen = false;
  362. },
  363. // 提交批量新增表单
  364. submitBatchForm() {
  365. if (!this.batchForm.reportId) {
  366. this.$message.error('请输入报告ID');
  367. return;
  368. }
  369. if (this.batchForm.results.length === 0) {
  370. this.$message.error('请添加检查结果行');
  371. return;
  372. }
  373. // 给每个结果设置报告ID
  374. this.batchForm.results.forEach(item => {
  375. item.reportId = this.batchForm.reportId;
  376. });
  377. batchAddResult(this.batchForm.results).then(res => {
  378. if (res.code === 200) {
  379. this.$message.success(res.msg || '批量新增成功');
  380. this.batchOpen = false;
  381. this.getList();
  382. } else {
  383. this.$message.error(res.msg || '批量新增失败');
  384. }
  385. });
  386. },
  387. // 提交新增或修改表单
  388. submitForm() {
  389. this.$refs.form.validate((valid) => {
  390. if (valid) {
  391. if (this.form.resultId) {
  392. updateResult(this.form).then(res => {
  393. if (res.code === 200) {
  394. this.$message.success(res.msg || '更新成功');
  395. this.open = false;
  396. this.getList();
  397. } else {
  398. this.$message.error(res.msg || '更新失败');
  399. }
  400. });
  401. } else {
  402. addResult(this.form).then(res => {
  403. if (res.code === 200) {
  404. this.$message.success(res.msg || '新增成功');
  405. this.open = false;
  406. this.getList();
  407. } else {
  408. this.$message.error(res.msg || '新增失败');
  409. }
  410. });
  411. }
  412. }
  413. });
  414. },
  415. // 取消新增或修改
  416. cancel() {
  417. this.open = false;
  418. },
  419. // 查看详情
  420. handleDetail(row) {
  421. getResult(row.resultId).then(res => {
  422. if (res.code === 200) {
  423. this.detailData = res.data;
  424. this.detailOpen = true;
  425. } else {
  426. this.$message.error(res.msg || '获取详情失败');
  427. }
  428. });
  429. },
  430. // 修改
  431. handleUpdate(row) {
  432. this.title = "修改检查结果";
  433. this.form = Object.assign({}, row);
  434. this.open = true;
  435. this.$nextTick(() => {
  436. if (this.$refs.form) {
  437. this.$refs.form.clearValidate();
  438. }
  439. });
  440. },
  441. // 删除
  442. handleDelete(row) {
  443. this.$confirm('确定删除该检查结果吗?', '提示', {
  444. confirmButtonText: '确定',
  445. cancelButtonText: '取消',
  446. type: 'warning'
  447. }).then(() => {
  448. delResult(row.resultId).then(res => {
  449. if (res.code === 200) {
  450. this.$message.success(res.msg || '删除成功');
  451. this.getList();
  452. } else {
  453. this.$message.error(res.msg || '删除失败');
  454. }
  455. });
  456. }).catch(() => {});
  457. }
  458. }
  459. };
  460. </script>