index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="报告编号" prop="reportNumber">
  5. <el-input
  6. v-model="queryParams.reportNumber"
  7. placeholder="请输入报告编号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="送检单位" prop="inspectName">
  14. <el-input
  15. v-model="queryParams.inspectName"
  16. placeholder="请输入送检单位"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item label="样品名称" prop="sampleName">
  23. <el-input
  24. v-model="queryParams.sampleName"
  25. placeholder="请输入样品名称"
  26. clearable
  27. size="small"
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item label="委托单位" prop="entrustName">
  32. <el-input
  33. v-model="queryParams.entrustName"
  34. placeholder="请输入委托单位"
  35. clearable
  36. size="small"
  37. @keyup.enter.native="handleQuery"
  38. />
  39. </el-form-item>
  40. <el-form-item label="是否合格" prop="isQualify">
  41. <el-select v-model="queryParams.isQualify" placeholder="请选择是否合格" clearable size="small">
  42. <el-option
  43. v-for="dict in dict.type.sys_yes_no"
  44. :key="dict.value"
  45. :label="dict.label"
  46. :value="dict.value"
  47. />
  48. </el-select>
  49. </el-form-item>
  50. <el-form-item>
  51. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  52. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  53. </el-form-item>
  54. </el-form>
  55. <el-row :gutter="10" class="mb8">
  56. <el-col :span="1.5">
  57. <el-button
  58. type="success"
  59. plain
  60. icon="el-icon-edit"
  61. size="mini"
  62. :disabled="single"
  63. @click="handleUpdate"
  64. v-hasPermi="['system:reportDetail:edit']"
  65. >修改</el-button>
  66. </el-col>
  67. <el-col :span="1.5">
  68. <el-button
  69. type="danger"
  70. plain
  71. icon="el-icon-delete"
  72. size="mini"
  73. :disabled="multiple"
  74. @click="handleDelete"
  75. v-hasPermi="['system:reportDetail:remove']"
  76. >删除</el-button>
  77. </el-col>
  78. <el-col :span="1.5">
  79. <el-button
  80. type="warning"
  81. plain
  82. icon="el-icon-download"
  83. size="mini"
  84. @click="handleExport"
  85. v-hasPermi="['system:reportDetail:export']"
  86. >导出</el-button>
  87. </el-col>
  88. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  89. </el-row>
  90. <el-table v-loading="loading" :data="reportDetailList" @selection-change="handleSelectionChange" :max-height="tableMaxHeight">
  91. <el-table-column fixed type="selection" width="55" align="center" />
  92. <!-- <el-table-column label="报告ID" align="center" prop="reportId" /> -->
  93. <el-table-column fixed label="报告编号" align="center" prop="reportNumber" width="220"/>
  94. <el-table-column label="样品名称" align="center" prop="sampleName" width="180px" />
  95. <el-table-column label="送检单位名称" align="center" prop="inspectName" width="180px"/>
  96. <el-table-column label="委托单位名称" align="center" prop="entrustName" width="180px"/>
  97. <el-table-column label="报告图片" align="center" prop="reportUrl" width="180px">
  98. <template slot-scope="scope">
  99. <img @click="imagew(scope.row.reportUrl)" :src="defaultSettings.urls + '/prod-api' + scope.row.reportUrl"
  100. style="width: 120px;height: 120px;" v-if="scope.row.reportUrl !== null" />
  101. <span v-else>暂无数据</span>
  102. </template>
  103. </el-table-column>
  104. <el-table-column label="二维码" align="center" prop="qrPath" width="180px" >
  105. <template slot-scope="scope">
  106. <img @click="imagew(scope.row.qrPath)" :src="defaultSettings.urls + '/prod-api' + scope.row.qrPath"
  107. style="width: 120px;height: 120px;" v-if="scope.row.qrPath !== null" />
  108. <span v-else>暂无数据</span>
  109. </template>
  110. </el-table-column>
  111. <el-table-column label="提交时间" align="center" prop="createTime" width="160px"/>
  112. <el-table-column label="是否合格" align="center" prop="isQualify" width="100px">
  113. <template slot-scope="scope">
  114. <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.isQualify"/>
  115. </template>
  116. </el-table-column>
  117. <!-- <el-table-column label="是否删除" align="center" prop="isDel">
  118. <template slot-scope="scope">
  119. <dict-tag :options="dict.type.is_del" :value="scope.row.isDel"/>
  120. </template>
  121. </el-table-column> -->
  122. <el-table-column label="备注" align="center" prop="remark" width="120px"/>
  123. <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="120px">
  124. <template slot-scope="scope">
  125. <el-button
  126. size="mini"
  127. type="text"
  128. icon="el-icon-edit"
  129. @click="handleUpdate(scope.row)"
  130. v-hasPermi="['system:reportDetail:edit']"
  131. >修改</el-button>
  132. <el-button
  133. size="mini"
  134. type="text"
  135. icon="el-icon-delete"
  136. @click="handleDelete(scope.row)"
  137. v-hasPermi="['system:reportDetail:remove']"
  138. >删除</el-button>
  139. </template>
  140. </el-table-column>
  141. </el-table>
  142. <pagination
  143. v-show="total>0"
  144. :total="total"
  145. :page.sync="queryParams.pageNum"
  146. :limit.sync="queryParams.pageSize"
  147. @pagination="getList"
  148. />
  149. <!-- 添加或修改报告信息对话框 -->
  150. <el-dialog :title="title" :visible.sync="open" width="700px" append-to-body>
  151. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  152. <el-row>
  153. <el-col :span="12">
  154. <el-form-item label="报告编号" prop="reportNumber" >
  155. <el-input v-model="form.reportNumber" placeholder="请输入报告编号" />
  156. </el-form-item>
  157. </el-col>
  158. <el-col :span="12">
  159. <el-form-item label="样品名称" prop="sampleName">
  160. <el-input v-model="form.sampleName" placeholder="请输入样品名称" disabled />
  161. </el-form-item>
  162. </el-col>
  163. <el-col :span="12">
  164. <el-form-item label="送检单位名称" prop="inspectName" >
  165. <el-input v-model="form.inspectName" placeholder="请输入送检单位名称" disabled/>
  166. </el-form-item>
  167. </el-col>
  168. <el-col :span="12">
  169. <el-form-item label="委托单位名称" prop="entrustName" >
  170. <el-input v-model="form.entrustName" placeholder="请输入委托单位名称" disabled/>
  171. </el-form-item>
  172. </el-col>
  173. <el-col :span="12">
  174. <el-form-item label="是否合格" prop="isQualify" >
  175. <el-select v-model="form.isQualify" placeholder="请选择是否合格" disabled>
  176. <el-option
  177. v-for="dict in dict.type.sys_yes_no"
  178. :key="dict.value"
  179. :label="dict.label"
  180. :value="dict.value"
  181. ></el-option>
  182. </el-select>
  183. </el-form-item>
  184. </el-col>
  185. <el-col :span="12">
  186. <el-form-item label="备注" prop="remark" >
  187. <el-input v-model="form.remark" placeholder="请输入备注" />
  188. </el-form-item>
  189. </el-col>
  190. <el-col :span="24">
  191. <el-form-item label="报告图片" prop="reportUrl">
  192. <imageUpload v-model="form.reportUrl" />
  193. <!-- <el-input v-model="form.reportUrl" placeholder="请输入报告图片" /> -->
  194. </el-form-item>
  195. </el-col>
  196. <el-col :span="12">
  197. <el-form-item label="二维码地址" prop="qrPath" >
  198. <!-- <el-input v-model="form.qrPath" placeholder="请输入二维码地址" /> -->
  199. <img :src="defaultSettings.urls + form.qrPath" alt="" style="width: 146px; height: 146px;">
  200. </el-form-item>
  201. </el-col>
  202. </el-row>
  203. </el-form>
  204. <div slot="footer" class="dialog-footer">
  205. <el-button type="primary" @click="submitForm">确 定</el-button>
  206. <el-button @click="cancel">取 消</el-button>
  207. </div>
  208. </el-dialog>
  209. <el-dialog title="图片预览" :visible.sync="opende" width="1000px" append-to-body style="text-align: center;">
  210. <img :src="defaultSettings.urls + '/prod-api' + urls" style="width: 80%;" >
  211. </el-dialog>
  212. </div>
  213. </template>
  214. <script>
  215. import { listReportDetail, getReportDetail, delReportDetail, addReportDetail, updateReportDetail } from "@/api/system/reportDetail";
  216. const defaultSettings = require("@/settings.js");
  217. export default {
  218. name: "ReportDetail",
  219. dicts: ['sys_yes_no', 'is_del'],
  220. data() {
  221. return {
  222. // 遮罩层
  223. loading: true,
  224. defaultSettings,
  225. // 选中数组
  226. ids: [],
  227. // 非单个禁用
  228. single: true,
  229. // 非多个禁用
  230. multiple: true,
  231. urls:'',
  232. // 显示搜索条件
  233. showSearch: true,
  234. // 总条数
  235. total: 0,
  236. // 报告信息表格数据
  237. reportDetailList: [],
  238. // 弹出层标题
  239. title: "",
  240. // 是否显示弹出层
  241. open: false,
  242. opende:false,
  243. // 查询参数
  244. queryParams: {
  245. pageNum: 1,
  246. pageSize: 10,
  247. reportNumber: null,
  248. sampleName: null,
  249. inspectName: null,
  250. entrustName: null,
  251. isQualify: null,
  252. },
  253. // 表单参数
  254. form: {},
  255. // 表单校验
  256. rules: {
  257. reportNumber: [
  258. { required: true, message: "报告编号不能为空", trigger: "blur" }
  259. ],
  260. sampleName: [
  261. { required: true, message: "样品名称不能为空", trigger: "blur" }
  262. ],
  263. isQualify: [
  264. { required: true, message: "是否合格不能为空", trigger: "change" }
  265. ],
  266. reportUrl: [
  267. { required: true, message: "报告图片不能为空", trigger: "blur" }
  268. ],
  269. },
  270. tableMaxHeight:300
  271. };
  272. },
  273. created() {
  274. this.getList();
  275. window.onresize = () => {
  276. this.changeTableMaxHeight()
  277. }
  278. this.changeTableMaxHeight()
  279. },
  280. destroyed () {
  281. window.onresize = null
  282. },
  283. mounted() {
  284. window.onresize = () => {
  285. this.changeTableMaxHeight()
  286. }
  287. this.changeTableMaxHeight()
  288. },
  289. methods: {
  290. /** 查询报告信息列表 */
  291. getList() {
  292. this.loading = true;
  293. listReportDetail(this.queryParams).then(response => {
  294. this.reportDetailList = response.rows;
  295. this.total = response.total;
  296. this.loading = false;
  297. });
  298. },
  299. // 取消按钮
  300. cancel() {
  301. this.open = false;
  302. this.opende = false
  303. this.reset();
  304. },
  305. // 表单重置
  306. reset() {
  307. this.form = {
  308. reportId: null,
  309. reportNumber: null,
  310. inspectId: null,
  311. sampleName: null,
  312. inspectName: null,
  313. entrustName: null,
  314. isQualify: null,
  315. reportUrl: null,
  316. qrPath: null,
  317. isDel: null,
  318. createBy: null,
  319. createTime: null,
  320. updateBy: null,
  321. updateTime: null,
  322. remark: null
  323. };
  324. this.resetForm("form");
  325. },
  326. /** 搜索按钮操作 */
  327. handleQuery() {
  328. this.queryParams.pageNum = 1;
  329. this.getList();
  330. },
  331. /** 重置按钮操作 */
  332. resetQuery() {
  333. this.resetForm("queryForm");
  334. this.handleQuery();
  335. },
  336. // 多选框选中数据
  337. handleSelectionChange(selection) {
  338. this.ids = selection.map(item => item.reportId)
  339. this.single = selection.length!==1
  340. this.multiple = !selection.length
  341. },
  342. /** 新增按钮操作 */
  343. handleAdd() {
  344. this.reset();
  345. this.open = true;
  346. this.title = "添加报告信息";
  347. },
  348. /** 修改按钮操作 */
  349. handleUpdate(row) {
  350. this.reset();
  351. const reportId = row.reportId || this.ids
  352. getReportDetail(reportId).then(response => {
  353. this.form = response.data;
  354. this.open = true;
  355. this.title = "修改报告信息";
  356. });
  357. },
  358. /** 提交按钮 */
  359. submitForm() {
  360. this.$refs["form"].validate(valid => {
  361. if (valid) {
  362. if (this.form.reportId != null) {
  363. updateReportDetail(this.form).then(response => {
  364. this.$modal.msgSuccess("修改成功");
  365. this.open = false;
  366. this.getList();
  367. });
  368. } else {
  369. addReportDetail(this.form).then(response => {
  370. this.$modal.msgSuccess("新增成功");
  371. this.open = false;
  372. this.getList();
  373. });
  374. }
  375. }
  376. });
  377. },
  378. /** 删除按钮操作 */
  379. handleDelete(row) {
  380. const reportIds = row.reportId || this.ids;
  381. this.$modal.confirm('是否确认删除报告信息编号为"' + reportIds + '"的数据项?').then(function() {
  382. return delReportDetail(reportIds);
  383. }).then(() => {
  384. this.getList();
  385. this.$modal.msgSuccess("删除成功");
  386. }).catch(() => {});
  387. },
  388. /** 导出按钮操作 */
  389. handleExport() {
  390. this.download('system/reportDetail/export', {
  391. ...this.queryParams
  392. }, `reportDetail_${new Date().getTime()}.xlsx`)
  393. },
  394. // 图片预览列表
  395. imagew(index) {
  396. this.urls = index
  397. this.opende = true
  398. },
  399. // 获取屏幕高度
  400. showFilterForm () {
  401. this.filterActive = !this.filterActive
  402. this.changeTableMaxHeight()
  403. },
  404. changeTableMaxHeight () {
  405. let height = document.body.offsetHeight // 网页可视区域高度
  406. // if (this.filterActive) {
  407. // this.tableMaxHeight = height - 320
  408. // } else {
  409. this.tableMaxHeight = height - 250
  410. // }
  411. console.log(height)
  412. }
  413. }
  414. };
  415. </script>