index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="150px">
  4. <el-form-item label="红外辐射强度[W/Sr]" prop="radiationIntensity">
  5. <el-input
  6. v-model="queryParams.radiationIntensity"
  7. placeholder="请输入红外辐射强度[W/Sr]"
  8. clearable
  9. @keyup.enter.native="handleQuery"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  15. </el-form-item>
  16. </el-form>
  17. <el-row :gutter="10" class="mb8">
  18. <el-col :span="1.5">
  19. <el-button
  20. type="primary"
  21. plain
  22. icon="el-icon-plus"
  23. size="mini"
  24. @click="handleAdd"
  25. v-hasPermi="['data:infraredOut:add']"
  26. >新增</el-button>
  27. </el-col>
  28. <el-col :span="1.5">
  29. <el-button
  30. type="success"
  31. plain
  32. icon="el-icon-edit"
  33. size="mini"
  34. :disabled="single"
  35. @click="handleUpdate"
  36. v-hasPermi="['data:infraredOut:edit']"
  37. >修改</el-button>
  38. </el-col>
  39. <el-col :span="1.5">
  40. <el-button
  41. type="danger"
  42. plain
  43. icon="el-icon-delete"
  44. size="mini"
  45. :disabled="multiple"
  46. @click="handleDelete"
  47. v-hasPermi="['data:infraredOut:remove']"
  48. >删除</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="warning"
  53. plain
  54. icon="el-icon-download"
  55. size="mini"
  56. @click="handleExport"
  57. v-hasPermi="['data:infraredOut:export']"
  58. >导出</el-button>
  59. </el-col>
  60. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  61. </el-row>
  62. <el-table v-loading="loading" :data="infraredOutList" @selection-change="handleSelectionChange">
  63. <el-table-column type="selection" width="55" align="center" />
  64. <el-table-column label="编号" align="center" prop="id" />
  65. <el-table-column label="对应红外输入编号" align="center" prop="infraredInputID" />
  66. <el-table-column label="文件输出" align="center" prop="outputFilePath">
  67. <template slot-scope="scope">
  68. <el-button
  69. size="mini"
  70. type="text"
  71. icon="el-icon-folder-opened"
  72. @click="openFolder(scope.row.outputFilePath)"
  73. v-hasPermi="['data:infraredOut:edit']"
  74. >{{ getFileName(scope.row.outputFilePath) }}
  75. </el-button>
  76. <el-button v-if="scope.row.outputFilePath !== null"
  77. size="mini"
  78. type="text"
  79. icon="el-icon-download"
  80. @click="downloadfile(scope.row.outputFilePath)"
  81. v-hasPermi="['data:infraredOut:edit']"
  82. >{{ getFileName(scope.row.outputFilePath) }}
  83. </el-button>
  84. </template>
  85. </el-table-column>
  86. <el-table-column label="红外辐射强度[W/Sr]" align="center" prop="radiationIntensity" />
  87. <el-table-column label="红外图像" align="center" prop="infraredImagePath">
  88. <template slot-scope="scope">
  89. <el-button
  90. size="mini"
  91. type="text"
  92. @click="openFolder(scope.row.infraredImagePath)"
  93. icon="el-icon-folder-opened"
  94. v-hasPermi="['data:infraredOut:edit']">
  95. {{getFileName(scope.row.infraredImagePath)}}
  96. </el-button>
  97. <el-button v-if="scope.row.infraredImagePath !== null"
  98. size="mini"
  99. type="text"
  100. icon="el-icon-download"
  101. @click="downloadfile(scope.row.infraredImagePath)"
  102. v-hasPermi="['data:infraredOut:edit']"
  103. >{{ getFileName(scope.row.infraredImagePath) }}
  104. </el-button>
  105. <image-preview :src="scope.row.infraredImagePath" :width="30" :height="30" ></image-preview>
  106. </template>
  107. </el-table-column>
  108. <el-table-column label="固体红外辐射强度[W/Sr]" align="center" prop="solidinfraredradiation" />
  109. <el-table-column label="气体红外辐射强度[W/Sr]" align="center" prop="gasinfraredradiation" />
  110. <el-table-column label="红外光谱辐射强度分布图" align="center" prop="infraredspectrumdistribution">
  111. <template slot-scope="scope">
  112. <el-button v-if="scope.row.infraredspectrumdistribution !== null"
  113. size="mini"
  114. type="text"
  115. @click="openFolder(scope.row.infraredspectrumdistribution)"
  116. icon="el-icon-folder-opened"
  117. v-hasPermi="['data:infraredOut:edit']">
  118. {{getFileName(scope.row.infraredspectrumdistribution)}}
  119. </el-button>
  120. <el-button v-if="scope.row.infraredspectrumdistribution !== null"
  121. size="mini"
  122. type="text"
  123. icon="el-icon-download"
  124. @click="downloadfile(scope.row.infraredspectrumdistribution)"
  125. v-hasPermi="['data:infraredOut:edit']"
  126. >{{ getFileName(scope.row.infraredspectrumdistribution) }}
  127. </el-button>
  128. <image-preview v-if="scope.row.infraredspectrumdistribution !== null" :src="scope.row.infraredspectrumdistribution" :width="30" :height="30" ></image-preview>
  129. </template>
  130. </el-table-column>
  131. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  132. <template slot-scope="scope">
  133. <el-button
  134. size="mini"
  135. type="text"
  136. icon="el-icon-edit"
  137. @click="handleUpdate(scope.row)"
  138. v-hasPermi="['data:infraredOut:edit']"
  139. >修改</el-button>
  140. <el-button
  141. size="mini"
  142. type="text"
  143. icon="el-icon-delete"
  144. @click="handleDelete(scope.row)"
  145. v-hasPermi="['data:infraredOut:remove']"
  146. >删除</el-button>
  147. </template>
  148. </el-table-column>
  149. </el-table>
  150. <pagination
  151. v-show="total>0"
  152. :total="total"
  153. :page.sync="queryParams.pageNum"
  154. :limit.sync="queryParams.pageSize"
  155. @pagination="getList"
  156. />
  157. <!-- 添加或修改红外输出对话框 -->
  158. <el-dialog :title="title" :visible.sync="open" width="580px" append-to-body>
  159. <el-form ref="form" :model="form" :rules="rules" label-width="170px">
  160. <el-form-item label="红外输入编号" prop="infraredInputID">
  161. <el-select v-model="form.infraredInputID" placeholder="请输入对应红外输入编号">
  162. <el-option v-for="item in infraredInputOption"
  163. :key="item.id"
  164. :label="item.name"
  165. :value="item.id">
  166. </el-option>
  167. </el-select>
  168. </el-form-item>
  169. <el-form-item label="文件输出" prop="outputFilePath">
  170. <file-upload v-model="form.outputFilePath" :fileType="fileType" :fileSize="2048" :limit="1" />
  171. </el-form-item>
  172. <el-form-item label="红外辐射强度[W/Sr]" prop="radiationIntensity">
  173. <el-input v-model="form.radiationIntensity" placeholder="请输入红外辐射强度[W/Sr]" />
  174. </el-form-item>
  175. <el-form-item label="红外图像" prop="infraredImagePath">
  176. <file-upload v-model="form.infraredImagePath" :fileType="imageType" :fileSize="2048" :limit="1"/>
  177. </el-form-item>
  178. <el-form-item label="固体红外辐射强度[W/Sr]" prop="solidinfraredradiation">
  179. <el-input v-model="form.solidinfraredradiation" placeholder="请输入固体红外辐射强度[W/Sr]" />
  180. </el-form-item>
  181. <el-form-item label="气体红外辐射强度[W/Sr]" prop="gasinfraredradiation">
  182. <el-input v-model="form.gasinfraredradiation" placeholder="请输入气体红外辐射强度[W/Sr]" />
  183. </el-form-item>
  184. <el-form-item label="红外图像" prop="infraredspectrumdistribution">
  185. <file-upload v-model="form.infraredspectrumdistribution" :fileType="imageType" :fileSize="2048" :limit="1"/>
  186. </el-form-item>
  187. </el-form>
  188. <div slot="footer" class="dialog-footer">
  189. <el-button type="primary" @click="submitForm">确 定</el-button>
  190. <el-button @click="cancel">取 消</el-button>
  191. </div>
  192. </el-dialog>
  193. </div>
  194. </template>
  195. <script>
  196. import { listInfraredOut, getInfraredOut, delInfraredOut, addInfraredOut, updateInfraredOut,getFolder } from "@/api/data/infraredOut";
  197. import { getInfraredInputID }from "@/api/data/infraredIn";
  198. export default {
  199. name: "InfraredOut",
  200. data() {
  201. return {
  202. // 遮罩层
  203. loading: true,
  204. // 选中数组
  205. ids: [],
  206. // 非单个禁用
  207. single: true,
  208. // 非多个禁用
  209. multiple: true,
  210. // 显示搜索条件
  211. showSearch: true,
  212. // 总条数
  213. total: 0,
  214. // 红外输出表格数据
  215. infraredOutList: [],
  216. // 弹出层标题
  217. title: "",
  218. // 是否显示弹出层
  219. open: false,
  220. // 查询参数
  221. queryParams: {
  222. pageNum: 1,
  223. pageSize: 10,
  224. infraredInputID:null,
  225. outputFile: null,
  226. outputFilePath: null,
  227. radiationIntensity: null,
  228. infraredImage:null,
  229. infraredImagePath:null,
  230. solidinfraredradiation:null,
  231. gasinfraredradiation:null,
  232. infraredspectrumdistribution:null,
  233. },
  234. // 表单参数
  235. form: {},
  236. // 表单校验
  237. rules: {
  238. infraredInputID: [
  239. { required: true, message: "对应红外输入编号不能为空", trigger: "change" }
  240. ],
  241. outputFilePath:[
  242. { required: true, message: "文件输出不能为空", trigger: "change" }
  243. ],
  244. infraredImagePath:[
  245. { required: true, message: "文件输出不能为空", trigger: "change" }
  246. ],
  247. radiationIntensity: [
  248. {
  249. validator: (rule, value, callback) => {
  250. if (value === '' || value === null) { // 允许空值通过验证
  251. callback();
  252. } else {
  253. const machNumberRegex = /^\d{1,10}(\.\d{1,6})?$/; // 匹配DECIMAL(16,6)格式的正则表达式
  254. if (!machNumberRegex.test(value)) {
  255. callback(new Error('红外辐射强度格式不正确,应为DECIMAL(16,6)格式'));
  256. } else {
  257. callback();
  258. }
  259. }
  260. },
  261. trigger: 'change'
  262. }
  263. ],
  264. solidinfraredradiation: [
  265. {
  266. validator: (rule, value, callback) => {
  267. if (value === '' || value === null) { // 允许空值通过验证
  268. callback();
  269. } else {
  270. const machNumberRegex = /^\d{1,10}(\.\d{1,6})?$/; // 匹配DECIMAL(16,6)格式的正则表达式
  271. if (!machNumberRegex.test(value)) {
  272. callback(new Error('固体红外辐射强度格式不正确,应为DECIMAL(16,6)格式'));
  273. } else {
  274. callback();
  275. }
  276. }
  277. },
  278. trigger: 'change'
  279. }
  280. ],
  281. gasinfraredradiation: [
  282. {
  283. validator: (rule, value, callback) => {
  284. if (value === '' || value === null) { // 允许空值通过验证
  285. callback();
  286. } else {
  287. const machNumberRegex = /^\d{1,10}(\.\d{1,6})?$/; // 匹配DECIMAL(16,6)格式的正则表达式
  288. if (!machNumberRegex.test(value)) {
  289. callback(new Error('气体红外辐射强度格式不正确,应为DECIMAL(16,6)格式'));
  290. } else {
  291. callback();
  292. }
  293. }
  294. },
  295. trigger: 'change'
  296. }
  297. ],
  298. },
  299. infraredInputOption:[],
  300. fileType: ['dat', 'xls', 'jpg', 'png'],
  301. imageType:['jpg','png']
  302. };
  303. },
  304. created() {
  305. this.getList();
  306. this.getOption();
  307. },
  308. methods: {
  309. /** 查询红外输出列表 */
  310. getList() {
  311. this.loading = true;
  312. listInfraredOut(this.queryParams).then(response => {
  313. this.infraredOutList = response.rows;
  314. this.total = response.total;
  315. this.loading = false;
  316. });
  317. },
  318. // 取消按钮
  319. cancel() {
  320. this.open = false;
  321. this.reset();
  322. },
  323. // 表单重置
  324. reset() {
  325. this.form = {
  326. id: null,
  327. infraredInputID:null,
  328. outputFile: null,
  329. outputFilePath: null,
  330. radiationIntensity: null,
  331. infraredImage:null,
  332. infraredImagePath:null,
  333. createBy: null,
  334. createTime: null,
  335. updateBy: null,
  336. updateTime: null,
  337. solidinfraredradiation:null,
  338. gasinfraredradiation:null,
  339. infraredspectrumdistribution:null,
  340. };
  341. this.resetForm("form");
  342. },
  343. /** 搜索按钮操作 */
  344. handleQuery() {
  345. if (this.queryParams.radiationIntensity &&!this.isDecimalFormat(this.queryParams.radiationIntensity)) {
  346. this.$modal.msgError("红外辐射强度格式不正确,请输入DECIMAL(16,6)格式数据");
  347. return;
  348. }
  349. this.queryParams.pageNum = 1;
  350. this.getList();
  351. },
  352. /** 重置按钮操作 */
  353. resetQuery() {
  354. this.resetForm("queryForm");
  355. this.handleQuery();
  356. },
  357. // 多选框选中数据
  358. handleSelectionChange(selection) {
  359. this.ids = selection.map(item => item.id)
  360. this.single = selection.length!==1
  361. this.multiple = !selection.length
  362. },
  363. /** 新增按钮操作 */
  364. handleAdd() {
  365. this.reset();
  366. this.open = true;
  367. this.title = "添加红外输出";
  368. },
  369. /** 修改按钮操作 */
  370. handleUpdate(row) {
  371. this.reset();
  372. const id = row.id || this.ids
  373. getInfraredOut(id).then(response => {
  374. this.form = response.data;
  375. this.open = true;
  376. this.title = "修改红外输出";
  377. });
  378. },
  379. /** 提交按钮 */
  380. submitForm() {
  381. this.$refs["form"].validate(valid => {
  382. if (valid) {
  383. if (this.form.id != null) {
  384. updateInfraredOut(this.form).then(response => {
  385. this.$modal.msgSuccess("修改成功");
  386. this.open = false;
  387. this.getList();
  388. });
  389. } else {
  390. addInfraredOut(this.form).then(response => {
  391. this.$modal.msgSuccess("新增成功");
  392. this.open = false;
  393. this.getList();
  394. });
  395. }
  396. }
  397. });
  398. },
  399. /** 删除按钮操作 */
  400. handleDelete(row) {
  401. const ids = row.id || this.ids;
  402. this.$modal.confirm('是否确认删除红外输出编号为"' + ids + '"的数据项?').then(function() {
  403. return delInfraredOut(ids);
  404. }).then(() => {
  405. this.getList();
  406. this.$modal.msgSuccess("删除成功");
  407. }).catch(() => {});
  408. },
  409. /** 导出按钮操作 */
  410. handleExport() {
  411. this.download('data/infraredOut/export', {
  412. ...this.queryParams
  413. }, `infraredOut_${new Date().getTime()}.xlsx`)
  414. },
  415. getFileName(path) {
  416. if (!path) {
  417. return ''
  418. } else if (path.lastIndexOf("/") > -1) {
  419. const newName = path.slice(path.lastIndexOf("/") + 1)
  420. const names = newName.split(".")
  421. if ((names.size = 2) && (names[0].length > 19)) {
  422. return newName.substring(0, names[0].length - 19) + '.' + names[1]
  423. } else {
  424. return newName
  425. }
  426. } else {
  427. return '';
  428. }
  429. },
  430. downloadfile(path) {
  431. this.$download.resource(path);
  432. },
  433. getOption() {
  434. getInfraredInputID().then(resp=>{this.infraredInputOption = resp.data})
  435. },
  436. openFolder(path){
  437. getFolder(path);
  438. },
  439. isDecimalFormat(value) {
  440. const decimalRegex = /^\d{1,16}(\.\d{1,6})?$/;
  441. return value === '' || decimalRegex.test(value);
  442. }
  443. }
  444. };
  445. </script>